/** * 发布文章功能 */ public function dopublish() { if (!$this->is_login()) { redirect('index.php/signin'); return; } $title = trim($this->input->post_get('title', TRUE)); $content = trim($this->input->post_get('content')); $filtered_content = xss_filter($content); $category_id = trim($this->input->post_get('category_id', TRUE)); $images = trim($this->input->post_get('images', TRUE)); $imageArray = array(); $image = NULL; if ($images) { $imageArray = explode('|', $images); if ($imageArray && count($imageArray)) { $image = $imageArray[0]; } } if (!$title) { $this->json_result(400, '请输入标题', NULL); return; } if (mb_strlen($title) > 50) { $this->json_result(400, '标题过长,请保持在50字以内', NULL); return; } if (!$category_id) { $this->json_result(400, '请选择分类', NULL); return; } if (!preg_match('/\\d+/', $category_id)) { $this->json_result(400, '分类不正确', NULL); return; } if (!$content) { $this->json_result(400, '内容不能为空', NULL); return; } $link = generate_link(); $article = array('link' => $link, 'title' => $title, 'original_content' => $content, 'content' => $filtered_content, 'image' => $image, 'category_id' => $category_id, 'user_id' => $this->user_id, 'create_at' => date_now(), 'update_at' => NULL, 'deleted' => FALSE, 'page_view' => 0, 'user_view' => 0, 'audit' => $this->role_id == 1, 'audit_by' => $this->role_id == 1 ? $this->user_id : NULL, 'audit_at' => date_now()); $publish_result = $this->model->publish($article); if ($publish_result) { $id = $this->model->get_article_id_by_link($link); if ($id) { foreach ($imageArray as $image) { $this->model->update_image_article_id($image, $id); } } $this->json_result(200, '发布成功', TRUE); } else { $this->json_result(200, '发布失败', FALSE); } }
function edit_eventdata(&$data) { global $xoopsModuleConfig, $xoopsUser; $myts =& MyTextSanitizer::getInstance(); $str = $pat = array(); $pat[] = '{X_DATE}'; $str[] = $data['ldate'] = empty($data['exdate']) ? $data['edate'] : $data['exdate']; if (isset($data['closetime'])) { $data['closedate'] = $data['ldate'] - $data['closetime']; $data['dispclose'] = eventdate($data['closedate'], _MD_TIME_FMT); } $data['date'] = eventdate($data['ldate']); $pat[] = '{X_TIME}'; $str[] = $data['time'] = eventdate($data['ldate'], _MD_STIME_FMT); $post = isset($data['cdate']) ? $data['cdate'] : time(); $data['postdate'] = formatTimestamp($post, _MD_POSTED_FMT); $data['uname'] = isset($data['uid']) ? XoopsUser::getUnameFromId($data['uid']) : $xoopsUser->getVar('uname'); $data['hits'] = sprintf(_MD_REFER, $data['counter']); $br = 0; $html = 1; switch ($data['style']) { case 2: $html = 0; case 1: $br = 1; } $data['disp_summary'] = empty($data['summary']) ? '' : str_replace($pat, $str, xss_filter($myts->displayTarea($data['summary'], $html, 0, 1, 1, $br))); $data['disp_body'] = empty($data['body']) ? '' : str_replace($pat, $str, xss_filter($myts->displayTarea($data['body'], $html, 0, 1, 1, $br))); $data['title'] = $myts->htmlSpecialChars($data['title']); // fill of seat if (!empty($data['persons'])) { $data['reserv_num'] = sprintf(_MD_RESERV_NUM, $data['persons']); $data['reserv_reg'] = sprintf(_MD_RESERV_REG, $data['reserved']); $marker = preg_split('/,|[\\r\\n]+/', $xoopsModuleConfig['maker_set']); $fill = $data['fill'] = intval($data['reserved'] / $data['persons'] * 100); if ($data['closedate'] < time()) { $fill = -1; } while (list($k, $v) = array_splice($marker, 0, 2)) { if ($fill < $k) { $data['fill_mark'] = $v; break; } } } $catlist = get_eguide_category(); if (isset($data['topicid'])) { $cid = $data['topicid']; if (isset($catlist[$cid])) { $data['catid'] = $cid; $data['catname'] = $catlist[$cid]['name']; $data['catimg'] = $catlist[$cid]['image']; $data['catgory'] = $catlist[$cid]; } } return $data; }
function safe($s) { return sql_filter(xss_filter($s)); }