/** *排序 */ public function drag_order() { if (!$this->input['video_id']) { $this->errorOutput(NOID); } $table_name = 'tuji'; $order_name = urldecode($this->input['order_name']); $ids = explode(',', urldecode($this->input['video_id'])); $order_ids = explode(',', urldecode($this->input['order_id'])); foreach ($ids as $k => $v) { $sql = "UPDATE " . DB_PREFIX . $table_name . " SET " . $order_name . " = '" . $order_ids[$k] . "' WHERE id = '" . $v . "'"; $this->db->query($sql); } $ids = implode(',', $ids); $sql = "SELECT * FROM " . DB_PREFIX . $table_name . " WHERE id IN(" . $ids . ")"; $ret = $this->db->query($sql); while ($row = $this->db->fetch_array($ret)) { if (!empty($row['column_id']) && !empty($row['expand_id'])) { publish_insert_query($row, 'update'); } } $ids = explode(',', $ids); $this->addItem($ids); $this->output(); }
function batch_review_publish() { $sql = "SELECT * FROM " . DB_PREFIX . "vodinfo WHERE status = 2 AND column_id !='' AND column_id != 'a:0:{}' AND expand_id = 0 AND create_time > 1364439200"; $q = $this->db->query($sql); while ($row = $this->db->fetch_array($q)) { publish_insert_query($row, 'insert'); } exit('成功'); }
function batch_review_publish() { $sql = "SELECT * FROM " . DB_PREFIX . "article WHERE state = 1 AND column_id !='' AND column_id != 'a:0:{}' AND expand_id = 0"; $q = $this->db->query($sql); while ($row = $this->db->fetch_array($q)) { publish_insert_query($row, 'delete'); echo '正在重新发布' . $row['id'] . '-----' . $row['title'] . str_repeat(' ', 4096) . "<br/>"; publish_insert_query($row, 'insert'); echo $row['id'] . '-----' . $row['title'] . '已放入发布队列' . str_repeat(' ', 4096) . "<br/>"; ob_flush(); } exit('成功'); }
public function show() { //查询有没有过期的电视剧 $sql = "SELECT * FROM " . DB_PREFIX . "tv_play WHERE copyright_limit < " . TIMENOW . " AND copyright_limit != 0 "; $q = $this->db->query($sql); $tv_play = array(); while ($r = $this->db->fetch_array($q)) { $tv_play[] = $r; } if ($tv_play) { foreach ($tv_play as $k => $v) { if ($v['column_id'] && $v['status'] == 2) { $sql = "SELECT * FROM " . DB_PREFIX . "tv_episode WHERE tv_play_id = '" . $v['id'] . "' "; $q = $this->db->query($sql); $video_ids = array(); $ep = array(); while ($r = $this->db->fetch_array($q)) { $video_ids[] = $r['video_id']; $ep[] = $r; } if ($video_ids) { $column_id_arr = array_keys(unserialize($v['column_id'])); $this->livmedia->insertQueueToLivmedia(implode(',', $video_ids), 'delete', implode(',', $column_id_arr)); //清空剧集里面的url $sql = "UPDATE " . DB_PREFIX . "tv_episode SET url = '' WHERE tv_play_id = '" . $v['id'] . "'"; $this->db->query($sql); //更新电视剧 foreach ($ep as $_k => $_v) { publish_insert_query($_v, 'update', $column_id_arr, 1); } publish_insert_query($v, 'update', $column_id_arr); } } } } $this->addItem('success'); $this->output(); }
/** * 文稿移到垃圾箱 */ public function moveToTrash() { $id = intval($this->input['id']); $news_id = intval($this->input['news_id']); $info = $this->obj->get_article(' id =' . $news_id); $info['column_id'] = @unserialize($info['column_id']); //取消文稿库中column的关系 //取消article $this->obj->update(array('column_id' => '', 'column_url' => ''), 'article', ' id =' . $news_id); //delete pub_column $this->obj->delete('pub_column', ' aid = ' . $news_id); //删除发布库 $op = "delete"; publish_insert_query($info, $op); $this->addItem(array('return' => true)); $this->output(); }
/** * 视频移到垃圾箱 */ public function moveToTrash() { $id = intval($this->input['id']); $vod_id = intval($this->input['vod_id']); $sql = "select * from " . DB_PREFIX . "vodinfo where id = " . $vod_id; $info = $this->db->query_first($sql); $info['column_id'] = @unserialize($info['column_id']); //取消文稿库中column的关系 //取消article $update_sql = "update " . DB_PREFIX . "vodinfo set column_id = '' , column_url = '' where id = " . $vod_id; $this->db->query($update_sql); //delete pub_column $delete_Sql = "delete from " . DB_PREFIX . "pub_column where aid = " . $vod_id; $this->db->query($delete_Sql); //删除发布库 $op = "delete"; publish_insert_query($info, $op); $this->addItem(array('return' => true)); $this->output(); }
/** * 更新评论计数 * @name update_comment_count */ function update_comment_count() { if (empty($this->input['id'])) { $this->errorOutput(NO_ID); } $id = intval($this->input['id']); //评论数 if ($this->input['comment_count']) { $comment_count = $this->input['comment_count']; } else { $comment_count = 1; } //审核增加评论数、打回减少评论数 if ($this->input['type'] == 'audit') { $type = '+'; } else { if ($this->input['type'] == 'back') { $type = '-'; } } $info = array(); if ($type) { $sql = "UPDATE " . DB_PREFIX . "content SET comm_num=comm_num" . $type . $comment_count . " WHERE id =" . $id; $this->db->query($sql); $sql = "SELECT id, audit, expand_id, title, column_id, publish_time,user_name FROM " . DB_PREFIX . "content WHERE id =" . $id; $info = $this->db->query_first($sql); } if (empty($info)) { return FALSE; } if (intval($info['audit']) == 2) { if (!empty($info['expand_id'])) { $op = "update"; } else { $op = "insert"; } } else { if (!empty($info['expand_id'])) { $op = 'delete'; } else { $op = ''; } } publish_insert_query($info, $op); $return = array('status' => 1, 'id' => $id, 'pubstatus' => 1); $this->addItem($return); $this->output(); }
public function insertQueueToLivmedia() { $op = $this->input['op']; if (!$op || !in_array($op, array('insert', 'delete', 'update'))) { $this->errorOutput('no opration'); } if (!$this->input['id']) { $this->errorOutput(NOID); } //如果现在的栏目存在就已审核否则待审核 if ($this->input['now_colum']) { $status = ", status = 2 "; } else { $status = ", status = 3 "; } $sql = "UPDATE " . DB_PREFIX . "vodinfo SET column_id = '" . html_entity_decode($this->input['now_colum']) . "' {$status} WHERE id IN (" . $this->input['id'] . ")"; $q = $this->db->query($sql); $sql = "SELECT * FROM " . DB_PREFIX . "vodinfo WHERE id IN (" . $this->input['id'] . ")"; $q = $this->db->query($sql); while ($r = $this->db->fetch_array($q)) { $column_id_arr = array(); if ($this->input['column_id']) { $column_id_arr = explode(',', $this->input['column_id']); } //插入到队列 $r['pub_time'] = $this->input['pub_time'] ? $this->input['pub_time'] : TIMENOW; publish_insert_query($r, $op, $column_id_arr); } }
public function yunupdate() { $id = intval($this->input['id']); $_survey = $this->mode->get_survey('id = ' . $id, '*'); //获取问卷信息的初始数据 if (!$_survey) { $this->errorOutput(NO_CONTENT); } $status = $_survey['status']; #####节点权限检测数据收集 if ($this->user['group_type'] > MAX_ADMIN_TYPE) { $_node_ids = ''; if ($_survey['node_id']) { $_node_ids = $_survey['node_id']; } if ($this->input['node_id']) { $_node_ids = $_node_ids ? $_node_ids . ',' . $this->input['node_id'] : $this->input['node_id']; } if ($_node_ids) { $sql = 'SELECT id, parents FROM ' . DB_PREFIX . 'survey_node WHERE id IN(' . $_node_ids . ')'; $query = $this->db->query($sql); $nodes = array(); while ($row = $this->db->fetch_array($query)) { $nodes['nodes'][$row['id']] = $row['parents']; } } } #####节点权限 $nodes['id'] = $id; $nodes['user_id'] = $_survey['user_id']; $nodes['org_id'] = $_survey['org_id']; $nodes['column_id'] = $this->input['column_id']; $nodes['published_column_id'] = ''; // $nodes['weight'] = $vote['weight']; ###获取默认数据状态 if (!empty($_survey['column_id'])) { $status = $this->get_status_setting('update_publish', $_survey['status']); } else { if (intval($_survey['status']) == 1) { $status = $this->get_status_setting('update_audit', $_survey['status']); } } $_survey['column_id'] = $_survey['column_id'] ? unserialize($_survey['column_id']) : array(); $ori_column_id = array(); if (is_array($_survey['column_id'])) { $ori_column_id = array_keys($_survey['column_id']); $nodes['published_column_id'] = implode(',', $ori_column_id); } $nodes['_action'] = 'manage'; ######获取默认数据状态 $this->verify_content_prms($nodes); ########权限######### $problems = $this->input['forms']; if (!$problems) { $this->errorOutput('未提交问卷的问题'); } $update_data = $this->request_param(); $update_data['problem_num'] = count(array_filter($problems)); $update_data['status'] = $status; if ($column_id = $this->input['column_id']) { $update_data['column_id'] = $this->mPublishColumn->get_columnname_by_ids('id,name', $column_id); $update_data['column_id'] = $update_data['column_id'] ? serialize($update_data['column_id']) : ''; } if ($_FILES['Filedata']['name']) { $files['Filedata'] = $_FILES['Filedata']; $picture_pic = $this->material->addMaterial($files, $id); if ($picture_pic['filename']) { $pic = array('host' => $picture_pic['host'], 'dir' => $picture_pic['dir'], 'filepath' => $picture_pic['filepath'], 'filename' => $picture_pic['filename'], 'id' => $picture_pic['id']); $indexpic = @serialize($pic); } $update_data['indexpic'] = $indexpic ? $indexpic : ''; } $affected_rows = $this->mode->update($id, 'survey', $update_data); //更新主表数据 $survey = $update_data; $survey['id'] = $id; $survey['column_id'] = $update_data['column_id'] ? unserialize($update_data['column_id']) : ''; $del_id = $_problem_id = array(); $sql = 'SELECT id FROM ' . DB_PREFIX . 'problem WHERE survey_id = ' . $id; $q = $this->db->query($sql); while ($r = $this->db->fetch_array($q)) { $_problem_id[] = $r['id']; } foreach ($problems as $v) { $problems_id[] = $v['id']; } $del_id = array_diff($_problem_id, $problems_id); //比较标准组件,要删除的组件id if ($del_id) { $detele_problem = implode(',', $del_id); //删除问题表 $sql = " DELETE FROM " . DB_PREFIX . "problem WHERE id IN (" . $detele_problem . ")"; $this->db->query($sql); //删除选项表 $sql = " DELETE FROM " . DB_PREFIX . "options WHERE problem_id IN (" . $detele_problem . ")"; $this->db->query($sql); $this->addLogs('更新', $ret, '', '删除问题' . $detele_problem); $affected_rows = 1; } $affected_rows = $this->mode->process_data($problems, $id) || $affected_rows ? 1 : 0; //发布系统 $ret_sur = $this->mode->get_survey(" id = {$id}", 'column_id,status,expand_id'); //更改问卷之后的栏目 $ret_sur['column_id'] = $ret_sur['column_id'] ? unserialize($ret_sur['column_id']) : array(); $new_column_id = array(); if ($ret_sur['column_id'] && is_array($ret_sur['column_id'])) { $new_column_id = array_keys($ret_sur['column_id']); } $update_data['id'] = $id; if (intval($status) == 1) { if (!empty($ret_sur['expand_id'])) { $del_column = array_diff($ori_column_id, $new_column_id); if (!empty($del_column)) { publish_insert_query($update_data, 'delete', $del_column); } $add_column = array_diff($new_column_id, $ori_column_id); if (!empty($add_column)) { publish_insert_query($update_data, 'insert', $add_column); } $same_column = array_intersect($ori_column_id, $new_column_id); if (!empty($same_column)) { publish_insert_query($update_data, 'update', $same_column); //有新插入素材时需插入子队列 //publish_insert_query($update_data, 'insert',$same_column,1); } } else { $op = "insert"; publish_insert_query($update_data, $op); } } else { if (!empty($ret_sur['expand_id'])) { $op = "delete"; publish_insert_query($update_data, $op); } } $affected_rows = $this->mode->update($id, 'survey', $update_data) || $affected_rows ? 1 : 0; if ($affected_rows) { $user_data = array('update_time' => TIMENOW, 'update_user_id' => $this->user['user_id'], 'update_user_name' => $this->user['user_name']); $ret = $this->mode->update($id, 'survey', $user_data); } $survey['problems'] = $problems; if ($id) { if ($update_data['picture_ids']) { $sql = 'UPDATE ' . DB_PREFIX . 'material SET cid = ' . $id . ' WHERE id in(' . $update_data['picture_ids'] . ')'; $this->db->query($sql); } $this->addLogs('更新问卷', $_survey, $survey, '更新' . $survey['title'] . $this->input['id']); $this->addItem($survey); $this->output(); } }
public function updateEpisodeUrl() { if (!$this->input['video_id']) { $this->errorOutput(NOID); } $sql = "UPDATE " . DB_PREFIX . "tv_episode SET url = '" . $this->input['url'] . "' WHERE video_id = '" . $this->input['video_id'] . "' "; $this->db->query($sql); $sql = "SELECT * FROM " . DB_PREFIX . "tv_episode WHERE video_id = '" . $this->input['video_id'] . "'"; $episode = $this->db->query_first($sql); if ($episode) { publish_insert_query($episode, 'update', '', 1, 1); } //查询出该剧集所属电视剧的信息 $sql = "SELECT tv.* FROM " . DB_PREFIX . "tv_play tv LEFT JOIN " . DB_PREFIX . "tv_episode te ON te.tv_play_id = tv.id WHERE te.video_id = '" . $this->input['video_id'] . "'"; $tv_play = $this->db->query_first($sql); if ($tv_play) { $column_id = unserialize($tv_play['column_id']); $column_id = array_keys($column_id); publish_insert_query($tv_play, 'update', $column_id); } $this->addItem('success'); $this->output(); }
public function fast_edit() { if (!$this->input['id']) { $this->errorOutput(NOID); } $sql = "SELECT * FROM " . DB_PREFIX . "vodinfo WHERE id = '" . intval($this->input['id']) . "'"; $arr = $this->db->query_first($sql); //快速编辑之前视频的状态 $ori_status = $arr['status']; //查询视频快速编辑之前已经发布到的栏目 $arr['column_id'] = unserialize($arr['column_id']); $ori_column_id = array(); if (is_array($arr['column_id'])) { $ori_column_id = array_keys($arr['column_id']); } $column_id = $this->publish_column->get_columnname_by_ids('id,name', $this->input['column_id']); $column_id = serialize($column_id); $sql = " UPDATE " . DB_PREFIX . "vodinfo SET "; $data = array('title' => $this->input['title'] ? $this->input['title'] : $arr['title'], 'subtitle' => $this->input['subtitle'] ? $this->input['subtitle'] : $arr['subtitle'], 'comment' => $this->input['comment'] ? $this->input['comment'] : $arr['comment'], 'keywords' => $this->input['keywords'] ? $this->input['keywords'] : $arr['keywords'], 'author' => $this->input['author'] ? $this->input['author'] : $arr['author'], 'source' => $this->input['mark_source_id'] ? $this->input['mark_source_id'] : $arr['source'], 'vod_sort_id' => intval($this->input['mark_sort_id']) ? intval($this->input['mark_sort_id']) : $arr['vod_sort_id'], 'isfile' => 0, 'column_id' => addslashes($column_id)); foreach ($data as $k => $v) { $sql .= " {$k} = '{$v}',"; } $sql = trim($sql, ','); $sql .= " WHERE id = '" . intval($this->input['id']) . "'"; $this->db->query($sql); $this->change_mark_pic(intval($this->input['id'])); $original_id_arr = $this->input['original_id']; $start_time_arr = $this->input['start_time']; $duration_arr = $this->input['duration']; $this->request_create_physics(intval($this->input['id']), $original_id_arr, $start_time_arr, $duration_arr, 'transcode_fast_edit', $arr['status']); //返回数据 $sql_r = "SELECT * FROM " . DB_PREFIX . "vodinfo WHERE id = '" . intval($this->input['id']) . "'"; $ret = $this->db->query_first($sql_r); //快编视频后发布的栏目 $ret['column_id'] = unserialize($ret['column_id']); $new_column_id = array(); if (is_array($ret['column_id'])) { $new_column_id = array_keys($ret['column_id']); } if ($ori_status == 2) { if (!empty($ret['expand_id'])) { $del_column = array_diff($ori_column_id, $new_column_id); if (!empty($del_column)) { publish_insert_query($ret, 'delete', $del_column); } $add_column = array_diff($new_column_id, $ori_column_id); if (!empty($add_column)) { publish_insert_query($ret, 'insert', $add_column); } $same_column = array_intersect($ori_column_id, $new_column_id); if (!empty($same_column)) { publish_insert_query($ret, 'update', $same_column); } } else { if ($new_column_id) { $op = "insert"; publish_insert_query($ret, $op); } } } else { if (!empty($ret['expand_id'])) { $op = "delete"; publish_insert_query($ret, $op); } } $this->index_search($ret, 'update'); //插入工作量统计 $statistic = new statistic(); $statistics_data = array('content_id' => intval($this->input['id']), 'contentfather_id' => '', 'type' => 'update', 'user_id' => $ret['user_id'], 'user_name' => $ret['addperson'], 'before_data' => '', 'last_data' => $this->input['title'], 'num' => 1); $statistic->insert_record($statistics_data); $this->addItem($ret); $this->output(); }
public function show() { //查询有没有过期的电视剧并且设置了每天发布的电视剧 $sql = "SELECT * FROM " . DB_PREFIX . "tv_play \n\t\t\t\tWHERE status = 2 \n\t\t\t\tAND publish_num_day != 0 \n\t\t\t\tAND (copyright_limit > " . TIMENOW . " OR copyright_limit = 0)"; $q = $this->db->query($sql); $tv_play = array(); while ($r = $this->db->fetch_array($q)) { $tv_play[] = $r; $tv_play_id[] = $r['id']; } //删除不在计划内的记录 $sql = "DELETE FROM " . DB_PREFIX . "publish_cron WHERE tv_play_id NOT IN (" . implode(',', $tv_play_id) . ")"; $this->db->query($sql); $today = strtotime(date('Y-m-d')); //查询当天发布过的电视剧id $sql = "SELECT tv_play_id,publish_num FROM " . DB_PREFIX . "publish_cron WHERE create_time = " . $today; $q = $this->db->query($sql); $tv_play_ids = array(); while ($r = $this->db->fetch_array($q)) { $tv_play_ids[] = $r['tv_play_id']; $publish_num[$r['tv_play_id']] = $r['publish_num']; } //hg_pre($publish_num); //hg_pre($tv_play_ids); if ($tv_play) { foreach ($tv_play as $k => $v) { //已经发布过的个数 $published_num = $publish_num[$v['id']]; $published_num = $published_num ? $published_num : 0; //过滤已经发布过的 if (in_array($v['id'], $tv_play_ids) && $published_num >= $v['publish_num_day']) { continue; } if ($v['column_id'] && $v['status'] == 2) { $count = $v['publish_num_day'] - $published_num; $sql = "SELECT * FROM " . DB_PREFIX . "tv_episode \n\t\t\t\t\t\t\tWHERE expand_id = 0 \n\t\t\t\t\t\t\tAND transcode_status = 1 \n\t\t\t\t\t\t\tAND tv_play_id = '" . $v['id'] . "' \n\t\t\t\t\t\t\tORDER BY index_num ASC \n\t\t\t\t\t\t\tLIMIT 0," . $count; //echo $sql; $q = $this->db->query($sql); $video_ids = array(); $ep = array(); while ($r = $this->db->fetch_array($q)) { $video_ids[] = $r['video_id']; $ep[] = $r; } //hg_pre($v); //hg_pre($video_ids); //hg_pre($ep); if ($video_ids) { $video_num = $video_ids ? count($video_ids) : 0; $video_num += $published_num; $column_id_arr = array_keys(unserialize($v['column_id'])); //触发视频发布 $this->livmedia->insertQueueToLivmedia(implode(',', $video_ids), 'insert', implode(',', $column_id_arr), $v['column_id']); //发布剧集 foreach ($ep as $_k => $_v) { publish_insert_query($_v, 'insert', $column_id_arr, 1); } publish_insert_query($v, 'update', $column_id_arr); //发布成功记录 $sql = "REPLACE INTO " . DB_PREFIX . "publish_cron SET tv_play_id = " . $v['id'] . ',create_time = ' . $today . ',publish_num = ' . $video_num; //echo $sql; $this->db->query($sql); } } } } $this->addItem('success'); $this->output(); }
/** * 文稿移到垃圾箱 */ public function moveToTrash() { $id = intval($this->input['id']); $vote_id = intval($this->input['vote_id']); $ret_sur = $this->mVote->get_vote_list(" id IN({$vote_id})"); $info = $ret_sur[0]; $info['column_id'] = @unserialize($info['column_id']); //取消文稿库中column的关系 //取消article $this->mVote->update(array('id' => $vote_id, 'column_id' => '', 'column_url' => '')); //delete pub_column // $this->obj->delete('pub_column', ' aid = '.$vote_id); //删除发布库 $op = "delete"; publish_insert_query($info, $op); $this->addItem(array('return' => true)); $this->output(); }
public function insertQueueToLivmediaByVideoID($tv_play_id, $video_id, $op, $column_id, $now_column, $pub_time) { /*$sql = "SELECT * FROM " .DB_PREFIX. "tv_episode WHERE tv_play_id = '" .$tv_play['id']. "' AND expand_id = 0 "; $q = $this->db->query($sql); $video_id_arr = array(); while ($r = $this->db->fetch_array($q)) { $video_id_arr[] = $r['video_id']; }*/ if ($video_id && $tv_play_id) { //查询剧集信息 $sql = "SELECT * FROM " . DB_PREFIX . "tv_episode WHERE tv_play_id = {$tv_play_id} AND video_id = {$video_id}"; $ep_info = $this->db->query_first($sql); publish_insert_query($ep_info, 'insert', $column_id, 1); include_once ROOT_PATH . 'lib/class/livmedia.class.php'; $livmedia = new livmedia(); $livmedia->insertQueueToLivmedia($video_id, $op, implode(',', $column_id), $now_column, $pub_time); } }
function update_block_content() { $block = $this->input['data']['block']; $data = $this->input['data']['data']; if (!$block || !$data || !is_array($data) || !is_array($block)) { $this->errorOutput('NO_DATA'); } foreach ($data as $k => $v) { $content_fromids[] = $v['content_fromid']; } if (!$content_fromids) { $this->errorOutput('NO_CONTENT_FROMID'); } $sq = "SELECT * FROM " . DB_PREFIX . "tuji WHERE id in (" . implode(',', $content_fromids) . ")"; $info = $this->db->query($sq); while ($row = $this->db->fetch_array($info)) { $pub_block = $row['block'] ? unserialize($row['block']) : array(); foreach ($block as $k => $v) { if ($block[$k]['del']) { unset($pub_block[$k]); } else { $pub_block[$k] = $block[$k]; } } $pub_block = $pub_block ? serialize($pub_block) : ''; $sql = "UPDATE " . DB_PREFIX . "tuji SET block='{$pub_block}' WHERE id=" . $row['id']; $this->db->query($sql); $row['block'] = $pub_block; //同步发布库 publish_insert_query($row, 'update'); } }
public function yunupdate() { $id = intval($this->input['id']); if (!$id) { $this->errorOutput(NOID); } $forms = $this->input['forms']; if (!$forms) { $this->errorOutput('对不起,组件不能为空'); } $standard_ids = $fixed_ids = array(); foreach ($forms as $key => $value) { $value['order_id'] = $key + 1; $is_name = $is_name ? 1 : $value['is_name']; if ($value['type'] == 'standard') { $standard[] = $value; $standard_ids[] = $value['id']; } else { $fixed[] = $value; $fixed_ids[] = $value['id']; } } if (!$is_name && !$this->input['is_login']) { $this->errorOutput("上传附件和分割线组件不允许单独使用"); } if (!$this->settings['App_verifycode'] && intval($this->input['is_verifycode'])) { $this->errorOutput('验证码应用未安装!'); } $_feedback = $this->mode->get_feedback('id = ' . $id, '*'); //获取问卷信息的初始数据 $status = $_feedback['status']; #####节点权限检测数据收集 if ($this->user['group_type'] > MAX_ADMIN_TYPE) { $_node_ids = ''; if ($_feedback['node_id']) { $_node_ids = $_feedback['node_id']; } if ($this->input['node_id']) { $_node_ids = $_node_ids ? $_node_ids . ',' . $this->input['node_id'] : $this->input['node_id']; } if ($_node_ids) { $sql = 'SELECT id, parents FROM ' . DB_PREFIX . 'feedback_node WHERE id IN(' . $_node_ids . ')'; $query = $this->db->query($sql); $nodes = array(); while ($row = $this->db->fetch_array($query)) { $nodes['nodes'][$row['id']] = $row['parents']; } } } #####节点权限 $nodes['id'] = $id; $nodes['user_id'] = $_feedback['user_id']; $nodes['org_id'] = $_feedback['org_id']; $nodes['column_id'] = $this->input['column_id']; $nodes['published_column_id'] = ''; ###获取默认数据状态 if (!empty($_feedback['column_id'])) { $status = $this->get_status_setting('update_publish', $_feedback['status']); } else { if (intval($_feedback['status']) == 1) { $status = $this->get_status_setting('update_audit', $_feedback['status']); } } $ori_column_id = array(); $_feedback['column_id'] = unserialize($_feedback['column_id']); if (is_array($_feedback['column_id'])) { $ori_column_id = array_keys($_feedback['column_id']); $nodes['published_column_id'] = implode(',', $ori_column_id); } $nodes['_action'] = 'manage'; ######获取默认数据状态 if ($this->user['group_type'] > MAX_ADMIN_TYPE && $_feedback['admin_user']) { $admin_user = array(); $admin_user = explode(',', $_feedback['admin_user']); if (!in_array($this->user['user_name'], $admin_user)) { $this->errorOutput("对不起,您没有此表单的权限"); } } if ($this->user['group_type'] > MAX_ADMIN_TYPE && !$_feedback['admin_user']) { $this->verify_content_prms($nodes); } ########权限######### $update_data = $this->request_param(); $vid = $id; if ($_FILES['indexpic']) { $files['Filedata'] = $_FILES['indexpic']; $material = $this->material->addMaterial($files, $vid); $indexpic = array('host' => $material['host'], 'dir' => $material['dir'], 'filepath' => $material['filepath'], 'filename' => $material['filename']); } elseif ($this->input['indexpic'] && $this->input['indexpic']['filename']) { $indexpic = $this->input['indexpic']; } $update_data['indexpic'] = $indexpic ? serialize($indexpic) : ''; $column_id = $this->input['column_id']; $update_data['column_id'] = $this->mPublishColumn->get_columnname_by_ids('id,name', $column_id); $update_data['column_id'] = $update_data['column_id'] ? serialize($update_data['column_id']) : ''; $update_data = $this->mode->update($id, 'feedback', $update_data); $update_data['id'] = $id; if ($update_data['affected_rows']) { $affect_rows = 1; } //表单的更新 包括表单新增 修改 删除; $_forms = $this->mode->get_forms($id); //原反馈表单id $_standard_ids = $_fixed_ids = array(); if (is_array($_forms) && count($_forms) > 0) { foreach ($_forms as $v) { if ($v['type'] == 'standard') { $_standard_ids[] = $v['id']; } if ($v['type'] == 'fixed') { $_fixed_ids[] = $v['id']; } } } $st_diff = array_diff($_standard_ids, $standard_ids); //比较标准组件,要删除的组件id $fx_diff = array_diff($_fixed_ids, $fixed_ids); //比较固定组件,要删除的组件id if (count($st_diff) > 0) { $delete_stan_ids = implode(',', $st_diff); } if (count($fx_diff) > 0) { $delete_fix_ids = implode(',', $fx_diff); } $data_s['common'] = $data_f['common'] = array(); if ($standard) { $data_s = $this->mode->process_standard($standard, $vid, 1); } if ($fixed) { $data_f = $this->mode->process_fixed($fixed, $vid, 1); } $common_data = array_merge($data_s['common'], $data_f['common']); if ($common_data) { $this->mode->insert_datas('common', $common_data, 1); } if ($data_s['standard']) { foreach ($data_s['standard'] as $v) { $up_standard_data = $this->mode->update($v['id'], 'standard', $v); //更新标准组建 if ($up_standard_data['affected_rows']) { $affect_rows = 1; } } } if ($data_f['fixed']) { foreach ($data_f['fixed'] as $v) { $up_fixed_data = $this->mode->update($v['id'], 'fixed', $v); //更新标准组建 if ($up_fixed_data['affected_rows']) { $affect_rows = 1; } } } if ($data_s['new_standard']) { $this->mode->insert_datas('standard', $data_s['new_standard']); $affect_rows = 1; } if ($data_f['new_fixed']) { $this->mode->insert_datas('fixed', $data_f['new_fixed']); $affect_rows = 1; } if ($delete_stan_ids) { $sql = "DELETE FROM " . DB_PREFIX . "standard WHERE id in(" . $delete_stan_ids . ")"; $this->db->query($sql); $affect_rows = 1; } if ($delete_fix_ids) { $sql = "DELETE FROM " . DB_PREFIX . "fixed WHERE id in(" . $delete_fix_ids . ")"; $this->db->query($sql); $affect_rows = 1; } if ($affect_rows) { $update_user = array('update_user_id' => $this->user['user_id'], 'update_user_name' => $this->user['user_name'], 'update_time' => TIMENOW); if ($status) { $update_data['reupdate'] = $update_user['reupdate'] = 1; } $update_user = $this->mode->update($id, 'feedback', $update_user); $update_data['update_user_id'] = $update_user['update_user_id']; $update_data['update_user_name'] = $update_user['update_user_name']; $update_data['update_time'] = $update_user['update_time']; } unset($update_data['affected_rows']); $update_data['sort_id'] = $update_data['node_id']; //发布系统 $ret_feedback = $this->mode->get_feedback(" id = {$id}", 'column_id,status,expand_id'); //更新的栏目 $ret_feedback['column_id'] = unserialize($ret_feedback['column_id']); $new_column_id = array(); if (is_array($ret_feedback['column_id'])) { $new_column_id = array_keys($ret_feedback['column_id']); } //$data['id'] = $id; if ($status == 1) { if (!empty($ret_feedback['expand_id'])) { $del_column = array_diff($ori_column_id, $new_column_id); if (!empty($del_column)) { publish_insert_query($update_data, 'delete', $del_column); } $add_column = array_diff($new_column_id, $ori_column_id); if (!empty($add_column)) { publish_insert_query($update_data, 'insert', $add_column); } $same_column = array_intersect($ori_column_id, $new_column_id); if (!empty($same_column)) { publish_insert_query($update_data, 'update', $same_column); //有新插入素材时需插入子队列 //publish_insert_query($update_data, 'insert',$same_column,1); } } else { $op = "insert"; publish_insert_query($update_data, $op); } } else { if (!empty($ret_feedback['expand_id'])) { $op = "delete"; publish_insert_query($update_data, $op); } } if ($id) { $update_data['forms'] = $forms; $this->addLogs('更新反馈表单', $_feedback, $update_data, '更新' . $update_data['title'] . $id); $this->addItem($update_data); $this->output(); } }
public function delete_pic() { if (!$this->input['id']) { $this->errorOutput(NOID); } $this->input['id'] = trim($this->input['id']); $sql = "SELECT * FROM " . DB_PREFIX . "pics WHERE id IN (" . $this->input['id'] . ")"; $r = $this->db->query($sql); while ($row = $this->db->fetch_array($r)) { $data[$row['id']] = array('title' => $row['old_name'], 'delete_people' => trim(urldecode($this->user['user_name'])), 'cid' => $row['id']); $data[$row['id']]['content']['pics'] = $row; } if (!empty($data)) { foreach ($data as $key => $value) { $this->recycle->add_recycle($value['title'], $value['delete_people'], $value['cid'], $value['content']); } } $sql = "SELECT * FROM " . DB_PREFIX . "pics WHERE id IN(" . urldecode($this->input['id']) . ")"; $ret = $this->db->query($sql); $is_cover = 0; $count = 0; while ($row = $this->db->fetch_array($ret)) { if ($row['tuji_id']) { $tuji_id = $row['tuji_id']; } if ($row['is_cover']) { $is_cover = 1; } if ($row['expand_id']) { publish_insert_query($row, 'delete', '', 1, 'old_name'); } if ($row['id']) { $count++; } } $sql = " DELETE FROM " . DB_PREFIX . "pics WHERE id IN (" . urldecode($this->input['id']) . ")"; $this->db->query($sql); //删除图集的封面 $cover_url = ''; if ($is_cover && $tuji_id) { $cover_url = 'cover_url = \'\','; } if ($tuji_id) { $total_pic = 'total_pic = total_pic -' . $count; $sql = " UPDATE " . DB_PREFIX . "tuji SET {$cover_url}{$total_pic} WHERE id = '" . $tuji_id . "'"; $this->db->query($sql); } $this->addItem('success'); $this->output(); }
function create() { if (!$this->input['title']) { $this->errorOutput('标题不能为空'); } if (!$this->input['content'] && !$this->input['outlink']) { $this->errorOutput('内容不能为空'); } if (urldecode($this->input['outlink']) && urldecode($this->input['outlink']) != '请填写超链接!') { $content = ''; } else { $check_info = hg_check_content(html_entity_decode($this->input['content'])); $content = addslashes($this->input['content']); } if (!(strpos(urldecode($this->input['indexpic']), 'http://') === false)) { $this->input['indexpic'] = $this->indexpic_img_local(urldecode($this->input['indexpic'])); } //是否开启评论 优先使用iscomment设置 if (isset($this->input['iscomment'])) { $this->input['other_settings']['closecomm'] = !intval($this->input['iscomment']); } $info = array('title' => $this->input['title'], 'page_title' => $this->input['pagetitles'], 'tcolor' => $this->input['tcolor'], 'isbold' => intval($this->input['isbold']), 'isitalic' => intval($this->input['isitalic']), 'istop' => $this->input['istop'] == 1 ? 1 : 0, 'iscomment' => !$this->input['other_settings']['closecomm'], 'istpl' => $this->input['istpl'] == 1 ? 1 : 0, 'subtitle' => $this->input['subtitle'], 'keywords' => str_replace(' ', ',', trim($this->input['keywords'])), 'brief' => $this->input['brief'], 'author' => $this->input['author'], 'source' => $this->input['source'], 'indexpic' => intval($this->input['indexpic']), 'outlink' => $this->input['outlink'], 'sort_id' => intval($this->input['sort_id']), 'column_id' => $this->input['column_id'], 'org_id' => $this->input['org_id'] ? intval($this->input['org_id']) : intval($this->user['org_id']), 'user_id' => $this->input['user_id'] ? intval($this->input['user_id']) : intval($this->user['user_id']), 'user_name' => $this->input['user_name'] ? $this->input['user_name'] : $this->user['user_name'], 'create_time' => $this->input['create_time'] ? $this->input['create_time'] : TIMENOW, 'update_time' => $this->input['update_time'] ? $this->input['update_time'] : TIMENOW, 'pub_time' => strtotime($this->input['pub_time']), 'ip' => hg_getip(), 'weight' => intval($this->input['weight']), 'water_id' => $this->input['water_config_id'], 'water_name' => $this->input['water_config_name'], 'is_img' => $check_info['is_img'], 'is_video' => $check_info['is_video'], 'is_tuji' => $check_info['is_tuji'], 'is_vote' => $check_info['is_vote'], 'appid' => intval($this->user['appid']), 'appname' => trim($this->user['display_name']), 'state' => isset($this->input['state']) ? intval($this->input['state']) : $this->settings['default_state'], 'pub_time' => strtotime($this->input['publish_time']), 'app' => $this->input['app_uniqueid'] ? $this->input['app_uniqueid'] : APP_UNIQUEID, 'module' => $this->input['module_uniqueid'] ? $this->input['module_uniqueid'] : MOD_UNIQUEID, 'para' => $this->input['para'], 'ori_url' => $this->input['ori_url']); include_once ROOT_PATH . 'lib/class/publishconfig.class.php'; $this->publish_column = new publishconfig(); $column_id = $info['column_id'] = $this->publish_column->get_columnname_by_ids('id,name', $info['column_id']); $info['column_id'] = serialize($info['column_id']); $info['id'] = $article_id = $this->obj->insert_data($info, "article"); $this->obj->update(array('order_id' => $article_id), "article", "id={$article_id}"); //内容表 $infoCon = array('articleid' => $article_id, 'content' => $content); $this->obj->insert_data($infoCon, "article_contentbody"); ###更新索引图ID $this->input['indexpic'] && $this->obj->update(array('cid' => $article_id), 'material', ' material_id=' . $this->input['indexpic']); //处理图片 if ($this->input['needlocalimg']) { $url = is_array($this->input['needlocalimg']) ? implode(',', $this->input['needlocalimg']) : $this->input['needlocalimg']; $material = $this->mater->localMaterial($url); if (is_array($material) && count($material) > 0) { foreach ($material as $k => $v) { if ($v && !$v['error']) { $tem_data = array('cid' => $info['id'], 'material_id' => $v['id'], 'name' => $v['name'], 'type' => $v['type'], 'mark' => $v['mark'], 'filesize' => $v['filesize'], 'create_time' => $v['create_time'], 'ip' => $v['ip'], 'remote_url' => $v['remote_url'], 'host' => $v['host'], 'dir' => $v['dir'], 'filepath' => $v['filepath'], 'filename' => $v['filename']); $tem_data['pic'] = array('host' => $v['host'], 'dir' => $v['dir'], 'filepath' => $v['filepath'], 'filename' => $v['filename']); $tem_data['pic'] = serialize($tem_data['pic']); $this->obj->insert_data($tem_data, 'material'); } } } } if ($this->input['img']) { if (is_array($this->input['img']) && count($this->input['img']) > 0) { $material_id = array(); foreach ($this->input['img'] as $k => $v) { if ($v) { $tmp_data = array('cid' => $info['id'], 'material_id' => $v['id'], 'name' => $v['name'], 'type' => $v['type'], 'mark' => $v['mark'] ? $v['mark'] : 'img', 'filesize' => $v['filesize'], 'create_time' => $v['create_time'], 'host' => $v['host'], 'dir' => $v['dir'], 'filepath' => $v['filepath'], 'filename' => $v['filename']); $tmp_data['pic'] = array('host' => $v['host'], 'dir' => $v['dir'], 'filepath' => $v['filepath'], 'filename' => $v['filename']); $tmp_data['pic'] = serialize($tmp_data['pic']); $material_id[] = $v['id']; $this->obj->insert_data($tmp_data, 'material'); } } $material_id = implode(',', $material_id); if ($material_id) { $this->mater->updateMaterialNum($material_id); } } } if ($this->input['material_ids']) { $material = $this->mater->get_material_by_ids($this->input['material_ids']); foreach ((array) $material as $k => $v) { if ($v) { $tmp_data = array('cid' => $info['id'], 'material_id' => $v['id'], 'name' => $v['name'], 'type' => $v['type'], 'mark' => $v['mark'] ? $v['mark'] : 'img', 'filesize' => $v['filesize'], 'create_time' => $v['create_time'], 'host' => $v['host'], 'dir' => $v['dir'], 'filepath' => $v['filepath'], 'filename' => $v['filename']); $tmp_data['pic'] = array('host' => $v['host'], 'dir' => $v['dir'], 'filepath' => $v['filepath'], 'filename' => $v['filename']); $tmp_data['pic'] = serialize($tmp_data['pic']); $material_id[] = $v['id']; $this->obj->insert_data($tmp_data, 'material'); } } } //放入发布队列 if (intval($info['state']) == 1 && !empty($column_id)) { $op = 'insert'; publish_insert_query($info, $op); } //叮当平台需要记录索引图 if ($this->input['need_indexpic'] && $info['indexpic']) { $info['indexpic_url'] = $this->obj->getIndexpic($info['indexpic']); } $this->addItem($info); $this->output(); }