/** * 空间模板 */ public function template() { $style = $this->input->get('style'); if ($style && $this->space['style'] != $style) { $rule = dr_string2array(@file_get_contents(FCPATH . 'member/templates/' . $style . '/rule.php')); if ($style == 'default' || isset($rule[$this->markrule])) { $this->db->where('uid', (int) $this->uid)->update($this->db->dbprefix('space'), array('style' => $style)); $this->member_msg(lang('m-319'), dr_member_url('space/template'), 1); } else { $this->member_msg(lang('m-320')); } } $list = array(); $data = array_diff(dr_dir_map(FCPATH . 'member/templates/', 1), array('admin', 'member')); if ($data) { foreach ($data as $dir) { $tpl = array('name' => $dir, 'preview' => MEMBER_URL . 'templates/' . $dir . '/preview.jpg'); $rule = dr_string2array(@file_get_contents(FCPATH . 'member/templates/' . $dir . '/rule.php')); if ($dir == 'default') { $list[] = $tpl; } elseif ($rule && isset($rule[$this->markrule])) { $list[] = $tpl; } } } $this->template->assign(array('list' => $list, 'style' => $this->space['style'] ? $this->space['style'] : 'default')); $this->template->display('space_template.html'); }
/** * 首页 */ public function index() { $uid = (int) $this->input->get('uid'); if ($uid) { $this->_space($uid); // 带会员uid参数时进入会员空间界面 } else { // 登录验证 $url = MEMBER_URL . SELF . '?c=login&m=index&backurl=' . urlencode(dr_now_url()); if (!$this->uid) { $this->member_msg(lang('m-039') . $this->member_model->logout(), $url); } /* $total = array(); // 会员模块统计 $module = $this->get_module(SITE_ID); if ($module) { $db = $this->site[SITE_ID]; foreach ($module as $dir => $m) { if (!$this->_module_post_catid($m)) { continue; } $total['name'][] = '"'.$m['name'].'"'; $total['total'][] = $db->where('uid', $this->uid)->count_all_results(SITE_ID.'_'.$dir.'_index'); } $total['name'] = @implode(',', $total['name']); $total['total'] = @implode(',', $total['total']); } */ // 消息提醒 $notice = array(); $new_notice = $this->db->where('uid', $this->uid)->count_all_results('member_new_notice'); if ($new_notice) { // 统计未读短消息 if ($total = $this->db->where('uid', $this->uid)->where('isnew', 1)->count_all_results('pm_members')) { $notice[] = array('name' => '短消息', 'url' => dr_member_url('pm/index'), 'total' => $total); } // 统计未读系统提醒 if ($total = $this->db->where('uid', $this->uid)->where('type', 1)->where('isnew', 1)->count_all_results('member_notice_' . (int) $this->member['tableid'])) { $notice[] = array('name' => '系统提醒', 'url' => dr_member_url('notice/index'), 'total' => $total); } // 统计未读会员提醒 if ($total = $this->db->where('uid', $this->uid)->where('type', 2)->where('isnew', 1)->count_all_results('member_notice_' . (int) $this->member['tableid'])) { $notice[] = array('name' => '会员互动', 'url' => dr_member_url('notice/member'), 'total' => $total); } // 统计未读模块提醒 if ($total = $this->db->where('uid', $this->uid)->where('type', 3)->where('isnew', 1)->count_all_results('member_notice_' . (int) $this->member['tableid'])) { $notice[] = array('name' => '模块提醒', 'url' => dr_member_url('notice/module'), 'total' => $total); } // 统计未读应用提醒 if ($total = $this->db->where('uid', $this->uid)->where('type', 4)->where('isnew', 1)->count_all_results('member_notice_' . (int) $this->member['tableid'])) { $notice[] = array('name' => '应用提醒', 'url' => dr_member_url('notice/app'), 'total' => $total); } } $this->template->assign(array('notice' => $notice, 'loginlog' => array_reverse(dr_string2array($this->member['loginlog'])), 'meta_name' => lang('m-012'), 'invite_url' => MEMBER_URL . 'index.php?c=register&uid=' . $this->uid . '&invite=' . $this->member['username'], 'new_notice' => $new_notice)); $this->template->display(IS_AJAX ? 'main.html' : 'index.html'); } }
/** * 提醒跳转 */ public function go() { $data = $this->db->select('type')->where('uid', (int) $this->uid)->where('isnew', 1)->get('member_notice_' . $this->member['tableid'])->row_array(); if (!$data) { redirect(dr_member_url('notice/index'), 'refresh'); } elseif ($data['type'] == 1) { redirect(dr_member_url('notice/index'), 'refresh'); } elseif ($data['type'] == 2) { redirect(dr_member_url('notice/member'), 'refresh'); } elseif ($data['type'] == 3) { redirect(dr_member_url('notice/module'), 'refresh'); } elseif ($data['type'] == 4) { redirect(dr_member_url('notice/app'), 'refresh'); } else { redirect(dr_member_url('notice/index'), 'refresh'); } }
/** * 审核会员 */ public function verify() { if (!isset($_SERVER['HTTP_USER_AGENT']) || strlen($_SERVER['HTTP_USER_AGENT']) < 20) { $this->member_msg('认证失败'); } $data = $this->member_model->get_decode($this->input->get('code')); if (!$data) { $this->member_msg(lang('m-190')); } list($time, $uid, $code) = explode(',', $data); if (!$this->db->where('uid', $uid)->where('randcode', $code)->count_all_results('member')) { $this->member_msg(lang('m-193')); } $this->db->where('uid', $uid)->where('groupid<>', 3)->update('member', array('randcode' => 0, 'groupid' => 3)); $this->member_msg(lang('m-194'), dr_member_url('login/index'), 1); }
/** * 会员动态内容URL地址 * * @param intval $id * @return string */ function dr_sns_feed_url($id) { return dr_member_url('sns/feed', array('id' => $id)); }
/** * 修改 */ public function edit() { // 初始化参数 $id = (int) $this->input->get('id'); $did = (int) $this->input->get('did'); $cid = (int) $this->input->get('catid'); $data = $this->content_model->get($id); $error = array(); $catid = $cid ? $cid : $data['catid']; // 数据是否存在 if (!$data) { $this->member_msg(lang('019')); } // 禁止修改他人文档 if ($data['author'] != $this->member['username'] && $data['uid'] != $this->member['uid']) { $this->member_msg(lang('mod-05')); } // 修改权限判断 if (!$this->module_rule[$catid]['edit']) { $this->member_msg(lang('mod-20')); } // 可用字段 $field = $this->_get_member_field($catid); $isedit = (int) $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category', $catid, 'setting', 'edit'); // 保存修数据 if (IS_POST) { $_data = $data; // 字段验证与过滤 $catid = $isedit ? $catid : (int) $this->input->post('catid'); // 修改权限判断 if (!$this->module_rule[$catid]['edit']) { $this->member_msg(lang('mod-20')); } $cat = $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, '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'] = $data['inputtime']; $_POST['data']['updatetime'] = SYS_TIME; $data = $this->validate_filter($field, $_data); if (isset($data['error'])) { $error = $data; $data = $this->input->post('data', TRUE); } elseif (!$isedit && !$catid) { $data = $this->input->post('data', TRUE); $error = array('error' => 'catid', 'msg' => lang('cat-22')); } else { // 初始化数据 $status = isset($data['status']) && $data['status'] ? 9 : ($this->module_rule[$catid]['verify'] ? 1 : 9); $status = isset($this->module_rule[$catid]['edit_verify']) && $this->module_rule[$catid]['edit_verify'] ? 9 : $status; $data[1]['uid'] = $this->uid; $data[1]['author'] = $this->member['username']; $data[1]['catid'] = $catid; $data[1]['status'] = $status; $data[1]['updatetime'] = SYS_TIME; // 保存为草稿 if ($this->input->post('action') == 'draft') { $data[1]['id'] = $data[0]['id'] = $id; $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->admin_msg(lang('m-229'), dr_url(APP_DIR . '/home/draft/'), 1); exit; } // 修改数据 if ($this->content_model->edit($_data, $data)) { // 发布草稿时删除草稿数据 if ($did && $this->content_model->delete_draft($did, 'cid=' . $id . ' and eid=0')) { $this->attachment_replace_draft($did, $id, 0, $this->content_model->prefix, $data[1]['status']); } $this->attachment_handle($this->uid, $this->content_model->prefix . '-' . $id, $field, $_data, $data[1]['status'] == 9 ? TRUE : FALSE); if ($data[1]['status'] == 9) { // 审核通过 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' => 1, 'list' => dr_member_url(APP_DIR . '/home/index'), 'html' => MODULE_HTML ? dr_module_create_show_file($id) . dr_module_create_list_file($catid) : '', 'catid' => $catid, 'meta_name' => lang('mod-03'))); $this->template->display('success.html'); } else { 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' => 1, 'list' => dr_member_url(APP_DIR . '/home/index'), 'catid' => $catid, 'meta_name' => lang('mod-03'))); $this->template->display('verify.html'); } } else { $this->member_msg(lang('mod-06')); } exit; } if (IS_AJAX) { exit(dr_json(0, $error['msg'], $error['error'])); } } else { if ($did) { $temp = $this->content_model->get_draft($did); if ($temp['draft']['cid'] == $data['id'] && $temp['draft']['eid'] == 0) { $temp['id'] = $id; $data = $temp; $catid = $temp['catid'] ? $temp['catid'] : $catid; } } } $backurl = str_replace(MEMBER_URL, '', $_SERVER['HTTP_REFERER']); $this->template->assign(array('did' => $did, 'purl' => dr_url(APP_DIR . '/home/add', array('id' => $id)), 'data' => $data, 'catid' => $catid, 'error' => $error, 'isedit' => $isedit, 'select' => $this->select_category($this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category'), $catid, 'id=\'dr_catid\' name=\'catid\' onChange="show_category_field(this.value)"', '', 1, 1), 'backurl' => $_SERVER['HTTP_REFERER'], 'myfield' => $this->field_input($field, $data, TRUE), 'listurl' => $backurl ? $backurl : dr_url(APP_DIR . '/home/index'), 'meta_name' => lang('mod-21'), 'draft_url' => MEMBER_URL . dr_url(APP_DIR . '/home/edit', array('id' => $id)), 'draft_list' => $this->content_model->get_draft_list('cid=' . $id . ' and eid=0'), 'result_error' => $error, 'category_field_url' => $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category_field') ? dr_url(APP_DIR . '/home/edit', array('id' => $id, 'did' => $did)) : '')); $this->template->display('content_add.html'); }
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; }
/** * 修改空间模型内容 */ protected function space_content_edit() { $this->_is_space(); $id = (int) $this->input->get('id'); $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_category_model'); $this->load->model('space_content_model'); $category = $this->space_category_model->get_data($mid); $this->space_content_model->tablename = $this->db->dbprefix('space_' . $model['table']); $data = $this->space_content_model->get($this->uid, $id); if (!$data) { $this->member_msg(lang('m-303')); } if (IS_POST) { // 栏目参数 $catid = (int) $this->input->post('catid'); // 设置uid便于校验处理 $_POST['data']['updatetime'] = SYS_TIME; $post = $this->validate_filter($model['field']); // 验证出错信息 if (isset($post['error'])) { $error = $post; $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 { // 设定文档默认值 $post[1]['catid'] = $catid; $post[1]['status'] = (int) $model['setting'][$this->markrule]['verify'] ? 0 : 1; $post[1]['updatetime'] = SYS_TIME; // 修改文档 if (($id = $this->space_content_model->edit($id, $data['uid'], $post[1])) != FALSE) { $this->attachment_handle($this->uid, $this->space_content_model->tablename . '-' . $id, $model['field'], $data, $post[1]['status'] ? TRUE : FALSE); $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 . '/edit', array('id' => $id)), '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 file() { $id = (int) $this->input->get('id'); $info = get_attachment($id); $this->template->admin(); if (!$info) { $this->admin_msg(lang('m-326')); } // 是否允许下载附件 if (!$this->uid && !$this->member_rule['is_download']) { $this->msg(lang('m-217'), dr_member_url('login/index'), 0, 3); } elseif (!$this->member['adminid'] && !$this->member_rule['is_download']) { $this->msg(lang('m-322', $this->member['groupname']), dr_member_url('login/index'), 0, 3); } // 虚拟币与经验值检查 $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 = SYS_UPLOAD_PATH . '/' . str_replace('..', '', $file); $file = str_replace('member/uploadfile/member/uploadfile', 'member/uploadfile', $file); $name = urlencode($info['filename'] . '.' . $info['fileext']); $this->load->helper('download'); force_download($name, file_get_contents($file)); } }
/** * 卡密充值 */ public function card() { if (IS_POST) { $card = $this->input->post('card', TRUE); $password = (int) $this->input->post('password'); if ($card && $password) { $data = $this->db->where('card', $card)->where('password', $password)->limit(1)->get('member_paycard')->row_array(); if (!$data) { $error = lang('m-171'); } elseif ($data['endtime'] < SYS_TIME) { $error = lang('m-169'); } elseif ($data['uid']) { $error = lang('m-170'); } else { if ($money = $this->pay_model->add_for_card($data['id'], $data['money'], $card)) { $this->member_msg(dr_lang('m-172', $data['money']), dr_member_url('pay/index'), 1); } $error = lang('m-172'); } } else { $error = lang('m-168'); } } $this->template->assign(array('card' => $card, 'result_error' => $error)); $this->template->display('pay_card.html'); }
/** * 修改审核 */ public function edit() { $id = (int) $this->input->get('id'); $data = $this->content_model->get_extend_verify($id); $error = array(); if (!$data) { $this->member_msg(lang('019')); } // 禁止修改他人文档 if ($data['author'] != $this->member['username'] && $data['uid'] != $this->member['uid']) { $this->member_msg(lang('mod-05')); } $field = $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'extend'); if (IS_POST) { $_data = $data; // 设置uid便于校验处理 $_POST['data']['id'] = $id; $_POST['data']['uid'] = $this->uid; $_POST['data']['author'] = $this->member['username']; $data = $this->validate_filter($field, $_data); if (isset($data['error'])) { $error = $data; $data = $this->input->post('data', TRUE); } else { $this->content = $this->content_model->get($_data['cid']); $data[1]['cid'] = (int) $this->content['id']; $data[1]['uid'] = $this->member['uid']; $data[1]['catid'] = (int) $this->content['catid']; $data[1]['status'] = 1; $data[1]['author'] = $this->member['username']; if (isset($data[1]['mytype'])) { $data[1]['mytype'] = $_data['mytype']; } // 修改数据 if ($this->content_model->edit_extend($_data, $data)) { $this->attachment_handle($this->uid, $this->content_model->prefix . '_verify-' . $_data['cid'] . '-' . $id, $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' => $_data['cid'])), 'edit' => 1, 'list' => dr_member_url(APP_DIR . '/extend/index', array('cid' => $_data['cid'])), 'meta_name' => lang('mod-03'))); $this->template->display('verify.html'); } else { $this->member_msg(lang('mod-06')); } exit; } } $backurl = str_replace(MEMBER_URL, '', $_SERVER['HTTP_REFERER']); $this->template->assign(array('purl' => dr_url(APP_DIR . '/everify/edit', array('id' => $id)), 'data' => $data, 'myfield' => $this->field_input($field, $data, TRUE), 'backurl' => $backurl ? $backurl : dr_url(APP_DIR . '/everify/index'), 'listurl' => $backurl ? $backurl : dr_url(APP_DIR . '/everify/index'), 'meta_name' => lang('mod-41'), 'result_error' => $error)); $this->template->display('everify_edit.html'); }
protected function _add($data) { // 入库 $this->link->insert($this->table, $data); if (($id = $this->link->insert_id()) && ($user = dr_member_info($this->cdata['uid']))) { $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>'); } return $id; }
/** * 会员空间页 */ private function _space($uid, $is_domain = 0) { if (!MEMBER_OPEN_SPACE) { $this->member_msg(lang('m-111')); } define('IS_SPACE', $uid); $this->load->model('space_model'); $this->load->model('space_category_model'); $space = $this->space_model->get($uid); if (!$space) { $this->template->assign('theme', MEMBER_PATH . 'templates/space/default/'); $this->member_msg(lang('m-234')); } if (!$space['status']) { $this->member_msg(lang('m-235')); } // 判断是否是自定义域名 if (!$is_domain && $this->_space_show($uid)) { redirect(dr_member_url('api/access', array('uid' => $uid)), 'refresh'); exit; } // 格式化空间信息 $space = $this->field_format_value($this->get_cache('member', 'spacefield'), $space, 1); $style = $space['style'] ? $space['style'] : 'default'; $theme = MEMBER_URL . 'templates/space/' . $style . '/'; $member = $this->member_model->get_member($uid); // 会员组使用权限判断 if (!$member['allowspace']) { $this->member_msg(lang('m-364')); } $action = str_replace(array('\\', '/', '..', '<', '>'), '', $this->input->get('action', TRUE)); $selected = 0; // 默认选中首页菜单 $category = $this->space_category_model->get_data(0, $uid, 1); switch ($action) { case 'category': // 栏目处理 $id = (int) $this->input->get('id'); $cat = $category[$id]; if (!$cat) { $this->msg(lang('m-315')); } switch ($cat['type']) { case 0: // 外链 if (!$cat['link']) { $this->msg(lang('m-316')); } redirect($cat['link'], 'location', 301); return NULL; break; case 1: // 模型 $model = $this->get_cache('space-model', $cat['modelid']); if (!$model) { $this->msg(lang('m-317')); } $template = 'list_' . $model['table'] . '.html'; // 选中顶级栏目 $temp = explode(',', $cat['pids']); $selected = $temp[1] ? $temp[1] : $id; break; case 2: // 单页 $template = 'page.html'; // 选中顶级栏目 $temp = explode(',', $cat['pids']); $selected = $temp[1] ? $temp[1] : $id; // 单页验证是否存在子栏目 if ($cat['child']) { $temp = explode(',', $cat['childids']); if (isset($temp[1]) && $category[$temp[1]]) { $id = $temp[1]; $cat = $category[$id]; } } break; } // 栏目下级或者同级栏目 $related = $parent = array(); if ($cat['pid']) { foreach ($category as $t) { if ($t['pid'] == $cat['pid']) { $related[] = $t; if ($cat['child']) { $parent = $cat; } else { $parent = $category[$t['pid']]; } } } } elseif ($cat['child']) { $parent = $cat; foreach ($category as $t) { if ($t['pid'] == $cat['id']) { $related[] = $t; } } } $this->template->assign(array('cat' => $cat, 'catid' => $id, 'parent' => $parent, 'related' => $related, 'modelid' => $cat['modelid'], 'urlrule' => dr_space_list_url($uid, $id, TRUE))); if ($cat['title']) { $title = $cat['title']; } else { $title = implode('-', array_reverse(explode('{-}', dr_space_catpos($uid, $id, '{-}', FALSE)))) . '-' . $space['name']; } $this->template->assign(array('meta_title' => $title, 'meta_keywords' => $cat['keywords'], 'meta_description' => $cat['description'])); break; case 'show': // 内容处理 $id = (int) $this->input->get('id'); $mid = (int) $this->input->get('mid'); $mod = $this->get_cache('space-model', $mid); if (!$mod) { $this->msg(lang('m-317')); } $name = $this->db->dbprefix('space_' . $mod['table']) . '-space-show-' . $id; $data = $this->get_cache_data($name); if (!$data) { $this->load->model('space_content_model'); $this->space_content_model->tablename = $this->db->dbprefix('space_' . $mod['table']); $data = $this->space_content_model->get($uid, $id); if (!$data) { $this->msg(lang('m-303')); } if (!$data['status'] && $data['uid'] != $this->uid) { $this->msg(lang('m-318')); } $cat = $category[$data['catid']]; if (!$cat) { $this->msg(lang('m-315')); } // 检测转向字段 foreach ($mod['field'] as $t) { if ($t['fieldtype'] == 'Redirect' && $data[$t['fieldname']]) { redirect($data[$t['fieldname']], 'location', 301); exit; } } // 上一篇文章 $data['prev_page'] = $this->db->where('catid', $data['catid'])->where('id<', $id)->where('status', 1)->order_by('id desc')->limit(1)->get($this->space_content_model->tablename)->row_array(); // 下一篇文章 $data['next_page'] = $this->db->where('catid', $data['catid'])->where('id>', $id)->where('status', 1)->order_by('id asc')->limit(1)->get($this->space_content_model->tablename)->row_array(); $this->set_cache_data($name, $data, 360000); } else { $cat = $category[$data['catid']]; if (!$cat) { $this->msg(lang('m-315')); } } // 格式化输出自定义字段 $fields = $mod['field']; $fields['inputtime'] = array('fieldtype' => 'Date'); $fields['updatetime'] = array('fieldtype' => 'Date'); $data = $this->field_format_value($fields, $data, max(1, (int) $this->input->get('page'))); // 栏目下级或者同级栏目 $related = $parent = array(); if ($cat['pid']) { foreach ($category as $t) { if ($t['pid'] == $cat['pid']) { $related[] = $t; if ($cat['child']) { $parent = $cat; } else { $parent = $category[$t['pid']]; } } } } elseif ($cat['child']) { $parent = $cat; foreach ($category as $t) { if ($t['pid'] == $cat['id']) { $related[] = $t; } } } $template = 'show_' . $mod['table'] . '.html'; // 选中顶级栏目 $temp = explode(',', $cat['pids']); $selected = $temp[1] ? $temp[1] : $cat['id']; $this->template->assign($data); $this->template->assign(array('cat' => $cat, 'catid' => $cat['id'], 'parent' => $parent, 'related' => $related, 'modelid' => $cat['modelid'])); $temp = dr_space_catpos($uid, $cat['id'], '{-}', FALSE); $temp = explode('{-}', $temp); $catstr = implode(SITE_SEOJOIN, array_reverse($temp)); $this->template->assign(array('meta_title' => ($data['content_title'] ? $data['content_title'] . SITE_SEOJOIN : '') . $data['title'] . SITE_SEOJOIN . $catstr . SITE_SEOJOIN . $space['name'], 'meta_keywords' => $data['keywords'], 'meta_description' => dr_strcut(dr_clearhtml($data['content']), 200, ''))); break; case 'sns': // sns部分 $template = $this->_sns($space); break; default: // 首页或者其他自定义页面 $template = $action ? $action . '.html' : 'index.html'; $this->template->assign(array('meta_title' => $space['title'] ? $space['title'] : $space['name'], 'meta_keywords' => $space['keywords'], 'meta_description' => $space['description'])); break; } // 更新访问量pv $this->db->where('uid', $uid)->update('space', array('hits' => $space['hits'] + 1)); // 空间地址 $space['url'] = dr_space_url($uid); // 会员姓名 $space['mname'] = $space['cname'] = $member['name']; // 我收藏的 $favorite = array(); if ($this->uid) { $temp = $this->db->where('uid', $this->uid)->get('sns_feed_favorite')->result_array(); if ($temp) { foreach ($temp as $t) { $favorite[] = $t['fid']; } unset($temp); } } $this->template->assign(array('uid' => $uid, 'style' => $style, 'theme' => $theme, 'space' => $space + $member, 'spaceid' => $uid, 'tableid' => (int) substr((string) $uid, -1, 1), 'selected' => $selected, 'category' => $category, 'favorite' => $favorite, 'space_count' => array('feed' => $this->db->where('uid', $uid)->count_all_results('sns_feed'), 'fans' => $this->db->where('uid', $uid)->count_all_results('sns_follow'), 'follow' => $this->db->where('fid', $uid)->count_all_results('sns_follow')))); $this->template->space($style); $this->template->display($template); exit; }
/** * 修改 */ public function edit() { $id = (int) $this->input->get('id'); $data = $this->space_category_model->get($id); if (!$data) { $this->member_msg(lang('019')); } $is_edit = $this->get_cache('member', 'setting', 'space', 'category') ? 0 : 1; if (IS_POST) { $post = $this->input->post('data', TRUE); $post['pid'] = $is_edit ? $post['pid'] : $data['pid']; $post['type'] = $data['type']; $post['modelid'] = $data['modelid']; $result = $this->space_category_model->edit($id, $post); if ($result === TRUE) { $this->member_msg(lang('000'), dr_member_url('category/index'), 1); } $post['id'] = $id; $data = $post; } else { $result = ''; } $this->template->assign(array('data' => $data, 'result' => $result, 'method' => $this->router->method, 'is_edit' => $is_edit)); $this->template->display('category_add.html'); }
/** * 修改 */ public function edit() { if (!$this->catrule['edit']) { $this->member_msg(lang('160')); } $id = (int) $this->input->get('id'); $data = $this->content_model->get_extend($id); if (!$data) { $this->member_msg(lang('019')); } $error = array(); $result = ''; if (IS_POST) { $_data = $data; $type = (int) $this->input->post('type'); $_POST['data']['cid'] = $this->content['id']; $_POST['data']['uid'] = $this->content['uid']; $data = $this->validate_filter($this->field, $_data); if (isset($data['error'])) { $error = $data; $data = $this->input->post('data', TRUE); } else { $status = isset($data['status']) && $data['status'] ? 9 : ($this->module_rule[$this->content['catid']]['verify'] ? 1 : 9); $status = isset($this->module_rule[$this->content['catid']]['edit_verify']) && $this->module_rule[$this->content['catid']]['edit_verify'] ? 9 : $status; $data[1]['cid'] = $this->content['id']; $data[1]['uid'] = $this->content['uid']; $data[1]['catid'] = $this->content['catid']; $data[1]['status'] = $status; $data[1]['author'] = $this->content['author']; if ($id = $this->content_model->edit_extend($_data, $data)) { if ($data[1]['status'] == 9) { $mark = $this->content_model->prefix . '-' . $this->content['id'] . '-' . $id; // 操作成功处理附件 $this->attachment_handle($this->content['uid'], $mark, $this->field, $_data); 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' => 1, '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, $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' => $id); } } } $this->template->assign(array('data' => $data, 'error' => $error, 'result' => $result, 'myfield' => $this->field_input($this->field, $data, TRUE), 'result_error' => $error)); $this->template->display('content_extend_add.html'); }
<?php if ($_GET['payok'] == 'payok') { $this->pay_msg('付款成功', dr_member_url('pay/index'), 1); } $myf = dirname(__FILE__) . "/a.txt"; file_put_contents($myf, "\r\n \$_POST = " . print_r($_POST, true), FILE_APPEND); $pay = $this->get_cache('member', 'setting', 'pay', 'paypal'); // read the post from PayPal system and add 'cmd' $req = 'cmd=_notify-validate'; foreach ($_POST as $key => $value) { $req .= '&' . $key . '=' . urlencode(stripslashes($value)); } // post back to PayPal system to validate $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30); // assign posted variables to local variables $payment_status = $_POST['payment_status']; // 返回状态 $receiver_email = $_POST['receiver_email']; // 商家账户 // 处理订单 if (!$fp) { fclose($fp); } else { fputs($fp, $header . $req); while (!feof($fp)) { $res = fgets($fp, 1024); $return = $header . "\r\n REQ: " . $req . "\r\n RES:" . $res;
/** * 修改退回 */ public function edit() { $id = (int) $this->input->get('id'); $cid = (int) $this->input->get('catid'); $data = $this->content_model->get_verify($id); $catid = $cid ? $cid : $data['catid']; $error = array(); // 审核数据不存在 if (!$data) { $this->member_msg(lang('019')); } // 禁止修改他人文档 if ($data['author'] != $this->member['username'] && $data['uid'] != $this->member['uid']) { $this->member_msg(lang('mod-05')); } $field = $this->_get_member_field($catid); $isedit = (int) $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category', $catid, 'setting', 'edit'); if (IS_POST) { $_data = $data; $catid = $isedit ? $catid : (int) $this->input->post('catid'); $cat = $this->get_cache('MODULE-' . SITE_ID, APP_DIR, 'category', $catid); $field = $this->_get_member_field($catid); // 设置uid便于校验处理 $_POST['data']['id'] = $id; $_POST['data']['uid'] = $this->uid; $_POST['data']['author'] = $this->member['username']; $_POST['data']['inputtime'] = $data['inputtime']; $_POST['data']['updatetime'] = SYS_TIME; $data = $this->validate_filter($field, $_data); if (isset($data['error'])) { $error = $data; $data = $this->input->post('data', TRUE); } elseif (!$isedit && !$catid) { $data = $this->input->post('data', TRUE); $error = array('error' => 'catid', 'msg' => lang('cat-22')); } else { $data[1]['catid'] = $catid; $data[1]['status'] = 1; // 修改审核后从头开始审核 $data[1]['updatetime'] = SYS_TIME; $data[1]['uid'] = $this->uid; $data[1]['author'] = $this->member['username']; // 修改数据 if ($this->content_model->edit($_data, $data)) { $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' => 1, 'list' => dr_member_url(APP_DIR . '/home/index'), 'catid' => $catid, 'meta_name' => lang('mod-03'))); $this->template->display('verify.html'); } else { $this->member_msg(lang('mod-06')); } exit; } } $backurl = str_replace(MEMBER_URL, '', $_SERVER['HTTP_REFERER']); $this->template->assign(array('purl' => dr_url(APP_DIR . '/back/edit', array('id' => $id)), 'data' => $data, 'catid' => $catid, 'error' => $error, 'isedit' => $isedit, 'select' => $this->select_category($this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category'), $catid, 'id=\'dr_catid\' name=\'catid\' onChange="show_category_field(this.value)"', '', 1), 'myfield' => $this->new_field_input($field, $data, TRUE), 'backurl' => $backurl ? $backurl : dr_url(APP_DIR . '/back/index'), 'listurl' => $backurl ? $backurl : dr_url(APP_DIR . '/back/index'), 'meta_name' => lang('mod-07'), 'result_error' => $error, 'category_field_url' => $this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category_field') ? dr_url(APP_DIR . '/back/edit', array('id' => $id)) : '')); $this->template->display('back_edit.html'); }
public function domain() { if (!$this->member['spacedomain']) { $this->member_msg(lang('m-219')); } $domain = $this->get_cache('member', 'setting', 'space', 'spacedomain'); if (!$domain) { $this->member_msg(lang('m-220')); } if (IS_POST) { $value = $this->input->post('domain'); if (!$value) { $this->db->where('uid', $this->uid)->delete('space_domain'); $this->set_cache_data('member-space-domain-' . $this->uid, '', -1); $this->member_msg(lang('m-351'), dr_member_url('space/domain'), 1); } $not_in = $this->get_cache('member', 'setting', 'space', 'notindomain'); if ($not_in && @in_array($value, @explode(PHP_EOL, $not_in))) { $error = lang('m-221'); } elseif (!preg_match('/^[a-z0-9_\\-]+$/iU', $value)) { $error = lang('m-222'); } elseif (is_dir(FCPATH . $value . '/')) { $error = lang('m-221'); } elseif ($this->db->where('uid<>' . $this->uid)->where('domain', $value)->count_all_results('space_domain')) { $error = lang('m-223'); } else { $this->db->replace('space_domain', array('uid' => $this->uid, 'domain' => $value)); $this->set_cache_data('member-space-domain-' . $this->uid, '', -1); $this->member_msg(lang('000'), dr_member_url('space/domain'), 1); } $my_domain = $value; } else { $error = 0; $my_domain = $this->space_model->get_domain($this->uid); } $this->template->assign(array('domain' => $domain, 'my_domain' => $my_domain, 'result_error' => $error)); $this->template->display('space_domain.html'); }
function dr_sns_content($content) { // 替换话题URL if (preg_match_all('/\\[TOPIC\\-URL\\-([0-9]+)\\]/Ui', $content, $match)) { foreach ($match[1] as $t) { $content = str_replace('[TOPIC-URL-' . $t . ']', dr_member_url('sns/topic', array('id' => $t)), $content); } } // 替换表情 if (preg_match_all('/\\[([a-z0-9]+)\\]/Ui', $content, $match)) { foreach ($match[1] as $t) { if (is_file(FCPATH . 'member/statics/emotions/' . $t . '.gif')) { $content = str_replace('[' . $t . ']', '<img src="' . MEMBER_URL . 'statics/emotions/' . $t . '.gif" />', $content); } } } return $content; }
protected function _member_isreview() { if (!$this->mconfig['isreview']) { exit(''); } // 评论关闭 #$fid = $this->input->get('fid'); $oid = (int) $this->input->get('oid'); #$iid = (int)$this->input->get('iid'); $data = $this->link->where('oid', $oid)->where('uid', $this->uid)->select('review,id')->limit(1)->get($this->order_model->indexname)->row_array(); if (!$data) { exit(''); } if (IS_ADMIN) { echo 'document.write(\'' . ($data['review'] ? lang('my-21') : '') . '\');'; } else { $html = '<a href="' . dr_member_url(APP_DIR . '/order/review', array('id' => $oid)) . '" target="_blank">' . ($data['review'] ? lang('my-21') : lang('my-22')) . '</a>'; echo 'document.write(\'' . $html . '\');'; } $this->output->enable_profiler(FALSE); }
/** * 修改 */ public function edit() { // 作者判断 if ($this->content['uid'] != $this->uid) { $this->member_msg(lang('mod-05')); } // 修改权限 if (!$this->catrule['edit']) { $this->member_msg(lang('160')); } $id = (int) $this->input->get('id'); $did = (int) $this->input->get('did'); $data = $this->content_model->get_extend($id); if (!$data) { $this->member_msg(lang('019')); } $error = array(); $result = ''; if (IS_POST) { $_data = $data; $type = (int) $this->input->post('type'); $_POST['data']['cid'] = $this->content['id']; $_POST['data']['uid'] = $this->content['uid']; $data = $this->validate_filter($this->field, $_data); if (isset($data['error'])) { $error = $data; $data = $this->input->post('data', TRUE); } else { $status = isset($data['status']) && $data['status'] ? 9 : ($this->module_rule[$this->content['catid']]['verify'] ? 1 : 9); $status = isset($this->module_rule[$this->content['catid']]['edit_verify']) && $this->module_rule[$this->content['catid']]['edit_verify'] ? 9 : $status; $data[1]['cid'] = $this->content['id']; $data[1]['uid'] = $_data['uid']; $data[1]['catid'] = $this->content['catid']; $data[1]['status'] = $status; $data[1]['author'] = $_data['author']; $data[1]['updatetime'] = SYS_TIME; // 保存为草稿 if ($this->input->post('action') == 'draft') { $data[1]['id'] = $data[0]['id'] = $id; $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->edit_extend($_data, $data)) { // 发布草稿时删除草稿数据 if ($did && $this->content_model->delete_draft($did, 'cid=' . $this->content['id'] . ' and eid=' . $id)) { $this->attachment_replace_draft($did, $this->content['id'], $id, $this->content_model->prefix, $data[1]['status']); } if ($data[1]['status'] == 9) { $mark = $this->content_model->prefix . '-' . $this->content['id'] . '-' . $id; // 操作成功处理附件 $this->attachment_handle($this->content['uid'], $mark, $this->field, $_data); 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' => 1, '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' => $id); } } } else { if ($did) { $temp = $this->content_model->get_draft($did); if ($temp['draft']['cid'] == $this->content['id'] && $temp['draft']['eid'] == $id) { $data = $temp; } } } $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/edit', array('cid' => $this->content['id'], 'catid' => $this->catid, 'id' => $id)), 'draft_list' => $this->content_model->get_draft_list('cid=' . $this->content['id'] . ' and eid=' . $id), 'result_error' => $error)); $this->template->display('content_extend_add.html'); }
/** * 我的fans */ public function fans() { $uid = (int) $this->input->get('uid'); $page = max((int) $this->input->get('page'), 1); // ta的粉丝 if ($uid) { // 访问权限 $this->_show($uid); $ta = dr_member_info($uid); $this->db->where('uid IN(select fid from ' . $this->db->dbprefix('sns_follow') . ' where uid=' . $uid . ')'); $this->template->assign('ta', $ta); } else { $this->db->where('uid IN(select fid from ' . $this->db->dbprefix('sns_follow') . ' where uid=' . $this->uid . ')'); } // 查询数据 $this->db->from($this->db->dbprefix('member')); $this->db->order_by('uid desc'); $this->db->limit($this->pagesize, $this->pagesize * ($page - 1)); $data = $this->db->get()->result_array(); // 模板选择 if ($page == 1) { $this->template->assign(array('list' => $data, 'moreurl' => dr_member_url('sns/fans', array('uid' => $uid)))); $this->template->display('sns_fans.html'); } else { if (!$data) { exit('null'); } $this->template->assign(array('list' => $data)); $this->template->display('sns_fans_data.html'); } }