commit
						ae3ee1fe79
					
				| @ -69,7 +69,7 @@ abstract class BaseConfig implements Config { | |||||||
| 		$this->save($name); | 		$this->save($name); | ||||||
| 	} | 	} | ||||||
| 	public function set_array(/*string*/ $name, $value) { | 	public function set_array(/*string*/ $name, $value) { | ||||||
| 		assert(is_array($value)); | 		assert(isset($value) && is_array($value)); | ||||||
| 		$this->values[$name] = implode(",", $value); | 		$this->values[$name] = implode(",", $value); | ||||||
| 		$this->save($name); | 		$this->save($name); | ||||||
| 	} | 	} | ||||||
| @ -90,7 +90,7 @@ abstract class BaseConfig implements Config { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	public function set_default_array(/*string*/ $name, $value) { | 	public function set_default_array(/*string*/ $name, $value) { | ||||||
| 		assert(is_array($value)); | 		assert(isset($value) && is_array($value)); | ||||||
| 		if(is_null($this->get($name))) { | 		if(is_null($this->get($name))) { | ||||||
| 			$this->values[$name] = implode(",", $value); | 			$this->values[$name] = implode(",", $value); | ||||||
| 		} | 		} | ||||||
|  | |||||||
| @ -150,7 +150,7 @@ class Image { | |||||||
| 		global $database; | 		global $database; | ||||||
| 		$tag_count = count($tags); | 		$tag_count = count($tags); | ||||||
| 		 | 		 | ||||||
| 		if($tag_count == 0) { | 		if($tag_count === 0) { | ||||||
| 			$total = $database->cache->get("image-count"); | 			$total = $database->cache->get("image-count"); | ||||||
| 			if(!$total) { | 			if(!$total) { | ||||||
| 				$total = $database->get_one("SELECT COUNT(*) FROM images"); | 				$total = $database->get_one("SELECT COUNT(*) FROM images"); | ||||||
| @ -158,7 +158,7 @@ class Image { | |||||||
| 			} | 			} | ||||||
| 			return $total; | 			return $total; | ||||||
| 		} | 		} | ||||||
| 		else if($tag_count == 1 && !preg_match("/[:=><\*\?]/", $tags[0])) { | 		else if($tag_count === 1 && !preg_match("/[:=><\*\?]/", $tags[0])) { | ||||||
| 			$term = Tag::resolve_alias($tags[0]); | 			$term = Tag::resolve_alias($tags[0]); | ||||||
| 			return $database->get_one( | 			return $database->get_one( | ||||||
| 				$database->scoreql_to_sql("SELECT count FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"), | 				$database->scoreql_to_sql("SELECT count FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"), | ||||||
| @ -207,7 +207,7 @@ class Image { | |||||||
| 			$dir = "ASC"; | 			$dir = "ASC"; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if(count($tags) == 0) { | 		if(count($tags) === 0) { | ||||||
| 			$row = $database->get_row('SELECT images.* FROM images WHERE images.id '.$gtlt.' '.$this->id.' ORDER BY images.id '.$dir.' LIMIT 1'); | 			$row = $database->get_row('SELECT images.* FROM images WHERE images.id '.$gtlt.' '.$this->id.' ORDER BY images.id '.$dir.' LIMIT 1'); | ||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| @ -587,11 +587,11 @@ class Image { | |||||||
| 					$parts_count = count($parts); | 					$parts_count = count($parts); | ||||||
| 					$opt_val = ""; | 					$opt_val = ""; | ||||||
| 					$opt_weight = 0; | 					$opt_weight = 0; | ||||||
| 					if($parts_count == 2) { | 					if($parts_count === 2) { | ||||||
| 						$opt_val = $parts[0]; | 						$opt_val = $parts[0]; | ||||||
| 						$opt_weight = $parts[1]; | 						$opt_weight = $parts[1]; | ||||||
| 					} | 					} | ||||||
| 					elseif($parts_count == 1) { | 					elseif($parts_count === 1) { | ||||||
| 						$opt_val = $parts[0]; | 						$opt_val = $parts[0]; | ||||||
| 						$opt_weight = 1; | 						$opt_weight = 1; | ||||||
| 					} | 					} | ||||||
| @ -694,9 +694,11 @@ class Image { | |||||||
| 		} | 		} | ||||||
| 		$img_search = new Querylet($sql, $terms); | 		$img_search = new Querylet($sql, $terms); | ||||||
| 
 | 
 | ||||||
|  | 		// How many tag querylets are there?
 | ||||||
|  | 		$count_tag_querylets = count($tag_querylets); | ||||||
| 
 | 
 | ||||||
| 		// no tags, do a simple search (+image metadata if we have any)
 | 		// no tags, do a simple search (+image metadata if we have any)
 | ||||||
| 		if(count($tag_querylets) == 0) { | 		if($count_tag_querylets === 0) { | ||||||
| 			$query = new Querylet("SELECT images.* FROM images "); | 			$query = new Querylet("SELECT images.* FROM images "); | ||||||
| 
 | 
 | ||||||
| 			if(!empty($img_search->sql)) { | 			if(!empty($img_search->sql)) { | ||||||
| @ -706,7 +708,7 @@ class Image { | |||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		// one positive tag (a common case), do an optimised search
 | 		// one positive tag (a common case), do an optimised search
 | ||||||
| 		else if(count($tag_querylets) == 1 && $tag_querylets[0]->positive) { | 		else if($count_tag_querylets === 1 && $tag_querylets[0]->positive) { | ||||||
| 			$query = new Querylet($database->scoreql_to_sql(" | 			$query = new Querylet($database->scoreql_to_sql(" | ||||||
| 				SELECT images.* FROM images | 				SELECT images.* FROM images | ||||||
| 				JOIN image_tags ON images.id=image_tags.image_id | 				JOIN image_tags ON images.id=image_tags.image_id | ||||||
| @ -990,7 +992,7 @@ class Tag { | |||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if(count($tag_array) == 0 && $tagme) { | 		if(count($tag_array) === 0 && $tagme) { | ||||||
| 			$tag_array = array("tagme"); | 			$tag_array = array("tagme"); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| @ -1106,8 +1108,8 @@ function move_upload_to_archive(DataUploadEvent $event) { | |||||||
| function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) { | function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) { | ||||||
| 	global $config; | 	global $config; | ||||||
| 
 | 
 | ||||||
| 	if($orig_width == 0) $orig_width = 192; | 	if($orig_width === 0) $orig_width = 192; | ||||||
| 	if($orig_height == 0) $orig_height = 192; | 	if($orig_height === 0) $orig_height = 192; | ||||||
| 
 | 
 | ||||||
| 	if($orig_width > $orig_height * 5) $orig_width = $orig_height * 5; | 	if($orig_width > $orig_height * 5) $orig_width = $orig_height * 5; | ||||||
| 	if($orig_height > $orig_width * 5) $orig_height = $orig_width * 5; | 	if($orig_height > $orig_width * 5) $orig_height = $orig_width * 5; | ||||||
|  | |||||||
| @ -797,7 +797,7 @@ function data_path($filename) { | |||||||
| function transload($url, $mfile) { | function transload($url, $mfile) { | ||||||
| 	global $config; | 	global $config; | ||||||
| 
 | 
 | ||||||
| 	if($config->get_string("transload_engine") == "curl" && function_exists("curl_init")) { | 	if($config->get_string("transload_engine") === "curl" && function_exists("curl_init")) { | ||||||
| 		$ch = curl_init($url); | 		$ch = curl_init($url); | ||||||
| 		$fp = fopen($mfile, "w"); | 		$fp = fopen($mfile, "w"); | ||||||
| 
 | 
 | ||||||
| @ -814,7 +814,7 @@ function transload($url, $mfile) { | |||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if($config->get_string("transload_engine") == "wget") { | 	if($config->get_string("transload_engine") === "wget") { | ||||||
| 		$s_url = escapeshellarg($url); | 		$s_url = escapeshellarg($url); | ||||||
| 		$s_mfile = escapeshellarg($mfile); | 		$s_mfile = escapeshellarg($mfile); | ||||||
| 		system("wget --no-check-certificate $s_url --output-document=$s_mfile"); | 		system("wget --no-check-certificate $s_url --output-document=$s_mfile"); | ||||||
| @ -822,7 +822,7 @@ function transload($url, $mfile) { | |||||||
| 		return file_exists($mfile); | 		return file_exists($mfile); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if($config->get_string("transload_engine") == "fopen") { | 	if($config->get_string("transload_engine") === "fopen") { | ||||||
| 		$fp = @fopen($url, "r"); | 		$fp = @fopen($url, "r"); | ||||||
| 		if(!$fp) { | 		if(!$fp) { | ||||||
| 			return false; | 			return false; | ||||||
|  | |||||||
| @ -112,7 +112,7 @@ class Artists extends Extension { | |||||||
|         global $database; |         global $database; | ||||||
| 
 | 
 | ||||||
|         $author = strtolower($event->author); |         $author = strtolower($event->author); | ||||||
|         if (strlen($author) == 0 || strpos($author, " ")) |         if (strlen($author) === 0 || strpos($author, " ")) | ||||||
|            return; |            return; | ||||||
| 
 | 
 | ||||||
|         $paddedAuthor = str_replace(" ", "_", $author); |         $paddedAuthor = str_replace(" ", "_", $author); | ||||||
| @ -709,7 +709,7 @@ class Artists extends Extension { | |||||||
|         if (is_null($aliasID) || !is_numeric($aliasID)) |         if (is_null($aliasID) || !is_numeric($aliasID)) | ||||||
|             return; |             return; | ||||||
| 
 | 
 | ||||||
|         if (is_null($alias) || strlen($alias) == 0) |         if (is_null($alias) || strlen($alias) === 0) | ||||||
|             return; |             return; | ||||||
| 
 | 
 | ||||||
|         global $user; |         global $user; | ||||||
| @ -767,7 +767,7 @@ class Artists extends Extension { | |||||||
|         if (is_null($memberID) || !is_numeric($memberID)) |         if (is_null($memberID) || !is_numeric($memberID)) | ||||||
|             return; |             return; | ||||||
| 
 | 
 | ||||||
|         if (is_null($memberName) || strlen($memberName) == 0) |         if (is_null($memberName) || strlen($memberName) === 0) | ||||||
|             return; |             return; | ||||||
| 
 | 
 | ||||||
|          global $user; |          global $user; | ||||||
| @ -796,7 +796,7 @@ class Artists extends Extension { | |||||||
|         global $user; |         global $user; | ||||||
| 
 | 
 | ||||||
|         $name = html_escape(strtolower($_POST["name"])); |         $name = html_escape(strtolower($_POST["name"])); | ||||||
|         if (is_null($name) || (strlen($name) == 0) || strpos($name, " ")) |         if (is_null($name) || (strlen($name) === 0) || strpos($name, " ")) | ||||||
|             return -1; |             return -1; | ||||||
| 
 | 
 | ||||||
|         $notes = html_escape(ucfirst($_POST["notes"])); |         $notes = html_escape(ucfirst($_POST["notes"])); | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ | |||||||
| 	$ys = ys($log); | 	$ys = ys($log); | ||||||
| 	$posts = $ys->posts(); | 	$posts = $ys->posts(); | ||||||
| 
 | 
 | ||||||
| 	if (sizeof($posts) == 0) | 	if (sizeof($posts) === 0) | ||||||
| 		$html .= ' | 		$html .= ' | ||||||
| 			<div id="ys-post-1" class="ys-post ys-first ys-admin-post"> | 			<div id="ys-post-1" class="ys-post ys-first ys-admin-post"> | ||||||
| 				<span class="ys-post-timestamp">13:37</span> | 				<span class="ys-post-timestamp">13:37</span> | ||||||
|  | |||||||
| @ -162,10 +162,13 @@ class Index extends Extension { | |||||||
| 			$search_terms = $event->get_search_terms(); | 			$search_terms = $event->get_search_terms(); | ||||||
| 			$page_number = $event->get_page_number(); | 			$page_number = $event->get_page_number(); | ||||||
| 			$page_size = $event->get_page_size(); | 			$page_size = $event->get_page_size(); | ||||||
|  |              | ||||||
|  | 			$count_search_terms = count($search_terms); | ||||||
|  |              | ||||||
| 			try { | 			try { | ||||||
| 				#log_debug("index", "Search for ".implode(" ", $search_terms), false, array("terms"=>$search_terms));
 | 				#log_debug("index", "Search for ".implode(" ", $search_terms), false, array("terms"=>$search_terms));
 | ||||||
| 				$total_pages = Image::count_pages($search_terms); | 				$total_pages = Image::count_pages($search_terms); | ||||||
| 				if(SPEED_HAX && count($search_terms) == 0 && ($page_number < 10)) { // extra caching for the first few post/list pages
 | 				if(SPEED_HAX && $count_search_terms === 0 && ($page_number < 10)) { // extra caching for the first few post/list pages
 | ||||||
| 					$images = $database->cache->get("post-list-$page_number"); | 					$images = $database->cache->get("post-list-$page_number"); | ||||||
| 					if(!$images) { | 					if(!$images) { | ||||||
| 						$images = Image::find_images(($page_number-1)*$page_size, $page_size, $search_terms); | 						$images = Image::find_images(($page_number-1)*$page_size, $page_size, $search_terms); | ||||||
| @ -182,11 +185,13 @@ class Index extends Extension { | |||||||
| 				$images = array(); | 				$images = array(); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			if(count($search_terms) == 0 && count($images) == 0 && $page_number == 1) { | 			$count_images = count($images); | ||||||
|  |              | ||||||
|  | 			if($count_search_terms === 0 && $count_images === 0 && $page_number === 1) { | ||||||
| 				$this->theme->display_intro($page); | 				$this->theme->display_intro($page); | ||||||
| 				send_event(new PostListBuildingEvent($search_terms)); | 				send_event(new PostListBuildingEvent($search_terms)); | ||||||
| 			} | 			} | ||||||
| 			else if(count($search_terms) > 0 && count($images) == 1 && $page_number == 1) { | 			else if($count_search_terms > 0 && $count_images === 1 && $page_number === 1) { | ||||||
| 				$page->set_mode("redirect"); | 				$page->set_mode("redirect"); | ||||||
| 				$page->set_redirect(make_link('post/view/'.$images[0]->id)); | 				$page->set_redirect(make_link('post/view/'.$images[0]->id)); | ||||||
| 			} | 			} | ||||||
|  | |||||||
| @ -256,7 +256,9 @@ EOD; | |||||||
| 			$url=$matches[1][0]; | 			$url=$matches[1][0]; | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		for($i=0;$i<count($pages_matched);$i++) { | 		$count_pages_matched = count($pages_matched); | ||||||
|  | 		 | ||||||
|  | 		for($i=0; $i < $count_pages_matched; $i++) { | ||||||
| 			if($url == $pages_matched[$i]) { | 			if($url == $pages_matched[$i]) { | ||||||
| 				$html = "<li class='current-page'><a href='$link'>$desc</a></li>"; | 				$html = "<li class='current-page'><a href='$link'>$desc</a></li>"; | ||||||
| 			} | 			} | ||||||
|  | |||||||
| @ -282,7 +282,9 @@ EOD; | |||||||
| 			$url=$matches[1][0]; | 			$url=$matches[1][0]; | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		for($i=0;$i<count($pages_matched);$i++) { | 		$count_pages_matched = count($pages_matched); | ||||||
|  | 		 | ||||||
|  | 		for($i=0; $i < $count_pages_matched; $i++) { | ||||||
| 			if($url == $pages_matched[$i]) { | 			if($url == $pages_matched[$i]) { | ||||||
| 				$html = "<li class='current-page'><a href='$link'>$desc</a></li>"; | 				$html = "<li class='current-page'><a href='$link'>$desc</a></li>"; | ||||||
| 			} | 			} | ||||||
|  | |||||||
| @ -245,12 +245,16 @@ EOD; | |||||||
| 			$url=$matches[1][0]; | 			$url=$matches[1][0]; | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		for($i=0;$i<count($pages_matched);$i++) { | 		$count_pages_matched = count($pages_matched); | ||||||
|  | 		 | ||||||
|  | 		for($i=0; $i < $count_pages_matched; $i++) { | ||||||
| 			if($url == $pages_matched[$i]) { | 			if($url == $pages_matched[$i]) { | ||||||
| 				$html = "<a class='tab-selected' href='$link'>$desc</a>"; | 				$html = "<a class='tab-selected' href='$link'>$desc</a>"; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | 		 | ||||||
| 		if(is_null($html)) {$html = "<a class='tab' href='$link'>$desc</a>";} | 		if(is_null($html)) {$html = "<a class='tab' href='$link'>$desc</a>";} | ||||||
|  | 		 | ||||||
| 		return $html; | 		return $html; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user