function handle($userInput) { if (parent::handleInput($input, $shortcut)) { return false; } $str = iconv('UTF-8', 'GBK', $userInput); if (!$this->isEnglish($str)) { $url = "http://www.google.com/uds/Gtranslate?callback=google.language.callbacks.id102&context=22&q={translate}&langpair=zh%7Cen&key=notsupplied&v=1.0&nocache=1226926245757"; } else { $url = "http://www.google.com/uds/Gtranslate?callback=google.language.callbacks.id103&context=22&q={translate}&langpair=en%7Czh-CN&key=notsupplied&v=1.0&nocache=1226926245758"; } $url = str_replace('{translate}', urlencode($userInput), $url); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); ob_start(); curl_exec($ch); $content = ob_get_contents(); ob_end_clean(); curl_close($ch); $start = "\"translatedText\":\""; $end = "\""; $posStart = strpos($content, $start) + strlen($start); $posEnd = strpos($content, $end, $posStart); $tmpStr = substr($content, $posStart, $posEnd - $posStart); $tmpStr .= "\n请输入需要翻译的中英文短句"; return $tmpStr . $this->getFooter(); }
public function handle($input) { if (parent::handleInput($input)) { return false; } $url = "http://www.ip138.com:8080/search.asp"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 2); curl_setopt($ch, CURLOPT_POSTFIELDS, "action=mobile&mobile={$input}"); ob_start(); curl_exec($ch); $content = ob_get_contents(); ob_end_clean(); curl_close($ch); $content = iconv('GBK', 'UTF-8', $content); $start = "<TD width=* align=\"center\" class=tdc2>"; $end = "</TD>"; $startPos = 0; $arr = array(); $flag = 0; while ($flag < 3) { $posStart = strpos($content, $start, $startPos) + strlen($start); $posEnd = strpos($content, $end, $posStart); $startPos = $posEnd + strlen($posEnd); $tmpStr = substr($content, $posStart, $posEnd - $posStart); $arr[] = $tmpStr; $flag++; } $mobile = $arr[1] . " " . $arr[2]; if (strstr($mobile, "TML 4.0")) { $mobile = "您输入的信息有误,未能查询到正确的结果"; } return $mobile . $this->getFooter(); }
function handle($input, $shortcut = false) { if (parent::handleInput($input, $shortcut)) { return false; } $content = $input; $content = urlencode($input); $svcUrl = "http://www.dict.cn/{content}.htm"; $svcUrl = str_replace('{content}', $content, $svcUrl); $content = file_get_contents($svcUrl); $content = iconv('gbk', 'utf-8', $content); $start = "<div class=\"mut_jies\">"; $end = "</div>"; $posStart = strpos($content, $start) + strlen($start); $posEnd = strpos($content, $end, $posStart); $dict = substr($content, $posStart, $posEnd - $posStart); $dict = " " . str_replace("<br />", "\n", $dict); $out = "<font color=\"red\"><b>翻译结果:</b></font>\n" . trim($dict) . "\n\n"; $start2 = "<h3>例句与用法:</h3>"; $end2 = "</ol></div>"; $posStart2 = strpos($content, $start2, $posEnd); if (!($posStart2 === false)) { $posEnd2 = strpos($content, $end2, $posStart2); $sub = substr($content, $posStart2 + strlen($start2), $posEnd2 - $posStart2 - strlen($start2) + 1); $sub = strip_tags($sub); $out .= "<font color=\"red\"><b>例句与用法:</b></font>" . $sub; } if (strpos($out, "您要查找的是不是:") > 0) { $out = "<Font Face='楷体' Color='-16744320' Size='10.5'>对不起,系统无法为您翻译该单词:{$userInput}</font>"; } return $out . $this->getFooter('', $shortcut); }
public function handle($input) { if (parent::handleInput($input)) { return false; } $msg = "系统中未发现有关 {$input} 的帮助内容\n"; $msg .= $this->getFooter(); return $msg; }
public function handle($input) { if (parent::handleInput($input)) { return false; } $robotName = $this->extraParam['robotname']; if ($input == 'v') { return "我的名字叫:" . $robotName . "\n" . $this->getFooter(); } return "不支持的指令\n" . $this->getFooter(); }
public function handle($input) { if (parent::handleInput($input)) { return false; } if ($this->getPosition() == 0) { return $this->enterDiscussion($input); } else { if ($input == "l") { return $this->getTips(); } return $this->writeDiscussion($input); } return "不支持的指令\n" . $this->getFooter(); }
public function handle($input) { if (parent::handleInput($input)) { return false; } $url = "http://www1.wst.net.cn/scripts/flex/TodayOnHistory/"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); ob_start(); curl_exec($ch); $content = ob_get_contents(); ob_end_clean(); curl_close($ch); $content = iconv('GBK', 'UTF-8', $content); $start = "<a href='"; $end = "</a>"; $startPos = 0; $arr = array(); $flag = 0; while (1) { $posStart = strpos($content, $start, $startPos) + strlen($start); $posEnd = strpos($content, $end, $posStart); if ($posStart - strlen($start) == 0) { break; } $startPos = $posEnd + strlen($posEnd); $tmpStr = substr($content, $posStart, $posEnd - $posStart); $arr[] = $tmpStr; } array_shift($arr); array_shift($arr); array_shift($arr); array_shift($arr); array_shift($arr); $content = ""; for ($i = 0; $i < count($arr); $i++) { $arr[$i] = substr($arr[$i], strpos($arr[$i], '>') + 1); $content .= $arr[$i] . "\\n"; } return $content . $this->getFooter(); }
public function handle($input) { if (parent::handleInput($input)) { return false; } $str = iconv('utf-8', 'gbk', $input); $url = "http://www.google.cn/search?as_q=tq+{city}&num=1"; $url = str_replace('{city}', urlencode($input), $url); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); ob_start(); curl_exec($ch); $content = ob_get_contents(); ob_end_clean(); curl_close($ch); $start = "<div style=\"padding:5px;float:left\">"; $end = "</div>"; $posStart = strpos($content, $start) + strlen($start); $posEnd = strpos($content, $end, $posStart + 1); $posEnd = strpos($content, $end, $posEnd + 1); $posEnd = strpos($content, $end, $posEnd + 1); $posEnd = strpos($content, $end, $posEnd + 1); $posEnd = strpos($content, $end, $posEnd + 1); $posEnd = strpos($content, $end, $posEnd + 1); $weatherStr = substr($content, $posStart, $posEnd - $posStart); $weatherStr = strip_tags($weatherStr); $content = iconv('gbk', 'utf-8', $weatherStr); $content = mb_ereg_replace('当前', ' 当前', $content); $content = mb_ereg_replace('温度', ' 温度 ', $content); $content = mb_ereg_replace('今日', ' 今日', $content); $content = mb_ereg_replace('周', ' 周', $content); if (strlen($content) > 500) { $content = "无该城市天气信息"; } return $content . $this->getFooter(); }
public function handle($input) { if (parent::handleInput($input)) { return false; } echo "positon=" . $this->getPosition() . "==================================\n"; if ($this->getPosition() == 0) { return $this->enterDiscussion($input); } else { if ($input == "l") { return $this->getTips(); } // Get Count $class_id = $this->getPosition(); $where = "where class_id={$class_id} and verify=1 order by id desc"; if ($this->isAdmin()) { $where = "where class_id={$class_id}"; } $order = "order by id desc"; $sql = "select count(*) as count from fx_discussion {$where}"; $retArr = $this->session->db->fetchQueryAll($sql); $count = $retArr[0]['count']; $perPage = 5; $pages = 1; $currentPage = $this->getPage($class_id); if ($count > $perPage) { $pages = ceil($count / $perPage); } if ($input == 'p') { if ($currentPage > 1) { $currentPage--; $this->setPage($class_id, $currentPage); } return $this->getList($class_id); } else { if ($input == 'n') { echo $currentPage . "***{$pages}********************************" . $this->getPage($class_id) . "\n"; if ($currentPage < $pages) { $currentPage++; $this->setPage($class_id, $currentPage); echo $currentPage . "***********************************" . $this->getPage($class_id) . "\n"; } return $this->getList($class_id); } } if ($this->isAdmin()) { return $this->parseAdmin($input); } } return "不支持的指令\n" . $this->getFooter(); }
public function handleMsg($input, $type = 'text/html') { $time = time(NULL); $buddy_uri = $this->buddyURI; // update buddy last_update_time $sql = "update fx_buddies set last_update_time={$time} where id={$this->buddyID}"; $this->db->execute($sql); $inputEncode = mysql_real_escape_string($input); if (!(strlen($input) == 1 && is_numeric($inputEncode))) { $sql = "insert into fx_incomming_messages(buddy_uri,message,add_time)"; $sql .= " values('{$buddy_uri}','{$inputEncode}','{$time}')"; $this->db->execute($sql); } /*每日积分*/ $msg = '登录'; CommonPlugin::addScore($this->db, $this->buddyID, 1, 10, $msg); if ($handle = opendir('./plugins/provider/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { preg_match_all('/([0-9A-Za-z]*).class.php/', $file, $matches); if (is_array($matches) && count($matches) == 2) { if (isset($matches[1][0]) && $matches[1][0] != 'CommonPlugin') { $pluginName = $matches[1][0]; require_once './plugins/provider/' . $pluginName . '.class.php'; $plugin = new $pluginName($this, 0, ''); if (method_exists($pluginName, 'shortcut')) { $done = false; $body = $plugin->shortcut($input, $done); if ($done) { return FetionEncodeMsg($body); } } } } } } closedir($handle); } // $currentNode = $this->getValue('NODE'); // 已经在plugin空间 if ($this->getStr('PLUGIN') != "") { $currentPlugin = $this->getStr('PLUGIN'); if (in_array($this->buddyURI, $this->testNoArr)) { $currentMenu = $this->db->fetchQueryAll('select * from fx_menus where id=' . $currentNode . ' order by s_order,id'); } else { $currentMenu = $this->db->fetchQueryAll('select * from fx_menus where disabled=0 and id=' . $currentNode . ' order by s_order,id'); } $this->currentMenu = $currentMenu[0]; $parentID = 0; $extraPara = ""; if (count($currentMenu) == 1) { $parentID = $currentMenu[0]['p_id']; $extraPara = $currentMenu[0]['extra_param']; } require_once './plugins/provider/' . $currentPlugin . '.class.php'; $plugin = new $currentPlugin($this, $parentID, $extraPara); $body = $plugin->handle($input); if ($body) { return FetionEncodeMsg($body); } else { return $this->getCurrentMenu(); } } else { // 顶级页面的帮助和建议 if ($currentNode == 0 && ($input == '?' || $input == 'j' || $input == 'J')) { $pluginName = $input == '?' ? 'Help' : 'Advice'; require_once './plugins/provider/' . $pluginName . '.class.php'; $plugin = new $pluginName($this, 0, ""); $body = $plugin->getTips(); $this->set('PLUGIN', $pluginName); return FetionEncodeMsg($body); } else { if ($currentNode > 0 && ($input == 'm' || $input == 'q')) { if ($input == 'm') { $this->set('NODE', 0); $this->set('PLUGIN', ''); } if ($input == 'q') { $currentMenu = $this->db->fetchQueryAll('select * from fx_menus where id=' . $currentNode); $this->set('NODE', $currentMenu[0]['p_id']); $this->set('PLUGIN', ''); } return $this->getCurrentMenu(); } } } if (in_array($this->buddyURI, $this->testNoArr)) { $menuList = $this->db->fetchQueryAll('select * from fx_menus where p_id=' . $currentNode . ' order by s_order,id'); } else { $menuList = $this->db->fetchQueryAll('select * from fx_menus where disabled=0 and p_id=' . $currentNode . ' order by s_order,id'); } $key = 1; for ($i = 0; $i < count($menuList); $i++) { switch ($menuList[$i]['c_type']) { case 1: if ($key == $input) { $this->set('NODE', $menuList[$i]['id']); return $this->getCurrentMenu(); } $key++; break; } } return "您的输入错误!请重新输入!\n" . $this->getCurrentMenu(); }
public function handle($input) { if (parent::handleInput($input)) { return false; } $class_id = $this->extraParam['classid']; $action = $this->extraParam['action']; if ($action == 'iswinner') { return $this->isWinner($class_id); } if ($action != 'start') { return "错误输入" . $this->getFooter(); } if ($input == 'r') { $this->setQuestionID($class_id, 0); //清空记录 $buddy_id = $this->getBuddyID(); $this->execute("delete from fx_game_kaixincidian_records where buddy_id={$buddy_id} and class_id={$class_id}"); $this->execute("update fx_game_kaixincidian_scores set score=0 where buddy_id={$buddy_id} and class_id={$class_id}"); return $this->newQuestion($class_id); } if (is_numeric($input)) { return $this->doQuestion($class_id, $input); } return "输入错误:{$input}\n" . $this->getFooter(); }
public function handle($input) { if (parent::handleInput($input)) { return false; } $action = $this->extraParam['action']; $class_id = $this->extraParam['classid']; if ($action == 'list') { $extra = ""; $perPage = 4; $pages = 1; $currentPage = $this->getPage($class_id); $sql = "select count(*) as count from fx_guestbook where class_id={$class_id}"; $retArr = $this->session->db->fetchQueryAll($sql); $count = $retArr[0]['count']; if ($count > $perPage) { $pages = ceil($count / $perPage); } if ($input == 'p') { if ($currentPage > 1) { $currentPage--; $this->setPage($class_id, $currentPage); } return $this->getList($class_id, $count); } else { if ($input == 'n') { if ($currentPage < $pages) { $currentPage++; $this->setPage($class_id, $currentPage); } return $this->getList($class_id, $count); } } } else { if ($action == 'write') { $buddyNo = $this->session->buddyID; $buddyName = $this->session->buddyArray['nickname']; if (empty($buddyName)) { $buddyName = $this->session->buddyArray['localname']; } if (empty($buddyName)) { $buddyName = $this->session->buddyArray['sid']; } if (empty($buddyName)) { $buddyName = $this->session->buddyArray['mobile']; } $content = mysql_real_escape_string($input); $send_time = time(NULL); $sql = "insert into fx_guestbook(class_id,buddy_no,buddy_name,content,send_time) "; $sql .= "values({$class_id},'{$buddyNo}','{$buddyName}','{$content}','{$send_time}')"; $this->session->db->execute($sql); return "您的发言已成功!\n" . $this->getFooter(''); } } return $msg; }
public function handle($input) { if (parent::handleInput($input)) { return false; } $voteid = $this->extraParam['voteid']; $start = isset($this->extraParam['start']) ? $this->extraParam['start'] : ""; $end = isset($this->extraParam['end']) ? $this->extraParam['end'] : ""; $secret = isset($this->extraParam['secret']) ? $this->extraParam['secret'] : 0; $today = date('Y-m-d'); // 检查时间 if ($start != "" && $today < $start) { return "投票活动尚未开始[开始时间:{$start}]\n" . $this->getFooter(); } if ($end != "" && $today > $end) { return "投票活动已经结束[结束时间:{$end}]\n" . $this->getFooter(); } if ($input == 'v') { if ($secret == 1) { return "该投票为保密投票,结果不对外!\n" . $this->getFooter(); } return $this->getList($voteid, true) . $this->getFooter(); } $inputArr = explode(',', $input); for ($i = 0; $i < count($inputArr); $i++) { if (!is_numeric($inputArr[$i])) { return "错误指令\n" . $this->getFooter(); } } $allowMulti = $this->extraParam['multi']; if (count($inputArr) > 1 && !$allowMulti) { return "不支持多选" . $this->getFooter(); } return $this->doVote($voteid, $inputArr, $secret); }
public function handle($input) { if (parent::handleInput($input)) { return false; } $eventid = $this->extraParam['eventid']; $action = $this->extraParam['action']; $type = $this->extraParam['type']; if ($action == 'show') { return $this->handleShow($eventid, $input); } $msg = ""; if ($type == "BM") { $input = preg_replace("/^bm/", "bm ", $input); $input = preg_replace("/^BM/", "BM ", $input); while (strstr($input, " ")) { $input = str_replace(" ", " ", $input); } //格式:BM 飞信群号+飞信群名 $array = explode("+", $input); if (count($array) != 2) { return "您发送格式有误,请回复“BM 飞信群号+飞信群名”,报名参加“飞信集结号,人多闯天下”活动,如编辑“BM 3380048+镇江我爱你”即可报名参赛。\n" . $this->getFooter(); } $leftArr = explode(" ", $array[0]); if (count($leftArr) != 2) { return "您发送格式有误,请回复“BM 飞信群号+飞信群名”,报名参加“飞信集结号,人多闯天下”活动,如编辑“BM 3380048+镇江我爱你”即可报名参赛。\n" . $this->getFooter(); } if ($leftArr[0] != "BM" && $leftArr[0] != "bm") { return "您发送格式有误,请回复“BM 飞信群号+飞信群名”,报名参加“飞信集结号,人多闯天下”活动,如编辑“BM 3380048+镇江我爱你”即可报名参赛。\n" . $this->getFooter(); } if (!is_numeric($leftArr[1])) { return "您发送格式有误,请回复“BM 飞信群号+飞信群名”,报名参加“飞信集结号,人多闯天下”活动,如编辑“BM 3380048+镇江我爱你”即可报名参赛。\n" . $this->getFooter(); } if (intval($leftArr[1]) <= 10000 || intval($leftArr[1]) > 999999999) { return "您发送格式有误,请回复“BM 飞信群号+飞信群名”,报名参加“飞信集结号,人多闯天下”活动,如编辑“BM 3380048+镇江我爱你”即可报名参赛。\n" . $this->getFooter(); } $qunNo = $leftArr[1]; $qunName = $array[1]; $lenQunNo = strlen($qunNo) + 1; //普通活动 $today = date("Y-m-d"); $sql = "select * from fx_participate where event_id={$eventid} and buddy_id={$this->session->buddyID} and left(extra,{$lenQunNo})='{$qunNo} '"; $retArr = $this->query($sql); if (count($retArr) >= 1) { $time = date('Y年m月d日H时i分s秒', $retArr[0]['add_time']); $msg = "您已经于{$time}报名!"; } else { $time = time(NULL); $sql = "insert into fx_participate(buddy_id,event_id,add_time,extra) values({$this->session->buddyID},{$eventid},{$time},'{$qunNo} {$qunName}')"; $this->execute($sql); $msg = "您已成功报名,赶快邀请好友赢取话费吧!\n"; } } else { if ($input == "我要参与") { //普通活动 $today = date("Y-m-d"); $sql = "select * from fx_participate where event_id={$eventid} and buddy_id={$this->session->buddyID} and left(from_unixtime(add_time),10)='{$today}'"; $retArr = $this->query($sql); if (count($retArr) >= 1) { $time = date('Y年m月d日H时i分s秒', $retArr[0]['add_time']); $msg = "您已经于{$time}参加“我要抢票”活动,请改日参加!"; } else { $time = time(NULL); $sql = "insert into fx_participate(buddy_id,event_id,add_time) values({$this->session->buddyID},{$eventid},{$time})"; $this->execute($sql); $msg = "您已成功报名,飞信精灵将于次日0点00分进行随机抽奖,获奖结果将公布在“每日幸运榜”中,感谢您的参与!\n"; } } } return $msg . $this->getFooter(); }
public function handle($input) { if (parent::handleInput($input)) { return false; } $action = $this->extraParam['action']; if ($action == 'list') { $class_id = $this->extraParam['classid']; $extra = ""; $perPage = $this->pageSize; $pages = 1; $currentPage = $this->getPage($class_id); $sql = "select count(*) as count from fx_articles where class_id={$class_id}"; $retArr = $this->session->db->fetchQueryAll($sql); $count = $retArr[0]['count']; if ($count > $perPage) { $pages = ceil($count / $perPage); } if ($input == 'p') { if ($currentPage > 1) { $currentPage--; $this->setPage($class_id, $currentPage); } return $this->getList($class_id, $count); } else { if ($input == 'n') { if ($currentPage < $pages) { $currentPage++; $this->setPage($class_id, $currentPage); } return $this->getList($class_id, $count); } else { if ($input == 't') { return $this->getList($class_id, $count); } else { if (is_numeric($input)) { $type = $this->extraParam['type']; if ($type == 'riddle') { return $this->riddleEnter($class_id, $count, $input); } else { return $this->getListContent($class_id, $count, $input); } } else { if ($input == 'v') { $type = $this->extraParam['type']; if ($type == 'riddle') { return $this->riddleShow($class_id); } } else { $type = $this->extraParam['type']; if ($type == 'riddle') { return $this->riddleDo($class_id, $input); } } } } } } } else { if ($action == 'view') { $id = $this->extraParam['id']; return $this->getContent($id); } } $msg = "系统中未发现有关 {$input} 的帮助内容\n"; $msg .= $this->getFooter(); return $msg; }
public function handle($input) { if (parent::handleInput($input)) { return false; } if ($input == 's') { $id = 0; $retArr = array(); while (1) { $id = rand(1, 1000); $sql = "select * from fx_games_24point where id={$id}"; $retArr = $this->session->db->fetchQueryAll($sql); if (!empty($retArr[0]['nr'])) { break; } } $msg = "<Font Face='楷体' Color='-16744320' Size='10.5'>开动脑筋吧!四个数字分别是:</Font>\n"; $msg .= "<Font Face='楷体' Color='-8388608' Size='14.5'>{$retArr[0]['b1']},{$retArr[0]['b2']},{$retArr[0]['b3']},{$retArr[0]['b4']}</Font>\n"; $msg .= "<Font Face='楷体' Color='-16744320' Size='10.5'>把您的答案发给我,我来帮您运算,看是否正确。如输入 1+2/(3*4)</Font>\n"; $this->setQuestionID($id); $msg .= $this->getFooter(',s-抽题 v-查看答案'); return $msg; } else { if ($input == 'v') { $id = $this->getQuestionID(); if ($id == 0) { return "您还没有抽题!输入s抽题!"; } $sql = "select * from fx_games_24point where id={$id}"; $retArr = $this->session->db->fetchQueryAll($sql); $msg = ""; $msg .= "<Font Face='楷体' Color='-8388608' Size='14.5'>{$retArr[0]['b1']},{$retArr[0]['b2']},{$retArr[0]['b3']},{$retArr[0]['b4']}</Font>\n"; $msg .= "<Font Face='楷体' Color='-16744320' Size='10.5'>正确答案是: {$retArr[0]['nr']}</Font>\n"; $msg .= $this->getFooter(',s-抽题 v-查看答案'); return $msg; } else { $id = $this->getQuestionID(); if ($id == 0) { return "您还没有抽题!输入s抽题!"; } $sql = "select * from fx_games_24point where id={$id}"; $retArr = $this->session->db->fetchQueryAll($sql); $input = str_replace("\n", '', $input); $input = str_replace("\r", '', $input); $allowChar = array('+', '-', '*', '/', ')', '('); $msg = ""; for ($i = 0; $i < strlen($input); $i++) { $c = substr($input, $i, 1); if (!(is_numeric($c) || in_array($c, $allowChar))) { $msg = "您输入的算式不正确,请重新输入"; break; } } $input2 = ""; for ($i = 0; $i < strlen($input); $i++) { $c = substr($input, $i, 1); if (is_numeric($c)) { $input2 .= $c; } else { $input2 .= ","; } } $inputArr = explode(",", $input2); for ($i = 0; $i < count($inputArr); $i++) { if (empty($inputArr[$i])) { continue; } if ($inputArr[$i] == $retArr[0]['b1'] || $inputArr[$i] == $retArr[0]['b2'] || $inputArr[$i] == $retArr[0]['b3'] || $inputArr[$i] == $retArr[0]['b4']) { continue; } else { $msg = "输入有误!"; return $msg . $this->getFooter(',s-抽题 v-查看答案'); } } if ($msg == "") { $str = '$value=' . $input . ';'; try { eval($str); $msg = "您输入的算式结果是:{$value}。"; if ($value == 24) { $msg .= "恭喜您,答对了!"; } else { $msg .= "结果不正确,请再努力!"; } } catch (Exception $e) { $msg = "您输入的算式非法!请重新输入"; } } return $msg . $this->getFooter(',s-抽题 v-查看答案'); } } $msg .= $this->getFooter(',s-抽题'); return $msg; }
public function handle($input) { if (parent::handleInput($input)) { return false; } if (is_numeric($input)) { return $this->subSong(intval($input)); } if ($input == 'l') { return $this->getListFromCache(); } else { if ($input == 'p') { $page = $this->getPage(); $page--; if ($page == 0) { $page = 1; } $this->setPage($page); $key = $this->getKeyword(); return $this->getSongList($key); } else { if ($input == 'n') { $page = $this->getPage(); $page++; $this->setPage($page); $key = $this->getKeyword(); return $this->getSongList($key); } else { $this->setPage(1); $this->setKeyword($input); return $this->getSongList($input); } } } }
public function handle($input) { if (parent::handleInput($input)) { return false; } $class_id = $this->extraParam['classid']; $extra = ""; $perPage = 4; $pages = 1; $currentPage = $this->getPage($class_id); $sql = "select count(*) as count from fx_mindtest_questions where class_id={$class_id} order by id desc"; $retArr = $this->session->db->fetchQueryAll($sql); $count = $retArr[0]['count']; if ($count > $perPage) { $pages = ceil($count / $perPage); } if ($input == 'p') { if ($currentPage > 1) { $currentPage--; $this->setPage($class_id, $currentPage); } return $this->getList($class_id, $count); } else { if ($input == 'n') { if ($currentPage < $pages) { $currentPage++; $this->setPage($class_id, $currentPage); } return $this->getList($class_id, $count); } else { if ($input == 'l') { return $this->getList($class_id, $count); } else { if (is_numeric($input)) { $questionID = $this->getQuestionID($class_id); if ($questionID == 0) { return $this->getListContent($class_id, $count, $input); } else { return $this->selectOption($class_id, $questionID, $input); } } } } } return $this->getFooter(); }