###############################################################
# SUMAS mod
# File to edit: 1
#
# /sessions.php
#
#
#
# !! As always, Please backup your forum before installing
# any mod!! I cant be held responsible if something goes wrong.
#
###############################################################
#
#-----[ OPEN ]-----
#
includes/sessions.php
#
#-----[ FIND ]-----
#
//
// 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 append_sid($url, $non_html_amp = false)
{
global $SID;
if ( !empty($SID) && !preg_match('#sid=#', $url) )
{
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}
return $url;
}
#
#-----[ REPLACE, WITH ]-----
#
//
// 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 (
"antibot",
"appie",
"architext",
"bjaaland",
"digout4u",
"echo",
"fast-webcrawler",
"ferret",
"googlebot",
"gulliver",
"harvest",
"htdig",
"ia_archiver",
"jeeves",
"jennybot",
"linkwalker",
"lycos",
"mercator",
"moget",
"muscatferret",
"myweb",
"netcraft",
"nomad",
"petersnews",
"scooter",
"slurp",
"unlost_web_crawler",
"voila",
"voyager",
"webbase",
"weblayers",
"wget",
"wisenutbot",
"acme.spider",
"ahoythehomepagefinder",
"alkaline",
"arachnophilia",
"aretha",
"ariadne",
"arks",
"aspider",
"atn.txt",
"atomz",
"auresys",
"backrub",
"bigbrother",
"blackwidow",
"blindekuh",
"bloodhound",
"brightnet",
"bspider",
"cactvschemistryspider",
"cassandra",
"cgireader",
"checkbot",
"churl",
"cmc",
"collective",
"combine",
"conceptbot",
"coolbot",
"core",
"cosmos",
"cruiser",
"cusco",
"cyberspyder",
"deweb",
"dienstspider",
"digger",
"diibot",
"directhit",
"dnabot",
"download_express",
"dragonbot",
"dwcp",
"e-collector",
"ebiness",
"eit",
"elfinbot",
"emacs",
"emcspider",
"esther",
"evliyacelebi",
"nzexplorer",
"fdse",
"felix",
"fetchrover",
"fido",
"finnish",
"fireball",
"fouineur",
"francoroute",
"freecrawl",
"funnelweb",
"gama",
"gazz",
"gcreep",
"getbot",
"geturl",
"golem",
"grapnel",
"griffon",
"gromit",
"hambot",
"havindex",
"hometown",
"htmlgobble",
"hyperdecontextualizer",
"iajabot",
"ibm",
"iconoclast",
"ilse",
"imagelock",
"incywincy",
"informant",
"infoseek",
"infoseeksidewinder",
"infospider",
"inspectorwww",
"intelliagent",
"irobot",
"iron33",
"israelisearch",
"javabee",
"jbot",
"jcrawler",
"jobo",
"jobot",
"joebot",
"jubii",
"jumpstation",
"katipo",
"kdd",
"kilroy",
"ko_yappo_robot",
"labelgrabber.txt",
"larbin",
"legs",
"linkidator",
"linkscan",
"lockon",
"logo_gif",
"macworm",
"magpie",
"marvin",
"mattie",
"mediafox",
"merzscope",
"meshexplorer",
"mindcrawler",
"momspider",
"monster",
"motor",
"mwdsearch",
"netcarta",
"netmechanic",
"netscoop",
"newscan-online",
"nhse",
"northstar",
"occam",
"octopus",
"openfind",
"orb_search",
"packrat",
"pageboy",
"parasite",
"patric",
"pegasus",
"perignator",
"perlcrawler",
"phantom",
"piltdownman",
"pimptrain",
"pioneer",
"pitkow",
"pjspider",
"pka",
"plumtreewebaccessor",
"poppi",
"portalb",
"puu",
"python",
"raven",
"rbse",
"resumerobot",
"rhcs",
"roadrunner",
"robbie",
"robi",
"robofox",
"robozilla",
"roverbot",
"rules",
"safetynetrobot",
"search_au",
"searchprocess",
"senrigan",
"sgscout",
"shaggy",
"shaihulud",
"sift",
"simbot",
"site-valet",
"sitegrabber",
"sitetech",
"slcrawler",
"smartspider",
"snooper",
"solbot",
"spanner",
"speedy",
"spider_monkey",
"spiderbot",
"spiderline",
"spiderman",
"spiderview",
"spry",
"ssearcher",
"suke",
"suntek",
"sven",
"tach_bw",
"tarantula",
"tarspider",
"techbot",
"templeton",
"teoma_agent1",
"titin",
"titan",
"tkwww",
"tlspider",
"ucsd",
"udmsearch",
"urlck",
"valkyrie",
"victoria",
"visionsearch",
"vwbot",
"w3index",
"w3m2",
"wallpaper",
"wanderer",
"wapspider",
"webbandit",
"webcatcher",
"webcopy",
"webfetcher",
"webfoot",
"weblinker",
"webmirror",
"webmoose",
"webquest",
"webreader",
"webreaper",
"websnarf",
"webspider",
"webvac",
"webwalk",
"webwalker",
"webwatch",
"whatuseek",
"whowhere",
"wired-digital",
"wmir",
"wolp",
"wombat",
"worm",
"wwwc",
"wz101",
"xget",
"awbot",
"bobby",
"boris",
"bumblebee",
"cscrawler",
"daviesbot",
"ezresult",
"gigabot",
"gnodspider",
"internetseer",
"justview",
"linkbot",
"linkchecker",
"nederland.zoek",
"perman",
"pompos",
"pooodle",
"redalert",
"shoutcast",
"slysearch",
"ultraseek",
"webcompass",
"yandex",
"robot",
"bot",
"psbot",
"crawl"
);
$botID = strtolower($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
$iamabot = 0;
for ($i = 0; $i < count($RobotsList); $i++)
{
if ( strstr($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', '-', '-', '-');
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 )
{
}
}
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;
}
if($found==true) {
$url = strtr($url,array("&t="=>",","?t="=>",","?p="=>",","&"=>"","highlight="=>",","view="=>",","amp;"=>"","postorder="=>",","start="=>",","postdays="=>",","sid="=>",","ascvote="=>",","vote="=>","));
if ($found_subject_topic==true) $url.=",-".urlencode(strtolower(str_replace($suma_search, $suma_replace, $row['topic_title'])));
$url .= '.html'.$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 .= '.html';
}
$url = ereg_replace(',,',',',$url);
return $url;
}
function append_sid_normal($url, $non_html_amp = false)
{
global $SID;
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);
}
}
#
#-----[ SAVE/CLOSE ALL FILES ]-----
#
# EoM
#
#-----[ CREATE .htaccess file ]----- place it in your forum root. put the code below into it.
#
#
RewriteEngine on
###
###
# View Category
RewriteCond %{REQUEST_URI} ^/vcat,([0-9]*).htm*
RewriteRule ^(.*) /index.php?c=%1 [L]
# View Forum
RewriteCond %{REQUEST_URI} ^/forum,([0-9]*).htm*
RewriteRule ^(.*) /viewforum.php?f=%1 [L]
RewriteCond %{REQUEST_URI} ^/forum,([0-9]*),-(.*).htm*
RewriteRule ^(.*) /viewforum.php?f=%1 [L]
RewriteCond %{REQUEST_URI} ^/forum,([0-9]*),([0-9]*).htm*
RewriteRule ^(.*) /viewforum.php?f=%1&start=%2 [L]
RewriteCond %{REQUEST_URI} ^/forum,([0-9]*),([0-9]*),-(.*).htm*
RewriteRule ^(.*) /viewforum.php?f=%1&start=%2 [L]
RewriteCond %{REQUEST_URI} ^/pforum,([0-9]*),([0-9]*),([0-9]*).htm*
RewriteRule ^(.*) /viewforum.php?f=%1&topicdays=%2&start=%3 [L]
# View Forum
RewriteCond %{REQUEST_URI} ^/mforum,([0-9]*),([a-zA-Z0-9]*).htm*
RewriteRule ^(.*) /viewforum.php?f=%1&mark=%2 [L]
# View Topic -- after first page
RewriteCond %{REQUEST_URI} ^/ltopic,([0-9]*),([0-9]*),([a-zA-Z0-9]*),([0-9]*).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&postdays=%2&postorder=%3&start=%4 [L]
# View Topic -- after first page
#lhtopic,426,0,asc,%FCber%2A,0.html #viewtopic.php?t=426&postdays=0&postorder=asc&highlight=%FCber%2A&start=15
#lhtopic,426,0,0,asc,%FCber%2A.html #viewtopic.php?t=426&start=0&postdays=0&postorder=asc&highlight=%FCber%2A
RewriteCond %{REQUEST_URI} ^/lhtopic,([0-9]*),([0-9]*),([a-z]*),(.*),([0-9?]*).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&postdays=%2&postorder=%3&highlight=%4&start=%5 [L]
RewriteCond %{REQUEST_URI} ^/lhtopic,([0-9]*),([0-9?]*),([0-9]*),([a-z]*),(.*).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&postdays=%3&postorder=%4&highlight=%5&start=%2 [L]
# View Topic -- normal
RewriteCond %{REQUEST_URI} ^/stopic,([0-9]*),([0-9]*).htm*
RewriteRule ^(.*) /viewtopic.php?p=%1\#%2 [L]
# View Topic -- normal
RewriteCond %{REQUEST_URI} ^/htopic,([0-9]*),([^,]*).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&highlight=%2 [L]
RewriteCond %{REQUEST_URI} ^/htopic,([0-9]*),([0-9]*),([^,]*).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&start=%2&highlight=%3 [L]
# View Topic -- normal
RewriteCond %{REQUEST_URI} ^/vtopic,([0-9]*),([a-zA-Z0-9]*).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&view=%2 [L]
# View Topic -- normal
RewriteCond %{REQUEST_URI} ^/ptopic,([0-9]*).htm*
RewriteRule ^(.*) /viewtopic.php?p=%1\#%2 [L]
RewriteCond %{REQUEST_URI} ^/ptopic,([0-9]*),([^,]*).htm*
RewriteRule ^(.*) /viewtopic.php?p=%1&highlight=%2\#%3 [L]
# View Topic -- normal
RewriteCond %{REQUEST_URI} ^/topic,([0-9]*).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1 [L]
RewriteCond %{REQUEST_URI} ^/topic,([0-9]*),-(.*).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1 [L]
RewriteCond %{REQUEST_URI} ^/topic,([0-9]*),([0-9]*),-(.*).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&start=%2 [L]
RewriteCond %{REQUEST_URI} ^/topic,([0-9]*),([0-9]*).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&start=%2 [L]
#with session
#############
# View Forum
RewriteCond %{REQUEST_URI} ^/forum,([0-9]*),([a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewforum.php?f=%1&sid=%2 [L]
RewriteCond %{REQUEST_URI} ^/forum,([0-9]*),([0-9]*),([a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewforum.php?f=%1&start=%2&sid=%3 [L]
RewriteCond %{REQUEST_URI} ^/forum,([0-9]*),([a-fA-F0-9]{32}),-(.*).htm*
RewriteRule ^(.*) /viewforum.php?f=%1&sid=%2 [L]
RewriteCond %{REQUEST_URI} ^/forum,([0-9]*),([0-9]*),([a-fA-F0-9]{32}),-(.*).htm*
RewriteRule ^(.*) /viewforum.php?f=%1&start=%2&sid=%3 [L]
RewriteCond %{REQUEST_URI} ^/pforum,([0-9]*),([0-9]*),([0-9]*),([a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewforum.php?f=%1&topicdays=%2&start=%3&sid=%4 [L]
# View Forum
RewriteCond %{REQUEST_URI} ^/mforum,([0-9]*),([a-zA-Z0-9]*),([a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewforum.php?f=%1&mark=%2&sid=%3 [L]
# View Topic -- after first page
RewriteCond %{REQUEST_URI} ^/ltopic,([0-9]*),([0-9]*),([a-zA-Z0-9]*),([0-9]*),([a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&postdays=%2&postorder=%3&start=%4&sid=%5 [L]
# View Topic -- after first page
RewriteCond %{REQUEST_URI} ^/lhtopic,([0-9]*),([0-9]*),([a-z]*),([^,]*),([0-9?]*),([a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&postdays=%2&postorder=%3&highlight=%4&start=%5&sid=%6 [L]
RewriteCond %{REQUEST_URI} ^/lhtopic,([0-9]*),([0-9?]*),([0-9]*),([a-z]*),([^,]*),([a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&postdays=%3&postorder=%4&highlight=%5&start=%2&sid=%6 [L]
# View Topic -- normal
RewriteCond %{REQUEST_URI} ^/stopic,([0-9]*),([0-9]*),([a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewtopic.php?p=%1&sid=%2\#%3 [L]
# View Topic -- normal
RewriteCond %{REQUEST_URI} ^/htopic,([0-9]*),([^,]*),([a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&highlight=%2&sid=%3 [L]
RewriteCond %{REQUEST_URI} ^/htopic,([0-9]*),([0-9]*),([^,]*),([a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&start=%2&highlight=%3&sid=%4 [L]
# View Topic -- normal
RewriteCond %{REQUEST_URI} ^/vtopic,([0-9]*),([a-zA-Z0-9]*),([a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&view=%2&sid=%3 [L]
# View Topic -- normal
RewriteCond %{REQUEST_URI} ^/ptopic,([0-9]*),([a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewtopic.php?p=%1&sid=%2\#%3 [L]
RewriteCond %{REQUEST_URI} ^/ptopic,([0-9]*),([^,]*),([[a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewtopic.php?p=%1&highlight=%2&sid=%3\#%4 [L]
# View Topic -- normal
RewriteCond %{REQUEST_URI} ^/topic,([0-9]*),([a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&sid=%2 [L]
RewriteCond %{REQUEST_URI} ^/topic,([0-9]*),([a-fA-F0-9]{32}),-(.*).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&sid=%2 [L]
RewriteCond %{REQUEST_URI} ^/topic,([0-9]*),([0-9]*),([a-fA-F0-9]{32}).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&start=%2&sid=%3 [L]
RewriteCond %{REQUEST_URI} ^/topic,([0-9]*),([0-9]*),([a-zA-Z0-9]*),-(.*).htm*
RewriteRule ^(.*) /viewtopic.php?t=%1&start=%2&sid=%3 [L]
#
#-----[ SAVE/CLOSE UPLOAD]-----
#
# EoM
Zusätlich habe ich noch die Session ID`s für unregistrierte Benutzer geändert:
$SID = 'sid=' . $session_id;
if ( $userdata['session_user_id'] != ANONYMOUS || $userdata['session_page'] == -4 ){
$SID = 'sid=' . $session_id;