//
// Append $SID to a url. Borrowed from phplib and modified. This is an
// extra routine utilised by the session code above and acts as a wrapper
// around every single URL and form action. If you replace the session
// code you must include this routine, even if it's empty.
//
function areyouabot()
{
global $HTTP_SERVER_VARS;
$RobotsList = array (
"bot",
"spider",
"crawler",
"spyder",
"appie",
"architext",
"bjaaland",
"digout4u",
"echo",
"ferret",
"gulliver",
"harvest",
"htdig",
"ia_archiver",
"jeeves",
"linkwalker",
"lycos",
"mercator",
"moget",
"muscatferret",
"myweb",
"netcraft",
"nomad",
"petersnews",
"scooter",
"slurp",
"voila",
"voyager",
"webbase",
"weblayers",
"wget",
"ahoythehomepagefinder",
"alkaline",
"arachnophilia",
"aretha",
"ariadne",
"arks",
"aspider",
"atn.txt",
"atomz",
"auresys",
"backrub",
"bigbrother",
"blackwidow",
"blindekuh",
"bloodhound",
"brightnet",
"bspider",
"cassandra",
"cgireader",
"churl",
"cmc",
"collective",
"combine",
"core",
"cosmos",
"cruiser",
"cusco",
"deweb",
"digger",
"directhit",
"download_express",
"dwcp",
"e-collector",
"ebiness",
"eit",
"emacs",
"esther",
"evliyacelebi",
"nzexplorer",
"fdse",
"felix",
"fetchrover",
"fido",
"finnish",
"fireball",
"fouineur",
"francoroute",
"freecrawl",
"funnelweb",
"gama",
"gazz",
"gcreep",
"geturl",
"golem",
"grapnel",
"griffon",
"gromit",
"havindex",
"hometown",
"htmlgobble",
"hyperdecontextualizer",
"ibm",
"iconoclast",
"ilse",
"imagelock",
"incywincy",
"informant",
"infoseek",
"inspectorwww",
"intelliagent",
"iron33",
"israelisearch",
"javabee",
"jobo",
"jubii",
"jumpstation",
"katipo",
"kdd",
"kilroy",
"labelgrabber.txt",
"larbin",
"legs",
"linkidator",
"linkscan",
"lockon",
"logo_gif",
"macworm",
"magpie",
"marvin",
"mattie",
"mediafox",
"merzscope",
"meshexplorer",
"monster",
"motor",
"mwdsearch",
"netcarta",
"netmechanic",
"netscoop",
"newscan-online",
"nhse",
"northstar",
"occam",
"octopus",
"openfind",
"orb_search",
"packrat",
"pageboy",
"parasite",
"patric",
"pegasus",
"perignator",
"phantom",
"piltdownman",
"pimptrain",
"pioneer",
"pitkow",
"pka",
"plumtreewebaccessor",
"poppi",
"portalb",
"puu",
"python",
"raven",
"rbse",
"rhcs",
"roadrunner",
"robbie",
"robi",
"robofox",
"robozilla",
"rules",
"search_au",
"searchprocess",
"senrigan",
"sgscout",
"shaggy",
"shaihulud",
"sift",
"site-valet",
"sitegrabber",
"sitetech",
"snooper",
"spanner",
"speedy",
"spry",
"ssearcher",
"suke",
"suntek",
"sven",
"tach_bw",
"tarantula",
"templeton",
"teoma_agent1",
"titin",
"titan",
"tkwww",
"ucsd",
"udmsearch",
"urlck",
"valkyrie",
"victoria",
"visionsearch",
"w3index",
"w3m2",
"wallpaper",
"wanderer",
"webbandit",
"webcatcher",
"webcopy",
"webfetcher",
"webfoot",
"weblinker",
"webmirror",
"webmoose",
"webquest",
"webreader",
"webreaper",
"websnarf",
"webvac",
"webwalk",
"webwalker",
"webwatch",
"whatuseek",
"whowhere",
"wired-digital",
"wmir",
"wolp",
"wombat",
"worm",
"wwwc",
"wz101",
"xget",
"bobby",
"boris",
"bumblebee",
"ezresult",
"internetseer",
"justview",
"linkbot",
"linkchecker",
"nederland.zoek",
"perman",
"pompos",
"pooodle",
"redalert",
"shoutcast",
"slysearch",
"ultraseek",
"webcompass",
"yandex",
"crawl"
);
$botID = strtolower($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
$iamabot = 0;
for ($i = 0; $i < count($RobotsList); $i++)
{
if ( stristr($botID, $RobotsList[$i]) )
{
$iamabot = 1;
return $iamabot;
}
}
return $iamabot;
}
function append_sid_suma($url, $non_html_amp = false)
{
global $SID,$HTTP_SERVER_VARS,$db;
// CONFIG: Umlaute ersetzen
$suma_search = array( 'Ö', 'Ä', 'Ü', 'ö', 'ä', 'à', 'é', 'è', 'ü', ' ', ".", "'", '#', '"', '&', '!', '?', '[', ']', '/', '>', '<', ";", ")", "(", ':', '&', ',', '+');
$suma_replace = array( 'oe', 'ae', 'ue', 'oe', 'ae', 'a', 'e', 'e', 'ue', '-', "-", "", '', '', 'und', '', '', '', '', '-', '', '', '', '', '', '', 'und', '', 'plus');
if (areyouabot() != 1) {
if( !empty($SID) && !preg_match('#sid=#', $url) )
{
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}
}
if( strstr($url,'viewtopic.php') && !strstr($url,'viewtopic.php?replace') )
{
if(ereg("#",$url)) {
$pos=strpos($url, "#");
$url_temp=substr($url,0,$pos);
$zusatz=substr($url,$pos,strlen($url));
$url=$url_temp;
}
else
{
$zusatz="";
}
$found=false;
$found_subject_topic=false;
$found_subject_forum=false;
if ( preg_match('#viewtopic.php\?t=#', $url) )
{
$highlight = preg_match('#highlight=#', $url);
$view = preg_match( '#view=#', $url);
$postdays = preg_match( '#postdays=#', $url);
$watch = preg_match( '#watch=#', $url);
$unwatch = preg_match( '#unwatch=#', $url);
$mode = preg_match( '#mode=#', $url);
if( !($highlight) && !($view) && !($postdays) && !($watch) && !($unwatch) && !($mode) )
{
$prg=str_replace("viewtopic.php?","",$url);
parse_str($prg, $prg_output);
$sql = "SELECT topic_title
FROM " . TOPICS_TABLE . "
WHERE topic_id = '".$prg_output['t']."'";
if ( !($result = $db->sql_query($sql)) )
{
#message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$found_subject_topic=true;
}
$url = str_replace( 'viewtopic.php', 'topic', $url );
$found=true;
}
elseif( $highlight && !($postdays) && !($watch) && !($unwatch) && !($mode))
{
$url = str_replace( 'viewtopic.php', 'htopic', $url );
$found=true;
}
elseif( $view )
{
$url = str_replace( 'viewtopic.php', 'vtopic', $url );
$found=true;
}
elseif( !$highlight )
{
$printertopic = preg_match('#printertopic=#', $url);
if( !($printertopic) )
{
$vote = preg_match('#vote=#', $url);
if( $postdays && !($vote) )
{
$url = str_replace( 'viewtopic.php', 'ltopic', $url );
$found=true;
}
elseif( $postdays && $vote )
{
$url = str_replace( 'viewtopic.php', 'utopic', $url );
$found=true;
}
}
elseif( $postdays && $printertopic )
{
$url = str_replace( 'viewtopic.php', 'prtopic', $url );
$found=true;
}
}
elseif( $postdays && $highlight )
{
$url = str_replace( 'viewtopic.php', 'lhtopic', $url );
$found=true;
}
}
elseif( preg_match('#viewtopic.php\?p=#', $url) )
{
$url = str_replace( 'viewtopic.php', 'ptopic', $url );
$found=true;
}
// ALT
//else
//{
// //nothing
// $url = str_replace( 'viewtopic.php', 'ptopic', $url );
// $found=true;
//}
if($found==true) {
$url = strtr($url,array("&t="=>"-","?t="=>"","?p="=>"","&"=>"","highlight="=>"-","view="=>"-","amp;"=>"","postorder="=>"-","start="=>"-","postdays="=>"-","sid="=>"-","ascvote="=>"-","vote="=>"-","setbm"=>"-"));
if ($found_subject_topic==true) $url.="--".urlencode(strtolower(str_replace($suma_search, $suma_replace, $row['topic_title'])));
$url .= '.htm'.$zusatz;
}
}
if( strstr ($url, 'viewforum.php?f=') )
{
$topicdays = preg_match('#topicdays=#', $url);
if( !preg_match('#mark=#', $url) && !($topicdays) )
{
$prg=str_replace("viewforum.php?","",$url);
parse_str($prg, $prg_output);
$sql = "SELECT forum_name
FROM " . FORUMS_TABLE . "
WHERE forum_id = '".$prg_output['f']."'";
if ( !($result = $db->sql_query($sql)) )
{
#message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$found_subject_forum=true;
}
$url = str_replace( 'viewforum.php', 'forum', $url );
}
elseif( $topicdays )
{
$url = str_replace( 'viewforum.php', 'pforum', $url );
}
else
{
$url = str_replace( 'viewforum.php', 'mforum', $url );
}
$url = strtr($url,array("?f="=>"","amp;"=>"","mark="=>"-","sid="=>"-","&"=>"","start="=>"-","topicdays="=>"-"));
if ($found_subject_forum==true) $url.="--".urlencode(strtolower(str_replace($suma_search, $suma_replace, $row['forum_name'])));
$url .= '.htm';
}
$url = ereg_replace('---','-',$url);
$url = ereg_replace('--','-',$url);
$url = ereg_replace('-.htm','.htm',$url);
return $url;
}
function append_sid_normal($url, $non_html_amp = false)
{
global $SID;
if (areyouabot($_SERVER["HTTP_USER_AGENT"], TRUE) != 1) {
if ( !empty($SID) && !preg_match('#sid=#', $url) )
{
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}}
return $url;
}
function append_sid($url, $non_html_amp = false)
{
$sumadebug=0;
if($sumadebug==1) {
return append_sid_normal($url, $non_html_amp);
}else{
return append_sid_suma($url, $non_html_amp);
}
}