Exemple #1
0
<?php

/**
 * 静态相关
 */
function D($var)
{
    echo "<pre>";
    var_dump($var);
    echo "<pre>";
    exit;
}
define('APP', dirname(__FILE__));
define('ROOT', 'http://localhost/web_3.0/PPL/bin/P2H/demo/');
define('NEWS_ROOT', ROOT . 'news/');
define('IT_ROOT', NEWS_ROOT . 'it/');
define('DS', DIRECTORY_SEPARATOR);
define('M5CPL', 'just a test');
date_default_timezone_set('PRC');
require_once dirname(APP) . '/P2H.php';
P2H::initConfig(require APP . '/config/P2HConfig.php');
//var_dump(P2H::getVars());exit;
Exemple #2
0
 /**
  * Init初始化 载入配置 检查更新 打开ob
  * 
  */
 public static function init($time = 0)
 {
     if (!P2HConfig::get('isStatic')) {
         return;
     }
     self::$rwPath = self::RWPath($time);
     self::$rwURL = self::RWURL($time);
     self::checkUpdate($time);
     self::ob_end();
     ob_start();
 }
Exemple #3
0
<?php

require_once './bootstrap.php';
P2H::update();
Exemple #4
0
/*
echo P2H::RW('news/news.php?id=3', time());exit;

echo P2H::RW('news/it/news.php?id=3&pag=0&cid=0&gid=2', time());
echo P2H::RW('./news/news.php?id=3&gid=1&pag=11', time());
exit;

echo P2HPath::RWPath('news/news.php?id=3&gid=1&pag=11', time());echo "<br />";
echo P2HPath::RWPath('index.php?pag=3');echo "<br />";
echo P2HPath::RWPath('news/news.php?id=3', time());echo "<br />";
echo P2HPath::RWPath('news/it/news.php?id=3&cid=2&pag=1', time());echo "<br />";




echo P2H::RWURL(NEWS_ROOT.'news.php?id=3', time());echo "<br />";
echo P2H::RWURL(NEWS_ROOT.'index.php?pag=3', time());echo "<br />";
echo P2H::RWURL('news/it/news.php?id=3&pag=0&cid=0&gid=2', time());
echo "<hr>";

echo P2HPath::RWPath('index.php?pag=3', time());
echo "<br />";
echo P2HPath::RWPath('./news/news.php?id=3', time());echo "<br />";
echo P2HPath::RWPath('news/index.php?pag=3', time());echo "<br />";
echo P2HPath::RWPath('news/it/news.php?id=3&pag=0&cid=0&gid=2', time());
*/
//P2H::check($id>0); //检测无效不更新
$time = date('Y-m-d H:i:s');
include './templates/index.html';
P2H::toHTML();
Exemple #5
0
/**
 *
 * 兼容P2H类的分页
 *@param $url
 *@param $total
 *@param $page
 *@param $limit
 *@return [上一页][1][2][3][下一页]
 */
function show_page($url, $total, $page, $limit = 20, $where = '')
{
    if (!empty($where)) {
        $where = '&' . $where;
    }
    $ceil = ceil($total / $limit);
    $ceil > 1 && ($ceil_limit = 5);
    if ($ceil > 1 && $page >= 5) {
        $ceil_limit = 10;
    }
    if ($page >= 8) {
        $ceil - $page > 10 ? $st = $page - 5 : ($st = $ceil - 10);
        $ceil_limit += $st - 1;
        if ($ceil - $page < 8) {
            $st = $page - 2;
            $ceil_limit = $ceil;
        }
        if ($ceil - $page == 10) {
            $st = $page - 2;
            $ceil_limit = $st + 9;
        }
    } else {
        $st = 1;
    }
    $ceil < $ceil_limit && ($ceil_limit = $ceil);
    for ($st; $st <= $ceil_limit; $st++) {
        if ($page == $st || empty($page) && $page == $st - 1) {
            $page == 0 && ($page = 1);
            $spage .= "<font style='background:#00a0cb;padding:1px 6px;color:#fff;margin-right:15px'>{$page}</font>";
        } else {
            $urls = P2H::RW($url . "?pag=" . $st . $where);
            $spage .= "<a href='" . $urls . "'><font>{$st}</font></a>";
        }
    }
    if ($page >= $ceil) {
        $npage = "<font>[已到尾页]</font>";
    } else {
        $urls = P2H::RW($url . "?pag=" . ($page + 1) . $where);
        $urlend = P2H::RW($url . "?pag=" . $ceil . $where);
        $npage = "<a href='" . $urls . "'>下一页</a>";
        $npage .= "<a href='" . $urlend . "'>到尾页</a>";
    }
    $furl = P2H::RW($url . "?pag=1" . $where);
    $ppage = $page > 7 ? "<a href='" . $furl . "'>回首页</a>" : '';
    return $ceil > 1 ? $ppage . $spage . $npage : $spage;
}