Beispiel #1
0
	function slideshow() {
		global $check; global $def; global $sets; global $url;
		$types = array ('tag','author','category','mixed','date','pool');
		if (in_array(query::$get['type'],$types) && $check->num(query::$get['id'])) {
			$limit = ' order by sortdate desc limit '.(query::$get['id'] - 1).', 5'; $area_prefix = 'area="'.$def['area'][0].'" and ';
			switch (query::$get['type']) {
				case "mixed":
					$url['area'] = 'main';  $area_prefix = '';
					$area = "(".engine::mixed_make_sql(engine::mixed_parse(html_entity_decode(urldecode(query::$get['area'])))).")";
					break;
				case "date":
					$parts = explode('-',query::$get['area']);
					if (is_numeric($parts[0].$parts[1].$parts[2]) && count($parts) == 3)
						$area = '(pretty_date ="'.obj::transform('text')->rumonth($parts[1]).' '.$parts[2].', '.$parts[0].'")';
					break;
				case "pool":
					$pool = Database::order('order', 'asc')
						->limit(5, query::$get['id'] - 1)
						->get_vector('art_in_pool', 'art_id', 'pool_id = ?', query::$get['area']);

					$area = "(id=".implode(' or id=',$pool).")";
					$limit = ''; $area_prefix = '';

					break;
				default:
					$area = '(locate("|'.urldecode(query::$get['area']).'|",art.'.query::$get['type'].'))';
			}
			if (!$sets['show']['nsfw'] && query::$get['type'] != 'pool')
				$area .= ' and !locate("|nsfw|",art.category)';
			elseif ($sets['show']['nsfw'] && query::$get['type'] != 'pool') {
				if (!$sets['show']['yaoi']) $area .= ' and !(locate("|yaoi|",art.tag) and locate("|nsfw|",art.category))';
				if (!$sets['show']['furry']) $area .= ' and !(locate("|furry|",art.tag) and locate("|nsfw|",art.category))';
				if (!$sets['show']['guro']) $area .= ' and !(locate("|guro|",art.tag) and locate("|nsfw|",art.category))';
			}
			$return = obj::db()->sql('select id, md5, extension, resized from art where ('.$area_prefix.$area.')'.$limit,'id');
			if (query::$get['type'] == 'pool') {
				$_return = $return; unset($return);
				foreach ($pool as $one) $return[$one] = $_return[$one];
			}
			if (is_array($return)) {
				foreach ($return as &$art) {
					if (!$art['resized']) $sizes = getimagesize('images/booru/full/'.$art['md5'].'.'.$art['extension']);
					else $sizes = getimagesize('images/booru/resized/'.$art['md5'].'.jpg');
					$art['height'] = $sizes[1];
				}
				if ($sets['show']['translation']) {
					$where = 'art_id='.implode(' or art_id=',array_keys($return));
					$translations = obj::db()->sql('select art_id, data from art_translation where ('.$where.' and active = 1)','art_id');
					if (is_array($translations)) foreach ($translations as $key => $translation) {
						$return[$key]['translations']['full'] = unserialize(base64_decode($translation));
						if ($return[$key]['resized'] && is_array($return[$key]['translations']['full'])) {
							$size = explode('x',$return[$key]['resized']);
							$coeff = $size[0] / $def['booru']['resizewidth'];
							foreach ($return[$key]['translations']['full'] as $one) {
								foreach ($one as $field => &$param) if ($field != 'text') $param = round($param / $coeff);
								$return[$key]['translations']['resized'][] = $one;
							}
						}
					}
				}
				return $return;
			}
			else die ("finish");
		}
	}