鏤??php require_once('smarty/Smarty.class.php'); define('LINK_PER_PAGE',30); main(); function main() { DynamicSmarty::init(); $inst =& new LinkList; $inst->execute(); DynamicSmarty::release(); } class LinkList { function execute() { $query = $this->getquery(); $queryindex = 0; if($query == 0 || $query == 1) { $queryindex = 0; }else{ $queryindex = $query - 1; } $list = $this->getlist(); $pagecount = count($list); if($queryindex >= $pagecount) { $queryindex = $pagecount - 1; } $smarty =& DynamicSmarty::createSmarty(); $smarty->assign('linklist',$list[$queryindex]); $smarty->assign('pagelist',range(1,$pagecount)); $smarty->assign('current_number',$queryindex + 1); $smarty->assign('pagecap',($queryindex == 0 ? '' : sprintf('%s%s',$queryindex + 1,'???若?悟??))); $smarty->assign('base',($query == 0 ? '..' : '../..')); $smarty->display('osusume.tpl'); } function getlist() { $list = @file_get_contents('list.txt'); if($list === false) return array(); $reallist = array(); $index = 0; $list = explode("\n",str_replace("\r","",$list)); foreach($list as $item) { $reallist[(int)($index / LINK_PER_PAGE)][] = $item; $index++; } return $reallist; } function getquery() { if(isset($_SERVER['PATH_INFO'])) { if(ereg('^/([0-9]+)\.html$',$_SERVER['PATH_INFO'],$ref)) { return $ref[1]; }else{ return 0; } }else{ return 0; } } } class DynamicSmarty { function init() { if(!function_exists('sys_get_temp_dir')) { function sys_get_temp_dir() { if(!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); }else if(!empty($_ENV['TMPDIR'])) { return realpath($_ENV['TMPDIR']); }else if(!empty($_ENV['TEMP'])) { return realpath($_ENV['TEMP']); }else{ $temp_file = tempnam(md5(uniqid(rand(),true)),''); if($temp_file) { $temp_dir = realpath(dirname($temp_file)); unlink($temp_file); return $temp_dir; }else{ return FALSE; } } } } } function getBaseSmartyDir() { $dir = sprintf('%s/viaMFEn8buah3kjz/',sys_get_temp_dir()); if(!file_exists($dir)) { mkdir($dir,0777); } return $dir; } function release() { } function getSmartyDir($prefix) { $dir = DynamicSmarty::getBaseSmartyDir(); $dir2 = sprintf('%s/%s',$dir,$prefix); if(!file_exists($dir2)) { mkdir($dir2,0777); } return $dir2; } function &createSmarty() { $smarty =& new Smarty; $smarty->template_dir = dirname(__FILE__); $smarty->cache_dir = DynamicSmarty::getSmartyDir('cache'); $smarty->config_dir = DynamicSmarty::getSmartyDir('config'); $smarty->compile_dir = DynamicSmarty::getSmartyDir('compile'); $smarty->register_prefilter('_DynamicSmarty_prefilter'); $smarty->register_postfilter('_DynamicSmarty_postfilter'); return $smarty; } } function _DynamicSmarty_prefilter($template) { return mb_convert_encoding($template,'eucJP-win','UTF-8'); } function _DynamicSmarty_postfilter($template) { return mb_convert_encoding($template,'UTF-8','eucJP-win'); } ?>