Ejemplo n.º 1
0
 /**
  * 清除页面缓存
  */
 public function clear()
 {
     $list = array('WAP首页' => 'Wap:index');
     foreach ($list as $key => $val) {
         delcache($val);
     }
     $this->success('缓存删除完毕');
 }
Ejemplo n.º 2
0
 /**
  * 生成内容页
  */
 public function show()
 {
     if (isset($_POST['dosubmit'])) {
         extract($_POST, EXTR_SKIP);
         $this->html = pc_base::load_app_class('html');
         $modelid = intval($_POST['modelid']);
         if ($modelid) {
             //设置模型数据表名
             $this->db->set_model($modelid);
             $table_name = $this->db->table_name;
             if ($type == 'lastinput') {
                 $offset = 0;
             } else {
                 $page = max(intval($page), 1);
                 $offset = $pagesize * ($page - 1);
             }
             $where = ' WHERE status=99 ';
             $order = 'ASC';
             if (!isset($first) && is_array($catids) && $catids[0] > 0) {
                 setcache('html_show_' . $_SESSION['userid'], $catids, 'content');
                 $catids = implode(',', $catids);
                 $where .= " AND catid IN({$catids}) ";
                 $first = 1;
             } elseif (count($catids) == 1 && $catids[0] == 0) {
                 $catids = array();
                 foreach ($this->categorys as $catid => $cat) {
                     if ($cat['child'] || $cat['siteid'] != $this->siteid || $cat['type'] != 0) {
                         continue;
                     }
                     $setting = string2array($cat['setting']);
                     if (!$setting['content_ishtml']) {
                         continue;
                     }
                     $catids[] = $catid;
                 }
                 setcache('html_show_' . $_SESSION['userid'], $catids, 'content');
                 $catids = implode(',', $catids);
                 $where .= " AND catid IN({$catids}) ";
                 $first = 1;
             } elseif ($first) {
                 $catids = getcache('html_show_' . $_SESSION['userid'], 'content');
                 $catids = implode(',', $catids);
                 $where .= " AND catid IN({$catids}) ";
             } else {
                 $first = 0;
             }
             if (count($catids) == 1 && $catids[0] == 0) {
                 $message = L('create_update_success');
                 $forward = '?m=content&c=create_html&a=show';
                 showmessage($message, $forward);
             }
             if ($type == 'lastinput' && $number) {
                 $offset = 0;
                 $pagesize = $number;
                 $order = 'DESC';
             } elseif ($type == 'date') {
                 if ($fromdate) {
                     $fromtime = strtotime($fromdate . ' 00:00:00');
                     $where .= " AND `inputtime`>={$fromtime} ";
                 }
                 if ($todate) {
                     $totime = strtotime($todate . ' 23:59:59');
                     $where .= " AND `inputtime`<={$totime} ";
                 }
             } elseif ($type == 'id') {
                 $fromid = intval($fromid);
                 $toid = intval($toid);
                 if ($fromid) {
                     $where .= " AND `id`>={$fromid} ";
                 }
                 if ($toid) {
                     $where .= " AND `id`<={$toid} ";
                 }
             }
             if (!isset($total) && $type != 'lastinput') {
                 $rs = $this->db->query("SELECT COUNT(*) AS `count` FROM `{$table_name}` {$where}");
                 $result = $this->db->fetch_array($rs);
                 $total = $result[0]['count'];
                 $pages = ceil($total / $pagesize);
                 $start = 1;
             }
             $rs = $this->db->query("SELECT * FROM `{$table_name}` {$where} ORDER BY `id` {$order} LIMIT {$offset},{$pagesize}");
             $data = $this->db->fetch_array($rs);
             $tablename = $this->db->table_name . '_data';
             $this->url = pc_base::load_app_class('url');
             foreach ($data as $r) {
                 if ($r['islink']) {
                     continue;
                 }
                 $this->db->table_name = $tablename;
                 $r2 = $this->db->get_one(array('id' => $r['id']));
                 if ($r) {
                     $r = array_merge($r, $r2);
                 }
                 if ($r['upgrade']) {
                     $urls[1] = $r['url'];
                 } else {
                     $urls = $this->url->show($r['id'], '', $r['catid'], $r['inputtime']);
                 }
                 $this->html->show($urls[1], $r, 0, 'edit', $r['upgrade']);
             }
             if ($pages > $page) {
                 $page++;
                 $http_url = get_url();
                 $creatednum = $offset + count($data);
                 $percent = round($creatednum / $total, 2) * 100;
                 $message = L('need_update_items', array('total' => $total, 'creatednum' => $creatednum, 'percent' => $percent));
                 $forward = $start ? "?m=content&c=create_html&a=show&type={$type}&dosubmit=1&first={$first}&fromid={$fromid}&toid={$toid}&fromdate={$fromdate}&todate={$todate}&pagesize={$pagesize}&page={$page}&pages={$pages}&total={$total}&modelid={$modelid}" : preg_replace("/&page=([0-9]+)&pages=([0-9]+)&total=([0-9]+)/", "&page={$page}&pages={$pages}&total={$total}", $http_url);
             } else {
                 delcache('html_show_' . $_SESSION['userid'], 'content');
                 $message = L('create_update_success');
                 $forward = '?m=content&c=create_html&a=show';
             }
             showmessage($message, $forward, 200);
         } else {
             //当没有选择模型时,需要按照栏目来更新
             if (!isset($set_catid)) {
                 if ($catids[0] != 0) {
                     $update_url_catids = $catids;
                 } else {
                     foreach ($this->categorys as $catid => $cat) {
                         if ($cat['child'] || $cat['siteid'] != $this->siteid || $cat['type'] != 0) {
                             continue;
                         }
                         $setting = string2array($cat['setting']);
                         if (!$setting['content_ishtml']) {
                             continue;
                         }
                         $update_url_catids[] = $catid;
                     }
                 }
                 setcache('update_html_catid' . '-' . $this->siteid . '-' . $_SESSION['userid'], $update_url_catids, 'content');
                 $message = L('start_update');
                 $forward = "?m=content&c=create_html&a=show&set_catid=1&pagesize={$pagesize}&dosubmit=1";
                 showmessage($message, $forward, 200);
             }
             if (count($catids) == 1 && $catids[0] == 0) {
                 $message = L('create_update_success');
                 $forward = '?m=content&c=create_html&a=show';
                 showmessage($message, $forward, 200);
             }
             $catid_arr = getcache('update_html_catid' . '-' . $this->siteid . '-' . $_SESSION['userid'], 'content');
             $autoid = $autoid ? intval($autoid) : 0;
             if (!isset($catid_arr[$autoid])) {
                 showmessage(L('create_update_success'), '?m=content&c=create_html&a=show', 200);
             }
             $catid = $catid_arr[$autoid];
             $modelid = $this->categorys[$catid]['modelid'];
             //设置模型数据表名
             $this->db->set_model($modelid);
             $table_name = $this->db->table_name;
             $page = max(intval($page), 1);
             $offset = $pagesize * ($page - 1);
             $where = " WHERE status=99 AND catid='{$catid}'";
             $order = 'ASC';
             if (!isset($total)) {
                 $rs = $this->db->query("SELECT COUNT(*) AS `count` FROM `{$table_name}` {$where}");
                 $result = $this->db->fetch_array($rs);
                 $total = $result[0]['count'];
                 $pages = ceil($total / $pagesize);
                 $start = 1;
             }
             $rs = $this->db->query("SELECT * FROM `{$table_name}` {$where} ORDER BY `id` {$order} LIMIT {$offset},{$pagesize}");
             $data = $this->db->fetch_array($rs);
             $tablename = $this->db->table_name . '_data';
             $this->url = pc_base::load_app_class('url');
             foreach ($data as $r) {
                 if ($r['islink']) {
                     continue;
                 }
                 //写入文件
                 $this->db->table_name = $tablename;
                 $r2 = $this->db->get_one(array('id' => $r['id']));
                 if ($r2) {
                     $r = array_merge($r, $r2);
                 }
                 if ($r['upgrade']) {
                     $urls[1] = $r['url'];
                 } else {
                     $urls = $this->url->show($r['id'], '', $r['catid'], $r['inputtime']);
                 }
                 $this->html->show($urls[1], $r, 0, 'edit', $r['upgrade']);
             }
             if ($pages > $page) {
                 $page++;
                 $http_url = get_url();
                 $creatednum = $offset + count($data);
                 $percent = round($creatednum / $total, 2) * 100;
                 $message = '【' . $this->categorys[$catid]['catname'] . '】 ' . L('have_update_items', array('total' => $total, 'creatednum' => $creatednum, 'percent' => $percent));
                 $forward = $start ? "?m=content&c=create_html&a=show&type={$type}&dosubmit=1&first={$first}&fromid={$fromid}&toid={$toid}&fromdate={$fromdate}&todate={$todate}&pagesize={$pagesize}&page={$page}&pages={$pages}&total={$total}&autoid={$autoid}&set_catid=1" : preg_replace("/&page=([0-9]+)&pages=([0-9]+)&total=([0-9]+)/", "&page={$page}&pages={$pages}&total={$total}", $http_url);
             } else {
                 $autoid++;
                 $message = L('start_update') . $this->categorys[$catid]['catname'] . " ...";
                 $forward = "?m=content&c=create_html&a=show&set_catid=1&pagesize={$pagesize}&dosubmit=1&autoid={$autoid}";
             }
             showmessage($message, $forward, 200);
         }
     } else {
         $show_header = $show_dialog = '';
         $admin_username = param::get_cookie('admin_username');
         $modelid = isset($_GET['modelid']) ? intval($_GET['modelid']) : 0;
         $tree = pc_base::load_sys_class('tree');
         $tree->icon = array('&nbsp;&nbsp;&nbsp;│ ', '&nbsp;&nbsp;&nbsp;├─ ', '&nbsp;&nbsp;&nbsp;└─ ');
         $tree->nbsp = '&nbsp;&nbsp;&nbsp;';
         $categorys = array();
         if (!empty($this->categorys)) {
             foreach ($this->categorys as $catid => $r) {
                 if ($this->siteid != $r['siteid'] || $r['type'] != 0 && $r['child'] == 0) {
                     continue;
                 }
                 if ($modelid && $modelid != $r['modelid']) {
                     continue;
                 }
                 if ($r['child'] == 0) {
                     $setting = string2array($r['setting']);
                     if (!$setting['content_ishtml']) {
                         continue;
                     }
                 }
                 $r['disabled'] = $r['child'] ? 'disabled' : '';
                 $categorys[$catid] = $r;
             }
         }
         $str = "<option value='\$catid' \$selected \$disabled>\$spacer \$catname</option>";
         $tree->init($categorys);
         $string .= $tree->get_tree(0, $str);
         include $this->admin_tpl('create_html_show');
     }
 }
Ejemplo n.º 3
0
 /**
  * 数据库导出方法
  * @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);
     }
 }
Ejemplo n.º 4
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');			
		}

	}
Ejemplo n.º 5
0
Archivo: special.php Proyecto: cfhb/MIS
 public function public_create_type()
 {
     $specialid = $_GET['specialid'] ? intval($_GET['specialid']) : 0;
     if (!$specialid) {
         showmessage(L('illegal_action'));
     }
     $page = isset($_GET['page']) ? intval($_GET['page']) : 1;
     $pages = isset($_GET['pages']) ? intval($_GET['pages']) : 0;
     $types = getcache('create_types', 'commons');
     if (is_array($types) && !empty($types) || $pages) {
         if (!isset($page) || $page == 1) {
             $typeids = array_keys($types);
             $typeid = array_shift($typeids);
             $typename = $types[$typeid];
             unset($types[$typeid]);
             setcache('create_types', $types, 'commons');
         }
         if (!$pages) {
             $c = pc_base::load_model('special_content_model');
             $result = $c->get_one(array('typeid' => $typeid), 'COUNT(*) AS total');
             $total = $result['total'];
             $pages = ceil($total / 20);
         }
         if ($_GET['typeid']) {
             $typeid = intval($_GET['typeid']);
             $typename = $_GET['typename'];
         }
         $maxpage = $page + 10;
         if ($maxpage > $pages) {
             $maxpage = $pages;
         }
         for ($page; $page <= $maxpage; $page++) {
             $html = pc_base::load_app_class('html');
             $html->create_type($typeid, $page);
         }
         if (empty($types) && $pages == $maxpage) {
             delcache('create_types', 'commons');
             showmessage($typename . L('type_update_success'), '?m=special&c=special&a=public_create_content&specialid=' . $specialid);
         }
         if ($pages <= $maxpage) {
             showmessage($typename . L('update_success'), '?m=special&c=special&a=public_create_type&specialid=' . $specialid);
         } else {
             showmessage($typename . L('type_from') . ($_GET['page'] ? $_GET['page'] : 1) . L('type_end') . $maxpage . '</font> ' . L('update_success'), '?m=special&c=special&a=public_create_type&typeid=' . $typeid . '&typename=' . $typename . '&page=' . $page . '&pages=' . $pages . '&specialid=' . $specialid);
         }
     } else {
         $special_api = pc_base::load_app_class('special_api');
         $types = $special_api->_get_types($specialid);
         setcache('create_types', $types, 'commons');
         showmessage(L('start_update_type'), '?m=special&c=special&a=public_create_type&specialid=' . $specialid);
     }
 }
Ejemplo n.º 6
0
 /**
  * 删除联动菜单缓存文件
  * @param init $linkageid
  */
 private function _dlecache($linkageid)
 {
     return delcache($linkageid, 'linkage');
 }
Ejemplo n.º 7
0
 /**
  * 数据库导出方法
  * @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 备份数据库类型 (非wmmall数据与wmmall数据)
  */
 private function export_database($tables, $sqlcompat, $sqlcharset, $sizelimit, $action, $fileid, $random, $tableid, $startfrom, $tabletype)
 {
     $res_url = $this->admin_url . 'system/dbsave/export?loghash=' . $this->session->userdata('loghash');
     $dbprefix = $this->db->dbprefix;
     $dumpcharset = $sqlcharset ? $sqlcharset : str_replace('-', '', 'utf8');
     $fileid = $fileid != '' ? $fileid : 1;
     if ($fileid == 1 && $tables) {
         if (!isset($tables) || !is_array($tables)) {
             $this->showmessage('error', '请选择数据表', $res_url);
         }
         $random = mt_rand(1000, 9999);
         setcache('bakup_tables', $tables, 'commons');
     } else {
         if (!($tables = getcache('bakup_tables', 'commons'))) {
             $this->showmessage('error', '请选择数据表', $res_url);
         }
     }
     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] != $dbprefix . 'session') {
                 $tabledump .= "DROP TABLE IF EXISTS `{$tables[$i]}`;\n";
             }
             $createtable = $this->db->query("SHOW CREATE TABLE `{$tables[$i]}` ");
             $res = $this->db->query("SHOW CREATE TABLE {$tables[$i]}")->result_array();
             $tabledump .= $res[0]['Create Table'] . ";\n\n";
             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] == $dbprefix . 'session') {
                 $tabledump = str_replace("CREATE TABLE `" . $dbprefix . "session`", "CREATE TABLE IF NOT EXISTS `" . $dbprefix . "session`", $tabledump);
             }
         }
         $numrows = $offset;
         while (strlen($tabledump) < $sizelimit * 1000 && $numrows == $offset) {
             if ($tables[$i] == $dbprefix . 'session' || $tables[$i] == $dbprefix . 'member_cache') {
                 break;
             }
             $sql = "SELECT * FROM `{$tables[$i]}` LIMIT {$startfrom}, {$offset}";
             $numfields = $this->db->query($sql)->num_fields();
             //字段个数
             $numrows = $this->db->query($sql)->num_rows();
             //数据条数
             $fields_name = $this->db->list_fields($tables[$i]);
             //字段名称
             $rows_list = $this->db->query($sql)->result_array();
             foreach ($rows_list as $v) {
                 $comma = "";
                 $tabledump .= "INSERT INTO `{$tables[$i]}` VALUES(";
                 for ($j = 0; $j < $numfields; $j++) {
                     $tabledump .= $comma . "'" . mysql_escape_string($v[$fields_name[$j]]) . "'";
                     $comma = ",";
                 }
                 $tabledump .= ");\n";
             }
             $startfrom += $offset;
         }
         $tabledump .= "\n";
         $startrow = $startfrom;
         $startfrom = 0;
     }
     $cache_path = FCPATH . 'caches' . DIRECTORY_SEPARATOR;
     $pdo_name = $this->db->database;
     if (trim($tabledump)) {
         $tabledump = "# wmmall bakfile\n# version:MVMALL V1\n# time:" . date('Y-m-d H:i:s') . "\n# type:wmmall\n# \n# --------------------------------------------------------\n\n\n" . $tabledump;
         $tableid = $i;
         $filename = $tabletype . '_' . date('Ymd') . '_' . $random . '_' . $fileid . '.sql';
         $altid = $fileid;
         $fileid++;
         $bakfile_path = $cache_path . 'bakup' . DIRECTORY_SEPARATOR . $pdo_name;
         $this->load->library('ifile_lib');
         if (!$this->ifile_lib->is_dir_exists($bakfile_path)) {
             $this->ifile_lib->mkdir($bakfile_path);
         }
         $bakfile = $bakfile_path . DIRECTORY_SEPARATOR . $filename;
         if (!is_writable($cache_path . 'bakup')) {
             $this->showmessage('error', '目录无法写入文件', $res_url);
         }
         file_put_contents($bakfile, $tabledump);
         @chmod($bakfile, 0777);
         $filename = '分卷:' . $altid . '#写入成功';
         $next_url = $this->admin_url . 'system/dbsave/export?dosubmit=1&sizelimit=' . $sizelimit . '&sqlcompat=' . $sqlcompat . '&sqlcharset=' . $sqlcharset . '&tableid=' . $tableid . '&fileid=' . $fileid . '&startfrom=' . $startrow . '&random=' . $random . '&dosubmit=1&tabletype=' . $tabletype . '&pdo_select=' . $pdo_name . '&loghash=' . $this->session->userdata('loghash');
         $this->showmessage('success', $filename, $next_url);
     } else {
         $bakfile_path = $cache_path . 'bakup' . DIRECTORY_SEPARATOR . $pdo_name . DIRECTORY_SEPARATOR;
         file_put_contents($bakfile_path . 'index.html', '');
         delcache('bakup_tables', 'commons');
         $this->showmessage('success', '数据备份完成!', $this->admin_url . 'maintenance/dbsave/import?loghash=' . $this->session->userdata('loghash'));
     }
 }
Ejemplo n.º 8
0
{
  $handle = opendir($dir);
  while (false!==($FolderOrFile = readdir($handle)))
  {
     if($FolderOrFile != "." && $FolderOrFile != "..")
     { 
       if(is_dir("$dir/$FolderOrFile"))
       { deldir("$dir/$FolderOrFile"); }  // recursive
       else
       { unlink("$dir/$FolderOrFile"); }
     } 
  }
} 

if($delete != "") {
	delcache($cachefolder);
}

$cacheSize = getTotalSize($cachefolder);

?>
<a href="<?php 
echo $HTTP_SERVER['PHP_SELF'];
?>
">[Refresh]</a><br><br>
Total size of cache folder: <B><?php 
echo $cacheSize / 1000000;
?>
 Mb.</B> (<?php 
echo $cacheSize;
?>
Ejemplo n.º 9
0
 function setStatus()
 {
     $addon = I('addonname');
     $token_status = D('Common/AddonStatus')->getList();
     if ($token_status[$addon] === '-1') {
         $this->success('无权限设置');
     }
     $status = 1 - I('status');
     $res = D('Common/AddonStatus')->set($addon, $status);
     delcache();
     $this->success('设置成功');
 }