Ejemplo n.º 1
0
 public function __construct()
 {
     if (self::$reObj === null) {
         if (!extension_loaded('redis')) {
             die('服务器不支持redis扩展!');
         }
         $reObj = new \redis();
         $config = \System\Entrance::config('REDIS_CONFIG');
         $host = $config['host'];
         $port = $config['port'];
         $auth = $config['auth'];
         if ($config['connectType'] == 'connect') {
             $connect = $reObj->connect($host, $port);
         } else {
             $connect = $reObj->pconnect($host, $port);
         }
         if (!empty($auth)) {
             if (!$reObj->auth($auth)) {
                 die('redis密码错误!');
             }
         }
         if (!$connect) {
             die('redis服务器连接失败!');
         }
         self::$reObj = $reObj;
     }
     return self::$reObj;
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     if (self::$memObj === null) {
         //为了支持window
         if (extension_loaded('Memcached')) {
             $class = 'Memcached';
             self::$type = 'Memcached';
         } elseif (extension_loaded('Memcache')) {
             $class = 'Memcache';
             self::$type = 'Memcache';
         } else {
             die('缺乏memcached支持!');
         }
         self::$memObj = new $class();
         $memConfig = \System\Entrance::config("MEMCACHE_CONFIG");
         //添加服务器
         foreach ($memConfig as $key => $server) {
             self::$memObj->addServer($server['host'], $server['port']);
         }
         if ($class == 'Memcached' && $this->isCompression == false) {
             self::$memObj->setOption($class::OPT_COMPRESSION, false);
             //关闭压缩
         }
     } else {
         return self::$memObj;
     }
 }
Ejemplo n.º 3
0
 public function __construct($db, $debug = false)
 {
     $this->conn = Database::openConnection($db);
     //$this->initClassfromTable();
     $this->isDebug = \System\Entrance::config('IS_DB_DEBUG');
     //$this->initTable();
     //$this->initSqlStmt();
 }
Ejemplo n.º 4
0
 public function __construct($DB)
 {
     $DBConfig = \System\Entrance::config($DB);
     $this->host = $DBConfig['host'];
     $this->user = $DBConfig['user'];
     $this->password = $DBConfig['password'];
     $this->dbName = $DBConfig['dbName'];
 }
Ejemplo n.º 5
0
 public function getMultiLength($multiSqlStmt, $fieldsName)
 {
     \System\database\MultiBaseTable::setMultiSqlStmt($multiSqlStmt);
     $length = \System\database\MultiBaseTable::getMultiListLength($fieldsName);
     if (\System\Entrance::config('IS_DB_DEBUG') == true) {
         sqlDebugLog(\System\database\MultiBaseTable::$lastSql, \System\database\MultiBaseTable::$error);
     }
     return $length;
 }
Ejemplo n.º 6
0
 /**
  * 读取\修改配置文件
  * @param string $name  缓存名称
  * @param mixed $value 修改数据
  */
 public function config($name, $value = null)
 {
     return \System\Entrance::config($name, $value);
 }
Ejemplo n.º 7
0
 public function __construct($db = 'DB_MASTER', $debug = false)
 {
     $this->db = $db;
     $this->conn = Database::openConnection($db);
     $this->isDebug = \System\Entrance::config('IS_DB_DEBUG');
 }
Ejemplo n.º 8
0
 /**
  * sftp上传企业资质
  * sftp upload
  * @param $file 上传文件路径
  * @return false 失败   true 成功
  */
 function sftp_upload($file, $filename)
 {
     $sina_config = \System\Entrance::config('SINA_FUND_MANAGED');
     $strServer = $sina_config['sftp_address'];
     $strServerPort = $sina_config['sftp_port'];
     $strServerUsername = $sina_config['sftp_username'];
     $strServerprivatekey = $sina_config['sftp_privatekey'];
     $strServerpublickey = $sina_config['sftp_publickey'];
     $resConnection = ssh2_connect($strServer, $strServerPort);
     if (ssh2_auth_pubkey_file($resConnection, $strServerUsername, $strServerpublickey, $strServerprivatekey)) {
         $resSFTP = ssh2_sftp($resConnection);
         file_put_contents("ssh2.sftp://{$resSFTP}/upload/" . $filename, $file);
         if (!copy($file, "ssh2.sftp://{$resSFTP}/upload/{$filename}")) {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 9
0
 /**
  * 获取微信media并保存
  * @param str $mediaID  media_id
  * @param str $path 目录
  * @return bool
  */
 public static function getWechatMedia($mediaID, $savePath = null)
 {
     if (empty($savePath)) {
         $savePath = 'order/' . time() . '_' . rand(1000, 9999) . ".jpg";
     }
     $weObj = new \System\lib\Wechat\Wechat(\System\Entrance::config("WEIXIN_CONFIG"));
     $media = $weObj->getMedia($mediaID);
     if (!$media) {
         return false;
     }
     $temPath = '../TempImg/';
     //临时保存路径
     if (!dirExists($temPath)) {
         return false;
     }
     $fileName = basename($savePath);
     /* $fileName=basename($savePath);
        $checkPath=str_replace($fileName, '', $savePath);
        if(!dirExists($checkPath)) return false; */
     if (!file_put_contents($temPath . $fileName, $media)) {
         return false;
     }
     //生成压缩图片
     $image = new \System\lib\Image\Image($temPath . $fileName);
     $img1 = $image->size();
     $return['img1']['path'] = $temPath . $fileName;
     $return['img1']['width'] = $img1[0];
     $return['img1']['heigh'] = $img1[1];
     //200*200缩略图
     $img2Path = $temPath . str_replace('.', '_thumb200.', $fileName);
     $image->thumb(200, 10000)->save($img2Path);
     $img2 = $image->size();
     $return['img2']['path'] = $img2Path;
     $return['img2']['width'] = $img2[0];
     $return['img2']['heigh'] = $img2[1];
     //360*360缩略图
     $img3Path = $temPath . str_replace('.', '_thumb360.', $fileName);
     $image->open($temPath . $fileName);
     $image->thumb(360, 10000)->save($img3Path);
     $img3 = $image->size();
     $return['img3']['path'] = $img3Path;
     $return['img3']['width'] = $img3[0];
     $return['img3']['heigh'] = $img3[1];
     //dump($return);
     //上传
     foreach ($return as $key => $a) {
         $upload = httpPost(\System\Entrance::config('IMG_UPLOAD'), ['file' => new \CURLFile(realpath($a['path'])), 'savePath' => dirname($savePath) . '/', 'saveName' => basename($a['path'])], true);
         //dump($upload);
         $upload = json_decode($upload, true);
         if (!($upload && $upload['result'] == true)) {
             return false;
         }
         unlink($a['path']);
         $return[$key]['path'] = $upload['path'];
     }
     return $return;
 }
Ejemplo n.º 10
0
 static function CURL_TIMEOUT()
 {
     return \System\Entrance::config('WEIXIN_PAY_CONFIG')['CURL_TIMEOUT'];
 }