/** * 将数组转换为字符串 * * @param array $data 数组 * @param bool $isformdata 如果为0,则不使用new_stripslashes处理,可选参数,默认为1 * @return string 返回字符串,如果,data为空,则返回空 */ function array2string($data, $isformdata = 1) { if ($data == '') { return ''; } if ($isformdata) { $data = new_stripslashes($data); } return addslashes(var_export($data, TRUE)); }
/** * 返回经stripslashes处理过的字符串或数组 * @param $string 需要处理的字符串或数组 * @return mixed */ function new_stripslashes($string) { if (!is_array($string)) { return stripslashes($string); } foreach ($string as $key => $val) { $string[$key] = new_stripslashes($val); } return $string; }
/** * 将数组转换为字符串 * * @param array $data 数组 * @param bool $isformdata 如果为0,则不使用new_stripslashes处理,可选参数,默认为1 * @return string 返回字符串,如果,data为空,则返回空 */ function array2string($data, $isformdata = 1) { if ($data == '' || empty($data)) { return ''; } if ($isformdata) { $data = new_stripslashes($data); } if (strtolower(CHARSET) == 'gbk') { $data = mult_iconv("GBK", "UTF-8", $data); } if (version_compare(PHP_VERSION, '5.3.0', '<')) { return addslashes(json_encode($data)); } else { return addslashes(json_encode($data, JSON_FORCE_OBJECT)); } }
public function manage() { if (isset($_POST['dosubmit'])) { $_POST['info']['denyusername'] = isset($_POST['info']['denyusername']) ? new_stripslashes(trim($_POST['info']['denyusername'])) : ''; $_POST['info']['denyusername'] = explode("\r\n", $_POST['info']['denyusername']); $_POST['info']['denyemail'] = isset($_POST['info']['denyemail']) ? new_stripslashes(trim($_POST['info']['denyemail'])) : ''; $_POST['info']['denyemail'] = explode("\r\n", $_POST['info']['denyemail']); $this->db->set_setting('member', $_POST['info']); S('member/member_setting', $_POST['info']); showmessage(L('operation_success'), HTTP_REFERER); } else { $show_validator = $show_header = true; $show_scroll = true; $member_setting = $this->db->get_setting('member'); include $this->view('member_setting'); } }
public function deleteuser($get, $post) { pc_base::load_app_func('global', 'admin'); pc_base::load_app_class('messagequeue', 'admin', 0); $ids = new_stripslashes($get['ids']); $s = $this->member_db->select("ucuserid in ({$ids})", "uid"); $this->member_db->delete("ucuserid in ({$ids})"); $noticedata['uids'] = array(); if ($s) { foreach ($s as $key => $v) { $noticedata['uids'][$key] = $v['uid']; } } else { return API_RETURN_FAILED; } messagequeue::add('member_delete', $noticedata); return API_RETURN_SUCCEED; }
/** * 构造函数 */ public function __construct() { $this->db = pc_base::load_model('member_model'); pc_base::load_app_func('global'); /*获取系统配置*/ $this->settings = getcache('settings', 'admin'); $this->applist = getcache('applist', 'admin'); if(isset($_GET) && is_array($_GET) && count($_GET) > 0) { foreach($_GET as $k=>$v) { if(!in_array($k, array('m','c','a'))) { $_POST[$k] = $v; } } } if(isset($_POST['appid'])) { $this->appid = intval($_POST['appid']); } else { exit('0'); } if(isset($_POST['data'])) { parse_str(sys_auth($_POST['data'], 'DECODE', $this->applist[$this->appid]['authkey']), $this->data); if(get_magic_quotes_gpc()) { $this->data = new_stripslashes($this->data); } if(!is_array($this->data)) { exit('0'); } } else { exit('0'); } if(isset($GLOBALS['HTTP_RAW_POST_DATA'])) { $this->data['avatardata'] = $GLOBALS['HTTP_RAW_POST_DATA']; if($this->applist[$this->appid]['authkey'] != $this->data['ps_auth_key']) { exit('0'); } } }
/** * 首页 */ public function init() { if (isset($_POST['dosubmit'])) { $denyusername = isset($_POST['denyusername']) ? new_stripslashes(trim($_POST['denyusername'])) : ''; $denyemail = isset($_POST['denyemail']) ? new_stripslashes(trim($_POST['denyemail'])) : ''; $denyemaildata = array2string(explode("\r\n", $denyemail)); $denyusernamedata = array2string(explode("\r\n", $denyusername)); $this->db->insert(array('name' => 'denyemail', 'data' => $denyemaildata), 1, 1); $this->db->insert(array('name' => 'denyusername', 'data' => $denyusernamedata), 1, 1); /*写入缓存*/ setcache('settings', array('denyemail' => explode("\r\n", $denyemail), 'denyusername' => explode("\r\n", $denyusername))); showmessage(L('operation_success'), HTTP_REFERER); } $where = to_sqls(array('denyemail', 'denyusername'), '', 'name'); $settingarr = $this->db->listinfo($where); foreach ($settingarr as $v) { $setting[$v['name']] = string2array($v['data']); } include $this->admin_tpl('system'); }
/** * 生成模板返回路径 * @param integer $id 碎片ID号 * @param string $template 风格 */ public function template_url($id, $template = '') { $filepath = CACHE_PATH.'caches_template'.DIRECTORY_SEPARATOR.'block'.DIRECTORY_SEPARATOR.$id.'.php'; $dir = dirname($filepath); if ($template) { if(!is_dir($dir)) { mkdir($dir, 0777, true); } $tpl = pc_base::load_sys_class('template_cache'); $str = $tpl->template_parse(new_stripslashes($template)); @file_put_contents($filepath, $str); } else { if (!file_exists($filepath)) { if(!is_dir($dir)) { mkdir($dir, 0777, true); } $tpl = pc_base::load_sys_class('template_cache'); $str = $this->db->get_one(array('id'=>$id), 'template'); $str = $tpl->template_parse($str['template']); @file_put_contents($filepath, $str); } } return $filepath; }
function array2string($data, $is_addslashes = true) { if ($data == '') { return ''; } // addslashes 数据需要 stripslashes if ($is_addslashes) { $data = new_stripslashes($data); } return addslashes(var_export($data, TRUE)); }
/** * 生成内容页 * @param $file 文件地址 * @param $data 数据 * @param $array_merge 是否合并 * @param $action 方法 * @param $upgrade 是否是升级数据 */ public function show($file, $data = '', $array_merge = 1, $action = 'add', $upgrade = 0) { if ($upgrade) { $file = '/' . ltrim($file, WEB_PATH); } $allow_visitor = 1; $id = $data['id']; if ($array_merge) { $data = new_stripslashes($data); $data = array_merge($data['system'], $data['model']); } //通过rs获取原始值 $rs = $data; if (isset($data['paginationtype'])) { $paginationtype = $data['paginationtype']; $maxcharperpage = $data['maxcharperpage']; } else { $paginationtype = 0; } $catid = $data['catid']; $CATEGORYS = $this->categorys; $CAT = $CATEGORYS[$catid]; $CAT['setting'] = string2array($CAT['setting']); define('STYLE', $CAT['setting']['template_list']); //最顶级栏目ID $arrparentid = explode(',', $CAT['arrparentid']); $top_parentid = $arrparentid[1] ? $arrparentid[1] : $catid; //$file = '/'.$file; //添加到发布点队列 //当站点为非系统站点 if ($this->siteid != 1) { $site_dir = $this->sitelist[$this->siteid]['dirname']; $file = $this->html_root . '/' . $site_dir . $file; } $this->queue->add_queue($action, $file, $this->siteid); $modelid = $CAT['modelid']; require_once CACHE_MODEL_PATH . 'content_output.class.php'; $content_output = new content_output($modelid, $catid, $CATEGORYS); $output_data = $content_output->get($data); extract($output_data); if (module_exists('comment')) { $allow_comment = isset($allow_comment) ? $allow_comment : 1; } else { $allow_comment = 0; } $this->db = pc_base::load_model('content_model'); $this->db->set_model($modelid); //上一页 $previous_page = $this->db->get_one("`catid` = '{$catid}' AND `id`<'{$id}' AND `status`=99", '*', 'id DESC'); //下一页 $next_page = $this->db->get_one("`catid`= '{$catid}' AND `id`>'{$id}' AND `status`=99"); if (empty($previous_page)) { $previous_page = array('title' => L('first_page', '', 'content'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('first_page', '', 'content') . '\');'); } if (empty($next_page)) { $next_page = array('title' => L('last_page', '', 'content'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('last_page', '', 'content') . '\');'); } $title = strip_tags($title); //SEO $seo_keywords = ''; if (!empty($keywords)) { $seo_keywords = implode(',', $keywords); } $siteid = $this->siteid; $SEO = seo($siteid, $catid, $title, $description, $seo_keywords); $ishtml = 1; $template = $template ? $template : $CAT['setting']['show_template']; //分页处理 $pages = $titles = ''; if ($paginationtype == 1) { //自动分页 if ($maxcharperpage < 10) { $maxcharperpage = 500; } $contentpage = pc_base::load_app_class('contentpage'); $content = $contentpage->get_data($content, $maxcharperpage); } if ($paginationtype != 0) { //手动分页 $CONTENT_POS = strpos($content, '[page]'); if ($CONTENT_POS !== false) { $this->url = pc_base::load_app_class('url', 'content'); $contents = array_filter(explode('[page]', $content)); $pagenumber = count($contents); if (strpos($content, '[/page]') !== false && $CONTENT_POS < 7) { $pagenumber--; } for ($i = 1; $i <= $pagenumber; $i++) { $upgrade = $upgrade ? '/' . ltrim($file, WEB_PATH) : ''; $pageurls[$i] = $this->url->show($id, $i, $catid, $data['inputtime'], '', '', 'edit', $upgrade); } $END_POS = strpos($content, '[/page]'); if ($END_POS !== false) { if ($CONTENT_POS > 7) { $content = '[page]' . $title . '[/page]' . $content; } if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) { foreach ($m[1] as $k => $v) { $p = $k + 1; $titles[$p]['title'] = strip_tags($v); $titles[$p]['url'] = $pageurls[$p][0]; } } } //生成分页 foreach ($pageurls as $page => $urls) { $pages = content_pages($pagenumber, $page, $pageurls); //判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { if ($page == 1 && !empty($titles)) { $content = $title . '[/page]' . $contents[$page - 1]; } else { $content = $contents[$page - 1]; } } if ($titles) { list($title, $content) = explode('[/page]', $content); $content = trim($content); if (strpos($content, '</p>') === 0) { $content = '<p>' . $content; } if (stripos($content, '<p>') === 0) { $content = $content . '</p>'; } } $pagefile = $urls[1]; if ($this->siteid != 1) { $pagefile = $this->html_root . '/' . $site_dir . $pagefile; } $this->queue->add_queue($action, $pagefile, $this->siteid); $pagefile = PHPCMS_PATH . $pagefile; ob_start(); include template('content', $template); $this->createhtml($pagefile); } return true; } } //分页处理结束 $file = PHPCMS_PATH . $file; ob_start(); include template('content', $template); return $this->createhtml($file); }
/** * 附件下载 * Enter description here ... * @param $field 预留字段 * @param $value 传入下载内容 * @param $watermark 是否加入水印 * @param $ext 下载扩展名 * @param $absurl 绝对路径 * @param $basehref */ function download($field, $value, $watermark = '0', $ext = 'gif|jpg|jpeg|bmp|png', $absurl = '', $basehref = '') { global $image_d; $this->att_db = pc_base::load_model('attachment_model'); $upload_url = pc_base::load_config('system', 'upload_url'); $this->field = $field; $dir = date('Y/md/'); $uploadpath = $upload_url . $dir; $uploaddir = $this->upload_root . $dir; $string = new_stripslashes($value); if (!preg_match_all("/(href|src)=([\"|']?)([^ \"'>]+\\.({$ext}))\\2/i", $string, $matches)) { return $value; } $remotefileurls = array(); foreach ($matches[3] as $matche) { if (strpos($matche, '://') === false) { continue; } dir_create($uploaddir); $remotefileurls[$matche] = $this->fillurl($matche, $absurl, $basehref); } unset($matches, $string); $remotefileurls = array_unique($remotefileurls); $oldpath = $newpath = array(); foreach ($remotefileurls as $k => $file) { if (strpos($file, '://') === false || strpos($file, $upload_url) !== false) { continue; } $filename = fileext($file); $file_name = basename($file); $filename = $this->getname($filename); $newfile = $uploaddir . $filename; $upload_func = $this->upload_func; if ($upload_func($file, $newfile)) { $oldpath[] = $k; $GLOBALS['downloadfiles'][] = $newpath[] = $uploadpath . $filename; @chmod($newfile, 0777); $fileext = fileext($filename); if ($watermark) { watermark($newfile, $newfile, $this->siteid); } $filepath = $dir . $filename; $downloadedfile = array('filename' => $filename, 'filepath' => $filepath, 'filesize' => filesize($newfile), 'fileext' => $fileext); $aid = $this->add($downloadedfile); $this->downloadedfiles[$aid] = $filepath; } } return str_replace($oldpath, $newpath, $value); }
/** * 将数组转换为字符串 * @param array $data 数组 * @param bool $isformdata 如果为0,则不使用new_stripslashes处理,可选参数,默认为1 * @return string 返回字符串,如果,data为空,则返回空 */ function array2string($data, $isformdata = 1) { if ($data == '') { return ''; } if ($isformdata) { $data = new_stripslashes($data); } return serialize($data); }
public function view() { $url = isset($_GET['url']) && trim($_GET['url']) ? new_stripslashes(urldecode(trim($_GET['url']))) : showmessage(L('illegal_action'), HTTP_REFERER); $url = str_replace("..","",$url); if (!file_exists(ZLCMS_PATH.$url)) { showmessage(L('file_not_exists')); } $html = file_get_contents(ZLCMS_PATH.$url); //判断文件名,如果是database.php 对里面的关键字符进行替换 $basename = basename($url); if($basename == "database.php"){ //$html = str_replace(); showmessage(L('重要文件,不允许在线查看!')); } $file_list = getcache('scan_bad_file', 'scan'); if (isset($file_list[$url]['func']) && is_array($file_list[$url]['func']) && !empty($file_list[$url]['func'])) foreach ($file_list[$url]['func'] as $key=>$val) { $func[$key] = strtolower($val[1]); } if (isset($file_list[$url]['code']) && is_array($file_list[$url]['code']) && !empty($file_list[$url]['code'])) foreach ($file_list[$url]['code'] as $key=>$val) { $code[$key] = strtolower($val[1]); } if (isset($func)) $func = array_unique($func); if (isset($code)) $code = array_unique($code); $show_header = true; include $this->admin_tpl('public_view'); }
function image_upload() { $field_id = $this->input->get_post('id'); $config = array('module' => 'shop_goods', 'isadmin' => 1, 'sts' => 0, 'class_id' => 1); $this->load->library('ifile_lib', $config); $this->ifile_lib->initialize(); //配置初始化文件 $this->ifile_lib->do_uploadfile($field_id); //上传附件 $re_msg = $this->ifile_lib->error_data(); $re_data = $this->ifile_lib->file_data(); if (!empty($re_msg)) { $res['error'] = $re_msg[0]; $json = cc_json_encode($res); echo $json; return false; } $this->file_id = $this->ifile_lib->save_data(); //保存数据到数据库 //if ($this->instance=='shop_goods'){ /**生成水印图片**/ // $wm_info=$this->a_shop_model->get_one(array('shop_id'=>$this->shop_id),'shop_watermark'); // if(isset($wm_info['wm_model'])&& intval($wm_info['wm_model']) >0){ // /**生成水印**/ // $this->load->library('ithumb_lib'); // $full_path=$re_data['full_path']; // $path_arr=explode('.',$full_path); // $config['img_path']=$path_arr[0].'_b.'.$path_arr[1]; // $config['wm_model']=$wm_info['wm_model']; // $config['wm_post']=$wm_info['wm_model']=='1'?$wm_info['txt_pos']:$wm_info['image_pos']; // // $config['wm_txt']=$wm_info['txt']; // $config['wm_txt_size']=$wm_info['txt_size']; // $config['wm_txt_font']=$wm_info['txt_font']; // $config['wm_txt_color']=$wm_info['txt_color']; // // $config['wm_image_path']=$wm_info['image_path']; // $config['wm_opacity']=$wm_info['image_transition']; // $this->ithumb_lib->initialize($config); // $this->ithumb_lib->water_mark(); // } //} $res['msg'] = 'success'; $res['file_id'] = $this->file_id; $res['realname'] = $re_data['client_name']; $res['filename'] = $re_data['file_name']; $base_path = str_replace('\\', '/', FCPATH); $res['filepath'] = str_replace($base_path, '', $re_data['full_path']); $json = cc_json_encode($res); $json = new_stripslashes($json); echo $json; //$this->script="window.parent.do_uploadedfile('$json');"; //$this->upload_iframe(); return true; }
public function public_view() { $id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : exit('0'); if (!($data = $this->db->get_one(array('id' => $id)))) { showmessage(L('nofound')); } if ($data['type'] == 1) { exit('<script type="text/javascript">parent.showblock(' . $id . ', \'' . str_replace("\r\n", '', $_POST['data']) . '\')</script>'); } elseif ($data['type'] == 2) { extract($data); unset($data); $title = isset($_POST['title']) ? $_POST['title'] : ''; $url = isset($_POST['url']) ? $_POST['url'] : ''; $thumb = isset($_POST['thumb']) ? $_POST['thumb'] : ''; $desc = isset($_POST['desc']) ? $_POST['desc'] : ''; $template = isset($_POST['template']) && trim($_POST['template']) ? trim($_POST['template']) : ''; $data = array(); foreach ($title as $key => $v) { if (empty($v) || !isset($url[$key]) || empty($url[$key])) { continue; } $data[$key] = array('title' => $v, 'url' => $url[$key], 'thumb' => $thumb[$key], 'desc' => str_replace(array(chr(13), chr(43)), array('<br />', ' '), $desc[$key])); } $tpl = pc_base::load_sys_class('template_cache'); $str = $tpl->template_parse(new_stripslashes($template)); $filepath = CACHE_PATH . 'caches_template' . DIRECTORY_SEPARATOR . 'block' . DIRECTORY_SEPARATOR . 'tmp_' . $id . '.php'; $dir = dirname($filepath); if (!is_dir($dir)) { @mkdir($dir, 0777, true); } if (@file_put_contents($filepath, $str)) { ob_start(); include $filepath; $html = ob_get_contents(); ob_clean(); @unlink($filepath); } exit('<script type="text/javascript">parent.showblock(' . $id . ', \'' . str_replace("\r\n", '', $html) . '\')</script>'); } }
/** * 将数组转换为字符串 * * @param array $data 数组 * @param bool $isformdata 如果为0,则不使用new_stripslashes处理,可选参数,默认为1 * @return string 返回字符串,如果,data为空,则返回空 */ public function array2string($data, $isformdata = 1) { if($data == '') return ''; if($isformdata) $data = new_stripslashes($data); return var_export($data, TRUE); }
function image_upload() { $field_id = $this->input->get_post('id'); //语言包配置---加载 $lang = $this->config->item('language'); if ($lang) { $this->_language = $lang; } $this->lang->load('jslang', $this->_language); //检测用户是否session失效 // if(intval($this->shop_id)<=0){ // $res['error']=lang('js_session_error'); // $json=cc_json_encode($res);echo $json; // return false; // } // $this->load->model('a_shop_model'); // $shop_info=$this->a_shop_model->get_one(array('shop_id'=>$this->shop_id),'shop'); // // //检测用户是否失效 // if(!isset($shop_info['shop_id']) || empty($shop_info['shop_id'])){ // $res['error']=lang('js_session_error'); // $json=cc_json_encode($res);echo $json; // return false; // } //获取该商铺拥有空间的大小 // $sg_id=empty($shop_info['sg_id'])?1:$shop_info['sg_id']; // $sg_info=$this->m_shop_model->get_one(array('sg_id'=>$sg_id),'shop_grade'); // $space_limit=$sg_info['sg_space_limit']; //获取该商铺已经使用的空间大小 // $space_size=$this->m_shop_model->get_one(array('isadmin'=>0,'shop_id'=>$this->shop_id,'sts'=>0),'uploadfile','sum(filesize) as file_size'); // $now_space_size=isset($space_size['file_size'])?$space_size['file_size']:0; //剩余可以使用空间大小,false表示不做限制 // $remaid = $space_limit > 0 ? $space_limit * 1024 * 1024 - $now_space_size : false; // if($remaid ===false){ // $res['error']=lang('js_space_limit_arrived'); // $json=cc_json_encode($res);echo $json; // return false; // } $config = array('module' => 'shop_goods', 'shop_id' => 0, 'isadmin' => 0, 'sts' => 0, 'class_id' => 1); $this->load->library('iupload_lib'); $this->iupload_lib->initialize($config); //配置初始化文件 $this->iupload_lib->do_uploadfile($field_id); //上传附件 $re_msg = $this->iupload_lib->error_data(); $re_data = $this->iupload_lib->file_data(); if (!empty($re_msg)) { $res['error'] = $re_msg[0]; $json = cc_json_encode($res); echo $json; return false; } $this->file_id = $this->iupload_lib->save_data(); //保存数据到数据库 //if ($this->instance=='shop_goods'){ /**生成水印图片**/ // $wm_info=$this->m_shop_model->get_one(array('shop_id'=>$this->shop_id),'shop_watermark'); // if(isset($wm_info['wm_model'])&& intval($wm_info['wm_model']) >0){ // /**生成水印**/ // $this->load->library('ithumb_lib'); // $full_path=$re_data['full_path']; // $path_arr=explode('.',$full_path); // $config['img_path']=$path_arr[0].'_b.'.$path_arr[1]; // $config['wm_model']=$wm_info['wm_model']; // $config['wm_post']=$wm_info['wm_model']=='1'?$wm_info['txt_pos']:$wm_info['image_pos']; // // $config['wm_txt']=$wm_info['txt']; // $config['wm_txt_size']=$wm_info['txt_size']; // $config['wm_txt_font']=$wm_info['txt_font']; // $config['wm_txt_color']=$wm_info['txt_color']; // // $config['wm_image_path']=$wm_info['image_path']; // $config['wm_opacity']=$wm_info['image_transition']; // $this->ithumb_lib->initialize($config); // $this->ithumb_lib->water_mark(); // } //} $res['msg'] = 'success'; $res['file_id'] = $this->file_id; $res['realname'] = $re_data['client_name']; $res['filename'] = $re_data['file_name']; $base_path = str_replace('\\', '/', FCPATH); $res['filepath'] = str_replace($base_path, '', $re_data['full_path']); $json = cc_json_encode($res); $json = new_stripslashes($json); echo $json; //$this->script="window.parent.do_uploadedfile('$json');"; //$this->upload_iframe(); return true; }
/** * 生成内容页 * @param $file 文件地址 * @param $data 数据 * @param $array_merge 是否合并 * @param $action 方法 */ public function show($file, $data = '', $array_merge = 1, $action = 'add') { //取得信息ID $id = $data['id']; //判断数据是否已经合并成一个数组,而不是分主表和附表 if ($array_merge) { $data = new_stripslashes($data); $data = array_merge($data['system'], $data['model']); $data['id'] = $id; } //通过rs获取原始值 $rs = $data; //栏目ID $catid = $data['catid']; //获取栏目缓存 $Category = $this->categorys; //获取当前栏目数据 $CAT = $Category[$catid]; //反序列化栏目配置 $CAT['setting'] = unserialize($CAT['setting']); //模型ID $this->modelid = $modelid = $CAT['modelid']; //获取主表名 $this->table_name = $this->Model[$this->modelid]['tablename']; //处理由于通过关联模型获取数据,会把副表字段内容归入下标为 表名_data ,重新组合 if (isset($data[ucwords($this->table_name) . "_data"])) { $data = array_merge($data, $data[ucwords($this->table_name) . "_data"]); unset($data[ucwords($this->table_name) . "_data"]); } //分页方式 if (isset($data['paginationtype'])) { //分页方式 $paginationtype = $data['paginationtype']; //自动分页字符数 $maxcharperpage = (int) $data['maxcharperpage']; } else { //默认不分页 $paginationtype = 0; } //载入字段数据处理类 if (!file_exists(RUNTIME_PATH . 'content_output.class.php')) { $this->error("请更新缓存后再操作!"); } require_cache(RUNTIME_PATH . 'content_output.class.php'); $content_output = new content_output($modelid, $catid, $Category); //获取字段类型处理以后的数据 $output_data = $content_output->get($data); $output_data['id'] = $id; extract($output_data); $this->table_name = $this->Model[$this->modelid]['tablename']; $this->db = M(ucwords($this->table_name)); //上一篇 $where = array(); $where['catid'] = $catid; $where['status'] = array("EQ", "99"); $where['id'] = array("LT", $id); $previous_page = $this->db->where($where)->order(array("id" => "DESC"))->find(); //下一篇 $where['id'] = array("GT", $id); $next_page = $this->db->where($where)->find(); if (empty($previous_page)) { $previous_page = array('title' => "第一页", 'thumb' => CONFIG_SITEURL . 'statics/images/nopic_small.gif', 'url' => 'javascript:alert(\'第一页\');'); } if (empty($next_page)) { $next_page = array('title' => "最后一页", 'thumb' => CONFIG_SITEURL . 'statics/images/nopic_small.gif', 'url' => 'javascript:alert(\'最后一页\');'); } $output_data['title'] = $title = strip_tags($title); //SEO $seo_keywords = ''; if (!empty($keywords)) { $seo_keywords = implode(',', $keywords); } $SEO = seo($catid, $title, $description, $seo_keywords); //模板处理开始 $template = $template ? $template : $CAT['setting']['show_template']; //去除模板文件后缀 $newstempid = explode(".", $template); $template = $newstempid[0]; unset($newstempid); //检测模板是否存在、不存在使用默认! $tempstatus = parseTemplateFile("Show:" . $template); if ($tempstatus == false) { //模板不存在,重新使用默认模板 $template = "show"; $tempstatus = parseTemplateFile("Show:" . $template); } //分页处理 $pages = $titles = ''; if ($paginationtype == 1) { //自动分页 if ($maxcharperpage < 10) { $maxcharperpage = 500; } //按字数分割成几页处理开始 import('Contentpage', APP_PATH . C("APP_GROUP_PATH") . '/Contents/ORG'); $contentpage = new Contentpage(); $contentfy = $contentpage->get_data($content, $maxcharperpage); //自动分页有时会造成返回空,如果返回空,就不分页了 if (!empty($contentfy)) { $content = $contentfy; } } //分配变量到模板 $this->assign($output_data); //seo分配到模板 $this->assign("SEO", $SEO); //上一篇 下一篇 $this->assign("previous_page", $previous_page); $this->assign("next_page", $next_page); //栏目ID $this->assign("catid", $catid); //模板地址 $template = $tempstatus; //分页生成处理 if ($paginationtype > 0) { //手动分页 $CONTENT_POS = strpos($content, '[page]'); if ($CONTENT_POS !== false) { $contents = array_filter(explode('[page]', $content)); $pagenumber = count($contents); if (strpos($content, '[/page]') !== false && $CONTENT_POS < 7) { $pagenumber--; } for ($i = 1; $i <= $pagenumber; $i++) { $pageurls[$i] = $this->url->show($id, $i, $catid, $data['inputtime'], $data['prefix'], '', 'edit'); } $END_POS = strpos($content, '[/page]'); if ($END_POS !== false) { if ($CONTENT_POS > 7) { $content = '[page]' . $title . '[/page]' . $content; } if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) { foreach ($m[1] as $k => $v) { $p = $k + 1; $titles[$p]['title'] = strip_tags($v); $titles[$p]['url'] = $pageurls[$p][0]; } } } $urlrules = $this->url->show($id, $page, $catid, $data['inputtime'], $data['prefix'], "", "", "URLRULE"); $urlrules = implode("~", $urlrules); define('URLRULE', $urlrules); $pages = ""; //生成分页 foreach ($pageurls as $page => $urls) { //$pagenumber 分页总数 $_GET[C("VAR_PAGE")] = $page; $pages = page($pagenumber, 1, $page, 6, C("VAR_PAGE"), '', true)->show("default"); //判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { if ($page == 1 && !empty($titles)) { $content = $title . '[/page]' . $contents[$page - 1]; } else { $content = $contents[$page - 1]; } } if ($titles) { list($title, $content) = explode('[/page]', $content); $content = trim($content); if (strpos($content, '</p>') === 0) { $content = '<p>' . $content; } if (stripos($content, '<p>') === 0) { $content = $content . '</p>'; } } //分页 $this->assign("pages", $pages); $this->assign("content", $content); $pagefile = $urls[1]; //生成路径 $this->buildHtml($pagefile, SITE_PATH . "/", $template); } $this->assign("pages", ""); return true; } } $this->assign("content", $content); //分页处理结束 $filename = $file; //生成路径 $this->buildHtml($filename, SITE_PATH . "/", $template); return true; }
public function public_view() { $url = isset($_GET['url']) && trim($_GET['url']) ? new_stripslashes(urldecode(trim($_GET['url']))) : showmessage(L('illegal_action'), HTTP_REFERER); if (!file_exists(PHPCMS_PATH . $url)) { showmessage(L('file_not_exists')); } $html = file_get_contents(PHPCMS_PATH . $url); $file_list = getcache('scan_bad_file', 'scan'); if (isset($file_list[$url]['func']) && is_array($file_list[$url]['func']) && !empty($file_list[$url]['func'])) { foreach ($file_list[$url]['func'] as $key => $val) { $func[$key] = strtolower($val[1]); } } if (isset($file_list[$url]['code']) && is_array($file_list[$url]['code']) && !empty($file_list[$url]['code'])) { foreach ($file_list[$url]['code'] as $key => $val) { $code[$key] = strtolower($val[1]); } } if (isset($func)) { $func = array_unique($func); } if (isset($code)) { $code = array_unique($code); } $show_header = true; include $this->admin_tpl('public_view'); }