Пример #1
0
 /**
  * 删除回复
  */
 public static final function remove()
 {
     $online = front::online();
     //if(!parent::init('in_manager') || $online->grade!=1) die('Permission Denied!');
     // 获取数据
     $doc_remark = new self();
     $doc_remark->doc_remark_id = isset($_GET['doc_remark_id']) ? $_GET['doc_remark_id'] : null;
     if (!is_numeric($doc_remark->doc_remark_id) || !$doc_remark->select()) {
         $error = '该回复不存在';
         return;
     }
     // 删除数据
     $doc_remark->delete();
     header('Location: ?' . $_GET['query']);
 }
Пример #2
0
 /**
  * 修改账本
  */
 public static final function modify()
 {
     $item_types = book_item::get_items();
     $ccys = book::get_ccy();
     $error = array();
     // 获取数据
     $book = new self();
     $book->book_id = isset($_GET['book_id']) ? $_GET['book_id'] : null;
     if (!is_numeric($book->book_id) || !$book->select()) {
         $error = '该日志不存在';
         front::view2('error.tpl', compact('error'));
         return;
     }
     $post = get_object_vars($book);
     $online = front::online();
     $book_items = self::selects('book_item_id,item,info', '#@__book_item', array('user_id' => $online->user_id), array('ORDER BY book_item_id ASC'), array('book_item_id', 'assoc' => null));
     $opposites = self::selects('opposite', null, array('user_id' => $online->user_id), array('GROUP BY opposite'), array(null, 'column|table=book' => 'opposite'));
     $item_txts = self::selects('item_txt', null, array('user_id' => $online->user_id), array(' GROUP BY item_txt'), array(NULL, 'column|table=book' => 'item_txt'));
     if (!$item_txts) {
         $item_txts = array();
     }
     // 表单处理
     while (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST') {
         // 数据消毒
         $time = time();
         $post = array('item' => isset($_POST['item']) ? $_POST['item'] : '', 'item_txt' => isset($_POST['item_txt']) ? $_POST['item_txt'] : '', 'remark' => isset($_POST['remark']) ? $_POST['remark'] : '', 'opposite' => isset($_POST['opposite']) ? $_POST['opposite'] : '', 'book_item_id' => isset($_POST['book_item_id']) ? $_POST['book_item_id'] : '', 'ccy' => isset($_POST['ccy']) ? $_POST['ccy'] : '', 'net' => isset($_POST['net']) ? $_POST['net'] : '0', 'otype' => isset($_POST['otype']) ? $_POST['otype'] : '', 'amount' => isset($_POST['amount']) ? $_POST['amount'] : '', 'user_id' => $online->user_id, 'create_date' => isset($_POST['create_date']) ? $_POST['create_date'] : '', 'create_time' => isset($_POST['create_time']) ? $_POST['create_time'] : '', 'update_date' => date('Y-m-d', $time), 'update_time' => date('H:i:s', $time));
         if (get_magic_quotes_gpc()) {
             $post = array_map('stripslashes', $post);
         }
         if (!empty($_POST['item_txt2'])) {
             $post['item_txt'] = $_POST['item_txt2'];
         }
         if (!empty($_POST['opposite2'])) {
             $post['opposite'] = $_POST['opposite2'];
         }
         if ($post['book_item_id']) {
             $post['item'] = $book_items[$post['book_item_id']]['item'];
         }
         // 数据验证
         if (empty($post['item'])) {
             $post['item'] = substr($post['item'], 0, 15);
         }
         if ($post['otype'] == 'IN') {
             $post['amount'] = abs($post['amount']);
         } else {
             $post['amount'] = -abs($post['amount']);
         }
         $reg = "/(\\d{4})-(\\d{1,2})-(\\d{1,2})/";
         if (!empty($post['create_date'])) {
             preg_match($reg, $post['create_date'], $arr);
             //checkdate ( int $month , int $day , int $year )
             if (!$arr || !checkdate($arr[2], $arr[3], $arr[1])) {
                 $error['create_date'] = '日期格式不正确';
             }
         } else {
             $error['create_date'] = '请输入日期';
         }
         if (!empty($error)) {
             break;
         }
         $book->struct($post);
         $book->update();
         $online = front::online();
         self::update_statement_net($online->user_id, 0, $post['ccy']);
         header('Location: ?' . $_GET['query']);
         return;
     }
     // 页面显示
     foreach (array('item', 'item_txt', 'typeid', 'remark', 'ccy', 'net', 'otype', 'amount', 'create_date', 'create_time') as $value) {
         $post[$value] = htmlspecialchars($post[$value]);
     }
     front::view2(__CLASS__ . '.' . 'form.tpl', compact('post', 'error', 'item_txts', 'otype', 'item_types', 'book_items', 'opposites', 'ccys'));
 }
Пример #3
0
 /**
 * 取分类数据
 */
 function get_channel()
 {
     $online = front::online();
     $class_arr = array();
     $channels = self::selects('channel_id,name,parent_id,sort,path,component', null, array('user_id' => $online->user_id), array('ORDER BY sort ASC,channel_id DESC'), array('channel_id', 'assoc|table=channel' => null));
     return $channels;
 }
Пример #4
0
 /**
  * 群删用户
  */
 public static final function group_remove()
 {
     if (!self::user_level(2, __CLASS__, __FUNCTION__)) {
         return;
     }
     $online = front::online();
     // 获取数据
     if (!isset($_POST['user_id']) || !is_array($_POST['user_id'])) {
         $error = '该用户不存在';
         front::view2('common/error.tpl', compact('error'));
         return;
     }
     // 删除数据
     self::deletes(null, null, array('user_id' => $_POST['user_id'], 'user_id!=?' => $online->user_id), null, __CLASS__);
     header('Location: ?' . $_GET['query']);
 }
Пример #5
0
 /**
  * 添加日志
  */
 public static final function append()
 {
     $error = array();
     $online = front::online();
     $time = time();
     // 数据消毒
     $post = array('diary_date' => isset($_POST['diary_date']) ? $_POST['diary_date'] : '', 'title' => isset($_POST['title']) ? $_POST['title'] : '', 'mood' => isset($_POST['mood']) ? $_POST['mood'] : '', 'weather' => isset($_POST['weather']) ? $_POST['weather'] : '', 'content' => isset($_POST['content']) ? $_POST['content'] : '', 'user_id' => $online->user_id, 'create_date' => date('Y-m-d', $time), 'create_time' => date('H:i:s', $time), 'update_date' => date('Y-m-d', $time), 'update_time' => date('H:i:s', $time));
     if (get_magic_quotes_gpc()) {
         $post = array_map('stripslashes', $post);
     }
     // 表单处理
     while (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST') {
         // 数据验证
         if (empty($post['diary_date'])) {
             //title=content
             $post['diary_date'] = date('Y-m-d');
         }
         if (empty($post['title'])) {
             //title=content
             $post['title'] = substr(strip_tags($post['content']), 0, 15);
         } else {
             $post['title'] = strip_tags($post['title']);
         }
         if (empty($post['title'])) {
             $error['title'] = '标题不能为空';
         }
         if (!empty($error)) {
             break;
         }
         // 数据入库
         $diary = new self();
         $diary->diary_id = null;
         $diary->struct($post);
         $diary->insert();
         header('Location: ?go=diary&do=browse');
         return;
     }
     // 页面显示
     foreach (array('title', 'url', 'typeid', 'content') as $value) {
         $post[$value] = htmlspecialchars($post[$value]);
     }
     front::view2(__CLASS__ . '.' . 'form.tpl', compact('post', 'error'));
 }
Пример #6
0
 /**
  * 添加网址
  */
 public static final function append()
 {
     $error = array();
     $online = front::online();
     $time = time();
     // 数据消毒
     $post = array('title' => isset($_POST['title']) ? $_POST['title'] : '', 'url' => isset($_POST['url']) ? $_POST['url'] : '', 'typeid' => isset($_POST['typeid']) ? $_POST['typeid'] : '', 'content' => isset($_POST['content']) ? $_POST['content'] : '', 'user_id' => $online->user_id, 'create_date' => date('Y-m-d', $time), 'create_time' => date('H:i:s', $time), 'update_date' => date('Y-m-d', $time), 'update_time' => date('H:i:s', $time));
     if (get_magic_quotes_gpc()) {
         $post = array_map('stripslashes', $post);
     }
     // 表单处理
     while (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST') {
         // 数据验证
         $length = (strlen($post['title']) + mb_strlen($post['title'], 'UTF-8')) / 2;
         if ($length < 3 || $length > 200) {
             $error['title'] = '网站名至少3个字符,最多200个字符';
         } else {
             $count = self::selects('COUNT(*)', null, array('title' => $post['title']), null, array('column|table=site' => 'COUNT(*)'));
             if ($count > 0) {
                 $error['title'] = '网站名重复,请检查是否重复记录';
             }
         }
         $count = self::selects('COUNT(*)', null, array('url' => $post['url']), null, array('column|table=site' => 'COUNT(*)'));
         if ($count > 0) {
             $error['url'] = 'URL重复,请检查是否重复记录';
         }
         if ($post['typeid'] === 0) {
             $error['typeid'] = '请选择分类';
         }
         //$length = (strlen ($post ['content']) + mb_strlen ($post ['content'], 'UTF-8')) /2;
         //if ($length > 100) {
         //	$error ['content'] = '备注最多只能填写100个字符';
         //}
         if (!empty($error)) {
             break;
         }
         // 数据入库
         $site = new self();
         $site->site_id = null;
         $site->struct($post);
         $site->insert();
         header('Location: ?go=site&do=browse');
         return;
     }
     // 页面显示
     foreach (array('title', 'url', 'typeid', 'content') as $value) {
         $post[$value] = htmlspecialchars($post[$value]);
     }
     front::view2(__CLASS__ . '.' . 'form.tpl', compact('post', 'error'));
 }
Пример #7
0
 /**
  * 添加关系
  */
 public static final function append()
 {
     $error = array();
     $online = front::online();
     $get = array('s_type' => isset($_GET['s_type']) ? $_GET['s_type'] : '', 't_type' => isset($_GET['t_type']) ? $_GET['t_type'] : '', 's_id' => isset($_GET['s_id']) ? (int) $_GET['s_id'] : '0', 't_id' => isset($_GET['t_id']) ? (int) $_GET['t_id'] : '0');
     $s_list = null;
     if ($get['s_type'] == 'channel') {
         $s_list = channel::get_channel_select(0, 0, $get['s_id'], null, null);
     } elseif ($get['s_type'] == 'address') {
         $s_lists = address::selects('address_id as id,name', null, array('user_id' => $online->user_id), array('ORDER BY address_id DESC'), array('id', 'column|table=address' => 'name'));
         if ($s_lists) {
             $s_list = make_option($s_lists, $get['s_id']);
         }
     } elseif ($get['s_type'] == 'book') {
         $s_lists = book::selects('book_id as id,concat_ws(\',\',create_date,item_txt,remark,ccy,amount,otype) as name', null, array('user_id' => $online->user_id), array('ORDER BY create_date DESC,book_id DESC'), array('id', 'column|table=book' => 'name'));
         if ($s_lists) {
             $s_list = make_option($s_lists, $get['s_id']);
         }
     } elseif ($get['s_type'] == 'diary') {
         $s_lists = diary::selects('diary_id as id,title as name', null, array('user_id' => $online->user_id), array('ORDER BY diary_id DESC'), array('id', 'column|table=diary' => 'name'));
         if ($s_lists) {
             $s_list = make_option($s_lists, $get['s_id']);
         }
     } elseif ($get['s_type'] == 'doc') {
         $s_lists = doc::selects('doc_id as id,title as name', null, array('user_id' => $online->user_id), array('ORDER BY doc_id DESC'), array('id', 'column|table=doc' => 'name'));
         if ($s_lists) {
             $s_list = make_option($s_lists, $get['s_id']);
         }
     } elseif ($get['s_type'] == 'site') {
         $s_lists = site::selects('site_id as id,title as name', null, array('user_id' => $online->user_id), array('ORDER BY site_id DESC'), array('id', 'column|table=site' => 'name'));
         if ($s_lists) {
             $s_list = make_option($s_lists, $get['s_id']);
         }
     } elseif ($get['s_type'] == 'user') {
         $s_lists = user::selects('user_id as id,username as name', null, array('user_id' => $online->user_id), array('ORDER BY user_id DESC'), array('id', 'column|table=user' => 'name'));
         if ($s_lists) {
             $s_list = make_option($s_lists, $get['s_id']);
         }
     } else {
     }
     $t_list = null;
     if ($get['t_type'] == 'channel') {
         $t_list = channel::get_channel_select(0, 0, $get['t_id'], null, null);
     } elseif ($get['t_type'] == 'address') {
         $t_lists = address::selects('address_id as id,name', null, array('user_id' => $online->user_id), array('ORDER BY address_id DESC'), array('id', 'column|table=address' => 'name'));
         if ($t_lists) {
             $t_list = make_option($t_lists, $get['t_id']);
         }
     } elseif ($get['t_type'] == 'book') {
         $t_lists = book::selects('book_id as id,concat_ws(\',\',create_date,item_txt,remark,ccy,amount,otype) as name', null, array('user_id' => $online->user_id), array('ORDER BY create_date DESC,book_id DESC'), array('id', 'column|table=book' => 'name'));
         if ($t_lists) {
             $t_list = make_option($t_lists, $get['t_id']);
         }
     } elseif ($get['t_type'] == 'diary') {
         $t_lists = diary::selects('diary_id as id,title as name', null, array('user_id' => $online->user_id), array('ORDER BY diary_id DESC'), array('id', 'column|table=diary' => 'name'));
         if ($t_lists) {
             $t_list = make_option($t_lists, $get['t_id']);
         }
     } elseif ($get['t_type'] == 'doc') {
         $t_lists = doc::selects('doc_id as id,title as name', null, array('user_id' => $online->user_id), array('ORDER BY doc_id DESC'), array('id', 'column|table=doc' => 'name'));
         if ($t_lists) {
             $t_list = make_option($t_lists, $get['t_id']);
         }
     } elseif ($get['t_type'] == 'site') {
         $t_lists = site::selects('site_id as id,title as name', null, array('user_id' => $online->user_id), array('ORDER BY site_id DESC'), array('id', 'column|table=site' => 'name'));
         if ($t_lists) {
             $t_list = make_option($t_lists, $get['t_id']);
         }
     } elseif ($get['t_type'] == 'user') {
         $t_lists = user::selects('user_id as id,username as name', null, array('user_id' => $online->user_id), array('ORDER BY user_id DESC'), array('id', 'column|table=user' => 'name'));
         if ($t_lists) {
             $t_list = make_option($t_lists, $get['t_id']);
         }
     } else {
     }
     // 表单处理
     while (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST') {
         // 数据消毒
         $post = array('s_type' => isset($_POST['s_type']) ? $_POST['s_type'] : '', 't_type' => isset($_POST['t_type']) ? $_POST['t_type'] : '', 's_id' => isset($_POST['s_id']) ? (int) $_POST['s_id'] : '0', 't_id' => isset($_POST['t_id']) ? (int) $_POST['t_id'] : '0', 'user_id' => $online->user_id);
         if (!$post['s_type']) {
             $error['s_type'] = '请选择源类型';
         }
         if (!$post['t_type']) {
             $error['t_type'] = '请选择目标类型';
         }
         if (!$post['s_id']) {
             $error['s_id'] = '请选择源内容';
         }
         if (!$post['t_id']) {
             $error['t_id'] = '请选目标内容';
         }
         if (!$error['t_id']) {
             if ($post['s_type'] == $post['t_type'] && $post['s_id'] == $post['t_id']) {
                 $error['t_id'] = '不能和自己关联';
             }
         }
         if (!$error['t_id']) {
             $related_id = self::selects('related_id', null, array('user_id' => $online->user_id, 's_id' => $post['s_id'], 's_type' => $post['s_type'], 't_id' => $post['t_id'], 't_type' => $post['t_type']), null, array('column' => 'related_id'));
             if (!$related_id) {
                 $related_id = self::selects('related_id', null, array('user_id' => $online->user_id, 's_id' => $post['t_id'], 's_type' => $post['t_type'], 't_id' => $post['s_id'], 't_type' => $post['s_type']), null, array('column' => 'related_id'));
             }
             if ($related_id) {
                 $error['t_id'] = '目标内容已经关联,请重新选择';
             }
         }
         if (!empty($error)) {
             break;
         }
         // 数据入库
         $related = new self();
         $related->related_id = null;
         $related->struct($post);
         $related->insert();
         $error = '添加成功';
         front::view2('error.tpl', compact('error'));
         return;
     }
     $types = array('address' => '地址', 'book' => '账本', 'channel' => '分类', 'diary' => '日志', 'doc' => '文章', 'site' => '网址', 'user' => '用户');
     front::view2(__CLASS__ . '.' . 'form.tpl', compact('post', 'get', 'error', 'types', 's_list', 't_list'));
 }
Пример #8
0
 /**
  * 修改账本
  */
 public static final function modify()
 {
     $item_types = self::get_items();
     $error = array();
     // 获取数据
     $book = new self();
     $book->book_item_id = isset($_GET['book_item_id']) ? $_GET['book_item_id'] : null;
     if (!is_numeric($book->book_item_id) || !$book->select()) {
         $error = '该信息不存在';
         front::view2('error.tpl', compact('error'));
         return;
     }
     $post = get_object_vars($book);
     $online = front::online();
     // 表单处理
     while (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST') {
         // 数据消毒
         $time = time();
         $post = array('item' => isset($_POST['item']) ? $_POST['item'] : '', 'info' => isset($_POST['info']) ? $_POST['info'] : '', 'user_id' => $online->user_id);
         if (get_magic_quotes_gpc()) {
             $post = array_map('stripslashes', $post);
         }
         // 数据验证
         if (empty($post['info'])) {
             $post['info'] = substr($post['info'], 0, 255);
         }
         if (!empty($error)) {
             break;
         }
         $book->struct($post);
         $book->update();
         $online = front::online();
         header('Location: ?' . $_GET['query']);
         return;
     }
     // 页面显示
     foreach (array('info') as $value) {
         $post[$value] = htmlspecialchars($post[$value]);
     }
     front::view2(__CLASS__ . '.' . 'form.tpl', compact('post', 'error', 'item_types'));
 }
Пример #9
0
 /**
  * 修改文章
  */
 public static final function modify()
 {
     $online = front::online();
     $error = array();
     $quick = isset($_GET['quick']) ? $_GET['quick'] : null;
     //快速编辑【仅保存content】
     // 获取数据
     $doc = new self();
     $doc->doc_id = isset($_GET['doc_id']) ? $_GET['doc_id'] : null;
     if (!is_numeric($doc->doc_id) || !$doc->select()) {
         $error = '该文章不存在';
         front::view2('error.tpl', compact('error'));
         return;
     }
     if ($doc->user_id != $online->user_id) {
         $error = '该文章你没有权限查看';
         front::view2('error.tpl', compact('error'));
         return;
     }
     $post = get_object_vars($doc);
     // 表单处理
     while (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST') {
         // 数据消毒
         $time = time();
         $post = array('title' => isset($_POST['title']) ? $_POST['title'] : '', 'copyfrom' => isset($_POST['copyfrom']) ? $_POST['copyfrom'] : '', 'typeid' => isset($_POST['typeid']) ? $_POST['typeid'] : '', 'keyword' => isset($_POST['keyword']) ? $_POST['keyword'] : '', 'keyword_auto' => isset($_POST['keyword_auto']) ? $_POST['keyword_auto'] : '', 'content' => isset($_POST['content']) ? $_POST['content'] : '', 'update_date' => date('Y-m-d', $time), 'update_time' => date('H:i:s', $time));
         if (get_magic_quotes_gpc()) {
             $post = array_map('stripslashes', $post);
         }
         // 数据验证
         if (!$quick) {
             $length = (strlen($post['title']) + mb_strlen($post['title'], 'UTF-8')) / 2;
             if ($length < 3 || $length > 200) {
                 $error['title'] = '文章名至少3个字符,最多200个字符';
             }
             if ($post['typeid'] === 0) {
                 $error['typeid'] = '请选择文章分类';
             }
             if ($post['keyword_auto'] == 1) {
                 $post['keyword'] = self::get_keywords(strip_tags($post['title'] . $post['content']));
             }
             unset($post['keyword_auto']);
         } else {
             unset($post['title']);
             unset($post['copyfrom']);
             unset($post['typeid']);
             unset($post['keyword']);
             unset($post['keyword_auto']);
         }
         if (!empty($error)) {
             break;
         }
         //pecho($post);
         // 数据入库
         $doc->struct($post);
         $doc->update();
         header('Location: ?' . $_GET['query']);
         //header ('Location: ?go=doc&do=modify&doc_id='.$doc->doc_id);
         return;
     }
     // 页面显示s
     foreach (array('title', 'mobile', 'email', 'url', 'content') as $value) {
         $post[$value] = htmlspecialchars($post[$value]);
     }
     $meta_title = $doc->title;
     $query = $_SERVER['QUERY_STRING'];
     front::view2(__CLASS__ . '.' . 'form.tpl', compact('post', 'error', 'query', 'meta_title'));
 }