<?php session_start(); include_once '../../frame.php'; if ($_SERVER["REMOTE_ADDR"] != '127.0.0.1') { judge_role(); } $db = get_db(); $news = $db->query("select t2.id,t2.created_at,t2.content,t1.id as pid from fb_publish_schedule t1 join fb_news t2 on t1.resource_id=t2.id where t1.status=0 and t1.publish_date<=now() order by t1.publish_date asc"); $count = $db->record_count; $pid = array(); $nid = array(); $error_id = array(); for ($i = 0; $i < $count; $i++) { $db->execute("update fb_news set created_at = '" . now() . "' where id={$news[$i]->id}"); $news[$i]->created_at = now(); $result = static_news($news[$i], 'page'); if ($result) { array_push($pid, $news[$i]->pid); array_push($nid, $news[$i]->id); } else { array_push($error_id, $news[$i]->id); } } $pid = implode(',', $pid); $nid = implode(',', $nid); if ($pid) { $db->execute("delete from fb_publish_schedule where id in ({$pid})"); $db->execute("update fb_news set is_adopt=1 where id in ({$nid})"); } close_db();
<meta http-equiv=Content-Language content=zh-cn> </head> <?php $type = $_GET['type']; switch ($type) { case 'news': $id = intval($_GET['id']); $news = new table_class('fb_news'); if (empty($id)) { return false; } $news->find($id); if ($news->id <= 0) { return false; } if (static_news($news, 'page')) { echo '静态化新闻成功'; } else { echo '静态化新闻失败'; } break; case 'index': if (static_index()) { echo '静态化首页成功!'; } else { echo '静态化首页失败!'; } break; case 'top': if (static_top()) { echo '静态化顶部成功!';
function static_news($news, $symbol = 'fck_pageindex', $en = false) { if (!$news) { return false; } global $static_dir; global $static_url; $url = "{$static_url}/news/news.php?id={$news->id}&page_type=static"; if ($en) { $url .= "&lang=en"; } $content = file_get_contents($url); $date = date('Ym', strtotime($news->created_at)); $dir = "{$static_dir}/review/{$date}"; if (!is_dir($dir)) { mkdir($dir); } $news_id = str_pad($news->id, 7, '0', STR_PAD_LEFT); if ($en) { $news_id .= "_en"; } $file = $dir . "/{$news_id}.shtml"; if (!write_to_file($file, $content, 'w')) { return false; } $page_count = get_fck_page_count($news->content); if ($page_count > 1) { for ($i = 2; $i <= $page_count; $i++) { $url = "{$static_url}/news/news.php?id={$news->id}&{$symbol}={$i}&page_type=static"; if ($en) { $url .= "&lang=en"; } $content = file_get_contents($url); $file = "{$dir}/{$news_id}_{$i}.shtml"; if (!write_to_file($file, $content, 'w')) { return false; } } } //handle the english article if (!$en) { $db = get_db(); $db->query("select * from fb_news_relationship where chinese_news_id = {$news->id}"); if ($db->move_first()) { $news->find($news->id); return static_news($news, $symbol, true); } } return true; }
if (write_to_file($file, $content, 'w')) { echo "<a href='{$dir}/{$id}.html'>查看</a>"; return true; } else { return false; } } function static_index() { global $url_head; $content = file_get_contents("{$url_head}/index.php"); return write_to_file("./index.html", $content, 'w'); } switch ($type) { case 'news': if (static_news($id)) { echo '静态新闻成功!'; } else { echo '静态新闻失败!'; } break; case 'index': if (static_index()) { echo '静态首页成功!'; } else { echo '静态首页失败!'; } break; default: break; }
unlink(ROOT_DIR . $old_video_photo_src); } //if it has english new, should update the english news's category_id, news_type and so on. $db->query("select english_news_id from fb_news_relationship where chinese_news_id={$news->id}"); if ($db->move_first()) { $e_id = $db->field_by_index(0); $english_news = new table_class($tb_news); $english_news->find($e_id); $english_news->category_id = $news->category_id; $english_news->news_type = $news->news_type; $english_news->save(); } } //news saved if ($news->is_adopt) { static_news($news); } //handle the keywords $keywords = explode(' ', $news->keywords); if ($keywords) { foreach ($keywords as $val) { $db->execute("insert into fb_news_keywords (name) values('{$val}') on duplicate key update name='{$val}'"); } } if (isset($_POST['publish_schedule_date'])) { $schedule = new table_class('fb_publish_schedule'); if ($id) { $schedule->find_by_resource_id($id); } if ($_POST['publish_schedule_date']) { $schedule->publish_date = $_POST['publish_schedule_date'];
unlink(ROOT_DIR . $old_video_photo_src); } //if it has english new, should update the english news's category_id, news_type and so on. $db->query("select english_news_id from fb_news_relationship where chinese_news_id={$news->id}"); if ($db->move_first()) { $e_id = $db->field_by_index(0); $english_news = new table_class($tb_news); $english_news->find($e_id); $english_news->category_id = $news->category_id; $english_news->news_type = $news->news_type; $english_news->save(); } } //news saved if ($news->is_adopt) { static_news($news, 'page'); } //handle the keywords $keywords = explode(' ', $news->keywords); if ($keywords) { foreach ($keywords as $val) { $db->execute("insert into fb_news_keywords (name) values('{$val}') on duplicate key update name='{$val}'"); } } if (isset($_POST['publish_schedule_date'])) { $schedule = new table_class('fb_publish_schedule'); if ($id) { $schedule->find_by_resource_id($id); } if ($_POST['publish_schedule_date']) { $schedule->publish_date = $_POST['publish_schedule_date'];
<?php $id = intval($_GET['id']); $type = $_GET['type']; include '../../frame.php'; if (empty($id)) { die('alert("非法访问!");'); } $news = new table_class('fb_news'); $news->find($id); if ($type == 'publish') { $result = static_news($news, 'page'); if ($result) { $news->is_adopt = 1; $news->save(); echo 'location.reload()'; } else { echo 'alert("发布新闻失败")'; } } else { $date = date('Ym', strtotime($news->created_at)); $dir = "{$static_dir}/review/{$date}"; $news_id = str_pad($news->id, 7, '0', STR_PAD_LEFT); $file = $dir . "/{$news_id}.shtml"; @unlink($file); $news->is_adopt = 0; $news->save(); echo 'location.reload()'; }
<?php include '../../frame.php'; $type = $_GET['type']; switch ($type) { case 'news': $id = intval($_GET['id']); $news = new table_class('fb_news'); if (empty($id)) { return false; } $news->find($id); if ($news->id <= 0) { return false; } if (static_news($news)) { echo '静态化新闻成功'; } else { echo '静态化新闻失败'; } break; case 'index': if (static_index()) { echo '静态化首页成功!'; } else { echo '静态化首页失败!'; } break; case 'top': if (static_top()) { echo '静态化顶部成功!';
<?php $id = intval($_GET['id']); $type = $_GET['type']; include '../../frame.php'; if (empty($id)) { die('alert("非法访问!");'); } $news = new table_class('fb_news'); $news->find($id); if ($type == 'publish') { $result = static_news($news); if ($result) { $news->is_adopt = 1; $news->save(); echo 'location.reload()'; } else { echo 'alert("发布新闻失败")'; } } else { $date = date('Ym', strtotime($news->created_at)); $dir = "{$static_dir}/review/{$date}"; $file = $dir . "/{$news->id}.shtml"; @unlink($file); $news->is_adopt = 0; $news->save(); echo 'location.reload()'; }