include("config.php");
##############################################
//mysql database connection
##############################################
include("config.php");
mysql_pconnect($dbhost, $dbuname, $dbpass);
@mysql_select_db("$dbname") or die ("Unable to select database");
/*********************************************************/
/* Rounder - Rounds Input to 1 decimal */
/*********************************************************/
function rounder ($value , $precision=0) {
$round_to = pow (10, $precision);
return round ($value * $round_to) / $round_to;
}
function ShortenString ($string, $maxchars=20)
{
if( strlen($string) <= $maxchars ) {
return $string;
}
$string = wordwrap($string, $maxchars, '!+&');
$strings = explode('!+&', $string);
$shortstring = $strings[0];
$shortstring .= '...';
return $shortstring;
}
/*********************************************************/
/* Text Filter */
/*********************************************************/
function FixQuotes ($what = "") {
$what = ereg_replace("'","''",$what);
while (eregi("\\\\'", $what)) {
$what = ereg_replace("\\\\'","'",$what);
}
return $what;
}
function check_reg($Message) {
global $EditedMessage, $CensorList, $CensorMode, $CensorReplace;
include("config.php");
$EditedMessage = $Message;
$CensorMode=1;
if ($CensorMode != 0){
if (is_array($CensorList)){
$Replacement = $CensorReplace;
// Word fragment
$RegExPrefix = '([^[:alpha:]]*)[[:alpha:]]*';
$RegExSuffix = '[[:alpha:]]*([^[:alpha:]]*)';
for ($i = 0; $i < count($CensorList) && $RegExPrefix != ''; $i++){
$bad_word=$CensorList[$i];
$length=strlen($bad_word);
settype ( $length, integer);
$Replacement=str_repeat("*", $length);
$EditedMessage = eregi_replace("$RegExPrefix$CensorList[$i]$RegExSuffix"," $Replacement ",$EditedMessage);
}
}
}
return ($EditedMessage);
}
function check_words($Message)
{
global $EditedMessage, $CensorList, $CensorMode, $CensorReplace;
include("config.php");
$EditedMessage = $Message;
$CensorMode=1;
if ($CensorMode != 0){
if (is_array($CensorList)){
$Replacement = $CensorReplace;
if ($CensorMode == 1){ // Exact match
$RegExPrefix = '([^[:alpha:]]|^)';
$RegExSuffix = '([^[:alpha:]]|$)';
}
elseif ($CensorMode == 2){ // Word beginning
$RegExPrefix = '([^[:alpha:]]|^)';
$RegExSuffix = '[[:alpha:]]*([^[:alpha:]]|$)';
}
elseif ($CensorMode == 3){ // Word fragment
$RegExPrefix = '([^[:alpha:]]*)[[:alpha:]]*';
$RegExSuffix = '[[:alpha:]]*([^[:alpha:]]*)';
}
for ($i = 0; $i < count($CensorList) && $RegExPrefix != ''; $i++)
{
$bad_word=$CensorList[$i];
$length=strlen($bad_word);
settype ( $length, integer);
$Replacement=str_repeat("*", $length);
$EditedMessage = eregi_replace("$RegExPrefix$CensorList[$i]$RegExSuffix"," $Replacement ",$EditedMessage);
}
}
}
return ($EditedMessage);
}
function delQuotes($string){
/* no recursive function to add quote to an HTML tag if needed */
/* and delete duplicate spaces between attribs. */
$tmp=""; # string buffer
$result=""; # result string
$i=0;
$attrib=-1; # Are us in an HTML attrib ? -1: no attrib 0: name of the attrib 1: value of the atrib
$quote=0; # Is a string quote delimited opened ? 0=no, 1=yes
$len = strlen($string);
while($i<$len){
switch($string[$i]) { # What car is it in the buffer ?
case "\"": #" # a quote.
if ($quote==0) {
$quote=1;
} else {
$quote=0;
if (($attrib>0) && ($tmp != "")) { $result .= "=\"$tmp\""; }
$tmp="";
$attrib=-1;
}
break;
case "=": # an equal - attrib delimiter
if ($quote==0) { # Is it found in a string ?
$attrib=1;
if ($tmp!="") $result.=" $tmp";
$tmp="";
} else $tmp .= '=';
break;
case " ": # a blank ?
if ($attrib>0) { # add it to the string, if one opened.
$tmp .= $string[$i];
}
break;
default: # Other
if ($attrib<0) # If we weren't in an attrib, set attrib to 0
$attrib=0;
$tmp .= $string[$i];
break;
}
$i++;
}
if (($quote!=0) && ($tmp != "")) {
if ($attrib==1) $result .= "=";
/* If it is the value of an atrib, add the '=' */
$result .= "\"$tmp\""; /* Add quote if needed (the reason of the function ;-) */
}
return $result;
}
function check_html ($str, $strip="") {
/* The core of this code has been lifted from phpslash */
/* which is licenced under the GPL. */
include("config.php");
if ($strip == "nohtml")
$AllowableHTML=array('');
$str = stripslashes($str);
$str = eregi_replace("<[[:space:]]*([^>]*)[[:space:]]*>",
'<\\1>', $str);
// Delete all spaces from html tags .
$str = eregi_replace("]*href[[:space:]]*=[[:space:]]*\"?[[:space:]]*([^\" >]*)[[:space:]]*\"?[^>]*>",
'', $str); # "
// Delete all attribs from Anchor, except an href, double quoted.
$str = eregi_replace("]*)>",$str,$reg)) {
$i = strpos($str,$reg[0]);
$l = strlen($reg[0]);
if ($reg[1][0] == "/") $tag = strtolower(substr($reg[1],1));
else $tag = strtolower($reg[1]);
if ($a = $AllowableHTML[$tag])
if ($reg[1][0] == "/") $tag = "$tag>";
elseif (($a == 1) || ($reg[2] == "")) $tag = "<$tag>";
else {
# Place here the double quote fix function.
$attrb_list=delQuotes($reg[2]);
// A VER
$attrb_list = ereg_replace("&","&",$attrb_list);
$tag = "<$tag" . $attrb_list . ">";
} # Attribs in tag allowed
else $tag = "";
$tmp .= substr($str,0,$i) . $tag;
$str = substr($str,$i+$l);
}
$str = $tmp . $str;
return $str;
exit;
/* Squash PHP tags unconditionally */
$str = ereg_replace("<\?","",$str);
return $str;
}
function filter_text($Message, $strip="") {
global $EditedMessage;
check_words($Message);
$EditedMessage=check_html($EditedMessage, $strip);
return ($EditedMessage);
}
##############################################
//functions
##############################################
##footer_links
function footer_msg(){
?>
}
##feed categories
function feed_categories(){
/*$result=mysql_query("select count(feed.id) as id from feeds_category, feed where feed.cat_id=feeds_category.id");
while(list($cat_count)=mysql_fetch_array($result)){
echo"o $cat_name
";
}
*/
$result=mysql_query("select feeds_category.id as cat_id, feeds_category.category, count(feed.id) from feeds_category, feed where feed.cat_id=feeds_category.id and feed.accepted=1 group by feeds_category.category");
while(list($cat_id,$cat_name, $cat_total)= mysql_fetch_array($result)) {
echo"$cat_name
";
}
}
##latest feeds
function newfeeds(){
$result=mysql_query("
select
feed.id,
feed.title,
feed.link,
feed.description,
feed.date,
feed.votes,
feed.votes_total,
feed.hits,
feed.rss,
feed.atom,
feed.pod,
feed.blog,
feeds_category.category,
feeds_category.id as cat_id
from
feed,
feeds_category
where
feeds_category.id=feed.cat_id and
feed.accepted=1
order by
feed.id
DESC limit 10
");
?>
while($row=mysql_fetch_array($result)){
?>
=ShortenString($row[title])?>
}
?>
}
function search_boxfeeds($query,$catid,$searchby) {
?>
![]()