public function __construct($config) { $port = isset($config['port']) ? $config['port'] : 3306; $dsn = sprintf('mysql:host=%s;dbname=%s;port=%d', $config['host'], $config['dbname'], $port); YafDebug::log($dsn); try { $this->dbh = new PDO($dsn, $config['user'], $config['pass'], array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'utf8\'', PDO::ATTR_PERSISTENT => false, PDO::ATTR_EMULATE_PREPARES => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING)); } catch (Exception $e) { if ($this) { $this->error = $e->getMessage(); } } }
protected function inputRefererErrorResult() { // echo json_encode(array('code'=>-101,'desc'=>'referer error')); // haloDie(); YafDebug::log(sprintf("Illegal referer: uid is %s, referer is %s, params is %s ", WZhaopinEnv::getWid(), $_SERVER['HTTP_REFERER'], json_encode($_SERVER)), "refer_error"); $this->inputErrorResult(WrmErrorCodeManager::CLIENT_ERR_ILLEGAL_REFER); }
protected function inputResult($data = null) { $login = 0; $status = 0; $role = 1; $statusArray = array(); if ($this->uid) { $login = 1; YafDebug::log("get user status start .uid is" . $this->uid); YafDebug::log("client boject is"); YafDebug::log($this->client); if (is_object($this->client)) { #warning TODO //获取不到对象 $this->client = HaloClient::singleton(); $result = $this->client->getUserStatus($this->uid); } YafDebug::log($result); $role = intval($result['user_role']); if ($result['user_role'] == 1) { $status = $result['resume_status']; } else { if ($result['mem_status'] !== null) { $statusArray['mem_status'] = $result['mem_status']; } } } $statusArray['login'] = $login; $statusArray['status'] = $status; $statusArray['role'] = $role; if ($data !== null) { echo json_encode(array('data' => $data, 'code' => 0, 'status' => $statusArray)); } else { echo json_encode(array('code' => 0, 'status' => array('login' => $login, 'status' => $status))); } // } haloDie(); }