function syn_content_add($param)
 {
     if (!isset($param['syn']['use']) || !$param['syn']['use']) {
         return;
     }
     $name = $param['syn']['name'];
     unset($param['data'][0]['id'], $param['data'][1]['id'], $param['data'][1]['tableid'], $param['data'][1]['url'], $param['data'][0][$name], $param['data'][1][$name], $param['syn']['name'], $param['syn']['use']);
     foreach ($param['syn'] as $site => $catid) {
         $catid = (int) $catid;
         if ($this->ci->SITE[$site] && $catid) {
             $param['data'][0]['catid'] = $param['data'][1]['catid'] = $catid;
             $this->ci->content_model->link = $this->ci->site[$site];
             $this->ci->content_model->prefix = $this->ci->db->dbprefix($site . '_' . APP_DIR);
             $this->ci->content_model->is_category = FALSE;
             if ($param['data'][1]['id'] = $this->ci->content_model->add($param['data'])) {
                 // 更新地址
                 $this->ci->site[$site]->where('id', $param['data'][1]['id'])->update($this->ci->content_model->prefix, array('url' => dr_show_url($this->ci->get_cache('module-' . $site . '-' . APP_DIR), $param['data'][1])));
             }
         }
     }
     unset($param);
 }
예제 #2
0
 /**
  * 创建内容html文件
  */
 protected function _create_show_file($id, $member = TRUE)
 {
     if (!MODULE_HTML || !$id) {
         return NULL;
     }
     $this->clear_cache('show' . $this->dir . SITE_ID . $id);
     $mod = $this->get_cache('module-' . SITE_ID . '-' . $this->dir);
     list($data, $tpl) = $this->index($id, 1, TRUE);
     if (!$data) {
         return NULL;
     }
     $file = str_replace($mod['url'], '', $data['url']);
     if (strpos($file, 'index.php?c=show') !== FALSE) {
         return NULL;
     }
     $filepath = array();
     ob_start();
     $this->template->display($tpl);
     $dir = dirname($file);
     $file = basename($file);
     $html = ob_get_clean();
     if (SITE_ID > 1) {
         $dir = trim('html/' . SITE_ID . '/' . trim($dir, '.'), '/');
     }
     if ($dir != '.' && !file_exists(APPPATH . $dir)) {
         dr_mkdirs(APPPATH . $dir, TRUE);
     }
     // 判断是否为目录形式
     if (strpos($file, '.html') === FALSE && strpos($file, '.htm') === FALSE && strpos($file, '.shtml') === FALSE) {
         dr_mkdirs(APPPATH . $dir . '/' . $file, TRUE);
     }
     // 如果是目录就生成一个index.html
     if (is_dir(APPPATH . $dir . '/' . $file)) {
         $dir .= '/' . $file;
         $file = 'index.html';
     }
     if (!file_put_contents(APPPATH . $dir . '/' . $file, $html, LOCK_EX)) {
         return NULL;
     }
     $filepath[] = APPPATH . $dir . '/' . $file;
     // 表示存在内容分页
     if (isset($data['content_page']) && $data['content_page']) {
         foreach ($data['content_page'] as $i => $p) {
             $url = dr_show_url($mod, $data, $i);
             $file = str_replace($mod['url'], '', $url);
             list($cdata, $tpl) = $this->index($id, $i, TRUE);
             if ($cdata) {
                 ob_start();
                 $this->template->display($tpl);
                 $dir = dirname($file);
                 $file = basename($file);
                 $html = ob_get_clean();
                 if (SITE_ID > 1) {
                     $dir = trim('html/' . SITE_ID . '/' . trim($dir, '.'), '/');
                 }
                 if ($dir != '.' && !file_exists(APPPATH . $dir)) {
                     dr_mkdirs(APPPATH . $dir, TRUE);
                 }
                 // 判断是否为目录形式
                 if (strpos($file, '.html') === FALSE && strpos($file, '.htm') === FALSE && strpos($file, '.shtml') === FALSE) {
                     dr_mkdirs(APPPATH . $dir . '/' . $file, TRUE);
                 }
                 // 如果是目录就生成一个index.html
                 if (is_dir(APPPATH . $dir . '/' . $file)) {
                     $dir .= '/' . $file;
                     $file = 'index.html';
                 }
                 @file_put_contents(APPPATH . $dir . '/' . $file, $html, LOCK_EX);
                 $filepath[] = APPPATH . $dir . '/' . $file;
             }
         }
     }
     // 保存文件记录
     $this->content_model->set_html(1, $data['uid'], 0, $id, $data['catid'], $filepath);
     if ($mod['extend']) {
         $list = $this->link->select('id')->where('cid', (int) $id)->get(SITE_ID . '_' . $this->dir . '_extend')->result_array();
         if ($list) {
             $this->clear_cache('show-extend' . $this->dir . SITE_ID . $id);
             foreach ($list as $t) {
                 list($edata, $tpl) = $this->_extend($t['id'], TRUE);
                 if (!$edata) {
                     continue;
                 }
                 $file = str_replace($mod['url'], '', $edata['url']);
                 if (strpos($file, 'index.php?c=extend') !== FALSE) {
                     continue;
                 }
                 ob_start();
                 $this->template->display($tpl);
                 $dir = dirname($file);
                 $file = basename($file);
                 $html = ob_get_clean();
                 if (SITE_ID > 1) {
                     $dir = trim('html/' . SITE_ID . '/' . trim($dir, '.'), '/');
                 }
                 if ($dir != '.' && !file_exists(APPPATH . $dir)) {
                     dr_mkdirs(APPPATH . $dir, TRUE);
                 }
                 // 判断是否为目录形式
                 if (strpos($file, '.html') === FALSE && strpos($file, '.htm') === FALSE && strpos($file, '.shtml') === FALSE) {
                     dr_mkdirs(APPPATH . $dir . '/' . $file, TRUE);
                 }
                 // 如果是目录就生成一个index.html
                 if (is_dir(APPPATH . $dir . '/' . $file)) {
                     $dir .= '/' . $file;
                     $file = 'index.html';
                 }
                 if (!file_put_contents(APPPATH . $dir . '/' . $file, $html, LOCK_EX)) {
                     continue;
                 }
                 $filepath = array(APPPATH . $dir . '/' . $file);
                 // 保存文件记录
                 $this->content_model->set_html(2, $data['uid'], $data['id'], $t['id'], $data['catid'], $filepath);
             }
         }
     }
     return TRUE;
 }
 /**
  * 更新URL
  */
 public function url()
 {
     $cfile = SITE_ID . APP_DIR . $this->uid . $this->input->ip_address() . '_content_url';
     if (IS_POST) {
         $catid = $this->input->post('catid');
         $query = $this->link;
         if (count($catid) > 1 || $catid[0]) {
             $query->where_in('catid', $catid);
             if (count($this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category')) == count($catid)) {
                 $catid = 0;
             }
         } else {
             $catid = 0;
         }
         // 统计数量
         $total = $query->count_all_results($this->content_model->prefix . '_index');
         $this->cache->file->save($cfile, array('catid' => $catid, 'total' => $total), 10000);
         if ($total) {
             $this->system_log('站点【#' . SITE_ID . '】模块【' . APP_DIR . '】更新URL地址#' . $total);
             // 记录日志
             $this->mini_msg(dr_lang('132', $total), dr_url(APP_DIR . '/home/url', array('todo' => 1)), 2);
         } else {
             $this->mini_msg(lang('133'));
         }
     }
     // 处理url
     if ($this->input->get('todo')) {
         $page = max(1, (int) $this->input->get('page'));
         $psize = 100;
         // 每页处理的数量
         $cache = $this->cache->file->get($cfile);
         if ($cache) {
             $total = $cache['total'];
             $catid = $cache['catid'];
         } else {
             $catid = 0;
             $total = $this->link->count_all_results($this->content_model->prefix);
         }
         $tpage = ceil($total / $psize);
         // 总页数
         if ($page > $tpage) {
             // 更新完成删除缓存
             $this->cache->file->delete($cfile);
             $this->mini_msg(lang('360'), NULL, 1);
         }
         $module = $this->get_cache('module-' . SITE_ID . '-' . APP_DIR);
         $table = $this->content_model->prefix;
         if ($catid) {
             $this->link->where_in('catid', $catid);
         }
         $data = $this->link->limit($psize, $psize * ($page - 1))->order_by('id DESC')->get($table)->result_array();
         foreach ($data as $t) {
             $url = dr_show_url($module, $t);
             $this->link->update($table, array('url' => $url), 'id=' . $t['id']);
             if ($module['extend']) {
                 $extend = $this->link->where('cid', (int) $t['id'])->order_by('id DESC')->get($table . '_extend')->result_array();
                 if ($extend) {
                     foreach ($extend as $e) {
                         $this->link->where('id=', (int) $e['id'])->update($table . '_extend', array('url' => dr_extend_url($module, $e)));
                     }
                 }
             }
         }
         $this->mini_msg(dr_lang('135', "{$tpage}/{$page}"), dr_url(APP_DIR . '/home/url', array('todo' => 1, 'page' => $page + 1)), 2, 0);
     } else {
         $this->template->assign(array('menu' => $this->get_menu($this->_get_content_menu()), 'select' => $this->select_category($this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category'), 0, 'id="dr_synid" name=\'catid[]\' multiple style="width:200px;height:250px;"', '')));
         $this->template->display('content_url.html');
     }
 }
예제 #4
0
 public function edit($_data, $data)
 {
     // 参数判断
     if (!$data || !$_data) {
         return FALSE;
     }
     // 修改之前挂钩点
     $data['edit'] = $_data;
     $this->hooks->call_hook('content_edit_before', $data);
     unset($data['edit']);
     // 被退回处理
     if (isset($data[1]['back']) && $this->admin) {
         $backinfo = array('uid' => $this->uid, 'author' => $this->admin['username'], 'rolename' => $this->admin['role']['name'], 'optiontime' => SYS_TIME, 'backcontent' => $data[1]['back']);
         unset($data[1]['back']);
     }
     // 格式化字段值
     $data = $this->get_content_data($data, $_data);
     // 分析栏目字段数据
     $data = $this->replace_category_data($_data['id'], $data);
     // 生成url地址
     $data[1]['url'] = dr_show_url($this->ci->get_cache('MODULE-' . SITE_ID . '-' . $this->mdir), array_merge($_data, $data[1]));
     // 更新索引表
     $this->link->where('id', $_data['id'])->update($this->prefix . '_index', array('uid' => $data[1]['uid'], 'catid' => $data[1]['catid'], 'status' => $data[1]['status']));
     // 提交为审核通过状态
     $data[1]['id'] = $data[0]['id'] = $_data['id'];
     $data[0]['uid'] = $data[1]['uid'];
     $data[0]['catid'] = $data[1]['catid'];
     // 副表以5w左右数据量无限分表
     $data[1]['tableid'] = $_data['tableid'] ? $_data['tableid'] : floor($_data['id'] / 50000);
     if (!$this->link->query("SHOW TABLES LIKE '" . $this->prefix . '_data_' . $data[1]['tableid'] . "'")->row_array()) {
         // 附表不存在时创建附表
         $sql = $this->link->query("SHOW CREATE TABLE `{$this->prefix}_data_0`")->row_array();
         $this->link->query(str_replace(array($sql['Table'], 'CREATE TABLE '), array($this->prefix . '_data_' . $data[1]['tableid'], 'CREATE TABLE IF NOT EXISTS '), $sql['Create Table']));
     }
     // 主表更新
     if ($this->link->where('id', $_data['id'])->count_all_results($this->prefix)) {
         $this->link->where('id', $_data['id'])->update($this->prefix, $data[1]);
     } else {
         $this->link->replace($this->prefix, $data[1]);
     }
     // 副表
     $this->link->replace($this->prefix . '_data_' . $data[1]['tableid'], $data[0]);
     // 审核表
     // 更新tag表
     if (isset($data[1]['keywords']) && $data[1]['keywords']) {
         $this->update_tag($data[1]['keywords']);
     }
     //$this->sns_share($data[1]); // 分享信息
     $this->ci->clear_cache('hits' . $this->mdir . SITE_ID . $_data['id']);
     $this->ci->clear_cache((SITE_MOBILE === TRUE ? 'm' : '') . 'show' . $this->mdir . SITE_ID . $_data['id']);
     // 修改之后挂钩点
     $data['edit'] = $_data;
     $this->hooks->call_hook('content_edit_after', $data);
     // 修改之后执行的方法
     $this->_edit_content($data);
     return $_data['id'];
 }
예제 #5
0
 /**
  * 更新URL
  */
 public function url()
 {
     $cfile = SITE_ID . APP_DIR . $this->uid . $this->input->ip_address() . '_content_url';
     if (IS_POST) {
         $catid = $this->input->post('catid');
         $query = $this->link;
         if (count($catid) > 1 || $catid[0]) {
             $query->where_in('catid', $catid);
         }
         $data = $query->select('id')->get($this->content_model->prefix . '_index')->result_array();
         if ($data) {
             $id = array();
             foreach ($data as $t) {
                 $id[] = $t['id'];
             }
             $this->cache->file->save($cfile, $id, 7200);
             // 缓存搜索结果->id
             $this->mini_msg(dr_lang('132', count($id)), dr_url(APP_DIR . '/home/url', array('todo' => 1)), 2);
         } else {
             $this->mini_msg(lang('133'));
         }
     }
     if ($this->input->get('todo')) {
         $id = $this->cache->file->get($cfile);
         // 取缓存搜索结果->id
         if (!$id) {
             $this->mini_msg(lang('134'));
         }
         $page = max(1, (int) $this->input->get('page'));
         $psize = 50;
         $total = count($id);
         $tpage = ceil($total / $psize);
         // 总页数
         if ($page > $tpage) {
             // 更新完成删除缓存
             $this->cache->file->delete($cfile);
             $this->mini_msg(lang('360'), NULL, 1);
         }
         $module = $this->get_cache('module-' . SITE_ID . '-' . APP_DIR);
         $table = $this->content_model->prefix;
         $data = $this->link->where_in('id', $id)->limit($psize, $psize * ($page - 1))->order_by('id DESC')->get($table)->result_array();
         foreach ($data as $t) {
             $url = dr_show_url($module, $t);
             $this->link->update($table, array('url' => $url), 'id=' . $t['id']);
             if ($module['extend']) {
                 $extend = $this->link->where('cid', $t['id'])->order_by('id DESC')->get($table . '_extend')->result_array();
                 if ($extend) {
                     foreach ($extend as $e) {
                         $url = dr_extend_url($module, $e);
                         $this->link->update($table . '_extend', array('url' => $url), 'id=' . (int) $e['id']);
                     }
                 }
             }
         }
         $this->mini_msg(dr_lang('135', "{$tpage}/{$page}"), dr_url(APP_DIR . '/home/url', array('todo' => 1, 'page' => $page + 1)), 2, 0);
     } else {
         $this->template->assign(array('menu' => $this->get_menu(array(lang('136') => APP_DIR . '/admin/home/url', lang('001') => 'admin/module/cache')), 'select' => $this->select_category($this->get_cache('module-' . SITE_ID . '-' . APP_DIR, 'category'), 0, 'id="dr_synid" name=\'catid[]\' multiple style="width:200px;height:250px;"', '')));
         $this->template->display('content_url.html');
     }
 }
예제 #6
0
 public function edit($_data, $data)
 {
     // 参数判断
     if (!$data || !$_data) {
         return FALSE;
     }
     // 被退回处理
     if (isset($data[1]['back']) && $this->admin) {
         $backinfo = array('uid' => $this->uid, 'author' => $this->admin['username'], 'rolename' => $this->admin['role']['name'], 'optiontime' => SYS_TIME, 'backcontent' => $data[1]['back']);
         unset($data[1]['back']);
     }
     // 格式化字段值
     $data = $this->get_content_data($data, $_data);
     // 分析栏目字段数据
     if ($this->is_category) {
         $data = $this->replace_category_data($_data['id'], $data);
     }
     // 生成url地址
     $data[1]['url'] = dr_show_url($this->ci->get_cache('MODULE-' . SITE_ID . '-' . APP_DIR), array_merge($_data, $data[1]));
     // 更新索引表
     $this->link->where('id', $_data['id'])->update($this->prefix . '_index', array('uid' => $data[1]['uid'], 'catid' => $data[1]['catid'], 'status' => $data[1]['status']));
     if ($data[1]['status'] == 9) {
         // 提交为审核通过状态
         $data[1]['id'] = $data[0]['id'] = $_data['id'];
         $data[0]['uid'] = $data[1]['uid'];
         $data[0]['catid'] = $data[1]['catid'];
         // 副表以5w左右数据量无限分表
         $data[1]['tableid'] = $_data['tableid'] ? $_data['tableid'] : floor($_data['id'] / 50000);
         if (!$this->link->query("SHOW TABLES LIKE '" . $this->prefix . '_data_' . $data[1]['tableid'] . "'")->row_array()) {
             // 附表不存在时创建附表
             $sql = $this->link->query("SHOW CREATE TABLE `{$this->prefix}_data_0`")->row_array();
             $this->link->query(str_replace(array($sql['Table'], 'CREATE TABLE '), array($this->prefix . '_data_' . $data[1]['tableid'], 'CREATE TABLE IF NOT EXISTS '), $sql['Create Table']));
         }
         // 主表更新
         if ($this->link->where('id', $_data['id'])->count_all_results($this->prefix)) {
             $this->link->where('id', $_data['id'])->update($this->prefix, $data[1]);
         } else {
             $this->link->replace($this->prefix, $data[1]);
         }
         $this->link->replace($this->prefix . '_data_' . $data[1]['tableid'], $data[0]);
         $this->link->where('id', $_data['id'])->delete($this->prefix . '_verify');
         // 更新tag表
         if (isset($data[1]['keywords']) && $data[1]['keywords']) {
             $this->update_tag($data[1]['keywords']);
         }
         //$this->sns_share($data[1]); // 分享信息
     } else {
         // 检查合并审核数据
         $content = $data[0] ? array_merge($data[0], $data[1]) : $data[1];
         if (!$content) {
             return FALSE;
         }
         // 更新主表
         $this->link->where('id', $_data['id'])->update($this->prefix, array('status' => $data[1]['status']));
         // 更新审核表
         $this->link->replace($this->prefix . '_verify', array('id' => $_data['id'], 'uid' => $data[1]['uid'], 'catid' => $data[1]['catid'], 'author' => $data[1]['author'], 'status' => $data[1]['status'], 'content' => dr_array2string($content), 'backuid' => (int) $this->uid, 'backinfo' => $this->admin ? dr_array2string($backinfo) : '', 'inputtime' => SYS_TIME));
     }
     $this->ci->clear_cache('hits' . APP_DIR . SITE_ID . $_data['id']);
     $this->ci->clear_cache((SITE_MOBILE === TRUE ? 'm' : '') . 'show' . APP_DIR . SITE_ID . $_data['id']);
     return $_data['id'];
 }