dedecms qq咨询平均分配
qq后台页: qq_admin.php
1 <style type="text/css"> 2 <!-- 3 * {margin:0; padding:0;} 4 .wrap { width:250px; margin:5px;} 5 .wrap h4 { line-height:30px; border-bottom:1px solid #993300; margin-bottom:5px;} 6 .wrap label{ display:inline-block; width:80px; line-height:25px;} 7 8 .tables { background:#999;text-align:center; border-collapse:separate;border-spacing:1px; margin:10px 0 10px 10px;} 9 .tables td {background:#fff; padding:0 8px; line-height:25px;} 10 .tables th { padding:0 16px; background:#66cc99;} 11 --> 12 </style> 13 <?php 14 require_once(dirname(__FILE__).'/config.php'); 15 16 $sqlm="select * from qqslink"; 17 $dsql->SetQuery($sqlm); 18 $dsql->Execute(); 19 20 echo "<table class='tables'>"; 21 echo "<tr><th>id</th><th>qq</th><th>name</th><th>点击数</th><th>状态</th><th>Delete</th><th>Change</th></tr>"; 22 while($row=$dsql->GetArray()){ 23 if($row['state']==1){ 24 $sta="正常"; 25 }else{ 26 $sta="<font color='red'>停用</font>"; 27 } 28 echo "<tr><td>$row[id]</td><td>$row[qq]</td><td>$row[name]</td><td>$row[clicks]</td><td>$sta</td><td><a href='qq_admin.php?delid=$row[id]'>删除</a></td><td><a href='qq_admin.php?onoffid=$row[id]&sta=$row[state]'>停用/启用</a></td></tr>"; 29 } 30 echo "</table>"; 31 32 //添加QQ 33 if(!empty($_POST['qq'])){ 34 $sql="insert into qqslink(qq,name,clicks,state) values ('$_POST[qq]','$_POST[name]','$_POST[clicks]','1')"; 35 $res2=$dsql->ExecNoneQuery($sql); 36 //$res2=mysql_query($sql) or die(mysql_error()); 37 if(!$res2){ 38 echo '<script>alert(\'添加失败!\');location.href=\'qq_admin.php\';</script>'; 39 }else{ 40 echo '<script>alert(\'添加成功!\');location.href=\'qq_admin.php\';</script>'; 41 } 42 } 43 44 //删除QQ 45 if(!empty($_GET['delid'])){ 46 $sql3="delete from qqslink where id='$_GET[delid]'"; 47 //$dsql->SetQuery($sql3); 48 $res3=$dsql->ExecNoneQuery($sql3); 49 50 if(!$res3){ 51 echo '<script>alert(\'删除失败!\');location.href=\'qq_admin.php\';</script>'; 52 }else{ 53 echo '<script>alert(\'成功删除!\');location.href=\'qq_admin.php\';</script>'; 54 } 55 } 56 57 //停用启用QQ 58 if(!empty($_GET['onoffid'])){ 59 if($_GET['sta']==1){ 60 //停用 61 $sql4="update qqslink set state='2' where id='$_GET[onoffid]'"; 62 $res4=$dsql->ExecuteNoneQuery($sql4); 63 if(!$res4){ 64 echo '<script>alert(\'操作失败!\');location.href=\'qq_admin.php\';</script>'; 65 }else{ 66 echo '<script>alert(\'操作成功!\');location.href=\'qq_admin.php\';</script>'; 67 } 68 }else{ 69 //启用 70 $sql5="update qqslink set state='1' where id='$_GET[onoffid]'"; 71 $res5=$dsql->ExecuteNoneQuery($sql5); 72 if(!$res5){ 73 echo '<script>alert(\'操作失败!\');location.href=\'qq_admin.php\';</script>'; 74 }else{ 75 echo '<script>alert(\'操作成功!\');location.href=\'qq_admin.php\';</script>'; 76 } 77 } 78 } 79 80 ?> 81 82 <form method="post" action="qq_admin.php"> 83 <table class='tables'> 84 <tr><th colspan='6'>添加QQ</th></tr> 85 <tr><td>QQ号:</td><td><input type="number" name="qq" /></td> 86 <td>咨询员:</td><td><input type="text" name="name" /></td> 87 <td>点击数:</td><td><input type="number" name="clicks" value="0" /></td> 88 </tr> 89 <tr> 90 <td colspan='6'><input type="submit" value="提交" /></td> 91 </tr> 92 </table> 93 </form>
qq请求页:qqindex.php
1 <?php 2 require_once(dirname(__FILE__)."/../include/common.inc.php"); 3 4 if(isset($_COOKIE["qq"])){ 5 $qqid=$_COOKIE["qq"]; 6 }else{ 7 8 $sql="select clicks from qqslink where state=1"; 9 $dsql->SetQuery($sql); 10 $dsql->Execute(); 11 $akarr=array(); 12 while($row=$dsql->GetArray()){ //获取点击数 13 $akarr[]=$row[clicks]; 14 } 15 $minsk=min($akarr); //取得最小点击数 16 $rows=$dsql->GetOne("select id,qq from qqslink where clicks=$minsk and state=1 limit 1"); //取得最小点击数的id和qq 17 18 if($dsql->ExecuteNoneQuery("update qqslink set clicks=clicks+1 where id=$rows[id] and state=1")){ //点击数自加1 19 $qqid=$rows['qq']; 20 } 21 } 22 23 header("location: http://wpa.qq.com/msgrd?v=3&uin=$qqid&site=qq&menu=yes"); 24 setcookie("qq","$qqid",time()+36000); 25 ?>