Commit 36fa4b7b by 庄欣

2016.4.25

parent 1f064674
...@@ -5,6 +5,7 @@ username = root ...@@ -5,6 +5,7 @@ username = root
password = "MepaiSVSQL!@#321" password = "MepaiSVSQL!@#321"
dbname = yuepai dbname = yuepai
charset = utf8 charset = utf8
prefix = myp_
[application] [application]
controller = app/controller/ controller = app/controller/
......
...@@ -7,6 +7,7 @@ class Base extends Model ...@@ -7,6 +7,7 @@ class Base extends Model
protected $pk = "id"; protected $pk = "id";
protected $models = []; protected $models = [];
protected $errors = []; protected $errors = [];
public function initialize() public function initialize()
{ {
$this->addBehavior( $this->addBehavior(
...@@ -86,4 +87,10 @@ class Base extends Model ...@@ -86,4 +87,10 @@ class Base extends Model
return $mata->getAttributes($this); 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{ ...@@ -21,7 +21,8 @@ class TxImgCloud extends Cloud{
$this->config = [ $this->config = [
"appid" => self::AppId, "appid" => self::AppId,
'bucket' => self::Bucket, 'bucket' => self::Bucket,
'userid' => 0 'userid' => 0,
'file_id'=> urlencode(date("Y-m-d",NOW_TIME).'/'.uniqid().rand(0,1000))
]; ];
$this->format = ""; $this->format = "";
} }
...@@ -76,20 +77,10 @@ class TxImgCloud extends Cloud{ ...@@ -76,20 +77,10 @@ class TxImgCloud extends Cloud{
//获取签名 //获取签名
protected function getSign() protected function getSign()
{ {
$file = "./runtime/data/ImgCloud_sign.dat"; $cache = getCache(3600*24*30);
if (!file_exists("./runtime/data")) { $key = "IMG_SIGN";
mkdir("./runtime/data",true); if($cache->exists($key)) {
} else { return $cache->get($key);
@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;
}
}
} }
$config = [ $config = [
'a' => self::AppId, //appid 'a' => self::AppId, //appid
...@@ -106,7 +97,7 @@ class TxImgCloud extends Cloud{ ...@@ -106,7 +97,7 @@ class TxImgCloud extends Cloud{
} }
$str = implode("&",$url); $str = implode("&",$url);
$new_sign = base64_encode(hash_hmac("sha1",$str,self::SecretKey,true).$str); $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; 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