dedecms qq咨询平均分配

时间:2021-07-01 19:18:41

qq后台页: qq_admin.php

 <style type="text/css">
<!--
* {margin:0; padding:0;}
.wrap { width:250px; margin:5px;}
.wrap h4 { line-height:30px; border-bottom:1px solid #993300; margin-bottom:5px;}
.wrap label{ display:inline-block; width:80px; line-height:25px;} .tables { background:#999;text-align:center; border-collapse:separate;border-spacing:1px; margin:10px 0 10px 10px;}
.tables td {background:#fff; padding:0 8px; line-height:25px;}
.tables th { padding:0 16px; background:#66cc99;}
-->
</style>
<?php
require_once(dirname(__FILE__).'/config.php'); $sqlm="select * from qqslink";
$dsql->SetQuery($sqlm);
$dsql->Execute(); echo "<table class='tables'>";
echo "<tr><th>id</th><th>qq</th><th>name</th><th>点击数</th><th>状态</th><th>Delete</th><th>Change</th></tr>";
while($row=$dsql->GetArray()){
if($row['state']==1){
$sta="正常";
}else{
$sta="<font color='red'>停用</font>";
}
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>";
}
echo "</table>"; //添加QQ
if(!empty($_POST['qq'])){
$sql="insert into qqslink(qq,name,clicks,state) values ('$_POST[qq]','$_POST[name]','$_POST[clicks]','1')";
$res2=$dsql->ExecNoneQuery($sql);
//$res2=mysql_query($sql) or die(mysql_error());
if(!$res2){
echo '<script>alert(\'添加失败!\');location.href=\'qq_admin.php\';</script>';
}else{
echo '<script>alert(\'添加成功!\');location.href=\'qq_admin.php\';</script>';
}
} //删除QQ
if(!empty($_GET['delid'])){
$sql3="delete from qqslink where id='$_GET[delid]'";
//$dsql->SetQuery($sql3);
$res3=$dsql->ExecNoneQuery($sql3); if(!$res3){
echo '<script>alert(\'删除失败!\');location.href=\'qq_admin.php\';</script>';
}else{
echo '<script>alert(\'成功删除!\');location.href=\'qq_admin.php\';</script>';
}
} //停用启用QQ
if(!empty($_GET['onoffid'])){
if($_GET['sta']==1){
//停用
$sql4="update qqslink set state='2' where id='$_GET[onoffid]'";
$res4=$dsql->ExecuteNoneQuery($sql4);
if(!$res4){
echo '<script>alert(\'操作失败!\');location.href=\'qq_admin.php\';</script>';
}else{
echo '<script>alert(\'操作成功!\');location.href=\'qq_admin.php\';</script>';
}
}else{
//启用
$sql5="update qqslink set state='1' where id='$_GET[onoffid]'";
$res5=$dsql->ExecuteNoneQuery($sql5);
if(!$res5){
echo '<script>alert(\'操作失败!\');location.href=\'qq_admin.php\';</script>';
}else{
echo '<script>alert(\'操作成功!\');location.href=\'qq_admin.php\';</script>';
}
}
} ?> <form method="post" action="qq_admin.php">
<table class='tables'>
<tr><th colspan='6'>添加QQ</th></tr>
<tr><td>QQ号:</td><td><input type="number" name="qq" /></td>
<td>咨询员:</td><td><input type="text" name="name" /></td>
<td>点击数:</td><td><input type="number" name="clicks" value="0" /></td>
</tr>
<tr>
<td colspan='6'><input type="submit" value="提交" /></td>
</tr>
</table>
</form>

qq请求页:qqindex.php

 <?php
require_once(dirname(__FILE__)."/../include/common.inc.php"); if(isset($_COOKIE["qq"])){
$qqid=$_COOKIE["qq"];
}else{ $sql="select clicks from qqslink where state=1";
$dsql->SetQuery($sql);
$dsql->Execute();
$akarr=array();
while($row=$dsql->GetArray()){ //获取点击数
$akarr[]=$row[clicks];
}
$minsk=min($akarr); //取得最小点击数
$rows=$dsql->GetOne("select id,qq from qqslink where clicks=$minsk and state=1 limit 1"); //取得最小点击数的id和qq if($dsql->ExecuteNoneQuery("update qqslink set clicks=clicks+1 where id=$rows[id] and state=1")){ //点击数自加1
$qqid=$rows['qq'];
}
} header("location: http://wpa.qq.com/msgrd?v=3&uin=$qqid&site=qq&menu=yes");
setcookie("qq","$qqid",time()+36000);
?>