本文整理汇总了PHP中zmf::uuid方法的典型用法代码示例。如果您正苦于以下问题:PHP zmf::uuid方法的具体用法?PHP zmf::uuid怎么用?PHP zmf::uuid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zmf
的用法示例。
在下文中一共展示了zmf::uuid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionLogin
function actionLogin()
{
$this->layout = 'common';
if (!Yii::app()->user->isGuest) {
$this->message(0, '您已登录,请勿重复操作', Yii::app()->createUrl('admin/index/index'));
}
$model = new LoginForm();
if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['LoginForm'])) {
$model->attributes = $_POST['LoginForm'];
if ($model->validate() && $model->login()) {
$arr = array('latestLoginTime' => zmf::now());
$uid = Yii::app()->user->id;
if (!$this->checkPower('user', $uid, true)) {
Yii::app()->user->logout();
$model->addError('username', '您不是管理员');
} else {
//User::model()->updateByPk($uid, $arr);
zmf::delCookie('checkWithCaptcha');
//只允许单点登录
$randKey = zmf::randMykeys(8);
zmf::setCookie('adminRandKey' . $uid, $randKey, 86400);
zmf::setFCache('adminRandKey' . $uid, $randKey, 86400);
//记录操作
//UserLog::add($uid, '登录后台'.Yii::app()->request->userHostAddress);
$uuid = zmf::uuid();
zmf::setCookie('userCheckedLogin' . $uid, $uuid, 86400);
$this->redirect(array('index/index'));
}
} else {
$times = zmf::getCookie('checkWithCaptcha');
zmf::setCookie('checkWithCaptcha', intval($times) + 1, 86400);
}
}
$data = array('model' => $model);
$this->render('login', $data);
}
示例2: actionUpload
public function actionUpload()
{
$uptype = zmf::filterInput($_GET['type'], 't', 1);
$logid = zmf::filterInput($_GET['id']);
//所属对象
$reImgsize = zmf::filterInput($_GET['imgsize']);
//返回图片的尺寸
$fileholder = zmf::filterInput($_GET['fileholder'], 't', 1);
//上传控件的ID
if (!isset($uptype) or !in_array($uptype, array('posts', 'siteinfo'))) {
$this->jsonOutPut(0, '请设置上传所属类型' . $uptype);
}
if (Yii::app()->request->getParam('PHPSESSID')) {
Yii::app()->session->close();
$res = Yii::app()->session->setSessionID(Yii::app()->request->getParam('PHPSESSID'));
Yii::app()->session->open();
}
if (Yii::app()->user->isGuest) {
$this->jsonOutPut(0, '请先登录');
}
if (!$fileholder) {
$fileholder = 'filedata';
}
if (!isset($_FILES[$fileholder]) || !is_uploaded_file($_FILES[$fileholder]["tmp_name"]) || $_FILES[$fileholder]["error"] != 0) {
$this->jsonOutPut(0, '无效上传,请重试');
}
$img = CUploadedFile::getInstanceByName($fileholder);
$ext = $img->getExtensionName();
$size = $img->getSize();
if ($size > zmf::config('imgMaxSize')) {
$this->jsonOutPut(0, '上传文件最大尺寸为:' . tools::formatBytes(zmf::config('imgMaxSize')));
}
$upExt = zmf::config("imgAllowTypes");
if (!preg_match('/^(' . str_replace('*.', '|', str_replace(';', '', $upExt)) . ')$/i', $ext)) {
$this->jsonOutPut(0, '上传文件扩展名必需为:' . $upExt);
}
$sizeinfo = getimagesize($_FILES[$fileholder]["tmp_name"]);
if ($sizeinfo['0'] < zmf::config('imgMinWidth') or $sizeinfo[1] < zmf::config('imgMinHeight')) {
$this->jsonOutPut(0, "要求上传的图片尺寸,宽不能不小于" . zmf::config('imgMinWidth') . "px,高不能小于" . zmf::config('imgMinHeight') . "px.");
}
$ctime = zmf::now();
$dir = zmf::uploadDirs($ctime, 'app', $uptype);
zmf::createUploadDir($dir);
$fileName = zmf::uuid() . '.' . $ext;
$origin = $dir;
if (move_uploaded_file($_FILES[$fileholder]["tmp_name"], $origin . $fileName)) {
$data = array();
$status = Posts::STATUS_NOTPASSED;
$data['uid'] = zmf::uid();
$data['logid'] = $logid;
$data['filePath'] = $fileName;
$data['fileDesc'] = '';
$data['classify'] = $uptype;
$data['covered'] = '0';
$data['cTime'] = $ctime;
$data['status'] = $status;
$data['width'] = $sizeinfo[0];
$data['height'] = $sizeinfo[1];
$data['size'] = $size;
$model = new Attachments();
$model->attributes = $data;
if ($model->save()) {
$attachid = $model->id;
$returnImgDir = zmf::getUpExtraUrl($ctime);
$saveName = $uptype . '/' . $returnImgDir . '/' . $fileName;
$accessKey = zmf::config('qiniuAk');
$secretKey = zmf::config('qiniuSk');
$bucket = zmf::config('qiniuBucket');
if ($accessKey && $secretKey && $bucket) {
$auth = new Auth($accessKey, $secretKey);
$token = $auth->uploadToken($bucket);
$uploadMgr = new UploadManager();
list($ret, $err) = $uploadMgr->putFile($token, $saveName, $origin . $fileName);
if ($err !== null) {
zmf::fp(var_export($err));
$this->jsonOutPut(0, '上传至云服务错误');
}
}
$returnimg = zmf::uploadDirs($ctime, 'site', $uptype) . $fileName;
$returnimg = zmf::getThumbnailUrl($returnimg, '650', $uptype);
$_attr = array('id' => $attachid, 'imgurl' => $returnimg);
$html = '';
if ($uptype == 'posts') {
//$html= $this->renderPartial('/posts/_addImg',array('data'=>$_attr),true);
}
$outPutData = array('status' => 1, 'attachid' => $attachid, 'imgsrc' => $returnimg, 'html' => $html);
$json = CJSON::encode($outPutData);
echo $json;
} else {
$this->jsonOutPut(0, '写入数据库错误');
}
}
}