/** * 添加扩展模型 * * @param array $data * @return string|TRUE */ public function add($data) { if (!$data['name'] || !$data['table']) { return lang('238'); } if (!preg_match('/^[a-z]+[a-z0-9_\\-]+$/i', $data['table']) || $this->link->where('table', $data['table'])->count_all_results($this->prefix)) { return lang('239'); } $data['setting'] = dr_array2string($data['setting']); if ($this->link->insert($this->prefix, $data)) { $id = $this->link->insert_id(); $name = 'Form_' . SITE_ID . '_' . $id; $file = FCPATH . 'omooo/controllers/admin/' . $name . '.php'; if (!file_put_contents($file, '<?php' . PHP_EOL . PHP_EOL . 'require FCPATH.\'omooo/core/D_Form.php\';' . PHP_EOL . PHP_EOL . 'class ' . $name . ' extends D_Form {' . PHP_EOL . PHP_EOL . ' public function __construct() {' . PHP_EOL . ' parent::__construct();' . PHP_EOL . ' }' . PHP_EOL . PHP_EOL . ' public function add() {' . PHP_EOL . ' $this->_addc();' . PHP_EOL . ' }' . PHP_EOL . PHP_EOL . ' public function edit() {' . PHP_EOL . ' $this->_editc();' . PHP_EOL . ' }' . PHP_EOL . PHP_EOL . ' public function index() {' . PHP_EOL . ' $this->_listc();' . PHP_EOL . ' }' . PHP_EOL . PHP_EOL . '}')) { $this->db->where('id', $id)->delete($this->prefix); return dr_lang('243', '/omooo/controllers/admin/'); } $file = FCPATH . 'omooo/controllers/' . $name . '.php'; if (!file_put_contents($file, '<?php' . PHP_EOL . PHP_EOL . 'require FCPATH.\'omooo/core/D_Form.php\';' . PHP_EOL . PHP_EOL . 'class ' . $name . ' extends D_Form {' . PHP_EOL . PHP_EOL . ' public function __construct() {' . PHP_EOL . ' parent::__construct();' . PHP_EOL . ' }' . PHP_EOL . PHP_EOL . ' public function index() {' . PHP_EOL . ' $this->_post();' . PHP_EOL . ' }' . PHP_EOL . PHP_EOL . '}')) { $this->db->where('id', $id)->delete($this->prefix); return dr_lang('243', '/omooo/controllers/'); } $sql = "\n\t\t\tCREATE TABLE IF NOT EXISTS `" . $this->prefix . '_' . $data['table'] . "` (\n\t\t\t `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t `title` varchar(255) DEFAULT NULL COMMENT '主题',\n\t\t\t `inputip` varchar(30) DEFAULT NULL COMMENT '录入者ip',\n\t\t\t `inputtime` int(10) unsigned NOT NULL COMMENT '录入时间',\n\t\t\t `displayorder` tinyint(3) NOT NULL DEFAULT '0',\n\t\t\t PRIMARY KEY `id` (`id`),\n\t\t\t KEY `inputtime` (`inputtime`),\n\t\t\t KEY `displayorder` (`displayorder`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='" . $data['name'] . "表单表';"; $this->link->query($sql); $this->db->insert('field', array('name' => '主题', 'fieldname' => 'title', 'fieldtype' => 'Text', 'relatedid' => $id, 'relatedname' => 'form-' . SITE_ID, 'isedit' => 1, 'ismain' => 1, 'ismember' => 1, 'issystem' => 1, 'issearch' => 1, 'disabled' => 0, 'setting' => dr_array2string(array('option' => array('width' => 400, 'fieldtype' => 'VARCHAR', 'fieldlength' => '255'), 'validate' => array('xss' => 1, 'required' => 1))), 'displayorder' => 0)); } return TRUE; }
/** * 添加表单 * * @param array $data * @return string|TRUE */ public function add($dir, $data) { if (!$data['name'] || !$data['table']) { return lang('332'); } // 判断表名称是否存在 if ($this->db->where('module', $dir)->where('table', $data['table'])->count_all_results('module_form')) { return lang('333'); } // 插入表单数据 $this->db->insert('module_form', array('name' => $data['name'], 'table' => $data['table'], 'module' => $dir, 'setting' => dr_array2string($data['setting']), 'disabled' => 0, 'permission' => dr_array2string($data['permission']))); // 执行成功的操作 if ($id = $this->db->insert_id()) { // 表单控制器名称 $name = 'Form_' . $data['table']; // 管理控制器 $file = FCPATH . $dir . '/controllers/admin/' . $name . '.php'; if (!file_put_contents($file, '<?php' . PHP_EOL . PHP_EOL . 'require FCPATH.\'dayrui/core/D_Admin_Form.php\';' . PHP_EOL . PHP_EOL . 'class ' . $name . ' extends D_Admin_Form {' . PHP_EOL . PHP_EOL . ' public function __construct() {' . PHP_EOL . ' parent::__construct();' . PHP_EOL . ' }' . PHP_EOL . '}')) { $this->db->where('id', $id)->delete('module_form'); return dr_lang('243', FCPATH . $dir . '/controllers/admin/'); } // 会员控制器 $file = FCPATH . $dir . '/controllers/member/' . $name . '.php'; if (!file_put_contents($file, '<?php' . PHP_EOL . PHP_EOL . 'require FCPATH.\'dayrui/core/D_Member_Form.php\';' . PHP_EOL . PHP_EOL . 'class ' . $name . ' extends D_Member_Form {' . PHP_EOL . PHP_EOL . ' public function __construct() {' . PHP_EOL . ' parent::__construct();' . PHP_EOL . ' }' . PHP_EOL . '}')) { $this->db->where('id', $id)->delete('module_form'); return dr_lang('243', FCPATH . $dir . '/controllers/member/'); } // 前端发布控制器 $file = FCPATH . $dir . '/controllers/' . $name . '.php'; if (!file_put_contents($file, '<?php' . PHP_EOL . PHP_EOL . 'require FCPATH.\'dayrui/core/D_Home_Form.php\';' . PHP_EOL . PHP_EOL . 'class ' . $name . ' extends D_Home_Form {' . PHP_EOL . PHP_EOL . ' public function __construct() {' . PHP_EOL . ' parent::__construct();' . PHP_EOL . ' }' . PHP_EOL . '}')) { $this->db->where('id', $id)->delete('module_form'); return dr_lang('243', APPPATH . 'controllers/'); } // 按站点更新模块表数据 $sql = "\n\t\t\tCREATE TABLE IF NOT EXISTS `{tablename}` (\n\t\t\t `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t `cid` int(10) unsigned NOT NULL COMMENT '内容id',\n\t\t\t `uid` mediumint(8) unsigned NOT NULL COMMENT '作者id',\n\t\t\t `author` varchar(50) NOT NULL COMMENT '作者名称',\n\t\t\t `inputip` varchar(30) DEFAULT NULL COMMENT '录入者ip',\n\t\t\t `inputtime` int(10) unsigned NOT NULL COMMENT '录入时间',\n\t\t\t `title` varchar(255) DEFAULT NULL COMMENT '内容主题',\n\t\t\t `url` varchar(255) DEFAULT NULL COMMENT '内容地址',\n\t\t\t `subject` varchar(255) DEFAULT NULL COMMENT '表单主题',\n\t\t\t PRIMARY KEY `id` (`id`),\n\t\t\t KEY `cid` (`cid`),\n\t\t\t KEY `uid` (`uid`),\n\t\t\t KEY `author` (`author`),\n\t\t\t KEY `inputtime` (`inputtime`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='" . $data['name'] . "表单数据表';"; // 获取所有站点的模块 $module = $this->ci->get_cache('module'); foreach ($module as $sid => $mod) { // 更新站点模块 if (!in_array($dir, $mod)) { continue; } // 主表名称 $table = $this->db->dbprefix($sid . '_' . $dir . '_form_' . $data['table']); $this->site[$sid]->query("DROP TABLE IF EXISTS `" . $table . "`"); $this->site[$sid]->query(str_replace('{tablename}', $table, $sql)); } // 字段入库 $this->db->insert('field', array('name' => '主题', 'fieldname' => 'subject', 'fieldtype' => 'Text', 'relatedid' => $id, 'relatedname' => 'mform-' . $this->dir, 'isedit' => 1, 'ismain' => 1, 'ismember' => 1, 'issystem' => 1, 'issearch' => 1, 'disabled' => 0, 'setting' => dr_array2string(array('option' => array('width' => 300, 'fieldtype' => 'VARCHAR', 'fieldlength' => '255'), 'validate' => array('xss' => 1, 'required' => 1))), 'displayorder' => 0)); // 查询后台模块的菜单 $menu = $this->db->where('pid<>0')->where('uri', '')->where('mark', 'module-' . $dir)->order_by('displayorder ASC,id ASC')->get('admin_menu')->row_array(); if ($menu) { // 将此表单放在模块菜单中 $this->db->insert('admin_menu', array('uri' => $this->dir . '/admin/' . strtolower($name) . '/index', 'url' => '', 'pid' => $menu['id'], 'name' => $data['name'] . '管理', 'mark' => 'module-' . $dir . '-' . $id, 'hidden' => 0, 'displayorder' => 0)); } } return FALSE; }
/** * 充值 */ public function add() { if (IS_POST) { $data = $this->input->post('data'); $value = intval($data['value']); if (!$value) { exit(dr_json(0, lang('131'), 'value')); } $this->member_model->update_score(0, $this->userinfo['uid'], $value, '', $data['note']); $this->member_model->add_notice($this->userinfo['uid'], 1, dr_lang('m-080', SITE_EXPERIENCE, $value, $this->member['username'])); exit(dr_json(1, lang('000'))); } $this->template->display('score_add.html'); }
/** * 构造函数 */ public function __construct() { parent::__construct(); $this->load->model('mform_model'); $this->load->model('module_model'); $this->dir = $this->input->get('dir'); $module = $this->get_cache('module-' . SITE_ID . '-' . $this->dir); if (!$module) { $this->admin_msg(lang('100')); } $this->mid = $module['id']; $this->template->assign('menu', $this->get_menu(array(lang('073') => 'admin/module/index', dr_lang('330', $module['name']) => 'admin/mform/index/dir/' . $this->dir, lang('add') => 'admin/mform/add/dir/' . $this->dir))); $this->template->assign(array('dir' => $this->dir, 'mid' => $this->mid, 'tpl' => $module['template'] ? $module['template'] : SITE_TEMPLATE)); }
/** * 添加模型 * * @param array $data * @return string|TRUE */ public function add($data) { if (!$data['name'] || !$data['table']) { return lang('238'); } if (in_array($data['table'], array('category', 'model')) || !preg_match('/^[a-z]+[a-z0-9_\\-]+$/i', $data['table']) || $this->db->where('table', $data['table'])->count_all_results('space_model')) { return lang('239'); } $data['setting'] = dr_array2string($data['setting']); if ($this->db->insert('space_model', $data)) { $id = $this->db->insert_id(); $file = FCPATH . 'member/controllers/Space' . $id . '.php'; if (!file_put_contents($file, '<?php class Space' . $id . ' extends M_Controller { public function __construct() { parent::__construct(); } public function add() { $this->space_content_add(); } public function edit() { $this->space_content_edit(); } public function index() { $this->space_content_index(); } }')) { $this->db->where('id', $id)->delete($this->db->dbprefix('space_model')); return dr_lang('243', '/member/controllers/'); } $sql = "\n\t\t\tCREATE TABLE IF NOT EXISTS `{tablename}` (\n\t\t\t `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t `catid` mediumint(8) unsigned NOT NULL COMMENT '栏目id',\n\t\t\t `title` varchar(255) NOT NULL COMMENT '标题',\n\t\t\t `uid` mediumint(8) unsigned NOT NULL COMMENT '作者uid',\n\t\t\t `author` varchar(50) NOT NULL COMMENT '作者',\n\t\t\t `hits` int(10) unsigned NOT NULL COMMENT '点击量',\n\t\t\t `status` tinyint(1) unsigned NOT NULL COMMENT '审核状态',\n\t\t\t `inputtime` int(10) unsigned NOT NULL COMMENT '录入时间',\n\t\t\t `updatetime` int(10) unsigned NOT NULL COMMENT '更新时间',\n\t\t\t `displayorder` tinyint(3) NOT NULL DEFAULT '0',\n\t\t\t PRIMARY KEY `id` (`id`),\n\t\t\t KEY `uid` (`uid`),\n\t\t\t KEY `hits` (`hits`),\n\t\t\t KEY `catid` (`catid`),\n\t\t\t KEY `status` (`status`),\n\t\t\t KEY `inputtime` (`inputtime`),\n\t\t\t KEY `updatetime` (`updatetime`),\n\t\t\t KEY `displayorder` (`displayorder`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='会员空间" . $data['name'] . "模型表';"; $this->db->query(str_replace('{tablename}', $this->db->dbprefix('space_' . $data['table']), $sql)); $this->db->insert('admin_menu', array('pid' => 80, 'uri' => 'member/admin/content/index/mid/' . $id, 'url' => '', 'mark' => 'space-' . $id, 'name' => $data['name'] . '管理', 'hidden' => 0, 'displayorder' => $id + 5)); $this->db->insert('member_menu', array('pid' => 26, 'uri' => 'space' . $id . '/index', 'url' => '', 'mark' => 'space-' . $id, 'name' => $data['name'] . '管理', 'hidden' => 0, 'displayorder' => $id + 5)); $this->db->insert('field', array('name' => '主题', 'fieldname' => 'title', 'fieldtype' => 'Text', 'relatedid' => $id, 'relatedname' => 'space', 'isedit' => 1, 'ismain' => 1, 'ismember' => 1, 'issystem' => 1, 'issearch' => 1, 'disabled' => 0, 'setting' => dr_array2string(array('option' => array('width' => 400, 'fieldtype' => 'VARCHAR', 'fieldlength' => '255'), 'validate' => array('xss' => 1, 'required' => 1))), 'displayorder' => 0)); } return TRUE; }
/** * 充值 */ public function add() { $uid = (int) $this->input->get('uid'); $userinfo = $this->member_model->get_member($uid); if (!$userinfo) { exit(dr_json(1, lang('130'))); } if (IS_POST) { $data = $this->input->post('data'); $value = intval($data['value']); if (!$value) { exit(dr_json(0, lang('131'), 'value')); } $this->pay_model->add($uid, $data['value'], $data['note']); $this->member_model->add_notice($this->userinfo['uid'], 1, dr_lang('m-080', SITE_MONEY, $value, $this->member['username'])); exit(dr_json(1, lang('000'))); } $this->template->assign('userinfo', $userinfo); $this->template->display('score_add.html'); }
/** * tag */ protected function _tag() { $code = $this->input->get('name', TRUE); $this->load->model('tag_model'); $data = $this->tag_model->tag($code); if (!$data) { $this->msg(dr_lang('mod-33', $code)); } $urlrule = $this->module['setting']['tag']['url_page'] ? $this->module['setting']['tag']['url_page'] : 'index.php?c=tag&name={tag}&page={page}'; $urlrule = $this->module['url'] . str_replace('{tag}', $code, $urlrule); $sql = 'SELECT * FROM ' . $this->content_model->prefix . ' WHERE '; $tag = $where = array(); foreach ($data as $t) { $tag[] = $t['name']; $where[] = '`title` LIKE "%' . $t['name'] . '%" OR `keywords` LIKE "%' . $t['name'] . '%"'; } $tag = implode(',', $tag); $sql .= implode(' OR ', $where) . ' ORDER BY `updatetime` DESC'; $this->template->assign(array('tag' => $tag, 'list' => $data, 'tagsql' => $sql, 'urlrule' => $urlrule, 'pagesize' => $this->module['setting']['tag']['pagesize'] ? $this->module['setting']['tag']['pagesize'] : 20, 'meta_title' => $tag . (SITE_SEOJOIN ? SITE_SEOJOIN : '_') . $this->module['name'], 'meta_keywords' => $this->module['setting']['seo']['meta_keywords'], 'meta_description' => $this->module['setting']['seo']['meta_description'])); $this->template->display('tag.html'); }
/** * 数据维护 */ public function index() { $list = $this->siteid ? $this->system_model->get_site_table($this->siteid) : $this->system_model->get_system_table(); if (IS_POST) { $tables = $this->input->post('select'); if (!$tables) { $this->admin_msg(lang('196')); } switch ((int) $this->input->post('action')) { case 1: // 优化表 foreach ($tables as $table) { $this->link->query("OPTIMIZE TABLE `{$table}`"); } $result = lang('000'); $this->system_log('优化数据表'); // 记录日志 break; case 2: // 修复表 foreach ($tables as $table) { $this->link->query("REPAIR TABLE `{$table}`"); } $result = lang('000'); $this->system_log('修复数据表'); // 记录日志 break; } } $menu = array(); $menu[lang('194')] = 'admin/db/index'; foreach ($this->SITE as $id => $s) { $menu[dr_lang('384', $id)] = 'admin/db/index/siteid/' . $id; } $this->template->assign(array('menu' => $this->get_menu($menu), 'list' => $list, 'result' => $result)); $this->template->display('db_index.html'); }
/** * 添加表单 * * @param array $data * @return string|TRUE */ public function add($data) { $this->link->insert($this->table, array('name' => $data['name'] ? $data['name'] : 'form', 'setting' => dr_array2string($data['setting']), 'disabled' => 0, 'permission' => dr_array2string($data['permission']))); if ($id = $this->link->insert_id()) { $name = 'Form_' . SITE_ID . '_' . $id; // 管理控制器 $file = FCPATH . $this->dir . '/controllers/admin/' . $name . '.php'; if (!file_put_contents($file, '<?php' . PHP_EOL . PHP_EOL . 'require FCPATH.\'omooo/core/D_Admin_Form.php\';' . PHP_EOL . PHP_EOL . 'class ' . $name . ' extends D_Admin_Form {' . PHP_EOL . PHP_EOL . ' public function __construct() {' . PHP_EOL . ' parent::__construct();' . PHP_EOL . ' }' . PHP_EOL . '}')) { $this->link->where('id', $id)->delete($this->table); return dr_lang('243', FCPATH . $this->dir . '/controllers/admin/'); } // 会员控制器 $file = FCPATH . $this->dir . '/controllers/member/' . $name . '.php'; if (!file_put_contents($file, '<?php' . PHP_EOL . PHP_EOL . 'require FCPATH.\'omooo/core/D_Member_Form.php\';' . PHP_EOL . PHP_EOL . 'class ' . $name . ' extends D_Member_Form {' . PHP_EOL . PHP_EOL . ' public function __construct() {' . PHP_EOL . ' parent::__construct();' . PHP_EOL . ' }' . PHP_EOL . '}')) { $this->link->where('id', $id)->delete($this->table); return dr_lang('243', FCPATH . $this->dir . '/controllers/member/'); } // 前端发布控制器 $file = FCPATH . $this->dir . '/controllers/' . $name . '.php'; if (!file_put_contents($file, '<?php' . PHP_EOL . PHP_EOL . 'require FCPATH.\'omooo/core/D_Home_Form.php\';' . PHP_EOL . PHP_EOL . 'class ' . $name . ' extends D_Home_Form {' . PHP_EOL . PHP_EOL . ' public function __construct() {' . PHP_EOL . ' parent::__construct();' . PHP_EOL . ' }' . PHP_EOL . '}')) { $this->link->where('id', $id)->delete($this->table); return dr_lang('243', APPPATH . 'controllers/'); } // 主表sql $this->link->query("DROP TABLE IF EXISTS `" . $this->table . '_' . $id . "`"); $sql = "\n\t\t\tCREATE TABLE IF NOT EXISTS `" . $this->table . '_' . $id . "` (\n\t\t\t `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t `cid` int(10) unsigned NOT NULL COMMENT '内容id',\n\t\t\t `uid` mediumint(8) unsigned NOT NULL COMMENT '作者id',\n\t\t\t `author` varchar(50) NOT NULL COMMENT '作者名称',\n\t\t\t `inputip` varchar(30) DEFAULT NULL COMMENT '录入者ip',\n\t\t\t `inputtime` int(10) unsigned NOT NULL COMMENT '录入时间',\n\t\t\t `title` varchar(255) DEFAULT NULL COMMENT '内容主题',\n\t\t\t `url` varchar(255) DEFAULT NULL COMMENT '内容地址',\n\t\t\t `subject` varchar(255) DEFAULT NULL COMMENT '表单主题',\n\t\t\t PRIMARY KEY `id` (`id`),\n\t\t\t KEY `cid` (`cid`),\n\t\t\t KEY `uid` (`uid`),\n\t\t\t KEY `author` (`author`),\n\t\t\t KEY `inputtime` (`inputtime`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='" . $data['name'] . "表单数据表';"; $this->link->query($sql); $this->db->insert('field', array('name' => '主题', 'fieldname' => 'subject', 'fieldtype' => 'Text', 'relatedid' => $id, 'relatedname' => 'mform-' . $this->dir . '-' . SITE_ID, 'isedit' => 1, 'ismain' => 1, 'ismember' => 1, 'issystem' => 1, 'issearch' => 1, 'disabled' => 0, 'setting' => dr_array2string(array('option' => array('width' => 300, 'fieldtype' => 'VARCHAR', 'fieldlength' => '255'), 'validate' => array('xss' => 1, 'required' => 1))), 'displayorder' => 0)); // 查询后台模块的菜单 $menu = $this->db->where('pid<>0')->where('uri', '')->where('mark', 'module-' . $this->dir)->order_by('displayorder ASC,id ASC')->get('admin_menu')->row_array(); if ($menu) { // 将此表单放在模块菜单中 $this->db->insert('admin_menu', array('uri' => $this->dir . '/admin/' . strtolower($name) . '/index', 'url' => '', 'pid' => $menu['id'], 'name' => $data['name'] . '管理', 'mark' => 'module-' . $this->dir . '-' . SITE_ID . '-' . $id, 'displayorder' => 0)); } } return FALSE; }
/** * 重发邮件审核 */ public function resend() { if ($this->member['groupid'] != 1) { $this->member_msg(lang('m-233')); } if ($this->get_cache('MEMBER', 'setting', 'regverify') != 1) { $this->member_msg(lang('m-230')); } if (get_cookie('resend') && $this->member['randcode']) { $this->member_msg(lang('m-232')); } $url = MEMBER_URL . 'index.php?c=login&m=verify&code=' . $this->member_model->get_encode($this->uid); $this->sendmail($this->member['email'], lang('m-191'), dr_lang('m-192', $this->member['username'], $url, $url, $this->input->ip_address())); $this->input->set_cookie('resend', $this->uid, 3600); $this->member_msg(dr_lang('m-231', $this->member['email']), dr_url('home/index'), 1); }
/** * 添加微博 * * @param uid 发布者 * @param content 内容 * @param attach 附件 * @param source 来源 * @param repost 转发id */ public function add_sns($uid, $content, $attach, $source = 0, $repost = 0) { // 判断uid是否存在 if (!$uid) { return FALSE; } // 查询用户名 if ($uid == $this->uid) { $username = $this->member['username']; } else { $m = dr_member_info($uid); $username = $m['username']; unset($m); } // 来源 if (!$source) { if ($this->agent->is_mobile()) { $source = lang('m-247'); } else { $source = lang('m-246'); } } // 过滤非法内容 $content = dr_preg_html($content) . ' '; // 提取URL链接 $content = preg_replace_callback('/((?:https?|mailto|ftp):\\/\\/([^\\x{2e80}-\\x{9fff}\\s<\'\\"“”‘’,。}]*)?)/u', '_format_feed_content_url_length', $content); // 提取@ $user = array(); if (preg_match_all('/@(.+) /U', $content, $match)) { $data = array_unique($match[1]); foreach ($data as $t) { $m = $this->db->select('uid')->where('username', $t)->get('member')->row_array(); if ($m) { $user[$t] = $m['uid']; $content = str_replace('@' . $t . ' ', ' <a href="javascript:;" uid="' . $m['uid'] . '" event-node="face_card" target="_blank">@' . $t . '</a> ', $content); } } unset($data, $m); } // 提取话题 $topic = array(); if (preg_match_all('/#(.+)#/U', $content, $match)) { $data = array_unique($match[1]); foreach ($data as $t) { // 查询话题是否存在,不存在就创建 $row = $this->db->where('name', $t)->get('sns_topic')->row_array(); if ($row) { $tid = $row['id']; } else { $this->db->insert('sns_topic', array('name' => $t, 'uid' => $uid, 'username' => $username, 'count' => 0, 'inputtime' => SYS_TIME)); $tid = $this->db->insert_id(); } $topic[] = $tid; $content = str_replace('#' . $t . '#', '<a href="[TOPIC-URL-' . $tid . ']" target="_blank">#' . $t . '#</a> ', $content); } unset($data); } $content = trim($content); if (!$content) { return FALSE; } // 是转发文章 if ($repost) { $row = $this->db->where('id', $repost)->get('sns_feed')->row_array(); if ($row) { $repost = $row['repost_id'] ? $row['repost_id'] : $row['id']; // 统计原文转发数量 $this->db->where('id', $repost)->set('repost', 'repost+1', FALSE)->update('sns_feed'); // 清除缓存数据 $this->ci->set_cache_data('sns-feed-' . $repost, '', 1); } else { $repost = 0; } } $images = $attach ? trim($attach, '|') : ''; // 插入的数据 $this->db->insert('sns_feed', array('uid' => $uid, 'username' => $username, 'comment' => 0, 'repost' => 0, 'digg' => 0, 'content' => $content, 'repost_id' => $repost, 'source' => $source, 'images' => $images, 'inputip' => $this->input->ip_address(), 'inputtime' => SYS_TIME)); $id = $this->db->insert_id(); // 保存附件 if ($images) { $this->load->model('attachment_model'); $this->attachment_model->replace_attach($uid, $this->db->dbprefix('sns_feed') . '-' . $id, explode('|', $images)); } // 更新话题关系表 if ($topic) { foreach ($topic as $tid) { $this->db->insert('sns_topic_index', array('fid' => $id, 'tid' => $tid)); $this->db->where('id', $tid)->set('count', 'count+1', FALSE)->update('sns_topic'); } } // 给@的人发送提醒 if ($user) { $this->add_notice($user, 2, dr_lang('m-248', $username, dr_sns_feed_url($id))); } // 给作者发送转发的提醒 if ($repost) { $this->add_notice($row['uid'], 2, dr_lang('m-252', $username, dr_sns_feed_url($id))); } // 分数奖励 if ($uid == $this->uid) { if ($this->member_rule['feed_experience']) { $this->update_score(0, $uid, (int) $this->member_rule['feed_experience'], '', "lang,m-212"); } if ($this->member_rule['feed_score']) { $this->update_score(1, $uid, (int) $this->member_rule['feed_score'], '', "lang,m-212"); } } return TRUE; }
/** * 发送给会员 */ public function member() { $data = $this->cache->file->get($this->cache_file); if (!$data) { $this->admin_msg(lang('134')); } $page = max((int) $this->input->get('page'), 1); $psize = 5; $tpage = ceil($data['total'] / $psize); if ($data['groupid']) { $this->db->where('groupid', $data['groupid']); } $member = $this->db->select('email')->order_by('uid desc')->limit($psize, $psize * ($page - 1))->get('member')->result_array(); if ($member) { foreach ($member as $t) { $this->member_model->sendmail($t['email'], $data['title'], $data['message']); } $this->admin_msg(dr_lang('348', $data['total'], $tpage . '/' . $page), dr_url('mail/member', array('page' => $page + 1)), 2, 1); } else { $this->cache->file->delete($this->cache_file); $this->admin_msg(lang('000'), dr_url('mail/send'), 1); } }
/** * 提交内容 */ protected function _post() { if (!$this->form['setting']['post']) { if (IS_POST) { exit($this->call_msg(lang('m-114'))); } else { $this->msg(lang('m-114')); } } if (IS_POST) { if ($this->form['setting']['code'] && !$this->check_captcha('code')) { exit($this->call_msg(lang('m-000'))); } $data = $this->validate_filter($this->form['field']); // 验证出错信息 if (isset($data['error'])) { exit($this->call_msg($data['msg'])); } $data['inputip'] = $this->input->ip_address(); $data['inputtime'] = SYS_TIME; $data['displayorder'] = 0; $this->load->model('form_model'); $this->form_model->new_addc($this->form['table'], $data); if ($this->form['setting']['send'] && $this->form['setting']['template']) { // 兼容php5.5 if (version_compare(PHP_VERSION, '5.5.0') >= 0) { $rep = new php5replace($data[1]); $content = preg_replace_callback('#{(.*)}#U', array($rep, 'php55_replace_data'), $this->form['setting']['template']); $content = preg_replace_callback('#{([a-z_0-9]+)\\((.*)\\)}#Ui', array($rep, 'php55_replace_function'), $content); unset($rep); } else { @extract($data[1]); unset($data[1]); $content = preg_replace("/{(.*)}/Ue", "\$\\1", $this->form['setting']['template']); $content = preg_replace('#{([a-z_0-9]+)\\((.*)\\)}#Uie', "\\1(dr_safe_replace('\\2'))", $content); } $this->sendmail_queue($this->form['setting']['send'], dr_lang('m-306', $this->form['name']), nl2br($content)); } $this->call_msg(lang('m-305'), 1); } else { $tpl = FCPATH . 'dayrui/templates/' . SITE_TEMPLATE . '/form_' . $this->form['table'] . '.html'; $this->template->assign(array('form' => $this->form, 'code' => $this->form['setting']['code'], 'myfield' => $this->field_input($this->form['field']), 'meta_title' => $this->form['name'] . SITE_SEOJOIN . SITE_NAME)); $this->template->display(is_file($tpl) ? basename($tpl) : 'form.html'); } }
/** * 字段输出格式化 * * @param array $fields 可用字段集 * @param array $data 数据 * @param intval $curpage 分页id * @param string $dirname 模块目录 * @return string */ public function field_format_value($fields, $data, $curpage = 1, $dirname = NULL) { if (!$fields || !$data || !is_array($data)) { return $data; } foreach ($data as $n => $value) { if (isset($fields[$n])) { $format = dr_get_value($fields[$n]['fieldtype'], $value, $fields[$n]['setting']['option'], $dirname); if ($format !== $value) { $data['_' . $n] = $value; $data[$n] = $format; } elseif (SITE_MOBILE !== TRUE && $n == 'content' && $fields[$n]['fieldtype'] == 'Ueditor' && strpos($value, '<div name="dr_page_break" class="pagebreak">') !== FALSE && preg_match_all('/<div name="dr_page_break" class="pagebreak">(.*)<\\/div>/Us', $value, $match) && preg_match('/(.*)<div name="dr_page_break"/Us', $value, $frist)) { // 编辑器分页 老版本 $page = 1; $content = $title = array(); $data['_' . $n] = $value; $content[$page]['title'] = dr_lang('m-131', $page); $content[$page]['body'] = $frist[1]; foreach ($match[0] as $i => $t) { $page++; $value = str_replace($content[$page - 1]['body'] . $t, '', $value); if (preg_match('/(.*)<div name="dr_page_break"/Us', $value, $match_body)) { $body = $match_body[1]; } else { $body = $value; } $title[$page] = trim($match[1][$i]); $content[$page]['title'] = trim($match[1][$i]) ? trim($match[1][$i]) : dr_lang('m-131', $page); $content[$page]['body'] = $body; } $page = max(1, min($page, $curpage)); $data[$n] = $content[$page]['body']; $data[$n . '_page'] = $content; $data[$n . '_title'] = $title[$page]; } elseif (SITE_MOBILE !== TRUE && $n == 'content' && $fields[$n]['fieldtype'] == 'Ueditor' && strpos($value, '<p class="pagebreak">') !== FALSE && preg_match_all('/<p class="pagebreak">(.*)<\\/p>/Us', $value, $match) && preg_match('/(.*)<p class="pagebreak">/Us', $value, $frist)) { // 编辑器分页 新版 $page = 1; $content = $title = array(); $data['_' . $n] = $value; $content[$page]['title'] = dr_lang('m-131', $page); $content[$page]['body'] = $frist[1]; foreach ($match[0] as $i => $t) { $page++; $value = str_replace($content[$page - 1]['body'] . $t, '', $value); if (preg_match('/(.*)<p class="pagebreak"/Us', $value, $match_body)) { $body = $match_body[1]; } else { $body = $value; } $title[$page] = trim($match[1][$i]); $content[$page]['title'] = trim($match[1][$i]) ? trim($match[1][$i]) : dr_lang('m-131', $page); $content[$page]['body'] = $body; } $page = max(1, min($page, $curpage)); $data[$n] = $content[$page]['body']; $data[$n . '_page'] = $content; $data[$n . '_title'] = $title[$page]; } } elseif (strpos($n, '_lng') !== FALSE) { // 百度地图 $name = str_replace('_lng', '', $n); if (isset($data[$name . '_lat'])) { $data[$name] = ''; if ($data[$name . '_lng'] > 0 || $data[$name . '_lat'] > 0) { $data[$name] = $data[$name . '_lng'] . ',' . $data[$name . '_lat']; } } } } return $data; }
protected function _add($data) { // 入库 $table = $this->db->dbprefix($this->table); $data[1]['tableid'] = 0; $this->link->insert($table, $data[1]); // if (($id = $this->link->insert_id()) && ($user = dr_member_info($this->cdata['uid']))) { // 无限分表 $tableid = floor($id / 50000); $this->link->where('id', $id)->update($table, array('tableid' => $tableid)); if (!$this->link->query("SHOW TABLES LIKE '" . $table . '_data_' . $tableid . "'")->row_array()) { // 附表不存在时创建附表 $sql = $this->link->query("SHOW CREATE TABLE `" . $table . "_data_0`")->row_array(); $this->link->query(str_replace(array($sql['Table'], 'CREATE TABLE '), array($table . '_data_' . $tableid, 'CREATE TABLE IF NOT EXISTS '), $sql['Create Table'])); } $data[0]['id'] = $id; $data[0]['cid'] = $data[1]['cid']; $data[0]['uid'] = $data[1]['uid']; $this->db->replace($table . '_data_' . $tableid, $data[0]); // 通知功能 $murl = dr_member_url(APP_DIR . '/' . $this->router->class . '/listc', array('cid' => $this->cdata['id'])); $title = dr_lang('mod-106', $this->cdata['title'], $this->form['name']); // 邮件提醒 if ($this->form['setting']['email']) { $this->sendmail_queue($user['email'], $title, dr_lang('mod-107', $this->cdata['title'], $this->form['name'], $murl, $murl)); } // 短信提醒 if ($this->form['setting']['sms'] && $user['phone']) { $this->member_model->sendsms($user['phone'], $title); } // 添加提醒 $this->member_model->add_notice($this->cdata['uid'], 3, '<a href="' . $murl . '">' . $title . '</a>'); // 更新模块表的统计值 $this->link->where('id', $this->cid)->set($this->fid . '_total', $this->fid . '_total + 1', FALSE)->update(SITE_ID . '_' . APP_DIR); } return $id; }
/** * 下载文件 */ public function file() { $id = (int) $this->input->get('id'); $info = get_attachment($id); $this->template->admin(); if (!$info) { $this->admin_msg(lang('m-326')); } // 是否允许下载附件 if (!$this->member['adminid'] && !$this->member_rule['is_download']) { $this->admin_msg(lang('m-322')); } // 虚拟币与经验值检查 $mark = 'attachment-' . $id; $table = $this->db->dbprefix('member_scorelog_' . (int) substr((string) $this->uid, -1, 1)); if ($this->member_rule['download_score'] && !$this->db->where('type', 1)->where('mark', $mark)->count_all_results($table)) { // 虚拟币不足时,提示错误 if ($this->member_rule['download_score'] + $this->member['score'] < 0) { $this->admin_msg(dr_lang('m-324', SITE_SCORE, abs($this->member_rule['download_score']))); } // 虚拟币扣减 $this->member_model->update_score(1, $this->uid, (int) $this->member_rule['download_score'], $mark, "lang,m-325"); } if ($this->member_rule['download_experience'] && !$this->db->where('type', 0)->where('mark', $mark)->count_all_results($table)) { // 经验值扣减 $this->member_model->update_score(0, $this->uid, (int) $this->member_rule['download_experience'], $mark, "lang,m-325"); } $file = $info['attachment']; $this->db->where('id', $id)->set('download', 'download+1', FALSE)->update('attachment'); if (strpos($file, ':/')) { //远程文件 header("Location: {$file}"); } else { //本地文件 $file = FCPATH . str_replace('..', '', $file); $name = urlencode($info['filename'] . '.' . $info['fileext']); $this->load->helper('download'); force_download($name, file_get_contents($file)); } }
public function domain() { $ip = $this->_get_server_ip(); $domain = $this->input->get('domain'); if (gethostbyname($domain) != $ip) { exit(dr_lang('html-731', $domain, $ip)); } exit(''); }
/** * 更新URL */ public function url() { $cfile = SITE_ID . APP_DIR . $this->uid . $this->input->ip_address() . '_content_url'; if (IS_POST) { $catid = $this->input->post('catid'); $query = $this->link; if (count($catid) > 1 || $catid[0]) { $query->where_in('catid', $catid); } $data = $query->select('id')->get($this->content_model->prefix . '_index')->result_array(); if ($data) { $id = array(); foreach ($data as $t) { $id[] = $t['id']; } $this->cache->file->save($cfile, $id, 7200); // 缓存搜索结果->id $this->mini_msg(dr_lang('132', count($id)), dr_url(APP_DIR . '/home/url', array('todo' => 1)), 2); } else { $this->mini_msg(lang('133')); } } if ($this->input->get('todo')) { $id = $this->cache->file->get($cfile); // 取缓存搜索结果->id if (!$id) { $this->mini_msg(lang('134')); } $page = max(1, (int) $this->input->get('page')); $psize = 50; $total = count($id); $tpage = ceil($total / $psize); // 总页数 if ($page > $tpage) { // 更新完成删除缓存 $this->cache->file->delete($cfile); $this->mini_msg(lang('360'), NULL, 1); } $module = $this->get_cache('module-' . SITE_ID . '-' . APP_DIR); $table = $this->content_model->prefix; $data = $this->link->where_in('id', $id)->limit($psize, $psize * ($page - 1))->order_by('id DESC')->get($table)->result_array(); foreach ($data as $t) { $url = dr_show_url($module, $t); $this->link->update($table, array('url' => $url), 'id=' . $t['id']); if ($module['extend']) { $extend = $this->link->where('cid', $t['id'])->order_by('id DESC')->get($table . '_extend')->result_array(); if ($extend) { foreach ($extend as $e) { $url = dr_extend_url($module, $e); $this->link->update($table . '_extend', array('url' => $url), 'id=' . (int) $e['id']); } } } } $this->mini_msg(dr_lang('135', "{$tpage}/{$page}"), dr_url(APP_DIR . '/home/url', array('todo' => 1, 'page' => $page + 1)), 2, 0); } else { $this->template->assign(array('menu' => $this->get_menu(array(lang('136') => APP_DIR . '/admin/home/url', lang('001') => 'admin/module/cache')), 'select' => $this->select_category($this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category'), 0, 'id="dr_synid" name=\'catid[]\' multiple style="width:200px;height:250px;"', ''))); $this->template->display('content_url.html'); } }
/** * 添加空间模型内容 */ protected function space_content_add() { $this->_is_space(); $mid = (int) str_replace('space', '', $this->router->class); $model = $this->get_cache('space-model', $mid); if (!$model) { $this->member_msg(lang('m-290')); } if (!$model['setting'][$this->markrule]['use']) { $this->member_msg(lang('m-307')); } $this->load->model('space_content_model'); $this->load->model('space_category_model'); $category = $this->space_category_model->get_data($mid); $this->space_content_model->tablename = $this->db->dbprefix('space_' . $model['table']); // 虚拟币检查 $score = (int) $model['setting'][$this->markrule]['score']; if ($score && $score + $this->member['score'] < 0) { $this->member_msg(dr_lang('m-302', abs($score), $this->member['score'])); } // 日投稿上限检查 if ($model['setting'][$this->markrule]['postnum']) { $total = $this->db->where('uid', $this->uid)->where('DATEDIFF(from_unixtime(inputtime),now())=0')->count_all_results($this->space_content_model->tablename); if ($total >= $model['setting'][$this->markrule]['postnum']) { $this->member_msg(dr_lang('m-287', $model['setting'][$this->markrule]['postnum'])); } } // 投稿总数检查 if ($model['setting'][$this->markrule]['postcount']) { $total = $this->db->where('uid', $this->uid)->count_all_results($this->space_content_model->tablename); if ($total >= $model['setting'][$this->markrule]['postcount']) { $this->member_msg(dr_lang('m-288', $model['setting'][$this->markrule]['postcount'])); } } if (IS_POST) { // 栏目参数 $catid = (int) $this->input->post('catid'); // 设置uid便于校验处理 $_POST['data']['uid'] = $this->uid; $_POST['data']['author'] = $this->member['username']; $_POST['data']['inputtime'] = $_POST['data']['updatetime'] = SYS_TIME; $data = $this->validate_filter($model['field']); // 验证出错信息 if (isset($data['error'])) { $error = $data; $data = $this->input->post('data', TRUE); } elseif (!$catid) { $data = $this->input->post('data', TRUE); $error = array('error' => 'catid', 'msg' => lang('m-300')); } elseif ($category[$catid]['child'] || $category[$catid]['modelid'] != $mid) { $data = $this->input->post('data', TRUE); $error = array('error' => 'catid', 'msg' => lang('m-301')); } else { // 设定文档默认值 $data[1]['uid'] = $this->uid; $data[1]['catid'] = $catid; $data[1]['status'] = (int) $model['setting'][$this->markrule]['verify'] ? 0 : 1; $data[1]['author'] = $this->member['username']; $data[1]['inputtime'] = $data[1]['updatetime'] = SYS_TIME; $data[1]['displayorder'] = $data[1]['hits'] = 0; // 发布文档 if (($id = $this->space_content_model->add($data[1])) != FALSE) { $mark = $this->space_content_model->tablename . '-' . $id; if ($data[1]['status']) { // 积分处理 $experience = (int) $model['setting'][$this->markrule]['experience']; if ($experience) { $this->member_model->update_score(0, $this->uid, $experience, $mark, "lang,m-151,{$category[$catid]['name']}", 1); } // 虚拟币处理 $score = (int) $model['setting'][$this->markrule]['score']; if ($score) { $this->member_model->update_score(1, $this->uid, $score, $mark, "lang,m-151,{$category[$catid]['name']}", 1); } } // 附件归档到文档 $this->attachment_handle($this->uid, $mark, $model['field']); $this->attachment_replace($this->uid, $id, $this->space_content_model->tablename); $this->member_msg(lang('000'), dr_member_url($this->router->class . '/index'), 1); } } if (IS_AJAX) { exit(dr_json(0, $error['msg'], $error['error'])); } $data = $data[1]; unset($data['id']); } $this->template->assign(array('purl' => dr_url($this->router->class . '/add'), 'error' => $error, 'verify' => 0, 'select' => $this->select_space_category($category, (int) $data['catid'], 'name=\'catid\'', NULL, 1), 'listurl' => dr_url($this->router->class . '/index'), 'myfield' => $this->field_input($model['field'], $data, TRUE), 'meta_name' => lang('m-299'), 'model_name' => $model['name'], 'result_error' => $error)); $this->template->display(is_file(FCPATH . 'member/templates/' . MEMBER_TEMPLATE . '/space_' . $model['table'] . '_add.html') ? 'space_' . $model['table'] . '_add.html' : 'space_content_add.html'); }
/** * 注册 */ public function index() { $MEMBER = $this->get_cache('MEMBER'); // 判断是否开启注册 if (!$MEMBER['setting']['register']) { $this->member_msg(lang('m-016')); } // 已经登录不允许注册 if ($this->member) { $this->member_msg(lang('m-017')); } if (IS_POST) { $data = $this->input->post('data', TRUE); $back_url = $_POST['back'] ? urldecode($this->input->post('back')) : ''; if ($MEMBER['setting']['regcode'] && !$this->check_captcha('code')) { $error = array('name' => 'code', 'msg' => lang('m-000')); } elseif (!$data['password']) { $error = array('name' => 'password', 'msg' => lang('m-018')); } elseif ($data['password'] !== $data['password2']) { $error = array('name' => 'password2', 'msg' => lang('m-019')); } elseif ($result = $this->is_username($data['username'])) { $error = array('name' => 'username', 'msg' => $result); } elseif ($result = $this->is_email($data['email'])) { $error = array('name' => 'email', 'msg' => $result); } else { $this->hooks->call_hook('member_register_before', $data); // 注册之前挂钩点 $id = $this->member_model->register($data); if ($id > 0) { // 注册成功 $this->hooks->call_hook('member_register_after', $data); // 注册之后挂钩点 $this->member_msg(lang('m-020'), $back_url && strpos($back_url, 'register') === FALSE ? $back_url : dr_url('login/index'), 1); } elseif ($id == -1) { $error = array('name' => 'username', 'msg' => dr_lang('m-021', $data['username'])); } elseif ($id == -2) { $error = array('name' => 'email', 'msg' => lang('m-011')); } elseif ($id == -3) { $error = array('name' => 'email', 'msg' => dr_lang('m-022', $data['email'])); } elseif ($id == -4) { $error = array('name' => 'username', 'msg' => lang('m-023')); } elseif ($id == -5) { $error = array('name' => 'username', 'msg' => lang('m-024')); } elseif ($id == -6) { $error = array('name' => 'username', 'msg' => lang('m-025')); } elseif ($id == -7) { $error = array('name' => 'username', 'msg' => lang('m-026')); } elseif ($id == -8) { $error = array('name' => 'username', 'msg' => lang('m-027')); } elseif ($id == -9) { $error = array('name' => 'username', 'msg' => lang('m-028')); } } } else { $data = array(); $error = ''; $back_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; } $this->template->assign(array('data' => $data, 'code' => $MEMBER['setting']['regcode'], 'back_url' => $back_url, 'meta_name' => lang('m-029'), 'result_error' => $error)); $this->template->display('register.html'); }
public function pay_for_online($id) { if (!$id) { return NULL; } // 查询支付记录 $data = $this->db->where('id', $id)->where('uid', $this->uid)->where('status', 0)->select('value,type,order')->limit(1)->get('member_paylog_' . $this->member['tableid'])->row_array(); if (!$data) { return NULL; } // 判断订单是否支付过,否则作废 if ($data['order']) { $sn = 'FC-' . $id . '-' . $this->uid . '-' . strtoupper($data['module']) . '-' . $data['order']; $title = dr_lang('m-180', strtoupper($data['module']) . '-' . $data['order']); } else { $sn = 'FC-' . $id . '-' . $this->uid; $title = lang('m-179'); } $money = $data['value']; require_once FCPATH . 'member/pay/' . $data['type'] . '/pay.php'; return $result; //return method_exists($this, '_get_'.$data['type']) ? call_user_func_array(array($this, '_get_'.$data['type']), array($id, $data['value'], $title, $sn)) : ''; }
/** * 模块栏目SEO信息 * * @param array $mod * @param array $cat * @param intval $page * @return array */ function dr_category_seo($mod, $cat, $page = 1) { $seo = array(); $cat['page'] = $page; $cat['join'] = SITE_SEOJOIN ? SITE_SEOJOIN : '_'; $cat['name'] = $cat['catname'] = dr_get_cat_pname($mod, $cat, $cat['join']); $cat['modulename'] = $cat['modname'] = $mod['name']; $meta_title = $cat['setting']['seo']['list_title'] ? $cat['setting']['seo']['list_title'] : '[' . dr_lang('m-214', '{page}') . '{join}]{modulename}{join}{SITE_NAME}'; if ($page > 1) { $meta_title = str_replace(array('[', ']'), '', $meta_title); } else { $meta_title = preg_replace('/\\[.+\\]/U', '', $meta_title); } // 兼容php5.5 if (version_compare(PHP_VERSION, '5.5.0') >= 0) { $rep = new php5replace($cat); $seo['meta_title'] = preg_replace_callback('#{([a-z_0-9]+)}#U', array($rep, 'php55_replace_data'), $meta_title); $seo['meta_title'] = preg_replace_callback('#{([A-Z_]+)}#U', array($rep, 'php55_replace_var'), $seo['meta_title']); $seo['meta_keywords'] = preg_replace_callback('#{([a-z_0-9]+)}#U', array($rep, 'php55_replace_data'), $cat['setting']['seo']['list_keywords']); $seo['meta_keywords'] = preg_replace_callback('#{([A-Z_]+)}#U', array($rep, 'php55_replace_var'), $seo['meta_keywords']); $seo['meta_description'] = preg_replace_callback('#{([a-z_0-9]+)}#U', array($rep, 'php55_replace_data'), $cat['setting']['seo']['list_description']); $seo['meta_description'] = preg_replace_callback('#{([A-Z_]+)}#U', array($rep, 'php55_replace_var'), $seo['meta_description']); unset($rep); } else { $seo['meta_title'] = preg_replace('#{([a-z_0-9]+)}#Ue', "\$cat[\\1]", $meta_title); $seo['meta_title'] = preg_replace('#{([A-Z_]+)}#Ue', "\\1", $seo['meta_title']); $seo['meta_keywords'] = preg_replace('#{([a-z_0-9]+)}#Ue', "\$cat[\\1]", $cat['setting']['seo']['list_keywords']); $seo['meta_keywords'] = preg_replace('#{([A-Z_]+)}#Ue', "\\1", $seo['meta_keywords']); $seo['meta_description'] = preg_replace('#{([a-z_0-9]+)}#Ue', "\$cat[\\1]", $cat['setting']['seo']['list_description']); $seo['meta_description'] = preg_replace('#{([A-Z_]+)}#Ue', "\\1", $seo['meta_description']); } $seo['meta_description'] = htmlspecialchars(dr_clearhtml($data['description'])); return $seo; }
/** * 发布 */ public function add() { $did = (int) $this->input->get('did'); $catid = (int) $this->input->get('catid'); $module = $this->get_cache('module-' . SITE_ID . '-' . APP_DIR); if (!$this->_module_post_catid($module)) { $this->member_msg(lang('mod-15')); } // 栏目选择判断 $isselect = isset($module['setting']['postselect']) && $module['setting']['postselect'] ? 0 : 1; if (!$isselect && ($catid == 0 || $module['category'][$catid]['child'])) { $level = $module['category_level'] + 1; $cpids = substr($module['category'][$catid]['pids'], 2); $value = !$cpids ? '' : '["' . str_replace(',', '","', $cpids) . '","' . $catid . '"]'; $select = ''; for ($i = 1; $i <= $level; $i++) { $select .= '<ul iid=' . ($i - 1) . ' class="sortList_step finecms-select-category" ' . ($i > 1 ? 'style="display:none"' : '') . '></ul>'; } $select .= ' <script type="text/javascript"> $(function(){ var $ld5 = $(".finecms-select-category"); $ld5.ld({ ajaxOptions:{"url":memberpath+"index.php?c=api&m=category&module=' . APP_DIR . '"}, defaultParentId:0, drevent:"click" }); var ld5_api = $ld5.ld("api"); ld5_api.selected(' . $value . '); }) </script>'; $this->template->assign(array('select' => $select, 'category' => $this->select_category($module['category'], $catid, 'id=\'dr_catid\' name=\'catid\'', '', 1, 1), 'meta_name' => lang('cat-00'))); $this->template->display('content_select.html'); exit; } // 可用字段 $field = $this->_get_member_field($catid); // 初始化参数 $error = $data = array(); // 提交操作 if (IS_POST) { // 栏目参数 $catid = (int) $this->input->post('catid'); $catid = $catid ? $catid : (int) $this->input->get('catid'); // 发布权限判断 if (!$this->module_rule[$catid]['add']) { $this->member_msg(lang('mod-15')); } // 日投稿上限检查 if ($this->uid && $this->module_rule[$catid]['postnum']) { $total = $this->link->where('uid', $this->uid)->where('DATEDIFF(from_unixtime(inputtime),now())=0')->where('catid', $catid)->count_all_results($this->content_model->prefix . '_index'); if ($total >= $this->module_rule[$catid]['postnum']) { $this->member_msg(dr_lang('mod-16', $this->module_rule[$catid]['postnum'])); } } // 投稿总数检查 if ($this->uid && $this->module_rule[$catid]['postcount']) { $total = $this->link->where('uid', $this->uid)->where('catid', $catid)->count_all_results($this->content_model->prefix . '_index'); if ($total >= $this->module_rule[$catid]['postcount']) { $this->member_msg(dr_lang('mod-17', $this->module_rule[$catid]['postcount'])); } } // 虚拟币检查 if ($this->uid && $this->module_rule[$catid]['score'] + $this->member['score'] < 0) { $this->member_msg(dr_lang('mod-09', abs($this->module_rule[$catid]['score']), $this->member['score'])); } // 字段验证与过滤 $cat = $module['category'][$catid]; $field = $cat['field'] ? array_merge($field, $cat['field']) : $field; // 设置uid便于校验处理 $_POST['data']['id'] = $id; $_POST['data']['uid'] = $this->uid; $_POST['data']['author'] = $this->member['username']; $_POST['data']['inputtime'] = $_POST['data']['updatetime'] = SYS_TIME; $data = $this->validate_filter($field); // 验证出错信息 if (isset($data['error'])) { $error = $data; $data = $this->input->post('data', TRUE); } elseif (!$catid) { $data = $this->input->post('data', TRUE); $error = array('error' => 'catid', 'msg' => lang('cat-22')); } elseif ($cat['child']) { $data = $this->input->post('data', TRUE); $error = array('error' => 'catid', 'msg' => lang('mod-18')); } else { // 设定文档默认值 $data[1]['uid'] = $this->uid; $data[1]['hits'] = 0; $data[1]['catid'] = $catid; $data[1]['status'] = !$this->uid || $this->module_rule[$catid]['verify'] ? 1 : 9; $data[1]['inputip'] = $this->input->ip_address(); $data[1]['author'] = $this->member['username'] ? $this->member['username'] : '******'; $data[1]['inputtime'] = $data[1]['updatetime'] = SYS_TIME; // 保存为草稿 if ($this->input->post('action') == 'draft') { $this->clear_cache('save_' . APP_DIR . '_' . $this->uid); $id = $this->content_model->save_draft($did, $data, 0); $this->attachment_handle($this->uid, $this->content_model->prefix . '_draft-' . $id, $field); if (IS_AJAX) { exit(dr_json(0, lang('m-229'), dr_url(APP_DIR . '/home/draft/'))); } $this->member_msg(lang('m-229'), dr_url(APP_DIR . '/home/draft/'), 1); exit; } // 数据来至草稿时更新时间 if ($did) { $data[1]['updatetime'] = $data[1]['inputtime'] = SYS_TIME; } // 发布文档 if (($id = $this->content_model->add($data)) != FALSE) { // 发布草稿时删除草稿数据 if ($did && $this->content_model->delete_draft($did, 'cid=0 and eid=0')) { $this->attachment_replace_draft($did, $id, 0, $this->content_model->prefix, $data[1]['status']); } else { $this->clear_cache('save_' . APP_DIR . '_' . $this->uid); } // 发布文档后执行 $this->_post($id, $data); if ($data[1]['status'] == 9) { // 审核通过 $mark = $this->content_model->prefix . '-' . $id; // 积分处理 $experience = (int) $this->module_rule[$catid]['experience']; if ($experience) { $this->member_model->update_score(0, $this->uid, $experience, $mark, "lang,m-151,{$cat['name']}", 1); } // 虚拟币处理 $score = (int) $this->module_rule[$catid]['score']; if ($score) { $this->member_model->update_score(1, $this->uid, $score, $mark, "lang,m-151,{$cat['name']}", 1); } // 附件归档到文档 $this->attachment_handle($this->uid, $mark, $field); $this->attachment_replace($this->uid, $id, $this->content_model->prefix); if (IS_AJAX) { exit(dr_json(1, lang('m-340'), dr_member_url(APP_DIR . '/home/index'))); } $this->template->assign(array('url' => SITE_URL . APP_DIR . '/index.php?c=show&id=' . $id, 'add' => dr_member_url(APP_DIR . '/home/add', array('catid' => $catid)), 'edit' => 0, 'html' => MODULE_HTML ? dr_module_create_show_file($id) . dr_module_create_list_file($catid) : '', 'list' => $this->member['uid'] ? dr_member_url(APP_DIR . '/home/index') : SITE_URL . APP_DIR . '/index.php?c=category&id=' . $catid, 'catid' => $catid, 'meta_name' => lang('mod-19'))); $this->template->display('success.html'); } else { $this->attachment_handle($this->uid, $this->content_model->prefix . '_verify-' . $id, $field); if (IS_AJAX) { exit(dr_json(1, lang('m-341'), dr_member_url(APP_DIR . '/verify/index'))); } $this->template->assign(array('url' => dr_member_url(APP_DIR . '/verify/index'), 'add' => dr_member_url(APP_DIR . '/home/add', array('catid' => $catid)), 'edit' => 0, 'list' => $this->member['uid'] ? dr_member_url(APP_DIR . '/home/index') : SITE_URL . APP_DIR . '/index.php?c=category&id=' . $catid, 'catid' => $catid, 'meta_name' => lang('mod-19'))); $this->template->display('verify.html'); } exit; } } if (IS_AJAX) { exit(dr_json(0, $error['msg'], $error['error'])); } unset($data['id']); } else { if ($did) { $temp = $this->content_model->get_draft($did); if ($temp['draft']['cid'] == 0 && $temp['draft']['eid'] == 0) { $data = $temp; } } else { $data = $this->get_cache_data('save_' . APP_DIR . '_' . $this->uid); } $catid = $data['catid'] ? $data['catid'] : $catid; // 栏目id不存在时就去第一个可用栏目为catid if (!$catid) { list($select, $catid) = $this->select_category($module['category'], 0, 'id=\'dr_catid\' name=\'catid\' onChange="show_category_field(this.value)"', '', 1, 1, 1); } else { $select = $this->select_category($module['category'], $catid, 'id=\'dr_catid\' name=\'catid\' onChange="show_category_field(this.value)"', '', 1, 1); } $field = $this->_get_member_field($catid); } $backurl = str_replace(MEMBER_URL, '', $_SERVER['HTTP_REFERER']); $this->template->assign(array('did' => $did, 'purl' => dr_url(APP_DIR . '/home/add', array('catid' => $catid)), 'catid' => $catid, 'error' => $error, 'verify' => 0, 'select' => $select, 'myfield' => $this->new_field_input($field, $data, TRUE), 'listurl' => $backurl ? $backurl : dr_url(APP_DIR . '/home/index'), 'isselect' => $isselect, 'meta_name' => lang('mod-02'), 'draft_url' => MEMBER_URL . dr_url(APP_DIR . '/home/add', array('catid' => $catid)), 'draft_list' => $this->content_model->get_draft_list('cid=0 and eid=0'), 'result_error' => $error, 'category_field_url' => $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category_field') ? dr_url(APP_DIR . '/home/add') : '')); $this->template->display('content_add.html'); }
<!doctype html> <html> <head> <meta charset="utf-8"> <title><?php echo dr_lang('html-001', SITE_NAME); ?> </title> <meta name="robots" content="noindex,nofollow"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <link rel="stylesheet" href="<?php echo SITE_PATH; ?> omooo/statics/css/bootstrap.css" /> <link rel="stylesheet" href="<?php echo SITE_PATH; ?> omooo/statics/css/font-awesome/css/font-awesome.css" /> <link href="<?php echo SITE_PATH; ?> omooo/statics/css/login/metro.css" rel="stylesheet" /> <link href="<?php echo SITE_PATH; ?> omooo/statics/css/login/style.css" rel="stylesheet" /> </head> <body class='login'> <script type="text/javascript">var siteurl = "<?php echo SITE_PATH;
/** * 添加 */ public function add() { // 作者判断 if ($this->content['uid'] != $this->uid) { $this->member_msg(lang('mod-05')); } // 添加权限 if (!$this->catrule['add']) { $this->member_msg(lang('160')); } // 虚拟币检查 if ($this->catrule['extend_score'] + $this->member['score'] < 0) { $this->member_msg(dr_lang('mod-44', abs($this->catrule['extend_score']), $this->member['score'])); } $did = (int) $this->input->get('did'); $error = $data = array(); $result = ''; // 保存操作 if (IS_POST) { $type = (int) $this->input->post('type'); $_POST['data']['cid'] = $this->content['id']; $_POST['data']['uid'] = $this->member['uid']; $data = $this->validate_filter($this->field); if (isset($data['error'])) { $error = $data; $data = $this->input->post('data', TRUE); } else { $data[1]['cid'] = $this->content['id']; $data[1]['uid'] = $this->member['uid']; $data[1]['catid'] = $this->content['catid']; $data[1]['author'] = $this->member['username']; $data[1]['status'] = !$this->uid || $this->module_rule[$this->content['catid']]['verify'] ? 1 : 9; $data[1]['updatetime'] = $data[1]['inputtime'] = SYS_TIME; // 保存为草稿 if ($this->input->post('action') == 'draft') { $this->clear_cache('save_' . APP_DIR . '_extend_' . $this->uid); $id = $this->content_model->save_draft($did, $data, 1); $this->attachment_handle($this->uid, $this->content_model->prefix . '_draft-' . $id, $this->field); $this->admin_msg(lang('m-229'), dr_url(APP_DIR . '/home/draft/'), 1); exit; } if ($id = $this->content_model->add_extend($data)) { // 发布草稿时删除草稿数据 if ($did && $this->content_model->delete_draft($did, 'cid=' . $this->content['id'] . ' and eid=-1')) { $this->attachment_replace_draft($did, $this->content['id'], $id, $this->content_model->prefix, $data[1]['status']); } else { $this->clear_cache('save_' . APP_DIR . '_extend_' . $this->uid); } if ($data[1]['status'] == 9) { $mark = $this->content_model->prefix . '-' . $this->content['id'] . '-' . $id; $category = $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category', $this->content['catid']); // 积分处理 if ($this->catrule['extend_experience']) { $this->member_model->update_score(0, $this->content['uid'], $this->catrule['extend_experience'], $mark, "lang,m-343,{$category['name']}", 1); } // 虚拟币处理 if ($this->catrule['extend_score']) { $this->member_model->update_score(1, $this->content['uid'], $this->catrule['extend_score'], $mark, "lang,m-343,{$category['name']}", 1); } // 操作成功处理附件 $this->attachment_handle($this->content['uid'], $mark, $this->field); if (IS_AJAX) { exit(dr_json(1, lang('m-340'), dr_member_url(APP_DIR . '/extend/index', array('cid' => $this->content['id'])))); } $this->template->assign(array('url' => SITE_URL . APP_DIR . '/index.php?c=extend&id=' . $id, 'add' => dr_member_url(APP_DIR . '/extend/add', array('cid' => $this->content['id'], 'type' => $data[1]['mytype'])), 'edit' => 0, 'html' => MODULE_HTML ? dr_module_create_show_file($this->content['id']) . dr_module_create_list_file($this->content['catid']) : '', 'list' => dr_member_url(APP_DIR . '/extend/index', array('cid' => $this->content['id'])), 'meta_name' => lang('mod-19'))); $this->template->display('success.html'); } else { $this->attachment_handle($this->uid, $this->content_model->prefix . '_verify-' . $this->content['id'] . '-' . $id, $this->field); if (IS_AJAX) { exit(dr_json(1, lang('m-341'), dr_member_url(APP_DIR . '/everify/index'))); } $this->template->assign(array('url' => dr_member_url(APP_DIR . '/everify/index'), 'add' => dr_member_url(APP_DIR . '/extend/add', array('cid' => $this->content['id'], 'type' => $data[1]['mytype'])), 'edit' => 0, 'list' => dr_member_url(APP_DIR . '/extend/index', array('cid' => $this->content['id'])), 'meta_name' => lang('mod-19'))); $this->template->display('verify.html'); } exit; } else { $error = array('error' => 'error'); } } } else { if ($did) { $temp = $this->content_model->get_draft($did); if ($temp['draft']['cid'] == $this->content['id'] && $temp['draft']['eid'] == -1) { $data = $temp; } } else { $data = $this->get_cache_data('save_' . APP_DIR . '_extend_' . $this->uid); } } $this->template->assign(array('did' => $did, 'data' => $data, 'error' => $error, 'result' => $result, 'myfield' => $this->field_input($this->field, $data, TRUE), 'draft_url' => MEMBER_URL . dr_url(APP_DIR . '/extend/add', array('cid' => $this->content['id'], 'catid' => $this->catid)), 'draft_list' => $this->content_model->get_draft_list('cid=' . $this->content['id'] . ' and eid=-1'), 'result_error' => $error)); $this->template->display('content_extend_add.html'); }
/** * 修改 */ public function edit() { $uid = (int) $this->input->get('uid'); $page = (int) $this->input->get('page'); $data = $this->member_model->get_member($uid); if (!$data) { $this->admin_msg(lang('019')); } $field = array(); $MEMBER = $this->get_cache('member'); if ($MEMBER['field'] && $MEMBER['group'][$data['groupid']]['allowfield']) { foreach ($MEMBER['field'] as $t) { if (in_array($t['fieldname'], $MEMBER['group'][$data['groupid']]['allowfield'])) { $field[] = $t; } } } $is_uc = function_exists('uc_user_edit') && $MEMBER['setting']['ucenter']; if (IS_POST) { $edit = $this->input->post('member'); $page = (int) $this->input->post('page'); $post = $this->validate_filter($field, $data); if (!$edit['groupid']) { $error = lang('m-156'); } elseif (isset($post['error'])) { $error = $post['msg']; } else { $post[1]['uid'] = $uid; $post[1]['complete'] = (int) $data['complete']; $this->db->replace('member_data', $post[1]); $this->attachment_handle($uid, $this->db->dbprefix('member') . '-' . $uid, $field, $data); $update = array('name' => $edit['name'], 'phone' => $edit['phone'], 'groupid' => $edit['groupid']); // 修改密码 $edit['password'] = trim($edit['password']); if ($edit['password']) { if ($is_uc) { uc_user_edit($data['username'], '', $edit['password'], '', 1); } $update['password'] = md5(md5($edit['password']) . $data['salt'] . md5($edit['password'])); $this->member_model->add_notice($uid, 1, dr_lang('m-079', $this->member['username'])); $this->system_log('修改会员【' . $data['username'] . '】密码'); // 记录日志 } // 修改邮箱 if ($edit['email'] != $data['email']) { if (!preg_match('/^[\\w\\-\\.]+@[\\w\\-\\.]+(\\.\\w+)+$/', $edit['email'])) { $this->admin_msg(lang('m-011')); } if ($this->db->where('email', $edit['email'])->where('uid<>', $uid)->count_all_results('member')) { $this->admin_msg(dr_lang('m-022', $edit['email'])); } if ($is_uc) { $ucid = uc_user_edit($data['username'], '', '', $edit['email'], 1); if ($ucid == -4) { $this->admin_msg(lang('m-026')); } elseif ($ucid == -5) { $this->admin_msg(lang('m-027')); } elseif ($ucid == -6) { $this->admin_msg(lang('m-028')); } } $update['email'] = $edit['email']; $this->member_model->add_notice($uid, 1, dr_lang('m-121', $this->member['username'])); $this->system_log('修改会员【' . $data['username'] . '】邮箱'); // 记录日志 } $this->db->where('uid', $uid)->update('member', $update); // 会员组升级挂钩点 if ($data['groupid'] != $edit['groupid']) { $this->hooks->call_hook('member_group_upgrade', array('uid' => $uid, 'groupid' => $edit['groupid'])); $this->system_log('修改会员【' . $data['username'] . '】会员组'); // 记录日志 } $this->system_log('修改会员【' . $data['username'] . '】资料'); // 记录日志 $this->admin_msg(lang('000'), dr_url('member/home/edit', array('uid' => $uid, 'page' => $page)), 1); } $this->admin_msg($error, dr_url('member/home/edit', array('uid' => $uid, 'page' => $page))); } $this->template->assign(array('data' => $data, 'page' => $page, 'myfield' => $this->field_input($field, $data, TRUE))); $this->template->display('edit.html'); }
/** * 更新URL */ public function url() { $cfile = SITE_ID . APP_DIR . $this->uid . $this->input->ip_address() . '_content_url'; if (IS_POST) { $catid = $this->input->post('catid'); $query = $this->link; if (count($catid) > 1 || $catid[0]) { $query->where_in('catid', $catid); if (count($this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category')) == count($catid)) { $catid = 0; } } else { $catid = 0; } // 统计数量 $total = $query->count_all_results($this->content_model->prefix . '_index'); $this->cache->file->save($cfile, array('catid' => $catid, 'total' => $total), 10000); if ($total) { $this->system_log('站点【#' . SITE_ID . '】模块【' . APP_DIR . '】更新URL地址#' . $total); // 记录日志 $this->mini_msg(dr_lang('132', $total), dr_url(APP_DIR . '/home/url', array('todo' => 1)), 2); } else { $this->mini_msg(lang('133')); } } // 处理url if ($this->input->get('todo')) { $page = max(1, (int) $this->input->get('page')); $psize = 100; // 每页处理的数量 $cache = $this->cache->file->get($cfile); if ($cache) { $total = $cache['total']; $catid = $cache['catid']; } else { $catid = 0; $total = $this->link->count_all_results($this->content_model->prefix); } $tpage = ceil($total / $psize); // 总页数 if ($page > $tpage) { // 更新完成删除缓存 $this->cache->file->delete($cfile); $this->mini_msg(lang('360'), NULL, 1); } $module = $this->get_cache('module-' . SITE_ID . '-' . APP_DIR); $table = $this->content_model->prefix; if ($catid) { $this->link->where_in('catid', $catid); } $data = $this->link->limit($psize, $psize * ($page - 1))->order_by('id DESC')->get($table)->result_array(); foreach ($data as $t) { $url = dr_show_url($module, $t); $this->link->update($table, array('url' => $url), 'id=' . $t['id']); if ($module['extend']) { $extend = $this->link->where('cid', (int) $t['id'])->order_by('id DESC')->get($table . '_extend')->result_array(); if ($extend) { foreach ($extend as $e) { $this->link->where('id=', (int) $e['id'])->update($table . '_extend', array('url' => dr_extend_url($module, $e))); } } } } $this->mini_msg(dr_lang('135', "{$tpage}/{$page}"), dr_url(APP_DIR . '/home/url', array('todo' => 1, 'page' => $page + 1)), 2, 0); } else { $this->template->assign(array('menu' => $this->get_menu($this->_get_content_menu()), 'select' => $this->select_category($this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category'), 0, 'id="dr_synid" name=\'catid[]\' multiple style="width:200px;height:250px;"', ''))); $this->template->display('content_url.html'); } }
/** * 缓存 * * 模块缓存文件格式:module-站点id-模块名称 = array(模块数组); * 模块数据缓存文件:module = array( 模块名称1, 模块名称2, 模块名称3); * */ public function cache($update = 1) { $dir = $this->input->get('dir'); $admin = (int) $this->input->get('admin'); // 更新后台菜单缓存 $this->load->model('menu_model'); $this->menu_model->cache(); if ($dir) { $url = $this->input->get('url') ? $this->input->get('url') : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''); $todo = (int) $this->input->get('todo'); if (!($admin || !$update) && !$todo) { $this->admin_msg(lang('004'), dr_url('module/cache', array('dir' => $dir, 'todo' => 1, 'url' => urlencode($url))), 2, 0); } $this->module_model->cache($dir, $update); if ($admin || !$update) { return ''; } $this->admin_msg(lang('000'), urldecode($url), 1); } else { // 模块页面更新缓存 $step = (int) $this->input->get('step'); $todo = (int) $this->input->get('todo'); $module = $this->db->where('disabled', 0)->get('module')->result_array(); if (!$todo && $module) { $cache = array(); foreach ($module as $t) { $site = dr_string2array($t['site']); foreach ($site as $_site => $url) { $cache[$_site][] = $t['dirname']; // 将模块归类至站点 } } $this->dcache->set('module', $cache); $this->admin_msg(lang('004'), dr_url('module/cache', array('step' => 0, 'todo' => 1)), 2, 0); } if (!isset($module[$step])) { $this->admin_msg(lang('116'), dr_url('module/index'), 1); } $this->module_model->cache($module[$step]['dirname'], $update); $this->admin_msg(dr_lang('009', $module[$step]['dirname']) . ' ...', dr_url('module/cache', array('step' => $step + 1, 'todo' => 1)), 2, 0); } }
/** * 模块扩展内容页 */ protected function _extend($id = NULL, $return = FALSE) { // 缓存查询结果 $name = (SITE_MOBILE === TRUE ? 'm' : '') . 'extend' . $this->dir . SITE_ID . $id; $data = $this->get_cache_data($name); if (!$data) { $mod = $this->get_cache('module-' . SITE_ID . '-' . $this->dir); if (!$mod) { if ($return) { return NULL; } $this->msg(lang('m-148')); } $this->load->model('content_model'); $data = $this->content_model->get_extend($id); if (!$data) { if ($return) { return NULL; } $this->goto_404_page(dr_lang('mod-45', $id)); } $content = $this->get_cache_data('show' . $this->dir . SITE_ID . $data['cid']); if (!$content) { $content = $this->get_cache_data('extend-show' . $this->dir . SITE_ID . $data['cid']); } if (!$content) { $content = $this->content_model->get($data['cid']); $this->set_cache_data('extend-show' . $this->dir . SITE_ID . $data['cid'], $content, $mod['setting']['show_cache']); } if (!$content) { if ($return) { return NULL; } $this->goto_404_page(dr_lang('mod-30', $data['cid'])); } $data = $data + $content; $data['curl'] = $content['url']; // 检测转向字段 $redirect = 0; foreach ($mod['extend'] as $t) { if ($t['fieldtype'] == 'Redirect' && $data[$t['fieldname']]) { if (MODULE_HTML) { $redirect = 1; $data['goto_url'] = $data[$t['fieldname']]; break; } else { redirect($data[$t['fieldname']], 'location', 301); exit; } } } $cat = $mod['category'][$data['catid']]; // 上一篇 $data['prev_page'] = $this->link->where('cid', (int) $data['cid'])->where('id<', $id)->order_by('displayorder desc,id desc')->limit(1)->get($this->content_model->prefix . '_extend')->row_array(); // 下一篇 $data['next_page'] = $this->link->where('cid', (int) $data['cid'])->where('id>', $id)->order_by('displayorder desc,id asc')->limit(1)->get($this->content_model->prefix . '_extend')->row_array(); // 缓存数据 if ($data['uid'] != $this->uid) { $data = $this->set_cache_data($name, $data, $mod['setting']['show_cache']); } } else { $mod = $this->get_cache('module-' . SITE_ID . '-' . $this->dir); $cat = $mod['category'][$data['catid']]; } // 拒绝访问判断 if ($cat['permission'][$this->markrule]['show']) { $this->msg(lang('m-338')); } // 格式化输出自定义字段 $fields = $mod['field']; $fields = $cat['field'] ? array_merge($fields, $cat['field']) : $fields; $fields = $fields + $mod['extend']; $fields['inputtime'] = array('fieldtype' => 'Date'); $data = $this->field_format_value($fields, $data, 1); // 栏目下级或者同级栏目 list($parent, $related) = $this->_related_cat($mod, $data['catid']); $this->template->assign($data); $this->template->assign(dr_extend_seo($mod, $data)); $this->template->assign(array('cat' => $cat, 'params' => array('catid' => $data['catid']), 'parent' => $parent, 'related' => $related, 'urlrule' => $this->mobile ? dr_mobile_extend_url($this->dir, $id, '{page}') : dr_extend_url($mod, $data, '{page}'))); $tpl = $cat['setting']['template']['extend']; $tpl = $tpl ? $tpl : 'extend.html'; if (!$return) { $this->template->display($tpl); } // 存在转向字段时处理方式 return array($data, $redirect ? 'go' : $tpl); }
public function verify_notice($id, $data) { $this->member_model->add_notice($data[1]['uid'], 3, dr_lang('m-084', $data[1]['title'])); }