阅读:1733回复:2
后台删除指定来源不可用,自己写 了一个来删除,现在提供源码
使用之前一定要备份数据库并修改安全码,出了问题概不负责!
只做了简单安全验证,使用后请删除文件! 把代码复制下来保证为del.php文件 在浏览器中打开: https://你的网址/del.php?from=要删除的来源&scode=你的安全码 来源请使用播放后辍,一定不要出错 <?php define("SCODE","123456789a"); //安全码 $n = 30; //每次删除条数 $wtime = 2; //等侍时间 $host = "local"; //服务器地址 $user = ""; //数据库用户名 $password = ""; //数据库密码 $db = ""; //数据库名 $from = $_GET['from']; //要删除的播放来源,请使用之前备份数据库,出了问题,概不负责 $scode = $_GET['scode']; if(SCODE<>$scode){ die("验证错误"); } $page = $_GET['page']; $page = isset($page) ? intval($page) : 1; if($page==0) $page=1; $con = mysqli_connect($host,$user,$password); if(!$con){ echo mysqli_error(); } mysqli_select_db($con,$db) or die ("找不到数据库"); mysqli_query($con,"set names utf8"); $where = "where body like '%".$from."%'"; // $sel = "SELECT count(*) FROM `sea_playdata` ".$where; $sql = mysqli_query($con,$sel); $row = mysqli_fetch_array($sql); if(is_array($row)){ $num = $row[0]; }else{ $num = 0; } // if($num == 0){ mysqli_close($con); die("全部搞定"); } $allpage = ceil($num / $n); $sel = "SELECT v_id,body FROM `sea_playdata` ".$where." limit 0,".$n; $sql = mysqli_query($con,$sel); while($row = mysqli_fetch_array($sql)){ $rows[]=$row; } foreach($rows as $key =>$pl){ $list = $pl['body']; $list = explode("$$$",$list); if(is_array($list)){ foreach($list as $key=>$l){ if((preg_match('/'.$from.'/',$l))==1){ array_splice($list,$key,1); } } }else{ array_splice($list,0,1); } $ln = count($list); if($ln>=1){ for($i=1;$i<$ln;$i++){ $playdata .= $list[$i-1]."$$$"; } $playdata=$playdata.$list[$ln-1]; }else{ $playdata = $list[0]; } $updata = "UPDATE `sea_playdata` SET `body`='".$playdata."' WHERE v_id=".$pl['v_id']; mysqli_query($con,$updata); echo "数据ID<span style="color:red;">".$pl['v_id']."</span>的<span style="color:red;">".$from."</span>来源删除成功 "; $playdata=NULL; } echo " 暂停".$wtime."秒后继续<script language=\"javascript\">setTimeout(\"transNextPage();\",".$wtime."*1000);function transNextPage(){location.href='del.php?&from=".$from."&scode=".$scode."';}</script> 还有<span style="color:red;"> ".$allpage." </span>页"; ?> |
|