del() public method

+---------------------------------------------------------- 删除目录下面的所有文件,但不删除目录 +---------------------------------------------------------- +---------------------------------------------------------- +----------------------------------------------------------
public del ( $directory )
Beispiel #1
0
 public function qclear()
 {
     $obj_dir = new Dir();
     is_dir(DATA_PATH . '_fields/') && $obj_dir->del(DATA_PATH . '_fields/');
     is_dir(CACHE_PATH) && $obj_dir->delDir(CACHE_PATH);
     is_dir(DATA_PATH) && $obj_dir->del(DATA_PATH);
     is_dir(TEMP_PATH) && $obj_dir->delDir(TEMP_PATH);
     is_dir(LOG_PATH) && $obj_dir->delDir(LOG_PATH);
     is_dir(PIN_DATA_PATH . '/static/') && $obj_dir->del(PIN_DATA_PATH . '/static/');
     @unlink(RUNTIME_FILE);
     $this->ajaxReturn(1, L('clear_success'));
 }
Beispiel #2
0
 function clearCache()
 {
     import("ORG.Io.Dir");
     $dir = new Dir();
     if (is_dir(CACHE_PATH)) {
         $dir->del(CACHE_PATH);
     }
     if (is_dir(TEMP_PATH)) {
         $dir->del(TEMP_PATH);
     }
     if (is_dir(LOG_PATH)) {
         $dir->del(LOG_PATH);
     }
     if (is_dir(DATA_PATH . '_fields/')) {
         $dir->del(DATA_PATH . '_fields/');
     }
     if (is_dir("./index/Runtime/Cache/")) {
         $dir->del("./index/Runtime/Cache/");
     }
     if (is_dir("./index/Runtime/Temp/")) {
         $dir->del("./index/Runtime/Temp/");
     }
     if (is_dir("./index/Runtime/Logs/")) {
         $dir->del("./index/Runtime/Logs/");
     }
     if (is_dir("./index/Runtime/Data/_fields/")) {
         $dir->del("./index/Runtime/Data/_fields/");
     }
     $this->display('index');
 }
 public function public_cache()
 {
     if (isset($_GET['type'])) {
         import("Dir");
         import('Cacheapi');
         $Cache = new Cacheapi();
         $Cachepath = RUNTIME_PATH;
         $Dir = new Dir();
         $type = $this->_get("type");
         switch ($type) {
             case "site":
                 try {
                     $Dir->del($Cachepath);
                     $Dir->del($Cachepath . "Data/");
                     $Dir->del($Cachepath . "Data/_fields/");
                 } catch (Exception $exc) {
                 }
                 try {
                     $cache = Cache::getInstance();
                     $cache->clear();
                 } catch (Exception $exc) {
                 }
                 $modules = array(array('name' => "菜单,模型,栏目缓存更新成功!", 'function' => 'site_cache', 'param' => ''), array('name' => "模型字段缓存更新成功!", 'function' => 'model_field_cache', 'param' => ''), array('name' => "模型content处理类缓存更新成功!", 'function' => 'model_content_cache', 'param' => ''), array('name' => "会员相关缓存更新成功!", 'function' => 'member_cache', 'param' => ''), array('name' => "应用更新成功!", 'function' => 'appstart_cache', 'param' => ''), array('name' => "敏感词缓存生成成功!", 'function' => 'censorword_cache', 'param' => ''));
                 foreach ($modules as $k => $v) {
                     try {
                         if ($v['function']) {
                             $Cache->{$v}['function']();
                         }
                     } catch (Exception $exc) {
                     }
                 }
                 $this->success("站点数据缓存更新成功!", U('Index/public_cache'));
                 break;
             case "template":
                 $Dir->delDir($Cachepath . "Cache/");
                 $this->success("模板缓存清理成功!", U('Index/public_cache'));
                 break;
             case "logs":
                 $Dir->del($Cachepath . "Logs/");
                 $this->success("站点日志清理成功!", U('Index/public_cache'));
                 break;
             default:
                 $this->error("请选择清楚缓存类型!");
                 break;
         }
     } else {
         $this->display("Index:cache");
     }
 }
Beispiel #4
0
 function setup()
 {
     $post = $_POST;
     $file = $post['path_root'] . '/' . trim($post['filename'], '.php') . '.php';
     $appgroup = empty($post['appgroup']) ? '' : "\tdefine('APP_GROUP','{$post['appgroup']}');//应用组目录 \n";
     $appname = empty($post['appname']) ? '' : "\tdefine('APP_NAME','{$post['appname']}');//应用名 \n";
     $compile = $post['compile'] ? "\tdefine('COMPILE',true);//是否生成核心编译文件\n" : "define('COMPILE',false);//是否生成核心编译文件 \n";
     $path_hdphp = dirname(PATH_ROOT) . '/hdphp/hdphp.php';
     $str = '<?php ' . "\n\t//www.hdphp.com 向军\n" . $appgroup . $appname . $compile . "\tinclude '{$path_hdphp}'; //HD框架核心包 \n" . '?>';
     $appgroup = empty($post['appgroup']) ? $post['appgroup'] : $post['appgroup'] . '/';
     $url = $post['root'] . '/' . basename($file);
     $appDir = PATH_ROOT . '/' . $appgroup . $post['appname'];
     //删除缓存
     $cachefiles = glob($_POST['path_root'] . '/temp/*');
     foreach ($cachefiles as $v) {
         $fileName = basename($v);
         if (in_array($fileName, array("log", "Session"))) {
             continue;
         }
         Dir::del($v);
     }
     if (is_dir($appDir)) {
         $this->error("应用{$post['appname']}已经创建,请删除后再创建");
     }
     if (is_file($file)) {
         $this->error("单入口文件已经存在");
     }
     if (file_put_contents($file, $str)) {
         $this->success("单入口文件创建成功", $url);
     } else {
         $this->error('文件创建失败,请检查目录权限');
     }
 }
Beispiel #5
0
 public function cache()
 {
     if (isset($_GET['type'])) {
         $Dir = new \Dir();
         $cache = D('Common/Cache');
         $type = I('get.type');
         switch ($type) {
             case "template":
                 //删除缓存目录下的文件
                 $Dir->del(RUNTIME_PATH);
                 $Dir->delDir(RUNTIME_PATH . "Cache/");
                 $Dir->delDir(RUNTIME_PATH . "Temp/");
                 //更新开启其他方式的缓存
                 \Think\Cache::getInstance()->clear();
                 $this->success("模板缓存清理成功!", U('Index/cache'));
                 break;
             case "logs":
                 $Dir->delDir(RUNTIME_PATH . "Logs/");
                 $this->success("站点日志清理成功!", U('Index/cache'));
                 break;
             default:
                 $this->error("请选择清楚缓存类型!");
                 break;
         }
     } else {
         $this->display();
     }
 }
Beispiel #6
0
/**
 * 清空缓存
 */
function sp_clear_cache()
{
    import("ORG.Util.Dir");
    $dirs = array();
    // runtime/
    $rootdirs = scandir(RUNTIME_PATH);
    //$noneed_clear=array(".","..","Data");
    $noneed_clear = array(".", "..");
    $rootdirs = array_diff($rootdirs, $noneed_clear);
    foreach ($rootdirs as $dir) {
        if ($dir != "." && $dir != "..") {
            $dir = RUNTIME_PATH . $dir;
            if (is_dir($dir)) {
                array_push($dirs, $dir);
                $tmprootdirs = scandir($dir);
                foreach ($tmprootdirs as $tdir) {
                    if ($tdir != "." && $tdir != "..") {
                        $tdir = $dir . '/' . $tdir;
                        if (is_dir($tdir)) {
                            array_push($dirs, $tdir);
                        }
                    }
                }
            } else {
                @unlink($dir);
            }
        }
    }
    $dirtool = new Dir("");
    foreach ($dirs as $dir) {
        $dirtool->del($dir);
    }
    if (defined('IS_SAE') && IS_SAE) {
        $global_mc = @memcache_init();
        if ($global_mc) {
            $global_mc->flush();
        }
        $no_need_delete = array("THINKCMF_DYNAMIC_CONFIG");
        $kv = new SaeKV();
        // 初始化KVClient对象
        $ret = $kv->init();
        // 循环获取所有key-values
        $ret = $kv->pkrget('', 100);
        while (true) {
            foreach ($ret as $key => $value) {
                if (!in_array($key, $no_need_delete)) {
                    $kv->delete($key);
                }
            }
            end($ret);
            $start_key = key($ret);
            $i = count($ret);
            if ($i < 100) {
                break;
            }
            $ret = $kv->pkrget('', 100, $start_key);
        }
    }
}
Beispiel #7
0
 public function updateCache()
 {
     $ActionCache = F('updateCache');
     if ($ActionCache) {
         $action = array_shift($ActionCache);
         F('updateCache', $ActionCache);
         switch ($action) {
             case "Config":
                 $Model = K("Config");
                 $Model->updateCache();
                 $this->success('网站配置更新完毕...', U("updateCache"), 0);
                 break;
             case "Model":
                 $Model = K("Model");
                 $Model->updateCache();
                 $this->success('模型更新完毕...', U("updateCache"), 0);
                 break;
             case "Field":
                 $Model = new ModelFieldModel(1);
                 $ModelCache = cache("model");
                 foreach ($ModelCache as $mid => $data) {
                     $Model->updateCache($mid);
                 }
                 $this->success('字段更新完毕...', U("updateCache"), 0);
                 break;
             case "Category":
                 $Model = K("Category");
                 $Model->updateCache();
                 $this->success('栏目更新完毕...', U("updateCache"), 0);
                 break;
             case "Node":
                 $Model = K("Node");
                 $Model->updateCache();
                 $this->success('权限节点更新完毕...', U("updateCache"), 0);
                 break;
             case "Table":
                 cache('table', null);
                 $this->success('数据表更新完毕...', U("updateCache"), 0);
                 break;
             case "Role":
                 $Model = K("Role");
                 $Model->updateCache();
                 $this->success('角色更新完毕...', U("updateCache"), 0);
                 break;
             case "Flag":
                 $Model = new FlagModel(1);
                 $ModelCache = cache("model");
                 foreach ($ModelCache as $mid => $data) {
                     $Model->updateCache($mid);
                 }
                 $this->success('Flag更新完毕...', U("updateCache"), 0);
                 break;
         }
     } else {
         Dir::del('temp');
         $this->success('缓存更新成功...', U('index'), 0);
     }
 }
 public function del()
 {
     $r = Dir::del('Backup/' . $_GET['dir']);
     if ($r) {
         $this->success('删除成功');
     } else {
         $this->error('删除失败');
     }
 }
Beispiel #9
0
 public function del()
 {
     $dir = Q('dir');
     if (Dir::del('backup/' . $dir)) {
         $this->success('删除成功!', 'index');
     } else {
         $this->error('删除失败,请检查目录权限!', 'index');
     }
 }
 public function updateCache()
 {
     if ($action = Q('get.action')) {
         switch ($action) {
             case "Config":
                 $Model = K("Config");
                 $Model->updateCache();
                 $this->success('网站配置更新完毕...', U('updateCache', array('action' => 'Model')), 0);
                 break;
             case "Model":
                 $Model = K("Model");
                 $Model->updateCache();
                 $this->success('模型更新完毕...', U('updateCache', array('action' => 'Field')), 0);
                 break;
             case "Field":
                 $ModelCache = S("model");
                 foreach ($ModelCache as $mid => $data) {
                     $_REQUEST['mid'] = $mid;
                     $Model = new FieldModel();
                     $Model->updateCache($mid);
                 }
                 $this->success('字段更新完毕...', U('updateCache', array('action' => 'Category')), 0);
                 break;
             case "Category":
                 $Model = K('Category');
                 $Model->updateCache();
                 $this->success('栏目更新完毕...', U('updateCache', array('action' => 'Node')), 0);
                 break;
             case "Node":
                 $Model = K("Node");
                 $Model->updateCache();
                 $this->success('权限节点更新完毕...', U('updateCache', array('action' => 'Table')), 0);
                 break;
             case "Table":
                 Dir::del('temp/Table');
                 $this->success('数据表更新完毕...', U('updateCache', array('action' => 'Role')), 0);
                 break;
             case "Role":
                 $Model = K("Role");
                 $Model->updateCache();
                 $this->success('角色更新完毕...', U('updateCache', array('action' => 'Flag')), 0);
                 break;
             case "Flag":
                 $ModelCache = S("model");
                 foreach ($ModelCache as $mid => $data) {
                     $_REQUEST['mid'] = $mid;
                     $Model = new FlagModel();
                     $Model->updateCache();
                 }
                 $this->display('success.php');
                 break;
         }
     } else {
         $this->success('缓存更新成功...', U('index'), 0);
     }
 }
Beispiel #11
0
 function clearCache()
 {
     set_time_limit(0);
     $i = intval($_REQUEST['id']);
     if (!$i) {
         $this->error('操作失败');
     } else {
         import("ORG.Io.Dir");
         $dir = new Dir();
         switch ($i) {
             case 1:
                 //更新全站缓存
                 is_dir(CACHE_PATH) && $dir->del(CACHE_PATH);
                 is_dir(DATA_PATH . '_fields/') && $dir->del(DATA_PATH . '_fields/');
                 is_dir(TEMP_PATH) && $dir->del(TEMP_PATH);
                 if (is_dir("./index/Runtime")) {
                     deleteCacheData("./index/Runtime");
                 }
                 if (is_dir("./admin/Runtime")) {
                     deleteCacheData("./admin/Runtime");
                 }
                 //Api缓存
                 is_dir('./Apicache/') && delCache('./Apicache/');
                 break;
             case 2:
                 //后台模版缓存
                 is_dir(CACHE_PATH) && $dir->del(CACHE_PATH);
                 break;
             case 3:
                 //前台模版缓存
                 is_dir("./index/Runtime/Cache/") && $dir->del("./index/Runtime/Cache/");
                 is_dir("./index/Html/") && $dir->del("./index/Html/");
                 break;
             case 4:
                 //数据库缓存
                 is_dir(DATA_PATH . '_fields/') && $dir->del(DATA_PATH . '_fields/');
                 is_dir("./index/Runtime/Data/_fields/") && $dir->del("./index/Runtime/Data/_fields/");
                 break;
             case 5:
                 //Api缓存
                 is_dir('./Apicache/') && delCache('./Apicache/');
                 break;
             default:
                 break;
         }
         $runtime = defined('MODE_NAME') ? '~' . strtolower(MODE_NAME) . '_runtime.php' : '~runtime.php';
         $runtime_file_admin = RUNTIME_PATH . $runtime;
         $runtime_file_front = ROOT_PATH . '/index/Runtime/' . $runtime;
         is_file($runtime_file_admin) && @unlink($runtime_file_admin);
         is_file($runtime_file_front) && @unlink($runtime_file_front);
         $this->success('更新完成', U('Cache/index'));
     }
 }
Beispiel #12
0
 function delcache()
 {
     $temp = Q('temp', null, 'trim');
     if ($temp && is_dir($temp)) {
         foreach (glob($temp . '/*') as $d) {
             Dir::del($d);
         }
     }
     $url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
     $this->success('缓存目录已经全部删除成功', $url);
 }
Beispiel #13
0
 public function deleteFailureDir($dir)
 {
     foreach (Dir::tree($dir) as $d) {
         if (!is_file($d['path'] . '/lock.php')) {
             if (!\Dir::del($d['path'])) {
                 $this->error = $d['path'] . "删除失败";
                 return FALSE;
             }
         }
     }
     return TRUE;
 }
Beispiel #14
0
 public function create_all()
 {
     if (IS_POST) {
         //删除html目录
         Dir::del(C('HTML_PATH'));
         F("RedirectInfo", array(array('url' => 'create_index', 'title' => '准备生成首页'), array('url' => 'create_category', 'title' => '准备生成栏目页...'), array('url' => 'create_content', 'title' => '准备生成内容页...'), array('url' => 'create_all', 'title' => '全部生成完毕...')));
         //生成首页
         $this->success('初始化完成...', 'create_index');
     } else {
         F("RedirectInfo", null);
         $this->display();
     }
 }
 public function index()
 {
     if (IS_POST) {
         is_file(TEMP_PATH . '~Boot.php') && unlink(TEMP_PATH . '~Boot.php');
         Dir::del('Temp/Compile');
         Dir::del('Temp/Content');
         Dir::del('Temp/Table');
         //缓存更新动作
         S('updateCacheAction', $_POST['Action']);
         $this->success('准备更新...', U('updateCache', array('action' => 'Config')), 1);
     } else {
         $this->display();
     }
 }
Beispiel #16
0
 /**
  * 全局缓存
  */
 public function delete()
 {
     if (!IS_GET) {
         $this->error("页面不存在!");
     }
     $temp = Q("get.temp");
     $dir = glob($temp . '*');
     if (!empty($dir) && $temp && is_dir($temp)) {
         foreach ($dir as $d) {
             Dir::del($d);
         }
     }
     $url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
     $this->success('缓存目录已经全部删除成功', $url);
 }
 public function selectStyle()
 {
     $dir_name = Q("dirName");
     if ($dir_name) {
         import('Config.Model.ConfigModel');
         $Model = K("Config");
         $Model->where("name='WEB_STYLE'")->save(array("value" => $dir_name));
         //更新配置文件
         $Model->updateCache();
         //删除前台编译文件
         is_dir("./temp/hdcms/Content/Compile") and Dir::del("./temp/hdcms/Content/Compile");
         //删除编译文件
         is_dir('temp/Hdcms/Index') and dir::del('temp/Hdcms/Index');
         $this->success('操作成功');
     }
 }
Beispiel #18
0
 public function select_style()
 {
     $dir_name = Q("dir_name");
     if ($dir_name) {
         import('Config.Model.ConfigModel');
         $db = K("config");
         K("config")->join()->where("name='WEB_STYLE'")->save(array("value" => $dir_name));
         //更新配置文件
         $db->update_config_file();
         //删除前台编译文件
         is_dir("./temp/hdcms/Content/Compile") and Dir::del("./temp/hdcms/Content/Compile");
         //删除编译文件
         is_dir('temp/Hdcms/Index') and dir::del('temp/Hdcms/Index');
         $this->ajax(array('state' => 1, 'message' => '操作成功'));
     }
 }
Beispiel #19
0
 /**
  * 删除表态文件
  * @param void $name 目录名或者HTML文件
  * @return boolean
  */
 public static function del($name)
 {
     if (is_array($name)) {
         foreach ($name as $v) {
             if (is_file($v)) {
                 unlink($v);
                 continue;
             }
             Dir::del($v);
         }
     } else {
         if (is_file($name)) {
             unlink($name);
         } else {
             Dir::del($name);
         }
     }
     return true;
 }
Beispiel #20
0
 /**
  +----------------------------------------------------------
 * 保存配置到数据库和config文件
  +----------------------------------------------------------
 * @access public
  +----------------------------------------------------------
 */
 function save()
 {
     //db_siteurl和EXTRA_UPLOAD_PATH这两个值如果用户在最后写上了/,把/去掉
     if (substr($_POST["SITE_HOST"], strlen($_POST["SITE_HOST"]) - 1) == '/') {
         $_POST["SITE_HOST"] = substr($_POST["SITE_HOST"], 0, strlen($_POST["SITE_HOST"]) - 1);
     }
     $web_config = "<?php\r\nif (!defined('THINK_PATH')) exit();\r\nreturn array(\r\n";
     foreach ($_POST as $key => $value) {
         if (strtolower($value) == "true" || strtolower($value) == "false" || is_numeric($value)) {
             $web_config .= "\t'" . $key . "'=>{$value},\r\n";
         } else {
             $web_config .= "\t'" . $key . "'=>'{$value}',\r\n";
         }
     }
     $web_config .= ");\r\n?>";
     file_put_contents(APP_PATH . "/siteconfig.inc.php", $web_config);
     $dir = new Dir("./Runtime");
     $dir->del("./Runtime");
     $this->success(L('_OPTIONS_SAVE_SUCCESS_'));
 }
 public function del()
 {
     import("ORG.Io.Dir");
     $dir = new Dir();
     $this->create_channel();
     @unlink('./temp/~app.php');
     @unlink('./temp/~runtime.php');
     if (is_dir('./temp/Data/_fields')) {
         $dir->del('./temp/Data/_fields');
     }
     if (is_dir('./temp/Temp')) {
         $dir->delDir('./temp/Temp');
     }
     if (is_dir('./temp/Cache')) {
         $dir->delDir('./temp/Cache');
     }
     if (is_dir('./temp/Logs')) {
         $dir->delDir('./temp/Logs');
     }
     echo '[清除成功]';
 }
Beispiel #22
0
 /**
  * 更新缓存
  * @return mixed
  */
 public function updateCache()
 {
     if (!service('user')->isSuperUser()) {
         message('您不是系统管理员,无法进行操作', 'back', 'error');
     }
     if (IS_POST) {
         //更新数据缓存
         if (isset($_POST['data'])) {
             Dir::del(ROOT_PATH . '/storage/cache');
         }
         //更新模板缓存
         if (isset($_POST['tpl'])) {
             Dir::del(ROOT_PATH . '/storage/view');
         }
         //微信缓存
         if (isset($_POST['weixin'])) {
             Dir::del(ROOT_PATH . '/storage/weixin');
         }
         //更新所有站点缓存
         service('site')->updateAllCache();
         message('缓存更新成功', 'menu', 'success');
     }
     return view();
 }
Beispiel #23
0
	public function cache_log() {
		libfile('Dir');
		$dir = new Dir();
		return $dir->del(LOG_PATH);
	}
 /**
  *导入活动数据
  *@date 2010-7-6
  *@time 下午02:34:57
  */
 function events()
 {
     //导入活动数据
     import("@.Com.OLERead");
     import("@.Com.Spreadsheet_Excel_Reader");
     import("ORG.Util.Image");
     $filename = $_GET['fname'];
     $act = $_GET['act'];
     if (empty($filename) && $act != 'hebing') {
         echo '<a href=' . __URL__ . "/events/fname/bj_20100827/>bj_20100827</a><br>";
         echo '<a href=' . __URL__ . "/events/fname/gz_20100825/>gz_20100825</a><br>";
         echo '<a href=' . __URL__ . "/events/fname/sh_20100826/>sh_20100826</a><br>";
         echo '<a href=' . __URL__ . "/events/fname/sz_20100824/>sz_20100824</a><br>";
         echo '<a href=' . __URL__ . "/events/act/hebing/>合并数据</a><br>";
         exit;
     }
     if ($act == 'hebing') {
         $newarr = array();
         $arr1 = S('bj_20100827');
         $arr2 = S('gz_20100825');
         $arr3 = S('sh_20100826');
         $arr4 = S('sz_20100824');
         $newarr = array_merge($arr1, $arr2, $arr3, $arr4);
         shuffle($newarr);
         S('hebing', $newarr, 6000);
         if (S('hebing')) {
             echo "<a href='" . __URL__ . "/events/'>返回</a><br>";
             echo '写入成功';
         } else {
             echo '写入bu成功';
         }
         exit;
     }
     $path = "Public/events/";
     $file = $path . $filename . '.xls';
     $arr = array();
     $data = new Spreadsheet_Excel_Reader();
     $data->setOutputEncoding('utf-8');
     $data->read($file);
     //error_reporting(E_ALL ^ E_NOTICE);
     //echo $data->sheets[0]['numRows'];
     //echo $data->sheets[0]['numCols'];
     //echo $data->sheets[0]['cells'][3][8];
     if (($act == 'ok' || $act == 'fdb') && !empty($filename)) {
         import("ORG.Io.Dir");
         if (is_dir('Public/event/exl' . $filename)) {
             Dir::del('Public/event/exl' . $filename);
         }
     }
     $arr = array();
     $msg = '';
     $errnum = 0;
     $warr = 0;
     $img_arr = array();
     if (empty($data->sheets[0])) {
         //dump($data->formatRecords);
         $this->error("0");
     }
     for ($i = 2; $i <= 220; $i++) {
         if ($data->sheets[0]['cells'][$i][16] == '1' || empty($data->sheets[0]['cells'][$i][1])) {
             continue;
         }
         $l = $data->sheets[0]['cells'][$i][4];
         if (strpos($l, '_')) {
             $l = end(explode('_', $l));
         }
         //dump($data->sheets[0]['cells'][$i]);
         $arr[$i]['title'] = $data->sheets[0]['cells'][$i][1];
         $arr[$i]['cid'] = $this->city($data->sheets[0]['cells'][$i][2]);
         if ($arr[$i]['cid'] == '0') {
             continue;
         }
         $msg .= 'CID ' . $arr[$i]['cid'] . '___';
         $time = $this->get_time($data->sheets[0]['cells'][$i][3]);
         $arr[$i]['showstart'] = $time['st'];
         $arr[$i]['showend'] = $time['et'];
         $arr[$i]['channel'] = 10;
         $arr[$i]['dir'] = $path . $filename . '/' . $l . '/';
         $arr[$i]['writer'] = $data->sheets[0]['cells'][$i][4];
         if (!empty($data->sheets[0]['cells'][$i][5]) || $data->sheets[0]['cells'][$i][5] == '0') {
             $arr[$i]['albumnum'] = $data->sheets[0]['cells'][$i][5];
         }
         if (empty($data->sheets[0]['cells'][$i][6])) {
             continue;
         }
         $arr[$i]['typeid'] = $this->get_etype($data->sheets[0]['cells'][$i][6]);
         $msg .= 'typeid ' . $arr[$i]['typeid'] . '___';
         $arr[$i]['maps'] = $this->br_or_b($data->sheets[0]['cells'][$i][8]);
         $arr[$i]['event']['detail'] = $this->br_or_b($data->sheets[0]['cells'][$i][7]);
         $kw = str_word_count($arr[$i]['title'], 1);
         $keywords = "";
         foreach ($kw as $vkw) {
             $keywords .= $vkw . ',';
         }
         $arr[$i]['keywords'] = trim($keywords, ',');
         $arr[$i]['my_content'] = strip_tags($arr[$i]['event']['detail']);
         $arr[$i]['description'] = $arr[$i]['my_content'];
         if ($arr[$i]['albumnum'] || $arr[$i]['albumnum'] == '0') {
             $flist = $this->file_list($arr[$i]['dir']);
             $img = count($flist);
             $num = $arr[$i]['albumnum'] + 1;
             if ($num != $img) {
                 $msg .= $data->sheets[0]['cells'][$i][4] . '图片数量不正确实际图:' . $img . '填写图片:' . $arr[$i]['albumnum'] . "<br>\n";
                 $errnum++;
             } else {
                 $msg .= $data->sheets[0]['cells'][$i][4] . "信息图片匹配<br>\n";
                 foreach ($flist as $v) {
                     $type = Image::getImageInfo($v);
                     if ($type['type'] == 'bmp') {
                         $msg .= '<b>' . $v . '图片格式不能是bmp</b><br>';
                         $warr++;
                     } elseif (($act == 'ok' || $act == 'fdb') && !empty($filename)) {
                         //是否确认写入
                         $filelen = strpos($v, '.');
                         //获取文件名长度
                         $filename_name = substr($v, 0, $filelen);
                         //截取文件名
                         $filename_name = end(explode("/", $filename_name));
                         $ext = strtolower(end(explode(".", $v)));
                         if ($filename_name == '0') {
                             $width = array('120', '514');
                             $height = array('140', '600');
                             $pre = array('s_', 'm_');
                             $fname = 's_' . md5_file(auto_charset($v, 'utf-8', 'gbk')) . '.' . $ext;
                             $dir = $l['0'] . '/' . date("Y_m_d") . '/';
                             $spath = 'Public/event/exl' . $filename . '/' . $dir;
                             if (in_array($dir . $fname, $img_arr)) {
                                 $arr[$i]['picurl'] = $spath . $fname;
                                 $arr[$i]['pic'][]['filename'] = $spath . 'm_' . md5_file(auto_charset($v, 'utf-8', 'gbk')) . '.' . $ext;
                             } else {
                                 $img_arr[$i] = $dir . $fname;
                                 $this->mvimg($v, $spath, md5_file(auto_charset($v, 'utf-8', 'gbk')), $width, $height, $pre);
                                 $arr[$i]['picurl'] = $spath . $fname;
                                 $arr[$i]['pic'][]['filename'] = $spath . 'm_' . md5_file(auto_charset($v, 'utf-8', 'gbk')) . '.' . $ext;
                             }
                         } else {
                             $width = array('514');
                             $height = array('600');
                             $pre = array('m_');
                             $fname = 'm_' . md5_file(auto_charset($v, 'utf-8', 'gbk')) . '.' . $ext;
                             $dir = $l['0'] . '/' . date("Y_m_d") . '/';
                             $spath = 'Public/event/exl' . $filename . '/' . $dir;
                             if (in_array($dir . $fname, $img_arr)) {
                                 $arr[$i]['pic'][]['filename'] = $spath . $fname;
                             } else {
                                 $img_arr[$i] = $dir . $fname;
                                 $this->mvimg($v, $spath, md5_file(auto_charset($v, 'utf-8', 'gbk')), $width, $height, $pre);
                                 $arr[$i]['pic'][]['filename'] = $spath . $fname;
                             }
                         }
                     }
                     //图片不是BMP格式
                 }
                 //dump($arr[$i]['picurl']);
             }
         } else {
             $msg .= '<b>' . $data->sheets[0]['cells'][$i][4] . "信息无图片</b><br>\n";
             $warr++;
         }
     }
     //end 循环读取数据
     if ($act == 'ok') {
         $return = '';
         $arc = D("Archives");
         $event = D("Event");
         $arr = S('hebing');
         foreach ($arr as $d) {
             if (!empty($d['title']) && !empty($d['typeid'])) {
                 $acr_vo = '';
                 $arc_vo = $arc->create($d);
                 $aid = $arc->add($arc_vo);
                 if ($aid) {
                     $event_vo = $event->create($d['event']);
                     $event_vo['aid'] = $aid;
                     $eid = $event->add($event_vo);
                     $this->add_photo($aid, $d['pic'], $d['writer'], 11);
                     $return .= $d['writer'] . "写入成功!<br>\n";
                 } else {
                     $return .= $d['writer'] . "主档写入失败!<br>\n";
                 }
             } else {
                 $return .= $d['writer'] . "标题或分类为空写入失败!<br>\n";
             }
         }
         echo $return;
     } elseif ($act == 'fdb') {
         S($filename, $arr, 6000);
         if (S($filename)) {
             echo "<a href='" . __URL__ . "/events/'>返回</a><br>";
             echo '写入成功';
         } else {
             echo '写入bu成功';
         }
     } else {
         echo '共有' . $errnum . '错误!<br>' . $warr . "警告!<br>\n";
         echo $msg;
         echo "<a href='" . __URL__ . "/events/act/fdb/fname/" . $filename . "'>写入缓存</a><br>";
         echo "<a href='" . __URL__ . "/events/act/ok/fname/" . $filename . "'>写入数据</a>";
     }
 }
Beispiel #25
0
 public function spmy_export_menu()
 {
     $menus = D("Menu")->order(array("app" => "ASC", "model" => "ASC", "action" => "ASC"))->select();
     $menus_tree = array();
     $apps = scandir(SPAPP);
     import('@.ORG.Dir');
     $dir = new \Dir();
     foreach ($apps as $a) {
         if (is_dir(SPAPP . $a)) {
             if (!(strpos($a, ".") === 0)) {
                 $menudir = SPAPP . $a . "/Menu";
                 $dir->del($menudir);
             }
         }
     }
     foreach ($menus as $m) {
         $mm = $m;
         unset($mm['app']);
         unset($mm['model']);
         unset($mm['id']);
         unset($mm['parentid']);
         $menus_tree[$m['app']][$m['model']][] = $mm;
     }
     foreach ($menus_tree as $app => $models) {
         $menudir = SPAPP . $app . "/Menu";
         foreach ($models as $model => $a) {
             if (!file_exists($menudir)) {
                 mkdir($menudir);
             }
             file_put_contents($menudir . "/{$model}.php", "<?php\treturn " . var_export($a, true) . ";?>");
         }
     }
     $this->display("export_menu");
 }
Beispiel #26
0
 /**
  * 清除Html静态缓存
  */
 static function deleteHtml($type)
 {
     $type = strtolower($type);
     import('ORG.Io.Dir');
     $dir = new Dir();
     switch ($type) {
         case 'channel':
             //频道Html缓存
             $path = HTML_PATH . 'Home/channel';
             if (is_dir($path)) {
                 @$dir->del($path);
             }
             $path = HTML_PATH . 'Wap/channel';
             if (is_dir($path)) {
                 @$dir->del($path);
             }
             break;
         case 'info':
             //信息Html缓存
             $path = HTML_PATH . 'Home/info';
             if (is_dir($path)) {
                 $dir->del($path);
             }
             $path = HTML_PATH . 'Wap/info';
             if (is_dir($path)) {
                 $dir->del($path);
             }
             break;
         case 'all':
             //全部Html缓存
             if (is_dir(HTML_PATH)) {
                 @deldir(HTML_PATH);
             }
             break;
         case 'index':
             //首页Html缓存
         //首页Html缓存
         default:
             $cnName = ChannelHtml(1);
             $enName = ChannelHtml(2);
             $suffix = C('URL_HTML_SUFFIX');
             $filelist = array(HTML_PATH . 'Home/channel/' . $cnName . '_cn.' . $suffix, HTML_PATH . 'Home/channel/' . $enName . '_en.' . $suffix, HTML_PATH . 'Home/index_cn.' . $suffix, HTML_PATH . 'Home/index_en.' . $suffix, HTML_PATH . 'Wap/channel/' . $cnName . '_cn.' . $suffix, HTML_PATH . 'Wap/channel/' . $enName . '_en.' . $suffix, HTML_PATH . 'Wap/index_cn.' . $suffix, HTML_PATH . 'Wap/index_en.' . $suffix);
             foreach ($filelist as $f) {
                 if (is_file($f)) {
                     @unlink($f);
                 }
             }
             break;
     }
 }
Beispiel #27
0
 /**
 +----------------------------------------------------------
 * 清除缓存
 +----------------------------------------------------------
 * @access public 
 +----------------------------------------------------------
 * @param string $name 缓存变量名
 +----------------------------------------------------------
 * @return boolen
 +----------------------------------------------------------
 */
 public function clear()
 {
     import("ORG.Io.Dir");
     Dir::del($this->options['temp']);
 }
 private function keys()
 {
     $path = APP_PATH . 'Conf/dataconfig.php';
     if (is_writable($path) == false) {
         exit(serialize(array('error' => -10007, 'status' => 'fail')));
     }
     //读取数据
     $config = (include $path);
     if (empty($config)) {
         exit(serialize(array('error' => -10018, 'status' => 'fail')));
     }
     //开始更新
     $config['AUTHCODE'] = genRandomString(30);
     if (F('dataconfig', $config, APP_PATH . 'Conf/')) {
         //删除缓存
         $Dir = new Dir();
         $Dir->del(RUNTIME_PATH);
         exit(serialize(array('authcode' => $config['AUTHCODE'], 'status' => 'success')));
     } else {
         exit(serialize(array('error' => -10019, 'status' => 'fail')));
     }
 }
 public function clear()
 {
     $type = $this->_get('type', 'trim');
     $obj_dir = new Dir();
     switch ($type) {
         case 'field':
             is_dir(DATA_PATH) && $obj_dir->del(DATA_PATH);
             break;
         case 'tpl':
             is_dir(CACHE_PATH) && $obj_dir->delDir(CACHE_PATH);
             break;
         case 'data':
             is_dir(DATA_PATH) && $obj_dir->del(DATA_PATH);
             is_dir(TEMP_PATH) && $obj_dir->delDir(TEMP_PATH);
             break;
         case 'runtime':
             @unlink(RUNTIME_FILE);
             break;
         case 'logs':
             is_dir(LOG_PATH) && $obj_dir->delDir(LOG_PATH);
             break;
     }
     $this->ajaxReturn(1);
 }
 /**
  * @Title: setSubDetail
  * @Description: todo(获取动态配置的明细返回值)
  * @param  $modelname      string 模型对象名称
  * @param  $data          array 数据设置
  * @author 杨希
  * @date 2014-4-15 上午10:00:00
  * @throws
  */
 public function setSubDetail($modelname, $data = array())
 {
     $filename = "sublist.inc.php";
     //文件路径
     $filepath = DConfig_PATH . "/Models/" . $modelname;
     if (!is_dir($filepath)) {
         $this->make_dir($filepath, 0777);
     }
     $this->writeover($filepath . "/" . $filename, "return " . $this->pw_var_export($data) . ";\n", true);
     //针对具体人员配置到缓存中去
     $filename_user = $filename . $_SESSION[C('USER_AUTH_KEY')] . ".php";
     $cachepath = C("DATA_CACHE_PATH") . "Dynamicconf/Models/" . $modelname;
     $cachedata = array();
     foreach ($data as $k => $v) {
         if ($v['shows'] == 1) {
             $cachedata[] = $v;
         }
     }
     //是否存在配置文件
     if (file_exists($filepath . "/" . $filename)) {
         //是否存在cache缓存,存在则删除里面的数据
         if (file_exists($cachepath)) {
             $obj_dir = new Dir();
             $obj_dir->del($cachepath);
         } else {
             $isdir = $this->make_dir($cachepath);
         }
     }
     $this->writeover($cachepath . "/" . $filename_user, "return " . $this->pw_var_export($cachedata) . ";\n", true);
 }