[PHP] php离线下载服务器 →→→→→进入此内容的聊天室

来自 , 2021-01-22, 写在 PHP, 查看 148 次.
URL http://www.code666.cn/view/78f7d96e
  1. <?php
  2. $user='admin';
  3. $pwd='admin';
  4. $savedir='down';
  5. $savetxt='index.php#sy.txt';
  6. $adminfile=$SCRIPT_NAME;
  7. $act=htmlspecialchars(trim($_GET['act']));
  8. $head='<!DOCTYPE html><html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=GBK"><meta charset="GBK"><title>泷涯离线下载</title><link style="text/css" rel="stylesheet" href="style.css"></head><body>';
  9. $menu='<div id="menu"><h3 id="menu_title"><a href="http://code.worldedit.org" target="_blank">泷涯离线下载</a></h3><ul><li><a href="'.$adminfile.'">管理首页</a></li><li><a href="'.$adminfile.'?act=manage">任务管理</a></li><li><a href="'.$adminfile.'?act=add">新建下载</a></li><li><a href="'.$adminfile.'?act=about">关于</a></li></ul><div class="clear"></div></div>';
  10. $bottom='<div id="footer"><div id="footer_box"><span>Powered by <a href="http://code.worldedit.org" target="_blank">泷涯离线下载</a></span></div></div></body></html>';
  11. if (!is_dir($savedir)) mkdir($savedir);
  12. if (!file_exists($savetxt)) {
  13.         $fp = fopen($savetxt,'wb');
  14.         fwrite($fp,'');
  15.         @fclose($fp);
  16. }
  17. function tips($bodyi,$etype='n') {
  18.         global $head,$menu,$bottom;
  19.         if ($etype=='y') {
  20.                 echo $head.$menu.'<div id="content"><div id="content_box"><div class="admin_page_name">提示</div><div class="table_list post_list">'.$bodyi.'</div></div></div>'.$bottom;
  21.         } else {
  22.                 echo $head.'<div id="content"><div id="content_box"><div class="admin_page_name">提示</div><div class="table_list post_list">'.$bodyi.'</div></div></div>'.$bottom;
  23.         }
  24. }
  25. function show($name) {
  26. switch ($result=get_cfg_var($name)) {
  27.         case 0:
  28.         $result='<font color="red">×</font>';
  29.         break;
  30.         case 1:
  31.         $result='<font color="green">√</font>';
  32.         break;
  33.         default:
  34.         break;
  35. }
  36. return $result;
  37. }
  38. function isfun($funName = '') {
  39. if (!$funName || trim($funName) == '' || preg_match('~[^a-z0-9\_]+~i', $funName, $tmp)) return '错误';
  40. return (false !== function_exists($funName)) ? '<font color="green">√</font>' : '<font color="red">×</font>';
  41. }
  42. if ($_SESSION['login']=='ok') {
  43.         if ($act=='manage') { //任务管理
  44.                 $body='<div id="content"><div id="content_box"><div class="admin_page_name">任务管理</div><div class="table_list post_list"><table colspan="0" rowspan="0" cellpadding="0" cellspacing="0" id="list"><thead><tr><td>名称</td><td style="width:15%">动作</td></tr></thead><tbody>';
  45.                 if (filesize($savetxt)==0) {
  46.                         $body.='<td colspan="4"><center><h3>没有记录,<a href="'.$adminfile.'?act=add">新建一个</a></h3></center></td>';
  47.                 } else {
  48.                         $url=str_replace("\\",'/',dirname(__FILE__));
  49.                         $file=file_get_contents($savetxt);
  50.                         $lines=explode("\n",$file);
  51.                         foreach ($lines as $line) {
  52.                                 $body.='<tr class="alt">';
  53.                                 $i=1;
  54.                                 $keys=explode(',',$line);
  55.                                         foreach ($keys as $key) {
  56.                                                 if ($i==1) $id=$key;
  57.                                                 elseif ($i==2) $name=$key;
  58.                                                 elseif ($i==3) {
  59.                                                         $filename=$key;
  60.                                                         $i=0;
  61.                                                         $body.="<td>$name</td><td><a href=\"$adminfile?act=del&id=$id&name=$name&filename=$filename\" class=\"link_button\">删除</a><a href=\"$savedir/$filename\" class=\"link_button\">下载</a>";
  62.                                                 }
  63.                                                 $i++;
  64.                                         }
  65.                                 $body.='</tr>';
  66.                         }
  67.                 }
  68.                 $body.='<tbody></table></div></div></div></div>';
  69.                 $menu=str_replace("<li><a href=\"$adminfile?act=manage\">任务管理</a></li>","<li class=\"current\"><a href=\"$adminfile?act=manage\">任务管理</a></li>",$menu);
  70.                 $show=TRUE;
  71.         } elseif ($act=='add') { //新建下载
  72.                 $body='<div id="content"><div id="content_box"><div class="admin_page_name">新建下载</div><div class="table_list post_list"><form action="'.$adminfile.'?act=adda" method="post"><center><p><h5>地址:<input type="text" name="iurl" value="http://"/></h5></p><p><h5>名称:<input type="text" name="iname" /></h5></p><p><input type="submit" name="Submit" value="添加" /></p></center></form></div></div></div>';
  73.                 $menu=str_replace("<li><a href=\"$adminfile?act=add\">新建下载</a></li>","<li class=\"current\"><a href=\"$adminfile?act=add\">新建下载</a></li>",$menu);
  74.                 $show=TRUE;
  75.         } elseif ($act=='del') { //删除
  76.                 $id=htmlspecialchars(trim($_GET['id']));
  77.                 $name=htmlspecialchars(trim($_GET['name']));
  78.                 $filename=htmlspecialchars(trim($_GET['filename']));
  79.                 $str=$id.','.$name.','.$filename."\n";
  80.                 $file=file_get_contents($savetxt);
  81.                 $file=str_replace($str,'',$file);
  82.                 $fp=fopen($savetxt,'wb');
  83.                 fwrite($fp,$file);
  84.                 if ($fp) @fclose($fp);
  85.                 @unlink("$savedir/$filename");
  86.                 tips('<h5>删除成功</h5>','y');
  87.                 $show=FALSE;
  88.         } elseif ($act=='adda') { //下载
  89.                 $url=htmlspecialchars(trim($_POST['iurl']));
  90.                 $name=htmlspecialchars(trim($_POST['iname']));
  91.                 if (empty($url)) {
  92.                         tips('<p><center><h5>没有输入地址,点击<a href="javascript:history.back(-1)">这里</a>返回</h5></center></p>');
  93.                 } elseif (empty($name)) {
  94.                         tips('<p><center><h5>没有输入名称,点击<a href="javascript:history.back(-1)">这里</a>返回</h5></center></p>');
  95.                 } else {
  96.                         $dt='.sy';
  97.                         do {
  98.                                 $tmp_name=substr(str_shuffle('abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ'),0,20).$dt;
  99.                         }
  100.                         while (file_exists($savedir.'/'.$tmp_name));
  101.                         $file=file_get_contents($savetxt);
  102.                         $lines=explode("\n",$file);
  103.                         foreach ($lines as $line) {
  104.                                 $body.='<tr class="alt">';
  105.                                 $i=1;
  106.                                 $keys=explode(',',$line);
  107.                                         foreach ($keys as $key) {
  108.                                                 if ($i==1) $id=$key;
  109.                                         }
  110.                                         $i++;
  111.                         }
  112.                         if (empty($id)) $id=1; else $id=$id++;
  113.                         $file=$file.$id.','.$name.','.$tmp_name."\n";
  114.                         $fp=fopen($savetxt,'wb');
  115.                         fwrite($fp,$file);
  116.                         @fclose($fp);
  117.                         $d=fopen($url,'rb');
  118.                         if ($d) {
  119.                                 $b=fopen($savedir.'/'.$tmp_name,'wb');
  120.                                 if ($b) {
  121.                                         while (!feof($d)) {
  122.                                         fwrite($b, fread($d,1024*8),1024*8);
  123.                                         }
  124.                                 }
  125.                         }
  126.                         if ($d) @fclose($d);
  127.                         if ($b) @fclose($b);
  128.                 }
  129.                 tips('<h5>成功添加任务</h5>','y');
  130.                 $show=FALSE;
  131.         } elseif ($act=='delall') { //删除所有
  132.                 $file=file_get_contents($savetxt);
  133.                 $lines=explode("\n",$file);
  134.                 foreach ($lines as $line) {
  135.                         $i=1;
  136.                         $keys=explode(',',$line);
  137.                                 foreach ($keys as $key) {
  138.                                         if ($i==3) {
  139.                                                 @unlink("$savedir/$filename");
  140.                                         }
  141.                                 }
  142.                 }
  143.                 $body.='<tbody></table></div></div></div></div>';
  144.                 $fp=fopen($savetxt,'wb');
  145.                 fwrite($fp,'');
  146.         @fclose($fp);
  147.                 tips('<h5>删除成功</h5>','y');
  148.                 $show=FALSE;
  149.         } elseif ($act=='about') { //关于
  150.                 $body='<div id="content"><div id="content_box"><div class="admin_page_name">关于</div><div class="table_list post_list"><p>这个程序完全开源,大家可以免费使用、学习</p><p>但是,禁止在没有经过作者允许下,篡改、去除版权,如果需要基于此程序开发,需要先联系作者</p><p>泷涯离线下载 ver 1.0 <a href="http://code.worldedit.org">查看最新版</a></p></div></div></div>';
  151.                 $menu=str_replace("<li><a href=\"$adminfile?act=about\">关于</a></li>","<li class=\"current\"><a href=\"$adminfile?act=about\">关于</a></li>",$menu);
  152.                 $show=TRUE;
  153.         } else { //首页
  154.                 $body='<div id="content"><div id="content_box"><div class="admin_page_name">管理首页</div><div class="table_list post_list"><center><p><h5>允许URL打开文件:'.show(allow_url_fopen).'</h5></p><p><h5>Curl支持:'.isfun("curl_init").'</h5></p></center></div></div></div>';
  155.                 $menu=str_replace("<li><a href=\"$adminfile\">管理首页</a></li>","<li class=\"current\"><a href=\"$adminfile\">管理首页</a></li>",$menu);
  156.                 $show=TRUE;
  157.         }
  158.         if ($show) echo $head.$menu.$body.$bottom;
  159. } else {
  160.         if ($_GET['act']=='logincheck') {
  161.                 $inputpwd=md5(trim($_POST['ipwd']));
  162.                 $inputuser=md5(trim($_POST['iuser']));
  163.                 if ($inputpwd==md5($pwd) && $inputuser==md5($user)) {
  164.                         $_SESSION['login']='ok';
  165.                         header('Location:'.$adminfile);
  166.                 } else {
  167.                         tips('<p><h5>啊哦,错了哦</h5></p><p><h6>点击<a href="'.$adminfile.'">这里</a>返回</h6></p>','0');
  168.                 }
  169.         } else {
  170.                 echo '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=GBK"><meta charset="GBK"><title>后台管理</title><style type="text/css">* { font-family:"Microsoft YaHei",Arial; }body { background:#f9f9f9; font-size:14px; }#login_title { text-align:center; width:360px; margin:120px auto; margin-bottom:0px; font-size:32px; color:#333;  text-shadow: 0 2px 0 #FFFFFF;}#login_form { width:360px; margin:0 auto; margin-top:20px; border:solid 1px #e0e0e0; background:#fff; border-radius:3px 3px 3px 3px;}#login_form_box { padding:16px; }#login_form .label { font-weight:bold; padding-bottom:6px; color:#333; }#login_form .textbox input { border:none; padding:0; font-size:24px; width:312px; color:#333; }#login_form .textbox { border:1px solid #e0e0e0; padding:6px; margin-bottom:20px; border-radius:3px 3px 3px 3px; }#login_form .bottom { text-align:right; }#login_form .button { padding:8px 16px; font-size:14px; }</style></head><body><form action="'.$adminfile.'?act=logincheck" method="post">  <div id="login_title">泷涯离线下载</div><div id="login_form"><div id="login_form_box"><div class="label">用户名</div><div class="textbox"><input name="iuser" type="text"></div><div class="label">密码</div><div class="textbox"><input name="ipwd" type="password"></div><div class="bottom"><input name="login" type="submit" value="登录" class="button"></div></div></div></form></body></html>';
  171.         }
  172. }
  173. ?>

回复 "php离线下载服务器"

这儿你可以回复上面这条便签

captcha