예제 #1
0
 /**
  * 批量保存配置
  * @author 麦当苗儿 <*****@*****.**>
  */
 public function save($config)
 {
     $old['artid'] = M('Config')->where(array('name' => 'WXARTID'))->getField('value');
     if ($config && is_array($config)) {
         $Config = M('Config');
         foreach ($config as $name => $value) {
             $map = array('name' => $name);
             if ($name == 'WXARTID') {
                 if ($old['artid'] != $value) {
                     asyn_sendwx();
                     //$WX->sendwx();
                 }
             }
             if ($name == 'WXPASS') {
                 $value = think_encrypt($value, UC_AUTH_KEY);
             }
             $Config->where($map)->setField('value', $value);
         }
     }
     S('DB_CONFIG_DATA', null);
     $config_file = './App/Home/Conf/theme.php';
     $themename = (include $config_file);
     if ($config['WEB_THEME'] != $themename['DEFAULT_THEME']) {
         //写入配置文件
         $theme['DEFAULT_THEME'] = $config['WEB_THEME'];
         file_put_contents($config_file, "<?php \nreturn " . var_export($theme, true) . ";", LOCK_EX);
         dir_delete(RUNTIME_PATH);
     }
     $this->mtReturn(200, '网站配置保存成功!', '', 'forward', U('group'));
 }
예제 #2
0
파일: unlink.php 프로젝트: nopuls/dzcp
function all_delete($dir_file)
{
    if (is_dir($dir_file)) {
        $array = dir_delete($dir_file);
        $array = array_reverse($array);
        foreach ($array as $elem) {
            @rmdir($elem);
        }
    } elseif (is_file($dir_file)) {
        @unlink($dir_file);
    }
}
 public function rollback()
 {
     $this->setProgress(0, 'Rolling back...');
     $this->dbRemoveAll();
     if (is_dir($this->packageFolder)) {
         dir_delete($this->packageFolder);
     }
     if (is_file($this->packageFile)) {
         @unlink($this->packageFile);
     }
     $this->setProgress(0, 'Roll back finished: Ok. ');
 }
예제 #4
0
 public function cache()
 {
     dir_delete(CACHE_PATH . 'Html/');
     dir_delete(CACHE_PATH . 'Tpl/');
     dir_delete(CACHE_PATH . 'Temp/');
     if (is_file(RUNTIME_FILE)) {
         @unlink(RUNTIME_FILE);
     }
     R('Admin/Category/repair');
     R('Admin/Category/repair');
     foreach ($this->cache_model as $r) {
         savecache($r);
     }
     $forward = $_GET['forward'] ? $_GET['forward'] : U('Index/main');
     $this->assign('jumpUrl', $forward);
     $this->success(L('do_success'));
 }
예제 #5
0
 public function images()
 {
     $path = $this->publicpath . 'images/' . $_GET['folder'];
     $this->assign('Public', $this->publicpath);
     $uppath = explode('/', $_GET['folder']);
     $leve = count($uppath) - 1;
     unset($uppath[$leve]);
     if ($leve > 1) {
         unset($uppath[$leve - 1]);
         $uppath = implode('/', $uppath) . '/';
     } else {
         $uppath = '';
     }
     $this->assign('leve', $leve);
     $this->assign('uppath', $uppath);
     if ($_GET['delete']) {
         $file = $path . $_GET['filename'];
         if (file_exists($file)) {
             is_dir($file) ? dir_delete($file) : unlink($file);
             $this->success(L('delete_ok'));
         } else {
             $this->error(L('file_no_find'));
         }
     }
     $files = glob($path . '*');
     $folders = array();
     foreach ($files as $key => $file) {
         $filename = basename($file);
         if (is_dir($file)) {
             $folders[$key]['filename'] = $filename;
             $folders[$key]['filepath'] = $file;
             $folders[$key]['ext'] = 'folder';
         } else {
             $templates[$key]['filename'] = $filename;
             $templates[$key]['filepath'] = $file;
             $templates[$key]['ext'] = strtolower(substr($filename, strrpos($filename, '.') - strlen($filename) + 1));
             if (!in_array($templates[$key]['ext'], array('gif', 'jpg', 'png', 'bmp'))) {
                 $templates[$key]['ico'] = 1;
             }
         }
     }
     $this->assign('path', $path);
     $this->assign('folders', $folders);
     $this->assign('files', $templates);
     $this->display();
 }
예제 #6
0
 public function cache()
 {
     dir_delete(RUNTIME_PATH . 'Html/');
     dir_delete(RUNTIME_PATH . 'Cache/');
     if (is_file(RUNTIME_PATH . '~runtime.php')) {
         @unlink(RUNTIME_PATH . '~runtime.php');
     }
     if (is_file(RUNTIME_PATH . '~allinone.php')) {
         @unlink(RUNTIME_PATH . '~allinone.php');
     }
     R('Admin/Category/repair');
     R('Admin/Category/repair');
     foreach ($this->cache_model as $r) {
         savecache($r);
     }
     $this->assign('jumpUrl', U('Main/main'));
     $this->success(L('do_success'));
 }
예제 #7
0
파일: F_Basic.php 프로젝트: GobYang/thaidh
function dir_delete($dir)
{
    $dir = dir_path($dir);
    if (!is_dir($dir)) {
        return false;
    }
    $list = glob($dir . '*');
    foreach ($list as $file) {
        is_dir($file) ? dir_delete($file) : unlink($file);
    }
    return rmdir($dir);
}
예제 #8
0
 function dir_delete($df)
 {
     echo "<b>" . basename($df) . "</b><ul>";
     if ($dir = opendir($df)) {
         $i = 0;
         while (($file = readdir($dir)) !== false) {
             if ($file == "." || $file == "..") {
                 continue;
             }
             if (is_dir("{$df}/{$file}")) {
                 dir_delete($df . "/" . $file);
             } else {
                 echo "{$file}<br>";
                 echo "" . mm("DELETE") . " <tt>{$df}/{$file}</tt> ...<br>";
                 unlink($df . "/" . $file);
             }
             $i++;
         }
         //if ($i==0) echo "-empty-<br>";
     }
     closedir($dir);
     echo "</ul>";
     echo "" . mm("DELETE") . " " . mm("DIR") . " <tt>{$df}</tt> ...<br>";
     rmdir("{$df}/{$file}");
 }
 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();
 }
예제 #10
0
            }
        }
        exit('');
        break;
    case 'run':
        $code = stripslashes($code);
        $base = DT_PATH . 'file/temp/' . dirname($temp) . '/';
        $code = str_replace('src="', 'src="' . $base, $code);
        echo '<html>';
        echo '<meta http-equiv="Content-Type" content="text/html;charset=' . DT_CHARSET . '"/>';
        echo '<body>';
        echo $code;
        echo '</body>';
        echo '</html>';
        break;
    default:
        if ($submit) {
            if (!isset($water)) {
                $DT['water_type'] = 0;
            }
            $content = stripslashes($content);
            $dir = dirname($word);
            $base = DT_PATH . 'file/temp/' . $dir . '/';
            $content = str_replace('src="', 'src="' . $base, $content);
            $content = save_remote($content, 'jpg|gif|png', 1);
            $tmp = explode('/', $dir);
            dir_delete(DT_ROOT . '/file/temp/' . $tmp[0]);
        }
        include tpl('word');
        break;
}
예제 #11
0
function cache_clear($str, $type = '', $dir = '')
{
    $dir = $dir ? DT_CACHE . '/' . $dir . '/' : DT_CACHE . '/';
    $files = glob($dir . '*');
    if (is_array($files)) {
        if ($type == 'dir') {
            foreach ($files as $file) {
                if (is_dir($file)) {
                    dir_delete($file);
                } else {
                    if (file_ext($file) == $str) {
                        file_del($file);
                    }
                }
            }
        } else {
            foreach ($files as $file) {
                if (!is_dir($file) && strpos(basename($file), $str) !== false) {
                    file_del($file);
                }
            }
        }
    }
}
예제 #12
0
	/**
	 * 应用删除程序
	 */
	public function delete() {
		if(isset($_POST['dosubmit'])) {
			$pluginid = intval($_POST['pluginid']);
			$plugin_data =  $this->db->get_one(array('pluginid'=>$pluginid));
			$op_status = FALSE;	
			$dir = $plugin_data['dir'];
			$config_file = PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.'plugin_'.$dir.'.cfg.php';	
			if(file_exists($config_file)) {
				$plugin_data = @require($config_file);
			}		
			$filename = PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.$plugin_data['plugin']['uninstallfile'];
			if(file_exists($filename)) {
				@include_once $filename;
			} else {
				showmessage(L('plugin_lacks_uninstall_file','','plugin'),HTTP_REFERER);
			}
			if($op_status) {
				$this->db->delete(array('pluginid'=>$pluginid));
				$this->db_var->delete(array('pluginid'=>$pluginid));
				delcache($dir,'plugins');
				delcache($dir.'_var','plugins');
				$this->set_hook_cache();
				if($plugin_data['plugin']['iframe']) {
					pc_base::load_sys_func('dir');
					if(!dir_delete(PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$dir)) {
						showmessage(L('plugin_uninstall_success_no_delete','','plugin'),'?m=zl_admin&c=plugin');
					}
				}
				showmessage(L('plugin_uninstall_success','','plugin'),'?m=zl_admin&c=plugin');
			} else {
				showmessage(L('plugin_uninstall_fail','','plugin'),'?m=zl_admin&c=plugin');
			}	
		} else {
			$show_header = 0;
			$pluginid = intval($_GET['pluginid']);
			$plugin_data =  $this->db->get_one(array('pluginid'=>$pluginid));
			include $this->admin_tpl('plugin_delete_confirm');			
		}

	}
예제 #13
0
         $n = basename($f);
         if (file_ext($n) == 'js') {
             if (in_array(substr($n, 0, 1), array('A', '0'))) {
                 continue;
             }
         }
         $t = filemtime($f);
         if ($t >= $ft && $t <= $tt) {
             $lists[] = $f;
         }
     }
     $find = count($lists);
     if ($find) {
         $dir = DT_ROOT . '/file/patch/' . timetodate($ft, 'Y-m-d H.i') . '~' . timetodate($tt, 'Y-m-d H.i') . '/';
         if (is_dir($dir)) {
             dir_delete($dir);
         }
         foreach ($lists as $f) {
             file_copy($f, $dir . str_replace(DT_ROOT . '/', '', $f));
             @touch($dir . str_replace(DT_ROOT . '/', '', $f), filemtime($f));
         }
         msg('备份成功 ' . $find . ' 个文件,已保存于file/patch目录', '?file=' . $file, 5);
     }
     msg('没有符合条件的文件');
 } else {
     $files = glob(DT_ROOT . '/*');
     $dirs = $rfiles = $baks = $ups = array();
     foreach ($files as $f) {
         $bn = basename($f);
         if (is_file($f)) {
             $rfiles[] = $bn;
예제 #14
0
 /**
  * 清除临时目录
  */
 public function clearTempDir()
 {
     dir_delete($this->TEMP);
 }
예제 #15
0
파일: dir.php 프로젝트: im286er/madphp
function dir_delete($dir, $log_path = null)
{
    if (!is_dir($dir)) {
        return FALSE;
    }
    if (!empty($log_path)) {
        error_log($dir . "\n", 3, $log_path . 'dir_delete.log');
    }
    $files = array_diff(scandir($dir), array('.', '..'));
    foreach ($files as $file) {
        is_dir("{$dir}/{$file}") ? dir_delete("{$dir}/{$file}", $log_path) : unlink("{$dir}/{$file}");
    }
    return rmdir($dir);
}
예제 #16
0
 protected function update_config($new_config, $config_file = '')
 {
     !is_file($config_file) && ($config_file = './App/Home/Conf/url.php');
     if (is_writable($config_file)) {
         $config = (require $config_file);
         $config = array_merge($config, $new_config);
         file_put_contents($config_file, "<?php \nreturn " . stripslashes(var_export($config, true)) . ";", LOCK_EX);
         dir_delete(RUNTIME_PATH);
         return true;
     } else {
         return false;
     }
 }
예제 #17
0
function dir_delete($dir)
{
    $dir = dir_path($dir);
    if (!is_dir($dir)) {
        return false;
    }
    $dirs = array(DT_ROOT . '/admin/', DT_ROOT . '/api/', DT_CACHE . '/', DT_ROOT . '/file/', DT_ROOT . '/include/', DT_ROOT . '/lang/', DT_ROOT . '/member/', DT_ROOT . '/module/', DT_ROOT . '/skin/', DT_ROOT . '/template/', DT_ROOT . '/mobile/');
    if (substr($dir, 0, 1) == '.' || in_array($dir, $dirs)) {
        die("Cannot Remove System DIR {$dir} ");
    }
    $list = glob($dir . '*');
    if ($list) {
        foreach ($list as $v) {
            is_dir($v) ? dir_delete($v) : @unlink($v);
        }
    }
    return @rmdir($dir);
}
예제 #18
0
                     $cf++;
                     $i++;
                     if ($i > 500) {
                         msg('已删除 ' . $cd . ' 个目录,' . $cf . ' 个文件' . progress(0, $cd, $tt), '?action=' . $action . '&dir=' . $dir . '&cd=' . $cd . '&cf=' . $cf . '&job=' . $job . '&tt=' . $tt, 0);
                     }
                 }
                 dir_delete($sub);
                 $cd++;
                 msg('已删除 ' . $cd . ' 个目录,' . $cf . ' 个文件' . progress(0, $cd, $tt), '?action=' . $action . '&dir=' . $dir . '&cd=' . $cd . '&cf=' . $cf . '&job=' . $job . '&tt=' . $tt, 0);
             } else {
                 dir_delete($sub);
                 $cd++;
                 msg('已删除 ' . $cd . ' 个目录,' . $cf . ' 个文件' . progress(0, $cd, $tt), '?action=' . $action . '&dir=' . $dir . '&cd=' . $cd . '&cf=' . $cf . '&job=' . $job . '&tt=' . $tt, 0);
             }
         } else {
             dir_delete(DT_CACHE . '/' . $dir);
             msg('缓存更新成功');
         }
     } else {
         msg('目录名错误');
     }
 } else {
     $dir = $job . timetodate($DT_TIME, 'YmdHis');
     if (rename(DT_CACHE . '/' . $job, DT_CACHE . '/' . $dir)) {
         dir_create(DT_CACHE . '/' . $job);
         file_del(DT_CACHE . '/' . $dir . '/index.html');
         $dirs = glob(DT_CACHE . '/' . $dir . '/*');
         $tt = count($dirs);
         msg('正在更新,此操作可能用时较长,请不要中断..', '?action=' . $action . '&dir=' . $dir . '&job=' . $job . '&tt=' . $tt);
     } else {
         msg('更新失败');
예제 #19
0
         }
         @(include DT_ROOT . '/module/' . $module . '/admin/uninstall.inc.php');
         $result = $db->query("SHOW TABLES FROM `" . $CFG['db_name'] . "`");
         while ($r = $db->fetch_row($result)) {
             $tb = $r[0];
             $pt = str_replace($DT_PRE . $moduleid . '_', '', $tb);
             if (is_numeric($pt)) {
                 $db->query("DROP TABLE IF EXISTS `" . $tb . "`");
             }
         }
         $db->query("DELETE FROM `" . $DT_PRE . "category` WHERE moduleid={$moduleid}");
         $db->query("DELETE FROM `" . $DT_PRE . "keylink` WHERE item={$moduleid}");
         $db->query("DELETE FROM `" . $DT_PRE . "setting` WHERE item={$moduleid}");
         $tb = str_replace($DT_PRE, '', get_table($moduleid));
         $db->query("DELETE FROM `" . $DT_PRE . "fields` WHERE tb='{$tb}'");
         dir_delete(DT_ROOT . '/' . $dir);
     }
     $db->query("DELETE FROM {$DT_PRE}module WHERE moduleid='{$modid}'");
     cache_module();
     dmsg('模块删除成功', $this_forward);
     break;
 case 'remkdir':
     if (!$modid) {
         msg('模块ID不能为空');
     }
     $r = $db->get_one("SELECT * FROM {$DT_PRE}module WHERE moduleid='{$modid}'");
     $remkdir = DT_ROOT . '/module/' . $r['module'] . '/admin/remkdir.inc.php';
     if (is_file($remkdir)) {
         $moduleid = $r['moduleid'];
         $module = $r['module'];
         $dir = $r['moduledir'];
예제 #20
0
/**
 * ディレクトリごと移動(コピーして削除)する
 */
function dir_move($dir_name, $new_dir, $permission = 0755)
{
    if (TRUE === dir_copy($dir_name, $new_dir, $permission)) {
        // コピーに成功してから削除する
        // XXX 冗長だが敢えて
        return dir_delete($dir_name);
        return TRUE;
    }
    return FALSE;
}
예제 #21
0
	/**
	 *  上传头像处理
	 *  传入头像压缩包,解压到指定文件夹后删除非图片文件
	 */
	public function uploadavatar() {
		
		//根据用户id创建文件夹
		if(isset($this->data['uid']) && isset($this->data['avatardata'])) {
			$this->uid = intval($this->data['uid']);
			$this->avatardata = $this->data['avatardata'];
		} else {
			exit('0');
		}
		
		$dir1 = ceil($this->uid / 10000);
		$dir2 = ceil($this->uid % 10000 / 1000);
		
		//创建图片存储文件夹
		$avatarfile = pc_base::load_config('system', 'upload_path').'avatar/';
		$dir = $avatarfile.$dir1.'/'.$dir2.'/'.$this->uid.'/';
		if(!file_exists($dir)) {
			mkdir($dir, 0777, true);
		}
		//存储flashpost图片
		$filename = $dir.'180x180.jpg';

		$fp = fopen($filename, 'w');
		fwrite($fp, $this->avatardata);
		fclose($fp);

		$avatararr = array('180x180.jpg', '30x30.jpg', '45x45.jpg', '90x90.jpg');
		$files = glob($dir."*");
		foreach($files as $_files) {
			if(is_dir($_files)) dir_delete($_files);
			if(!in_array(basename($_files), $avatararr)) @unlink($_files);
		}
		if($handle = opendir($dir)) {
		    while(false !== ($file = readdir($handle))) {
				if($file !== '.' && $file !== '..') {
					if(!in_array($file, $avatararr)) {
						@unlink($dir.$file);
					} else {
						$info = @getimagesize($dir.$file);
						if(!$info || $info[2] !=2) {
							@unlink($dir.$file);
						}
					}
				}
		    }
		    closedir($handle);    
		}

		pc_base::load_sys_class('image','','0');
		$image = new image(1,0);
		$image->thumb($filename, $dir.'30x30.jpg', 30, 30);
		$image->thumb($filename, $dir.'45x45.jpg', 45, 45);
		$image->thumb($filename, $dir.'90x90.jpg', 90, 90);
		
		$this->db->update(array('avatar'=>1), array('uid'=>$this->uid));
		exit('1');
	}
예제 #22
0
파일: dir.php 프로젝트: 290329416/guahao
/**
 * 删除目录及目录下面的所有文件
 *
 * @param	string	$dir		路径
 * @return	bool	如果成功则返回 TRUE,失败则返回 FALSE
 */
function dir_delete($dir)
{
    $dir = dir_path($dir);
    if (!is_dir($dir)) {
        return FALSE;
    }
    $list = glob($dir . '*');
    foreach ($list as $v) {
        is_dir($v) ? dir_delete($v) : @unlink($v);
    }
    return @rmdir($dir);
}
예제 #23
0
파일: ajax.php 프로젝트: AlexanderS/Part-DB
function dir_delete($path)
{
    if (!is_string($path) || $path == "") {
        return false;
    }
    if (is_dir($path) && !is_link($path)) {
        if (!($dh = @opendir($path))) {
            return false;
        }
        while ($f = readdir($dh)) {
            if ($f == '..' || $f == '.') {
                continue;
            }
            dir_delete("{$path}/{$f}");
        }
        closedir($dh);
        return @rmdir($path);
    } else {
        return @unlink($path);
    }
    return false;
}
예제 #24
0
function dir_delete($dir)
{
    if (!is_dir($dir)) {
        return FALSE;
    }
    $handle = opendir($dir);
    while (($file = readdir($handle)) !== false) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        $d = $dir . DIRECTORY_SEPARATOR . $file;
        is_dir($d) ? dir_delete($d) : @unlink($d);
    }
    closedir($handle);
    return @rmdir($dir);
}
예제 #25
0
파일: function.php 프로젝트: Eidn/shanghai
function dir_delete($dir)
{
    //ɾ������Ŀ¼,�谤��ɾ��Ŀ¼�µ�Ŀ¼���ļ�
    $dir = dir_path($dir);
    if (!is_dir($dir)) {
        return false;
    }
    $list = glob($dir . '*');
    //Ѱ����*ģʽƥ��������ļ�·��
    if ($list) {
        foreach ($list as $v) {
            is_dir($v) ? dir_delete($v) : @unlink($v);
            //ɾ�����ļ�
        }
    }
    return @rmdir($dir);
}
예제 #26
0
/**
 * Handle file uploads via XMLHttpRequest
 *
 * @return mixed false on error, id of the new file on success
 */
function media_upload_xhr($ns, $auth)
{
    if (!checkSecurityToken()) {
        return false;
    }
    global $INPUT;
    $id = $INPUT->get->str('qqfile');
    list($ext, $mime, $dl) = mimetype($id);
    $input = fopen("php://input", "r");
    if (!($tmp = io_mktmpdir())) {
        return false;
    }
    $path = $tmp . '/' . md5($id);
    $target = fopen($path, "w");
    $realSize = stream_copy_to_stream($input, $target);
    fclose($target);
    fclose($input);
    if (isset($_SERVER["CONTENT_LENGTH"]) && $realSize != (int) $_SERVER["CONTENT_LENGTH"]) {
        unlink($path);
        return false;
    }
    $res = media_save(array('name' => $path, 'mime' => $mime, 'ext' => $ext), $ns . ':' . $id, $INPUT->get->str('ow') == 'checked' ? true : false, $auth, 'copy');
    unlink($path);
    if ($tmp) {
        dir_delete($tmp);
    }
    if (is_array($res)) {
        msg($res[0], $res[1]);
        return false;
    }
    return $res;
}
예제 #27
0
 /**
  * 更新删除缓存文件方法
  */
 public function del_file()
 {
     $path = PHPCMS_PATH . 'caches' . DIRECTORY_SEPARATOR . 'caches_template' . DIRECTORY_SEPARATOR;
     $files = glob($path . '*');
     pc_base::load_sys_func('dir');
     if (is_array($files)) {
         foreach ($files as $f) {
             $dir = basename($f);
             if (!in_array($dir, array('block', 'dbsource'))) {
                 dir_delete($path . $dir);
             }
         }
     }
     $path = PHPCMS_PATH . 'caches' . DIRECTORY_SEPARATOR . 'caches_tpl_data' . DIRECTORY_SEPARATOR . 'caches_data' . DIRECTORY_SEPARATOR;
     $files = glob($path . '*');
     if (is_array($files)) {
         foreach ($files as $f) {
             $dir = basename($f);
             @unlink($path . $dir);
         }
     }
     return true;
 }
예제 #28
0
         msg('只能下载SQL文件');
     }
     file_down($dir ? $D . $dir . '/' . $filename : $D . $filename);
     break;
 case 'delete':
     if (!is_array($filenames)) {
         $tmp = $filenames;
         $filenames = array();
         $filenames[0] = $tmp;
     }
     foreach ($filenames as $filename) {
         if (file_ext($filename) == 'sql') {
             file_del($dir ? $D . $dir . '/' . $filename : $D . $filename);
         } else {
             if (is_dir($D . $filename)) {
                 dir_delete($D . $filename);
             }
         }
     }
     dmsg('删除成功', $forward);
     break;
 case 'move':
     if ($submit) {
         $condition = str_replace('and', 'AND', trim($condition));
         $condition = strpos($condition, 'AND') === false ? "itemid IN ({$condition})" : substr($condition, 3);
         $condition = stripslashes($condition);
         if ($type == 1) {
             $ftb = $DT_PRE . 'sell_5';
             $ftb_data = $DT_PRE . 'sell_data_5';
             $fmid = 5;
             $ttb = $DT_PRE . 'buy_6';
예제 #29
0
 /**
  * 模块卸载
  * @param string $module 模块名
  */
 public function uninstall($module)
 {
     define('UNINSTALL', true);
     if (!$module) {
         $this->error_msg = L('illegal_parameters');
         return false;
     }
     $this->module = $module;
     $this->uninstalldir = PC_PATH . 'modules' . DIRECTORY_SEPARATOR . $this->module . DIRECTORY_SEPARATOR . 'uninstall' . DIRECTORY_SEPARATOR;
     if (!is_dir($this->uninstalldir)) {
         $this->error_msg = L('uninstall_dir_no_exist');
         return false;
     }
     if (file_exists($this->uninstalldir . 'model.php')) {
         $models = @(require $this->uninstalldir . 'model.php');
         if (is_array($models) && !empty($models)) {
             foreach ($models as $m) {
                 if (!file_exists($this->uninstalldir . $m . '.sql')) {
                     $this->error_msg = $this->module . DIRECTORY_SEPARATOR . 'uninstall' . DIRECTORY_SEPARATOR . $m . L('sql_no_exist');
                     return false;
                 }
             }
         }
     }
     if (file_exists($this->uninstalldir . 'extention.inc.php')) {
         @(include $this->uninstalldir . 'extention.inc.php');
     }
     if (is_array($models) && !empty($models)) {
         foreach ($models as $m) {
             $this->m_db = pc_base::load_model($m . '_model');
             $sql = file_get_contents($this->uninstalldir . $m . '.sql');
             $this->sql_execute($sql);
         }
     }
     if (file_exists(PC_PATH . 'languages' . DIRECTORY_SEPARATOR . pc_base::load_config('system', 'lang') . DIRECTORY_SEPARATOR . $this->module . '.lang.php')) {
         @unlink(PC_PATH . 'languages' . DIRECTORY_SEPARATOR . pc_base::load_config('system', 'lang') . DIRECTORY_SEPARATOR . $this->module . '.lang.php');
     }
     if (is_dir(PC_PATH . 'templates' . DIRECTORY_SEPARATOR . pc_base::load_config('system', 'tpl_name') . DIRECTORY_SEPARATOR . $this->module)) {
         @dir_delete(PC_PATH . 'templates' . DIRECTORY_SEPARATOR . pc_base::load_config('system', 'tpl_name') . DIRECTORY_SEPARATOR . $this->module);
     }
     $templatepath = PC_PATH . 'templates' . DIRECTORY_SEPARATOR . pc_base::load_config('system', 'tpl_name') . DIRECTORY_SEPARATOR;
     if (file_exists($templatepath . 'config.php')) {
         $keyid = 'templates|' . pc_base::load_config('system', 'tpl_name') . '|' . $this->module;
         $style_info = (include $templatepath . 'config.php');
         unset($style_info['file_explan'][$keyid]);
         @file_put_contents($templatepath . 'config.php', '<?php return ' . var_export($style_info, true) . ';?>');
     }
     $menu_db = pc_base::load_model('menu_model');
     $menu_db->delete(array('m' => $this->module));
     $this->db->delete(array('module' => $this->module));
     return true;
 }
예제 #30
0
 /**
  * 删除专题 执行删除操作的方法,同时删除专题下的分类、信息、及生成静态文件和图片
  * @param intval $id 专题ID
  * @return boolen 
  */
 public function _del_special($id = 0)
 {
     $id = intval($id);
     if (!$id) {
         return false;
     }
     //检查专题下是否有信息
     $rs = $this->c_db->select(array('specialid' => $id), 'id');
     $info = $this->db->get_one(array('id' => $id, 'siteid' => get_siteid()), 'siteid, ispage, filename, ishtml');
     //有信息时,循环删除
     if (is_array($rs) && !empty($rs)) {
         foreach ($rs as $r) {
             $this->_delete_content($r['id'], $info['siteid'], $info['ishtml']);
         }
     }
     //删除专题的附属分类
     $type_info = $this->type_db->select(array('module' => 'special', 'parentid' => $id, 'siteid' => get_siteid()), '`typeid`');
     if (is_array($type_info) && !empty($type_info)) {
         foreach ($type_info as $t) {
             $this->delete_type($t['typeid'], $info['siteid'], $info['ishtml']);
         }
     }
     pc_base::load_sys_func('dir');
     $this->db->delete(array('id' => $id, 'siteid' => get_siteid()));
     $info['filename'] = str_replace('..', '', $info['filename']);
     if ($info['siteid'] > 1) {
         if ($info['ishtml']) {
             $queue = pc_base::load_model('queue_model');
             $site = pc_base::load_app_class('sites', 'admin');
             $site_info = $site->get_by_id($info['siteid']);
             $file = pc_base::load_config('system', 'html_root') . '/' . $site_info['dirname'] . '/special/' . $info['filename'] . '/index.html';
             if ($info['ispage']) {
                 for ($i == 1; $i > 0; $i++) {
                     if ($i > 1) {
                         $file = str_replace('.html', '-' . $i . '.html', $file);
                     }
                     if (!file_exists(PHPCMS_PATH . $file)) {
                         break;
                     } else {
                         $queue->add_queue('del', $file, $info['siteid']);
                         unlink(PHPCMS_PATH . $file);
                     }
                 }
             } else {
                 $queue->add_queue('del', $file, $info['siteid']);
                 unlink(PHPCMS_PATH . $file);
             }
             $queue->add_queue('del', pc_base::load_config('system', 'html_root') . '/' . $site_info['dirname'] . '/special/' . $info['filename'] . '/', $info['siteid']);
             dir_delete(pc_base::load_config('system', 'html_root') . '/' . $site_info['dirname'] . '/special/' . $info['filename']);
         }
     } else {
         if ($info['ishtml']) {
             dir_delete(PHPCMS_PATH . pc_base::load_config('system', 'html_root') . DIRECTORY_SEPARATOR . 'special' . DIRECTORY_SEPARATOR . $info['filename']);
             //删除专题目录
         }
     }
     if (pc_base::load_config('system', 'attachment_stat')) {
         $keyid = 'special-' . $id;
         $this->attachment_db = pc_base::load_model('attachment_model');
         $this->attachment_db->api_delete($keyid);
     }
     return true;
 }