Commit 36fa4b7b by 庄欣

2016.4.25

parent 1f064674
......@@ -5,6 +5,7 @@ username = root
password = "MepaiSVSQL!@#321"
dbname = yuepai
charset = utf8
prefix = myp_
[application]
controller = app/controller/
......
......@@ -7,6 +7,7 @@ class Base extends Model
protected $pk = "id";
protected $models = [];
protected $errors = [];
public function initialize()
{
$this->addBehavior(
......@@ -86,4 +87,10 @@ class Base extends Model
return $mata->getAttributes($this);
}
public function getPrefix()
{
$config = new \Phalcon\Config\Adapter\Ini(APP_PATH.'./app/config/config.ini');
return $config->database->prefix;
}
}
......@@ -21,7 +21,8 @@ class TxImgCloud extends Cloud{
$this->config = [
"appid" => self::AppId,
'bucket' => self::Bucket,
'userid' => 0
'userid' => 0,
'file_id'=> urlencode(date("Y-m-d",NOW_TIME).'/'.uniqid().rand(0,1000))
];
$this->format = "";
}
......@@ -76,20 +77,10 @@ class TxImgCloud extends Cloud{
//获取签名
protected function getSign()
{
$file = "./runtime/data/ImgCloud_sign.dat";
if (!file_exists("./runtime/data")) {
mkdir("./runtime/data",true);
} else {
@chmod("./runtime/data",0777);
}
if (file_exists($file)) {
$sign = file_get_contents($file);
if ($sign) {
$sign = json_decode($sign);
if (NOW_TIME < $sign->to_time) {
// return $sign->data;
}
}
$cache = getCache(3600*24*30);
$key = "IMG_SIGN";
if($cache->exists($key)) {
return $cache->get($key);
}
$config = [
'a' => self::AppId, //appid
......@@ -106,7 +97,7 @@ class TxImgCloud extends Cloud{
}
$str = implode("&",$url);
$new_sign = base64_encode(hash_hmac("sha1",$str,self::SecretKey,true).$str);
file_put_contents($file,json_encode(['to_time'=>$config['e'],'data'=>$new_sign]));
$cache->save($key,$new_sign);
return $new_sign;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment