Example #1
0
 /**
  * magic method 
  * @param string $method method name
  * @param array $parms params of the method
  */
 public function __call($method, $parms)
 {
     if (0 === strcasecmp($method, ACTION_NAME)) {
         if (method_exists($this, '_empty')) {
             $this->_empty($method, $parms);
         } else {
             throw_exception(L('_ERROR_ACTION_') . ACTION_NAME);
         }
     } elseif (in_array(strtolower($method), array('ispost', 'isget', 'ishead', 'isdelete', 'isput'))) {
         //get REQUEST METHOD
         return strtolower($_SERVER['REQUEST_METHOD']) == strtolower(substr($method, 2));
     } else {
         //log the exception of the app, module && action not find
         logNotice(__CLASS__ . ':' . $method . '_METHOD_NOT_EXIST_');
         //throw_exception(__CLASS__.':'.$method.'_METHOD_NOT_EXIST_');
     }
 }
Example #2
0
 /**
  * get the instance of the class
  * @param string $class class name
  * @param string $parmaNode param node of the class
  * @param string $method method name
  */
 public static function instance($class = '', $paramNode = '', $method = '')
 {
     $identify = $class . $paramNode . $method;
     if (!isset(self::$_instance[$identify])) {
         if (class_exists($class)) {
             $o = empty($paramNode) ? new $class() : new $class(strtolower($class) . '.' . strtolower($paramNode));
             if (!empty($method) && method_exists($o, $method)) {
                 self::$_instance[$identify] = call_user_func_array(array(&$o, $method));
             } else {
                 self::$_instance[$identify] = $o;
             }
         } else {
             logNotice(__CLASS__ . '/' . __FUNCTION__ . ":{$class} CLASS_NOT_EXIST ");
             exit;
         }
     }
     return self::$_instance[$identify];
 }
Example #3
0
 /**
  * get error msg
  * @param string $intMsgId
  */
 public static function getMsg($intMsgId = 0)
 {
     if (isset($intMsgId) && isset(self::$_arrErrMap[$intMsgId])) {
         return self::$_arrErrMap[$intMsgId];
     }
     logNotice("ERROR CODE NOT INFO ID:%s", $intMsgId);
     return '';
 }
Example #4
0
 /**
  * save file or image to upaiyun.com then update db
  * 先保存数据到又拍云存储,然后在更新数据库
  * @param string $model
  * @param string $filename   保存文件名
  * @param mixed $streamFile  流文件或者是图片路径
  * @param bigint $id ID
  * @param bigint $user_id userid
  */
 public function save($account_id, $filename = '', $streamFile = '', $id = '')
 {
     $result = $this->put('image', $filename, $streamFile);
     logDebug('UPLOAD FILE TO UPAI ' . json_encode($result));
     $id = empty($id) ? objid() : $id;
     $filename = empty($filename) ? $id . '.jpg' : $filename;
     if ($result['code'] == 200) {
         return ImageLogic::setImage($id, $account_id, $filename, 'web');
     }
     logNotice(__CLASS__ . '/' . __FUNCTION__ . ':UPLOAD IMAGE ERROR PATH:%s', $filename);
     return false;
 }
Example #5
0
 function _Connect()
 {
     if ($this->_socket !== false) {
         // we are in persistent connection mode, so we have a socket
         // however, need to check whether it's still alive
         if (!@feof($this->_socket)) {
             return $this->_socket;
         }
         // force reopen
         $this->_socket = false;
     }
     $errno = 0;
     $errstr = "";
     $this->_connerror = false;
     if ($this->_path) {
         $host = $this->_path;
         $port = 0;
     } else {
         $host = $this->_host;
         $port = $this->_port;
     }
     try {
         if ($this->_timeout <= 0) {
             $fp = @fsockopen($host, $port, $errno, $errstr);
         } else {
             $fp = @fsockopen($host, $port, $errno, $errstr, $this->_timeout);
         }
         if (!$fp) {
             if ($this->_path) {
                 $location = $this->_path;
             } else {
                 $location = "{$this->_host}:{$this->_port}";
             }
             $errstr = trim($errstr);
             $this->_error = "connection to {$location} failed (errno={$errno}, msg={$errstr})";
             $this->_connerror = true;
             return false;
         }
     } catch (Exception $e) {
         logNotice("CONNECT TO SPHINX ERROR %s", $e->__toString());
     }
     // send my version
     // this is a subtle part. we must do it before (!) reading back from searchd.
     // because otherwise under some conditions (reported on FreeBSD for instance)
     // TCP stack could throttle write-write-read pattern because of Nagle.
     if (!$this->_Send($fp, pack("N", 1), 4)) {
         fclose($fp);
         $this->_error = "failed to send client protocol version";
         return false;
     }
     // check version
     list(, $v) = unpack("N*", fread($fp, 4));
     $v = (int) $v;
     if ($v < 1) {
         fclose($fp);
         $this->_error = "expected searchd protocol version 1+, got version '{$v}'";
         return false;
     }
     return $fp;
 }
Example #6
0
 /**
  * App Error
  * @param string $errno error number
  * @param string $errstr  error info
  * @param string $errfile  error file
  * @param string $errline  error line
  */
 public static function appError($errno, $errstr, $errfile, $errline)
 {
     switch ($errno) {
         case E_ERROR:
         case E_USER_ERROR:
             $errorStr = "[{$errno}] {$errstr} " . basename($errfile) . " {$errline} Line.";
             logNotice($errorStr);
             exit($errorStr);
             break;
         case E_STRICT:
         case E_USER_WARNING:
         case E_USER_NOTICE:
         default:
             $errorStr = "[{$errno}] {$errstr} " . basename($errfile) . " {$errline} Line.";
             logNotice($errorStr);
             exit($errorStr);
             break;
     }
 }