GetAll($strsql); foreach ($data as $k => $v) { $id = $v['articleid']; $url = "article.php?id=".$id; $title[$v['articleid']] = "".$v['title'].""; $enclitic[$v['articleid']] = $v['enclitic']; } //排名 unset($i, $j, $tmp, $arr_poll_TOP); arsort($arr_poll); //将数组的值由大到小排序 $i = 1; $j = 0; $clicks_TOP = array(); foreach ($arr_poll as $k => $v) { if (is_array($arr_poll_TOP) && count($arr_poll_TOP) > 0) { //考虑排名相同的情况 foreach ($arr_poll_TOP as $v2) { $tmp = explode('|', $v2); $j = $tmp[1]; //上级排名 if ($tmp[0] != $v) { //如果票数一样,沿用上级排名 $j++; $i = $j; } } } $arr_poll_TOP[$k] = $v.'|'.$i; } //排名 END unset($tmp_clicks, $tmp_clicks_sj, $tmp_total, $arr_OK, $arr_enclitic, $arr_top); foreach ($arr_poll_TOP as $k => $v) { $tmp_top = explode('|', $v); $arr_enclitic[] = intval($enclitic[$k]); $arr_top[] = $tmp_top[1]; $arr_OK[] = array('aid'=>$k, 'enclitic'=>intval($enclitic[$k]), 'title'=>$title[$k], 'poll'=>$tmp_top[0], 'top'=>$tmp_top[1]); } array_multisort($arr_top, SORT_NUMERIC, SORT_ASC, $arr_enclitic, SORT_NUMERIC, SORT_ASC, $arr_OK); unset($v); $data_top = ''; foreach ($arr_OK as $v) { $data_top .= " ".str_pad($v['enclitic'], 2, "0", STR_PAD_LEFT).".".$v['title']." ".$v['poll']." ".$v['top']." "; } //网络 END //红花榜 $url = 'http://61.129.77.67:8180/voteAdmin/static?partnerId=7&programId=74&subProgramId=95'; $data = Core_GetVarable($url); $arr = explode("\r\n", $data); foreach ($arr as $v) { $arr2 = explode("#", $v); if (strlen($arr2[0]) == 2) { $enclitic[intval($arr2[0])] = intval($arr2[0]); $title[intval($arr2[0])] = $arr2[1]; $poll[intval($arr2[0])] = intval($arr2[2]); } } //排名 unset($i, $j, $tmp, $arr_poll_TOP); arsort($poll); //将数组的值由大到小排序 $i = 1; $j = 0; $clicks_TOP = array(); foreach ($poll as $k => $v) { if (is_array($arr_poll_TOP) && count($arr_poll_TOP) > 0) { //考虑排名相同的情况 foreach ($arr_poll_TOP as $v2) { $tmp = explode('|', $v2); $j = $tmp[1]; //上级排名 if ($tmp[0] != $v) { //如果票数一样,沿用上级排名 $j++; $i = $j; } } } $arr_poll_TOP[$k] = $v.'|'.$i; } //排名 END unset($tmp_clicks, $tmp_clicks_sj, $tmp_total, $arr_OK, $arr_enclitic, $arr_top); foreach ($arr_poll_TOP as $k => $v) { $tmp_top = explode('|', $v); $arr_enclitic[] = $enclitic[$k]; $arr_top[] = $tmp_top[1]; $arr_OK[] = array('enclitic'=>$enclitic[$k], 'title'=>$title[$k], 'poll'=>$tmp_top[0], 'top'=>$tmp_top[1]); } array_multisort($arr_top, SORT_NUMERIC, SORT_ASC, $arr_enclitic, SORT_NUMERIC, SORT_ASC, $arr_OK); unset($v); $data_top2 = ''; foreach ($arr_OK as $v) { $data_top2 .= " ".str_pad($v['enclitic'], 2, "0", STR_PAD_LEFT).".".$v['title']." ".$v['poll']." ".$v['top']." \n "; } //红花榜 END $smarty->assign('data_top',$data_top); $smarty->assign('data_top2',$data_top2); $smarty->assign('postfix',$postfix); $smarty->display($tpl.'index_lbjqpx.tpl.asp'); } elseif ($act == 'dovote') // 提交投票 { //exit; //开始投票 //if (time() < mktime(0, 0, 0, 10, 23, 2012)) { //mktime格式:时:分:秒 月-日-年 // reExit('投票还没开始!'); //} //截止投票 if (time() >= mktime(0, 0, 0, 5, 13, 2013)) { //mktime格式:时:分:秒 月-日-年 reExit('投票已截止!'); } exit; $arr_artSortid = array(33); // 文章所属分类 $time = time(); $diff_10m = $time - 600; $diff_5m = $time - 300; $diff_1m = $time - 60; $ip = $_SERVER['REMOTE_ADDR']; if (empty($_POST['str_artids'])) { reExit('请选择候选项再提交投票!'); } $arr_artid = explode(',', $_POST['str_artids']); $arr_artid2 = array_unique($arr_artid); $total = count($arr_artid2); if ($total <= 0) { reExit('请选择候选项再提交投票!'); } if ($total > 5) { reExit('一次投票合计不超过5票,您已勾选:'.$total); } $username = htmlspecialchars(trim($_POST['username'])); if (empty($username)) { reExit('请输入ID(称呼)'); } $username = utf2gbk($username); $tel = utf2gbk(htmlspecialchars(trim($_POST['tel']))); if (!preg_match("/^1\d{10}$/", $tel)) { reExit('请输入您11位手机号!'); } if (intval($_SESSION['dgtstiio_'.$postfix]) != 1) { //验证码 unset($_SESSION['dgtstiio_'.$postfix]); reExit('请输入正确的验证码!'); } foreach ($arr_artid2 as $v) { $aid = intval($v); if ($aid <= 0) { reExit('出错 1'); } $artSortid = getSortid($aid); if (!in_array($artSortid, $arr_artSortid)) { reExit('出错 2'); } //一位候选人一分钟内最多只能获得十票,超过则【本次】投票操作无效 $total = $DB->GetOne("SELECT COUNT(*) FROM pa_voteuser WHERE aid='$aid' AND `time`>=".$diff_1m); if ($total >= 50) { reExit('请稍后再投一 1'); } } include($cfg['sys']['WWW_ROOT']."/include/IPLocation.php"); $ipLocation = new IpLocation($cfg['sys']['WWW_ROOT']."/include/qqwry.dat"); $ipData = $ipLocation->getlocation($ip); //限制IP $isgx = (strpos($ipData['country'], '广西') === false) ? 0 : 1; $diff = ($isgx > 0) ? $diff_5m : $diff_10m; $total = $DB->GetOne("SELECT COUNT(*) FROM pa_voteuser WHERE sortid='$voteSortid' AND ip='$ip' AND `time`>=".$diff); if ($total >= 1) { reExit('请稍后再投二 '.$isgx); } unset($v, $total); foreach ($arr_artid2 as $v) { $aid = intval($v); $sql1 = "INSERT pa_voteuser SET sortid='$voteSortid', username='$username', tel='$tel', ip='$ip', isgx='$isgx', time='$time', aid='$aid'"; $DB->query($sql1); $sql2 = "UPDATE pa_article SET poll=poll+1 WHERE articleid='$aid'"; $DB->query($sql2); } unset($_SESSION['dgtstiio_'.$postfix]); reExit('投票成功,感谢您的参与!#http://vote.gxnews.com.cn/2013/lbjqpx/index.php'); } function utf2gbk($str) { return iconv('utf-8', 'gbk', $str); } //提示信息并退出 function reExit($msg) { echo $msg; exit; } //获得分类id function getSortid($articleid) { global $DB; $sortid = $DB->GetOne("SELECT sortid FROM pa_article WHERE articleid='".intval($articleid)."'"); return intval($sortid); } ?>