--- mainfile.php 2004-05-06 15:42:01.000000000 +0200
+++ ../../public_html/gnuheter-arbete/mainfile.php 2004-06-01 15:39:50.000000000 +0200
@@ -27,378 +27,152 @@
# $Id: mainfile.php,v 1.50 2004/05/06 13:42:01 pawal Exp $
if (ereg("/mainfile\.php$",$SCRIPT_NAME)) {
- header("Location: index.php");
- die();
+ header("Location: index.php");
+ die();
}
$query_string = getenv ("QUERY_STRING");
if (preg_match ("/UNION|FROM|OUTFILE|nuke_authors|nuke_users/i", $query_string)) {
- die ("Thank you! Your data have been logged and sent to the administrator of this site!");
+ die ("Thank you! Your data have been logged and sent to the administrator of this site!");
}
if (!isset($config)) { include("config.php"); }
$mainfile = 1;
+function check_user($user)
+{
+ setcookie('user','');
+
+ $user = base64_decode($user);
+ $cookieuser = explode(":", $user);
+ $cookie[11]=urldecode($cookie[11]);
+ return $cookie;
+
+ $userArray = cookiedecode($user);
+ $claimedUser = $userArray[1];
+ $claimedPass = $userArray[2];
+ if (($claimedUser == '') and ($claimedPass == ''))
+ return false; # inte inloggad
+
+ dbconnect();
+ $sql = "SELECT COUNT(*) FROM users ".
+ "WHERE uname='".addslashes($claimedUser)."' ".
+ "AND pass='".addslashes($claimedPass)."'";
+ $result = mysql_query($sql);
+ $resultarray = mysql_fetch_array($result);
+ $resultcounter = $resultarray[0];
+ mysql_free_result($result);
+
+ if ($resultcounter == 1)
+ return true; # inloggad, inget skumt
+
+ $errmsg = 'Du har råkat ut för något märkligt! Antagligen ';
+ $errmsg.= 'gör du något dumt på egen hand, eller så har du ';
+ $errmsg.= 'en gammal cookie som ligger och skräpar. Radera ';
+ $errmsg.= 'dina cookies och försök igen.';
+ die($errmsg); # Skumt!
+
+}
+
function dbconnect() {
- global $dbhost,$dbname,$dbuname,$dbpass;
- mysql_pconnect($dbhost, $dbuname, $dbpass);
- @mysql_select_db("$dbname") or die ("Unable to select database");
+ global $dbhost,$dbname,$dbuname,$dbpass;
+ mysql_pconnect($dbhost, $dbuname, $dbpass);
+ @mysql_select_db("$dbname") or die ("Unable to select database");
}
function counter() {
- dbconnect();
- mysql_query("UPDATE vars SET value=value+1 where name='totalhits'");
+ dbconnect();
+ mysql_query("UPDATE vars SET value=value+1 where name='totalhits'");
}
function cookiedecode($user) {
- global $cookie;
- $user = base64_decode($user);
- $cookie = explode(":", $user);
- $cookie[11]=urldecode($cookie[11]);
- return $cookie;
+ global $cookie;
+ $user = base64_decode($user);
+ $cookie = explode(":", $user);
+ $cookie[11]=urldecode($cookie[11]);
+ return $cookie;
}
function isRealUser($user) {
- $userArray = cookiedecode($user);
- $claimedUser = $userArray[1];
- $claimedPass = $userArray[2];
- if (($claimedUser == '') and ($claimedPass == ''))
- return false; # inte inloggad
-
- dbconnect();
- $sql = "SELECT COUNT(*) FROM users ".
- "WHERE uname='".addslashes($claimedUser)."' ".
- "AND pass='".addslashes($claimedPass)."'";
- $result = mysql_query($sql);
- $resultarray = mysql_fetch_array($result);
- $resultcounter = $resultarray[0];
- mysql_free_result($result);
-
- if ($resultcounter == 1)
- return true; # inloggad, inget skumt
-
- $errmsg = 'Du har råkat ut för något märkligt! Antagligen ';
- $errmsg.= 'gör du något dumt på egen hand, eller så har du ';
- $errmsg.= 'en gammal cookie som ligger och skräpar. Radera ';
- $errmsg.= 'dina cookies och försök igen.';
- die($errmsg); # Skumt!
+ $userArray = cookiedecode($user);
+ $claimedUser = $userArray[1];
+ $claimedPass = $userArray[2];
+ if (($claimedUser == '') and ($claimedPass == ''))
+ return false; # inte inloggad
+
+ dbconnect();
+ $sql = "SELECT COUNT(*) FROM users ".
+ "WHERE uname='".addslashes($claimedUser)."' ".
+ "AND pass='".addslashes($claimedPass)."'";
+ $result = mysql_query($sql);
+ $resultarray = mysql_fetch_array($result);
+ $resultcounter = $resultarray[0];
+ mysql_free_result($result);
+
+ if ($resultcounter == 1)
+ return true; # inloggad, inget skumt
+
+ $errmsg = 'Du har råkat ut för något märkligt! Antagligen ';
+ $errmsg.= 'gör du något dumt på egen hand, eller så har du ';
+ $errmsg.= 'en gammal cookie som ligger och skräpar. Radera ';
+ $errmsg.= 'dina cookies och försök igen.';
+ die($errmsg); # Skumt!
}
function getusrinfo($user) {
- global $userinfo;
- $user2 = base64_decode($user);
- dbconnect();
- $user3 = explode(":", $user2);
- $sql = "SELECT uid, name, uname, email, femail, url, ".
- "pass, storynum, umode, uorder, thold, noscore, bio, ".
- "ublockon, ublock, theme, commentmax, sig FROM users ".
- "WHERE uname='{$user3[1]}' AND pass='{$user3[2]}'";
- $result = mysql_query($sql);
- if(mysql_num_rows($result)==1) {
- $userinfo = mysql_fetch_array($result);
- } else {
- echo "A problem occured
";
- }
- return $userinfo;
+ global $userinfo;
+ if (!isset($user) || $user == "")
+ return;
+ $user = base64_decode($user);
+ dbconnect();
+ $user = explode(":", $user);
+ $sql = "SELECT uid, name, uname, email, femail, url, ".
+ "pass, storynum, umode, uorder, thold, noscore, bio, ".
+ "ublockon, ublock, theme, commentmax, sig, status FROM users ".
+ "WHERE uname='{$user[1]}' AND pass='{$user[2]}'";
+ $result = mysql_query($sql);
+ if(mysql_num_rows($result)==1) {
+ $userinfo = mysql_fetch_array($result);
+ }
+ else
+ {
+ if (isset($user) && $user != "") setcookie('user','');
+ return;
+ }
+ $userinfo[sig] = urldecode($userinfo[sig]);
+ return $userinfo;
}
function rmflags() {
- global $cookie;
- if (isset($cookie[4])) { $rmflags = "&mode=$cookie[4]"; } else {
- $rmflags = "&mode=thread"; }
- if (isset($cookie[5])) { $rmflags .= "&order=$cookie[5]"; } else {
- $rmflags .= "&order=0"; }
- if (isset($cookie[6])) { $rmflags .= "&thold=$cookie[6]"; } else {
- $rmflags .= "&thold=0"; }
- return $rmflags;
+ global $cookie;
+ if (isset($cookie[4])) { $rmflags = "&mode=$cookie[4]"; } else {
+ $rmflags = "&mode=thread"; }
+ if (isset($cookie[5])) { $rmflags .= "&order=$cookie[5]"; } else {
+ $rmflags .= "&order=0"; }
+ if (isset($cookie[6])) { $rmflags .= "&thold=$cookie[6]"; } else {
+ $rmflags .= "&thold=0"; }
+ return $rmflags;
}
function store_referer() {
- global $httpref, $httprefmax, $HTTP_REFERER, $HTTP_HOST;
- if ($httpref > 0) {
- if(!$HTTP_REFERER or
- ereg("unknown",$HTTP_REFERER) or
- ereg($HTTP_HOST, $HTTP_REFERER)) {
- } else {
- mysql_query("insert into referer values(NULL, '$HTTP_REFERER')");
- }
- $result = mysql_query("SELECT COUNT(*) FROM referer");
- list($numrows) = mysql_fetch_row($result);
- if($numrows >= $httprefmax) {
- mysql_query("DELETE FROM referer");
- }
- }
+ global $httpref, $httprefmax, $HTTP_REFERER, $HTTP_HOST;
+ if ($httpref > 0) {
+ if(!$HTTP_REFERER or
+ ereg("unknown",$HTTP_REFERER) or
+ ereg($HTTP_HOST, $HTTP_REFERER)) {
+ } else {
+ mysql_query("insert into referer values(NULL, '$HTTP_REFERER')");
+ }
+ $result = mysql_query("SELECT COUNT(*) FROM referer");
+ list($numrows) = mysql_fetch_row($result);
+ if($numrows >= $httprefmax) {
+ mysql_query("DELETE FROM referer");
+ }
+ }
}
function removecrlf($string) {
- return strtr($string, "\015\012", ' ');
-}
-
-function urlWithProtocol($url) {
- if (!eregi('^(f|ht)tp:', $url))
- $url = "http://$url";
-
- if ($url == 'http://')
- $url = '';
-
- $url = preg_replace('/(\s|"|\'|\\\\)/', '', $url);
-
- return $url;
-}
-
-function wordlinks($doc) {
- return preg_replace
- ('%\[\s*'. # [
- '([a-z0-9]+)\s*'. # (wordlink)
- ':\s*'. # :
- '([^][<>\\\\]+?)'. # (själva ordet)
- '\s*\]%ei', # ]
- 'wordlinksProc("\\1", "\\2")',
- $doc);
-}
-
-function wordlinksProc($name, $str) {
- global $wordlinks;
-
- $str = stripslashes($str);
- $strenc = $str;
-
- $url = $wordlinks[$name]['url'];
- if ($url == '')
- return '*felaktig ordlänk*';
-
- switch ($wordlinks[$name]['enc']) {
- case 'susning':
- $strenc = wordlinksEncodingSusning($str);
- break;
- case 'jargon':
- $strenc = wordlinksEncodingJargon($str);
- break;
- case 'urlencode':
- $strenc = urlencode($str);
- break;
- }
-
- $url = ereg_replace(' WORD ', $strenc, $url);
- $url = "$str";
- return $url;
-}
-
-function wordlinksEncodingSusning($str) {
- $str = preg_replace('/^([a-z])/e', "strtoupper('\\1')", $str);
- $str = urlencode($str);
- $str = ereg_replace('_', '%5F', $str);
- $str = ereg_replace('\+', '_', $str);
- $str = ereg_replace('%2F', '/', $str);
- return $str;
-}
-
-function wordlinksEncodingJargon($str) {
- $str = ereg_replace(' ', '-', $str);
- $str = ereg_replace('[/@~*?]', '', $str);
- $str = ereg_replace('&', 'amp;', $str);
- $str = urlencode($str);
- return $str;
-}
-
-function nowordlinkshtml($str) {
- return strip_tags(wordlinks($str));
-}
-
-function nowordlinksshow($str) {
- $str = htmlspecialchars($str);
- $str = ereg_replace('\[', '[', $str);
- $str = ereg_replace('\]', ']', $str);
- return $str;
-}
-
-function ampersand($str) {
- $str = str_replace("&", "&", $str);
- $str = eregi_replace("&(#x?[0-9a-f]+;)", "&\\1", $str);
- $str = eregi_replace("&([a-z][a-z0-9]+;)", "&\\1", $str);
- return $str;
-}
-
-function printAllowedHTML() {
- global $allowed_html;
-
- echo "Tillåten HTML:
\n";
-
- foreach ($allowed_html as $onekey => $oneval) {
- echo "<$onekey";
-
- foreach ($oneval as $twokey => $twoval)
- echo " $twokey=";
-
- echo '> ';
- }
-
- echo "
\n";
-}
-
-function new_check_html($string, $strip = '') {
-
-# Den här funktionen ser till att bara godkända HTML-element och deras
-# godkända HTML-attribut får förekomma i $string. Man måste ha tagit bort
-# eventuella slashes från magic quotes innan man anropar den här funktionen.
-
- global $allowed_html;
-
- $string = ampersand($string);
-
- if ($strip == 'nohtml')
- return strip_tags($string);
-
- $allow = '';
- foreach ($allowed_html as $htmlkey => $htmlvar)
- $allow .= "<$htmlkey>";
-
- $string = strip_tags($string, $allow);
- return new_check_html_split($string);
-}
-
-function new_check_html_split($string) {
-
-# Den här funktionen letar upp HTML-taggar, delar upp dem i element och alla
-# attribut, och anropar new_check_html_attr.
-
- $string = preg_replace('%<\s*'.
- '(/?[a-z]+)'. # element
- '([^>]*)'. # alla attribut
- '>%ei',
- "new_check_html_attr('\\1', '\\2')", $string);
- return $string;
-}
-
-function new_check_html_attr($element, $attr) {
-
-# Den här funktionen tar bort alla attribut, om elementet inte ska ha några.
-# Om det ska det går den igenom attributlistan och delar noggrant upp den i
-# attribut, som sedan kontrolleras mot $allowed_html.
-
- global $allowed_html;
-
- $attr = stripslashes($attr);
-
-# Kolla om elementet ska ha några attribut alls.
-
- if (count($allowed_html[strtolower($element)]) == 0)
- return "<$element>";
-
-
-# Dela upp attributen, och lagra i $attrarr.
-
- $attr = preg_replace('/javascript\s*:\s*/i', '', $attr);
-
- $attrarr = array();
- $mode = 0;
- $attrname = '';
-
- while (strlen($attr) != 0)
- {
- $working = 0; # anger om operationen har lyckats eller inte
-
- switch ($mode)
- {
- case 0: # attributnamn, exempelvis href
-
- if (preg_match('/^([a-z]+)/i', $attr, $match))
- {
- $attrname = $match[1];
- $working = $mode = 1;
- $attr = preg_replace('/^[a-z]+/i', '', $attr);
- }
-
- break;
-
-
- case 1: # lika med eller bara tomt ("selected")
-
- if (preg_match('/^\s*=\s*/', $attr)) # lika med
- {
- $working = 1; $mode = 2;
- $attr = preg_replace('/^\s*=\s*/', '', $attr);
- break;
- }
-
- if (preg_match('/^\s+/', $attr)) # tomt
- {
- $working = 1; $mode = 0;
- $attrarr[] = array
- ('name' => $attrname,
- 'whole' => $attrname);
- $attr = preg_replace('/^\s+/', '', $attr);
- }
-
- break;
-
-
- case 2: # attributvärde, exempelvis en URL efter href=
-
- if (preg_match('/^("[^"]*")(\s+|$)/', $attr, $match))
- # "värde"
- {
- $attrarr[] = array
- ('name' => $attrname,
- 'whole' => "$attrname=$match[1]");
- $working = 1; $mode = 0;
- $attr = preg_replace('/^"[^"]*"(\s+|$)/', '', $attr);
- break;
- }
-
- if (preg_match("/^('[^']*')(\s+|$)/", $attr, $match))
- # 'värde'
- {
- $attrarr[] = array
- ('name' => $attrname,
- 'whole' => "$attrname=$match[1]");
- $working = 1; $mode = 0;
- $attr = preg_replace("/^'[^']*'(\s+|$)/", '', $attr);
- break;
- }
-
- if (preg_match("%^([^\s\"']+)(\s+|$)%", $attr, $match))
- # värde
- {
- $attrarr[] = array
- ('name' => $attrname,
- 'whole' => "$attrname=\"$match[1]\"");
- $working = 1; $mode = 0;
- $attr = preg_replace("%^[^\s\"']+(\s+|$)%",
- '', $attr);
- }
-
- break;
- }
-
- if ($working == 0)
- # inte välformad, ta bort t o m nästa mellanslag
- {
- $attr = preg_replace('/^\S*\s*/', '', $attr);
- $mode = 0;
- }
- } # while
-
-
- if ($mode == 1)
- # specialfall, om attributen slutar med ett tomt attribut som "selected"
- $attrarr[] = array
- ('name' => $attrname,
- 'whole' => $attrname);
-
-
-# Gå igenom $attrarr, och spara endast de tillåtna attributen för det
-# här elementet.
-
- $attr2 = '';
-
- foreach ($attrarr as $arreach)
- if ($allowed_html[strtolower($element)][strtolower($arreach['name'])]
- == 1)
- $attr2 .= ' '.$arreach['whole'];
-
-
- return "<$element$attr2>";
+ return strtr($string, "\015\012", ' ');
}
/*********************************************************/
@@ -406,110 +180,110 @@
/*********************************************************/
function formatTimestamp($time) {
- global $datetime,$locale;
- setlocale (LC_TIME, "$locale");
- ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
- $datetime = strftime("%e %b %Y %H.%M", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
- $datetime = ucfirst($datetime);
- return($datetime);
+ global $datetime,$locale;
+ setlocale (LC_TIME, "$locale");
+ ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
+ $datetime = strftime("%e %b %Y %H.%M", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
+ $datetime = ucfirst($datetime);
+ return($datetime);
}
function formatAidHeader($aid) {
- $holder = mysql_query("SELECT url, email FROM authors where aid='$aid'");
- if (!$holder) {
- echo mysql_errno(). ": ".mysql_error(). "
"; exit();
- }
- list($url, $email) = mysql_fetch_row($holder);
- if (isset($url)) {
- echo "$aid";
- } elseif (isset($email)) {
- echo "$aid";
- } else {
- echo $aid;
- }
+ $holder = mysql_query("SELECT url, email FROM authors where aid='$aid'");
+ if (!$holder) {
+ echo mysql_errno(). ": ".mysql_error(). "
"; exit();
+ }
+ list($url, $email) = mysql_fetch_row($holder);
+ if (isset($url)) {
+ echo "$aid";
+ } elseif (isset($email)) {
+ echo "$aid";
+ } else {
+ echo $aid;
+ }
}
function oldNews() {
- global $locale,$oldnum,$storynum;
- $storynum = (int) $storynum;
- $oldnum = (int) $oldnum;
- $boxstuff = "";
- $boxTitle = "Tidigare artiklar";
- $rmflags = rmflags();
+ global $locale,$oldnum,$storynum;
+ $storynum = (int) $storynum;
+ $oldnum = (int) $oldnum;
+ $boxstuff = "";
+ $boxTitle = "Tidigare artiklar";
+ $rmflags = rmflags();
$sql = "SELECT sid, title, time, comments ".
- "FROM stories ORDER BY time ".
- "DESC LIMIT $storynum,$oldnum";
- $result = mysql_query($sql);
- $vari = 0;
- while(list($sid, $title, $time, $comments) = mysql_fetch_row($result)) {
- $title = nowordlinkshtml($title);
- setlocale (LC_TIME, "$locale");
- ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime2);
- $datetime2 = strftime("%A, %e %B", mktime($datetime2[4],$datetime2[5],$datetime2[6],$datetime2[2],$datetime2[3],$datetime2[1]));
- $datetime2 = ucfirst($datetime2);
- if ($time2 == $datetime2) {
- $boxstuff .= "• $title ".
- "($comments)
\n";
- } else {
- if(!$a) {
- $boxstuff .= "$datetime2
• ".
- "$title ".
- "($comments)
\n";
- $time2 = $datetime2;
- $a = 1;
- } else {
- $boxstuff .= "
$datetime2
• ".
- "$title ".
- "($comments)
\n";
- $time2 = $datetime2;
- }
- }
- $vari++;
- if ($vari == $oldnum) {
- if (isset($cookie[3])) $storynum = $cookie[3]; else $storynum = $storyhome;
- $min = $oldnum + $storynum;
- $boxstuff .= "
". - "Äldre artiklar
\n"; - } - - } - if($boxstuff!="") - themesidebox($boxTitle, $boxstuff, "oldNewsBox"); + "FROM stories ORDER BY time ". + "DESC LIMIT $storynum,$oldnum"; + $result = mysql_query($sql); + $vari = 0; + while(list($sid, $title, $time, $comments) = mysql_fetch_row($result)) { + $title = nowordlinkshtml($title); + setlocale (LC_TIME, "$locale"); + ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime2); + $datetime2 = strftime("%A, %e %B", mktime($datetime2[4],$datetime2[5],$datetime2[6],$datetime2[2],$datetime2[3],$datetime2[1])); + $datetime2 = ucfirst($datetime2); + if ($time2 == $datetime2) { + $boxstuff .= "• $title ". + "($comments)". + "Äldre artiklar
\n"; + } + + } + if($boxstuff!="") + themesidebox($boxTitle, $boxstuff, "oldNewsBox"); } function mainblock() { - $result = mysql_query("SELECT title, content FROM mainblock"); - while(list($title, $content) = mysql_fetch_array($result)) { - $content = nl2br($content); - themesidebox($title, $content); - } + $result = mysql_query("SELECT title, content FROM mainblock"); + while(list($title, $content) = mysql_fetch_array($result)) { + $content = nl2br($content); + themesidebox($title, $content); + } } function rightblocks() { - $result = mysql_query("SELECT title, content FROM rblocks"); - while(list($title, $content) = mysql_fetch_array($result)) { - $content = nl2br($content); - themesidebox($title, $content); - } + $result = mysql_query("SELECT title, content FROM rblocks"); + while(list($title, $content) = mysql_fetch_array($result)) { + $content = nl2br($content); + themesidebox($title, $content); + } } function leftblocks() { - $result = mysql_query("SELECT title, content FROM lblocks"); - while(list($title, $content) = mysql_fetch_array($result)) { - $content = nl2br($content); - themesidebox($title, $content); - } + $result = mysql_query("SELECT title, content FROM lblocks"); + while(list($title, $content) = mysql_fetch_array($result)) { + $content = nl2br($content); + themesidebox($title, $content); + } } function eventblock() { $sql = "SELECT id,title,CONCAT(DAYOFMONTH(evfrom),'/',MONTH(evfrom)) ". - "FROM gevents WHERE evto>=NOW() ORDER BY evfrom LIMIT 10"; + "FROM gevents WHERE evto>=NOW() ORDER BY evfrom LIMIT 10"; $result = mysql_query($sql); - while (list($id,$title,$evfrom) = mysql_fetch_array($result)) { - $content.= "• $evfrom $title"; - echo "$optionText"; - echo " | "; - - if($sum) { - $percent = 100 * $optionCount * $BarScale / $sum; - } else { - $percent = 0; - } - echo "";
- $percentInt = (int)$percent * 4;
- $percent2 = (int)$percent;
-
- if ($percent > 0) {
- echo "";
- echo "";
- echo "";
- } else {
- echo "";
- echo "";
- echo "";
- }
+ global $maxOptions, $BarScale, $resultTableBgColor, $resultBarFile, $setCookies;
+ if (!isset($sid)) $sid = 1;
+ dbconnect();
+
+ $result = mysql_query("SELECT sid, pollTitle, timeStamp FROM poll_desc WHERE sid='$sid'");
+ $holdtitle = mysql_fetch_row($result);
+ echo " $holdtitle[1] "; + + mysql_free_result($result); + + $result = mysql_query("SELECT SUM(optionCount) AS SUM FROM poll_data WHERE sid='$sid'"); + $sum = (int)mysql_result($result, 0, "SUM"); + mysql_free_result($result); + + echo "
"; - echo " Totalt antal röster: $sum \n";
- return(1);
+ echo ""; - if($setCookies>0) { - echo "Vi tillåter endast en röst per person per dag \n"; - } else { - echo " "; - } - - $booth = $sid; - echo "[ Röstningsbås | "; - echo "Andra undersökningar ]\n"; - echo " | ";
+ }
+ }
+ echo "
\n", $in);
+ $in = preg_replace('/\s*\/{4,}\s*/', "\n
\n", $in); # //// ->
+ for ($i = 1; $i <= 12; $i++) # support for lists, up to twelve level
+ {
+ $in = preg_replace('/(\n\\*{'.$i.',}.+)+/', "
".$in."
"; + return $in; +} + +function wikiLink($str, $str2 = "") +{ + global $userinfo; + if ($str2 == "") $str2 = $str; + dbconnect(); + $wurl="/"; //import config instead + $res = normLink($str); + # check wether word exist... + $result = mysql_query("SELECT rev FROM nimm WHERE ord = '$res'"); + if (mysql_num_rows($result)>0) + $end = "$str2"; + else + { + if ($userinfo[uname]!="") + $end = "$str2"; + else + $end = $str2; + } + return $end; +} + +function externLink($str, $str2 = "") +{ + if ($str2 == "") $str2 = $str; + dbconnect(); + return "$str2"; +} + +function normLink($str) +{ + $res = pre_parse($str); + $res = preg_replace('/>/', '>',$res); # reinsert < + $res = preg_replace('/</', '<',$res); # and > in link + $res = preg_replace('/\s/', '_',$res); # Get rid of spaces and replace with underscore (_) + return strtoupper($res{0}).strtolower(substr($res, 1)); +} + +function denormLink($res) +{ + $res = preg_replace('/>/', '>',$res); # reinsert < + $res = preg_replace('/<;/', '<',$res); # and > in link + $res = preg_replace('/_/', ' ',$res); # Get rid of spaces and replace with underscore (_) + return strtolower($res); +} + +function dewhite($in) +{ + return $in;#preg_replace('/[\s]*[\n\r]{2,}[\s]*[\n\r]{2,}[\s]*/m', "\n\n", $in); +## return preg_replace("/[ \t\n\r]{1,}/m", " ", $out); +} + ?>