public function __construct() { parent::__construct(); $this->cache = \Alibaba::cache(); // 实例化云引擎缓存 $this->token = $this->cache->get('ACCESS_TOKEN'); // 获取ACCESS_TOKEN $this->msgRps = D('WeixinResponse'); // 实例化微信原始响应表 $this->weixinText = D('WeixinText'); // 实例化微信文本消息表 $this->weixinUrl = D('WeixinUrl'); // 实例化微信链接消息表 $this->weixinVideo = D('WeixinVideo'); // 实例化微信视频表 $this->weixinVoice = D('WeixinVoice'); // 实例化微信音频表 $this->weixinSVideo = D('WeixinSVideo'); // 实例化微信小视频表 $this->weixinPic = D('WeixinPic'); // 实例化微信图片消息表 $this->weixinLocation = D('WeixinLocation'); // 实例化微信地理信息表 $this->weixinUserInfo = D('WeixinUserInfo'); // 实例化用户信息表 }
function upload($file) { global $_G; $picService = Alibaba::Pic(); if (is_string($file)) { $file = file_get_contents(ROOT_PATH . $file); } else { $file = file_get_contents($file['tmp_name']); } if (!$file) { false; } $response = $picService->savePic($this->dir, $this->name, $file); if ($response->getStatus() && $response->isSuccess()) { $result = $response->getResult(); return $result[0]->fullUrl; } else { $code = array(200 => "请求成功", 400 => "参数错误", 404 => "图片不存在", 405 => "目录不存在", 408 => "图片大小超限", 406 => "目录非空不能删除", 406 => "存在同名目录或文件", 408 => "请求超时", 500 => "系统错误"); $codeInt = $response->getStatus(); $this->code = $codeInt; $this->msg = $code[$codeInt]; $msg = '图片上传错误,错误代码:' . $codeInt . ',错误信息:' . $code[$codeInt]; L($msg); } }
public function __construct() { parent::__construct(); $this->cache = \Alibaba::cache(); // 实例化云引擎缓存 $this->token = $this->cache->get('ACCESS_TOKEN'); }
public function getUsername() { if ($this->username) { return $this->username; } else { return Alibaba::getUsername(); } }
public function init($config) { global $_G; $this->obj = Alibaba::Cache($config); $this->enable = $this->obj ? true : false; $this->config = $config; return $this->enable; }
public function __construct() { parent::__construct(); $this->cache = \Alibaba::cache(); // 实例化云引擎缓存 $this->token = $this->cache->get('ACCESS_TOKEN'); $this->response = new WeixinResponseModel(); }
public function __construct() { parent::__construct(); $this->cache = \Alibaba::cache(); $this->storage = \Alibaba::storage('storage-01'); $this->token = $this->cache->get('ACCESS_TOKEN'); $this->log = new LogModel(); $this->response = new WeixinResponseModel(); $this->resource = new WeixinResourceManagerModel(); }
public function init($config) { if (!$config) { return false; } $this->config = $config; $connect = Alibaba::cache($config); $this->enable = true; $this->obj = $connect; return $this->enable; }
public static function AlibabaInit($params) { self::$app_name = $params['app_name']; self::$database_name = $params['database_name']; self::$database_host = $params['database_host']; self::$database_username = $params['database_username']; self::$database_password = $params['database_password']; self::$user_table_name = $params['user_table_name']; self::$username_field = $params['username_field']; self::$password_field = $params['password_field']; self::$hash_function = $params['hash_function']; self::$login_page_url = $params['login_page_url']; }
/** * @return Memcache|the */ public function getMemCache() { if ($this->_cache === null) { if (class_exists('Alibaba', false)) { $this->_cache = Alibaba::Cache('memcache'); } else { $memcache = new CMemCache(); $memcache->setServers($this->_servers); $memcache->init(); $this->_cache = $memcache; } } return $this->_cache; }
function down() { $fileKey = $this->get('key'); $storage = Alibaba::Storage(); if (!$storage->fileExists($fileKey)) { throw new MHttpException(404); } $meta = $storage->getMeta($fileKey); if (!$meta['content-length']) { throw new MHttpException('file size is 0 or file not found'); } $tmpFile = MONC . 'tmp' . DS . $fileKey; // 不存在,锁住下载 if (!$storage->get($fileKey, $tmpFile)) { throw new Exception('fail to get file from[' . $fileKey . '] to [' . $tmpFile . ']'); } header("Content-type: " . $meta['content-type']); header('Content-Disposition: attachment; filename="' . basename($fileKey) . '"'); header("Content-Length: " . $meta['content-length']); echo readfile($tmpFile); }
function baichuan_update($file) { $picService = Alibaba::Pic(); $target = date('Y') . '/' . date('m'); $name = date('Ymd-His') . '_' . strtolower(rand(1, 1000000)) . '.jpg'; $file = file_get_contents($file['tmp_name']); $response = $picService->savePic($target, $name, $file); if ($response->getStatus() && $response->isSuccess()) { $result = $response->getResult(); $picurl = $result[0]->fullUrl; $this->oriName = 'org_file_name'; $this->fileSize = '1000'; $this->fileType = '.jpg'; $this->fullName = $picurl; $this->filePath = $target; $this->fileName = $name; $this->stateInfo = $this->stateMap[0]; } else { $code = array(200 => "请求成功", 400 => "参数错误", 404 => "图片不存在", 405 => "目录不存在", 408 => "图片大小超限", 406 => "目录非空不能删除", 406 => "存在同名目录或文件", 408 => "请求超时", 500 => "系统错误"); $codeInt = $response->getStatus(); $msg = 'flash图片上传错误,错误代码:' . $codeInt . ',错误信息:' . $code[$codeInt]; L($msg); $this->stateInfo = $this->getStateInfo("ERROR_WRITE_CONTENT"); return; } }
function shake_reset() { //实例化一个memcache对象 if (!empty($_SERVER['HTTP_APPNAME'])) { @($mem = memcache_init()); } else { if (class_exists("Memcache")) { if (class_exists("Alibaba")) { @($mem = Alibaba::cache()); $sql = 'SELECT * FROM `weixin_shake_toshake`'; $query1 = mysql_query($sql); while ($z = mysql_fetch_assoc($query1)) { $mem->delete(realpath("..") . $z['wecha_id']); } $start = realpath("..") . "UPDATE `weixin_wall_config` SET `isopen` = "; $key2 = substr(md5($start), 10, 8); $mem->delete($key2); } else { @($mem = new Memcache()); @$mem->connect('localhost', '11211'); $mem->flush(); } } } mysql_query("TRUNCATE TABLE weixin_shake_toshake"); $sql_gm = "UPDATE `weixin_wall_config` SET `isopen` = '1'"; mysql_query($sql_gm); }
function L($msg) { global $_G; if (trim($msg)) { $msg = trim($msg); } $msg .= "\r\ndateline:" . dgmdate(TIMESTAMP, 'dt') . "\r\nIP:" . $_G[clientip]; $msg .= "\r\nMSG:" . $msg; $msg .= "\r\n" . $_SERVER['REQUEST_METHOD'] . ':' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '?' . $_SERVER['QUERY_STRING']; $msg .= "\r\nReferer:" . $_SERVER[HTTP_REFERER] . "\r\n"; if (class_exists('DB')) { $db =& DB::object(); if (method_exists($db, 'errorInfo')) { if ($db->errorInfo()) { $dberror = str_replace(DB::table(), '', $db->errorInfo()); $msg .= "\r\nDB:error_info:" . $dberror; $msg .= "\r\nDB:cur_sql:" . $db->currentSql; } } } if (TAE) { $appLog = Alibaba::Applog(); $appLog->error($msg); } else { if (!class_exists('error')) { include_once libfile('class/error'); } error::writeErrorLog('system', $msg); } }
public function __construct($sto) { $this->Storage = Alibaba::Storage($sto); }
<?php function test($val, $expect, $msg) { if ($val != $expect) { throw new Exception($msg); } } $cache = Alibaba::Cache(); $user = array("name" => "ace", "age" => 1, "sex" => "male"); test($cache->set('user', $user), true, 'Set cache failed'); test($cache->get('user')['age'], 1, 'Get cache failed'); test($cache->set('foo', 1), true, 'Set cache failed'); test($cache->add('foo', 1), false, 'Add cache failed'); test($cache->delete('foo'), true, 'Add cache failed'); test($cache->add('foo', 1), true, 'Add cache failed'); test($cache->increment('foo', 1), 2, 'increment cache failed'); test($cache->decrement('foo', 1), 1, 'decrement cache failed'); echo '测试完成.';
/** * 删除远程服务器上的单个文件 * * @param $file * @return mixed */ function delete_remote_file($file) { if (!false == strpos($file, '@!')) { return $file; } $oss_options = get_option('oss_options', TRUE); $config = array('id' => esc_attr($oss_options['ak']), 'key' => esc_attr($oss_options['sk']), 'bucket' => esc_attr($oss_options['bucket']), 'end_point' => esc_attr($oss_options['end_point'])); $oss_upload_path = trim($oss_options['path'], '/'); $wp_uploads = wp_upload_dir(); $del_file = str_replace($wp_uploads['basedir'], '', $file); $del_file = ltrim($oss_upload_path . '/' . ltrim($del_file, '/'), '/'); if (!is_object($aliyun_oss)) { $aliyun_oss = Alibaba::Storage($config); } $aliyun_oss->delete($del_file); return $file; }
public function __construct() { parent::__construct(); $this->sign(); $this->cache = \Alibaba::Cache(); }
<?php $storage = Alibaba::Storage(); file_put_contents("saveTextFile.jpg", 'test'); $res = $storage->saveFile("saveTextFile.jpg", "saveTextFile.jpg"); if (false == $res) { exit('saveFile failed.'); } $res = $storage->saveText("saveTextFile.txt", "OK", -11); if (false == $res) { exit('saveText failed.'); } $res = $storage->fileExists("saveTextFile.txt"); if (false == $res) { exit('fileExists failed.'); } $res = $storage->move("saveTextFile.txt", "newfile.txt"); if (false == $res) { exit('move failed.'); } if ($storage->get("newfile.txt") != 'OK') { exit('get failed.'); } print_r($storage->getMeta("newfile.txt")); print_r($storage->copy("newfile.txt", "newfile2.txt")); print_r($storage->listObject()); $res = $storage->delete("newfile.txt"); if (false == $res) { exit('delete failed.'); }
public function __construct() { $this->memcache = Alibaba::Cache('rsscabbitme'); }
function __constructor() { $this->cache = Alibaba::Cache(); session_set_save_handler(array($this, 'openSession'), array($this, 'closeSession'), array($this, 'readSession'), array($this, 'writeSession'), array($this, 'destroySession'), array($this, 'gcSession')); }
function ajax_get_sub() { global $_G; if (TAE) { $Storage = Alibaba::Storage(); $res = $Storage->get("cates"); if (!$res) { msg('未获取到分类,请先更新分类', 'error'); } $sub_cate = json_decode($res, true); if (!$sub_cate || !is_array($sub_cate)) { msg('分类读取失败,请先更新分类', 'errot'); } } else { $sub_cate = (include 'web/cache/cache_taobao_cate.php'); } $cid = intval($_GET['cid']); if ($sub_cate[$cid]) { $string = '<select name="postdb[cid]" class="select" ><option value="">------不限------</option>'; foreach ($sub_cate[$cid]['sub'] as $k => $v) { $string .= "<option value='" . $v[cid] . "'>" . $v[name] . "</option>"; } $string .= "</select>"; $string = htmlspecialchars($string); json(array('status' => 'success', 'msg' => $string)); } else { json(array('status' => 'error', 'msg' => '未找到子分类')); } }