/**
  * 推荐位中被推送过来的信息编辑
  * @param type $data
  * @return boolean
  */
 public function positionEdit($data)
 {
     if (!is_array($data)) {
         return false;
     }
     if (!$data['posid'] || !$data['modelid'] || !$data['id']) {
         return false;
     } else {
         $posid = $data['posid'];
         $modelid = $data['modelid'];
         $id = $data['id'];
         unset($data['posid'], $data['modelid'], $data['id']);
     }
     $content_input = new \content_input($modelid);
     $data['data'] = $content_input->get($data['data'], 2);
     $data['data'] = serialize($data['data']);
     if ($this->where(array('id' => $id, 'modelid' => $modelid, 'posid' => $posid))->save($data) !== false) {
         service('Attachment')->api_update('', 'position-' . $modelid . '-' . $id, 1);
         return true;
     }
     return false;
 }
 /**
  * 推荐位中被推送过来的信息编辑
  * @param type $data
  * @return boolean
  */
 public function Position_edit($data)
 {
     if (!is_array($data)) {
         return false;
     }
     if (!$data['posid'] || !$data['modelid'] || !$data['id']) {
         return false;
     }
     //载入数据处理类
     if (false == require_cache(RUNTIME_PATH . 'content_input.class.php')) {
         D("Category")->category_cache();
         D("Content_cache")->model_content_cache();
         require RUNTIME_PATH . 'content_input.class.php';
     }
     $content_input = new content_input($data['modelid']);
     $data['data'] = $content_input->get($data['data'], 2);
     $data['data'] = serialize($data['data']);
     if ($this->save($data) !== false) {
         service("Attachment")->api_update('', 'position-' . $data['modelid'] . '-' . $data['id'], 1);
         return true;
     }
     return false;
 }
 /**
  * 修改个人信息
  */
 public function account_manage_info()
 {
     if (IS_POST) {
         $Member = D("Member");
         //判断昵称是否修改
         if (AppframeAction::$Cache['User']['nickname'] == $_POST['nickname']) {
             unset($_POST['nickname']);
         }
         $data = $Member->create();
         if ($data) {
             if (isset($data['nickname'])) {
                 $Member->where(array("userid" => AppframeAction::$Cache['uid']))->save(array("nickname" => $data['nickname']));
             }
             $modelid = AppframeAction::$Cache['User']['modelid'];
             require 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 = $Model_Member[$modelid]['tablename'];
             $modedata = array_merge($modedata, array("userid" => AppframeAction::$Cache['uid']));
             M(ucwords($tablename))->save($modedata);
             $this->success("更新成功!", U("Index/account_manage_info"));
         } else {
             $this->error($Member->getError());
         }
     } else {
         $data = AppframeAction::$Cache['User'];
         $modelid = $data['modelid'];
         $Model_Member = F("Model_Member");
         $tablename = $Model_Member[$modelid]['tablename'];
         //相应会员模型数据
         $modeldata = M(ucwords($tablename))->where(array("userid" => AppframeAction::$Cache['uid']))->find();
         //引入输入表单处理类
         require RUNTIME_PATH . 'content_form.class.php';
         $content_form = new content_form($modelid);
         $data['modelid'] = $modelid;
         //字段内容
         $forminfos = $content_form->get($modeldata);
         //js提示
         $formValidator = $content_form->formValidator;
         $this->assign("forminfos", $forminfos);
         $this->assign("formValidator", $formValidator);
         $this->assign("data", $data);
         $this->display();
     }
 }
 public function editContent()
 {
     $result = false;
     $modelid = $this->modelid;
     $contentid = intval($_POST['id']);
     $data = $_POST['info'];
     if (isset($data['relation'])) {
         $data['relation'] = array2string($data['relation']);
     }
     require FIELDS_PATH . 'content_input.class.php';
     $content_input = new \content_input($this->modelid);
     $inputinfo = $content_input->get($data);
     $inputinfo = $inputinfo['system'];
     $systeminfo = $this->parseField($inputinfo);
     $systeminfo['siteid'] = get_siteid();
     // 设置更新时间 统一到CommonModel中通过CallBack函数设置
     /*if(isset($content_input->fields['updatetime'])) {
           $setting = string2array($content_input->fields['updatetime']['setting']);
           if ($setting['fieldtype'] == "int") {
               $systeminfo['updatetime'] = time();
           } else {
               $systeminfo['updatetime'] = date($setting['format']);
           }
       }*/
     if ($result = $this->where("id = %d", $contentid)->save($systeminfo) !== false) {
         // 发布到推荐位
         $position_model = D('PositionData');
         if ($position_model->where(array("id" => $contentid, "modelid" => $modelid))->delete() === false) {
             $this->rollback();
             return false;
         }
         if ($systeminfo['posids']) {
             foreach ($data['posids'] as $key => $posid) {
                 if ($posid > 0) {
                     $position_data[] = array('id' => $contentid, 'catid' => $systeminfo['catid'], 'posid' => $posid, 'modelid' => $modelid, 'module' => 'content', 'thumb' => $systeminfo['thumb'], 'siteid' => $systeminfo['siteid'], 'listorder' => $contentid, 'data' => var_export(array('title' => $systeminfo['title'], 'url' => $url, 'description' => $systeminfo['description'], 'inputtime' => $systeminfo['inputtime']), true));
                     $position_model->add($position_data);
                 }
             }
             if (!empty($position_data)) {
                 if (D("PositionData")->addAll($position_data) === false) {
                     $this->rollback();
                     return false;
                 }
             }
         }
         // END 发布到推荐位
         $this->commit();
     } else {
         $this->rollback();
     }
     return $result;
 }
 /**
  * 信息提交
  */
 public function post()
 {
     if (IS_POST) {
         //表单ID
         $modelid = $formid = (int) $this->_post("formid");
         //模型
         $moinfo = $this->Model_form[$formid];
         if (!$moinfo) {
             $this->error("该表单不存在或者已经关闭!");
         }
         $tablename = M('Model')->where(array("modelid" => $formid))->getField("tablename");
         $tablename = ucwords($tablename);
         $db = M($tablename);
         $setting = unserialize($moinfo['setting']);
         $time = time();
         //时间判断
         if ($setting['starttime']) {
             if ($time < (int) $setting['starttime']) {
                 $this->error("还没开始!");
             }
         }
         if ($setting['endtime']) {
             if ($time > (int) $setting['endtime']) {
                 $this->error("已经结束!");
             }
         }
         //是否允许游客提交
         if ((int) $setting['allowunreg'] == 0) {
             //判断是否登陆
             if (!AppframeAction::$Cache['uid']) {
                 $this->error("请先登陆!");
             }
         }
         //是否允许同一IP多次提交
         if ((int) $setting['allowmultisubmit'] == 0) {
             $ip = get_client_ip();
             $count = $db->where(array("ip" => $ip))->count();
             if ($count) {
                 $this->error("你已经提交过了!");
             }
         }
         $info = array_merge($_POST['info'], array(C("TOKEN_NAME") => $_POST[C("TOKEN_NAME")]));
         //关闭表单验证
         C('TOKEN_ON', false);
         $data = $db->create($info);
         if ($data) {
             require_cache(RUNTIME_PATH . 'content_input.class.php');
             require_cache(RUNTIME_PATH . 'content_update.class.php');
             $content_input = new content_input($modelid, $this);
             $inputinfo = $content_input->get($data, 0);
             //检查数据是否有问题!
             if (is_bool($inputinfo) && $inputinfo == false) {
                 $this->error($content_input->error);
             }
             //主表字段内容
             $systeminfo = $inputinfo['system'];
             //增加一些系统必要字段
             $uid = AppframeAction::$Cache['uid'];
             $username = AppframeAction::$Cache['username'];
             $systeminfo['userid'] = $uid ? $uid : 0;
             $systeminfo['username'] = $username ? $username : "******";
             $systeminfo['datetime'] = time();
             $systeminfo['ip'] = get_client_ip();
             if (!$db->autoCheckToken($info)) {
                 $this->error("表单令牌错误!");
             }
             //写入数据
             $id = $db->data($systeminfo)->add();
             if ($id) {
                 //信息量+1
                 M("Model")->where(array("modelid" => $modelid))->setInc("items");
                 //调用 update
                 $content_update = new content_update($modelid, $id, $this);
                 $content_update->update($systeminfo);
                 $forward = $_POST['forward'] ? $_POST['forward'] : "";
                 //发送邮件
                 if ($setting['sendmail'] && $setting['mails']) {
                     $mails = explode("|", $setting['mails']);
                     $title = $systeminfo['username'] . " 提交了新的表单信息!";
                     $message = "刚刚有人在《" . $moinfo['name'] . "》中提交了新的信息,请进入后台查看!";
                     SendMail($mails, $title, $message);
                 }
                 $this->success("提交成功!", $forward);
             } else {
                 $this->error("提交失败!");
             }
         } else {
             $this->error(M($tablename)->getError());
         }
     }
 }
Example #6
0
 /**
  * 修改内容 
  * @param array $data 数据
  * @param type $id 信息ID
  * @return boolean 
  */
 public function edit($data, $id)
 {
     $data['id'] = $id;
     $this->catid = (int) $data['catid'];
     $this->modelid = getCategory($this->catid, 'modelid');
     //取得表单令牌验证码
     $data[C("TOKEN_NAME")] = $_POST[C("TOKEN_NAME")];
     //标签
     tag("content_edit_begin", $data);
     //栏目数据
     $catidinfo = getCategory($this->catid);
     if (empty($catidinfo)) {
         $this->error = '获取不到栏目数据!';
         return false;
     }
     //setting配置
     $catidsetting = $catidinfo['setting'];
     //前台投稿状态判断
     if (defined('IN_ADMIN') && IN_ADMIN == false) {
         //前台投稿编辑是否需要审核
         if ($catidsetting['member_editcheck']) {
             $data['status'] = 1;
         }
     }
     //数据模型对象
     $this->contentModel = ContentModel::getInstance($this->modelid);
     $data['inputtime'] = $inputtime = $this->contentModel->where(array("id" => $id))->getField("inputtime");
     //更新时间处理
     if ($data['updatetime'] && !is_numeric($data['updatetime'])) {
         $data['updatetime'] = strtotime($data['updatetime']);
     } elseif (!$data['updatetime']) {
         $data['updatetime'] = time();
     }
     //自动提取摘要,如果有设置自动提取,且description为空,且有内容字段才执行
     if (isset($_POST['add_introduce']) && $data['description'] == '' && isset($data['content'])) {
         $content = $data['content'];
         $introcude_length = intval($_POST['introcude_length']);
         $data['description'] = str_cut(str_replace(array("\r\n", "\t", '[page]', '[/page]', '&ldquo;', '&rdquo;', '&nbsp;'), '', strip_tags($content)), $introcude_length);
     }
     //转向地址
     if ($data['islink'] == 1) {
         $urls["url"] = $_POST['linkurl'];
     } else {
         //生成该篇地址
         $urls = $this->url->show($data);
     }
     $data['url'] = $urls["url"];
     //inputtime为真实发表时间,不允许修改
     if (isset($data['inputtime'])) {
         unset($data['inputtime']);
     }
     if (false == require_cache(RUNTIME_PATH . 'content_input.class.php')) {
         D("Category")->category_cache();
         D("Content_cache")->model_content_cache();
         require RUNTIME_PATH . 'content_input.class.php';
     }
     $content_input = new content_input($this->modelid);
     //保存一份旧数据
     $oldata = $data;
     $data = $content_input->get($data, 2);
     if ($data) {
         //数据验证
         $data = $this->contentModel->create($data, 2);
         if (false == $data) {
             $this->error = $this->contentModel->getError();
             $this->contentModel->tokenRecovery($data);
             return false;
         }
     } else {
         $this->error = $content_input->getError();
         return false;
     }
     //取得副表下标
     $getRelationName = $this->contentModel->getRelationName();
     //检查content字段在主表还是副表
     $isContent = isset($data['content']) ? 1 : 0;
     //自动提取缩略图,从content 中提取
     if (empty($data['thumb'])) {
         $content = $isContent ? $data['content'] : $data[$getRelationName]['content'];
         $auto_thumb_no = I('.auto_thumb_no', 1, 'intval') - 1;
         if (preg_match_all("/(src)=([\"|']?)([^ \"'>]+\\.(gif|jpg|jpeg|bmp|png))\\2/i", $content, $matches)) {
             $oldata['thumb'] = $data['thumb'] = $matches[3][$auto_thumb_no];
         }
     }
     //数据修改,这里使用关联操作
     $status = $this->contentModel->relation(true)->where(array('id' => $id))->save($data);
     if (false === $status) {
         $this->error = $this->contentModel->getError();
         $this->contentModel->tokenRecovery($data);
         return false;
     }
     //字段合并
     $this->contentModel->dataMerger($data);
     $oldata['inputtime'] = $data['inputtime'] = $inputtime;
     //调用 update
     if (false == require_cache(RUNTIME_PATH . 'content_update.class.php')) {
         D("Category")->category_cache();
         D("Content_cache")->model_content_cache();
         require RUNTIME_PATH . 'content_update.class.php';
     }
     $content_update = new content_update($this->modelid);
     $updateStatus = $content_update->update($oldata);
     if (false == $updateStatus) {
         $this->error = $content_update->getError();
         return false;
     }
     //更新附件状态,把相关附件和文章进行管理
     $attachment = service("Attachment");
     $attachment->api_update('', 'c-' . $data['catid'] . '-' . $id, 2);
     //更新到全站搜索
     if ($data['status'] == 99) {
         $this->search_api($id, $data, "updata");
     } else {
         $this->search_api($id, $data, "delete");
     }
     //标签
     tag("content_edit_end", $data);
     //生成相关
     $generatelish = 0;
     import('Html');
     $html = get_instance_of('Html');
     if (defined('IN_ADMIN') && IN_ADMIN) {
         //是否生成内容页
         if ($catidsetting['generatehtml']) {
             //生成静态
             if ($catidsetting['content_ishtml'] && $data['status'] == 99) {
                 $html->show($data, 0, 'edit');
             }
         }
         //如果是未审核,删除已经生成
         if ($catidsetting['content_ishtml'] && !$data['islink'] && $data['status'] == 1) {
             $this->deleteHtml($data['catid'], $id, $inputtime, $data['prefix'], $data);
         }
         //生成列表
         if ((int) $catidsetting['generatelish'] > 0) {
             $generatelish = (int) $catidsetting['generatelish'];
         }
     } else {
         //投稿内容页生成,直接审核通过的直接生成内容页
         if ($data['status'] == 99) {
             //生成静态
             if ($catidsetting['content_ishtml']) {
                 $html->show($data, 0, 'edit');
             }
         } else {
             if ($catidsetting['content_ishtml'] && !$data['islink']) {
                 $this->deleteHtml($data['catid'], $id, $inputtime, $data['prefix'], $data);
             }
         }
         //列表生成
         if ((int) $catidsetting['member_generatelish'] > 0) {
             $generatelish = (int) $catidsetting['member_generatelish'];
         }
     }
     //列表生成
     switch ($generatelish) {
         //生成当前栏目
         case 1:
             $html->create_relation_html($data['catid']);
             break;
             //生成首页
         //生成首页
         case 2:
             $html->index();
             break;
             //生成父栏目
         //生成父栏目
         case 3:
             if ($catidinfo['parentid']) {
                 $html->create_relation_html($catidinfo['parentid']);
             }
             break;
             //生成当前栏目与父栏目
         //生成当前栏目与父栏目
         case 4:
             $html->create_relation_html($data['catid']);
             if ($catidinfo['parentid']) {
                 $html->create_relation_html($catidinfo['parentid']);
             }
             break;
             //生成父栏目与首页
         //生成父栏目与首页
         case 5:
             if ($catidinfo['parentid']) {
                 $html->create_relation_html($catidinfo['parentid']);
             }
             $html->index();
             break;
             //生成当前栏目、父栏目与首页
         //生成当前栏目、父栏目与首页
         case 6:
             $html->create_relation_html($data['catid']);
             if ($catidinfo['parentid']) {
                 $html->create_relation_html($catidinfo['parentid']);
             }
             $html->index();
             break;
     }
     //生成上一篇下一篇
     $this->related_content($data['catid'], $id, "edit");
     return true;
 }
Example #7
0
 /**
  * 修改内容
  * 
  * @param $datas
  */
 public function edit_content($data, $id)
 {
     $model_tablename = $this->model_tablename;
     //前台权限判断
     if (!defined('IN_ADMIN')) {
         $_username = param::get_cookie('_username');
         $us = $this->get_one(array('id' => $id, 'username' => $_username));
         if (!$us) {
             return false;
         }
     }
     $this->search_db = pc_base::load_model('search_model');
     require_once CACHE_MODEL_PATH . 'content_input.class.php';
     require_once CACHE_MODEL_PATH . 'content_update.class.php';
     $content_input = new content_input($this->modelid);
     $inputinfo = $content_input->get($data);
     $systeminfo = $inputinfo['system'];
     $modelinfo = $inputinfo['model'];
     if ($data['inputtime'] && !is_numeric($data['inputtime'])) {
         $systeminfo['inputtime'] = strtotime($data['inputtime']);
     } elseif (!$data['inputtime']) {
         $systeminfo['inputtime'] = SYS_TIME;
     } else {
         $systeminfo['inputtime'] = $data['inputtime'];
     }
     if ($data['updatetime'] && !is_numeric($data['updatetime'])) {
         $systeminfo['updatetime'] = strtotime($data['updatetime']);
     } elseif (!$data['updatetime']) {
         $systeminfo['updatetime'] = SYS_TIME;
     } else {
         $systeminfo['updatetime'] = $data['updatetime'];
     }
     //自动提取摘要
     if (isset($_POST['add_introduce']) && $systeminfo['description'] == '' && isset($modelinfo['content'])) {
         $content = stripslashes($modelinfo['content']);
         $introcude_length = intval($_POST['introcude_length']);
         $systeminfo['description'] = str_cut(str_replace(array("\r\n", "\t", '[page]', '[/page]', '&ldquo;', '&rdquo;', '&nbsp;'), '', strip_tags($content)), $introcude_length);
         $inputinfo['system']['description'] = $systeminfo['description'] = addslashes($systeminfo['description']);
     }
     //自动提取缩略图
     if (isset($_POST['auto_thumb']) && $systeminfo['thumb'] == '' && isset($modelinfo['content'])) {
         $content = $content ? $content : stripslashes($modelinfo['content']);
         $auto_thumb_no = intval($_POST['auto_thumb_no']) - 1;
         if (preg_match_all("/(src)=([\"|']?)([^ \"'>]+\\.(gif|jpg|jpeg|bmp|png))\\2/i", $content, $matches)) {
             $systeminfo['thumb'] = $matches[3][$auto_thumb_no];
         }
     }
     if ($data['islink'] == 1) {
         $systeminfo['url'] = $_POST['linkurl'];
     } else {
         //更新URL地址
         $urls = $this->url->show($id, 0, $systeminfo['catid'], $systeminfo['inputtime'], $data['prefix'], $inputinfo, 'edit');
         $systeminfo['url'] = $urls[0];
     }
     //主表
     $this->table_name = $this->db_tablepre . $model_tablename;
     $this->update($systeminfo, array('id' => $id));
     //附属表
     $this->table_name = $this->table_name . '_data';
     $this->update($modelinfo, array('id' => $id));
     $this->search_api($id, $inputinfo);
     //调用 update
     $content_update = new content_update($this->modelid, $id);
     $content_update->update($data);
     //更新附件状态
     if (pc_base::load_config('system', 'attachment_stat')) {
         $this->attachment_db = pc_base::load_model('attachment_model');
         $this->attachment_db->api_update('', 'c-' . $systeminfo['catid'] . '-' . $id, 2);
     }
     //更新审核列表
     $this->content_check_db = pc_base::load_model('content_check_model');
     $check_data = array('catid' => $systeminfo['catid'], 'siteid' => $this->siteid, 'title' => $systeminfo['title'], 'status' => $systeminfo['status']);
     if (!isset($systeminfo['status'])) {
         unset($check_data['status']);
     }
     $this->content_check_db->update($check_data, array('checkid' => 'c-' . $id . '-' . $this->modelid));
     //生成静态
     $html = pc_base::load_app_class('html', 'content');
     if ($urls['content_ishtml']) {
         $html->show($urls[1], $urls['data']);
     }
     //在添加和修改内容处定义了 INDEX_HTML
     if (defined('INDEX_HTML')) {
         $html->index();
     }
     if (defined('RELATION_HTML')) {
         $html->create_relation_html($systeminfo['catid']);
     }
     return true;
 }
 public function edit_content()
 {
     $result = false;
     $modelid = $this->modelid;
     $contentid = intval($_POST['contentid']);
     $data = $_POST['info'];
     $data['relation'] = array2string($data['relation']);
     require FIELDS_PATH . 'content_input.class.php';
     $content_input = new \content_input($this->modelid);
     $inputinfo = $content_input->get($data);
     $systeminfo = $this->parse_field($inputinfo['system']);
     $systeminfo['siteid'] = get_siteid();
     if ($data['inputtime'] && !is_numeric($data['inputtime'])) {
         $systeminfo['inputtime'] = strtotime($data['inputtime']);
     } elseif (!$data['inputtime']) {
         $systeminfo['inputtime'] = time();
     } else {
         $systeminfo['inputtime'] = $data['inputtime'];
     }
     if ($data['islink'] == 1) {
         $systeminfo['url'] = $_POST['linkurl'];
         $systeminfo['url'] = str_replace(array('select ', ')', '\\', '#', "'"), ' ', $systeminfo['url']);
     } else {
         $siteinfo = get_site_info(get_siteid());
         $url = U(C("DEFAULT_GROUP") . '/Content/show@' . $siteinfo['url'], 'catid=' . $systeminfo['catid'] . '&id=' . $contentid);
         // $url = U('Content/show','catid='.$systeminfo['catid'].'&id='.$contentid);
         $systeminfo['url'] = $url;
     }
     // 开启事务
     $this->startTrans();
     if ($result = $this->where("id = %d", $contentid)->save($systeminfo) !== false) {
         // 附表
         $this->trueTableName = $this->trueTableName . "_data";
         $this->set_field();
         $content_data = $this->parse_field($inputinfo['model']);
         if ($this->where("id = %d", $contentid)->save($content_data) === false) {
             $this->rollback();
             return false;
         }
         // 发布到推荐位
         $position_model = D('PositionData');
         if ($position_model->where(array("id" => $contentid, "modelid" => $modelid))->delete() === false) {
             $this->rollback();
             return false;
         }
         if ($systeminfo['posids']) {
             foreach ($data['posids'] as $key => $posid) {
                 if ($posid > 0) {
                     $position_data[] = array('id' => $contentid, 'catid' => $systeminfo['catid'], 'posid' => $posid, 'modelid' => $modelid, 'module' => 'content', 'thumb' => $systeminfo['thumb'], 'siteid' => $systeminfo['siteid'], 'listorder' => $contentid, 'data' => var_export(array('title' => $systeminfo['title'], 'url' => $url, 'description' => $systeminfo['description'], 'inputtime' => $systeminfo['inputtime']), true));
                 }
             }
             if (!empty($position_data)) {
                 if (D("PositionData")->addAll($position_data) === false) {
                     $this->rollback();
                     return false;
                 }
             }
         }
         // END 发布到推荐位
         $this->commit();
     } else {
         $this->rollback();
     }
     return $result;
 }
Example #9
0
 public function editContent($post_id, $data)
 {
     $modelid = $this->modelid;
     if (isset($data['relation'])) {
         $data['relation'] = array2string($data['relation']);
     }
     require MODEL_PATH . 'content_input.class.php';
     $content_input = new \content_input($this->modelid);
     $inputinfo = $content_input->get($data);
     $inputinfo = $inputinfo['system'];
     $systeminfo = $this->parseField($inputinfo);
     $systeminfo['siteid'] = get_siteid();
     // 设置更新时间 统一到CommonModel中通过CallBack函数设置
     /*if(isset($content_input->fields['updatetime'])) {
           $setting = string2array($content_input->fields['updatetime']['setting']);
           if ($setting['fieldtype'] == "int") {
               $systeminfo['updatetime'] = time();
           } else {
               $systeminfo['updatetime'] = date($setting['format']);
           }
       }*/
     return $this->where("id = %d", $post_id)->save($systeminfo);
 }
Example #10
0
 /**
  * 修改内容
  * @param type $data
  * @return boolean
  */
 public function edit($data = '')
 {
     if (empty($data)) {
         if (!empty($this->data)) {
             $data = $this->data;
             // 重置数据
             $this->data = array();
         } else {
             $this->error = L('_DATA_TYPE_INVALID_');
             return false;
         }
     }
     $this->id = (int) $data['id'];
     $this->catid = (int) $data['catid'];
     $this->modelid = getCategory($this->catid, 'modelid');
     //取得表单令牌验证码
     $data[C("TOKEN_NAME")] = $_POST[C("TOKEN_NAME")];
     //标签
     tag('content_edit_begin', $data);
     //栏目数据
     $catidinfo = getCategory($this->catid);
     if (empty($catidinfo)) {
         $this->error = '获取不到栏目数据!';
         return false;
     }
     //setting配置
     $catidsetting = $catidinfo['setting'];
     //前台投稿状态判断
     if (!defined('IN_ADMIN') || defined('IN_ADMIN') && IN_ADMIN == false) {
         //前台投稿编辑是否需要审核
         if ($catidsetting['member_editcheck']) {
             $data['status'] = 1;
         }
     }
     $model = ContentModel::getInstance($this->modelid);
     //真实发布时间
     $data['inputtime'] = $inputtime = $model->where(array("id" => $this->id))->getField('inputtime');
     //更新时间处理
     if ($data['updatetime'] && !is_numeric($data['updatetime'])) {
         $data['updatetime'] = strtotime($data['updatetime']);
     } elseif (!$data['updatetime']) {
         $data['updatetime'] = time();
     }
     //自动提取摘要,如果有设置自动提取,且description为空,且有内容字段才执行
     $this->description($data);
     //转向地址
     if ($data['islink'] == 1) {
         $urls["url"] = $_POST['linkurl'];
     } else {
         //生成该篇地址
         $urls = $this->generateUrl($data);
     }
     $data['url'] = $urls["url"];
     $content_input = new \content_input($this->modelid);
     //保存一份旧数据
     $oldata = $data;
     $data = $content_input->get($data, 2);
     if ($data) {
         //数据验证
         $data = $model->relation(true)->create($data, 2);
         if (false == $data) {
             $this->error = $model->getError();
             $this->tokenRecovery($data);
             return false;
         }
     } else {
         $this->error = $content_input->getError();
         return false;
     }
     //自动提取缩略图,从content 中提取
     $this->getThumb($data);
     $oldata['thumb'] = $data['thumb'];
     //数据修改,这里使用关联操作
     $status = $model->relation(true)->where(array('id' => $this->id))->save($data);
     if (false === $status) {
         $this->error = $model->getError();
         $this->tokenRecovery($data);
         return false;
     }
     //字段合并
     $model->dataMerger($data);
     //调用回调更新
     $content_update = new \content_update($this->modelid);
     $content_update->update($oldata);
     //更新附件状态,把相关附件和文章进行管理
     $attachment = service('Attachment');
     $attachment->api_update('', 'c-' . $data['catid'] . '-' . $id, 2);
     //标签
     tag('content_edit_end', $data);
     //生成相关
     $generatelish = 0;
     if (defined('IN_ADMIN') && IN_ADMIN) {
         //是否生成内容页
         if ($catidsetting['generatehtml']) {
             //生成静态
             if ($catidsetting['content_ishtml'] && $data['status'] == 99) {
                 $this->Html->show($data);
             }
         }
         //如果是未审核,删除已经生成
         if ($catidsetting['content_ishtml'] && !$data['islink'] && $data['status'] != 99) {
             $this->data($data)->deleteHtml();
         }
         //生成列表
         if ((int) $catidsetting['generatelish'] > 0) {
             $generatelish = (int) $catidsetting['generatelish'];
         }
     } else {
         //投稿内容页生成,直接审核通过的直接生成内容页
         if ($data['status'] == 99) {
             //生成静态
             if ($catidsetting['content_ishtml']) {
                 $this->Html->show($data);
             }
         } else {
             if ($catidsetting['content_ishtml'] && !$data['islink']) {
                 $this->data($data)->deleteHtml();
             }
         }
         //列表生成
         if ((int) $catidsetting['member_generatelish'] > 0) {
             $generatelish = (int) $catidsetting['member_generatelish'];
         }
     }
     //列表生成
     switch ($generatelish) {
         //生成当前栏目
         case 1:
             $this->Html->category($data['catid']);
             break;
             //生成首页
         //生成首页
         case 2:
             $this->Html->index();
             break;
             //生成父栏目
         //生成父栏目
         case 3:
             if ($catidinfo['parentid']) {
                 $this->Html->category($catidinfo['parentid']);
             }
             break;
             //生成当前栏目与父栏目
         //生成当前栏目与父栏目
         case 4:
             $this->Html->category($data['catid']);
             if ($catidinfo['parentid']) {
                 $this->Html->category($catidinfo['parentid']);
             }
             break;
             //生成父栏目与首页
         //生成父栏目与首页
         case 5:
             if ($catidinfo['parentid']) {
                 $this->Html->category($catidinfo['parentid']);
             }
             $this->Html->index();
             break;
             //生成当前栏目、父栏目与首页
         //生成当前栏目、父栏目与首页
         case 6:
             $this->Html->category($data['catid']);
             $this->Html->createRelationHtml($data['catid']);
             $this->Html->index();
             break;
     }
     //生成上一篇下一篇
     $this->relatedContent($this->catid, $this->id, 'edit');
     return true;
 }
 /**
  * 修改会员 
  */
 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();
     }
 }
 /**
  * 会员注册 
  * @param type $username 用户名
  * @param type $password 密码
  * @param type $email 邮箱
  * @param type $_data post
  * @return int 大于 0:返回用户 ID,表示用户注册成功
  *                              -1:用户名不合法
  *                              -2:包含不允许注册的词语
  *                              -3:用户名已经存在
  *                              -4:Email 格式有误
  *                              -5:Email 不允许注册
  *                              -6:该 Email 已经被注册
  *                              -7模型ID为空
  *                              -8用户注册成功,但添加模型资料失败
  */
 protected function registeradd($username, $password, $email, $_data)
 {
     $Model_Member = F("Model_Member");
     //模型ID
     $modelid = $_data['modelid'];
     if (!$modelid || !$Model_Member[$modelid]) {
         return -7;
     }
     require_cache(RUNTIME_PATH . 'content_input.class.php');
     $content_input = new content_input($modelid, $this);
     $inputinfo = $content_input->get($_data['info']);
     //取得模型内容
     $modedata = $inputinfo['model'];
     if (!$modedata) {
         $modedata = array();
     }
     //新注册用户积分
     $_data['point'] = $this->Member_config['defualtpoint'] ? $this->Member_config['defualtpoint'] : 0;
     //新会员注册默认赠送资金
     $_data['amount'] = $this->Member_config['defualtamount'] ? $this->Member_config['defualtamount'] : 0;
     //计算用户组
     $_data['groupid'] = $_data['groupid'] ? $_data['groupid'] : D("Member")->get_usergroup_bypoint($_data['point']);
     $userid = service("Passport")->user_register($username, $password, $email, $_data);
     if ($userid > 0) {
         //添加到相应模型
         $Model_Member = F("Model_Member");
         $tablename = $Model_Member[$modelid]['tablename'];
         $modedata = array_merge($modedata, array("userid" => $userid));
         //补充相应模型资料
         $status = M(ucwords($tablename))->add($modedata);
         if ($status) {
             return $userid;
         } else {
             return -8;
         }
     } else {
         return $userid;
     }
 }
Example #13
0
 /**
  * 修改内容 
  * @param array $data 数据
  * @param type $id 信息ID
  * @return boolean 
  */
 public function edit($data, $id)
 {
     require_array(array(RUNTIME_PATH . 'content_input.class.php', RUNTIME_PATH . 'content_update.class.php'));
     $this->catid = (int) $data['catid'];
     $this->modelid = $this->categorys[$this->catid]['modelid'];
     //主表操作开始
     $this->table_name = ucwords($this->Model[$this->modelid]['tablename']);
     $this->fbtable_name = $this->table_name . "_data";
     $this->Content = new ContentModel($this->table_name);
     $content_input = new content_input($this->modelid, $this);
     $inputinfo = $content_input->get($data);
     if (is_bool($inputinfo) && $inputinfo == false) {
         //显示错误
         $this->error($content_input->getError());
         return false;
     }
     //主表字段内容
     $systeminfo = $inputinfo['system'];
     //副表字段内容
     $modelinfo = $inputinfo['model'];
     //栏目数据
     $catidinfo = $this->categorys[$systeminfo['catid']];
     //setting配置
     $catidsetting = unserialize($catidinfo['setting']);
     //前台投稿状态判断
     if (defined('IN_ADMIN') && IN_ADMIN == false) {
         //前台投稿编辑是否需要审核
         if ($catidsetting['member_editcheck']) {
             $systeminfo['status'] = 1;
         }
     }
     //取得inputtime的真实发布时间
     //inputtime为真实发表时间,不允许修改
     $data['inputtime'] = $systeminfo['inputtime'] = $inputtime = $this->Content->where(array("id" => $id))->getField("inputtime");
     //更新时间处理
     if ($data['updatetime'] && !is_numeric($data['updatetime'])) {
         $systeminfo['updatetime'] = strtotime($data['updatetime']);
     } elseif (!$data['updatetime']) {
         $systeminfo['updatetime'] = time();
     } else {
         $systeminfo['updatetime'] = $data['updatetime'];
     }
     //自动提取摘要,如果有设置自动提取,且description为空,且有内容字段才执行
     if (isset($_POST['add_introduce']) && $systeminfo['description'] == '' && isset($modelinfo['content'])) {
         $content = stripslashes($modelinfo['content']);
         $introcude_length = intval($_POST['introcude_length']);
         $systeminfo['description'] = str_cut(str_replace(array("\r\n", "\t", '[page]', '[/page]', '&ldquo;', '&rdquo;', '&nbsp;'), '', strip_tags($content)), $introcude_length);
         $inputinfo['system']['description'] = $systeminfo['description'] = Input::getVar($systeminfo['description']);
     }
     //自动提取缩略图,从content 中提取
     if (isset($_POST['auto_thumb']) && $systeminfo['thumb'] == '' && isset($modelinfo['content'])) {
         $content = $content ? $content : stripslashes($modelinfo['content']);
         $auto_thumb_no = intval($_POST['auto_thumb_no']) - 1;
         if (preg_match_all("/(src)=([\"|']?)([^ \"'>]+\\.(gif|jpg|jpeg|bmp|png))\\2/i", $content, $matches)) {
             $systeminfo['thumb'] = $matches[3][$auto_thumb_no];
         }
     }
     //转向地址
     if ($data['islink'] == 1) {
         $systeminfo['url'] = $_POST['linkurl'];
     } else {
         //生成该篇地址
         $urls = $this->url->show($id, 0, $systeminfo['catid'], $inputtime, $data['prefix'], $inputinfo, 'edit');
         $systeminfo['url'] = $urls[0];
     }
     //使用TP的自动验证,所以要把令牌合并
     $systeminfo = array_merge($systeminfo, array(C("TOKEN_NAME") => $_POST[C("TOKEN_NAME")]));
     $status = $this->Content->create($systeminfo);
     if (!$status) {
         $this->error($this->Content->getError());
     }
     //把副表的数据合并,按关联模型的需求合并
     $status['id'] = $id;
     $fdata = array($this->fbtable_name => $modelinfo);
     $status = array_merge($status, $fdata);
     //删除真实时间的信息,避免被更新
     unset($status['inputtime']);
     //数据修改,这里使用关联操作
     $this->Content->relation(true)->where(array('id' => $id))->save($status);
     //调用 update
     $content_update = new content_update($this->modelid, $id, $this);
     $data['url'] = $systeminfo['url'];
     $content_update->update($data);
     //更新附件状态,把相关附件和文章进行管理
     $this->attachment_db = service("Attachment");
     $this->attachment_db->api_update('', 'c-' . $systeminfo['catid'] . '-' . $id, 2);
     //更新到全站搜索
     if ($systeminfo['status'] == 99) {
         $this->search_api($id, $inputinfo, "updata");
     } else {
         $this->search_api($id, $inputinfo, "delete");
     }
     //生成相关
     $generatelish = 0;
     import('Html');
     $html = new Html();
     if (defined('IN_ADMIN') && IN_ADMIN) {
         //是否生成内容页
         if ($catidsetting['generatehtml']) {
             //生成静态
             if ($urls['content_ishtml'] && $status['status'] == 99) {
                 $html->show($urls[1], $urls['data']);
             }
         }
         //如果是未审核,删除已经生成
         if ($urls['content_ishtml'] && !$data['islink'] && $status['status'] == 1) {
             $this->deleteHtml($data['catid'], $id, $systeminfo['inputtime'], $systeminfo['prefix']);
         }
         //生成列表
         if ((int) $catidsetting['generatelish'] > 0) {
             $generatelish = (int) $catidsetting['generatelish'];
         }
     } else {
         //投稿内容页生成,直接审核通过的直接生成内容页
         if ($status['status'] == 99) {
             //生成静态
             if ($urls['content_ishtml']) {
                 $html->show($urls[1], $urls['data']);
             }
         } else {
             if ($urls['content_ishtml'] && !$data['islink']) {
                 $this->deleteHtml($data['catid'], $id, $systeminfo['inputtime'], $systeminfo['prefix']);
             }
         }
         //列表生成
         if ((int) $catidsetting['member_generatelish'] > 0) {
             $generatelish = (int) $catidsetting['member_generatelish'];
         }
     }
     //列表生成
     switch ($generatelish) {
         //生成当前栏目
         case 1:
             $html->create_relation_html($status['catid']);
             break;
             //生成首页
         //生成首页
         case 2:
             $html->index();
             break;
             //生成父栏目
         //生成父栏目
         case 3:
             if ($catidinfo['parentid']) {
                 $html->create_relation_html($catidinfo['parentid']);
             }
             break;
             //生成当前栏目与父栏目
         //生成当前栏目与父栏目
         case 4:
             $html->create_relation_html($status['catid']);
             if ($catidinfo['parentid']) {
                 $html->create_relation_html($catidinfo['parentid']);
             }
             break;
             //生成父栏目与首页
         //生成父栏目与首页
         case 5:
             if ($catidinfo['parentid']) {
                 $html->create_relation_html($catidinfo['parentid']);
             }
             $html->index();
             break;
             //生成当前栏目、父栏目与首页
         //生成当前栏目、父栏目与首页
         case 6:
             $html->create_relation_html($status['catid']);
             if ($catidinfo['parentid']) {
                 $html->create_relation_html($catidinfo['parentid']);
             }
             $html->index();
             break;
     }
     //生成上一篇下一篇
     $this->related_content($status['catid'], $id, "edit");
     return true;
 }