public function edit() { //设置cookie 在附件添加处调用 param::set_cookie('module', 'content'); if (isset($_POST['dosubmit']) || isset($_POST['dosubmit_continue'])) { define('INDEX_HTML', true); $id = $_POST['info']['id'] = intval($_POST['id']); $catid = $_POST['info']['catid'] = intval($_POST['info']['catid']); if (trim($_POST['info']['title']) == '') { showmessage(L('title_is_empty')); } $modelid = $this->categorys[$catid]['modelid']; $this->db->set_model($modelid); $this->db->edit_content($_POST['info'], $id); if (isset($_POST['dosubmit'])) { showmessage(L('update_success') . L('2s_close'), 'blank', '', '', 'function set_time() {$("#secondid").html(1);}setTimeout("set_time()", 500);setTimeout("window.close()", 1200);'); } else { showmessage(L('update_success'), HTTP_REFERER); } } else { $show_header = $show_dialog = $show_validator = ''; //从数据库获取内容 $id = intval($_GET['id']); if (!isset($_GET['catid']) || !$_GET['catid']) { showmessage(L('missing_part_parameters')); } $catid = $_GET['catid'] = intval($_GET['catid']); $this->model = getcache('model', 'commons'); param::set_cookie('catid', $catid); $category = $this->categorys[$catid]; $modelid = $category['modelid']; $this->db->table_name = $this->db->db_tablepre . $this->model[$modelid]['tablename']; $r = $this->db->get_one(array('id' => $id)); $this->db->table_name = $this->db->table_name . '_data'; $r2 = $this->db->get_one(array('id' => $id)); if (!$r2) { showmessage(L('subsidiary_table_datalost'), 'blank'); } $data = array_merge($r, $r2); $data = array_map('htmlspecialchars_decode', $data); require CACHE_MODEL_PATH . 'content_form.class.php'; $content_form = new content_form($modelid, $catid, $this->categorys); $forminfos = $content_form->get($data); $formValidator = $content_form->formValidator; include $this->admin_tpl('content_edit'); } header("Cache-control: private"); }
public function index() { $formid = $modelid = (int) $this->_get("formid"); //判断是否JS显示 $action = $this->_get("action"); if (!$formid) { $action == "js" ? exit : $this->error("该表单不存在!"); } //模型 $moinfo = $this->Model_form[$formid]; if (!$moinfo) { $action == "js" ? exit : $this->error("该表单不存在或者已经关闭!"); } $setting = unserialize($moinfo['setting']); $time = time(); //时间判断 if ($setting['starttime']) { if ($time < (int) $setting['starttime']) { $action == "js" ? exit : $this->error("还没开始!"); } } if ($setting['endtime']) { if ($time > (int) $setting['endtime']) { $action == "js" ? exit : $this->error("已经结束!"); } } //是否允许游客提交 if ((int) $setting['allowunreg'] == 0) { //判断是否登陆 if (!AppframeAction::$Cache['uid']) { $action == "js" ? exit : $this->error("请先登陆!"); } } //是否允许同一IP多次提交 if ((int) $setting['allowmultisubmit'] == 0) { $tablename = M('Model')->where(array("modelid" => $formid))->getField("tablename"); $tablename = ucwords($tablename); $ip = get_client_ip(); $count = M($tablename)->where(array("ip" => $ip))->count(); if ($count) { $action == "js" ? exit : $this->error("你已经提交过了!"); } } //模板 $show_template = $setting['show_template'] ? $setting['show_template'] : "show"; //js模板 $show_js_template = $setting['show_js_template'] ? $setting['show_js_template'] : "show_js"; //引入输入表单处理类 require_cache(RUNTIME_PATH . 'content_form.class.php'); //实例化表单类 传入 模型ID 栏目ID 栏目数组 $content_form = new content_form($modelid); //生成对应字段的输入表单 $forminfos = $content_form->get(); $forminfos = $forminfos['base']; //生成对应的JS提示等 $formValidator = $content_form->formValidator; $this->assign("forminfos", $forminfos); $this->assign("formValidator", $formValidator); $this->assign("name", $moinfo['name']); $this->assign("modelid", $modelid); $this->assign("formid", $modelid); if ($action == 'js') { //获取模板路径 $filepath = TEMPLATE_PATH . (empty(AppframeAction::$Cache["Config"]['theme']) ? "Default" : AppframeAction::$Cache["Config"]['theme']) . "/Formguide/"; $html = $this->fetch($filepath . "Show/" . $show_js_template . C("TMPL_TEMPLATE_SUFFIX")); $dojs = $this->format_js($html); //输出js exit($dojs); } $this->display("Show:" . ($action == "js" ? $show_js_template : $show_template)); }
/** * 编辑信息 */ public function edit() { $catid = $this->_get("catid"); $catid = empty($catid) ? (int) $_POST['info']['catid'] : $catid; $id = $this->_get("id"); $id = empty($id) ? $this->_post("id") : $id; if (empty($catid) || empty($id)) { $this->error("参数不完整!"); } $Categorys = $this->categorys[$catid]; if (empty($Categorys)) { $this->error("该栏目不存在!"); } //栏目setting配置 $cat_setting = unserialize($Categorys['setting']); //检查是否锁定 $this->locking($catid, $id); $this->modelid = $modelid = $Categorys['modelid']; //取得表名 $this->table_name = ucwords($this->Model[$Categorys['modelid']]['tablename']); $this->fbtable_name = $this->table_name . "_data"; if (empty($this->table_name)) { $this->error("模型不存在!"); } //检查模型是否被禁用 if ($this->Model[$Categorys['modelid']]['disabled'] == 1) { $this->error("模型被禁用!"); } if (IS_POST) { if (trim($_POST['info']['title']) == '') { $this->error("标题不能为空!"); } import('Content'); $Content = new Content(); //取得原有文章信息 $data = M($this->table_name)->where(array("catid" => $catid, "id" => $id))->find(); //如果有自定义文件名,需要删除原来生成的静态文件 if ($_POST['info']['prefix'] != $data['prefix'] && $cat_setting['content_ishtml']) { //删除原来的生成的静态页面 $Content->deleteHtml($catid, $id, $data['inputtime'], $data['prefix']); } $status = $Content->edit($_POST['info'], $id); if ($status) { //解除信息锁定 M("Locking")->where(array("userid" => AppframeAction::$Cache["uid"], "catid" => $catid, "id" => $id))->delete(); $this->success("修改成功!"); } else { $this->error("修改失败!"); } } else { $this->Content = new ContentModel($this->table_name); //取得数据,这里使用关联查询 $data = $this->Content->relation(true)->where(array("id" => $id))->find(); if (!$data) { $this->error("该信息不存在!"); } //锁定信息 M("Locking")->add(array("userid" => AppframeAction::$Cache["uid"], "username" => AppframeAction::$Cache["username"], "catid" => $catid, "id" => $id, "locktime" => time())); //数据处理,把关联查询的结果集合并 $datafb = $data[$this->fbtable_name]; unset($data[$this->fbtable_name]); $data = array_merge($data, $datafb); //引入输入表单处理类 require_cache(RUNTIME_PATH . 'content_form.class.php'); $content_form = new content_form($modelid, $catid, $this->categorys); //字段内容 $forminfos = $content_form->get($data); //生成对应的JS验证规则 $formValidateRules = $content_form->formValidateRules; //js验证不通过提示语 $formValidateMessages = $content_form->formValidateMessages; //js $formJavascript = $content_form->formJavascript; $this->assign("category", $Categorys); $this->assign("data", $data); $this->assign("catid", $catid); $this->assign("id", $id); $this->assign("uploadurl", CONFIG_SITEFILEURL); $this->assign("content_form", $content_form); $this->assign("forminfos", $forminfos); $this->assign("formValidateRules", $formValidateRules); $this->assign("formValidateMessages", $formValidateMessages); $this->assign("formJavascript", $formJavascript); $this->display(); } }
public function edit() { if (IS_POST) { $hash[C('TOKEN_NAME')] = $_POST[C('TOKEN_NAME')]; $this->db->set_model($_POST['modelid']); if (!$this->db->autoCheckToken($hash)) { $this->error('令牌验证失败!'); } if ($id = $this->db->edit_content()) { if ($_POST['dosubmit_continue']) { $this->success('更新成功'); } else { $returnjs = 'function set_time() {$("#secondid").html(1);}setTimeout("set_time()", 500);setTimeout("window.close()", 1200);'; $this->assign('closeWin', true); $this->assign('returnjs', $returnjs); $this->success('更新成功,<span id="secondid">2</span>秒后关闭!'); } } else { // echo $this->db->getLastSql(); $this->error('更新失败!'); } } else { import('ORG.Util.Form'); $catid = intval($_GET['catid']); $category = $this->category_db->where("siteid = %d and id = %d", $this->siteid, $catid)->find(); $modelid = intval($category['modelid']); $this->db->set_model($modelid); $content = $this->db->get_content(intval($_GET['contentid'])); $categorys = $this->category_db->where('siteid = %d', $this->siteid)->order('listorder desc, id asc')->select(); $this->categorys = array(); if (!empty($categorys)) { foreach ($categorys as $key => $r) { $this->categorys[$r['id']] = $r; } } require MODEL_PATH . 'content_form.class.php'; $content_form = new content_form($modelid, $catid, $this->categorys); $forminfos = $content_form->get($content); $this->assign('formValidator', $content_form->formValidator); $this->assign('catid', $catid); $this->assign('forminfos', $forminfos); $this->assign('content_id', $content['id']); $this->assign('modelid', $modelid); /*load('extend'); $catid = intval($_GET['catid']); $category = $this->category_db->where("siteid = %d and id = %d", $this->siteid, $catid)->find(); $this->db->set_model($category['modelid']); $content = $this->db->get_content(intval($_GET['contentid']),$category['id']); // 推荐位载入 import("ORG.Util.Form"); $categorys = $this->category_db->where('siteid = %d',$this->siteid)->field('id, arrchildid')->select(); $this->categorys = array(); if (!empty($categorys)) { foreach ($categorys as $key => $r) { $this->categorys[$r['id']] = $r; } } $position = D('Position')->select(); if(empty($position)) return ''; $array = array(); foreach($position as $_key=>$_value) { if($_value['modelid'] && ($_value['modelid'] != $category['modelid']) || ($_value['catid'] && strpos(','.$this->categorys[$_value['catid']]['arrchildid'].',',','.$catid.',')===false)) { continue; } $array[$_value['id']] = $_value['name']; } $position_data = D('PositionData')->where('id = %d and modelid = %d', $content['id'], $category['modelid'])->field('posid')->group('posid')->select(); $position_data_ids = array(); foreach ($position_data as $key => $pos) { $position_data_ids[] = $pos['posid']; } $posids = implode(',', $position_data_ids); $posidstr = form::checkbox($array,$posids,"name='info[posids][]'",'',125); // END 推荐位载入 $this->assign('posidstr',$posidstr); $this->assign('content', $content); $this->assign('category', $category); $this->assign('catid', intval($_GET['catid']));*/ $this->display(); } }
public function priview() { import('Form'); //模型ID $modelid = I('get.modelid'); if (empty($modelid)) { $this->error("请指定模型!"); } //载入 content_form.class.php 缓存文件 if (false == require_cache(RUNTIME_PATH . 'content_form.class.php')) { D("Category")->category_cache(); D("Content_cache")->model_content_cache(); require RUNTIME_PATH . 'content_form.class.php'; } $content_form = new content_form($modelid); //生成对应字段的输入表单 $forminfos = $content_form->get(); //生成对应的JS验证规则 $formValidateRules = $content_form->formValidateRules; //js验证不通过提示语 $formValidateMessages = $content_form->formValidateMessages; //js $formJavascript = $content_form->formJavascript; //获取当前模型信息 $r = M("Model")->where(array("modelid" => $modelid))->find(); $this->assign("r", $r); $this->assign("forminfos", $forminfos); $this->assign("formValidateRules", $formValidateRules); $this->assign("formValidateMessages", $formValidateMessages); $this->assign("formJavascript", $formJavascript); $this->display(); }
/** * 预览模型 */ public function public_priview() { pc_base::load_sys_class('form', '', 0); $show_header = ''; $modelid = intval($_GET['modelid']); require CACHE_MODEL_PATH . 'content_form.class.php'; $content_form = new content_form($modelid); $forminfos = $content_form->get(); include $this->admin_tpl('sitemodel_priview'); }
public function edit() { $this->catid = (int) $_POST['info']['catid'] ?: $this->catid; //信息ID $id = I('request.id', 0, 'intval'); $Categorys = getCategory($this->catid); if (empty($Categorys)) { $this->error("该栏目不存在!"); } //栏目setting配置 $cat_setting = $Categorys['setting']; //模型ID $modelid = $Categorys['modelid']; //检查模型是否被禁用 if ($this->model[$Categorys['modelid']]['disabled'] == 1) { $this->error("模型被禁用!"); } $model = ContentModel::getInstance($modelid); //检查是否锁定 if (false === $model->locking($this->catid, $id)) { $this->error($model->getError()); } if (IS_POST) { if (trim($_POST['info']['title']) == '') { $this->error("标题不能为空!"); } $id = $id ?: $_POST['info']['id']; //取得原有文章信息 $data = $model->where(array("id" => $id))->find(); //如果有自定义文件名,需要删除原来生成的静态文件 if ($_POST['info']['prefix'] != $data['prefix'] && $cat_setting['content_ishtml']) { //删除原来的生成的静态页面 $this->Content->data($data)->deleteHtml(); } $status = $this->Content->data($_POST['info'])->edit(); if ($status) { //解除信息锁定 M("Locking")->where(array("userid" => User::getInstance()->id, "catid" => $catid, "id" => $id))->delete(); $this->success("修改成功!"); } else { $this->error($this->Content->getError()); } } else { //取得数据,这里使用关联查询 $data = $model->relation(true)->where(array("id" => $id))->find(); if (empty($data)) { $this->error("该信息不存在!"); } $model->dataMerger($data); //锁定信息 M("Locking")->add(array("userid" => User::getInstance()->id, "username" => User::getInstance()->username, "catid" => $this->catid, "id" => $id, "locktime" => time())); //引入输入表单处理类 $content_form = new \content_form($modelid, $this->catid); //字段内容 $forminfos = $content_form->get($data); //生成对应的JS验证规则 $formValidateRules = $content_form->formValidateRules; //js验证不通过提示语 $formValidateMessages = $content_form->formValidateMessages; //js $formJavascript = $content_form->formJavascript; $this->assign("category", $Categorys); $this->assign("data", $data); $this->assign("catid", $this->catid); $this->assign("id", $id); $this->assign("content_form", $content_form); $this->assign("forminfos", $forminfos); $this->assign("formValidateRules", $formValidateRules); $this->assign("formValidateMessages", $formValidateMessages); $this->assign("formJavascript", $formJavascript); $this->display(); } }
public function edit() { // 获取模型信息 $model_db = D('Model'); $model = $model_db->where(array('tablename' => $this->dbName))->find(); if (empty($model)) { $this->error('模型不存在!'); } if (IS_POST) { $hash[C('TOKEN_NAME')] = $_POST[C('TOKEN_NAME')]; if (!$this->db->autoCheckToken($hash)) { $this->error('令牌验证失败, 请刷新页面'); } if (!isset($_POST['id'])) { $this->error('参数缺失!'); } $this->moduleDb->setModel($model['id']); if ($this->moduleDb->editContent()) { $this->success('更新成功!', 'index'); } else { $this->error('更新失败!'); } } else { if (!isset($_GET['id'])) { $this->error('参数缺失!'); } // 设置模型,获取内容 $this->moduleDb->setModel($model['id']); $content = $this->moduleDb->getContent($_GET['id']); if (empty($content)) { $this->error('内容不存在!'); } require MODEL_PATH . 'content_form.class.php'; $content_form = new \content_form($model['id']); $forminfos = $content_form->get($content); $forminfos = array_merge($forminfos['base'], $forminfos['senior']); $this->assign('formValidator', $content_form->formValidator); $this->assign('forminfos', $forminfos); $this->assign('content', $content); $this->assign('module', $model); $this->display('Module:edit'); } }
public function edit() { if (IS_POST) { $hash[C('TOKEN_NAME')] = $_POST[C('TOKEN_NAME')]; $this->db->set_model($_POST['modelid']); if (!$this->db->autoCheckToken($hash)) { $this->error('令牌验证失败!'); } if ($id = $this->db->edit_content()) { if ($_POST['dosubmit_continue']) { $this->success('更新成功'); } else { $returnjs = 'function set_time() {$("#secondid").html(1);}setTimeout("set_time()", 500);setTimeout("window.close()", 1200);'; $this->assign('closeWin', true); $this->assign('returnjs', $returnjs); $this->success('更新成功,<span id="secondid">2</span>秒后关闭!'); } } else { // echo $this->db->getLastSql(); $this->error('更新失败!'); } } else { $catid = intval($_GET['catid']); $category = $this->category_db->where("siteid = %d and id = %d", $this->siteid, $catid)->find(); $modelid = intval($category['modelid']); $this->db->set_model($modelid); $content = $this->db->get_content(intval($_GET['contentid'])); $categorys = $this->category_db->where('siteid = %d', $this->siteid)->order('listorder desc, id asc')->select(); $this->categorys = array(); if (!empty($categorys)) { foreach ($categorys as $key => $r) { $this->categorys[$r['id']] = $r; } } require MODEL_PATH . 'content_form.class.php'; $content_form = new \content_form($modelid, $catid, $this->categorys); $forminfos = $content_form->get($content); $this->assign('formValidator', $content_form->formValidator); $this->assign('catid', $catid); $this->assign('status', $content['status']); $this->assign('forminfos', $forminfos); $this->assign('content_id', $content['id']); $this->assign('modelid', $modelid); $this->display(); } }
public function priview() { //模型ID $modelid = I('get.modelid'); if (empty($modelid)) { $this->error("请指定模型!"); } cache('Model', NULL); cache('ModelField', NULL); $content_form = new \content_form($modelid); //生成对应字段的输入表单 $forminfos = $content_form->get(); //生成对应的JS验证规则 $formValidateRules = $content_form->formValidateRules; //js验证不通过提示语 $formValidateMessages = $content_form->formValidateMessages; //js $formJavascript = $content_form->formJavascript; //获取当前模型信息 $r = M("Model")->where(array("modelid" => $modelid))->find(); $this->assign("r", $r); $this->assign("forminfos", $forminfos); $this->assign("formValidateRules", $formValidateRules); $this->assign("formValidateMessages", $formValidateMessages); $this->assign("formJavascript", $formJavascript); $this->display(); }
/** * 修改会员 */ public function edit() { $Member = D("Member"); if (IS_POST) { $data = $Member->create(); if ($data) { //根据积分,算出用户组 if (isset($data['point'])) { $data['groupid'] = $_POST['groupid'] = $Member->get_usergroup_bypoint($data['point']); } //检测帐号基本信息是否需要做修改:密码,邮箱 //========================用户名,旧密码,新密码,邮箱,是否忽略旧密码1 $edit = service("Passport")->user_edit($data['username'], $data['password'], $data['password'], $data['email'], 1, $data); if ($edit < 0) { switch ($edit) { case -4: $this->error("Email 格式有误!"); break; case -5: $this->error("Email 不允许注册!"); break; case -6: $this->error("该 Email 已经被注册!"); break; default: $this->error("修改失败!"); break; } } //判断是否需要删除头像 if ($this->_post("delavatar")) { service("Passport")->user_deleteavatar($data['userid']); } $modelid = $this->_post('modelid'); require_cache(RUNTIME_PATH . 'content_input.class.php'); $content_input = new content_input($modelid, $this); $inputinfo = $content_input->get($_POST['info']); //取得模型内容 $modedata = $inputinfo['model']; $Model_Member = F("Model_Member"); $tablename = ucwords($Model_Member[$modelid]['tablename']); M($tablename)->where(array("userid" => $data['userid']))->save($modedata); $this->success("更新成功!"); } else { $this->error($Member->getError()); } } else { $userid = (int) $this->_get("userid"); //主表 $data = $Member->where(array("userid" => $userid))->find(); if ($this->_get("modelid")) { $modelid = (int) $this->_get("modelid"); if (!$this->Model_Member[$modelid]) { $this->error("该模型不存在!"); } } else { $modelid = $data['modelid']; } if (!$data) { $this->error("该会员不存在!"); } $Model_Member = F("Model_Member"); $tablename = $Model_Member[$modelid]['tablename']; //相应会员模型数据 $modeldata = M(ucwords($tablename))->where(array("userid" => $userid))->find(); if (!is_array($modeldata)) { $modeldata = array(); } $data = array_merge($data, $modeldata); //引入输入表单处理类 require RUNTIME_PATH . 'content_form.class.php'; $content_form = new content_form($modelid); $data['modelid'] = $modelid; //字段内容 $forminfos = $content_form->get($data); //js提示 $formValidator = $content_form->formValidator; $this->assign("forminfos", $forminfos); $this->assign("formValidator", $formValidator); $this->assign("data", $data); $this->assign("show_header", true); $this->display(); } }
/** * 预览模型 */ public function public_priview() { $show_header = $show_validator = $show_dialog = ''; $modelid = intval($_GET['modelid']); require CACHE_MODEL_PATH . 'content_form.php'; $content_form = new content_form($modelid); $r = $this->model_db->where(array('modelid' => $modelid))->find(); $forminfos = $content_form->get(); include $this->view('model_priview'); }
/** * 编辑 */ public function edit() { $catid = $this->_get("catid"); $catid = empty($catid) ? (int) $_POST['info']['catid'] : $catid; $id = $this->_get("id"); $id = empty($id) ? $this->_post("id") : $id; if (empty($catid) || empty($id)) { $this->error("参数不完整!"); } $Categorys = $this->categorys[$catid]; $this->modelid = $modelid = $Categorys['modelid']; //检查模型是否被禁用 if ($this->Model[$modelid]['disabled'] == 1) { $this->error("模型被禁用!"); } if (IS_POST) { if (trim($_POST['info']['title']) == '') { $this->error("标题不能为空!"); } import('Content'); $Content = new Content(); define("GROUP_MODULE", "Contents"); $status = $Content->edit($_POST['info'], $id); if ($status) { $this->success("修改成功!", U("Content/mybutors")); } else { $this->error("修改失败!"); } } else { $this->table_name = ucwords($this->Model[$Categorys['modelid']]['tablename']); $this->fbtable_name = $this->table_name . "_data"; $this->Content = new ContentModel($this->table_name); //取得数据,这里使用关联查询 $data = $this->Content->relation(true)->where(array("id" => $id))->find(); if (!$data) { $this->error("该信息不存在!"); } //数据处理,把关联查询的结果集合并 $datafb = $data[$this->fbtable_name]; unset($data[$this->fbtable_name]); $data = array_merge($data, $datafb); //引入输入表单处理类 require_cache(RUNTIME_PATH . 'content_form.class.php'); $content_form = new content_form($modelid, $catid, $this->categorys); //字段内容 $forminfos = $content_form->get($data); $forminfos = array_merge($forminfos['base'], $forminfos['senior']); //生成对应的JS验证规则 $formValidateRules = $content_form->formValidateRules; //js验证不通过提示语 $formValidateMessages = $content_form->formValidateMessages; //js $formJavascript = $content_form->formJavascript; $this->assign("data", $data); $this->assign("catid", $catid); $this->assign("id", $id); $this->assign("uploadurl", CONFIG_SITEFILEURL); $this->assign("content_form", $content_form); $this->assign("forminfos", $forminfos); $this->assign("formValidateRules", $formValidateRules); $this->assign("formValidateMessages", $formValidateMessages); $this->assign("formJavascript", $formJavascript); $this->assign("Categorys", $this->categorys); $this->display(); } }
<?php require_once '../thinkedit.init.php'; require_once '../class/content_form.class.php'; error_reporting(E_ALL); ini_set('display_errors', true); $form = new content_form('participation'); echo $form->render(); if ($form->isValid()) { echo '<h1>form is valid</h1>'; } else { echo '<h1>form is NOT valid</h1>'; } echo '<pre>'; print_r($form->getContentAsArray()); //echo te_admin_toolbox();
public function info_publish() { $memberinfo = $this->memberinfo; $grouplist = getcache('grouplist'); $SEO['title'] = L('info_publish', '', 'info'); //判断会员组是否允许投稿 if (!$grouplist[$memberinfo['groupid']]['allowpost']) { showmessage(L('member_group') . L('publish_deny'), HTTP_REFERER); } //判断每日投稿数 $this->content_check_db = pc_base::load_model('content_check_model'); $todaytime = strtotime(date('y-m-d', SYS_TIME)); $_username = $memberinfo['username']; $allowpostnum = $this->content_check_db->count("`inputtime` > {$todaytime} AND `username`='{$_username}'"); if ($grouplist[$memberinfo['groupid']]['allowpostnum'] > 0 && $allowpostnum >= $grouplist[$memberinfo['groupid']]['allowpostnum']) { showmessage(L('allowpostnum_deny') . $grouplist[$memberinfo['groupid']]['allowpostnum'], HTTP_REFERER); } $siteids = getcache('category_content', 'commons'); header("Cache-control: private"); if (isset($_POST['dosubmit'])) { $catid = intval($_POST['info']['catid']); $siteid = $siteids[$catid]; $CATEGORYS = getcache('category_content_' . $siteid, 'commons'); $category = $CATEGORYS[$catid]; $modelid = $category['modelid']; if (!$modelid) { showmessage(L('illegal_parameters'), HTTP_REFERER); } $this->content_db = pc_base::load_model('content_model'); $this->content_db->set_model($modelid); $table_name = $this->content_db->table_name; $fields_sys = $this->content_db->get_fields(); $this->content_db->table_name = $table_name . '_data'; $fields_attr = $this->content_db->get_fields(); $fields = array_merge($fields_sys, $fields_attr); $fields = array_keys($fields); $info = array(); foreach ($_POST['info'] as $_k => $_v) { if (in_array($_k, $fields)) { $info[$_k] = $_v; } } $post_fields = array_keys($_POST['info']); $post_fields = array_intersect_assoc($fields, $post_fields); $setting = string2array($category['setting']); if ($setting['presentpoint'] < 0 && $memberinfo['point'] < abs($setting['presentpoint'])) { showmessage(L('points_less_than', array('point' => $memberinfo['point'], 'need_point' => abs($setting['presentpoint']))), APP_PATH . 'index.php?m=pay&c=deposit&a=pay&exchange=point', 3000); } //判断会员组投稿是否需要审核 if ($grouplist[$memberinfo['groupid']]['allowpostverify'] || !$setting['workflowid']) { $info['status'] = 99; } else { $info['status'] = 1; } $info['username'] = $memberinfo['username']; $this->content_db->siteid = $siteid; $id = $this->content_db->add_content($info); //检查投稿奖励或扣除积分 $flag = $catid . '_' . $id; if ($setting['presentpoint'] > 0) { pc_base::load_app_class('receipts', 'pay', 0); receipts::point($setting['presentpoint'], $memberinfo['userid'], $memberinfo['username'], $flag, 'selfincome', L('contribute_add_point'), $memberinfo['username']); } else { pc_base::load_app_class('spend', 'pay', 0); spend::point($setting['presentpoint'], L('contribute_del_point'), $memberinfo['userid'], $memberinfo['username'], '', '', $flag); } //缓存结果 $model_cache = getcache('model', 'commons'); $infos = array(); foreach ($model_cache as $modelid => $model) { if ($model['siteid'] == $siteid) { $datas = array(); $this->content_db->set_model($modelid); $datas = $this->content_db->select(array('username' => $memberinfo['username'], 'sysadd' => 0), 'id,catid,title,url,username,sysadd,inputtime,status', 100, 'id DESC'); } } setcache('member_' . $memberinfo['userid'] . '_' . $siteid, $infos, 'content'); //缓存结果 END if ($info['status'] == 99) { showmessage(L('contributors_success'), APP_PATH . 'index.php?m=member&c=content&a=info_top&id=' . $id . '&catid=' . $catid . '&msg=1'); } else { showmessage(L('contributors_checked'), APP_PATH . 'index.php?m=member&c=content&a=info_top&id=' . $id . '&catid=' . $catid . '&msg=1'); } } else { $show_header = $show_dialog = $show_validator = ''; $step = $step_1 = $step_2 = $step_3 = $step_4; $temp_language = L('news', '', 'content'); $sitelist = getcache('sitelist', 'commons'); /* if(!isset($_GET['siteid']) && count($sitelist)>1) { include template('member', 'content_publish_select_model'); exit; } */ //设置cookie 在附件添加处调用 param::set_cookie('module', 'content'); $siteid = intval($_GET['siteid']); //获取信息模型类别、区域、城市信息 $info_linkageid = getinfocache('info_linkageid'); $cityid = getcity(trim($_GET['city']), 'linkageid'); $cityname = getcity(trim($_GET['city']), 'name'); $citypinyin = getcity(trim($_GET['city']), 'pinyin'); $zone = intval($_GET['zone']); $zone_name = get_linkage($zone, $info_linkageid, '', 0); if (!$siteid) { $siteid = 1; } $CATEGORYS = getcache('category_content_' . $siteid, 'commons'); $priv_db = pc_base::load_model('category_priv_model'); //加载栏目权限表数据模型 foreach ($CATEGORYS as $catid => $cat) { if ($cat['siteid'] == $siteid && $cat['child'] == 0 && $cat['type'] == 0 && $priv_db->get_one(array('catid' => $catid, 'roleid' => $memberinfo['groupid'], 'is_admin' => 0, 'action' => 'add'))) { break; } } $catid = $_GET['catid'] ? intval($_GET['catid']) : $catid; if (!$catid) { showmessage(L('category') . L('publish_deny'), APP_PATH . 'index.php?m=member'); } //判断本栏目是否允许投稿 if (!$priv_db->get_one(array('catid' => $catid, 'roleid' => $memberinfo['groupid'], 'is_admin' => 0, 'action' => 'add'))) { showmessage(L('category') . L('publish_deny'), APP_PATH . 'index.php?m=member'); } $category = $CATEGORYS[$catid]; if ($category['siteid'] != $siteid) { showmessage(L('site_no_category'), '?m=member&c=content&a=info_publish'); } $setting = string2array($category['setting']); if ($zone == 0 && !isset($_GET['catid'])) { $step = 1; include template('member', 'info_content_publish_select'); exit; } elseif ($zone == 0 && $category['child']) { $step = 2; $step_1 = '<a href="' . APP_PATH . 'index.php?m=member&c=content&a=info_publish&siteid=' . $siteid . '&city=' . $citypinyin . '">' . $category['catname'] . '</a>'; include template('member', 'info_content_publish_select'); exit; } elseif ($zone == 0 && isset($_GET['catid'])) { $step = 3; $step_1 = '<a href="' . APP_PATH . 'index.php?m=member&c=content&a=info_publish&siteid=' . $siteid . '">' . $CATEGORYS[$category['parentid']]['catname'] . '</a>'; $step_2 = '<a href="' . APP_PATH . 'index.php?m=member&c=content&a=info_publish&siteid=' . $siteid . '&city=' . $citypinyin . '&catid=' . $category['parentid'] . '">' . $category['catname'] . '</a>'; $zone_arrchild = show_linkage($info_linkageid, $cityid, $cityid); include template('member', 'info_content_publish_select'); exit; } elseif ($zone !== 0 && get_linkage_level($info_linkageid, $zone, 'child') && !$_GET['jumpstep']) { $step = 4; $step_1 = '<a href="' . APP_PATH . 'index.php?m=member&c=content&a=info_publish&siteid=' . $siteid . '&city=' . $citypinyin . '">' . $CATEGORYS[$category['parentid']]['catname'] . '</a>'; $step_2 = '<a href="' . APP_PATH . 'index.php?m=member&c=content&a=info_publish&siteid=' . $siteid . '&city=' . $citypinyin . '&catid=' . $category['parentid'] . '">' . $category['catname'] . '</a>'; $step_3 = '<a href="' . APP_PATH . 'index.php?m=member&c=content&a=info_publish&siteid=' . $siteid . '&city=' . $citypinyin . '&catid=' . $catid . '">' . $zone_name . '</a>'; $zone_arrchild = get_linkage_level($info_linkageid, $zone, 'arrchildinfo'); include template('member', 'info_content_publish_select'); exit; } if ($setting['presentpoint'] < 0 && $memberinfo['point'] < abs($setting['presentpoint'])) { showmessage(L('points_less_than', array('point' => $memberinfo['point'], 'need_point' => abs($setting['presentpoint']))), APP_PATH . 'index.php?m=pay&c=deposit&a=pay&exchange=point', 3000); } if ($category['type'] != 0) { showmessage(L('illegal_operation')); } $modelid = $category['modelid']; require CACHE_MODEL_PATH . 'content_form.class.php'; $content_form = new content_form($modelid, $catid, $CATEGORYS); $data = array('zone' => $zone, 'city' => $cityid); $forminfos_data = $content_form->get($data); $forminfos = array(); foreach ($forminfos_data as $_fk => $_fv) { if ($_fv['isomnipotent']) { continue; } if ($_fv['formtype'] == 'omnipotent') { foreach ($forminfos_data as $_fm => $_fm_value) { if ($_fm_value['isomnipotent']) { $_fv['form'] = str_replace('{' . $_fm . '}', $_fm_value['form'], $_fv['form']); } } } $forminfos[$_fk] = $_fv; } $formValidator = $content_form->formValidator; //去掉栏目id unset($forminfos['catid']); $workflowid = $setting['workflowid']; header("Cache-control: private"); include template('member', 'info_content_publish'); } }
/** * 预览模型 */ public function public_priview() { import('ORG.Util.Form'); $modelid = intval($_GET['modelid']); require MODEL_PATH . 'content_form.class.php'; $content_form = new content_form($modelid); $r = $this->model_db->where(array('id' => $modelid))->find(); $forminfos = $content_form->get(); $this->assign('r', $r); $this->assign('forminfos', $forminfos); $this->display(); }
public function edit() { $this->catid = empty($this->catid) ? (int) $_POST['info']['catid'] : $this->catid; //信息ID $id = I('request.id', 0, 'intval'); $Categorys = getCategory($this->catid); if (empty($Categorys)) { $this->error("该栏目不存在!"); } //栏目setting配置 $cat_setting = $Categorys['setting']; //模型ID $modelid = $Categorys['modelid']; //检查模型是否被禁用 if ($this->model[$Categorys['modelid']]['disabled'] == 1) { $this->error("模型被禁用!"); } $this->contentModel = ContentModel::getInstance($modelid); //检查是否锁定 if (false === $this->contentModel->locking($this->catid, $id)) { $this->error($this->contentModel->getError()); } if (IS_POST) { if (trim($_POST['info']['title']) == '') { $this->error("标题不能为空!"); } import('Content'); $Content = get_instance_of('Content'); //取得原有文章信息 $data = $this->contentModel->where(array("id" => $id))->find(); //如果有自定义文件名,需要删除原来生成的静态文件 if ($_POST['info']['prefix'] != $data['prefix'] && $cat_setting['content_ishtml']) { //删除原来的生成的静态页面 $Content->deleteHtml($this->catid, $id, $data['inputtime'], $data['prefix'], $data); } $status = $Content->edit($_POST['info'], $id); if ($status) { //解除信息锁定 M("Locking")->where(array("userid" => AppframeAction::$Cache["uid"], "catid" => $catid, "id" => $id))->delete(); $this->success("修改成功!"); } else { $this->error($Content->getError()); } } else { //取得数据,这里使用关联查询 $data = $this->contentModel->relation(true)->where(array("id" => $id))->find(); if (empty($data)) { $this->error("该信息不存在!"); } $this->contentModel->dataMerger($data); //锁定信息 M("Locking")->add(array("userid" => AppframeAction::$Cache["uid"], "username" => AppframeAction::$Cache["username"], "catid" => $this->catid, "id" => $id, "locktime" => time())); //引入输入表单处理类 if (false == require_cache(RUNTIME_PATH . 'content_form.class.php')) { D("Category")->category_cache(); D("Content_cache")->model_content_cache(); require RUNTIME_PATH . 'content_form.class.php'; } $content_form = new content_form($modelid, $this->catid); //字段内容 $forminfos = $content_form->get($data); //生成对应的JS验证规则 $formValidateRules = $content_form->formValidateRules; //js验证不通过提示语 $formValidateMessages = $content_form->formValidateMessages; //js $formJavascript = $content_form->formJavascript; $this->assign("category", $Categorys); $this->assign("data", $data); $this->assign("catid", $this->catid); $this->assign("id", $id); $this->assign("uploadurl", CONFIG_SITEFILEURL); $this->assign("content_form", $content_form); $this->assign("forminfos", $forminfos); $this->assign("formValidateRules", $formValidateRules); $this->assign("formValidateMessages", $formValidateMessages); $this->assign("formJavascript", $formJavascript); if ($category['type'] == 1) { $this->display('singlepage_edit'); } else { $this->display(); } } }
/** * 预览模型 */ public function public_priview() { import('ORG.Util.Form'); $modelid = intval($_GET['modelid']); require MODEL_PATH . 'content_form.class.php'; $content_form = new \content_form($modelid); $module = $this->model_db->where(array('id' => $modelid))->find(); $forminfos = $content_form->get(); $forminfos = array_merge($forminfos['base'], $forminfos['senior']); $this->assign('formValidator', $content_form->formValidator); $this->assign('forminfos', $forminfos); $this->assign('module', $module); $this->display(); }
/** * connect登陆注册 */ public function connectregister() { import('Form'); C("TOKEN_ON", false); $openid = session("Connect_openid"); $app = session("Connect_app"); if (!$openid || !$app) { $this->error("请授权后再操作!"); } //允许新会员注册 if (!$this->Member_config['allowregister']) { $this->error("系统不允许新会员注册!", U("Index/public_binding")); } if (AppframeAction::$Cache['uid']) { $this->success("您已经是登陆状态!", U("Index/index")); exit; } if (IS_POST) { $code = $this->_post("code"); $username = $this->_post("username"); $password = $this->_post("password"); $email = $this->_post("email"); //验证码开始验证 if (!$this->verify($code)) { $this->error("验证码错误,请重新输入!"); } $Member = D("Member"); $data = $Member->create(); if ($data) { //新会员注册需要管理员审核 if ($this->Member_config['registerverify']) { $data['checked'] = 0; } else { $data['checked'] = 1; } $data = array_merge($_POST, $data); $status = $this->registeradd($username, $password, $email, $data); if ($status > 0 || $status == -8) { $this->connectAdd($status, $app, $openid); $Member = M("Member"); $info = $Member->where(array("userid" => $status))->find(); if (!$data['checked']) { $this->success("会员注册成功,但需要管理员审核通过!", CONFIG_SITEURL); exit; } service("Passport")->registerLogin($info); $this->success("会员注册成功!", U("Index/index")); exit; } else { switch ($status) { case -1: $error = '用户名不合法!'; break; case -2: $error = '包含不允许注册的词语!'; break; case -3: $error = '用户名已经存在!'; break; case -4: $error = 'Email 格式有误!'; break; case -5: $error = 'Email 不允许注册!'; break; case -6: $error = '该 Email 已经被注册!'; break; case -7: $error = '模型ID为空!'; break; default: $error = '注册会员失败!'; break; } } $this->error($error); } else { $this->error($Member->getError()); } } else { $choosemodel = $this->Member_config['choosemodel']; $defaultmodelid = $this->Member_config['defaultmodelid']; $showregprotocol = $this->Member_config['showregprotocol']; $appid = $this->Member_config['qq_akey']; //是否允许用户自己选择注册模型 if ($choosemodel) { $modelid = $this->_get("modelid"); } $modelid = $modelid ? $modelid : $defaultmodelid; //模型缓存 $Model_Member = F("Model_Member"); if (!$Model_Member[$modelid]) { $this->error("该会员模型不存在!"); } require_cache(RUNTIME_PATH . 'content_form.class.php'); //实例化表单类 传入 模型ID 栏目ID 栏目数组 $content_form = new content_form($modelid); //生成对应字段的输入表单 $forminfos = $content_form->get(); //生成对应的JS提示等 $formValidator = $content_form->formValidator; import('Util.Curl', APP_PATH . 'Lib'); $curl = new Curl(); $connect = array(); //授权的相关信息 switch (session("Connect_app")) { case "qq": $connect['name'] = "QQ授权登陆"; //取得授权用户基本信息 $sUrl = "https://graph.qq.com/user/get_user_info?"; $aGetParam = array("access_token" => session("access_token"), "oauth_consumer_key" => $appid, "openid" => session("Connect_openid"), "format" => "json"); $user_info = $curl->get($sUrl . http_build_query($aGetParam)); //把json数据转换为数组 $user_info = json_decode($user_info, true); $connect['userinfo'] = $user_info; $connect['userinfo']['name'] = $user_info['nickname']; break; case "sina_weibo": $connect['name'] = "新浪微博授权登陆"; //取得授权用户基本信息 $sUrl = "https://api.weibo.com/2/users/show.json?"; $aGetParam = array("access_token" => session("access_token"), "uid" => session("Connect_openid")); $user_info = $curl->get($sUrl . http_build_query($aGetParam)); //把json数据转换为数组 $user_info = json_decode($user_info, true); $connect['userinfo'] = $user_info; break; default: break; } $this->assign('showregprotocol', $showregprotocol); $this->assign("protocol", $this->Member_config['regprotocol']); $this->assign("forminfos", $forminfos); $this->assign("formValidator", $formValidator); $this->assign("choosemodel", $this->Member_config['choosemodel']); $this->assign("modelid", $modelid); $this->assign("Model_Member", $Model_Member); $this->assign("connect", $connect); $this->display("Public:connectregister"); } }
public function edit() { if (IS_POST) { $hash[C('TOKEN_NAME')] = $_POST[C('TOKEN_NAME')]; if (!isset($_POST['moduleid']) || !isset($_POST['id'])) { $this->error('模型参数缺失!'); } $module = model('Model')->find($_POST['moduleid']); if (empty($module)) { $this->error('模型不存在!'); } $this->db->setModel($module['id']); if (!$this->db->autoCheckToken($hash)) { $this->error('令牌验证失败, 请刷新页面'); } $data = I('post.info'); $post_id = I('post.id'); $this->db->startTrans(); if ($this->db->editContent($post_id, $data)) { // 分类处理 if (model('category_posts')->where(array('post_id' => $post_id))->delete() === false) { $this->db->rollback(); $this->error('更新失败!'); } $taxonomies = logic('taxonomy')->getPostTaxonomy($module['tablename']); if (!empty($taxonomies)) { $terms = array(); foreach ($taxonomies as $taxonomy) { $key = $module['tablename'] . '_' . $taxonomy['name']; $terms = array_merge($terms, I('post.' . $key, array())); } if (!empty($terms)) { $category_post_datas = array(); foreach ($terms as $key => $value) { $category_post_datas[] = array('term_id' => $value, 'post_id' => $post_id); } if (model('category_posts')->addAll($category_post_datas) !== false) { $this->db->commit(); $this->success('更新成功!', U('Post/index', array('moduleid' => $_POST['moduleid']))); } else { $this->db->rollback(); $this->error('更新失败!'); } } } // 分类处理结束 $this->db->commit(); $this->success('更新成功!', U('Post/index', array('moduleid' => $module['id']))); } else { $this->error('更新失败!'); } } else { if (!isset($_GET['moduleid']) || !isset($_GET['id'])) { $this->error('模型参数缺失!'); } $module = model('Model')->find($_GET['moduleid']); if (empty($module)) { $this->error('模型不存在!'); } // 设置模型,获取内容 $this->db->setModel($module['id']); $post = $this->db->getContent($_GET['id']); if (empty($post)) { $this->error('内容不存在!'); } $taxonomies = logic('taxonomy')->getPostTaxonomy($module['tablename']); $termsGroupByTaxonomy = logic('category')->getPostTermsGroupByTaxonomy($module['tablename']); $category_posts = model('category_posts')->where(array('post_id' => $post['id']))->select(); $post_terms = array(); foreach ($category_posts as $key => $value) { $post_terms[] = $value['term_id']; } require MODEL_PATH . 'content_form.class.php'; $content_form = new \content_form($module['id']); $forminfos = $content_form->get($post); $forminfos = array_merge($forminfos['base'], $forminfos['senior']); $this->assign('taxonomies', $taxonomies); $this->assign('termsGroupByTaxonomy', $termsGroupByTaxonomy); $this->assign('formValidator', $content_form->formValidator); $this->assign('forminfos', $forminfos); $this->assign('content', $post); $this->assign('module', $module); $this->assign('post_terms', $post_terms); $this->display(); } }