Last active
August 29, 2015 14:26
-
-
Save skahack/a5253b5efe194c49de2e to your computer and use it in GitHub Desktop.
ykkap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyTemplate { | |
function show($tpl_file_path) { | |
extract((array)$this); | |
include($tpl_file_path); | |
} | |
} | |
$tpl = new MyTemplate(); | |
if (isset($_GET['_escaped_fragment_'])) { | |
$path_correct = false; | |
if (preg_match('/^([a-zA-Z0-9]+\/*)+$/', $_GET['_escaped_fragment_'])) { | |
$hash = $_GET['_escaped_fragment_']; | |
$hash = preg_replace('/\/$/', '', $hash); | |
$path = preg_split('/\//', $hash); | |
$cate_json = file_get_contents('inc/category.json'); | |
if (preg_match("/^efbbbf/", bin2hex($cate_json))) { | |
$cate_json = substr($cate_json, 3); | |
} | |
$cate_obj = json_decode($cate_json, true); | |
$tpl->cate = $cate_obj; | |
if (1 <= count($path) && count($path) <= 3) { | |
if (count($path) === 1 && ($path[0] === 'all')) { | |
$path_correct = true; | |
$tpl->categories = $cate_obj; | |
} else { | |
foreach ($cate_obj as $cate_item) { | |
if ($cate_item['id'] == $path[0]) { | |
if (count($path) === 1) { | |
$path_correct = true; | |
$tpl->cate_id = $cate_item['id']; | |
$tpl->genres = $cate_item['items']; | |
// meta | |
$tpl->page_title = $cate_item['page_title']; | |
$tpl->page_description = $cate_item['page_description']; | |
$tpl->page_keywords = $cate_item['page_keywords']; | |
} else if (isset($cate_item['items']) && 0 < count($cate_item['items'])) { | |
foreach ($cate_item['items'] as $item_obj) { | |
if ($item_obj['id'] == $path[1]) { | |
if (count($path) === 2) { | |
$path_correct = true; | |
$tpl->cate_id = $cate_item['id']; | |
$tpl->genre_id = $path[1]; | |
$list_json = file_get_contents($path[0] . '/' . $path[1] . '/inc/list.json'); | |
if (preg_match("/^efbbbf/", bin2hex($list_json))) { | |
$list_json = substr($list_json, 3); | |
} | |
$list_obj = json_decode($list_json, true); | |
$tpl->list = $list_obj; | |
// meta | |
$tpl->page_title = $item_obj['page_title']; | |
$tpl->page_description = $item_obj['page_description']; | |
$tpl->page_keywords = $item_obj['page_keywords']; | |
} elseif (file_exists($path[0].'/'.$path[1].'/inc/'.$path[2].'.json')) { | |
$path_correct = true; | |
$tpl->cate_id = $cate_item['id']; | |
$tpl->genre_id = $path[1]; | |
$list_json = file_get_contents($path[0].'/'.$path[1].'/inc/'.$path[2].'.json'); | |
if (preg_match("/^efbbbf/", bin2hex($list_json))) { | |
$list_json = substr($list_json, 3); | |
} | |
$list_obj = json_decode($list_json, true); | |
$tpl->list = array($list_obj); | |
// meta | |
$tpl->page_title = $list_obj['page_title']; | |
$tpl->page_description = $list_obj['page_description']; | |
$tpl->page_keywords = $list_obj['page_keywords']; | |
} | |
} | |
} | |
} | |
break; | |
} | |
} | |
} | |
} | |
$tpl->show('./index_content.html'); | |
} | |
} else { | |
$tpl->show('./index_content.html'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment