function uploadCert($fileId)
 {
     $managerId = $this->mid;
     $path = SITE_PATH . '\\Cert\\wxzf\\' . $managerId;
     $file = M('file')->find($fileId);
     $file['savepath'] = substr($file['savepath'], 0, strlen($file['savepath']) - 1);
     $filename = SITE_PATH . '\\Uploads\\Download\\' . $file['savepath'] . '\\' . $file['savename'];
     //         dump($file);
     //         dump($filename);
     //         dump(file_exists($filename));
     //         die;
     if (!file_exists($filename)) {
         $this->error('上传失败');
         exit;
     }
     // 	    $extend = $file ['ext'];
     // 	    if (! ($extend == 'pem' || $extend == 'p12' )) {
     // 	        $this->error('上传证书格式有误,扩展名应为 pem');
     // 	        exit();
     // 	    }
     $mkres = mkdirs($path);
     $content = wp_file_get_contents($filename);
     $res = file_put_contents($path . '\\' . $file['name'], $content);
     return $res;
 }
Exemple #2
0
 public function settingsDisplay($settings)
 {
     global $_GPC, $_W;
     if (checksubmit()) {
         load()->func('file');
         mkdirs(ZC_ROOT . '/cert');
         $r = true;
         $pemname = isset($pemname) ? $pemname : time();
         if (!empty($_GPC['cert'])) {
             $ret = file_put_contents(ZC_ROOT . '/cert/apiclient_cert.pem.' . $pemname, trim($_GPC['cert']));
             $r = $r && $ret;
         }
         if (!empty($_GPC['key'])) {
             $ret = file_put_contents(ZC_ROOT . '/cert/apiclient_key.pem.' . $pemname, trim($_GPC['key']));
             $r = $r && $ret;
         }
         if (!empty($_GPC['ca'])) {
             $ret = file_put_contents(ZC_ROOT . '/cert/rootca.pem.' . $pemname, trim($_GPC['ca']));
             $r = $r && $ret;
         }
         if (!$r) {
             message('证书保存失败, 请保证 /addons/hx_zhongchou/cert/ 目录可写');
         }
         $cfg = array('noticeemail' => $_GPC['noticeemail'], 'kfid' => $_GPC['kfid'], 'k_templateid' => $_GPC['k_templateid'], 'kfirst' => $_GPC['kfirst'], 'kfoot' => $_GPC['kfoot'], 'm_templateid' => $_GPC['m_templateid'], 'mfirst' => $_GPC['mfirst'], 'mfoot' => $_GPC['mfoot'], 'ispublish' => intval($_GPC['ispublish']), 'shopname' => $_GPC['shopname'], 'address' => $_GPC['address'], 'phone' => $_GPC['phone'], 'email' => $_GPC['email'], 'officialweb' => $_GPC['officialweb'], 'description' => htmlspecialchars_decode($_GPC['description']), 'appid' => trim($_GPC['appid']), 'secret' => trim($_GPC['secret']), 'mchid' => trim($_GPC['mchid']), 'password' => trim($_GPC['password']), 'ip' => trim($_GPC['ip']), 'pemname' => $pemname);
         if (!empty($_GPC['logo'])) {
             $cfg['logo'] = $_GPC['logo'];
         }
         if ($this->saveSettings($cfg)) {
             message('保存成功', 'refresh');
         }
     }
     load()->func('tpl');
     include $this->template('setting');
 }
Exemple #3
0
 public function settingsDisplay($settings)
 {
     global $_W, $_GPC, $frames;
     require_once MB_ROOT . '/source/backlist.class.php';
     $backlist = new backlist();
     $frames = $backlist->getModuleFrames('feng_fightgroups');
     $backlist->_calc_current_frames2($frames);
     load()->func('tpl');
     load()->model('account');
     $modules = uni_modules();
     if (checksubmit()) {
         load()->func('file');
         $r = mkdirs(MB_ROOT . '/cert/' . $_W['uniacid']);
         if (!empty($_GPC['cert'])) {
             $ret = file_put_contents(MB_ROOT . '/cert/' . $_W['uniacid'] . '/apiclient_cert.pem', trim($_GPC['cert']));
             $r = $r && $ret;
         }
         if (!empty($_GPC['key'])) {
             $ret = file_put_contents(MB_ROOT . '/cert/' . $_W['uniacid'] . '/apiclient_key.pem', trim($_GPC['key']));
             $r = $r && $ret;
         }
         if (!$r) {
             message('证书保存失败, 请保证 /addons/feng_fightgroups/cert/ 目录可写');
         }
         $dat = array('userrefund' => $_GPC['userrefund'], 'gettime' => $_GPC['gettime'], 'goodstip' => $_GPC['goodstip'], 'openfirstpay' => $_GPC['openfirstpay'], 'firstpay' => $_GPC['firstpay'], 'refundpercent' => $_GPC['refundpercent'], 'status' => $_GPC['status'], 'sharestatus' => $_GPC['sharestatus'], 'mode' => $_GPC['mode'], 'picmode' => $_GPC['picmode'], 'mchid' => $_GPC['mchid'], 'apikey' => $_GPC['apikey'], 'share_title' => $_GPC['share_title'], 'share_image' => $_GPC['share_image'], 'share_desc' => $_GPC['share_desc'], 'share_imagestatus' => $_GPC['share_imagestatus'], 'pay_suc' => $_GPC['pay_suc'], 'm_pay' => $_GPC['m_pay'], 'm_tuan' => $_GPC['m_tuan'], 'm_cancle' => $_GPC['m_cancle'], 'm_ref' => $_GPC['m_ref'], 'm_send' => $_GPC['m_send'], 'pay_remark' => $_GPC['pay_remark'], 'tuan_remark' => $_GPC['tuan_remark'], 'tuan_suc' => $_GPC['tuan_suc'], 'cancle_remark' => $_GPC['cancle_remark'], 'cancle' => $_GPC['cancle'], 'send_remark' => $_GPC['send_remark'], 'send' => $_GPC['send'], 'ref_remark' => $_GPC['ref_remark'], 'ref' => $_GPC['ref'], 'sname' => $_GPC['sname'], 'slogo' => $_GPC['slogo'], 'marketprice1' => $_GPC['marketprice1'], 'marketprice2' => $_GPC['marketprice2'], 'marketprice3' => $_GPC['marketprice3'], 'marketprice4' => $_GPC['marketprice4'], 'productprice1' => $_GPC['productprice1'], 'productprice2' => $_GPC['productprice2'], 'productprice3' => $_GPC['productprice3'], 'productprice4' => $_GPC['productprice4'], 'copyright' => $_GPC['copyright'], 'content' => htmlspecialchars_decode($_GPC['content']));
         if ($this->saveSettings($dat)) {
             message('保存成功', 'refresh');
         }
     }
     //这里来展示设置项表单
     include $this->template('web/setting');
 }
Exemple #4
0
 /**
  * Function used to write a new cache file
  *
  * This function will create a new JSON file in which the payload will be saved for the specified amount. By default the cached data needs to be renewed manually.
  *
  * @param string $name The name under which the cached data will be saved.
  * @param mixed $payload Any data to be stored in this cache file (strings, integers, arrays, ...)
  * @param int $lifetime How long should the data be kept (in minutes). 0 means infinite.
  * @param bool $created Setting this to true will automatically create the folders needed to store the given cache key
  *
  * @return bool Whether or not the operation succeeded.
  */
 static function Write($name, $payload, $lifetime = 0, $create = false)
 {
     if (CACHE) {
         if (!is_dir(CACHE_DIR . dirname($name))) {
             if ($create) {
                 mkdirs(CACHE_DIR . dirname($name));
             } else {
                 return false;
             }
         }
         $time = time();
         // Get current time so we can use it for lifetime calculation
         if ($lifetime != 0) {
             $expires = $time + $lifetime * 60;
         } else {
             $expires = 0;
         }
         $data = array('name' => $name, 'created' => $time, 'expires' => $expires, 'lifetime' => $lifetime, 'payload' => $payload);
         file_put_contents(CACHE_DIR . $name . '.json', json_encode($data));
         Lightwork::Log('Cache stored: ' . $name, Lightwork::LOG_DEBUG);
         return true;
     } else {
         return false;
     }
 }
Exemple #5
0
 /**
  * Constructor
  * 
  * @param string $tpl_name, Name of Template for rendering
  */
 public function __construct($tpl_name)
 {
     $this->tpl_driver_class = Config::get('env.tplclass', 'Smarty');
     $this->tpl_postfix = Config::get('env.tplpostfix', '.htm');
     $this->tpl_name = $this->tpl_realpath($tpl_name);
     $this->modroot = SimPHP::$gConfig['modroot'];
     $tpl_config = array('caching' => Config::get('env.tplcache', 0), 'cache_lifetime' => Config::get('env.tplcache_expires', 300), 'compile_check' => Config::get('env.tplcompile_check', 1), 'force_compile' => Config::get('env.tplforce_compile', 0), 'debugging' => Config::get('env.tpldebug', 0));
     $tpldir = Config::get('env.sitetheme', 'default');
     if ($this->modroot != 'modules') {
         $tpldir = $this->modroot;
     }
     $template_dir = SIMPHP_ROOT . "/themes/{$tpldir}";
     $compiled_dir = SIMPHP_ROOT . Config::get('env.tplcachedir') . "/{$tpldir}/compiled";
     $cached_dir = SIMPHP_ROOT . Config::get('env.tplcachedir') . "/{$tpldir}/cached";
     $tpl_config['template_dir'] = $template_dir;
     $tpl_config['compile_dir'] = $compiled_dir;
     $tpl_config['cache_dir'] = $cached_dir;
     try {
         if (!is_dir($compiled_dir) && !mkdirs($compiled_dir) && !is_writable($compiled_dir)) {
             throw new DirWritableException($compiled_dir);
         }
         if (Config::get('env.tplcache') && !is_dir($cached_dir) && !mkdirs($cached_dir) && !is_writable($cached_dir)) {
             throw new DirWritableException($cached_dir);
         }
     } catch (DirWritableException $e) {
         trigger_error($e->getMessage(), E_USER_ERROR);
     }
     $this->tpl = Template::I(array('driverClass' => $this->tpl_driver_class, 'driverConfig' => $tpl_config));
     $this->assign('contextpath', Config::get('env.contextpath', '/'));
     $this->assign_by_ref('user', $GLOBALS['user']);
     //add default output filter
     $this->add_output_filter(array($this, 'filter_output'));
 }
Exemple #6
0
 public function settingsDisplay($settings)
 {
     global $_W, $_GPC;
     load()->func('tpl');
     if (checksubmit()) {
         load()->func('file');
         $r = mkdirs(MB_ROOT . '/cert/' . $_W['uniacid']);
         if (!empty($_GPC['cert'])) {
             $ret = file_put_contents(MB_ROOT . '/cert/' . $_W['uniacid'] . '/apiclient_cert.pem', trim($_GPC['cert']));
             $r = $r && $ret;
         }
         if (!empty($_GPC['key'])) {
             $ret = file_put_contents(MB_ROOT . '/cert/' . $_W['uniacid'] . '/apiclient_key.pem', trim($_GPC['key']));
             $r = $r && $ret;
         }
         if (!$r) {
             message('证书保存失败, 请保证 /addons/feng_fightgroups/cert/ 目录可写');
         }
         $dat = array('status' => $_GPC['status'], 'mode' => $_GPC['mode'], 'picmode' => $_GPC['picmode'], 'mchid' => $_GPC['mchid'], 'apikey' => $_GPC['apikey'], 'share_title' => $_GPC['share_title'], 'share_image' => $_GPC['share_image'], 'share_desc' => $_GPC['share_desc'], 'url' => $_GPC['url'], 'pay_suc' => $_GPC['pay_suc'], 'm_pay' => $_GPC['m_pay'], 'm_tuan' => $_GPC['m_tuan'], 'm_cancle' => $_GPC['m_cancle'], 'm_ref' => $_GPC['m_ref'], 'm_send' => $_GPC['m_send'], 'pay_remark' => $_GPC['pay_remark'], 'tuan_remark' => $_GPC['tuan_remark'], 'tuan_suc' => $_GPC['tuan_suc'], 'cancle_remark' => $_GPC['cancle_remark'], 'cancle' => $_GPC['cancle'], 'send_remark' => $_GPC['send_remark'], 'send' => $_GPC['send'], 'ref_remark' => $_GPC['ref_remark'], 'ref' => $_GPC['ref'], 'sname' => $_GPC['sname'], 'slogo' => $_GPC['slogo'], 'copyright' => $_GPC['copyright'], 'content' => htmlspecialchars_decode($_GPC['content']));
         if ($this->saveSettings($dat)) {
             message('保存成功', 'refresh');
         }
     }
     //这里来展示设置项表单
     include $this->template('setting');
 }
function logging($level = 'info', $message = '')
{
    $filename = IA_ROOT . '/data/logs/' . date('Ymd') . '.log';
    load()->func('file');
    mkdirs(dirname($filename));
    $content = date('Y-m-d H:i:s') . " {$level} :\n------------\n";
    if (is_string($message)) {
        $content .= "String:\n{$message}\n";
    }
    if (is_array($message)) {
        $content .= logging_implode($message);
    }
    if ($message == 'get') {
        $content .= "GET:\n";
        foreach ($_GET as $key => $value) {
            $content .= sprintf("%s : %s ;\n", $key, $value);
        }
    }
    if ($message == 'post') {
        $content .= "POST:\n";
        foreach ($_POST as $key => $value) {
            $content .= sprintf("%s : %s ;\n", $key, $value);
        }
    }
    $content .= "\n";
    $fp = fopen($filename, 'a+');
    fwrite($fp, $content);
    fclose($fp);
}
Exemple #8
0
function template_compile($from, $to) {
	$path = dirname($to);
	if (!is_dir($path))
		mkdirs($path);
	$content = template_parse(file_get_contents($from));
	file_put_contents($to, $content);
}
Exemple #9
0
    public function create_tpl()
    {
        mkdirs(APP_TPL . 'Index');
        if (file_exists(APP_TPL . 'Index/index.html')) {
            return;
        }
        $str = <<<EOT
<html>
<head>
\t<title>框架测试页面内容</title>
\t<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
</head>
<body>
\t<div style="margin 100px auto"><h2><{\$val}></h2></div>
\t<div style="margin 100px auto"><h2><{if (1 == 1)}>IF 语句的测试1<{/if}></h2></div>
\t<div style="margin 100px auto"><h2><{if (1 == 2)}>IF 语句的测试2<{/if}></h2></div>
\t<div style="margin 100px auto">
\t\t<h2>
\t\t\t<h1>第一种循环例子</h1>
\t\t\t<{ foreach (\$tarr as \$t)}>
\t\t\t<{\$t}><br/>
\t\t\t<{/foreach}>
\t\t\t<h1>第二种循环例子</h1>
\t\t\t<{ loop (\$tarr as \$t) }>
\t\t\t<{\$t}><br/>
\t\t\t<{/loop}>
\t\t</h2>
\t</div>
</body>
</html>
EOT;
        file_put_contents(APP_TPL . 'Index/index.html', $str);
    }
Exemple #10
0
 public function index()
 {
     $qrcode_width = intval($_GET['qw']);
     $qrcode_height = intval($_GET['qh']);
     $qrcode_type = trim($_GET['qt']);
     $qrcode_content = trim($_GET['qc']);
     $qrcode_logo = trim($_GET['ql']);
     $hash = md5($qrcode_content . $qrcode_width . $qrcode_height . $qrcode_type . $qrcode_logo);
     $map = array('hash' => $hash);
     $one = D('qrcode')->field('file_path')->where($map)->find();
     if ($one) {
         $qrcode_file = $one['file_path'];
     } else {
         $file_dir = 'Uploads/' . date('Y') . '/' . date('m') . '/' . date('d');
         mkdirs($file_dir);
         $qrcode_file = $file_dir . '/' . $hash . '.png';
     }
     //$qrcode_content = htmlspecialchars_decode($qrcode_content);
     if (!$one) {
         qrcode($qrcode_file, $qrcode_content, $qrcode_logo, $qrcode_width, $qrcode_height, $qrcode_type);
         //保存到数据库
         $data = array('hash' => $hash, 'width' => $qrcode_width, 'height' => $qrcode_height, 'logo' => $qrcode_logo, 'content' => $qrcode_content, 'file_path' => $qrcode_file, 'dateline' => time());
         D('qrcode')->add($data);
     }
     $qrcode_url = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $qrcode_file;
     //qrcode
     $qrcode_href = 'http://' . $_SERVER['HTTP_HOST'] . '/qr.html?hash=' . $hash;
     $this->assign('qrcode_width', $qrcode_width);
     $this->assign('qrcode_height', $qrcode_height);
     $this->assign('qrcode_url', $qrcode_url);
     $this->assign('qrcode_href', $qrcode_href);
     $this->display();
 }
Exemple #11
0
function AddMsg_User($uid, $msg)
{
    mkdirs(ONEZ_ROOT . './onezdata/message/users');
    $file = ONEZ_ROOT . './onezdata/message/users/' . $uid . '.php';
    !file_exists($file) && writeover($file, '<?php die();?>');
    writeover($file, $msg, "a+");
}
Exemple #12
0
 public function view_orderWeighing()
 {
     $config_path = 'images/cz';
     $time = date("Y/m/d", time());
     $dirPath = $config_path . '/' . $time;
     if (!is_dir($dirPath)) {
         mkdirs($dirPath, 0777);
     }
     $this->smarty->assign('time', $time);
     $navlist = array(array('url' => '', 'title' => '出库'), array('url' => 'index.php?mod=waitWeighing&act=waitWeighingList', 'title' => '待称重'), array('url' => '', 'title' => '称重扫描<小包>'));
     $secnev = 3;
     $toplevel = 2;
     $secondlevel = 26;
     //$userName = $_SESSION['username'];
     //$this->smarty->assign('secnev','1');
     $this->smarty->assign('navlist', $navlist);
     $this->smarty->assign('secnev', $secnev);
     $this->smarty->assign('toplevel', $toplevel);
     $this->smarty->assign('secondlevel', $secondlevel);
     $partion_list = CommonModel::getChannelNameByIds('all');
     //$channel_list = CommonModel::getCarrierChannelByIds('all');
     $channel_list = C('MAILWAYCONFIG');
     $this->smarty->assign("partion_list", $partion_list);
     $this->smarty->assign("channel_list", $channel_list);
     //$this->smarty->assign('toptitle', '货品资料管理');
     $this->smarty->display('orderWeighing.htm');
 }
Exemple #13
0
 /**
  * 生成缓存文件
  */
 public function createCache()
 {
     $path_file = UPLOAD_PATH . '/cache/';
     $file_name = $path_file . date('Ymd', time()) . '.txt';
     if (!file_exists($file_name)) {
         foreach ($data2 as $v) {
             $pinyin = $this->pinyin($v['name']);
             $array['arr'][] = [$pinyin => $v['name']];
         }
         $data3 = $this->m['columns']->getAllByField('module', 'ksys', 'id');
         $data4 = $this->m['article']->getAll(arrayToString($data3), 'title');
         foreach ($data4 as $v) {
             $pinyin = $this->pinyin($v['title']);
             $array['arr'][] = [$pinyin => $v['title']];
         }
         if (!file_exists($path_file)) {
             mkdirs($path_file);
         }
         $open = fopen($file_name, "a");
         fwrite($open, serialize($array));
         fclose($open);
     } else {
         return;
     }
 }
 function _thumb_media_id($cover_id)
 {
     $cover = get_cover($cover_id);
     $driver = C('PICTURE_UPLOAD_DRIVER');
     if ($driver != 'Local' && !file_exists(SITE_PATH . $cover['path'])) {
         // 先把图片下载到本地
         $pathinfo = pathinfo(SITE_PATH . $cover['path']);
         mkdirs($pathinfo['dirname']);
         $content = wp_file_get_contents($cover['url']);
         $res = file_put_contents(SITE_PATH . $cover['path'], $content);
         if ($res) {
             return '';
         }
     }
     $path = $cover['path'];
     if (!$path) {
         return '';
     }
     $param['type'] = 'thumb';
     $param['media'] = '@' . realpath(SITE_PATH . $path);
     $url = 'https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=' . get_access_token();
     $res = post_data($url, $param, true);
     if (isset($res['errcode']) && $res['errcode'] != 0) {
         return '';
     }
     $map['cover_id'] = $cover_id;
     $map['manager_id'] = $this->mid;
     $this->where($map)->setField('thumb_media_id', $res['media_id']);
     return $res['media_id'];
 }
 /**
  * 图像缩略处理
  * 可处理图像类型jpg和png
  * 如果原图像宽度小于指定宽度, 直接复制到目标地址
  * 如果原图像宽度大于指定宽度, 按比例缩放至指定宽度后保存至目标地址
  *
  * @param string $srcfile   原图像地址
  * @param string $desfile   新图像地址
  * @param int|number $width 大于0
  * @return bool true|error
  */
 public static function imageThumb($srcfile, $desfile, $width = 600)
 {
     if (!file_exists($srcfile)) {
         return error('-1', '原图像不存在');
     }
     if (intval($width) <= 0) {
         return error('-1', '缩放宽度无效');
     }
     $des = dirname($desfile);
     //创建存放目录
     if (!file_exists($des)) {
         if (!mkdirs($des)) {
             return error('-1', '创建目录失败');
         }
     } elseif (!is_writable($des)) {
         return error('-1', '目录无法写入');
     }
     //原图像信息
     $org_info = @getimagesize($srcfile);
     if ($width > $org_info[0]) {
         copy($srcfile, $desfile);
         return true;
     }
     if ($org_info) {
         if ($org_info[2] == 1) {
             //gif不处理
             if (function_exists("imagecreatefromgif")) {
                 $img_org = imagecreatefromgif($srcfile);
             }
         } elseif ($org_info[2] == 2) {
             if (function_exists("imagecreatefromjpeg")) {
                 $img_org = imagecreatefromjpeg($srcfile);
             }
         } elseif ($org_info[2] == 3) {
             if (function_exists("imagecreatefrompng")) {
                 $img_org = imagecreatefrompng($srcfile);
             }
         }
     } else {
         return error('-1', '获取原始图像信息失败');
     }
     //源图像的宽高比
     $scale_org = $org_info[0] / $org_info[1];
     //缩放后的高
     $height = $width / $scale_org;
     if (function_exists("imagecreatetruecolor") && function_exists("imagecopyresampled") && @($img_dst = imagecreatetruecolor($width, $height))) {
         imagecopyresampled($img_dst, $img_org, 0, 0, 0, 0, $width, $height, $org_info[0], $org_info[1]);
     } else {
         return error('-1', 'PHP环境不支持图片处理');
     }
     if (function_exists('imagejpeg')) {
         imagejpeg($img_dst, $desfile);
     } elseif (function_exists('imagepng')) {
         imagepng($img_dst, $desfile);
     }
     imagedestroy($img_dst);
     imagedestroy($img_org);
     return true;
 }
Exemple #16
0
 protected function create_compile_file($compile_file, $content)
 {
     $compile_dir = dirname($compile_file);
     if (!is_dir($compile_dir)) {
         mkdirs($compile_dir);
     }
     file_put_contents($compile_file, $content, LOCK_EX) or exit($compile_dir . '目录没有写入权限');
 }
/**
 * 创建一个目录树
 *
 * 用法:
 * <code>
 * mkdirs('/top/second/3rd');
 * </code>
 *
 * @param string $dir
 * @param int $mode
 */
function mkdirs($dir, $mode = 0777)
{
    if (!is_dir($dir)) {
        mkdirs(dirname($dir), $mode);
        return mkdir($dir, $mode);
    }
    return true;
}
Exemple #18
0
 /**
  * 初始化
  * @author wave
  */
 protected static function init()
 {
     $path = !empty(self::$path) ? self::$path : CACHE_DIR;
     //缓存路径
     self::$cache_dir = CACHE . DS . $path . DS;
     if (!file_exists(ROOT . DS . APP_PATH . DS . self::$cache_dir)) {
         mkdirs(self::$cache_dir);
     }
 }
Exemple #19
0
/**
 * 生成日志存放目录
 * 
 * 按yyyymmdd格式
 */
function logging_mkdir() {
	$logRoot = IA_ROOT . '/data/logs/';
	$logDir = $logRoot . date('Ymd');
	if (mkdirs($logDir)) {
		return $logDir . '/';
	} else {
		return false;
	}
}
Exemple #20
0
function buildAppDir()
{
    if (is_writable(SITE_PATH . '/runtime')) {
        mkdirs(array(LIB_PATH, RUNTIME_PATH, CONFIG_PATH, COMMON_PATH, LANG_PATH, CACHE_PATH, TMPL_PATH, TMPL_PATH . 'default/', LOG_PATH, TEMP_PATH, DATA_PATH, LIB_PATH . 'Model/', LIB_PATH . 'Action/'));
    } else {
        header("Content-Type:text/html; charset=utf-8");
        exit('<div style=\'font-weight:bold;float:left;width:345px;text-align:center;border:1px solid silver;background:#E8EFFF;padding:8px;color:red;font-size:14px;font-family:Tahoma\'>项目目录不可写,目录无法自动生成!<BR>请使用项目生成器或者手动生成项目目录~</div>');
    }
}
Exemple #21
0
 function Upload_ovoafile($files, $dizhi)
 {
     global $quid, $allowed_file, $allowed_size, $Db, $db_prefix, $Base, $ovoa, $FormExt, $web_url, $dizhi, $rstform, $introduce;
     $attachment = $files['tmp_name'];
     $extention = strrchr($files['name'], ".");
     $extention = strtolower($extention);
     $showtime = date("Y-m-d H:i:s");
     $mypcyzm = str_replace("-", "", $showtime);
     $mypcyzm = str_replace(" ", "", $mypcyzm);
     $mypcyzm = str_replace(":", "", $mypcyzm);
     $attachment = $files['tmp_name'];
     $extention = strrchr($files['name'], ".");
     $gzname = explode(".", $files['name']);
     $top_docname = $gzname[0];
     //文件名称
     $docname = $gzname[1];
     $extention = strtolower($extention);
     $attachment_name = date("YmdHi") . "_" . rand(1000, 9999) . "." . $docname;
     $filna = date("Y-m") . "/" . date("d");
     $dir = "../upload/" . $filna;
     if (is_dir($dir) == false) {
         mkdirs($dir, 0777);
     }
     $path = $dir . "/" . $attachment_name;
     //echo $extention;exit();
     if (!in_array($extention, $allowed_file)) {
         $Base->WarnBack('文件类型不允许!');
         exit;
     }
     if ($files['size'] > $allowed_size || $files['size'] == 0) {
         $Base->WarnBack('文件超过允许大小!');
         exit;
     }
     if (is_uploaded_file($attachment)) {
         @move_uploaded_file($attachment, $path);
         @chmod($path, 0666);
         if (@filesize($path) != $files['size']) {
             @unlink($path);
             $Base->WarnBack("检查权限或检查文件夹是否存在!");
         } else {
             $Db->ThisQuery("INSERT INTO `" . $db_prefix . "file` (`uid`,`file_name`,`file_extention`,`file_url`,`file_add_time`,`file_size`,`file_add_user`) VALUES (" . $quid . ",'" . $files[name] . "','" . $extention . "','" . substr($path, 0, strlen($path)) . "',NOW(),'" . $this->GetSize($files['size']) . "','" . $_SESSION['user_name'] . "')");
             if (in_array($extention, array('.jpg', '.jepg', '.gif', '.bmp', 'png', '.emf', '.flv'))) {
                 $message = "<img src=\"" . $web_url . substr($path, 2, strlen($path)) . "\">";
             } else {
                 $message = "<a href=\"" . $web_url . substr($path, 2, strlen($path)) . "\">" . $files['name'] . "</a>";
             }
             echo "<form style=\"margin:0px\" action=\"upload.php?action=upload_ovoa&dizhi=" . $dizhi . "&rstform=" . $rstform . "&introduce=" . $introduce . "\" method=\"post\" enctype=\"multipart/form-data\" name=\"fileform\" id=\"fileform\">";
             echo "<input name=\"attachment\" type=\"file\" style=\"width:160px;\"/>\n";
             echo "<input type='submit' class=\"button\" value='上传'/>&nbsp;";
             //		echo "<script type=\"text/javascript\">parent.document.".$rstform.".".$dizhi.".value='".substr($path,3,strlen($path))."';</script>";
             echo "<script type=\"text/javascript\">parent.document." . $rstform . "." . $dizhi . ".value='" . substr($path, 3, strlen($path)) . "';</script>";
             //		echo "<script type=\"text/javascript\">parent.document.".$rstform.".".$introduce.".value='".$top_docname."';</script>";
         }
     } else {
         $Base->WarnBack("检查权限或文件夹是否存在!");
     }
 }
Exemple #22
0
function mkdirs($dirname, $mode = 0777)
{
    if (!is_dir($dirname)) {
        mkdirs($dirname, $mode);
        //如果目录不存在,递归建立
        return mkdir($dirname, $mode);
    }
    return true;
}
function mkdirs($path)
{
    if (!is_dir(dirname($path))) {
        mkdirs(dirname($path));
    }
    if (!file_exists($path)) {
        mkdir($path);
    }
}
Exemple #24
0
 public function __construct($type = 'images', $extArr = array('jpg', 'gif', 'png'))
 {
     $this->dir = $type . DS . date('Ymd') . DS;
     $this->type = $type;
     $this->ext = $extArr;
     if (!is_dir(APP_UPLOAD . $this->dir)) {
         mkdirs(APP_UPLOAD . $this->dir, true);
     }
 }
 /**
  * 上传文件的构造方法
  * @param $type string 上传文件类型,默认images代表图片
  * @param $extArr array 上传文件扩展名的数组,默认array('jpg', 'gif', 'png')
  * @return void
  */
 public function __construct($type = 'images', $extArr = array('jpg', 'gif', 'png'))
 {
     $dir = $this->path . $type . '/' . date('Ymd') . '/';
     if (!is_dir($dir)) {
         mkdirs($dir, true);
     }
     $this->type = $type;
     $this->ext = $extArr;
     $this->file_path = $dir;
 }
function mkdirs($dir, $mode = 0777)
{
    if (is_dir($dir) || @mkdir($dir, $mode)) {
        return true;
    }
    if (!mkdirs(dirname($dir), $mode)) {
        return false;
    }
    return @mkdir($dir, $mode);
}
Exemple #27
0
function mkdirs($dir, $mode = 0777)
{
    if (is_dir($dir) || @mkdir($dir, $mode)) {
        return TRUE;
    }
    if (!mkdirs(dirname($dir), $mode)) {
        return FALSE;
    }
    return @mkdir($dir, $mode);
}
Exemple #28
0
function mkdirs($path, $mode = '0777')
{
    if (!is_dir($path)) {
        // 判断目录是否存在
        mkdirs(dirname($path), $mode);
        // 循环建立目录
        mkdir($path, $mode);
    }
    return true;
}
Exemple #29
0
function buildAppDir()
{
    // 没有创建项目目录的话自动创建
    if (!is_dir(APP_PATH)) {
        mk_dir(APP_PATH, 0777);
    }
    if (is_writeable(APP_PATH)) {
        mkdirs(array(LIB_PATH, CONFIG_PATH, COMMON_PATH, LANG_PATH, CACHE_PATH, TMPL_PATH, TMPL_PATH . 'default/', LOG_PATH, TEMP_PATH, DATA_PATH, LIB_PATH . 'Model/', LIB_PATH . 'Action/'));
        // 目录安全写入
        if (!defined('BUILD_DIR_SECURE')) {
            define('BUILD_DIR_SECURE', false);
        }
        if (BUILD_DIR_SECURE) {
            if (!defined('DIR_SECURE_FILENAME')) {
                define('DIR_SECURE_FILENAME', 'index.html');
            }
            if (!defined('DIR_SECURE_CONTENT')) {
                define('DIR_SECURE_CONTENT', ' ');
            }
            // 自动写入目录安全文件
            $content = DIR_SECURE_CONTENT;
            $a = explode(',', DIR_SECURE_FILENAME);
            foreach ($a as $filename) {
                file_put_contents(LIB_PATH . $filename, $content);
                file_put_contents(LIB_PATH . 'Action/' . $filename, $content);
                file_put_contents(LIB_PATH . 'Model/' . $filename, $content);
                file_put_contents(CACHE_PATH . $filename, $content);
                file_put_contents(LANG_PATH . $filename, $content);
                file_put_contents(TEMP_PATH . $filename, $content);
                file_put_contents(TMPL_PATH . $filename, $content);
                file_put_contents(TMPL_PATH . 'default/' . $filename, $content);
                file_put_contents(DATA_PATH . $filename, $content);
                file_put_contents(COMMON_PATH . $filename, $content);
                file_put_contents(CONFIG_PATH . $filename, $content);
                file_put_contents(LOG_PATH . $filename, $content);
            }
        }
        // 写入测试Action
        if (!file_exists(LIB_PATH . 'Action/IndexAction.class.php')) {
            $content = '<?php
// 本类由系统自动生成,仅供测试用途
class IndexAction extends Action{
    public function index(){
        header("Content-Type:text/html; charset=utf-8");
        echo "<div style=\'font-weight:normal;color:blue;float:left;width:345px;text-align:center;border:1px solid silver;background:#E8EFFF;padding:8px;font-size:14px;font-family:Tahoma\'>^_^ Hello,欢迎使用<span style=\'font-weight:bold;color:red\'>ThinkPHP</span></div>";
    }
}
?>';
            file_put_contents(LIB_PATH . 'Action/IndexAction.class.php', $content);
        }
    } else {
        header("Content-Type:text/html; charset=utf-8");
        exit('<div style=\'font-weight:bold;float:left;width:345px;text-align:center;border:1px solid silver;background:#E8EFFF;padding:8px;color:red;font-size:14px;font-family:Tahoma\'>项目目录不可写,目录无法自动生成!<BR>请使用项目生成器或者手动生成项目目录~</div>');
    }
}
Exemple #30
0
 /**
  * 記錄錯誤日記
  * @param Array $logs 錯誤數組
  * @author wave
  */
 protected function logs($logs)
 {
     if (is_array($logs) && !empty($logs)) {
         $errinfo = sprintf('error_type:%d message:%s errfile:%s errline:%d', $logs['type'], $logs['message'], $logs['file'], $logs['line']);
         $date = date('Y-m-d H:i:s');
         if (!file_exists(ROOT . DS . APP_PATH . DS . LOGS . DS)) {
             mkdirs(LOGS);
         }
         file_put_contents(ROOT . DS . APP_PATH . DS . LOGS . DS . 'logs.log', 'date:' . $date . ' ' . $errinfo . "\r\n", FILE_APPEND);
     }
 }