function SendCommand($command, $id = '') { if ($id == '') { $id = time(null); for ($i = 0;; $i++) { $cmdFile = CMD_PATH . SVC_MOBILE . "_" . ($id . $i) . ".cmd"; if (!file_exists($cmdFile)) { break; } } } else { $cmdFile = CMD_PATH . SVC_MOBILE . "_" . $id . ".cmd"; } file_put_contents($cmdFile, FetionEncodeMsg($command)); }
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(); }