"; /* Original code for 1 category news module by Daniel Story http://wannabegames.com -- Moded for multiple categories by Absolute Zero http://www.the-absolute-zero.com */ $category = $_GET['category']; function nw_echoarticles() { $template = f_returnfile( "templates/news_layout.tpl"); $page = ""; if($category == bored) { connectassign (bored); $comtable = "bcom"; $name = "Wow I/'m Bored"; } elseif ($category = "general") { connectassign (general); $comtable = "gcom"; $name = "General Topics"; } elseif ($category = "life") { connectassign (life); $comtable = "lcom"; $name = "My Life"; } elseif ($category = "nerd") { connectassign (nerd); $comtable = "ncom"; $name = "Nerd"; } elseif ($category = "site_news") { connectassign (site_news); $comtable = "sitecom"; $name = "Absolute Zero News"; } elseif ($category = "stupid") { connectassign (stupid); $comtable = "stupidcom"; $name = "Stupid Stuff"; } else { $current = array("Bored" => "bored", "General Topics" => "general", "My Life" => "life", "Nerd" => "nerd", "Site News" => "site_news", "Stupid" => "stupid"); foreach ($current AS $cat => $ontable) { $cat = $singnewscat; $allquery = "SELECT title, news, date, id FROM $ontable ORDER BY id DESC LIMIT 1"; $latest = mysql_query($allquery); echo $singnewscat; while( $row=mysql_fetch_array($latest)) { $news_title = $row['title']; $news_text = $row['news']; $news_date = $row['date']; $news_id = $row['id']; } } } } function connectassign ($dbname) { $curcat = mysql_query ("SELECT title, news, date, id FROM $dbname ORDER BY id DESC LIMIT 5"); while( $row=mysql_fetch_array( $curcat ) ) { $news_title = $row['title']; $news_text = $row['news']; $news_date = $row['date']; $news_id = $row['id']; } } function checkcomments () { while( $row=mysql_fetch_array( $new ) ) { $news_title = $row['title']; $news_text = $row['news']; $news_date = $row['date']; $news_id = $row['id']; $commments = nw_comment_amount( $news_id ); if ( $commments == 0 ) { $commments = "No Comments"; } else { $commments = "Comments: $commments"; } $page .= news_template( $template, $news_title, $news_date, $commments, $news_text ); } $page .= '
'; echo( $page ); } function nw_echoarticle( $newscat, $id ) { $query = "SELECT title, news, date FROM $newscat WHERE id=$id"; $result = mysql_query( $query ); $template = f_returnfile( "templates/news_layout.tpl" ); $page = ""; while( $row=mysql_fetch_array( $result ) ) { $news_title = $row['title']; $news_text = $row['news']; $news_date = $row['date']; $page .= news_template( $template, $news_title, $news_date, "Add Comment - Back", $news_text ); } $page .= '
'; echo( $page ); } function nw_echocomments( $newsid ) { $query = "SELECT name, comment, date FROM $comtable WHERE news_id=$newsid ORDER BY time DESC"; $result = mysql_query( $query ); $template = f_returnfile( "templates/comments_layout.tpl"); $page = ""; $page .= ""; while( $row=mysql_fetch_array( $result ) ) { $name = $row['name']; $comment = $row['comment']; $date = $row['date']; $comment = smile_replace( $comment ); $page .= news_template( $template, "", $date, $name, $comment ); } $page .= "
Comments:
"; echo( $page ); } function nw_comment_amount( $newsid ) { $query = "SELECT name FROM $comtable WHERE news_id=$newsid"; $result = mysql_query( $query ); return mysql_num_rows( $result ); } function nw_addcomment( $newsid, $name, $comment ) { $name = lf_removequotes( $name ); $comment = lf_removequotes( $comment ); $err_fields = 0; if( !$name ) { echo '
your name is REQUIRED
'; $err_fields = 1; } if( !$comment ) { echo '
a comment is REQUIRED
'; $err_fields = 1; } if( $err_fields == 1 ) { echo ( "
BACK
" ); die(); } if ( lf_hascurseword( $name ) == 1 ) { echo( "
\" $name \" has unsuitable word(s)." ); echo( "
BACK
" ); die(); } if ( lf_hascurseword( $comment ) == 1 ) { echo( "
\" $comment \" has unsuitable word(s)." ); echo( "
BACK
" ); die(); } $userip = l_returnip(); $new_id = $newsid; $date = date("dS M h:ia"); $time = time(); $query = "INSERT INTO $comtable (name, comment, date, time, user_ip, news_id) VALUES ('$name', '$comment', '$date', $time, '$userip', $new_id)"; $result = mysql_query( $query ); echo( "
Comment has been added.
Thank you for submiting a comment.
BACK
" ); } function nw_commentform( $newsid ) { echo( "
Your Name:
Comment:
" ); } function news_template( $template, $str_title, $str_date, $str_comments, $str_text, $newscat ) { $template = eregi_replace( "{category}", $name, $template ); $template = eregi_replace( "{news_title}", $str_title, $template ); $template = eregi_replace( "{news_date}", $str_date, $template ); $template = eregi_replace( "{news_comments}", $str_comments, $template ); $template = eregi_replace( "{news_text}", $str_text, $template ); return $template; }