function block_fetch_content($bid, $isjscall = false, $forceupdate = false) { global $_G; static $allowmem = null, $cachettl = null; if ($allowmem === null) { $allowmem = ($cachettl = getglobal('setting/memory/diyblockoutput')) !== null && memory('check'); } $str = ''; $block = empty($_G['block'][$bid]) ? array() : $_G['block'][$bid]; if (!$block) { return; } if ($forceupdate) { block_updatecache($bid, true); $block = $_G['block'][$bid]; } elseif ($block['cachetime'] > 0 && $_G['timestamp'] - $block['dateline'] > $block['cachetime']) { $block['cachetimerange'] = empty($block['cachetimerange']) ? isset($_G['setting']['blockcachetimerange']) ? $_G['setting']['blockcachetimerange'] : '' : $block['cachetimerange']; $inrange = empty($block['cachetimerange']) ? true : false; if (!$inrange) { $block['cachetimerange'] = explode(',', $block['cachetimerange']); $hour = date('G', TIMESTAMP); if ($block['cachetimerange'][0] <= $block['cachetimerange'][1]) { $inrange = $block['cachetimerange'][0] <= $hour && $block['cachetimerange'][1] >= $hour; } else { $inrange = !($block['cachetimerange'][1] < $hour && $block['cachetimerange'][0] > $hour); } } if ($isjscall || $block['punctualupdate']) { block_updatecache($bid, true); $block = $_G['block'][$bid]; } elseif ((empty($_G['blockupdate']) || $block['dateline'] < $_G['blockupdate']['dateline']) && $inrange) { $_G['blockupdate'] = array('bid' => $bid, 'dateline' => $block['dateline']); } } $hidediv = $isjscall || $block['blocktype']; $_cache_key = 'blockcache_' . ($isjscall ? 'js' : 'htm') . '_' . $bid; if ($allowmem && empty($block['hidedisplay']) && empty($block['nocache']) && ($str = memory('get', $_cache_key)) !== false) { } else { if ($hidediv) { if ($block['summary']) { $str .= $block['summary']; } $str .= block_template($bid); } else { if ($block['title']) { $str .= $block['title']; } $str .= '<div id="portal_block_' . $bid . '_content" class="dxb_bc">'; if ($block['summary']) { $str .= "<div class=\"portal_block_summary\">{$block['summary']}</div>"; } $str .= block_template($bid); $str .= '</div>'; } if ($allowmem && empty($block['hidedisplay']) && empty($block['nocache'])) { memory('set', $_cache_key, $str, C::t('common_block')->cache_ttl); } } if (!$hidediv) { $classname = !empty($block['classname']) ? $block['classname'] . ' ' : ''; $div = "<div id=\"portal_block_{$bid}\" class=\"{$classname}block move-span\">"; if (($_GET['diy'] === 'yes' || $_GET['inajax']) && check_diy_perm()) { $div .= "<div class='block-name'>{$block['name']} (ID:{$bid})</div>"; } $str = $div . $str . "</div>"; } if ($block['blockclass'] == 'html_html' && $block['script'] == 'search') { $str = strtr($str, array('{FORMHASH}' => FORMHASH)); } return !empty($block['hidedisplay']) ? '' : $str; }
function block_fetch_content($bid, $isjscall = false, $forceupdate = false) { global $_G; static $allowmem = null; if ($allowmem === null) { $allowmem = getglobal('setting/memory/diyblockoutput/enable') && memory('check'); } $str = ''; $block = empty($_G['block'][$bid]) ? array() : $_G['block'][$bid]; if (!$block) { return; } if ($forceupdate) { block_updatecache($bid, true); $block = $_G['block'][$bid]; } elseif ($block['cachetime'] > 0 && $_G['timestamp'] - $block['dateline'] > $block['cachetime']) { if ($isjscall || $block['punctualupdate']) { block_updatecache($bid, true); $block = $_G['block'][$bid]; } elseif (empty($_G['blockupdate']) || $block['dateline'] < $_G['blockupdate']['dateline']) { $_G['blockupdate'] = array('bid' => $bid, 'dateline' => $block['dateline']); } } if ($allowmem && empty($block['hidedisplay']) && empty($block['nocache'])) { $str = memory('get', 'blockcache_' . $bid . '_' . ($isjscall ? 'js' : 'htm')); if ($str !== null) { if ($block['blockclass'] == 'html_html' && $block['script'] == 'search') { $str = strtr($str, array('{FORMHASH}' => FORMHASH)); } return $str; } } if ($isjscall || $block['blocktype']) { if ($block['summary']) { $str .= $block['summary']; } $str .= block_template($bid); } else { $classname = !empty($block['classname']) ? $block['classname'] . ' ' : ''; $str .= "<div id=\"portal_block_{$bid}\" class=\"{$classname}block move-span\">"; if ($block['title']) { $str .= $block['title']; } $str .= '<div id="portal_block_' . $bid . '_content" class="dxb_bc">'; if ($block['summary']) { $block['summary'] = stripslashes($block['summary']); $str .= "<div class=\"portal_block_summary\">{$block['summary']}</div>"; } $str .= block_template($bid); $str .= '</div>'; $str .= "</div>"; } if ($allowmem && empty($block['hidedisplay']) && empty($block['nocache'])) { memory('set', 'blockcache_' . $bid . '_' . ($isjscall ? 'js' : 'htm'), $str, getglobal('setting/memory/diyblockoutput/ttl')); } if ($block['blockclass'] == 'html_html' && $block['script'] == 'search') { $str = strtr($str, array('{FORMHASH}' => FORMHASH)); } return !empty($block['hidedisplay']) ? '' : $str; }