<?php /** * [Discuz!] (C)2001-2099 Comsenz Inc. * This is NOT a freeware, use is subject to license terms * * $Id: javascript.php 7086 2010-03-29 02:06:27Z monkey $ */ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 60) . ' GMT'); if (!defined('IN_API')) { exit('document.write(\'Access Denied\')'); } loadcore(); include_once libfile('function/block'); loadcache('blockclass'); $bid = intval($_G['gp_bid']); block_get_batch($bid); $data = block_fetch_content($bid, true); $search = array("/\\<(a href)\\=(\"|')(\\w+)/i", "/\\<(img src)\\=(\"|')(\\w+)/i"); $replace = "<\\1=\\2{$_G['siteurl']}\\3"; $data = preg_replace($search, $replace, $data); echo 'document.write(\'' . preg_replace("/\r\n|\n|\r/", '\\n', addcslashes($data, "'\\")) . '\');';
function block_get($parameter) { include_once libfile('function/block'); block_get_batch($parameter); }
function import_diy($file) { global $_G; $css = ''; $html = array(); $arr = array(); $content = file_get_contents($file); require_once libfile('class/xml'); if (empty($content)) { return $arr; } $content = preg_replace("/\\<\\!\\-\\-\\[name\\](.+?)\\[\\/name\\]\\-\\-\\>\\s+/i", '', $content); $diycontent = xml2array($content); if ($diycontent) { foreach ($diycontent['layoutdata'] as $key => $value) { if (!empty($value)) { getframeblock($value); } } $newframe = array(); foreach ($_G['curtplframe'] as $value) { $newframe[] = $value['type'] . random(6); } $mapping = array(); if (!empty($diycontent['blockdata'])) { $mapping = block_import($diycontent['blockdata']); unset($diycontent['blockdata']); } $oldbids = $newbids = array(); if (!empty($mapping)) { foreach ($mapping as $obid => $nbid) { $oldbids[] = '#portal_block_' . $obid . ' '; $newbids[] = '#portal_block_' . $nbid . ' '; $oldbids[] = '[portal_block_' . $obid . ']'; $newbids[] = '[portal_block_' . $nbid . ']'; $oldbids[] = '~portal_block_' . $obid . '"'; $newbids[] = '~portal_block_' . $nbid . '"'; } } require_once libfile('class/xml'); $xml = array2xml($diycontent['layoutdata'], true); $xml = str_replace($oldbids, $newbids, $xml); $xml = str_replace((array) array_keys($_G['curtplframe']), $newframe, $xml); $diycontent['layoutdata'] = xml2array($xml); $css = str_replace($oldbids, $newbids, $diycontent['spacecss']); $css = str_replace((array) array_keys($_G['curtplframe']), $newframe, $css); foreach ($diycontent['layoutdata'] as $key => $value) { $html[$key] = getframehtml($value); } } if (!empty($html)) { $xml = array2xml($html, true); require_once libfile('function/block'); block_get_batch(implode(',', $mapping)); foreach ($mapping as $bid) { $blocktag[] = '<!--{block/' . $bid . '}-->'; $blockcontent[] = block_fetch_content($bid); } $xml = str_replace($blocktag, $blockcontent, $xml); $html = xml2array($xml); $arr = array('html' => $html, 'css' => $css, 'mapping' => $mapping); } return $arr; }
function block_get($parameter) { global $_G; static $allowmem; if ($allowmem === null) { include_once libfile('function/block'); $allowmem = getglobal('setting/memory/diyblock/enable') && memory('check'); } if (!$allowmem) { block_get_batch($parameter); return true; } $blockids = explode(',', $parameter); $lostbids = array(); foreach ($blockids as $bid) { $bid = intval($bid); if ($bid) { $_G['block'][$bid] = memory('get', 'blockcache_' . $bid); if ($_G['block'][$bid] === null) { $lostbids[] = $bid; } } } if ($lostbids) { block_get_batch(implode(',', $lostbids)); foreach ($lostbids as $bid) { if (isset($_G['block'][$bid])) { memory('set', 'blockcache_' . $bid, $_G['block'][$bid], getglobal('setting/memory/diyblock/ttl')); } } } }