<?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_display_batch($bid) { echo block_fetch_content($bid); }
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; }
} } elseif ($op == 'getblock') { if (!$bid || !$allowmanage && !$allowdata) { showmessage('block_edit_nopermission'); } block_get_batch($bid); if (!empty($_GET['forceupdate'])) { block_updatecache($bid, !empty($_GET['forceupdate'])); } if (strexists($block['summary'], '<script')) { $block['summary'] = lang('portalcp', 'block_diy_nopreview'); $_G['block'][$bid] = $block; $_G['block'][$bid]['cachetime'] = 0; $_G['block'][$bid]['nocache'] = true; } $html = block_fetch_content($bid, $block['blocktype']); } elseif ($op == 'saveblockclassname') { if (!$bid || !$allowmanage) { showmessage('block_edit_nopermission'); } if (submitcheck('saveclassnamesubmit')) { $setarr = array('classname' => getstr($_POST['classname'], 100, 0, 0, 0, -1)); C::t('common_block')->update($bid, $setarr); } C::t('common_block')->clear_cache($bid); showmessage('do_success'); } elseif ($op == 'saveblocktitle') { if (!$bid || !$allowmanage) { showmessage('block_edit_nopermission'); } if (submitcheck('savetitlesubmit')) {