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; }
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; } }
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(); }
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']; }
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; }
/** * 转换参数意义 * @param string $name 配置名称 * @param mixed $value id */ public function convertId($name, $id = null) { return \System\Entrance::convertId($name, $id); }
public function __construct($db = 'DB_MASTER', $debug = false) { $this->db = $db; $this->conn = Database::openConnection($db); $this->isDebug = \System\Entrance::config('IS_DB_DEBUG'); }
/** * 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; }
<?php define('__ROOT__', dirname(dirname(__FILE__))); require __ROOT__ . '/System/Entrance.class.php'; \System\Entrance::action(); /*// 指定允许其他域名访问 header('Access-Control-Allow-Origin:*'); // 响应类型 header('Access-Control-Allow-Methods:POST'); // 响应头设置 header('Access-Control-Allow-Headers:x-requested-with,content-type'); */
/** * 获取微信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; }
static function CURL_TIMEOUT() { return \System\Entrance::config('WEIXIN_PAY_CONFIG')['CURL_TIMEOUT']; }