header.php, search.php, includes/- corefunctions.php, upload_class.php: Security - local file inclusion/directory traversal and encode echoed terms patches - from @ariadoss
header.php, search.php, includes/- corefunctions.php, upload_class.php: Security - local file inclusion/directory traversal and encode echoed terms patches - from @ariadoss

file:a/header.php -> file:b/header.php
--- a/header.php
+++ b/header.php
@@ -145,7 +145,7 @@
 require_once("includes/get_session_vars.php");
 
 if(isset($_GET['skin'])) {
-	$siteskin = $_GET['skin'];
+	$siteskin = basename($_GET['skin']);
 	$_SESSION[SITEKEY."_skin"] = $siteskin;
 }
 
@@ -200,7 +200,7 @@
 if(isset($_GET['ageconsent'])) $_SESSION[SITEKEY."_ageconsent"] = 1;
 if(isset($_GET['warning'])) $_SESSION[SITEKEY."_warned"][$_GET['warning']] = 1;
 
-
+$siteskin = basename((string)$siteskin);
 if(is_dir(_BASEDIR."skins/$siteskin")) $skindir = _BASEDIR."skins/$siteskin";
 else if(is_dir(_BASEDIR."skins/".$settings['skin'])) $skindir = _BASEDIR."skins/".$defaultskin;
 else $skindir = _BASEDIR."default_tpls";

--- a/includes/corefunctions.php
+++ b/includes/corefunctions.php
@@ -574,8 +574,8 @@
 		$termArray = array_merge($_GET, $_POST);
 		$terms = array();
 		foreach($termArray as $term => $value) {
-			if($term == "submit" || $term == "go" || $term == "offset" || ($term != "complete" &&empty($value))) continue;
-			$terms[] = "$term=".(is_array($value) ? implode(",", $value) : $value);
+			if($term == "submit" || $term == "go" || $term == "offset" || ($term != "complete" && empty($value))) continue;
+			$terms[] = "$term=".(is_array($value) ? implode(",", array_map('htmlspecialchars', $value)) : htmlspecialchars($value, ENT_QUOTES));
 		}
 		$terms = implode("&", $terms);
 		$terms .= "&";

--- a/includes/upload_class.php
+++ b/includes/upload_class.php
@@ -57,7 +57,7 @@
 			sleep(3);
 			$name = $name.$this->get_extension($this->the_file);
 		} else {
-			$name = str_replace(" ", "_", $this->the_file); // space will result in problems on linux systems
+			$name = basename(str_replace("\\", "/", str_replace(" ", "_", $this->the_file))); // space will result in problems on linux systems
 		}
 		return $name;
 	}

file:a/search.php -> file:b/search.php
--- a/search.php
+++ b/search.php
@@ -236,7 +236,7 @@
 	$termsList = array();
 	foreach($termArray as $term => $value) {
 		if($term == "submit" || $term == "wordhigh" || $term == "wordlow" || empty($value) || $term == "formname" || $term == "searchtype") continue;
-		$termsList[$term] = "$term=".(is_array($value) ? implode(",", $value) : $value);
+		$termsList[$term] = "$term=".(is_array($value) ? implode(",", array_map('htmlspecialchars', $value)) : htmlspecialchars($value, ENT_QUOTES));
 	}
 	$terms = implode("&", $termsList);
 	if(!empty($scountquery)) {