仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1983|回复: 18
打印 上一主题 下一主题

[学习教程] PHP编程:收费主页办理法式

[复制链接]
若天明 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-16 00:26:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
现在,也有了从事软件工程的想法,在经过了一个月的PHP培训学习之后,发现其实软件工程并没有想像中的那么难。   
  上面的只是一些晋级法式、
  /*list.php3*/
  <?
  session_start();
  require("func.php3");
  connect();
  if (strstr($tpath,".."))
  {echo "不要试图损坏我的站点";exit;}
  If ($user=='')
  {Header("Location: login.php3");}
   
  echo "<head><title>====================================主页空间办理体系2.3====================================</title></head>
  <center><a href=sm.html target=_blank>主页空间办理体系2.3匡助</a>
  ――――<a href="javascript:ShowWin('xgxxxx.php3')">修正用户团体材料</a>――――<a href=logout.php3>加入上岸</a></div></center><br>";
  echo "你好{$user}。";
  if ($bf<>"")
  {
  $date=date(Y).date(m).date(d);
  $backupcommand="e:hubomysqlbinmysqldump --opt -u $user -p{$pass} {$user} >e:homepage\{$user}\{$user}数据库备份.日期{$date}";
  //echo $backupcommand;
  exec($backupcommand) ;
  echo "<font color=red>数据库导出胜利!</font><br>导出文件为:你的主页根目次下:{$user}数据库导出.日期{$date}";
   
  }
  $dbs = mysql_list_dbs();
  $dbcount=mysql_numrows($dbs);
  $flag=0;
  for ($i=0;$i<$dbcount;$i++)
  {
  if ($user==mysql_dbname($dbs, $i))
  {$flag=1;break;}
  }
  if ($flag==0)
  {
  $dbuser=$user;
  $dbpassword=$pass;
  session_register("dbuser");
  session_register("dbpassword");
  echo "您还没有创立本人的数据库。请点击创立数据库按钮,请不要关失落弹出窗口<input type=button value=创立本人的mysql数据库 onclick=window.open("createdb.php3","","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=50,height=50,top=40,left=30"); class=no>";
  }
  else
  {echo "<center><form method=post action=list.php3 >您的数据库已可使用,数据库名为{$user},暗码为上岸暗码,数据库主机为202.106.104.41";
  echo "<input type=hidden name=bf value=true><br><input type=submit value=数据库导出 class=no>
  <input type=button value=数据库导入 class=no onclick=window.open("import.php3","newwin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=270,height=50");>
  </form></center>";
  }
  ?>
   
  <script language="JavaScript">
  function ShowWin(htmlurl){
  var newwin=window.open(htmlurl,"newwin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=350,height=500");
  }
  function ShowWin2(htmlurl){
  var newwin=window.open(htmlurl,"newwin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=250,height=50");
  }
  </script>
   
  <style>
  td{font-size:9pt}
  body{font-size:9pt}
  input { background-color: #FFFFFF; border: 1px #000000 dashed}
  .no { background-color: #D4D0C8}
  .no1 { background-color: #E6F3F7; border-style: none}
  .no2 { background-color: #eeeeee; border-style: none}
  </style>
  <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
  <!--
   
  function button1_onclick()
  {
  form1.remark .value ="shangchuan";
  form1.submit() ;
   
  }
   
  function button2_onclick()
  {
  form1.remark .value ="chuangjian";
  form1.submit() ;
   
  }
   
  function del_onclick()
  {
  if (confirm("你确认要删除这些目次或文件吗?"))
  {
  form2.submit();
  }
  }
  //-->
   
  </SCRIPT>
   
  <?
  $df = diskfreespace("/");
  $freespace=ceil($df/1024/1024);
  echo "<br>磁盘残剩空间:{$freespace}M<BR>";
  if ($tpath=="")
  { $path=$basepath; }
  else if ($tpath=="/")
  {
  if ($basepath<>"/homepage/{$user}")
  {
  $splitpath=explode("/",$basepath);
  for ($i=1;$i<count($splitpath)-1;$i++)
  {$path=$path."/{$splitpath[$i]}";}
  }
  else
  {$path="/homepage/$user";}
   
  }
  else
  { $path=$basepath.$tpath; }
   
  if ($stoppath<>"")
  {$path=$stoppath;}
  if ($directpath<>"")
  {$path=$directpath;}
  //echo "path={$path}"."<br>";
  //echo "basepath:$basepath<br>";
   
  $basepath=$path;
  if (!strstr($basepath,"/homepage/$user"))
  {echo "你上他人的目次干甚么?";exit;}
  session_register("basepath");
  $splitpath=explode("/",$path);
  $newpath="<a href="http://202.106.104.41/zy/{$user}" target=_blank>你的主页</a>";
  for ($i=1;$i<count($splitpath);$i++)
  {
  $temppath=$temppath."/{$splitpath[$i]}";
  if ($i==1)
  {$newpath=$newpath;}
  else if ($i==2)
  {$newpath=$newpath."/<a href=list.php3?directpath=/homepage/$user>根目次</a>";}
  else
  {$newpath=$newpath."/<a href=list.php3?directpath={$temppath}>{$splitpath[$i]}</a>";}
  }
   
  echo $newpath."<br>";
   
  if (!file_exists($path))
  {mkdir($path,0000) or die("目次创立毛病,多是你的用户名里有不法的字符<br>请于<a href=mailto:qdlover@sina.com>站长</a>接洽");}
  chdir($path);
  $handle = opendir(".");
   
  //上传文件
  if ($remark=="shangchuan")
  {
  If($file1 != "none")
  {
  $filesize=ceil(filesize($file1)/1024);
  if ($filesize==0)
  {
  $dx=filesize($file1)."byte";
  }
  else
  {$dx=$filesize."K";}
  copy($file1,"{$path}/{$file1_name}");
  if ($unzip=="true")
  {
  $commandstring="echo a | e:/homepage/pkunzip -d e:{$path}/{$file1_name} e:{$path}/";
  $commandstring=strtr($commandstring,"/","\");
  system($commandstring) ;
  $unzipok="解压胜利!";
  $delcommand=strtr("del e:{$path}/{$file1_name}","/","");
  system($delcommand);
  }
  unlink($file1);
  $sqls="update upfile_user set dx=dx+{$filesize} where username='$user'";
  @mysql_query($sqls);
  echo "<font color=red>文件:".$file1_name."({$dx})";
  if ($unzipok<>"")
  {echo $unzipok;}
  else
  { echo "上传胜利,可以持续上传</font>";}
   
   
  }
  }
  //创立目次
  if ($remark=="chuangjian")
  {
  if (!$dir)
  {echo "<font color=red>创立目次不克不及为空!</font>";}
  else
  {
  if (!file_exists($dir))
  {
  mkdir($dir,0000);
  echo "<font color=red>目次{$dir}创立胜利</font>";
  }
  else
  {
  echo "<font color=red>目次{$dir}已存在</font>";
  }
  }
  }
  //删除文件和目次
  if ($remark=="del")
  {
  for ($i=1;$i<=$count;$i++)
  {
  $check="checkbox".$i;
  if ($$check=="on")
  {
  $del="del".$i;
   
  if (is_dir($$del))
  {rmdir("{$$del}");}
   
  if (is_file($$del))
  {unlink($$del);}
   
  echo "<font color=red>{$$del}被删除</font><br>";
  }
  }
  }
   
   
  while ($file = readdir($handle))
  {
  if (is_dir($file)){$dirlist[]=$file;}
  if (is_file($file)){$filelist[]=$file;}
  }
  closedir($handle);
  ?>
  <body bgcolor="#D0D2E3">
  <form action=list.php3 method=post ENCTYPE="multipart/form-data" name=form1>
  <input type=hidden name=remark value="">
  <table width="0%" cellspacing="0" cellpadding="0" align="center">
  <tr bgcolor="#0066FF">
  <td bgcolor="#3366FF">
  <div align="center"><font color="#FFFFFF"><b>文件上传</b></font></div>
  </td>
  <td bgcolor="#D0D2E3">        </td>
  <td bgcolor="#3366FF">
  <div align="center"><font color="#FFFFFF"><b>创立目次</b></font></div>
  </td>
  </tr>
  <tr>
  <td>
  <input type=file name=file1>
  <input type=button value=上传 name="button1" id="button1" class=no>
  </td>
  <td bgcolor="#D0D2E3" rowspan="2">        </td>
  <td rowspan="2" valign="top">
  <input type="text" name="dir">
  <input type="button" name="button2" id="button2" value="创立" class=no>
  </td>
  </tr>
  <tr>
  <td>
  <input type="checkbox" name="unzip" value="true" style="background-color:#D0D2E3;border-style: none">
  主动解压zip文件(包含途径) </td>
  </tr>
  </table>
  <input type=hidden name=stoppath value=<?echo $path;?>>
  </form>
  <form method="post" action="list.php3" name=form2>
  <table width="95%" border="0" cellspacing="0" cellpadding="0">
  <tr>
  <td>
  <div align="left">
  <input type=hidden name="remark" value="del">
  <input type=hidden name=stoppath value=<?echo $path;?>>
  <input type="button" name="del" value="删除" class=no>
  </div>
  </td>
  <td> </td>
  </tr>
  </table>
  <table width="100%" border="1" cellspacing="1" cellpadding="3" bordercolor="#666666">
  <tr bgcolor="#CCCCCC">
  <td width="1%" nowrap>
  <div align="center">选定</div>
  </td>
  <td width="25%" nowrap>
  <div align="center">文件名</div>
  </td>
  <td nowrap>
  <div align="center">更名</div>
  </td>
  <td width="21%" nowrap>
  <div align="center">文件类型</div>
  </td>
  <td width="21%" nowrap>
  <div align="center">文件尺寸</div>
  </td>
  <td width="32%" nowrap>
  <div align="center">最初修正日期</div>
  </td>
  </tr>
  <?
  $count=0;
  if ($dirlist)
  {
  asort($dirlist);
  for ($i=0;$i<count($dirlist);$i++)
  {
  $count++;
  $filename=$dirlist[$i];
  if ($filename=="abcdefghijk")
  {
  $sqls="update upfile_user set ph=ph+1,ptime=now() where username='$user'";
  @mysql_query($sqls);
  echo "<center><Font color=red>不要试图损坏我的硬盘。你的上岸已有效了,你的行动或许是有意的,可是你的行动已被纪录在案。
  <br>注重,不要到你的目次以上,假如损坏次数超越了10次你的账号将被作废。</font></center>";
  $user="";
  session_register("user");
  exit;}
  if ($filename<>".")
  {
  if ($filename=="..")
  {
  if ($path=="/homepage/{$user}")
  {$tfilename="根目次";$rename=" ";}
  else
  {$filename="上一级目次";$tfilename="<a href=list.php3?tpath=/>{$filename}</a>";$rename=" ";}
  }
  else
  {$tfilename="<a href=list.php3?tpath=/$filename>{$filename}</a>";$rename="<a href=javascript:ShowWin2("rename.php3?name={$filename}&lx=dir")>更名</a>";}
  $filetype="目次";
  $filesize="无";
  $lasttime=date("Y年m月d日H:i:s",filectime($dirlist[$i]));
   
  echo "<tr bgcolor="#E6F3F7">
  <td width=1%>
  <div align=center>
  <input type=checkbox name=checkbox{$count} class=no1>
  <input type=hidden name=del{$count} value={$filename}>
  </div>
  </td>
  <td width=25%>
  <div align=center>{$tfilename}</div>
  </td>
  <td nowrap>
  <div align=center>$rename</div>
  </td>
  <td width=21%>
  <div align=center>{$filetype}</div>
  </td>
  <td width=21%>
  <div align=center>{$filesize}</div>
  </td>
  <td width=32%>
  <div align=center>{$lasttime}</div>
  </td>
  </tr>
  ";
  }
  }
  }
  if ($filelist)
  {
  $splitpath=explode("/",$path);
  for ($i=3;$i<count($splitpath);$i++)
  {
  $temp=$temp."/{$splitpath[$i]}";
  }
   
   
   
   
  asort($filelist);
  for ($i=0;$i<count($filelist);$i++)
  {
  $count++;
  $filename=$filelist[$i];
  $tfilename="<a href="http://202.106.104.41/zy/$user$temp/{$filename}" target=_blank>{$filename}</a>";
  $filetype=strtolower(substr(($filelist[$i]),-4));
   
  if ($filetype==".txt")
  {$filetype="文本文件";
  $editname="――<a href=javascript:ShowWin("edit.php3?path=$temp&file={$filename}")>手工编纂</a>";
  }
   
  else if ($filetype=="html" || $filetype==".htm")
  {$filetype="超文本文件";
  $editname="――<a href=javascript:ShowWin("edit.php3?path=$temp&file={$filename}")>手工编纂</a>";
  }
  else if ($filetype==".jpg" || $filetype==".gif")
  {$filetype="图象文件";
  $editname="";}
  else if ($filetype==".zip" || $filetype==".rar")
  {$filetype="紧缩文件";$editname="";}
  else if ($filetype==".swf" || $filetype==".fla")
  {$filetype="Flash文件";$editname="";}
  else if ($filetype==".php" || $filetype==".php3")
  {$filetype="PHP文件";
  $tfilename=$tfilename."――<a href=javascript:ShowWin("edit.php3?path=$temp&file=$filename")>手工编纂</a>";
  }
  else if ($filetype==".CSS")
  {$filetype="款式表文件";
  $editname="――<a href=javascript:ShowWin("edit.php3?path=$temp&file=$filename")>手工编纂</a>";
  }
  else if ($filetype==".exe" || $filetype==".com")
  {$filetype="可履行文件";$editname="";}
  else
  {$filetype="未知类型";$editname="";}
  $filesize=filesize($filelist[$i]);
  $lasttime=date("Y年m月d日H:i:s",filectime($filelist[$i]));
  echo "<tr bgcolor="#eeeeee">
  <td width=1%>
  <div align=center>
  <input type=checkbox name=checkbox{$count} class=no2>
  <input type=hidden name=del{$count} value={$filename}>
  </div>
  </td>
  <td width=25%>
  <div align=center>{$tfilename}{$editname}</div>
  </td>
  <td nowrap>
  <div align=center><a href=javascript:ShowWin2("rename.php3?name={$filename}&lx=file")>更名</a></div>
  </td>
  <td width=21%>
  <div align=center>{$filetype}</div>
  </td>
  <td width=21%>
  <div align=center>{$filesize}B</div>
  </td>
  <td width=32%>
  <div align=center>{$lasttime}</div>
  </td>
  </tr>
   
  ";
  }
  }
  ?>
  <input type=hidden name=count value=<?echo $count;?>>
  <tr bgcolor="#CCCCCC">
  <td width="1%" nowrap>
  <div align="center">选定</div>
  </td>
  <td width="25%" nowrap>
  <div align="center">文件名</div>
  </td>
  <td nowrap>
  <div align="center">更名</div>
  </td>
  <td width="21%" nowrap>
  <div align="center">文件类型</div>
  </td>
  <td width="21%" nowrap bgcolor="#CCCCCC">
  <div align="center">文件尺寸</div>
  </td>
  <td width="32%" nowrap>
  <div align="center">最初修正日期</div>
  </td>
  </tr>
  </table>
  </form>
  <?
   
  if ($gg=="")
  {
  $gg="ok";
  session_register("gg");
  require("gg.html");
  }
  ?>
   
  
在相册系统的开发上,因为采用的是团队分工合作方式,更让我明白了在一个团队之中,团队成员之间的交流沟通的重要性,如果没有很好的沟通交流,成员之间的任务没有分配好。
不帅 该用户已被删除
沙发
发表于 2015-2-16 02:05:38 | 只看该作者
写的比较杂,因为我也是个新手,不当至于大家多多指正。
金色的骷髅 该用户已被删除
板凳
发表于 2015-2-27 04:36:25 | 只看该作者
如果你可以写完像留言板这样的程序,那么你可以去一些别人的代码了,
精灵巫婆 该用户已被删除
地板
发表于 2015-3-8 20:21:53 | 只看该作者
说点我烦的低级错误吧,曾经有次插入mysql的时间 弄了300年结果老报错,其实mysql的时间是有限制的,大概是到203X年  具体的记不清啦,囧。
透明 该用户已被删除
5#
发表于 2015-3-16 13:37:05 | 只看该作者
找到的的资料很多都是在论坛里的,需要注册,所以我一般没到一个论坛都注册一个id,所有的id都注册成一样的,这样下次再进来的时候就不用重复注册啦。当然有些论坛的某些资料是需要的付费的。
再见西城 该用户已被删除
6#
发表于 2015-3-21 19:09:45 | 只看该作者
作为一个合格的coder 编码的规范是必须,命名方面我推崇“驼峰法”,另外就是自己写的代码最好要带注释,不然时间长了,就算是自己的代码估计看起来都费事,更不用说别人拉。
谁可相欹 该用户已被删除
7#
发表于 2015-3-22 04:10:50 | 只看该作者
首推的搜索引擎当然是Google大神,其次我比较喜欢 百度知道。不过搜出来的结果往往都是 大家copy来copy去的,运气的的概率很大。
灵魂腐蚀 该用户已被删除
8#
发表于 2015-3-22 22:10:50 | 只看该作者
写的比较杂,因为我也是个新手,不当至于大家多多指正。
飘飘悠悠 该用户已被删除
9#
发表于 2015-3-27 18:09:45 | 只看该作者
曾经犯过一个很低级的错误,我在文件命名的时候用了一个横线\\\\\\\'-\\\\\\\' 号,结果找了好几个小时的错误,事实是命名的时候 是不能用横线 \\\\\\\'-\\\\\\\' 的,应该用的是下划线  \\\\\\\'_\\\\\\\' ;
10#
发表于 2015-4-4 04:08:15 | 只看该作者
使用zendstdio 写代码的的时候,把tab 的缩进设置成4个空格是很有必要的
小魔女 该用户已被删除
11#
发表于 2015-4-6 00:13:43 | 只看该作者
本文当是我的笔记啦,遇到的问题随时填充
海妖 该用户已被删除
12#
发表于 2015-4-15 17:59:24 | 只看该作者
找到的的资料很多都是在论坛里的,需要注册,所以我一般没到一个论坛都注册一个id,所有的id都注册成一样的,这样下次再进来的时候就不用重复注册啦。当然有些论坛的某些资料是需要的付费的。
蒙在股里 该用户已被删除
13#
发表于 2015-4-16 05:02:18 | 只看该作者
写的比较杂,因为我也是个新手,不当至于大家多多指正。
老尸 该用户已被删除
14#
发表于 2015-4-20 22:50:57 | 只看该作者
个人呢觉得,配wamp 最容易漏的一步就是忘了把$PHP$目录下的libmysql.dll拷贝到windows系统目录的system32目录下,还有重启apache。
第二个灵魂 该用户已被删除
15#
发表于 2015-4-29 00:47:35 | 只看该作者
至于模板嘛,各位高人一直以来就是争论不休,我一只小菜鸟就不加入战团啦,咱们新手还是多学点东西的好。
admin 该用户已被删除
16#
发表于 2015-5-4 03:27:12 | 只看该作者
先学习php和mysql,还有css(html语言很简单)我认为现在的效果比以前的方法好。
活着的死人 该用户已被删除
17#
发表于 2015-6-14 18:45:49 | 只看该作者
如果你可以写完像留言板这样的程序,那么你可以去一些别人的代码了,
莫相离 该用户已被删除
18#
发表于 2015-7-7 21:32:39 | 只看该作者
开发工具也会慢慢的更专业,每个公司的可能不一样,但是zend studio是个大伙都会用的。
飘灵儿 该用户已被删除
19#
发表于 2015-7-20 01:39:45 | 只看该作者
个人呢觉得,配wamp 最容易漏的一步就是忘了把$PHP$目录下的libmysql.dll拷贝到windows系统目录的system32目录下,还有重启apache。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-3 22:12

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表