本文整理汇总了PHP中zmf::createUploadDir方法的典型用法代码示例。如果您正苦于以下问题:PHP zmf::createUploadDir方法的具体用法?PHP zmf::createUploadDir怎么用?PHP zmf::createUploadDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zmf
的用法示例。
在下文中一共展示了zmf::createUploadDir方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionExrates
/**
* 获取汇率
* 雅虎YQL https://developer.yahoo.com/yql/console/
* 请求语句 select * from yahoo.finance.xchange where pair="CNYUSD,CNYHKD"
* 示例 https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%3D%22CNYUSD%2CCNYHKD%22%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=
*/
public function actionExrates()
{
$units = tools::getUnits();
unset($units['CNY']);
$arr = array();
foreach ($units as $k => $v) {
$arr[] = 'CNY' . $k;
}
$str = join(',', $arr);
$url = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%3D%22{$str}%22%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=";
$output = zmf::curlget($url);
if (!$output) {
exit('Failed');
}
$rateArr = CJSON::decode($output);
$rateArr = $rateArr['query']['results']['rate'];
foreach ($rateArr as $val) {
$_key = str_replace('CNY', '', $val['id']);
$rates[$_key] = array('rate' => $val['Rate'], 'title' => tools::getUnits($_key));
}
$detailDir = Yii::app()->basePath . '/runtime/rates/';
zmf::createUploadDir($detailDir);
$dir = $detailDir . 'detail.log';
file_put_contents($dir, CJSON::encode($rates));
exit('well done');
}
示例2: autoLink
/**
* 给内容自动加上坐标链接
* @param type $data
* @return boolean
*/
public static function autoLink($data)
{
$path = zmf::config('async_push_path');
$host = zmf::config('async_push_host');
if (!$path || !$host) {
return false;
}
$content = $data['content'];
$url = $data['url'];
if (!$data || !$content || !$url) {
return false;
}
$id = uniqid();
$dir = Yii::app()->basePath . '/runtime/autolink';
zmf::createUploadDir($dir);
file_put_contents($dir . "/{$id}.txt", $content);
$asyncdata = "method=linkPoi&" . $url . "&fileid={$id}";
AsyncController::Async($asyncdata, 'get');
}
示例3: uploadDirs
public static function uploadDirs($ctime = '', $base = 'site', $type = 'posts', $return = '', $create = false)
{
$dirConfig = self::config('imgThumbSize');
$sizes = array_unique(array_filter(explode(",", $dirConfig)));
if (empty($sizes)) {
return false;
}
$dir = array();
if (!$ctime) {
$ctime = time();
}
$baseUrl = self::attachBase($base);
$_extra = self::getUpExtraUrl($ctime);
$_thedir = $baseUrl . $type . '/' . $_extra . '/';
if ($create) {
zmf::createUploadDir($_thedir);
}
foreach ($sizes as $size) {
$dir[$size] = $_thedir . $size . '_';
}
if (!empty($return)) {
$dir = $dir[$return];
}
return $dir;
}
示例4: writeSet
public function writeSet($array)
{
$dir = Yii::app()->basePath . "/runtime/config/";
zmf::createUploadDir($dir);
$dir = $dir . 'zmfconfig.php';
$values = array_values($array);
$keys = array_keys($array);
$len = count($keys);
$config = "<?php\n";
$config .= "return array(\n";
for ($i = 0; $i < $len; $i++) {
$config .= "'" . $keys[$i] . "'=> '" . addslashes($values[$i]) . "',\n";
}
$config .= ");\n";
$config .= "?>";
$fp = fopen($dir, 'w');
$fw = fwrite($fp, $config);
if (!$fw) {
fclose($fp);
return false;
} else {
fclose($fp);
return true;
}
}
示例5: actionSimpleUpload
/**
* 不入数据库的上传
* 不做压缩和缩略图处理
*/
public function actionSimpleUpload()
{
$uptype = zmf::filterInput($_GET['type'], 't', 1);
$fileholder = zmf::filterInput($_GET['fileholder'], 't', 1);
//上传控件的ID
$fileName = zmf::filterInput($_GET['fileName'], 't', 1);
//上传后保存名字
$keyid = zmf::filterInput($_GET['keyid']);
//所属对象ID
if (!isset($uptype) or !in_array($uptype, array('topArea', 'avatar'))) {
$this->jsonOutPut(0, '请设置上传所属类型' . $uptype);
}
if (Yii::app()->request->getParam('PHPSESSID')) {
Yii::app()->session->close();
Yii::app()->session->setSessionID(Yii::app()->request->getParam('PHPSESSID'));
Yii::app()->session->open();
}
if (Yii::app()->user->isGuest) {
$this->jsonOutPut(0, Yii::t('default', 'loginfirst'));
}
if ($uptype == 'avatar' && !$keyid) {
$this->jsonOutPut(0, '缺少参数');
}
$checkInfo = UserPower::check('addImage', true);
if (!$checkInfo['status']) {
$this->jsonOutPut(0, $checkInfo['msg']);
}
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);
}
if (!$fileName) {
$fileName = uniqid() . '.' . $ext;
}
if ($uptype == 'avatar') {
$fileName = $keyid . '.jpg';
}
if ($uptype == 'topArea') {
$todir = zmf::attachBase('app') . '/daodao/';
$returnDir = zmf::attachBase('site') . '/daodao/';
} elseif ($uptype == 'avatar') {
$todir = zmf::attachBase('app') . '/avatar/origin/' . $keyid . '/';
$todir2 = zmf::attachBase('app') . '/avatar/big/' . $keyid . '/';
$todir3 = zmf::attachBase('app') . '/avatar/small/' . $keyid . '/';
$returnDir = zmf::attachBase('site') . '/avatar/small/' . $keyid . '/';
}
zmf::createUploadDir($todir);
if (move_uploaded_file($_FILES[$fileholder]["tmp_name"], $todir . $fileName)) {
if ($uptype == 'avatar') {
$image = Yii::app()->image->load($todir . $fileName);
zmf::createUploadDir($todir2);
zmf::createUploadDir($todir3);
$image->smart_resize(100, 100)->quality(95);
$image->save($todir2 . $fileName);
$image->smart_resize(50, 50)->quality(95);
$image->save($todir3 . $fileName);
}
$outPutData = array('status' => 1, 'imgsrc' => $returnDir . $fileName, 'attachid' => '');
$json = CJSON::encode($outPutData);
echo $json;
} else {
$this->jsonOutPut(0, '上传失败');
}
}
示例6: 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, '写入数据库错误');
}
}
}
示例7: addPostImg
public function addPostImg()
{
$logid = zmf::filterInput($_GET['id']);
$uptype = zmf::filterInput($_GET['imgtype'], 't', 1);
if (!$uptype) {
$this->jsonOutPut(0, '不允许的分类');
}
if (!$logid) {
$logid = 0;
}
$ctime = time();
$dirs = zmf::upDirs($ctime, 'app', $uptype);
$origin = $dirs['origin'] . '/';
unset($dirs['origin']);
zmf::createUploadDir($origin);
$img = CUploadedFile::getInstanceByName('filedata');
if ($img->getHasError()) {
$this->jsonOutPut(0, '上传有误,请重试');
}
$ext = $img->getExtensionName();
$upExt = zmf::config("imgAllowTypes");
if (!preg_match('/^(' . str_replace('*.', '|', str_replace(';', '', $upExt)) . ')$/i', $ext)) {
$this->jsonOutPut(0, '上传文件扩展名必需为:' . $upExt);
}
$size = $img->getSize();
if ($size > zmf::config('imgMaxSize')) {
$this->jsonOutPut(0, '上传文件最大尺寸为:' . tools::formatBytes(zmf::config('imgMaxSize')));
}
$_imgInfo = getimagesize($_FILES["filedata"]["tmp_name"]);
if ($_imgInfo['0'] < zmf::config('imgMinWidth') or $_imgInfo[1] < zmf::config('imgMinHeight')) {
$this->jsonOutPut(0, "宽不能小于" . zmf::config('imgMinWidth') . "px<br/>高不能小于" . zmf::config('imgMinHeight') . "px");
}
$fileName = uniqid() . '.' . $ext;
// $_extra=self::getUpExtraUrl($ctime);
// $filePath=$_extra.'/'.$fileName;
if (move_uploaded_file($_FILES["filedata"]["tmp_name"], $origin . $fileName)) {
$uid = Yii::app()->user->id;
$uid = 1;
$data['uid'] = $uid;
$data['logid'] = $logid;
$data['filePath'] = $fileName;
$data['fileDesc'] = $fileName;
$data['classify'] = $uptype;
$data['covered'] = '0';
$data['cTime'] = $ctime;
$data['status'] = Posts::STATUS_DELED;
$model = new Attachments();
$model->attributes = $data;
if ($model->validate()) {
if (!$model->save()) {
$this->jsonOutPut(0, '写入数据库出错');
} else {
$attachid = $model->id;
}
} else {
$this->jsonOutPut(0, '数据验证错误');
}
$image = Yii::app()->image->load($origin . $fileName);
$_quality = zmf::config('imgQuality');
$quality = isset($quality) ? $quality : 100;
foreach ($dirs as $dk => $_dir) {
zmf::createUploadDir($_dir);
if ($_imgInfo[0] < $dk && $_imgInfo[1] < $dk) {
$image->resize($_imgInfo[0], $_imgInfo[1])->quality($quality);
} else {
$image->smart_resize($dk, ceil($dk * 0.75))->quality($quality);
}
$image->save($_dir . '/' . $fileName, false);
}
$_dir = zmf::upDirs($ctime, 'site', $uptype, '600');
$returnimg = $_dir . '/' . $fileName;
$data = array('imgsrc' => $returnimg, 'attachid' => $attachid);
$this->jsonOutPut(1, $data);
}
}
示例8: actionSitemap
/**
* 生成站点地图
*/
public function actionSitemap()
{
if (!zmf::uid()) {
$this->redirect(zmf::config('domain'));
}
$a = $_GET['a'];
$basedir = Yii::app()->basePath . '/../attachments/sitemap/';
zmf::createUploadDir($basedir);
$total = Chengyu::model()->count('status=' . Posts::STATUS_PASSED);
$perFileNum = 1000;
//每个文件的连接数
$now = zmf::time('', 'Y-m-d');
$page = isset($_GET['page']) ? $_GET['page'] : 1;
if ($a == 'indexer') {
$dir = $basedir . 'indexer.xml';
$str = '';
for ($i = 1; $i <= $total / $perFileNum + 1; $i++) {
$str .= "<sitemap><loc>http://ciyuxinjie.org/attachments/sitemap/sitemap{$i}.xml</loc><lastmod>{$now}</lastmod></sitemap>";
}
$content = <<<SITEMAP
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">{$str}</sitemapindex>
SITEMAP;
file_put_contents($dir, $content);
exit;
} elseif ($a == 'create') {
$criteria = new CDbCriteria();
$criteria->condition = 'status=' . Posts::STATUS_PASSED;
$criteria->select = 'id';
$criteria->order = 'id ASC';
$criteria->limit = $perFileNum;
$criteria->offset = ($page - 1) * $perFileNum;
$items = Chengyu::model()->findAll($criteria);
if (!empty($items)) {
foreach ($items as $v) {
$str .= "<url><loc>http://ciyuxinjie.org/detail/{$v['id']}</loc><lastmod>{$now}</lastmod><changefreq>weekly</changefreq><priority>0.8</priority></url>";
}
$dir = $basedir . "sitemap{$page}.xml";
$content = <<<SITEMAP
<?xml version='1.0' encoding='UTF-8'?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">{$str}</urlset>
SITEMAP;
file_put_contents($dir, $content);
$this->message(1, "正在处理{$page}页", Yii::app()->createUrl('site/sitemap', array('a' => 'create', 'page' => $page + 1)));
} else {
exit('well done');
}
} else {
exit('不允许的操作');
}
}