Skip to content

Commit

Permalink
改进日历的年月日;
Browse files Browse the repository at this point in the history
httpd.ini下的Bug;GZip安装应用的Bug;
  • Loading branch information
rainbowsoft committed Nov 4, 2016
1 parent de39707 commit 21553d3
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 30 deletions.
2 changes: 1 addition & 1 deletion zb_system/function/c_system_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
define('ZC_VERSION_MAJOR', '1');
define('ZC_VERSION_MINOR', '5');
define('ZC_VERSION_BUILD', '0');
define('ZC_VERSION_COMMIT', '1619');
define('ZC_VERSION_COMMIT', '1624');
define('ZC_VERSION_CODENAME', 'Zero');
define('ZC_VERSION', ZC_VERSION_MAJOR . '.' . ZC_VERSION_MINOR . '.' . ZC_VERSION_BUILD . '.' . ZC_VERSION_COMMIT);
define('ZC_VERSION_DISPLAY', ZC_VERSION_MAJOR . '.' . ZC_VERSION_MINOR . ' ' . ZC_VERSION_CODENAME);
Expand Down
120 changes: 120 additions & 0 deletions zb_system/function/c_system_common.php
Original file line number Diff line number Diff line change
Expand Up @@ -1496,3 +1496,123 @@ function http_build_url($url, $parts = array(), $flags = HTTP_URL_REPLACE, &$new
return $parsed_string;
}
}

if (!function_exists('gzdecode')) {
function gzdecode($data) {
$len = strlen($data);
if ($len < 18 || strcmp(substr($data,0,2),"\x1f\x8b")) {
return null; // Not GZIP format (See RFC 1952)
}
$method = ord(substr($data,2,1)); // Compression method
$flags = ord(substr($data,3,1)); // Flags
if ($flags & 31 != $flags) {
// Reserved bits are set -- NOT ALLOWED by RFC 1952
return null;
}
// NOTE: $mtime may be negative (PHP integer limitations)
$mtime = unpack("V", substr($data,4,4));
$mtime = $mtime[1];
$xfl = substr($data,8,1);
$os = substr($data,8,1);
$headerlen = 10;
$extralen = 0;
$extra = "";
if ($flags & 4) {
// 2-byte length prefixed EXTRA data in header
if ($len - $headerlen - 2 < 8) {
return false; // Invalid format
}
$extralen = unpack("v",substr($data,8,2));
$extralen = $extralen[1];
if ($len - $headerlen - 2 - $extralen < 8) {
return false; // Invalid format
}
$extra = substr($data,10,$extralen);
$headerlen += 2 + $extralen;
}

$filenamelen = 0;
$filename = "";
if ($flags & 8) {
// C-style string file NAME data in header
if ($len - $headerlen - 1 < 8) {
return false; // Invalid format
}
$filenamelen = strpos(substr($data,8+$extralen),chr(0));
if ($filenamelen === false || $len - $headerlen - $filenamelen - 1 < 8) {
return false; // Invalid format
}
$filename = substr($data,$headerlen,$filenamelen);
$headerlen += $filenamelen + 1;
}

$commentlen = 0;
$comment = "";
if ($flags & 16) {
// C-style string COMMENT data in header
if ($len - $headerlen - 1 < 8) {
return false; // Invalid format
}
$commentlen = strpos(substr($data,8+$extralen+$filenamelen),chr(0));
if ($commentlen === false || $len - $headerlen - $commentlen - 1 < 8) {
return false; // Invalid header format
}
$comment = substr($data,$headerlen,$commentlen);
$headerlen += $commentlen + 1;
}

$headercrc = "";
if ($flags & 2) {
// 2-bytes (lowest order) of CRC32 on header present
if ($len - $headerlen - 2 < 8) {
return false; // Invalid format
}
$calccrc = crc32(substr($data,0,$headerlen)) & 0xffff;
$headercrc = unpack("v", substr($data,$headerlen,2));
$headercrc = $headercrc[1];
if ($headercrc != $calccrc) {
return false; // Bad header CRC
}
$headerlen += 2;
}

// GZIP FOOTER - These be negative due to PHP's limitations
$datacrc = unpack("V",substr($data,-8,4));
$datacrc = $datacrc[1];
$isize = unpack("V",substr($data,-4));
$isize = $isize[1];

// Perform the decompression:
$bodylen = $len-$headerlen-8;
if ($bodylen < 1) {
// This should never happen - IMPLEMENTATION BUG!
return null;
}
$body = substr($data,$headerlen,$bodylen);
$data = "";
if ($bodylen > 0) {
switch ($method) {
case 8:
// Currently the only supported compression method:
$data = gzinflate($body);
break;
default:
// Unknown compression method
return false;
}
} else {
// I'm not sure if zero-byte body content is allowed.
// Allow it for now... Do nothing...
}

// Verifiy decompressed size and CRC32:
// NOTE: This may fail with large data sizes depending on how
// PHP's integer limitations affect strlen() since $isize
// may be negative for large sizes.
if ($isize != strlen($data) || crc32($data) != $datacrc) {
// Bad format! Length or CRC doesn't match!
return false;
}
return $data;
}
}
81 changes: 60 additions & 21 deletions zb_system/function/c_system_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ function ViewAuto($inpurl) {
$url = trim(urldecode($url), '/');

if ($url == '' || $url == 'index.php') {
ViewList(null, null, null, null, null);
ViewList(null, null, null, null, null);

return null;
}
Expand All @@ -510,7 +510,7 @@ function ViewAuto($inpurl) {
$r = UrlRule::OutputUrlRegEx($zbp->option['ZC_INDEX_REGEX'], 'index');
$m = array();
if (preg_match($r, $url, $m) == 1) {
ViewList($m['page'], null, null, null, null, true);
ViewList($m['page'], null, null, null, null, true);

return null;
}
Expand Down Expand Up @@ -599,7 +599,7 @@ function ViewAuto($inpurl) {
$result = ViewPost($m, null, true);
if ($result == false) {
$zbp->ShowError(2, __FILE__, __LINE__);
}
}

return null;
}
Expand Down Expand Up @@ -717,7 +717,12 @@ function ViewList($page, $cate, $auth, $date, $tags, $isrewrite = false) {
if (!is_array($cate)) {
$cateId = $cate;
$cate = array();
$cate['id'] = $cateId;
if (strpos($zbp->option['ZC_CATEGORY_REGEX'], '{%id%}') !== false) {
$cate['id'] = $cateId;
}
if (strpos($zbp->option['ZC_CATEGORY_REGEX'], '{%alias%}') !== false) {
$cate['alias'] = $cateId;
}
}
if (isset($cate['id'])) {
$category = $zbp->GetCategoryByID($cate['id']);
Expand Down Expand Up @@ -762,7 +767,12 @@ function ViewList($page, $cate, $auth, $date, $tags, $isrewrite = false) {
if (!is_array($auth)) {
$authId = $auth;
$auth = array();
$auth['id'] = $authId;
if (strpos($zbp->option['ZC_AUTHOR_REGEX'], '{%id%}') !== false) {
$auth['id'] = $authId;
}
if (strpos($zbp->option['ZC_AUTHOR_REGEX'], '{%alias%}') !== false) {
$auth['alias'] = $authId;
}
}
if (isset($auth['id'])) {
$author = $zbp->GetMemberByID($auth['id']);
Expand Down Expand Up @@ -797,15 +807,25 @@ function ViewList($page, $cate, $auth, $date, $tags, $isrewrite = false) {
} else {
$datetime = $date['date'];
}
if(preg_match('/[0-9]{4}-[0-9]{1,2}/i', $datetime) == 0){

$dateregex_ymd='/[0-9]{1,4}-[0-9]{1,2}-[0-9]{1,2}/i';
$dateregex_ym='/[0-9]{1,4}-[0-9]{1,2}/i';

if(preg_match($dateregex_ymd, $datetime) == 0 && preg_match($dateregex_ym, $datetime) == 0){
return false;
}
$datetime_txt = $datetime;
$datetime = strtotime($datetime);
if($datetime == false){
return false;
}

$datetitle = str_replace(array('%y%', '%m%'), array(date('Y', $datetime), date('n', $datetime)), $zbp->lang['msg']['year_month']);
if(preg_match($dateregex_ymd, $datetime_txt) != 0 && isset($zbp->lang['msg']['year_month_day'])){
$datetitle = str_replace(array('%y%', '%m%', '%d%'), array(date('Y', $datetime), date('n', $datetime), date('j', $datetime)), $zbp->lang['msg']['year_month_day']);
}else{
$datetitle = str_replace(array('%y%', '%m%'), array(date('Y', $datetime), date('n', $datetime)), $zbp->lang['msg']['year_month']);
}

if ($page == 1) {
$zbp->title = $datetitle;
} else {
Expand All @@ -815,8 +835,15 @@ function ViewList($page, $cate, $auth, $date, $tags, $isrewrite = false) {
$zbp->modulesbyfilename['calendar']->Content = ModuleBuilder::Calendar(date('Y', $datetime) . '-' . date('n', $datetime));

$template = $zbp->option['ZC_INDEX_DEFAULT_TEMPLATE'];
$w[] = array('BETWEEN', 'log_PostTime', $datetime, strtotime('+1 month', $datetime));
$pagebar->UrlRule->Rules['{%date%}'] = date('Y-n', $datetime);

if(preg_match($dateregex_ymd, $datetime_txt) != 0){
$w[] = array('BETWEEN', 'log_PostTime', $datetime, strtotime('+1 day', $datetime));
$pagebar->UrlRule->Rules['{%date%}'] = date('Y-n-j', $datetime);
} else {
$w[] = array('BETWEEN', 'log_PostTime', $datetime, strtotime('+1 month', $datetime));
$pagebar->UrlRule->Rules['{%date%}'] = date('Y-n', $datetime);
}

$datetime = Metas::ConvertArray(getdate($datetime));
break;
########################################################################################################
Expand All @@ -827,7 +854,12 @@ function ViewList($page, $cate, $auth, $date, $tags, $isrewrite = false) {
if (!is_array($tags)) {
$tagId = $tags;
$tags = array();
$tags['id'] = $tagId;
if (strpos($zbp->option['ZC_TAGS_REGEX'], '{%id%}') !== false) {
$tags['id'] = $tagId;
}
if (strpos($zbp->option['ZC_TAGS_REGEX'], '{%alias%}') !== false) {
$tags['alias'] = $tagId;
}
}
if (isset($tags['id'])) {
$tag = $zbp->GetTagByID($tags['id']);
Expand Down Expand Up @@ -1332,12 +1364,13 @@ function PostArticle() {
}
}

FilterMeta($article);

foreach ($GLOBALS['hooks']['Filter_Plugin_PostArticle_Core'] as $fpname => &$fpsignal) {
$fpname($article);
}

FilterPost($article);
FilterMeta($article);

$article->Save();

Expand Down Expand Up @@ -1589,12 +1622,13 @@ function PostPage() {

$article->Type = ZC_POST_TYPE_PAGE;

FilterMeta($article);

foreach ($GLOBALS['hooks']['Filter_Plugin_PostPage_Core'] as $fpname => &$fpsignal) {
$fpname($article);
}

FilterPost($article);
FilterMeta($article);

$article->Save();

Expand Down Expand Up @@ -2011,15 +2045,16 @@ function PostCategory() {
}
}

foreach ($GLOBALS['hooks']['Filter_Plugin_PostCategory_Core'] as $fpname => &$fpsignal) {
$fpname($cate);
}
FilterMeta($cate);

//刷新RootID
$cate->Level;

foreach ($GLOBALS['hooks']['Filter_Plugin_PostCategory_Core'] as $fpname => &$fpsignal) {
$fpname($cate);
}

FilterCategory($cate);
FilterMeta($cate);

// 此处用作刷新分类内文章数据使用,不作更改
if ($cate->ID > 0) {
Expand Down Expand Up @@ -2117,14 +2152,17 @@ function PostTag() {
}
}

FilterMeta($tag);

foreach ($GLOBALS['hooks']['Filter_Plugin_PostTag_Core'] as $fpname => &$fpsignal) {
$fpname($tag);
}

FilterTag($tag);
FilterMeta($tag);

CountTag($tag);
if ($zbp->option['ZC_LARGE_DATA'] == false) {
CountTag($tag);
}

$tag->Save();

Expand Down Expand Up @@ -2247,12 +2285,13 @@ function PostMember() {
}
}

FilterMeta($mem);

foreach ($GLOBALS['hooks']['Filter_Plugin_PostMember_Core'] as $fpname => &$fpsignal) {
$fpname($mem);
}

FilterMember($mem);
FilterMeta($mem);

CountMember($mem);

Expand Down Expand Up @@ -2395,12 +2434,13 @@ function PostModule() {
$mod->NoRefresh = (bool) $_POST['NoRefresh'];
}

FilterMeta($mod);

foreach ($GLOBALS['hooks']['Filter_Plugin_PostModule_Core'] as $fpname => &$fpsignal) {
$fpname($mod);
}

FilterModule($mod);
FilterMeta($mod);

$mod->Save();

Expand Down Expand Up @@ -3067,7 +3107,6 @@ function CountTagArrayString($string, $plus = null, $articleid = null) {
$fpreturn = $fpname($array, $plus, $articleid);
if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) {
$fpsignal = PLUGIN_EXITSIGNAL_NONE;

return $fpreturn;
}
}
Expand Down
4 changes: 1 addition & 3 deletions zb_system/function/lib/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,7 @@ public static function UnPack($xml) {
$charset[1] = substr($xml, 0, 1);
$charset[2] = substr($xml, 1, 1);
if (ord($charset[1]) == 31 && ord($charset[2]) == 139) {
//if (function_exists('gzdecode')) {
$xml = gzdecode($xml);
//}
$xml = gzdecode($xml);
}

$xml = simplexml_load_string($xml);
Expand Down
Loading

0 comments on commit 21553d3

Please sign in to comment.