\\1://\\2\\3", $text); $ret = eregi_replace( "(([a-z0-9_]|\\-|\\.)+@([^[:space:]]*)([[:alnum:]-]))", "\\1", $ret); return($ret); } } # borrowed from http://www.kbcenter.com/kb.php?u_action=view_kb&kb_id=4949&category_id=246 function smart_text ($content ,$text_length) { $strip_content=stripslashes($content); $all_content=strlen("$strip_content"); $standard_content=substr($strip_content ,$text_length); $compare=stristr($standard_content ," "); $minus_content=strlen("$compare"); $result_content=$all_content-$minus_content; $display_content=substr($strip_content ,0, $result_content); $striped_content=stripslashes($display_content); #return nl2br($striped_content); return $striped_content; } # prepwork for search limits if ($iLimit) {} else {$iLimit=5;} if ($back) {$totaldisp=$limitstart-$iLimit;} else {$totaldisp=$limitstart+$iLimit;} if ($miniquery) { $customquery=urldecode($miniquery); $miniquery=urlencode($customquery); } if ($limitstart) { if ($back) { $backstart=$limitstart-(2*($iLimit)); $customquery=$customquery. " LIMIT $backstart,$iLimit"; } else{$customquery=$customquery. " LIMIT $limitstart,$iLimit";} } else {$customquery=$customquery. " LIMIT $iLimit";} # Decide what kind of page to display switch ($view) { case "category": $title_query="SELECT news_cat_title,news_cat_id from news_category where news_cat_id=$cat"; $title_art_query="SELECT news_art_id,news_art_title,news_art_pubdate,date_format(news_art_pubdate,'%m/%d/%y'),news_art_bodytext,news_art_author,news_art_category,news_cat_title,fname,lname,news_art_author from news_article,news_category,member where news_art_category=news_cat_id and id=news_art_author and news_cat_id=$cat order by news_art_pubdate desc"; $news_query="SELECT news_art_id,news_art_title,news_art_pubdate,date_format(news_art_pubdate,'%a %b %D %Y'),news_art_bodytext,news_art_author,news_art_category,news_cat_title,fname,lname,news_art_author,bbcode_uid from news_article,news_category,member where news_art_category=news_cat_id and id=news_art_author and news_art_default=1 and news_cat_id=$cat"; break; case "author": $title_query="SELECT concat(fname,' ',lname),id from member where id=$author"; $news_query="SELECT news_art_id,news_art_title,news_art_pubdate,date_format(news_art_pubdate,'%a %b %D %Y'),news_art_bodytext,news_art_author,news_art_category,news_cat_title,fname,lname,news_art_author,bbcode_uid from news_article,news_category,member where news_art_category=news_cat_id and id=news_art_author and news_art_author=$author"; break; case "date": $title_query="SELECT date_format(news_art_pubdate,'%a %b %D %Y') from news_article where news_art_pubdate like \"$bydate\""; $news_query="SELECT news_art_id,news_art_title,news_art_pubdate,date_format(news_art_pubdate,'%a %b %D %Y'),news_art_bodytext,news_art_author,news_art_category,news_cat_title,fname,lname,news_art_author,bbcode_uid from news_article,news_category,member where news_art_category=news_cat_id and id=news_art_author and news_art_pubdate like \"$bydate\""; break; case "article": list($curr_cat)=mysql_fetch_row(mysql_query("SELECT news_art_category from news_article where news_art_id=$article",$mysql_link)); $title_query="SELECT news_cat_title,news_cat_id from news_category,news_article where news_cat_id=news_art_category and news_art_id=$article"; $title_art_query="SELECT news_art_id,news_art_title,news_art_pubdate,date_format(news_art_pubdate,'%m/%d/%y'),news_art_bodytext,news_art_author,news_art_category,news_cat_title,fname,lname,news_art_author from news_article,news_category,member where news_art_category=news_cat_id and id=news_art_author and news_cat_id=$curr_cat order by news_art_pubdate desc"; $news_query="SELECT news_art_id,news_art_title,news_art_pubdate,date_format(news_art_pubdate,'%a %b %D %Y'),news_art_bodytext,news_art_author,news_art_category,news_cat_title,fname,lname,news_art_author,bbcode_uid from news_article,news_category,member where news_art_category=news_cat_id and id=news_art_author and news_art_id=$article"; break; default: $title_query=""; $title_art_query="SELECT news_art_id,news_art_title,news_art_pubdate,date_format(news_art_lastmod,'%m/%d/%y'),news_art_bodytext,news_art_author,news_art_category,news_cat_title,fname,lname,news_art_author from news_article,news_category,member where news_art_category=news_cat_id and id=news_art_author order by news_art_pubdate desc ,news_art_lastmod desc"; $news_query="SELECT news_art_id,news_art_title,news_art_pubdate,date_format(news_art_pubdate,'%a %b %D %Y'),news_art_bodytext,news_art_author,news_art_category,news_cat_title,fname,lname,news_art_author,bbcode_uid from news_article,news_category,member where news_art_category=news_cat_id and id=news_art_author order by news_art_pubdate desc ,news_art_lastmod desc limit 5"; break; } # Whatever we came up with we load from the database if ($title_art_query) {} else {$title_art_query=$news_query;} $prelimitquery=$title_art_query; $tmpresult=mysql_query($prelimitquery,$mysql_link); $totalrows=mysql_num_rows($tmpresult); $title_art_query.=$customquery; $top_articles=mysql_query($title_art_query,$mysql_link); if ($totalrows > $numrows) { # We'll figure the overflow as the total results minus the total number displayed so far $tdif=$totalrows-$totaldisp; # if that over flow is bigger than our per page limit than we prompt for the next set of results if ($tdif>$iLimit) {$nextdisp="next $iLimit articles >";} # If there aren't more than our limit on the next page then we say so. else { $nextdisp="next $tdif article"; if ($tdif==1) {$nextdisp=$nextdisp." >";} else {$nextdisp=$nextdisp."s >";} } if ($tdif>0) {$nextlink="$nextdisp";} # There are no more ahead, only back from here else {$nextlink=" ";} if ($limitstart) { $prevdisp="< previous $iLimit articles"; $prevlink="$prevdisp"; } else {$prevlink="                   ";} if ($totaldisp==$iLimit) {$prevlink="                   ";} } # There are no more. No more ahead no more behind else {$nextlink=" ";$prevlink=" ";} $totaltotal=count($usedlist); if ($title_query!="") {list($head_title,$head_id)=mysql_fetch_row(mysql_query($title_query,$mysql_link));} else { $head_title="recent"; $head_id=""; } $head_title='All '.$head_title.' articles'; $articles_in_category=""; $num_cat_arts=mysql_num_rows($top_articles); while (list($curr_art_id,$curr_art_title,$curr_art_pubdate,$curr_art_pubdate_pretty,$curr_art_bodytext,$curr_art_author,$curr_art_category,$curr_cat_title,$curr_author_fname,$curr_author_lname,$curr_author)=mysql_fetch_row($top_articles)) { if ($bgcolor == "#ffffff") {$bgcolor="#ccccff";} else {$bgcolor = "#ffffff";} $curr_art_title=stripslashes($curr_art_title); $curr_cat_title=stripslashes($curr_cat_title); $articles_in_category.=""; } $articles_in_category.="
Article Category Date
$curr_art_title$curr_cat_title$curr_art_pubdate_pretty
"; $top_table=$articles_in_category; # Whatever we came up with we load from the database $articles=mysql_query($news_query,$mysql_link); #$top_table=substr($top_table, 0, (strlen($top_table)-13)); $contents=$top_table.$contents; $contents.="
$prevlink $totalrows articles total $nextlink
"; # Print our top Table it with the good people MainBodyTable ($head_title,$contents,$BlueHeader,$MainBodyBg); # Display the news articles we have selected while (list($curr_art_id,$curr_art_title,$curr_art_pubdate,$curr_art_pubdate_pretty,$curr_art_bodytext,$curr_art_author,$curr_art_category,$curr_cat_title,$curr_author_fname,$curr_author_lname,$curr_author,$bbcode_uid)=mysql_fetch_row($articles)) { # Reset the permissions $allowed_to_edit=0; $allowed_to_del=0; $allowed_to_post=0; # Reset the list of who has access to be empty arrays $allowed_to_edit_who=array(); $allowed_to_delete_who=array(); $allowed_to_post_who=array(); # If this post belongs to the currently logged in person give them full access: if ($userregistered==$curr_art_author) { $allowed_to_edit=1; $allowed_to_del=1; $allowed_to_post=1; } # Not the owners post so let's invoke the permissions system else { # Pull the list of permission types and who has them from the DB for this category $perm_query="SELECT perm,who from news_perm where cat=$curr_art_category"; $permissions=mysql_query($perm_query,$mysql_link); # If we got any then loop though them and make arrays with the list of who can access what if ($permissions) { while (list($type_of_perm,$who)=mysql_fetch_row($permissions)) { switch ($type_of_perm) { case 1: $allowed_to_post_who[]=$who; break; case 2: $allowed_to_edit_who[]=$who; break; case 3: $allowed_to_delete_who[]=$who; break; } } } # If the current user appears in the array for a given form of access then grant it $allowed_to_edit=in_array($userregistered,$allowed_to_edit_who); $allowed_to_del=in_array($userregistered,$allowed_to_delete_who); $allowed_to_post=in_array($userregistered,$allowed_to_post_who); } # Prepare the text $final_text=""; $curr_art_title=stripslashes($curr_art_title); # Process BBCode from phpBB2 $final_text = stripslashes(prepare_message(addslashes(unprepare_message($curr_art_bodytext)), $html_on, $bbcode_on, $smile_on, $bbcode_uid)); $final_text = str_replace("\n", "\n
\n", bbencode_second_pass($final_text, $bbcode_uid)); # If we're not viewing an individual article and there is more than one article in the category then chop the text down. if (($view=="article") or ($view=="category") or ($num_cat_arts==1)) {$bodytext=stripslashes($final_text);} else { $bodytext=smart_text($final_text, $preview_length); if (strlen($final_text)>$preview_length) {$bodytext.="
read more...";} } # Build the header for this article if ($allowed_to_edit) {$edit_text="\"Edit";} else {$edit_text="";} if ($allowed_to_del) {$add_text="\"Delete";} else {$add_text="";} if ($allowed_to_post) {$post_text="\"Add";} else {$post_text="";} if ($edit_text.$post_text.$add_text!="") { $edit_string="$edit_text$add_text$post_text"; } else {$edit_string="";} $article_head=<< $curr_art_title$curr_art_pubdate_pretty - $curr_author_fname $curr_author_lname$edit_string END; # Find and display edit information - only if we're in single article mode if ($view=="article") { # Mods by G. Gorman, display only the last time somebody edited the article i.s.o. the whole history. # FUTURE: Show entire history if the user is the owner of the article #$edit_history_query="SELECT concat(fname,' ',lname),date_format(edit_time,'%r - %a %b %D %Y') from news_edit,member where who=id and what=$article"; $edit_history_query="SELECT concat(fname,' ',lname),date_format(edit_time,'%r - %a %b %D %Y') from news_edit,member where who=id and what=$article order by edit_time desc"; $edit_history=mysql_query($edit_history_query,$mysql_link); if (mysql_num_rows($edit_history)) { $bodytext.="

------"; #while (list($curr_who,$curr_time)=mysql_fetch_row($edit_history)) { list($curr_who,$curr_time)=mysql_fetch_row($edit_history); $bodytext.="
Last edit by $curr_who at $curr_time"; #$bodytext.="
Edited by $curr_who at $curr_time"; #} $bodytext.="

"; } } # Display this news article switch ($curr_art_category) { case 1: $MainHeader="#ff0033"; break; case 2: $MainHeader="#3333cc"; break; case 4: $MainHeader="#3333cc"; break; case 5: $MainHeader="#336699"; break; case 6: $MainHeader="#cc3333"; break; case 7: $MainHeader="#336633"; break; case 8: $MainHeader="#cc3333"; break; case 9: $MainHeader="#ff6600"; break; case 10: $MainHeader="#339900"; break; } MainBodyTable ($article_head,$bodytext,$MainHeader,$MainBodyBg); } ?> "; while (list($id, $ed_fname,$ed_lname)=mysql_fetch_row($editors)) { $bodytext.="$ed_fname $ed_lname
"; } $bodytext.="

"; # Display the editors MainBodyTable ($table_head,$bodytext,$BlueHeader,$MainBodyBg); } } ?>