<?
//
// FPCode v0.9.1, Date 2002-01-22
//
// Copyright (c) 2002 Wen-Yu Chang and FrostyPlace.com. All rights reserved.
//
// The contents of this file constitute Original Code as defined in and
// are subject to the GNU Library General Public License (the
// "License"). You may not use this file except in compliance with the
// License. Please obtain a copy of the License at
// http://www.gnu.org/licenses/gpl.html and read it before using this file.
//
// This Original Code and all software distributed under the License are
// distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
// EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
// INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
// License for the specific language governing rights and limitations
// under the License.
//
// * Change History *
//
// 2002-01-11 Initial Release
// 2002-01-22 Updated the query in print_summary.
//
//
require_once("./includes/config.inc.php"); // Load config params
require_once("{$fpconfig['root_path']}/includes/dbconnect.inc.php"); //All the db stuff
function main_switch(){
global $HTTP_GET_VARS;
global $HTTP_POST_VARS;
$error_code = 0;
if(isset($HTTP_GET_VARS["page"])){
$file_name = $HTTP_GET_VARS['page'];
// anti-hacker check: if the page name contains '.'or '/', invalidate the page name
if(!(strchr($file_name, "/") === false)) $file_name = "";
if(!(strchr($file_name, ".") === false)) $file_name = "";
if(strlen($file_name) > 0) {
$result = @include("pages/$file_name.inc.php");
if(!$result) $error_code = 1 ;
} else $error_code = 1;
switch ($error_code){
case 0:
print_template();
break;
default:
echo "<b>¨t²Î¿ù»~¡G§ä¤£¨ì«ü©w¤§¶±ÀɮסC</b>";
break;
}
} else if(isset($HTTP_GET_VARS["story_id"])){
if($HTTP_GET_VARS["story_id"] > 0){
print_story($HTTP_GET_VARS["story_id"]);
} else {
echo "<b>¨t²Î¿ù»~¡G§ä¤£¨ì«ü©w¤§ÀɮסC</b>";
}
} else if(isset($HTTP_GET_VARS["action"])){
if($HTTP_GET_VARS["action"] == "submit_new"){
process_new_story($HTTP_POST_VARS);
}else if($HTTP_GET_VARS["action"] == "search"){
do_search($HTTP_GET_VARS["search_str"], $HTTP_GET_VARS["search_start"]);
} else {
echo "<b>¨t²Î¿ù»~¡G¿ù»~ªº«ü¥O¡A½Ð¦^º¶¦A¸Õ¡C</b>";
}
} else {
if(isset($HTTP_GET_VARS["display"]) && $HTTP_GET_VARS["display"] > 0){
print_summary($HTTP_GET_VARS["display"]);
} else {
print_summary(0);
}
}
}
function do_search($query_str, $start){
global $fpconfig;
if(strlen($query_str) < 2){
echo "<b>·j´MÃöÁä¦r¤Óµu¡A½Ð¸ÕµÛ¨Ï¥Î¸ûªøªº¥y¤l¨Ó§@·j´M¡C</b>";
return;
}
if(!get_magic_quotes_gpc()){
$the_query = addslashes($query_str);
} else {
$the_query = $query_str;
}
if($start <= 0){
$limit_str = "LIMIT 0, 30";
} else {
$limit_str = "LIMIT $start, 30";
}
$my_query = "SELECT story_id, story_title, LEFT(story_text, 100) as text, unix_timestamp(post_time) as post_time, author_name ".
"FROM stories s, authors a ".
"WHERE s.author_id = a.author_id AND active = 1 " .
"AND CONCAT(story_title, story_text, story_more) like '%$the_query%' " .
"ORDER BY post_time desc " . $limit_str;
$result = mysql_query($my_query);
$total_rows = mysql_num_rows($result);
echo "<b>·j´MÃöÁä¦r¡u" . $query_str . "¡vµ²ªG¡G§ä¨ì $total_rows ¶µ°O¿ý</b><br><br>";
while ($row = mysql_fetch_array($result)){
$post_date = date ("Y/m/j g:i a", $row['post_time'] + ($fpconfig["time_diff"] * 3600));
$post_date_str = "<span class=\"date_str\">$post_date</span>";
$author = "<span class=\"author_str\">" . htmlspecialchars($row['author_name']) . "</span>";
echo "<table border=\"0\" cellspacing=\"5\" cellpadding=\"0\" width=\"95%\" align=\"center\">".
"<tr><td colspan=\"2\" class=\"search_result\"><a href=\"{$fpconfig['htdoc_root']}/index.php?story_id={$row['story_id']}\">{$row['story_title']}</a><br>$post_date_str $author</td></tr>\n" .
"<tr><td width=\"1\" class=\"dashline\"></td><td class=\"search_field\">" . strip_tags($row['text']). "...\n</td></tr>" .
"</table>\n";
}
if($result) mysql_free_result($result);
}
function process_new_story($HTTP_POST_VARS){
global $fpconfig;
if(isset($HTTP_POST_VARS["post_check"])){
if(!get_magic_quotes_gpc()){
$story_title = addslashes($HTTP_POST_VARS["story_title"]);
$story_text = addslashes($HTTP_POST_VARS["story_text"]);
$story_comment = addslashes($HTTP_POST_VARS["story_comment"]);
$author_email = addslashes($HTTP_POST_VARS["author_email"]);
$author_name = addslashes($HTTP_POST_VARS["author_name"]);
$pic_link = addslashes($HTTP_POST_VARS["pic_url"]);
$site_link = addslashes($HTTP_POST_VARS["site_url"]);
} else {
$story_title = $HTTP_POST_VARS["story_title"];
$story_text = $HTTP_POST_VARS["story_text"];
$story_comment = $HTTP_POST_VARS["story_comment"];
$author_email = $HTTP_POST_VARS["author_email"];
$author_name = $HTTP_POST_VARS["author_name"];
$pic_link = $HTTP_POST_VARS["pic_url"];
$site_link = $HTTP_POST_VARS["site_url"];
}
if($HTTP_POST_VARS["anon"] == 1) $anon = 1;
else $anon = 0;
$my_query = "INSERT INTO reader_submits ".
"(story_id, story_title, story_text, story_comment, post_time, author_email, author_name, anonymous, pic_link, site_link) ".
"VALUES( NULL, '$story_title', '$story_text', '$story_comment', now(), '$author_email', '$author_name', ".
"$anon, '$pic_link', '$site_link' )";
$result = mysql_query($my_query);
$new_item_id = mysql_insert_id();
if($result == false){
echo "<b>¨t²Î¿ù»~¡G¸ê®ÆµLªk¥¿½T¿é¤J¸ê®Æ®w¡A½ÐÀˬd¸ê®ÆÄ椺¸ê®Æ«á¦A¸Õ¡C</b>";
return;
}
if($fpconfig["sendmail_support"]){ // Send out email notification if sendmail support is turned on.
// Prepare and send the notification
$to = $fpconfig["admin_email"];
$subject = "FP: News Submission";
$timestamp = date("F j, Y, g:i a");
$message = "
<html>
<head>
<title>News Submission</title>
</head>
<body>
<p>¿Ë·Rªº¥D½s¡G</p>
<p>ŪªÌ <b>$author_name</b> (email: $author_email) °e¥X¤F¤@¥÷¦W¬°¡u<b>$story_title</b>¡vªº·s»D½Z¥ó¡A½Ð«ö¤U±ªº³sµ²¥h¼f®Ö¸Ó¶µ·s»D¡G</p>
<p><a href=\"http://{$fpconfig['server_address']}{$fpconfig['htdoc_root']}/site_manager/edit_reader_submits.php?id=$new_item_id\">".
"http://{$fpconfig['server_address']}{$fpconfig['htdoc_root']}/site_manager/edit_reader_submits.php?id=$new_item_id</a></p>
<p>ºô¯¸¦Û°ÊºÞ²z¨t²Î©ó $timestamp ±H¥X</p>
</body>
</html>";
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=big5\r\n";
/* additional headers */
$headers .= "From: FPBot <{$fpconfig[admin_email]}>\r\n";
if(strlen($fpconfig["cc_email"]) > 0) $headers .= "Cc: {$fpconfig['cc_email']}\r\n";
if(strlen($fpconfig["bcc_email"]) > 0) $headers .= "Bcc: {$fpconfig['bcc_email']}\r\n";
/* and now mail it */
mail($to, $subject, $message, $headers);
}
?>
<p align="left">·PÁ±z´£¨Ñªº¸ê®Æ¡A¨t²Î¥D¾÷¤w¸g³qª¾½s¿è¾¨§Ö«e¨Ó³B²z³oµ§¤å¥ó¡A¨Ã·|¦b¼f®Ö³q¹L«á©ó³Ìµu®É¶¡¤º¥Zµn¤W½u¡C</p>
<p align="center">½Ð«ö¤U¡i<a href="<? echo $fpconfig["htdoc_root"]; ?>/index.php">³oÓ³sµ²</a>¡j¦^¨ìº¶¡C</p>
<? return;
} else {
echo "<b>¨t²Î¿ù»~¡G¦¹³sµ²¤£¯àª½±µ¨Ï¥Î¡A½Ð§Q¥Î´£¨Ñ·s»Dºô¶¤º¤§Äæ¦ì¶Ç°e¸ê®Æ¡C</b>";
}
}
function print_story($story_id){
global $fpconfig;
$error_code = 0;
if($story_id > 0){
$my_query = "SELECT s.story_title, s.story_text, unix_timestamp(s.post_time) as post_time, ".
"s.story_more, s.story_link, s.pic_link, s.updated, ".
"s.ubb_link, a.author_name, a.author_email ".
"FROM stories s, authors a ".
"WHERE s.author_id = a.author_id AND story_id = $story_id AND s.active = 1";
$result = mysql_query($my_query);
if(mysql_num_rows($result) == 1){
$row = mysql_fetch_array($result);
$title_str = "<span class=\"title_item\">" . htmlspecialchars($row['story_title']) . "</span>";
$author = "<span class=\"author_str\">" . htmlspecialchars($row['author_name']) .
"</span>";
$post_date = date ("m/d g:i a", $row['post_time'] + ($fpconfig["time_diff"] * 3600));
$post_date_str = "<span class=\"date_str\">$post_date</span>";
$pic_str = "";
if (strlen($row['pic_link']) > 1){
$pic_str = "<img hspace=\"5\" vspace=\"5\" src=\"" .htmlspecialchars($row['pic_link']) . "\" align=\"right\">";
}
$footer = array();
$footer_str = "";
if (strlen($row['story_link']) > 1){
$footer[] = "<a href=\"" . htmlspecialchars($row['story_link']) ."\" target=\"_blank\">¬ÛÃö³sµ²</a>";
}
if (strlen($row['ubb_link']) > 1 && $fpconfig['ubb_support']){
$footer[] = "<a href=\"{$fpconfig['ubb_uri']}{$row['ubb_link']}\" target=\"_blank\">°Ñ¥[°Q½×</a>";
}
if(sizeof($footer) > 0){
$footer_right_links = "[". join(" | ", $footer) ."]";
} else $footer_right_links = " ";
// Output the story block
// (This is kind of messy, need to clean it up later.)
echo "<table border=\"0\" cellspacing=\"5\" cellpadding=\"0\" width=\"95%\" align=\"center\">".
"<tr><td colspan=\"2\">$title_str<br>$post_date_str $author</td></tr>\n" .
"<tr><td width=\"1\" class=\"dashline\"></td><td class=\"story_body_str\">$pic_str" . $row['story_text'] . "\n" .
$row['story_more'] . "</td></tr>" .
"<tr><td colspan=\"2\" align=\"right\" class=\"story_footer_str\">$footer_right_links</td></tr>" .
"</table>\n";
} else {
$error_code = 1;
}
} else {
$error_code = 1;
}
if($error_code > 0){
echo "<b>¨t²Î¿ù»~¡G§ä¤£¨ì«ü©w¤§¸ê®Æ</b>";
}
if($result) mysql_free_result($result);
}
function print_summary($range){
global $PHP_SELF, $fpconfig;
$limit_str = "";
$where_stmt = "";
$date_div = "";
$max = $fpconfig["summary_max"];
if($range <= 0) {
$limit_str = " LIMIT 0, $max";
$where_stmt = "";
} else {
$end_date = date("YmdHis", mktime (0,0,0,date("m"), (date("d") - $range), date("Y")));
$limit_str = "";
$where_stmt = "AND post_time >= $end_date ";
}
$my_query = "SELECT s.story_id, s.story_title, s.story_text, unix_timestamp(s.post_time) as post_time, ".
"s.post_time as day, s.story_more, s.story_link, s.pic_link, ".
"s.ubb_link, s.is_key_item, a.author_name, a.author_email, s.updated ".
"FROM stories s, authors a ".
"WHERE s.author_id = a.author_id and s.active = 1 AND is_report = 0 " . $where_stmt .
"order by day desc " . $limit_str;
$result = mysql_query($my_query);
$total_rows = mysql_num_rows($result);
while ($row = mysql_fetch_array($result)){
if($row['updated'] != 0) $updated_str = "¡@<span class=\"updated_str\">¤º®e§ó·s!</span>";
else $updated_str = "";
$title_str = htmlspecialchars($row['story_title']);
if($row['is_key_item'] == 1) {
$title_str = "<span class=\"key_item\">$title_str</span>";
} else {
$title_str = "<span class=\"title_item\">$title_str</span>";
}
$author = "<span class=\"author_str\">" . htmlspecialchars($row['author_name']) . "</span>";
$post_date = date ("m/d g:i a", $row['post_time'] + ($fpconfig["time_diff"] * 3600));
$post_date_str = "<span class=\"date_str\">$post_date</span>";
$pic_str = "";
if (strlen($row['pic_link'])){
$pic_str = "<img hspace=\"5\" vspace=\"5\" src=\"" .htmlspecialchars($row['pic_link']) . "\" align=\"right\">";
}
$footer = array();
$footer_str = "";
if (strlen($row['story_link'])){
$footer[] = "<a href=\"" . htmlspecialchars($row['story_link']) ."\" target=\"_blank\">¬ÛÃö³sµ²</a>";
}
if (strlen($row['ubb_link']) && $fpconfig['ubb_support']){
$footer[] = "<a href=\"{$fpconfig['ubb_uri']}{$row['ubb_link']}\" target=\"_blank\">°Ñ¥[°Q½×</a>";
}
if (strlen($row['story_more'])){
$more_link = "<br><br><a href=\"$PHP_SELF?story_id={$row['story_id']}\">¾\Ū¥þ¤å</a>";
} else $more_link = "¡@";
if(sizeof($footer) > 0){
$footer_right_links = "[". join(" | ", $footer) ."]";
} else $footer_right_links = " ";
// Output indivisual story sections
// (This is kind of messy, need to clean it up later.)
// if($date_div != ($my_date_str = date ("M d, Y", $row['post_time'] + ($fpconfig["time_diff"] * 3600)))){
// echo "<div align=\"right\"><blockquote>$my_date_str</blockquote></div>";
// $date_div = $my_date_str;
// }
echo "<!-- id: {$row['story_id']} -->".
"<table border=\"0\" cellspacing=\"5\" cellpadding=\"0\" width=\"95%\" align=\"center\">".
"<tr><td colspan=\"2\">$title_str $updated_str<br>$post_date_str $author</td></tr>\n" .
"<tr><td width=\"1\" class=\"dashline\"></td><td class=\"story_body_str\">$pic_str" . $row['story_text'] ." $more_link</td></tr>" .
"<tr><td colspan=\"2\" align=\"right\" class=\"story_footer_str\">$footer_right_links</td></tr>" .
"</table>\n";
}
if($result) mysql_free_result($result);
// Print date selection menu
?>
<form action="<? echo $PHP_SELF; ?>" method="get">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr align="center">
<td class="date_range_txt"><div align="center">Åã¥Ü <select name="display" onchange="location.href='?'+this.form.display.name+'='+this.form.display.options[this.form.display.selectedIndex].value" class="date_range_menu">
<option value="7" selected>¹L¥h¤C¤Ñ</option>
<option value="14">¹L¥h¨â¶g</option>
<option value="30">¹L¥h¤@Ó¤ë</option>
<option value="60">¹L¥h¨âÓ¤ë</option>
</select> ªº·s»D¤º®e</div></td>
</tr>
</table>
</form><br>
<?
}
function print_last_updated(){
global $fpconfig;
$my_query = "SELECT unix_timestamp(max(post_time)) as post_time FROM stories ";
$result = mysql_query($my_query);
if ($row = mysql_fetch_array($result)){
$my_date = date ("M j, Y, g:i a", $row['post_time'] + ($fpconfig["time_diff"] * 3600));
echo "<div class=\"date_str\" align=\"center\">¥»¯¸³Ìªñ§ó·s®É¶¡<br>$my_date </div>";
}
if($result) mysql_free_result($result);
}
function print_sw_links(){
global $fpconfig;
$bullet_pt = "•";
$row_hdr = "<tr><td align=\"left\">$bullet_pt</td>";
$row_ftr = "</tr>";
$max = $fpconfig["sofware_links_max"];
$my_query = "SELECT s.swl_title, s.swl_version, t.type_code, s.swl_url ".
"FROM software_links s, software_types t ".
"WHERE s.type_id = t.type_id and active = 1 ".
"ORDER BY t.type_id ASC, s.post_date DESC LIMIT 0, $max";
$result = mysql_query($my_query);
if(mysql_num_rows($result) > 0) {
$tbl_header = "<table width=\"100%\" border=\"0\" class=\"swl_tbl\">";
$tbl_header .="<tr><td colspan=\"2\" class=\"swl_tbl_hdr\">{$fpconfig[swl_title]}</td></tr>\n";
$tbl_footer="</table>\n";
}
echo $tbl_header;
while ($row = mysql_fetch_array($result)){
echo "$row_hdr<td><a href=\"" . htmlspecialchars($row['swl_url']) . "\">" . htmlspecialchars("{$row['swl_title']} {$row['swl_version']}") .
"</a> {$row['type_code']}</td>$row_ftr\n";
}
echo $tbl_footer;
if($result) mysql_free_result($result);
}
function print_quickies(){
global $fpconfig;
$bullet_pt = "•";
$row_hdr = "<tr valign=\"top\"><td align=\"left\">$bullet_pt</td>";
$row_ftr = "</tr>";
$max = $fpconfig["quickies_max"];
$my_query = "SELECT q_title, q_link ".
"FROM quickies ".
"WHERE active = 1 " .
"ORDER BY post_date DESC LIMIT 0, $max";
$result = mysql_query($my_query);
if(mysql_num_rows($result) > 0) {
$tbl_header = "<table width=\"100%\" border=\"0\" class=\"quickies\">";
$tbl_header .="<tr><td colspan=\"2\" class=\"quickies_hdr\">{$fpconfig[quickies_title]}</td></tr>\n";
$tbl_footer="</table>\n";
}
echo $tbl_header;
while ($row = mysql_fetch_array($result)){
echo "$row_hdr<td><a href=\"".htmlspecialchars($row['q_link']) .
"\" target=\"_blank\">" .htmlspecialchars($row['q_title']). "</a></td>$row_ftr\n";
}
echo $tbl_footer;
if($result) mysql_free_result($result);
}
function print_reports(){
global $PHP_SELF;
global $fpconfig;
$bullet_pt = "•";
$row_hdr = "<tr><td align=\"left\">$bullet_pt</td>";
$row_ftr = "</tr>";
$max = $fpconfig["reports_max"];
$my_query = "SELECT story_id, story_title ".
"FROM stories ".
"WHERE active = 1 AND is_report = 1 " .
"ORDER BY post_time DESC LIMIT 0, $max";
$result = mysql_query($my_query);
if(mysql_num_rows($result) > 0) {
$tbl_header = "<table width=\"100%\" border=\"0\" class=\"reports\">";
$tbl_header .="<tr><td colspan=\"2\" class=\"reports_hdr\">{$fpconfig[reports_title]}</td></tr>\n";
$tbl_footer="</table>\n";
}
echo $tbl_header;
while ($row = mysql_fetch_array($result)){
echo "$row_hdr<td><a href=\"$PHP_SELF?story_id={$row['story_id']}\">" .
htmlspecialchars($row['story_title']). "</a></td>$row_ftr\n";
}
echo $tbl_footer;
if($result) mysql_free_result($result);
}
function print_sites(){
global $fpconfig;
$bullet_pt = "•";
$row_hdr = "<tr><td align=\"left\">$bullet_pt</td>";
$row_ftr = "</tr>";
$max = $fpconfig["sites_max"];
$my_query = "SELECT site_title, site_url, type_code ".
"FROM site_links s, site_types t ".
"WHERE s.type_id = t.type_id AND active = 1 " .
"ORDER BY s.type_id ASC, site_order DESC LIMIT 0, $max";
$result = mysql_query($my_query);
if(mysql_num_rows($result) > 0) {
$tbl_header = "<table width=\"100%\" border=\"0\" class=\"site_link\">";
$tbl_header .="<tr><td colspan=\"2\" class=\"site_link_hdr\">{$fpconfig[sites_title]}</td></tr>\n";
$tbl_footer="</table>\n";
}
echo $tbl_header;
while ($row = mysql_fetch_array($result)){
$lang_mark = $row['type_code'];
echo "$row_hdr<td><a href=\"" . htmlspecialchars($row['site_url']) . "\" target=\"_blank\">" . htmlspecialchars($row['site_title']) .
"</a> $lang_mark</td>$row_ftr\n";
}
echo $tbl_footer;
if($result) mysql_free_result($result);
}
function print_top_banner(){
global $PHP_SELF, $fpconfig;
?>
<div class="top_banner" align="center"><a href="<? echo $PHP_SELF; ?>"><span class="top_banner_link">º¶</span></a> |
<? if($fpconfig['ubb_support']){ ?> <a href="<? echo $fpconfig['ubb_home']; ?>" target="ubb"><span class="top_banner_link">¥æ¬y°Ï</span></a> | <? } ?>
<a href="<? echo $PHP_SELF; ?>?page=post_news"><span class="top_banner_link">´£¨Ñ·s»D</span></a> |
<a href="<? echo $PHP_SELF; ?>?page=opensource"><span class="top_banner_link">¶}©ñì©l½X</span></a> |
<a href="<? echo $PHP_SELF; ?>?page=about"><span class="top_banner_link">Ãö©ó¥»¯¸</span></a> |
<a href="<? echo $PHP_SELF; ?>?page=contacts"><span class="top_banner_link">Ápµ¸§ÚÌ</span></a></div>
<?
}
function print_search_box(){
global $PHP_SELF;
?>
<div align="center" class="search_hdr">
<form name="search" action="<? echo $PHP_SELF; ?>" method="get">
<input type="hidden" name="action" value="search">
·s»D¢A³ø¾É¥þ¤åÀ˯Á<br>
<input type="text" name="search_str" size="24" value="<? echo $search_str; ?>" class="search_field"><br>
<input type="submit" value="·j´M">
</form>
</div>
<?
}
function print_footer(){
global $PHP_SELF, $fpconfig;
?>
<br><div class="footer_txt" align="center"><a href="<? echo $PHP_SELF; ?>" class="footer_txt">º¶</a> |
<? if($fpconfig['ubb_support']){ ?> <a href="<? echo $fpconfig['ubb_home']; ?>" class="footer_txt" target="ubb">¥æ¬y°Ï</a> | <? } ?>
<a href="<? echo $PHP_SELF; ?>?page=post_news" class="footer_txt">´£¨Ñ·s»D</a> |
<a href="<? echo $PHP_SELF; ?>?page=opensource" class="footer_txt">¶}©ñì©l½X</a> |
<a href="<? echo $PHP_SELF; ?>?page=about" class="footer_txt">Ãö©ó¥»¯¸</a> |
<a href="<? echo $PHP_SELF; ?>?page=contacts" class="footer_txt">Ápµ¸§ÚÌ</a></div>
<div align="center"><img src="./images/MadeOn_blue.gif" width="88" height="31" hspace="5" vspace="10" border="0" align="middle">
<a href="http://www.frostyplace.com/index.php?page=opensource"><img src="./images/FPCodeBadge.gif" width="88" height="31" hspace="5" border="0" align="middle"></div>
<div class="footer_txt" align="center">Copyright © 2002 FrostyPlace.com</div>
<?
}
?>