/** * member list */ function manage() { if (isset($_POST['dosubmit'])) { $member_setting = array2string($_POST['info']); $this->db->update(array('module' => 'member', 'setting' => $member_setting), array('module' => 'member')); setcache('member_setting', $_POST['info']); showmessage(L('operation_success'), HTTP_REFERER); } else { $show_scroll = true; $member_setting = $this->db->get_one(array('module' => 'member'), 'setting'); $member_setting = string2array($member_setting['setting']); $email_config = getcache('common', 'commons'); $this->sms_setting_arr = getcache('sms', 'sms'); $siteid = get_siteid(); if (empty($email_config['mail_user']) || empty($email_config['mail_password'])) { $mail_disabled = 1; } if (!empty($this->sms_setting_arr[$siteid])) { $this->sms_setting = $this->sms_setting_arr[$siteid]; if ($this->sms_setting['sms_enable'] == '0') { $sms_disabled = 1; } else { if (empty($this->sms_setting['userid']) || empty($this->sms_setting['productid']) || empty($this->sms_setting['sms_key'])) { $sms_disabled = 1; } } } else { $sms_disabled = 1; } include $this->admin_tpl('member_setting'); } }
/** * 添加规则 */ public function add() { if (isset($_POST['dosubmit'])) { $ruledata['fromid'] = isset($_POST['fromid']) ? intval($_POST['fromid']) : showmessage(L('illegal_parameters'), HTTP_REFERER); $ruledata['toid'] = isset($_POST['toid']) ? intval($_POST['toid']) : showmessage(L('illegal_parameters'), HTTP_REFERER); $ruledata['fromrate'] = isset($_POST['fromrate']) ? intval($_POST['fromrate']) : showmessage(L('illegal_parameters'), HTTP_REFERER); $ruledata['torate'] = isset($_POST['torate']) ? intval($_POST['torate']) : showmessage(L('illegal_parameters'), HTTP_REFERER); if(empty($_POST['from']) || empty($_POST['to'])) { showmessage(L('illegal_parameters'), HTTP_REFERER); } $fromarr = explode('_', $_POST['from']); $toarr = explode('_', $_POST['to']); $ruledata['from'] = isset($fromarr[0]) ? $fromarr[0] : ''; $ruledata['fromname'] = isset($fromarr[1]) ? $fromarr[1] : ''; $ruledata['fromunit'] = isset($fromarr[2]) ? $fromarr[2] : ''; $ruledata['to'] = isset($toarr[0]) ? $toarr[0] : ''; $ruledata['toname'] = isset($toarr[1]) ? $toarr[1] : ''; $ruledata['tounit'] = isset($toarr[2]) ? $toarr[2] : ''; $creditlistarr = $this->db->get_one(array('name'=>'creditrate')); $creditlist = string2array($creditlistarr['data']); $creditlist[] = $ruledata; $noticedata['creditlist'] = $creditlist; //加入消息队列 messagequeue::add('credit_update', $noticedata); setcache('creditlist', $creditlist); $this->db->insert(array('name'=>'creditrate', 'data'=>array2string($creditlist)), 1, 1); showmessage(L('operation_success'), HTTP_REFERER); } $applist = getcache('applist'); include $this->admin_tpl('credit_add'); }
/** * 更新模型缓存 */ public static function update_cache_model() { $sitemodel_db = pc_base::load_model('sitemodel_model'); $data = $sitemodel_db->select(array('type' => 2), "*", 1000, 'sort', '', 'modelid'); setcache('member_model', $data, 'commons'); if (!defined('MODEL_PATH')) { //模型原型存储路径 define('MODEL_PATH', PC_PATH . 'modules' . DIRECTORY_SEPARATOR . 'member' . DIRECTORY_SEPARATOR . 'fields' . DIRECTORY_SEPARATOR); } if (!defined('CACHE_MODEL_PATH')) { //模型缓存路径 define('CACHE_MODEL_PATH', PHPCMS_PATH . 'caches' . DIRECTORY_SEPARATOR . 'caches_model' . DIRECTORY_SEPARATOR . 'caches_data' . DIRECTORY_SEPARATOR); } require MODEL_PATH . 'fields.inc.php'; //更新内容模型类:表单生成、入库、更新、输出 $classtypes = array('form', 'input', 'update', 'output'); foreach ($classtypes as $classtype) { $cache_data = file_get_contents(MODEL_PATH . 'member_' . $classtype . '.class.php'); $cache_data = str_replace('}?>', '', $cache_data); foreach ($fields as $field => $fieldvalue) { if (file_exists(MODEL_PATH . $field . DIRECTORY_SEPARATOR . $classtype . '.inc.php')) { $cache_data .= file_get_contents(MODEL_PATH . $field . DIRECTORY_SEPARATOR . $classtype . '.inc.php'); } } $cache_data .= "\r\n } \r\n?>"; file_put_contents(CACHE_MODEL_PATH . 'member_' . $classtype . '.class.php', $cache_data); chmod(CACHE_MODEL_PATH . 'member_' . $classtype . '.class.php', 0777); } return true; }
public function get() { $id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : exit(); if ($data = $this->db->get_one(array('id'=>$id))) { if (!$str = tpl_cache('dbsource_'.$id,$data['cache'])) { if ($data['type'] == 1) { //自定义SQL调用 $get_db = pc_base::load_model("get_model"); $sql = $data['data'].(!empty($data['num']) ? " LIMIT $data[num]" : ''); $r= $get_db->query($sql); while(($s = $get_db->fetch_next()) != false) { $str[] = $s; } } else { $filepath = PC_PATH.'modules'.DIRECTORY_SEPARATOR.$data['module'].DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.$data['module'].'_tag.class.php'; if (file_exists($filepath)) { $pc_tag = pc_base::load_app_class($data['module'].'_tag', $data['module']); if (!method_exists($pc_tag, $data['action'])) { exit(); } $sql = string2array($data['data']); $sql['action'] = $data['action']; $sql['limit'] = $data['num']; unset($data['num']); $str = $pc_tag->$data['action']($sql); } else { exit(); } } if ($data['cache']) setcache('dbsource_'.$id, $str, 'tpl_data'); } echo $this->_format($data['id'], $str, $data['dis_type']); } }
/** * 创建索引 */ public function createindex() { if (isset($_GET['dosubmit'])) { //重建索引首先清空表所有数据,然后根据搜索类型接口重新全部重建索引 if (!isset($_GET['have_truncate'])) { $db_tablepre = $this->db->db_tablepre; //删除该站点全文索引 $this->db->delete(array('siteid' => $this->siteid)); $types = $this->type_db->select(array('siteid' => $this->siteid, 'module' => 'search')); setcache('search_types', $types, 'search'); } else { $types = getcache('search_types', 'search'); } //$key typeid 的索引 $key = isset($_GET['key']) ? intval($_GET['key']) : 0; foreach ($types as $_k => $_v) { if ($key == $_k) { $typeid = $_v['typeid']; if ($_v['modelid']) { if ($_v['typedir'] !== 'yp') { $search_api = pc_base::load_app_class('search_api', 'content'); } else { $search_api = pc_base::load_app_class('search_api', $_v['typedir']); } if (!isset($_GET['total'])) { $total = $search_api->total($_v['modelid']); } else { $total = intval($_GET['total']); $search_api->set_model($_v['modelid']); } } else { $module = trim($_v['typedir']); $search_api = pc_base::load_app_class('search_api', $module); if (!isset($_GET['total'])) { $total = $search_api->total(); } else { $total = intval($_GET['total']); } } $pagesize = $_GET['pagesize'] ? intval($_GET['pagesize']) : 50; $page = max(intval($_GET['page']), 1); $pages = ceil($total / $pagesize); $datas = $search_api->fulltext_api($pagesize, $page); foreach ($datas as $id => $r) { $this->db->update_search($typeid, $id, $r['fulltextcontent'], $r['title'], $r['adddate'], 1); } $page++; if ($pages >= $page) { showmessage("正在更新 <span style='color:#ff0000;font-size:14px;text-decoration:underline;' >{$_v['name']}</span> - 总数:{$total} - 当前第 <font color='red'>{$page}</font> 页", "?m=search&c=search_admin&a=createindex&menuid=909&page={$page}&total={$total}&key={$key}&pagesize={$pagesize}&have_truncate=1&dosubmit=1"); } $key++; showmessage("开始更新: <span style='color:#ff0000;font-size:14px;text-decoration:underline;' >{$_v['name']}</span> - 总数:{$total}条", "?m=search&c=search_admin&a=createindex&menuid=909&page=1&key={$key}&pagesize={$pagesize}&have_truncate=1&dosubmit=1"); } } showmessage('全站索引更新完成', 'blank'); } else { $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=search&c=search_type&a=add\', title:\'' . L('add_search_type') . '\', width:\'580\', height:\'240\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('add_search_type')); include $this->admin_tpl('createindex'); } }
/** * 加载模板标签缓存 * @param string $name 缓存名 */ function tpl_setcache($name, $data, $action, $timeout = 0) { $filepath = 'tpl_data/' . $action; if (empty($action)) { $filepath = 'tpl_data/' . $action; } return setcache($name, $data, $filepath, 'file', $timeout, ''); }
/** * 更新URL规则 */ public function public_cache_urlrule() { $datas = $this->db->select('','*','','','','urlruleid'); $basic_data = array(); foreach($datas as $roleid=>$r) { $basic_data[$roleid] = $r['urlrule'];; } setcache('urlrules_detail',$datas,'commons'); setcache('urlrules',$basic_data,'commons'); }
/** * 设置站点缓存 */ public function set_cache() { $list = $this->db->select(); $data = array(); foreach ($list as $key=>$val) { $data[$val['siteid']] = $val; $data[$val['siteid']]['url'] = $val['domain'] ? $val['domain'] : pc_base::load_config('system', 'web_path').$val['dirname'].'/'; } setcache('sitelist', $data, 'commons'); }
public function ajax_clear() { /*写入应用列表缓存*/ $applist = $this->applications_db->listinfo('', '', 1, 100, 'appid'); setcache('applist', $applist); $applistinfo = getcacheinfo('applist'); $return['filesize'] = sizecount($applistinfo['filesize']); $return['filemtime'] = date('Y-m-d H:i:s', $applistinfo['filemtime']); exit(json_encode($return)); }
/** * 外部数据源缓存 */ function dbsource_cache() { $db = pc_base::load_model('dbsource_model'); $list = $db->select(); $data = array(); if ($list) { foreach ($list as $val) { $data[$val['name']] = array('hostname'=>$val['host'].':'.$val['port'], 'database' =>$val['dbname'] , 'db_tablepre'=>$val['dbtablepre'], 'username' =>$val['username'],'password' => $val['password'],'charset'=>$val['charset'],'debug'=>0,'pconnect'=>0,'autoconnect'=>0); } } else { return false; } return setcache('dbsource', $data, 'commons'); }
public function sms_setting() { $siteid = get_siteid(); if (isset($_POST['dosubmit'])) { $this->sms_setting_arr[$siteid] = $_POST['setting']; $setting = array2string($this->sms_setting); setcache('sms', $this->sms_setting_arr); $this->module_db->update(array('setting' => $setting), array('module' => 'sms')); showmessage(L('operation_success'), HTTP_REFERER); } else { $show_pc_hash = ''; include $this->admin_tpl('sms_setting'); } }
public function sp4() { if (isset($_POST['dosubmit'])) { $data = isset($_POST['data']) ? $_POST['data'] : ''; $data['sp4use'] = isset($_POST['sp4use']) && intval($_POST['sp4use']) ? intval($_POST['sp4use']) : 0; $data['sp4_password_key'] = isset($_POST['sp4_password_key']) && $_POST[sp4_password_key] ? $_POST['sp4_password_key'] : ''; $this->db->insert(array('name' => 'sp4', 'data' => array2string($data)), 1, 1); setcache('settings_sp4', $data); showmessage(L('operation_success'), HTTP_REFERER); } $data = array(); $data = getcache('settings_sp4'); include $this->admin_tpl('system_sp4'); }
public function public_regcnzz() { if (empty($this->config)) { $key = md5(APP_PATH.'F0dkYYtw'); if ($data = @file_get_contents('http://wss.cnzz.com/user/companion/phpcms.php?domain='.APP_PATH.'&key='.$key.'&cms=phpcms')) { //ʧ°Ü if (substr($data, 0, 1) == '-') { showmessage(L('application_fails')); } else { $data = explode('@', $data); $data['siteid'] = $data[0]; $data['password'] = $data[1]; unset($data[0], $data[1]); setcache('cnzz', $data, 'commons'); showmessage(L('success'), '?m=cnzz&c=index&a=init'); } } else { showmessage(L('donot_connect_server')); } } else { showmessage(L('has_been_registered')); } }
private function player_list($return_data = 0) { $infos = $this->ku6api->player_list(); $infos = $infos['data']; $player_caches = array(); foreach ($infos as $info) { if ($info['default'] == 1) { $player_caches[$info['channelid']]['default'] = $info['style']; } $player_caches[$info['channelid']]['STY-' . $info['style']] = $info; } setcache('player', $player_caches, 'video'); if ($return_data) { return $infos; } /* 1=>array( 'default'=> 'idZwHK_aOJ7E-oGT', 'STY-idZwHK_aOJ7E-oGT'=> array('auto'=>1), 'STY-7i8TjPi7A3o.'=> array(), ), */ }
/** * 更新指定表单向导的字段缓存 * * @param $formid 表单向导id * @param $disabled 字段状态 */ public function cache_field($formid = 0, $disabled = 0) { $field_array = array(); $fields = $this->db->select(array('modelid' => $formid, 'disabled' => $disabled), '*', 100, 'listorder ASC'); foreach ($fields as $_value) { $setting = string2array($_value['setting']); $_value = array_merge($_value, $setting); $field_array[$_value['field']] = $_value; } setcache('formguide_field_' . $formid, $field_array, 'model'); return true; }
exit('0'); } } /** * 应用积分列表 */ if ($action == 'credit_list') { $credit_list = pc_base::load_config('credit'); echo $client->array2string($credit_list); exit; } /** * 更新积分兑换规则 */ if ($action == 'credit_update') { setcache('creditchange', $arr, 'member'); exit('1'); } /** * 同步登陆 */ if ($action == 'synlogin') { if (!isset($arr['uid'])) { exit('0'); } $phpssouid = $arr['uid']; $userinfo = $db->get_one(array('phpssouid' => $phpssouid)); if (!$userinfo) { //插入会员 exit; $ps_userinfo = $client->ps_get_member_info($userid);
/** * 配置模板 */ public function public_tempate_setting() { $siteid = $this->get_siteid(); $poster_template = getcache('poster_template_' . $siteid, 'commons'); if (isset($_POST['dosubmit'])) { if (is_array($_POST['info']['type']) && !empty($_POST['info']['type'])) { $type2name = array('images' => L('photo'), 'flash' => L('flash'), 'text' => L('title')); $type = array(); foreach ($_POST['info']['type'] as $t) { if (in_array($t, array('images', 'flash', 'text'))) { $type[$t] = $type2name[$t]; } else { continue; } } } unset($_POST['info']['type']); $_POST['info']['type'] = $type; $poster_template[$_POST['template']] = $_POST['info']; setcache('poster_template_' . $siteid, $poster_template, 'commons'); showmessage(L('setting_success'), '', '', 'testIframe'); } else { if (!isset($_GET['template'])) { showmessage(L('illegal_parameters')); } else { $template = $_GET['template']; } if ($poster_template[$template]) { $info = $poster_template[$template]; if (is_array($info['type']) && !empty($info['type'])) { $type = array(); $type = array_keys($info['type']); unset($info['type']); $info['type'] = $type; } } include $this->admin_tpl('template_setting'); } }
/** * 更新企业组列表缓存 */ private function _updatecache() { $grouplist = $this->db->listinfo('', '', 1, 1000, 'groupid'); setcache('grouplist', $grouplist); }
/** * 更新缓存 */ public function cache() { $categorys = array(); $models = getcache('model', 'commons'); foreach ($models as $modelid => $model) { $datas = $this->db->select(array('modelid' => $modelid), 'catid,type,items', 10000); $array = array(); foreach ($datas as $r) { if ($r['type'] == 0) { $array[$r['catid']] = $r['items']; } } setcache('category_items_' . $modelid, $array, 'commons'); } $array = array(); $categorys = $this->db->select('`module`=\'content\'', 'catid,siteid', 20000, 'listorder ASC'); foreach ($categorys as $r) { $array[$r['catid']] = $r['siteid']; } setcache('category_content', $array, 'commons'); $categorys = $this->categorys = array(); $this->categorys = $this->db->select(array('siteid' => $this->siteid, 'module' => 'content'), '*', 10000, 'listorder ASC'); foreach ($this->categorys as $r) { unset($r['module']); $setting = string2array($r['setting']); $r['create_to_html_root'] = $setting['create_to_html_root']; $r['ishtml'] = $setting['ishtml']; $r['content_ishtml'] = $setting['content_ishtml']; $r['category_ruleid'] = $setting['category_ruleid']; $r['show_ruleid'] = $setting['show_ruleid']; $r['workflowid'] = $setting['workflowid']; $r['isdomain'] = '0'; if (!preg_match('/^(http|https):\\/\\//', $r['url'])) { $r['url'] = siteurl($r['siteid']) . $r['url']; } elseif ($r['ishtml']) { $r['isdomain'] = '1'; } $categorys[$r['catid']] = $r; } setcache('category_content_' . $this->siteid, $categorys, 'commons'); return true; }
public final function reload_all_cache() { $menus = array(); $datas = $this->Module_menu_model->select('', '*', 10000, 'list_order ASC,menu_id asc'); $array = array(); foreach ($datas as $r) { //$r['url'] =base_url($r['folder'].'/'.$r['controller'].'/'.$r['method']) ; $r['url'] = $this->_load_submenu($r); $arr_parentid = $r['arr_parentid']; $arr_parentid = explode(",", $arr_parentid); $menus[$r['menu_id']] = $r; } setcache('cache_module_menu_all', $menus); $priv_arr = $this->Member_role_priv_model->select(""); $new_priv_arr = array(); if ($priv_arr) { foreach ($priv_arr as $k => $v) { $new_priv_arr[$v['role_id']][$v['menu_id']] = $v; } setcache('cache_member_role_priv', $new_priv_arr); $infos = $this->Member_role_model->select('', '*', '', 'role_id ASC'); $groups = array(); foreach ($infos as $info) { $role[$info['role_id']] = $info['role_name']; $groups[$info['role_id']] = $info; } setcache('cache_member_group', $groups); } }
public function check_status() { $appid = isset($_GET['appid']) && intval($_GET['appid']) ? intval($_GET['appid']) : exit('0'); $applist = getcache('applist'); if(empty($applist)) { /*写入应用列表缓存*/ $applist = $this->db->listinfo('', '', 1, 100, 'appid'); setcache('applist', $applist); } if (!empty($applist)) { $param = sys_auth('action=check_status', 'ENCODE', $applist[$appid]['authkey']); //如果填写ip则通信地址为ip地址,此时绑定了多个虚拟主机有可能出现错误 $appurl = !empty($applist[$appid]['ip']) ? 'http://'.$applist[$appid]['ip'].'/api/' : $applist[$appid]['url']; $url = $appurl.$applist[$appid]['apifilename']; if (strpos($url, '?')) { $url .= '&'; } else { $url .= "?"; } if ($data = @file_get_contents($url.'code='.urlencode($param))) { exit($data); } else { exit('0'); } } else { exit('0'); } }
/** * 写入缓存动态页面 */ function cache_page($ttl = 360, $isjs = 0) { if ($ttl == 0 || !defined('CACHE_PAGE_ID')) { return false; } $contents = ob_get_contents(); if ($isjs) { $contents = format_js($contents); } $contents = "<!--expiretime:" . (SYS_TIME + $ttl) . "-->\n" . $contents; setcache(CACHE_PAGE_ID, $contents, 'page_tmp/' . substr(CACHE_PAGE_ID, 0, 2)); }
public function open_setting() { if (isset($_POST['dosubmit'])) { $setting = array2string($_POST['setting']); setcache('video', $_POST['setting']); $this->ku6api->ku6api_skey = $_POST['setting']['skey']; $this->ku6api->ku6api_sn = $_POST['setting']['sn']; $this->module_db->update(array('setting' => $setting), array('module' => 'video')); if (!$this->ku6api->testapi()) { showmessage(L('vms_sn_skey_error'), HTTP_REFERER); } showmessage(L('operation_success'), HTTP_REFERER); } else { $show_pc_hash = ''; $v_model_categorys = $this->ku6api->get_categorys(true, $this->setting['catid']); $category_list = '<select name="setting[catid]" id="catid"><option value="0">' . L('please_choose_catid') . '</option>' . $v_model_categorys . '</select>'; include $this->admin_tpl('video_opensetting'); } }
/** * 更新缓存 */ private function cache() { $menus = array(); $datas = $this->Module_menu_model->select('', '*', 10000, 'list_order ASC,menu_id asc'); $array = array(); foreach ($datas as $r) { $r['url'] = base_url($r['folder'] . '/' . $r['controller'] . '/' . $r['method']); $menus[$r['menu_id']] = $r; } setcache('cache_module_menu_all', $menus); return true; }
public final function reload_all_cache() { $menus = array(); $datas = $this->Module_menu_model->select('', '*', 10000, 'list_order ASC,menu_id asc'); $array = array(); foreach ($datas as $r) { $r['url'] = base_url($r['folder'] . '/' . $r['controller'] . '/' . $r['method']); $arr_parentid = $r['arr_parentid']; $arr_parentid = explode(",", $arr_parentid); #缓存的时候自动将第一级要跳转的URL写入到缓存 if (count($arr_parentid) == 1) { #找到下面第一个子目录 $first_child_arr = $this->Module_menu_model->get_one("arr_parentid like '0," . $r['menu_id'] . "' and is_display = 1", "*", "list_order asc"); if ($first_child_arr) { $first_child_child_arr = $this->Module_menu_model->get_one("arr_parentid like '0," . $r['menu_id'] . "," . $first_child_arr['menu_id'] . "' and is_display = 1", "*", "list_order asc"); if ($first_child_child_arr) { $r['url'] = base_url($first_child_child_arr['folder'] . '/' . $first_child_child_arr['controller'] . '/' . $first_child_child_arr['method']); } } } $menus[$r['menu_id']] = $r; } setcache('cache_module_menu_all', $menus); $priv_arr = $this->Member_role_priv_model->select(""); $new_priv_arr = array(); if ($priv_arr) { foreach ($priv_arr as $k => $v) { $new_priv_arr[$v['role_id']][$v['menu_id']] = $v; } setcache('cache_member_role_priv', $new_priv_arr); $infos = $this->Member_role_model->select('', '*', '', 'role_id ASC'); $groups = array(); foreach ($infos as $info) { $role[$info['role_id']] = $info['role_name']; $groups[$info['role_id']] = $info; } setcache('cache_member_group', $groups); } }
$db = pc_base::load_model('admin_model'); $memberinfo = $db->get_one(array('username' => $username)); if (!empty($memberinfo)) { if (md5(md5($password) . $memberinfo['encrypt']) == $memberinfo['password']) { $appdb = pc_base::load_model('applications_model'); $appdata['authkey'] = $authkey; $appdata['apifilename'] = $apifilename; $appdata['charset'] = $charset; $appdata['type'] = $type; $appdata['synlogin'] = $synlogin; $appdata['url'] = $url; $appdata['name'] = $name; $appid = $appdb->insert($appdata, 1); if ($appid > 0) { $applist = $appdb->listinfo('', '', 1, 100, 'appid'); setcache('applist', $applist, 'admin'); echo $appid; unset($_SESSION['_is_dos']); exit; } else { exit('-3'); } } else { $try_num = $_SESSION['_is_dos']; if ($try_num) { if ($try_num > 15) { showmessage('try_again', APP_PATH); } $try_num = $try_num + 1; $_SESSION['_is_dos'] = $try_num + 1; } else {
/** * 数据库导出方法 * @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); } }
</div> <div class="bk10"></div> <div class="box"> <h5 class="title-2">一周评论排行</h5> <?php if (defined('IN_ADMIN') && !defined('HTML')) { echo "<div class=\"admin_piao\" pc_action=\"comment\" data=\"op=comment&tag_md5=f96eff7c12a07eee88c5cd43c712bf7e&action=bang&cache=3600\"><a href=\"javascript:void(0)\" class=\"admin_piao_edit\">编辑</a>"; } $tag_cache_name = md5(implode('&', array()) . 'f96eff7c12a07eee88c5cd43c712bf7e'); if (!($data = tpl_cache($tag_cache_name, 3600))) { $comment_tag = pc_base::load_app_class("comment_tag", "comment"); if (method_exists($comment_tag, 'bang')) { $data = $comment_tag->bang(array('limit' => '20')); } if (!empty($data)) { setcache($tag_cache_name, $data, 'tpl_data'); } } ?> <ul class="content digg"> <?php $n = 1; if (is_array($data)) { foreach ($data as $r) { ?> <li><a href="<?php echo $r['url']; ?> " target="_blank"><?php echo $r['title']; ?>
/** * 生成栏目页 */ public function category() { if (isset($_POST['dosubmit'])) { extract($_POST, EXTR_SKIP); $this->html = pc_base::load_app_class('html'); $referer = isset($referer) ? urlencode($referer) : ''; $modelid = intval($_POST['modelid']); if (!isset($set_catid)) { if ($catids[0] != 0) { $update_url_catids = $catids; } else { foreach ($this->categorys as $catid => $cat) { if ($cat['siteid'] != $this->siteid || $cat['type'] == 2 || !$cat['ishtml']) { continue; } if ($modelid && $modelid != $cat['modelid']) { continue; } $update_url_catids[] = $catid; } } setcache('update_html_catid' . '-' . $this->siteid . '-' . $_SESSION['userid'], $update_url_catids, 'content'); $message = L('start_update_category'); $forward = "?m=content&c=create_html&a=category&set_catid=1&pagesize={$pagesize}&dosubmit=1&modelid={$modelid}&referer={$referer}"; showmessage($message, $forward); } $catid_arr = getcache('update_html_catid' . '-' . $this->siteid . '-' . $_SESSION['userid'], 'content'); $autoid = $autoid ? intval($autoid) : 0; if (!isset($catid_arr[$autoid])) { if (!empty($referer) && $this->categorys[$catid_arr[0]]['type'] != 1) { showmessage(L('create_update_success'), '?m=content&c=content&a=init&catid=' . $catid_arr[0], 200); } else { showmessage(L('create_update_success'), '?m=content&c=create_html&a=category', 200); } } $catid = $catid_arr[$autoid]; $page = $page ? $page : 1; $j = 1; do { $this->html->category($catid, $page); $page++; $j++; $total_number = isset($total_number) ? $total_number : PAGES; } while ($j <= $total_number && $j < $pagesize); if ($page <= $total_number) { $endpage = intval($page + $pagesize); $message = L('updating') . $this->categorys[$catid]['catname'] . L('start_to_end_id', array('page' => $page, 'endpage' => $endpage)); $forward = "?m=content&c=create_html&a=category&set_catid=1&pagesize={$pagesize}&dosubmit=1&autoid={$autoid}&page={$page}&total_number={$total_number}&modelid={$modelid}&referer={$referer}"; } else { $autoid++; $message = $this->categorys[$catid]['catname'] . L('create_update_success'); $forward = "?m=content&c=create_html&a=category&set_catid=1&pagesize={$pagesize}&dosubmit=1&autoid={$autoid}&modelid={$modelid}&referer={$referer}"; } 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(' │ ', ' ├─ ', ' └─ '); $tree->nbsp = ' '; $categorys = array(); if (!empty($this->categorys)) { foreach ($this->categorys as $catid => $r) { if ($this->siteid != $r['siteid'] || $r['type'] == 2 && $r['child'] == 0) { continue; } if ($modelid && $modelid != $r['modelid']) { continue; } if ($r['child'] == 0) { if (!$r['ishtml']) { continue; } } $categorys[$catid] = $r; } } $str = "<option value='\$catid' \$selected>\$spacer \$catname</option>"; $tree->init($categorys); $string .= $tree->get_tree(0, $str); include $this->admin_tpl('create_html_category'); } }
/** * 更新来源缓存方法 */ public function copyfrom() { $infos = $this->db->select('', '*', '', 'listorder DESC', '', 'id'); setcache('copyfrom', $infos, 'admin'); return true; }