function import_diy($importfile, $primaltplname, $targettplname) { global $_G; $css = $html = ''; $arr = array(); $content = file_get_contents(realpath($importfile)); if (empty($content)) { return $arr; } require_once DISCUZ_ROOT . './source/class/class_xml.php'; $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['bockdata']); } $oldbids = $newbids = array(); if (!empty($mapping)) { foreach ($mapping as $obid => $nbid) { $oldbids[] = 'portal_block_' . $obid; $newbids[] = 'portal_block_' . $nbid; } } require_once DISCUZ_ROOT . './source/class/class_xml.php'; $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); $arr['spacecss'] = $css; $arr['layoutdata'] = $diycontent['layoutdata']; $arr['style'] = $diycontent['style']; save_diy_data($primaltplname, $targettplname, $arr, true); } return $arr; }
function updatediytemplate($targettplname = '', $tpldirectory = '') { $r = false; $alldata = !empty($targettplname) ? array(C::t('common_diy_data')->fetch($targettplname, $tpldirectory)) : C::t('common_diy_data')->range(); require_once libfile('function/portalcp'); foreach ($alldata as $value) { $r = save_diy_data($value['tpldirectory'], $value['primaltplname'], $value['targettplname'], dunserialize($value['diycontent'])); } return $r; }
$style = empty($_POST['style']) ? '' : preg_replace("/[^0-9a-z]/i", '', $_POST['style']); if ($style) { $cssfile = DISCUZ_ROOT . './static/topic/' . $style . '/style.css'; if (!file_exists($cssfile)) { showmessage('theme_does_not_exist'); } else { $templatedata['style'] = "static/topic/{$style}/style.css"; } } $layoutdata = getstr($_POST['layoutdata'], 0, 0, 0, 0, 1); require_once libfile('class/xml'); $templatedata['layoutdata'] = xml2array($layoutdata); if (empty($templatedata['layoutdata'])) { showmessage('diy_data_format_invalid'); } $r = save_diy_data($tpldirectory, $template, $targettplname, $templatedata, true, $optype); include_once libfile('function/cache'); updatecache('diytemplatename'); if ($r && $optype != 'savecache') { if (!$iscategory && !$istopic && empty($savemod) && !empty($clonefile)) { $delfile = DISCUZ_ROOT . './data/diy/' . $tpldirectory . '/' . $template . '_' . $clonefile . '.htm'; if (file_exists($delfile)) { unlink($delfile); @unlink($delfile . '.bak'); C::t('common_template_block')->delete_by_targettplname("{$template}_{$clonefile}", $tpldirectory); C::t('common_diy_data')->delete("{$template}_{$clonefile}", $tpldirectory); include_once libfile('function/cache'); updatecache('diytemplatename'); } } }
function updatediytemplate($targettplname = '') { global $_G; $r = false; $where = empty($targettplname) ? '' : " WHERE targettplname='{$targettplname}'"; $query = DB::query("SELECT * FROM " . DB::table('common_diy_data') . "{$where}"); require_once libfile('function/portalcp'); while ($value = DB::fetch($query)) { $r = save_diy_data($value['primaltplname'], $value['targettplname'], unserialize($value['diycontent'])); } return $r; }