コード例 #1
0
ファイル: Html.class.php プロジェクト: sxau-web-team/wish-web
 /**
  * 生成静态页面
  * <code>
  * array(控制器名,方法名,表态数据,保存表态文件路径)
  * array(news,show,1,'h/b/Hd.html');表示生成news控制器中的show方法生成ID为1的文章
  * </code>
  * @param $control
  * @param $method
  * @param $data
  * @return bool
  */
 public static function create($control, $method, $data)
 {
     //创建控制器对象
     if (is_null(self::$obj)) {
         $obj = control($control);
         if (!method_exists($obj, $method)) {
             error("方法{$method}不存在,请查看HD手册", false);
         }
     }
     foreach ($data as $d) {
         //************创建GET数据****************
         $_GET = array_merge($_GET, $d);
         $htmlPath = dirname($d['html_file']);
         //生成静态目录
         if (!dir_create($htmlPath)) {
             //创建生成静态的目录
             throw_exception(L("html_create_error2"));
             return false;
         }
         ob_start();
         $obj->{$method}();
         //执行控制器方法
         $content = ob_get_clean();
         file_put_contents($d['html_file'], $content);
     }
     return true;
 }
コード例 #2
0
ファイル: webConfigControl.php プロジェクト: com-itzcy/hdjob
 function emailTpl()
 {
     $db = M('mail_tpl');
     $type = $_GET['type'];
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if ($db->where("type='{$type}'")->update($_POST) >= 0) {
             $filename = PATH_ROOT . '/caches/email';
             if (!file_exists($filename)) {
                 dir_create($filename);
             }
             $filename .= '/' . $type . '.php';
             file_put_contents($filename, '<?php return ' . var_export(array('subject' => $_POST['subject'], 'content' => $_POST['content']), true) . '?>');
             $this->success('更新成功', __CONTROL__ . '/emailConfig/action/3');
         }
     }
     $placeholder = array('web_name' => '网站名称', 'web_host' => '网站域名');
     switch ($type) {
         case 'register_active':
             $placeholder = array_merge($placeholder, array('username' => '用户名', 'email' => '邮箱', 'password' => '密码', 'activate_url' => '激活地址', 'expire' => '有效时间(小时)'));
             break;
         case 'register_info':
             $placeholder = array_merge($placeholder, array('username' => '用户名', 'email' => '邮箱', 'password' => '密码'));
             break;
         default:
             break;
     }
     $tpl = $db->where("type='{$type}'")->find();
     $this->assign('tpl', $tpl);
     $this->assign('placeholder', $placeholder);
     $this->display();
 }
コード例 #3
0
ファイル: Html.class.php プロジェクト: jyht/v5
 /**
  * 生成静态页面
  * <code>
  * array(控制器名,方法名,表态数据,保存表态文件路径)
  * array(news,show,1,'h/b/Hd.html');表示生成news控制器中的show方法生成ID为1的文章
  * </code>
  * @param $control 控制器,需要事先加载
  * @param $method 方法
  * @param $field 数据array("aid"=>1,"_html"=>"html/2013/2/22/1.html")
  * @return bool
  */
 public static function make($control, $method, $field)
 {
     if (!class_exists($control) or !method_exists($control, $method)) {
         DEBUG && halt("静态生成需要的控制器{$control}或方法{$method}不存在");
     }
     if (!isset($field['_html'])) {
         DEBUG && halt("请指定静态文件参数'_html',请参考后盾HD框架手册");
     }
     $obj = NULL;
     if (!$obj) {
         $obj = new $control();
     }
     //************创建GET数据****************
     $html = $field['_html'];
     unset($field['_html']);
     $_GET = array_merge($_GET, $field);
     if (!dir_create(dirname($html))) {
         //创建生成静态的目录
         DEBUG && halt("创建目录失败,请检查目录权限");
         return false;
     }
     ob_start();
     $obj->{$method}();
     //执行控制器方法
     $content = ob_get_clean();
     file_put_contents($html, $content);
     return true;
 }
コード例 #4
0
ファイル: Functions.php プロジェクト: www2511550/ECSHOP
/**
 * 快速缓存 以文件形式缓存
 * @param String $name 缓存KEY
 * @param bool $value 删除缓存
 * @param string $path 缓存目录
 * @return bool
 */
function F($name, $value = false, $path = APP_CACHE_PATH)
{
    $_cache = array();
    $cacheFile = rtrim($path, '/') . '/' . $name . '.php';
    if (is_null($value)) {
        if (is_file($cacheFile)) {
            unlink($cacheFile);
            unset($_cache[$name]);
        }
        return true;
    }
    if ($value === false) {
        if (isset($_cache[$name])) {
            return $_cache[$name];
        }
        return is_file($cacheFile) ? include $cacheFile : null;
    }
    $data = "<?php if(!defined('HDPHP_PATH'))exit;\nreturn " . compress(var_export($value, true)) . ";\n?>";
    is_dir($path) || dir_create($path);
    if (!file_put_contents($cacheFile, $data)) {
        return false;
    }
    $_cache[$name] = $data;
    return true;
}
コード例 #5
0
ファイル: ViewHd.class.php プロジェクト: jyht/v5
 /**
  * 模板显示
  * @param string $tplFile 模板文件
  * @param string $cachePath 缓存目录
  * @param null $cacheTime 缓存时间
  * @param string $contentType 文件类型
  * @param string $charset 字符集
  * @param bool $show 是否显示
  * @return bool|string
  */
 public function display($tplFile = null, $cacheTime = null, $cachePath = null, $contentType = "text/html", $charset = "", $show = true)
 {
     //缓存文件名
     $cacheName = md5($_SERVER['REQUEST_URI']);
     //内容
     $content = null;
     if ($cacheTime >= 0) {
         $content = S($cacheName, false, $cacheTime, array("dir" => $cachePath, 'zip' => false, "Driver" => "File"));
     }
     //缓存失效
     if (!$content) {
         //获得模板文件
         $this->tplFile = $this->getTemplateFile($tplFile);
         //模板文件不存在
         if (!$this->tplFile) {
             return;
         }
         //编译文件
         $this->compileFile = COMPILE_PATH . basename($this->tplFile, C("TPL_FIX")) . '_' . substr(md5(APP . CONTROL . METHOD), 0, 5) . '.php';
         //记录模板编译文件
         if (DEBUG) {
             Debug::$tpl[] = array(basename($this->tplFile), $this->compileFile);
         }
         //缓存时间
         $cacheTime = is_int($cacheTime) ? $cacheTime : intval(C("CACHE_TPL_TIME"));
         //缓存路径
         $cachePath = $cachePath ? $cachePath : CACHE_PATH;
         //编译文件失效(不存在或过期)
         if ($this->compileInvalid($tplFile)) {
             //执行编译
             $this->compile();
         }
         $_CONFIG = C();
         $_LANGUAGE = L();
         //加载全局变量
         if (!empty($this->vars)) {
             extract($this->vars);
         }
         ob_start();
         include $this->compileFile;
         $content = ob_get_clean();
         //创建缓存
         if ($cacheTime >= 0) {
             //创建缓存目录
             is_dir(CACHE_PATH) || dir_create(CACHE_PATH);
             //写入缓存
             S($cacheName, $content, $cacheTime, array("dir" => $cachePath, 'zip' => false, "Driver" => "File"));
         }
     }
     if ($show) {
         $charset = strtoupper(C("CHARSET")) == 'UTF8' ? "UTF-8" : strtoupper(C("CHARSET"));
         if (!headers_sent()) {
             header("Content-type:" . $contentType . ';charset=' . $charset);
         }
         echo $content;
     } else {
         return $content;
     }
 }
コード例 #6
0
 /**
  * 模板显示
  * @param string $tplFile 模板文件
  * @param string $cachePath 缓存目录
  * @param null $cacheTime 缓存时间
  * @param string $contentType 文件类型
  * @param string $charset 字符集
  * @param bool $show 是否显示
  * @return bool|string
  */
 public function display($tplFile = null, $cacheTime = null, $cachePath = null, $contentType = "text/html", $charset = "", $show = true)
 {
     $this->tplFile = $this->getTemplateFile($tplFile);
     $this->compileFile = COMPILE_PATH . md5_d($this->tplFile) . '.php';
     if (DEBUG) {
         Debug::$tpl[] = array(basename($this->tplFile), $this->compileFile);
         //记录模板编译文件
     }
     //缓存时间设置
     $cacheTime = is_int($cacheTime) ? $cacheTime : intval(C("CACHE_TPL_TIME"));
     $content = false;
     $cachePath = $cachePath ? $cachePath : CACHE_PATH;
     if ($cacheTime >= 0) {
         $content = S($_SERVER['REQUEST_URI'], false, $cacheTime, array("dir" => $cachePath, "Driver" => "File"));
     }
     //缓存失效
     if (!$content) {
         if ($this->compileInvalid($tplFile)) {
             //编译文件失效
             $this->compile();
         }
         $_CONFIG = C();
         $_LANGUAGE = L();
         if (!empty($this->vars)) {
             //加载全局变量
             extract($this->vars);
         }
         ob_start();
         include $this->compileFile;
         $content = ob_get_clean();
         if ($cacheTime >= 0) {
             is_dir(CACHE_PATH) || dir_create(CACHE_PATH);
             //创建缓存目录
             S($_SERVER['REQUEST_URI'], $content, $cacheTime, array("dir" => $cachePath, "Driver" => "File"));
             //写入缓存
         }
     }
     if ($show) {
         $charset = strtoupper(C("CHARSET")) == 'UTF8' ? "UTF-8" : strtoupper(C("CHARSET"));
         if (!headers_sent()) {
             header("Content-type:" . $contentType . ';charset=' . $charset);
         }
         echo $content;
     } else {
         return $content;
     }
 }
コード例 #7
0
 function dsession()
 {
     if (DT_DOMAIN) {
         @ini_set('session.cookie_domain', '.' . DT_DOMAIN);
     }
     @ini_set('session.gc_maxlifetime', 1800);
     if (is_dir(DT_ROOT . '/file/session/')) {
         $dir = DT_ROOT . '/file/session/' . substr(DT_KEY, 2, 6) . '/';
         if (is_dir($dir)) {
             session_save_path($dir);
         } else {
             dir_create($dir);
         }
     }
     session_cache_limiter('private, must-revalidate');
     @session_start();
     header("cache-control: private");
 }
コード例 #8
0
ファイル: ViewSmarty.class.php プロジェクト: jyht/v5
 public function display($resource_name, $cacheTime = null)
 {
     $resource_name = $this->getTemplateFile($resource_name);
     //缓存时间设置
     $_cacheTime = is_null($cacheTime) ? C("CACHE_TPL_TIME") : $cacheTime;
     $cacheTime = is_int($_cacheTime) ? $_cacheTime : Null;
     $content = false;
     if ($cacheTime) {
         $content = S($_SERVER['REQUEST_URI'], false, null, array("dir" => PATH_TEMP_TPL_CACHE, "Driver" => "File"));
     }
     if (!$content) {
         $content = $this->smarty->fetch($resource_name);
         //创建缓存
         if ($cacheTime) {
             is_dir(PATH_TEMP_TPL_CACHE) || dir_create(PATH_TEMP_CACHE);
             //创建缓存目录
             S($_SERVER['REQUEST_URI'], $content, $cacheTime, array("dir" => PATH_TEMP_TPL_CACHE, "Driver" => "File"));
             //写入缓存
         }
     }
 }
コード例 #9
0
ファイル: dir.php プロジェクト: 290329416/guahao
/**
 * 拷贝目录及下面所有文件
 *
 * @param	string	$fromdir	原路径
 * @param	string	$todir		目标路径
 * @return	string	如果目标路径不存在则返回false,否则为true
 */
function dir_copy($fromdir, $todir)
{
    $fromdir = dir_path($fromdir);
    $todir = dir_path($todir);
    if (!is_dir($fromdir)) {
        return FALSE;
    }
    if (!is_dir($todir)) {
        dir_create($todir);
    }
    $list = glob($fromdir . '*');
    if (!empty($list)) {
        foreach ($list as $v) {
            $path = $todir . basename($v);
            if (is_dir($v)) {
                dir_copy($v, $path);
            } else {
                copy($v, $path);
                @chmod($path, 0777);
            }
        }
    }
    return TRUE;
}
コード例 #10
0
ファイル: contentControl.php プロジェクト: com-itzcy/hdjob
 /**
  * 生成文章静态HTML
  * @param int $id 文章ID
  * @param string $path 文章生成路径
  * @param string $tpl  文章内容页的模板
  */
 public function generate_arc_html($id, $path, $tpl)
 {
     $path = PATH_ROOT . $path;
     $arc = $this->arc->arc('id=' . $id);
     $this->assign('arc', $arc);
     $content = $this->display($tpl, 0, 'text/html', 'utf-8', false);
     if (!file_exists($path)) {
         dir_create($path);
     }
     $path .= "/arc_{$id}.html";
     file_put_contents($path, $content);
 }
コード例 #11
0
ファイル: html.class.php プロジェクト: boylzj/omguitar
 /**
  * 生成静态文件
  * @param string $file 文件路径
  * @return boolen/intval 成功返回生成文件的大小
  */
 private function create_html($file)
 {
     $data = ob_get_contents();
     ob_end_clean();
     pc_base::load_sys_func('dir');
     dir_create(dirname($file));
     $strlen = file_put_contents($file, $data);
     @chmod($file, 0777);
     return $strlen;
 }
コード例 #12
0
ファイル: plugin.php プロジェクト: panhongsheng/zl_cms
	public function design() {
		
	    if(isset($_POST['dosubmit'])) {
			$data['identification'] = $_POST['info']['identification'];
			$data['realease'] = date('YMd',SYS_TIME);
			$data['dir'] = $_POST['info']['identification'];
			$data['appid'] = '';
			$data['plugin'] = array(
							'version' => '0.0.2',
							'name' => $_POST['info']['name'],
							'copyright' => $_POST['info']['copyright'],
							'description' => "",
							'installfile' => 'install.php',
							'uninstallfile' => 'uninstall.php',
						);

			
			$filepath = PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$data['identification'].DIRECTORY_SEPARATOR.'plugin_'.$data['identification'].'.cfg.php';
			pc_base::load_sys_func('dir');
			dir_create(dirname($filepath));	
		    $data = "<?php\nreturn ".var_export($data, true).";\n?>";			
			if(pc_base::load_config('system', 'lock_ex')) {
				$file_size = file_put_contents($filepath, $data, LOCK_EX);
			} else {
				$file_size = file_put_contents($filepath, $data);
			}
			echo 'success';
		} else {
			include $this->admin_tpl('plugin_design');
		}
	}
コード例 #13
0
ファイル: ModuleInstall.php プロジェクト: heixiake/ACI
 function index()
 {
     $status = true;
     if (!file_exists(INTALL_UPLOAD_TEMP_PATH)) {
         $status = dir_create(INTALL_UPLOAD_TEMP_PATH);
     }
     $install_uploaded_chomd = $status ? octal_permissions(fileperms(INTALL_UPLOAD_TEMP_PATH)) : 0;
     $install_config_chomd = $status ? @octal_permissions(fileperms(APPPATH . 'config' . DIRECTORY_SEPARATOR . 'aci.php')) : 0;
     $error = array('uploadChomd' => $install_uploaded_chomd, 'configChomd' => $install_config_chomd, 'supportZip' => class_exists('ZipArchive'));
     $this->view('index', $error);
 }
コード例 #14
0
ファイル: http.class.php プロジェクト: klj123wan/czsz
 function save($file)
 {
     dir_create(dirname($file));
     return file_put_contents($file, $this->data);
 }
コード例 #15
0
ファイル: function.php プロジェクト: cy520win/yunchao
function qrCode($data, $fileName, $pathMy = '', $level = 'L', $size = 4)
{
    $path = './Public/qr/';
    if ($pathMy) {
        $path .= $pathMy . '/';
        $pathMy = $pathMy . '/';
    }
    dir_create($path);
    vendor('phpqrcode', '', '.php');
    $path .= $fileName . '.png';
    \QRcode::png($data, $path, $level, $size, 2);
    if ($fileName) {
        return C('APP_URL') . '/Public/qr/' . $pathMy . $fileName . '.png';
    }
}
コード例 #16
0
ファイル: word.inc.php プロジェクト: hiproz/zhaotaoci.cc
/*
	[Destoon B2B System] Copyright (c) 2008-2015 www.destoon.com
	This is NOT a freeware, use is subject to license.txt
*/
defined('DT_ADMIN') or exit('Access Denied');
$menus = array(array('编辑助手', '?file=' . $file));
switch ($action) {
    case 'upload':
        $_FILES['uploadfile']['size'] or dalert('请选择zip文件');
        require DT_ROOT . '/include/upload.class.php';
        $name = date('YmdHis') . mt_rand(10, 99) . $_userid;
        $upload = new upload($_FILES, 'file/temp/', $name . '.zip', 'zip');
        $upload->adduserid = false;
        if ($upload->save()) {
            dir_create(DT_ROOT . '/file/temp/' . $name);
            require DT_ROOT . '/admin/unzip.class.php';
            $zip = new unzip();
            $zip->extract_zip(DT_ROOT . '/file/temp/' . $name . '.zip', DT_ROOT . '/file/temp/' . $name);
            file_del(DT_ROOT . '/file/temp/' . $name . '.zip');
            $F = get_file(DT_ROOT . '/file/temp/' . $name);
            if ($F) {
                $htm = '';
                $max = 0;
                foreach ($F as $f) {
                    $ext = file_ext($f);
                    if (in_array($ext, array('htm', 'html'))) {
                        $tmp = filesize($f);
                        if ($tmp > $max) {
                            $htm = str_replace(DT_ROOT . '/file/temp/', '', $f);
                        }
コード例 #17
0
ファイル: database.php プロジェクト: zhangjSir/JinMaSite
 /**
  * 数据库导出方法
  * @param unknown_type $tables 数据表数据组
  * @param unknown_type $sqlcompat 数据库兼容类型
  * @param unknown_type $sqlcharset 数据库字符
  * @param unknown_type $sizelimit 卷大小
  * @param unknown_type $action 操作
  * @param unknown_type $fileid 卷标
  * @param unknown_type $random 随机字段
  * @param unknown_type $tableid 
  * @param unknown_type $startfrom 
  * @param unknown_type $tabletype 备份数据库类型 (非phpcms数据与phpcms数据)
  */
 private function export_database($tables, $sqlcompat, $sqlcharset, $sizelimit, $action, $fileid, $random, $tableid, $startfrom, $tabletype)
 {
     $dumpcharset = $sqlcharset ? $sqlcharset : str_replace('-', '', CHARSET);
     $fileid = $fileid != '' ? $fileid : 1;
     if ($fileid == 1 && $tables) {
         if (!isset($tables) || !is_array($tables)) {
             showmessage(L('select_tbl'));
         }
         $random = random(20, 'abcdefghigklmzopqrstuvwxyz0123456789');
         setcache('bakup_tables', $tables, 'commons');
     } else {
         if (!($tables = getcache('bakup_tables', 'commons'))) {
             showmessage(L('select_tbl'));
         }
     }
     if ($this->db->version() > '4.1') {
         if ($sqlcharset) {
             $this->db->query("SET NAMES '" . $sqlcharset . "';\n\n");
         }
         if ($sqlcompat == 'MYSQL40') {
             $this->db->query("SET SQL_MODE='MYSQL40'");
         } elseif ($sqlcompat == 'MYSQL41') {
             $this->db->query("SET SQL_MODE=''");
         }
     }
     $tabledump = '';
     $tableid = $tableid != '' ? $tableid - 1 : 0;
     $startfrom = $startfrom != '' ? intval($startfrom) : 0;
     for ($i = $tableid; $i < count($tables) && strlen($tabledump) < $sizelimit * 1000; $i++) {
         global $startrow;
         $offset = 100;
         if (!$startfrom) {
             if ($tables[$i] != DB_PRE . 'session') {
                 $tabledump .= "DROP TABLE IF EXISTS `{$tables[$i]}`;\n";
             }
             $createtable = $this->db->query("SHOW CREATE TABLE `{$tables[$i]}` ");
             $create = $this->db->fetch_next();
             $tabledump .= $create['Create Table'] . ";\n\n";
             $this->db->free_result($createtable);
             if ($sqlcompat == 'MYSQL41' && $this->db->version() < '4.1') {
                 $tabledump = preg_replace("/TYPE\\=([a-zA-Z0-9]+)/", "ENGINE=\\1 DEFAULT CHARSET=" . $dumpcharset, $tabledump);
             }
             if ($this->db->version() > '4.1' && $sqlcharset) {
                 $tabledump = preg_replace("/(DEFAULT)*\\s*CHARSET=[a-zA-Z0-9]+/", "DEFAULT CHARSET=" . $sqlcharset, $tabledump);
             }
             if ($tables[$i] == DB_PRE . 'session') {
                 $tabledump = str_replace("CREATE TABLE `" . DB_PRE . "session`", "CREATE TABLE IF NOT EXISTS `" . DB_PRE . "session`", $tabledump);
             }
         }
         $numrows = $offset;
         while (strlen($tabledump) < $sizelimit * 1000 && $numrows == $offset) {
             if ($tables[$i] == DB_PRE . 'session' || $tables[$i] == DB_PRE . 'member_cache') {
                 break;
             }
             $sql = "SELECT * FROM `{$tables[$i]}` LIMIT {$startfrom}, {$offset}";
             $numfields = $this->db->num_fields($sql);
             $numrows = $this->db->num_rows($sql);
             $fields_name = $this->db->get_fields($tables[$i]);
             $rows = $this->db->query($sql);
             $name = array_keys($fields_name);
             $r = array();
             while ($row = $this->db->fetch_next()) {
                 $r[] = $row;
                 $comma = "";
                 $tabledump .= "INSERT INTO `{$tables[$i]}` VALUES(";
                 for ($j = 0; $j < $numfields; $j++) {
                     $tabledump .= $comma . "'" . $this->db->escape($row[$name[$j]]) . "'";
                     $comma = ",";
                 }
                 $tabledump .= ");\n";
             }
             $this->db->free_result($rows);
             $startfrom += $offset;
         }
         $tabledump .= "\n";
         $startrow = $startfrom;
         $startfrom = 0;
     }
     if (trim($tabledump)) {
         $tabledump = "# phpcms bakfile\n# version:PHPCMS V9\n# time:" . date('Y-m-d H:i:s') . "\n# type:phpcms\n# phpcms:http://www.phpcms.cn\n# --------------------------------------------------------\n\n\n" . $tabledump;
         $tableid = $i;
         $filename = $random . '_' . $tabletype . '_' . date('Ymd') . '_' . $fileid . '.sql';
         $altid = $fileid;
         $fileid++;
         $bakfile_path = CACHE_PATH . 'bakup' . DIRECTORY_SEPARATOR . $this->pdo_name;
         if (!dir_create($bakfile_path)) {
             showmessage(L('dir_not_be_created'));
         }
         $bakfile = $bakfile_path . DIRECTORY_SEPARATOR . $filename;
         if (!is_writable(CACHE_PATH . 'bakup')) {
             showmessage(L('dir_not_be_created'));
         }
         file_put_contents($bakfile, $tabledump);
         @chmod($bakfile, 0777);
         if (!EXECUTION_SQL) {
             $filename = L('bundling') . $altid . '#';
         }
         showmessage(L('bakup_file') . " {$filename} " . L('bakup_write_succ'), '?m=admin&c=database&a=export&sizelimit=' . $sizelimit . '&sqlcompat=' . $sqlcompat . '&sqlcharset=' . $sqlcharset . '&tableid=' . $tableid . '&fileid=' . $fileid . '&startfrom=' . $startrow . '&random=' . $random . '&dosubmit=1&tabletype=' . $tabletype . '&allow=' . $allow . '&pdo_select=' . $this->pdo_name);
     } else {
         $bakfile_path = CACHE_PATH . 'bakup' . DIRECTORY_SEPARATOR . $this->pdo_name . DIRECTORY_SEPARATOR;
         file_put_contents($bakfile_path . 'index.html', '');
         delcache('bakup_tables', 'commons');
         showmessage(L('bakup_succ'), '?m=admin&c=database&a=import&pdoname=' . $this->pdo_name);
     }
 }
コード例 #18
0
ファイル: application.php プロジェクト: com-itzcy/hdjob
    /**
     * 创建测试主控制器文件 
     */
    private static function createDemoControl()
    {
        if (is_dir(PATH_TEMP . '/Applications')) {
            return;
        }
        $demoDir = array();
        if (defined("APP_GROUP")) {
            $demoDir['demo_app_group_libs_dir'] = PATH_APP_GROUP . '/libs';
            $demoDir['demo_app_group_config_dir'] = PATH_APP_GROUP . '/config';
            $demoDir['demo_app_group_language_dir'] = PATH_APP_GROUP . '/language';
        }
        $demoDir['demo_app_dir'] = PATH_APP;
        if (is_dir($demoDir['demo_app_dir'])) {
            return;
        }
        $demoDir['demo_control_dir'] = PATH_APP . '/control';
        $demoDir['demo_model_dir'] = PATH_APP . '/model';
        $demoDir['demo_libs_dir'] = PATH_APP . '/libs';
        $demoDir['demo_config_dir'] = PATH_APP . '/config';
        $demoDir['demo_tpl_dir'] = PATH_APP . '/tpl';
        $demoDir['demo_language_dir'] = PATH_APP . '/language';
        $demoDir['demo_tpl_public_dir'] = PATH_APP . '/tpl/public';
        foreach ($demoDir as $v) {
            dir_create($v);
        }
        $demo_control_file = $demoDir['demo_control_dir'] . '/index' . C("CONTROL_FIX") . '.php';
        $data = <<<str
<?php
class indexControl extends Control{
    function index(){
        header("Content-type:text/html;charset=utf-8");
        echo "<div style='font-size:16px;font-weight:bold;color:#333;margin-left:20px;border:solid 2px #F00;width:500px;height:30px;padding:30px 50px 20px;'>感谢使用由后盾网提供的HD开源框架,基础目录已经创建成功!</div>";
    }
}
str;
        file_put_contents($demo_control_file, $data);
        copy(PATH_HD . '/libs/boot/config.php', $demoDir['demo_config_dir'] . '/config.php');
        //复制错误页面error.html到模版文件夹下
        copy(PATH_HD . '/data/tpl/error.html', $demoDir['demo_tpl_public_dir'] . '/error.html');
        //复制错误页面error.html到模版文件夹下
        copy(PATH_HD . '/data/tpl/success.html', $demoDir['demo_tpl_public_dir'] . '/success.html');
        //复制错误页面error.html到模版文件夹下
        $languageDataUtf8 = <<<str
<?php
/**
 * Copyright              [HD框架] (C)2011-2012 houdunwang ,Inc. 
 * Encoding               UTF-8
 * @author                向军
 * Link                   http://www.houdunwang.com       
 * E-mail                 houdunwang@gmail.com
 */
/**
 * 本文件为语言包测试文件,在视图页面中通过{\$hd.lang.title}即可调用 
 * 可以创建任意多个语言文件如gbk,en,utf8等
 * 具体使用哪一个语言包可以能过C("language","utf8")这种方式设计或者直接修改配置文件
 */
if(!defined("PATH_HD"))exit;
return array(
    "title"=>"后盾多语言测试",
);
?>
str;
        file_put_contents($demoDir['demo_language_dir'] . '/utf8.php', $languageDataUtf8);
    }
コード例 #19
0
ファイル: update.inc.php プロジェクト: hcd2008/destoon
     $url = 'http://www.destoon.com/update.php?product=b2b&release=' . $release . '&charset=' . DT_CHARSET . '&version=' . DT_VERSION;
     $code = @file_get_contents($url);
     if ($code) {
         if (substr($code, 0, 8) == 'StatusOk') {
             $code = substr($code, 8);
         } else {
             msg($code);
         }
     } else {
         msg('无法连接官方服务器,请重试或稍后更新');
     }
     dir_create($release_dir);
     if (@copy($code, $release_dir . '/' . $release . '.zip')) {
         file_copy(DT_ROOT . '/file/index.html', $release_dir . '/index.html');
         dir_create($release_dir . '/source/');
         dir_create($release_dir . '/backup/');
         msg('更新下载成功,开始解压缩..', '?file=' . $file . '&action=unzip&release=' . $release);
     } else {
         msg('更新下载失败,请重试..');
     }
     break;
 case 'unzip':
     require DT_ROOT . '/admin/unzip.class.php';
     $zip = new unzip();
     $zip->extract_zip($release_dir . '/' . $release . '.zip', $release_dir . '/source/');
     if (is_file($release_dir . '/source/destoon/version.inc.php')) {
         msg('更新解压缩成功,开始更新文件..', '?file=' . $file . '&action=copy&release=' . $release);
     } else {
         msg('更新解压缩失败,请重试..');
     }
     break;
コード例 #20
0
ファイル: CacheFile.class.php プロジェクト: hdbaiyu/HDPHP
 /**
  * 创建目录
  * @access private
  */
 private function createDir()
 {
     $this->isConnect = dir_create($this->options['dir']);
 }
コード例 #21
0
ファイル: User.php プロジェクト: hwsyy/ACI
 /**
  * 上传附件
  * @param string $fieldName 字段名
  * @param string $controlId HTML控件ID
  * @param string $callbackJSfunction 是否返回函数
  * @return void
  */
 function upload($fieldName = '', $controlId = '', $callbackJSfunction = false)
 {
     $isImage = true;
     if (isset($this->method_config['upload'][$fieldName])) {
         if (isset($_POST['dosubmit'])) {
             $uc_first_id = ucfirst($controlId);
             if (DEMO_STATUS) {
                 $file_name = "nopic.gif";
                 $file_size = 0;
                 $image_width = 80;
                 $image_height = 80;
                 $this->showmessage("上传成功!", '', '', '', $callbackJSfunction ? "window.parent.get{$uc_first_id}(\"{$file_name}\",\"{$file_size}\",\"{$image_width}\",\"{$image_height}\");" : "\$(window.parent.document).find(\"#{$controlId}\").val(\"{$file_name}\");\$(\"#dialog\" ).dialog(\"close\")");
             }
             $upload_path = $this->method_config['upload'][$fieldName]['upload_path'];
             if ($upload_path == '') {
                 die('缺少上传参数');
             }
             $config['upload_path'] = $upload_path;
             $config['allowed_types'] = $this->method_config['upload'][$fieldName]['upload_file_type'];
             $config['max_size'] = $this->method_config['upload'][$fieldName]['upload_size'];
             $config['overwrite'] = FALSE;
             $config['encrypt_name'] = false;
             $config['file_name'] = date('Ymdhis') . random_string('nozero', 4);
             dir_create($upload_path);
             //创建正式文件夹
             $this->load->library('upload', $config);
             if (!$this->upload->do_upload('upload')) {
                 $this->showmessage("上传失败:" . $this->upload->display_errors());
             }
             $filedata = $this->upload->data();
             $file_name = $filedata['file_name'];
             $file_size = $filedata['file_size'];
             $image_width = $isImage ? $filedata['image_width'] : 0;
             $image_height = $isImage ? $filedata['image_height'] : 0;
             $this->showmessage("上传成功!", '', '', '', $callbackJSfunction ? "window.parent.get{$uc_first_id}(\"{$file_name}\",\"{$file_size}\",\"{$image_width}\",\"{$image_height}\");" : "\$(window.parent.document).find(\"#{$controlId}\").val(\"{$file_name}\");\$(\"#dialog\" ).dialog(\"close\")");
         } else {
             $this->view('upload', array('field_name' => $fieldName, 'control_id' => $controlId, 'upload_url' => $this->method_config['upload'][$fieldName]['upload_url'], 'is_image' => $isImage, 'hidden_menu' => true));
         }
     } else {
         die('缺少上传参数');
     }
 }
コード例 #22
0
ファイル: Boot.class.php プロジェクト: www2511550/ECSHOP
 /**
  * 编译核心文件
  * @access private
  */
 private static function compile()
 {
     if (DEBUG) {
         is_file(TEMP_FILE) and unlink(TEMP_FILE);
         return;
     }
     $compile = '';
     //常量编译
     $_define = get_defined_constants(true);
     foreach ($_define['user'] as $n => $d) {
         if ($d == '\\') {
             $d = "'\\\\'";
         } else {
             $d = is_int($d) ? intval($d) : "'{$d}'";
         }
         $compile .= "defined('{$n}') OR define('{$n}',{$d});";
     }
     $files = array(HDPHP_CORE_PATH . 'App.class.php', HDPHP_CORE_PATH . 'Controller.class.php', HDPHP_CORE_PATH . 'Debug.class.php', HDPHP_CORE_PATH . 'Hook.class.php', HDPHP_CORE_PATH . 'HDPHP.class.php', HDPHP_CORE_PATH . 'HdException.class.php', HDPHP_CORE_PATH . 'Log.class.php', HDPHP_CORE_PATH . 'Route.class.php', HDPHP_FUNCTION_PATH . 'Functions.php', HDPHP_DRIVER_PATH . 'Cache/Cache.class.php', HDPHP_DRIVER_PATH . 'Cache/CacheFactory.class.php', HDPHP_DRIVER_PATH . 'Cache/CacheFile.class.php', HDPHP_DRIVER_PATH . 'Db/Db.class.php', HDPHP_DRIVER_PATH . 'Db/DbFactory.class.php', HDPHP_DRIVER_PATH . 'Db/DbInterface.class.php', HDPHP_DRIVER_PATH . 'Db/DbMysql.class.php', HDPHP_DRIVER_PATH . 'Model/Model.class.php', HDPHP_DRIVER_PATH . 'Model/RelationModel.class.php', HDPHP_DRIVER_PATH . 'Model/ViewModel.class.php', HDPHP_DRIVER_PATH . 'View/ViewHd.class.php', HDPHP_DRIVER_PATH . 'View/View.class.php', HDPHP_DRIVER_PATH . 'View/ViewFactory.class.php', HDPHP_DRIVER_PATH . 'View/ViewCompile.class.php', HDPHP_EXTEND_PATH . 'Tool/Dir.class.php');
     foreach ($files as $f) {
         $con = compress(trim(file_get_contents($f)));
         $compile .= substr($con, -2) == '?>' ? trim(substr($con, 5, -2)) : trim(substr($con, 5));
     }
     //HDPHP框加核心配置
     $compile .= 'C(' . var_export(C(), true) . ');';
     //HDPHP框架核心语言包
     $compile .= 'L(' . var_export(L(), true) . ');';
     //别名配置文件
     $compile .= 'alias_import(' . var_export(alias_import(), true) . ');';
     //编译内容
     $compile = '<?php if(!defined(\'DEBUG\'))exit;' . $compile . 'HDPHP::init();App::run();?>';
     //创建Boot编译文件
     if (is_dir(TEMP_PATH) or dir_create(TEMP_PATH) and is_writable(TEMP_PATH)) {
         return file_put_contents(TEMP_FILE, compress($compile));
     }
     header("Content-type:text/html;charset=utf-8");
     exit("<div style='border:solid 1px #dcdcdc;padding:30px;'>请修改" . realpath(dirname(TEMP_PATH)) . "目录权限</div>");
 }
コード例 #23
0
 /**
  * 上传头像、图片
  * @author Martin.Cheng <*****@*****.**>
  */
 public function uphead()
 {
     $upload = new Upload();
     // 实例化上传类
     $upload->rootPath = 'Public/Upload/headpic/student/';
     // 设置附件上传根目录
     dir_create($upload->rootPath);
     //创建文件夹
     $head = $upload->uploadOne($_FILES['headpic']);
     $path = C('APP_URL') . '/' . $upload->rootPath . $head['savepath'] . $head['savename'];
     $data = array('msg' => $path, 'error' => '');
     exit(json_encode($data));
 }
コード例 #24
0
 public function index()
 {
     $v = explode(' ', VERSION);
     $menuid = intval($_REQUEST['menuid']);
     $var = $v[0];
     $upgrade_path = $this->_url . $var . '/patch/';
     $upgrade_path_str = @file_get_contents($upgrade_path);
     $allpatch = json_decode($upgrade_path_str);
     $patchlist = $patchlists = array();
     $key = -1;
     foreach ($allpatch as $k => $v) {
         if (strstr($v, 'patch_' . UPDATETIME)) {
             $key = $k;
             break;
         }
     }
     $key = $key < 0 ? '999' : $key;
     foreach ($allpatch as $k => $v) {
         if ($k >= $key) {
             $patchlist[$k]['file'] = $v;
             $time = explode('_', $v);
             $patchlist[$k]['oldtime'] = $time[1];
             $time = explode('.', $time[2]);
             $patchlist[$k]['filemtime'] = $time[0];
         }
     }
     if (!empty($_GET['do'])) {
         $cover = intval($_REQUEST['cover']);
         import("@.ORG.Http");
         import("@.ORG.Phpzip");
         foreach ($patchlist as $k => $v) {
             //远程压缩包地址
             $upgradezip_url = $upgrade_path . $v['file'];
             //保存到临时文件夹
             $upgradezip_file = TEMP_PATH . $v['file'];
             //解压路径
             $upgradezip_source_path = TEMP_PATH . basename($v['file'], ".zip");
             //备份路径
             $backupdir = TEMP_PATH . 'bakup_' . $v['oldtime'];
             dir_create($backupdir);
             //开始下载并解压
             Http::curldownload($upgradezip_url, $upgradezip_file);
             Phpzip::unZip($upgradezip_file, $upgradezip_source_path);
             //先做备份
             $backupfilelist = dir_list($upgradezip_source_path);
             foreach ((array) $backupfilelist as $k => $file) {
                 $fromfile = str_replace($upgradezip_source_path, './', $file);
                 $tofile = $backupdir . str_replace($upgradezip_source_path, '', $file);
                 if (is_dir($fromfile)) {
                     mkdir($tofile);
                 } elseif (is_file($fromfile)) {
                     copy($fromfile, $tofile);
                 }
             }
             $this->copyfileerror = 0;
             //复制并加判断是否成功
             $this->copydir($upgradezip_source_path, './', $cover);
             //如果失败,恢复当前版本
             if ($this->copyfileerror) {
                 $this->copydir($backupdir, './', $cover);
                 die(L('upgrade_error'));
             } else {
                 if (file_exists($upgradezip_source_path . '/yourphp.sql')) {
                     $sqldata = file_get_contents($upgradezip_source_path . '/yourphp.sql');
                     $sqlFormat = sql_split($sqldata, C('DB_PREFIX'));
                     foreach ((array) $sqlFormat as $sql) {
                         $sql = trim($sql);
                         if (strstr($sql, 'CREATE TABLE')) {
                             preg_match('/CREATE TABLE `([^ ]*)`/', $sql, $matches);
                             $ret = $this->excuteQuery($sql);
                             //if($ret){echo   L('CREATE_TABLE_OK').$matches[0].' <br />';}else{echo 'Error sql:'.$sql;}exit;
                         } else {
                             $ret = $this->excuteQuery($sql);
                         }
                     }
                 }
                 if (file_exists($upgradezip_source_path . '/upgrade.php')) {
                     include $upgradezip_source_path . '/upgrade.php';
                 }
                 dir_delete($upgradezip_source_path);
                 @unlink('./upgrade.php');
                 @unlink('./yourphp.sql');
                 @unlink($upgradezip_file);
             }
         }
         $this->assign('jumpUrl', U(MODULE_NAME . '/checkfile?menuid=' . $menuid));
         $this->success(L('upgrade_ok'));
         exit;
     }
     $this->assign('menuid', $menuid);
     $this->assign('var', $var);
     $this->assign('patchlist', $patchlist);
     $this->display();
 }
コード例 #25
0
ファイル: attachment.class.php プロジェクト: shenhua4286/gxw
 /**
  * 附件下载
  * Enter description here ...
  * @param $field 预留字段
  * @param $value 传入下载内容
  * @param $watermark 是否加入水印
  * @param $ext 下载扩展名
  * @param $absurl 绝对路径
  * @param $basehref 
  */
 function download($field, $value, $watermark = '0', $ext = 'gif|jpg|jpeg|bmp|png', $absurl = '', $basehref = '')
 {
     global $image_d;
     $this->att_db = pc_base::load_model('attachment_model');
     $upload_url = pc_base::load_config('system', 'upload_url');
     $this->field = $field;
     $dir = date('Y/md/');
     $uploadpath = $upload_url . $dir;
     $uploaddir = $this->upload_root . $dir;
     $string = new_stripslashes($value);
     if (!preg_match_all("/(href|src)=([\"|']?)([^ \"'>]+\\.({$ext}))\\2/i", $string, $matches)) {
         return $value;
     }
     $remotefileurls = array();
     foreach ($matches[3] as $matche) {
         if (strpos($matche, '://') === false) {
             continue;
         }
         dir_create($uploaddir);
         $remotefileurls[$matche] = $this->fillurl($matche, $absurl, $basehref);
     }
     unset($matches, $string);
     $remotefileurls = array_unique($remotefileurls);
     $oldpath = $newpath = array();
     foreach ($remotefileurls as $k => $file) {
         if (strpos($file, '://') === false || strpos($file, $upload_url) !== false) {
             continue;
         }
         $filename = fileext($file);
         $file_name = basename($file);
         $filename = $this->getname($filename);
         $newfile = $uploaddir . $filename;
         $upload_func = $this->upload_func;
         if ($upload_func($file, $newfile)) {
             $oldpath[] = $k;
             $GLOBALS['downloadfiles'][] = $newpath[] = $uploadpath . $filename;
             @chmod($newfile, 0777);
             $fileext = fileext($filename);
             if ($watermark) {
                 watermark($newfile, $newfile, $this->siteid);
             }
             $filepath = $dir . $filename;
             $downloadedfile = array('filename' => $filename, 'filepath' => $filepath, 'filesize' => filesize($newfile), 'fileext' => $fileext);
             $aid = $this->add($downloadedfile);
             $this->downloadedfiles[$aid] = $filepath;
         }
     }
     return str_replace($oldpath, $newpath, $value);
 }
コード例 #26
0
ファイル: attachments.php プロジェクト: baowzh/renfang
 public function crop_upload()
 {
     if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
         $pic = $GLOBALS["HTTP_RAW_POST_DATA"];
         if (isset($_GET['width']) && !empty($_GET['width'])) {
             $width = intval($_GET['width']);
         }
         if (isset($_GET['height']) && !empty($_GET['height'])) {
             $height = intval($_GET['height']);
         }
         if (isset($_GET['file']) && !empty($_GET['file'])) {
             $_GET['file'] = str_ireplace(';', '', 'php', $_GET['file']);
             if (is_image($_GET['file']) == false || stripos($_GET['file'], '.php') !== false) {
                 exit;
             }
             if (strpos($_GET['file'], pc_base::load_config('system', 'upload_url')) !== false) {
                 $file = $_GET['file'];
                 $basename = basename($file);
                 if (strpos($basename, 'thumb_') !== false) {
                     $file_arr = explode('_', $basename);
                     $basename = array_pop($file_arr);
                 }
                 $new_file = 'thumb_' . $width . '_' . $height . '_' . $basename;
             } else {
                 pc_base::load_sys_class('attachment', '', 0);
                 $module = trim($_GET['module']);
                 $catid = intval($_GET['catid']);
                 $siteid = $this->get_siteid();
                 $attachment = new attachment($module, $catid, $siteid);
                 $uploadedfile['filename'] = basename($_GET['file']);
                 $uploadedfile['fileext'] = fileext($_GET['file']);
                 if (in_array($uploadedfile['fileext'], array('jpg', 'gif', 'jpeg', 'png', 'bmp'))) {
                     $uploadedfile['isimage'] = 1;
                 }
                 $file_path = $this->upload_path . date('Y/md/');
                 pc_base::load_sys_func('dir');
                 dir_create($file_path);
                 $new_file = date('Ymdhis') . rand(100, 999) . '.' . $uploadedfile['fileext'];
                 $uploadedfile['filepath'] = date('Y/md/') . $new_file;
                 $aid = $attachment->add($uploadedfile);
             }
             $filepath = date('Y/md/');
             file_put_contents($this->upload_path . $filepath . $new_file, $pic);
         } else {
             return false;
         }
         echo pc_base::load_config('system', 'upload_url') . $filepath . $new_file;
         exit;
     }
 }
コード例 #27
0
ファイル: s2.php プロジェクト: crab890715/GoOut-Panel
echo $session;
?>
</td>
          <td>开启</td>
        </tr>
      </table>
      <table width="100%">
        <tr>
          <td class="td1">目录、文件权限检查</td>
          <td class="td1" width="25%">写入</td>
          <td class="td1" width="25%">读取</td>
        </tr>
<?php 
foreach ($folder as $dir) {
    $Testdir = SITEDIR . $dir;
    dir_create($Testdir);
    if (TestWrite($Testdir)) {
        $w = '<span class="correct_span">&radic;</span>可写 ';
    } else {
        $w = '<span class="correct_span error_span">&radic;</span>不可写 ';
        $err++;
    }
    if (is_readable($Testdir)) {
        $r = '<span class="correct_span">&radic;</span>可读';
    } else {
        $r = '<span class="correct_span error_span">&radic;</span>不可读';
        $err++;
    }
    ?>
        <tr>
          <td><?php 
コード例 #28
0
ファイル: upload.php プロジェクト: hcd2008/destoon
}
if ($DT['uploadlog'] && $MG['uploadday']) {
    $condition = 'addtime>' . ($DT_TIME - 86400);
    $condition .= $_username ? " AND username='******'" : " AND ip='{$DT_IP}'";
    $r = $db->get_one("SELECT COUNT(*) AS num FROM {$upload_table} WHERE {$condition}");
    if ($r['num'] >= $MG['uploadday']) {
        $errmsg = 'Error(4)' . lang('message->upload_limit_day', array($MG['uploadday'], $r['num']));
        if ($swfupload) {
            exit(convert($errmsg, DT_CHARSET, 'utf-8'));
        }
        dalert($errmsg);
    }
}
require DT_ROOT . '/include/post.func.php';
$uploaddir = 'file/upload/' . timetodate($DT_TIME, $DT['uploaddir']) . '/';
is_dir(DT_ROOT . '/' . $uploaddir) or dir_create(DT_ROOT . '/' . $uploaddir);
if ($MG['uploadtype']) {
    $DT['uploadtype'] = $MG['uploadtype'];
}
if ($MG['uploadsize']) {
    $DT['uploadsize'] = $MG['uploadsize'];
}
if ($remote && strlen($remote) > 17 && strpos($remote, '://') !== false) {
    require DT_ROOT . '/include/remote.class.php';
    $do = new remote($remote, $uploaddir);
} else {
    require DT_ROOT . '/include/upload.class.php';
    $do = new upload($_FILES, $uploaddir);
}
$js = $errjs = '';
if ($from == 'thumb' || $from == 'album' || $from == 'photo' || $from == 'file') {
コード例 #29
0
ファイル: module_api.class.php プロジェクト: baowzh/fulianweb
 /**
  * 检查安装目录
  * @param string $module 模块名
  */
 public function check($module = '')
 {
     define('INSTALL', true);
     if ($module) {
         $this->module = $module;
     }
     if (!$this->module) {
         $this->error_msg = L('no_module');
         return false;
     }
     if (!defined('INSTALL_MODULE')) {
         if (dir_create(PC_PATH . 'languages' . DIRECTORY_SEPARATOR . pc_base::load_config('system', 'lang') . DIRECTORY_SEPARATOR . 'test_create_dir')) {
             sleep(1);
             dir_delete(PC_PATH . 'languages' . DIRECTORY_SEPARATOR . pc_base::load_config('system', 'lang') . DIRECTORY_SEPARATOR . 'test_create_dir');
         } else {
             $this->error_msg = L('lang_dir_no_write');
             return false;
         }
     }
     $r = $this->db->get_one(array('module' => $this->module));
     if ($r) {
         $this->error_msg = L('this_module_installed');
         return false;
     }
     if (!$this->installdir) {
         $this->installdir = PC_PATH . 'modules' . DIRECTORY_SEPARATOR . $this->module . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR;
     }
     if (!is_dir($this->installdir)) {
         $this->error_msg = L('install_dir_no_exist');
         return false;
     }
     if (!file_exists($this->installdir . 'module.sql')) {
         $this->error_msg = L('module_sql_no_exist');
         return false;
     }
     $models = @(require $this->installdir . 'model.php');
     if (is_array($models) && !empty($models)) {
         foreach ($models as $m) {
             if (!file_exists(PC_PATH . 'model' . DIRECTORY_SEPARATOR . $m . '_model.class.php')) {
                 $this->error_msg = $m . L('model_clas_no_exist');
                 return false;
             }
             if (!file_exists($this->installdir . $m . '.sql')) {
                 $this->error_msg = $m . L('sql_no_exist');
                 return false;
             }
         }
     }
     return true;
 }
コード例 #30
0
ファイル: Process.php プロジェクト: mikegit2014/laravelback
 /**
  * 设置保存的路径
  *
  * @access private
  */
 private function setSavePath()
 {
     $savePath = base64url_decode($this->params['uploadPath']);
     if (!is_dir($savePath)) {
         //如果保存路径不存在,那么建立它
         dir_create($savePath);
     }
     return $savePath;
 }