Exemple #1
0
 public function add($arr)
 {
     $user = FN::i('module.user');
     $arr['datetime'] = time();
     $arr['user_id'] = $user->getUid();
     $arr['log_info'] = FNbase::setEscape(serialize($arr['log_info']), true);
     $arr['result'] = FNbase::setEscape(serialize($arr['result']), true);
     $this->log->add($arr);
 }
Exemple #2
0
 public function updateCode()
 {
     if (empty($this->cid)) {
         return false;
     }
     $data = array('status' => 1, 'updatetime' => FNbase::getTime());
     $this->codelist->cid = $this->cid;
     $this->codelist->edit($data);
     return true;
 }
Exemple #3
0
 protected function _call($url, $array = array())
 {
     if ($this->debug) {
         var_dump($url);
     }
     $content = FNbase::getUrlContent($url, FNbase::clearEscape($array));
     if ($this->debug) {
         var_dump($content);
     }
     return $content;
 }
Exemple #4
0
 private function __construct($array)
 {
     $this->template = FN::server('template', $this->_link);
     if (defined('FN_WEB_PATH')) {
         //如果是web访问,传递路径变量
         $this->template->assign('url', FN_WEB_PATH);
         if ($this->dir) {
             $this->template->assign('dir', $this->dir);
             $this->template->assign('static', FN_WEB_PATH . 'static/' . $this->dir);
         } else {
             $this->template->assign('static', FN_WEB_PATH . 'static/');
         }
     }
     $this->ajax = FNbase::isAJAX();
     $this->param = empty($array['param']) ? array() : $array['param'];
     $this->default = $array;
     $this->_init();
     $this->_view(empty($this->default['view']) ? '' : $this->default['view']);
 }
Exemple #5
0
 protected function _call($url, $array = array())
 {
     if ($this->debug) {
         var_dump($url);
     }
     $content = FNbase::getUrlContent($url, FNbase::clearEscape($array));
     if ($this->debug) {
         var_dump($content);
     }
     $content = json_decode($content, true);
     if (!is_array($content)) {
         return $this->_cache_msg($url, 'url error', 'error');
     }
     if (!empty($content['error'])) {
         return $this->_cache_msg($url, $content['error'], 'error');
     }
     $data = !isset($content['data']) ? array() : array('data' => $content['data']);
     if (!empty($content['other']) && is_array($content['other'])) {
         unset($content['other']['data']);
         $data = array_merge($data, $content['other']);
     }
     $content['data'] = $data;
     return $content;
 }
Exemple #6
0
 public function setValue($key, $value)
 {
     $sql = 'replace into `user_value` (`uid`,`key`,`value`)values("' . $this->getUid() . '","' . $key . '","' . FNbase::setEscape(serialize($value), true) . '")';
     $db = XG::getMysql();
     $db->query($sql);
 }
Exemple #7
0
 protected function createFileName($info)
 {
     $ext = strtolower(trim(substr(strrchr($info['filename'], '.'), 1)));
     return FNbase::guid(true) . '.' . $ext;
 }
 protected function getBatch()
 {
     return empty($_POST['batch']) ? array() : json_decode(FNbase::clearEscape($_POST['batch']), true);
 }
Exemple #9
0
 protected function requestProxy($params, $channel)
 {
     $url = $this->formatURL($channel);
     $params['apikey'] = $this->accesskey;
     $params['timestamp'] = FNbase::getTime();
     $sign = $this->sign('POST', $url, $params);
     $params['sign'] = $sign;
     $options = array();
     $options['url'] = $url;
     $options['method'] = $params['method'];
     if ($params['method'] == 'GET') {
         $options['url'] = $this->combineURL($options['url'], $params);
     } else {
         $options['content'] = $this->combineParams($params);
     }
     $response = $this->request($options);
     return $response->isOK() ? $response->getBodyJson() : false;
 }
Exemple #10
0
 protected function setSession($delete = false)
 {
     //$cache = FN::server('cache','session');
     if ($delete) {
         //$cache->delete($this->session);
         $this->st->delete($this->session);
     } else {
         if (empty($this->user)) {
             return false;
         }
         if (empty($this->session)) {
             $this->session = FNbase::random(10);
         }
         //10位的随机性已经足够
         $this->st->add(array('session' => $this->session, 'value' => FNbase::setEscape(json_encode($this->user), true), 'inserttime' => FNbase::getTime(), 'cachetime' => $this->cacheTime), true);
         //$cache->set($this->session,json_encode($this->user),false,$this->cacheTime);
         if (isset($this->user['password']) && $this->user['password']) {
             $this->login = '******';
         }
     }
     $this->setCookie($delete);
     return true;
 }
Exemple #11
0
 public function setHost($host = false)
 {
     $this->HOST = $host ? $host : FNbase::getHead('host');
     return $this;
 }
Exemple #12
0
 public static function guid($op = false, $namespace = '')
 {
     $uid = uniqid("", true);
     $data = $namespace;
     $data .= $_SERVER['REQUEST_TIME'];
     $data .= $_SERVER['HTTP_USER_AGENT'];
     $data .= $_SERVER['SERVER_ADDR'];
     $data .= $_SERVER['SERVER_PORT'];
     $data .= $_SERVER['REMOTE_ADDR'];
     $data .= $_SERVER['REMOTE_PORT'];
     $hash = strtoupper(hash('ripemd128', $uid . self::$_GUID . md5($data)));
     if ($op) {
         self::$_GUID = substr($hash, 0, 32);
     } else {
         self::$_GUID = substr($hash, 0, 8) . '-' . substr($hash, 8, 4) . '-' . substr($hash, 12, 4) . '-' . substr($hash, 16, 4) . '-' . substr($hash, 20, 12);
     }
     return self::$_GUID;
 }