private function updateContent($data) { if (empty($data['contentid'])) { return false; } $table = 'content_' . App::get_site_id() . '_extend'; $content = $this->from($table)->where('id=' . $data['contentid'])->select(false); if (empty($content)) { return false; } $position = @explode(',', $content['position']); $update = array(); if (empty($position)) { $update = array($data['posid']); } else { foreach ($position as $p) { if ($p) { $update[] = $p; } } $update[] = $data['posid']; $update = array_unique($update); } $update = @implode(',', $update); $this->query('update ' . $this->prefix . $table . ' set position="' . $update . '" where id=' . $data['contentid']); }
private function updateData($id, $where) { $data = $this->execute('SELECT id FROM ' . $this->prefix . 'content_' . App::get_site_id() . ' WHERE ' . $where, true); $this->set_table_name('tag_cache'); if (empty($data)) { $this->delete('id=' . $id); return false; } $total = count($data); $ids = ''; foreach ($data as $t) { $ids .= $t['id'] . ','; } $ids = substr($ids, -1) == ',' ? substr($ids, 0, -1) : $ids; $data = array('addtime' => time(), 'total' => $total, 'sql' => 'SELECT * FROM ' . $this->prefix . 'content_' . App::get_site_id() . ' WHERE `id` IN (' . $ids . ') ORDER BY `updatetime` DESC'); $this->update($data, 'id=' . $id); return $data; }
/** * 后台投稿权限验证 */ function admin_post_auth($roleid, $data) { if (isset($data['adminpost']) && $data['adminpost'] && $data['rolepost'] && in_array($roleid, $data['rolepost'])) { return true; } elseif (isset($data['siteuser']) && $data['siteuser'] && $data['site'] && in_array(App::get_site_id(), $data['site'])) { return true; } else { return false; } }
/** * 处理内容审核数据 */ public function set_verify_data($id, $table, $data) { if ($data['status'] != 2 && $data['status'] != 3) { return false; } if ($id) { //修改内容 $this->update(array('status' => $data['status']), 'id=' . $id); //更新内容表状态 $this->set_table_name('content_' . App::get_site_id() . '_verify'); //设置为审核表对象 $this->get_table_fields(true); $row = $this->find($id); $verify = array('id' => $id, 'catid' => $data['catid'], 'title' => $data['title'], 'userid' => $data['userid'], 'status' => $data['status'], 'modelid' => $data['modelid'], 'content' => array2string($data), 'username' => $data['username'], 'tablename' => $table, 'updatetime' => time()); if ($row) { //如果存在则修改 $this->update($verify, 'id=' . $id); } else { //不存在则插入新数据 $this->insert($verify); } } else { //增加内容 $id = $this->get_content_id(); //生成内容id $verify = array('id' => $id, 'catid' => $data['catid'], 'title' => $data['title'], 'userid' => $data['userid'], 'status' => $data['status'], 'modelid' => $data['modelid'], 'content' => array2string($data), 'username' => $data['username'], 'tablename' => $table, 'updatetime' => time()); $this->set_table_name('content_' . App::get_site_id() . '_verify'); //设置为审核表对象 $this->get_table_fields(true); $this->insert($verify); $this->query('UPDATE ' . $this->prefix . 'member_count SET post=post+1 WHERE id=' . $data['userid']); //增加会员统计数量 } $this->set_extend_data($id, $data); //处理内容扩展数据 return $id; }
/** * 相关文章列表 */ protected function relation($id, $num = 10) { if (empty($id)) { return false; } $db = Controller::model('content'); $row = $db->from('content_' . App::get_site_id() . '_extend')->where('id=' . (int) $id)->select(false); if (empty($row) || empty($row['relation'])) { return null; } $ids = $row['relation']; $data = $db->relation($ids, $num); return $data; }
/** * 相关文章列表 */ protected function relation($id, $num = 10, $more = 0) { if (empty($id)) { return false; } $db = Controller::model('content'); $row = $db->from('content_' . App::get_site_id() . '_extend')->where('id=' . (int) $id)->select(false); if (empty($row) || empty($row['relation'])) { return null; } $ids = $row['relation']; $num = $num ? $num : 10; if ($more) { $cats = get_category_data(App::get_site_id()); $models = get_model_data('content', App::get_site_id()); $table = $models[$cats[$row['catid']]['modelid']]['tablename']; if ($table) { $sql = 'select * from `' . $this->ci->db->dbprefix('content_' . App::get_site_id()) . '` as a left join `' . $this->ci->db->dbprefix($table) . '` as b on a.id=b.id where a.id IN (' . $ids . ') order by a.listorder desc, a.updatetime desc limit ' . $num; $data = $this->ci->db->query($sql)->result_array(); return $data; } } $data = $db->from('content_' . App::get_site_id())->where('id in (' . $ids . ')')->order('listorder desc, updatetime desc')->limit($num)->select(); return $data; }
public function del($posid) { $this->delete('posid=' . $posid . ' AND site=' . App::get_site_id()); $table = $this->prefix . 'position_data'; $this->query('delete from ' . $table . ' where posid=' . $posid); }
/** * 删除栏目及数据 * @param int $catid * @return boolean */ public function del($catid) { if (empty($catid)) { return false; } $this->repair($catid); //修复该栏目数据 $catids = $this->child($catid, true); if (empty($catids)) { return false; } $catids = substr($catids, -1) == ',' ? substr($catids, 0, -1) : $catids; //删除栏目数据 $this->delete('catid IN (' . $catids . ')'); //查询内容id集合 $ids = ''; $data = $this->execute('SELECT id FROM `' . $this->prefix . 'content_' . App::get_site_id() . '` WHERE `catid` IN (' . $catids . ')'); if ($data) { //删除内容扩展 $this->query('DELETE FROM `' . $this->prefix . 'content_' . App::get_site_id() . '_extend` WHERE `catid` IN (' . $catids . ')'); foreach ($data as $t) { $ids .= $t['id'] . ','; } $ids = substr($ids, -1) == ',' ? substr($ids, 0, -1) : $ids; $cats = get_category_data(); $catids = explode(',', $catids); foreach ($catids as $catid) { //删除内容表数据 if ($cats[$catid]['tablename']) { $this->query('DELETE FROM `' . $this->prefix . 'content_' . App::get_site_id() . '` WHERE `catid`=' . $catid); $this->query('DELETE FROM `' . $this->prefix . $cats[$catid]['tablename'] . '` WHERE `catid`=' . $catid); } //删除关联表单数据 $form = $this->execute('SELECT * FROM `' . $this->prefix . 'model` WHERE `joinid`=' . (int) $cats[$catid]['modelid']); if ($form) { foreach ($form as $t) { $this->query('DELETE FROM `' . $this->prefix . $t['tablename'] . '` WHERE `cid` IN (' . $ids . ')'); } } } } return true; }
private function updateData($data, $params, $sql, $modelid, $catid) { if (empty($data)) { return false; } if (empty($params)) { return $data; } $cdata = $this->execute($data['sql'], true); $tablename = 'content_' . App::get_site_id(); if (empty($cdata)) { $this->delete('id=' . $data['id']); return false; } $kw = $data['keywords']; $total = count($cdata); if ($total == 1 && $cdata && strcasecmp($cdata[0]['title'], $kw) == 0) { Controller::redirect($cdata[0]['url']); exit; } $ids = ''; foreach ($cdata as $t) { $ids .= $t['id'] . ','; } $ids = substr($ids, -1) == ',' ? substr($ids, 0, -1) : $ids; $upda = array('params' => md5($params), 'addtime' => time(), 'total' => $total, 'keywords' => $kw, 'sql' => $sql . ' WHERE `' . $this->prefix . $tablename . '`.`id` IN (' . $ids . ')', 'modelid' => $modelid, 'catid' => $catid); $this->update($upda, 'id=' . $data['id']); $upda['id'] = $data['id']; return $upda; }
public function get_site_id($site = 0) { $site = $site ? $site : App::get_site_id(); $sites = App::get_site(); return $sites[$site]['SITE_EXTEND_ID'] ? $sites[$site]['SITE_EXTEND_ID'] : $site; }