All pastes #617622 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-07-13 11:32 UTC
rendered paste body
# Sniffuser Function: Populates $_SESSION with user info

# $_SESSION['os'] = "Linux", "Windows", Defaults to windows 

# $_SESSION['browser'] = Firefox, Konqueror, MSIE, or Opera

# $_SESSION['width'] = 800, 1024, 1280, 1600

# MAC/SAFFARI Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/522.11 (KHTML, like Gecko) Version/3.0.2 Safari/522.12

function sniffuser () {

	if (ereg("Linux", $_SERVER['HTTP_USER_AGENT'])) {

  	$_SESSION['os'] = "Linux";

	} elseif (ereg("Windows", $_SERVER['HTTP_USER_AGENT'])) {

  	$_SESSION['os'] = "Windows";

  } elseif (ereg("Macin". $_SERVER['HTTP_USER_AGENT'])) {

  	$_SESSION['os'] = "Macintosh";

	} else {

  	$_SESSION['os'] = "Unknown";	

	}

	

	if (ereg("Firefox", $_SERVER['HTTP_USER_AGENT'])) {

  	$_SESSION['browser'] = "Firefox";

	} elseif (ereg("Konqueror", $_SERVER['HTTP_USER_AGENT'])) {

  	$_SESSION['browser'] = "Konqueror";

	} elseif (ereg("MSIE", $_SERVER['HTTP_USER_AGENT'])) {

  	$_SESSION['browser'] = "MSIE";

	} elseif (ereg("Opera", $_SERVER['HTTP_USER_AGENT'])) {

  	$_SESSION['browser'] = "Opera";

	} elseif (ereg("Safari", $_SERVER['HTTP_USER_AGENT'])) {

  	$_SESSION['browser'] = "Safari";

	} else {

		$_SESSION['browser'] = "Unknown";

	}

	

	if ($_POST[aheight]) {

  	$_SESSION['height'] = $_POST[aheight];

  	$_SESSION['width'] = $_POST[awidth];

  	#this is to fix a bug in opera for linux. It will return double resolution if dual head is running

  	if (($_SESSION[browser] == "Opera") && ($_SESSION[os] == "Linux")) {

  		#checks for dual 800x600 resolutions

  		if (($_SESSION[height] == "600") && ($_SESSION[width] == "1600")) {

  			$_SESSION[width] = "800";

  		#checks for dual 800x600 resolutions

  		} elseif (($_SESSION[height] == "768") && ($_SESSION[width] == "1024")) {

  			$_SESSION[width] = "1024";

  		#checks for dual 800x600 resolutions

  		} elseif (($_SESSION[height] == "1024") && ($_SESSION[width] == "2560")) {

  			$_SESSION[width] = "1280";

  		} elseif (($_SESSION[height] == "1200") && ($_SESSION[width] == "3200")) {

  			$_SESSION[width] = "1600";

  		}

  	}

	}

	#$special = sanitize_system_string($_SERVER[HTTP_USER_AGENT], '0', '255');

	#$special = ;

  $datatemp = mysql_fetch_array(mysql_query("SELECT * FROM `devData` WHERE `ip` = '{$_SERVER[REMOTE_ADDR]}' AND `os` = '{$_SESSION[os]}' AND `browser` = '{$_SESSION[browser]}' AND `width` = '{$_SESSION[width]}' AND `height` = '{$_SESSION[height]}' AND `http_user_agent` = '{$_SERVER[HTTP_USER_AGENT]}' AND `ua_cpu` = '{$_SERVER[HTTP_UA_CPU]}' AND `accept_language` = '{$_SERVER[HTTP_ACCEPT_LANGUAGE]}'"));

	if ($datatemp[ip] == $_SERVER[REMOTE_ADDR]) {

  	$datatemp[hits] = $datatemp[hits] + 1; 

    mysql_query("UPDATE `devData` SET hits = '{$datatemp[hits]}', `request_time` = '{$_SERVER[REQUEST_TIME]}' WHERE `ip` = '{$_SERVER[REMOTE_ADDR]}' AND `os` = '{$_SESSION[os]}' AND `browser` = '{$_SESSION[browser]}' AND `width` = '{$_SESSION[width]}' AND `height` = '{$_SESSION[height]}' AND `http_user_agent` = '{$_SERVER[HTTP_USER_AGENT]}' AND `ua_cpu` = '{$_SERVER[HTTP_UA_CPU]}' AND `accept_language` = '{$_SERVER[HTTP_ACCEPT_LANGUAGE]}'");

  } elseif (($_SERVER[REMOTE_ADDR] != "127.0.0.1") && ($_SESSION[width])) {

	  mysql_query("INSERT INTO `devData` ( `ip` , `os` , `browser` , `width` , `height` , `http_user_agent` , `request_time` , `ua_cpu` , `accept_language` , `hits` ) VALUES ('{$_SERVER[REMOTE_ADDR]}', '{$_SESSION[os]}', '{$_SESSION[browser]}', '{$_SESSION[width]}', '{$_SESSION[height]}', '$_SERVER[HTTP_USER_AGENT]', '{$_SERVER[REQUEST_TIME]}', '{$_SERVER[HTTP_UA_CPU]}', '{$_SERVER[HTTP_ACCEPT_LANGUAGE]}', '1')");

	}

}

function formatCSS ($mode) {

  $defaultsmall = "12px";

  $defaultlarge = "15px";

	$spaceMod1 = "8px";

	$spaceMod2 = "8px";

	$heightMod = "450px";

  if (($_SESSION[os] == "Linux") || ($_SESSION[os] == "Macintosh")) {

		$usefont = "arial";

		$spaceMod3 = "12px";

		if ($_SESSION[browser] == "Konqueror") {

			$spaceMod1 = "5px";

			$spaceMod3 = "10px";			

		}

	} elseif ($_SESSION[os] == "Windows") {

		$usefont = "tahoma";

		$spaceMod3 = "13px";

	}

	switch ($_SESSION[width]) {

		default: #800x600 and default

			$overall = ($_SESSION[width]-40)."px";

			$top2 = ($_SESSION[width]-230)."px";

			$top2half = (($_SESSION[width]-230) / 2)."px";

			$footcenter = ($_SESSION[width]-58)."px";

			$col1of2 = "495px";

			$col2of2 = "242px";

			$colby3 = "242px";

			if ($_GET[pageMode1] == "req") {

				$heightMod = "720px";

				$hinputwidthmod = "width: 228px;";

				$inputwidthmod = "width: 130px;";

				$checkboxmod = "width: 474px;";

	  		$checkboxtd = "width: 16px;";

	  		$checkboxtypetd = "width: 101px;";

	  		$bigboxmod = "height: 242px; width: 457px;";

			} else {

				$toursubwidth = "width: 232px;";

			}

		break;

	  case "1024": #1024x768

			$overall = ($_SESSION[width]-40)."px";

			$top2 = ($_SESSION[width]-230)."px";

			$top2half = (($_SESSION[width]-230) / 2)."px";

			$footcenter = ($_SESSION[width]-58)."px";

			$col1of2 = "645px";

			$col2of2 = "316px";

			$colby3 = "316px";

			if ($_GET[pageMode1] == "req") {

				$heightMod = "720px";

				$hinputwidthmod = "width: 306px;";

				$inputwidthmod = "width: 210px;";

				$checkboxmod = "width: 674px;";

	  		$checkboxtd = "width: 16px;";

	  		$checkboxtypetd = "width: 129px;";

	  		$bigboxmod = "height: 242px; width: 618px;";

			} else {

				$toursubwidth = "width: 296px;";

			}

		break;

	  case "1280": #1280x1024

			$overall = ($_SESSION[width]-40)."px";

			$top2 = ($_SESSION[width]-230)."px";

			$top2half = (($_SESSION[width]-230) / 2)."px";

			$footcenter = ($_SESSION[width]-58)."px";

			$col1of2 = "815px";

			$col2of2 = "402px";	

			$colby3 = "402px";

			$defaultsmall = "14px";

			$defaultlarge = "17px";

			if ($_SESSION['browser'] == "Konqueror") {

			  $spaceMod1 = "1px";

			  $spaceMod2 = "4px";

			  $spaceMod3 = "2px";			  

			} else {

			  $spaceMod1 = "5px";

			  $spaceMod2 = "5px";

			  $spaceMod3 = "4px";

			}

			if ($_GET[pageMode1] == "req") {

				$heightMod = "820px";

				$hinputwidthmod = "width: 382px;";

				$inputwidthmod = "width: 262px;";

				$checkboxmod = "width: 842px;";

	  		$checkboxtd = "width: 16px;";

	  		$checkboxtypetd = "width: 161px;";

	  		$bigboxmod = "height: 322px; width: 772px;";

			} else {

				$toursubwidth = "width: 370px;";

				$heightMod = "550px";

			}

		break;

	  case "1600":  #1600x1200

			if ($_GET[pageMode1] == "req") {

				$heightMod = "820px";

				$hinputwidthmod = "width: 382px;";

				$inputwidthmod = "width: 262px;";

				$checkboxmod = "width: 842px;";

	  		$checkboxtd = "width: 16px;";

	  		$checkboxtypetd = "width: 161px;";

	  		$bigboxmod = "height: 322px; width: 772px;";

			} else {

				$toursubwidth = "width: 462px;";

				$heightMod = "687px";

			}

			$overall = ($_SESSION[width]-40)."px";

			$top2 = ($_SESSION[width]-230)."px";

			$top2half = (($_SESSION[width]-230) / 2)."px";

			$footcenter = ($_SESSION[width]-58)."px";

			$col1of2 = "644px";

			$col2of2 = "317px";	

		break;		  

	}

  $retthis = <<< EONA

<style type="text/css">

body {margin: 0; margin-right: 0;padding: 0; background: #fff; font: $defaultsmall $usefont; color: #0099FF; text-align: center;}

* {padding: 0; margin: 0; border:0;}

a:link {text-decoration: none; font: $defaultsmall $usefont; color: #0099FF;}

a:visited	{text-decoration: none; font: $defaultsmall $usefont; color: #0099FF;}

a:hover	{text-decoration: underline; font: $defaultsmall $usefont; color: #0099FF;}

#main_holder {width: $overall; height: $totalheight; text-align: center; margin: 10px auto 0 auto; overflow: hidden;}

ul, ul li	{list-style-type: none;}



.tops {height: 157px; border: 0; float: left;}

#top1	{background: url('logo1.jpg') no-repeat; width: 156px;}

#top2	{background: url('logo2.jpg') repeat-x; width: $top2; font: $defaultsmall $usefont; color: #fff; text-align: left; padding-left: 14px;}

#top3 {background: url('logo3.jpg') no-repeat; width: 16px;}



#logo_holder {width: $top2half; float: left;}

#logo_part1 {padding-top: $spaceMod1;}

#logo_part2 {width: $top2half; float: left; text-align: right; padding-top: $spaceMod2;}



div#buttons_holder {clear: both; padding-top: $spaceMod3;}

ul.buttons, ul li.buttons, ul li.buttons a:link	{display: inline; color: #fff;}

ul li.buttons a:visited	{display: inline; color: #fff;}



.col_holder {float: left; border-left: 1px solid #ccc; padding-left: 10px; overflow: hidden; height: $heightMod;}

.col {clear: both; font: $defaultlarge $usefont; color: #003399; font-weight: bold; text-align: left;}

#hcol1of2 {width: $col1of2;}

#col1of2	{width: $col1of2;}

#hcol2of2 {width: $col2of2; border-right: 1px solid #ccc;}

#col2of2	{width: $col2of2;}

#hcol1of3	{width: $colby3;}

#hcol2of3	{width: $colby3;}

#hcol3of3	{width: $colby3; border-right: 1px solid #ccc;}

#col1of3	{width: $colby3;}

#col2of3	{width: $colby3;}

#col3of3	{width: $colby3;}



.spacer {width: $overall; clear: both; height: 10px;}

#foot_holder {width: $overall; clear: both; ; padding-bottom: 10px; margin-bottom: 10px;}

#foot_left {background: url('foot1.jpg') no-repeat; width: 9px; height: 27px; border: 0; float: left;}

#foot_center {background: url('foot2.jpg') repeat-x; width: $footcenter; height: 27px; border: 0; float: left;}

#foot_right {background: url('foot3.jpg') no-repeat; width: 9px; height: 27px; border: 0; float: left;}

EONA;



	if ($_GET[pageMode1] == "req") {

		$retthis.="

			.mission				 {clear: both; padding-right: 12px; margin-top: 10px; font: $defaultsmall $usefont; color: #006699;}

			.contentholder   {padding-left: 10px; font: $defaultsmall $usefont; background: #fff; color: #006699; height: $heightMod}

			.formexplination {font: $defaultsmall $usefont; padding-bottom: 12px; padding-right: 10px;}

			.sectiontitle    {clear: both; color: #003399; text-align: left; font: 13px tahoma; font-weight: bold; padding-bottom: 3px;}

			.input_holder    {float: left; text-align: right; padding-right: 10px; $hinputwidthmod}

			.input_style     {font: $defaultsmall $usefont; color: #000; border: 1px solid #000; padding-left: 2px;$inputwidthmod}

			.checkbox_row		 {text-align: center; padding-bottom: 10px; $checkboxmod}

			.checkbox_td		 {padding-top: 4px;$checkboxtd}

			.checkbox_type	 {padding-top: 4px;$checkboxtypetd}

			#bigbox					 {border: 1px solid #000; padding: 3px; margin-bottom: 5px; float: left; $bigboxmod}";

			

	} else {

	  $retthis.="

			.tours 					{list-style-type: none; font: $defaultsmall $usefont; color: #6699CC; font-weight: bold;}

			.tour_types, .tour_types a:link, .tour_types a:visited

											{list-style-type: none; font: $defaultsmall $usefont; color: #006699; text-decoration: none;}

			.tour_types a:hover

											{list-style-type: none; font: $defaultsmall $usefont; color: #0099FF; text-decoration: none;}

			.tour_button 		{border-bottom: 1px solid #fff}

			.news_heading		{width: 229px; clear: both; font: $defaultsmall $usefont; color:#6699CC; text-align: left; margin-top: 10px; font-weight: bold;}

			.news_heading1	{clear: both; font: $defaultsmall $usefont; color:#6699CC; text-align: left; margin-top: 0; padding-bottom: 2px; border-bottom: 1px solid #999; font-weight: bold;$toursubwidth}

			.news_body			{clear: both; font: $defaultsmall $usefont; color: #006699; text-align: left;$toursubwidth}

			.mission				{width: 232px; clear: both; padding-right: 10px; margin-top: 10px; font: $defaultsmall $usefont; color: #0099FF;}

			.prevlink				{width: 161px; font: $defaultsmall $usefont; color: #0099FF; float: left; text-align: right;}

			.nextlink				{width: 161px; font: $defaultsmall $usefont; color: #0099FF; float: left; text-align: left;}

			.returnlink			{width: 485px; text-align: center; padding-bottom: 5px;}

			.replaylink			{width: 161px; font: 11px tahoma; color: #0099FF; float: left; text-align: center;}

			.toursub				{list-style-type: none; font: $defaultsmall $usefont; color: #006699; margin-top: 10px; padding-left: 10px; height: 300px;$toursubwidth}

			.toursubholder	{position: relative; visibility: hidden;}";			

	}

	return $retthis;

}