/** * 敏感分析服务 * * @return void */ function searchEngine($data, $runtime = false) { $process_start_time = getCurrentTime(); $result = post(X::getConfigVar("searchEngine"), ["words" => cleanFormat($data['content']), 'if_spam' => $data['if_spam']]); $process_end_time = getCurrentTime(); if ($runtime) { $process_time = round($process_end_time - $process_start_time, 4); //运行时间 return [$result, $process_time]; } return $result; }
/** * 公司登录 * * @return void */ public function signin($account, $password) { if (!$account || !$password) { exit; } $password = md5($password . X::getConfigVar('salt')); if ($result = $this->db()->table('company')->where("account = '%s' AND password = '******'", $account, $password)->findOne()) { X::session()->set(['company_name' => $result['company_name'], 'account' => $account, 'company_id' => $result['company_id']]); return $result; } else { return false; } }
<?php require "./X.php"; use Engine\X; use Engine\Gvar; use Engine\Mysql; require '__init__.php'; /********************************************/ /********************************************/ // Bottle::map('notFound', function(){ // echo("~~~~~~~~~~~~notFound~~~~~~~~~~~~"); // }); X::map('exception', function () { echo "~~~~~~~~~~error~~~~~~~~~~~~~~"; }); X::init(['online' => false, 'baseUrl' => dirname(__FILE__) . DIRECTORY_SEPARATOR, 'templateFuncFile' => 'function/template.php']); //连接数据库 X::register('db', function () { return new Mysql(X::getConfigVar('database')); }); Gvar::set(['ip' => ip()], 'global'); //csrf_token X::start(['audit']);
/** * 默认分页limit * * @return void */ function defaultPageLimit($page) { $end = X::getConfigVar('defaultPageRecordNumber'); $start = ($page - 1) * $end; return [$start, $end]; }