当前位置: 首页>>代码示例>>PHP>>正文


PHP swritefile函数代码示例

本文整理汇总了PHP中swritefile函数的典型用法代码示例。如果您正苦于以下问题:PHP swritefile函数的具体用法?PHP swritefile怎么用?PHP swritefile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了swritefile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cache_write

function cache_write($name, $var, $values)
{
    $cachefile = S_ROOT . './data/data_' . $name . '.php';
    $cachetext = "<?php\r\n" . "if(!defined('IN_SYS')) exit('Access Denied');\r\n" . '$' . $var . '=' . arrayeval($values) . "\r\n?>";
    if (!swritefile($cachefile, $cachetext)) {
        exit("File: {$cachefile} write error.");
    }
}
开发者ID:hugolong,项目名称:weixiao,代码行数:8,代码来源:function_cache.php

示例2: parse_template

function parse_template($tpl)
{
    global $_SGLOBAL;
    //包含模板
    $_SGLOBAL['sub_tpls'] = array($tpl);
    $tplfile = S_ROOT . './' . $tpl . '.htm';
    $objfile = S_ROOT . './runtime/tpl_cache/' . str_replace('/', '_', $tpl) . '.php';
    $template = sreadfile($tplfile);
    if (empty($template)) {
        exit("Template file : {$tplfile} Not found or have no access!");
    }
    //模板
    @($template = preg_replace("/\\<\\!\\-\\-\\{template\\s+([a-z0-9_\\/]+)\\}\\-\\-\\>/ie", "readtemplate('\\1')", $template));
    //处理子页面中的代码
    @($template = preg_replace("/\\<\\!\\-\\-\\{template\\s+([a-z0-9_\\/]+)\\}\\-\\-\\>/ie", "readtemplate('\\1')", $template));
    //PHP代码
    @($template = preg_replace("/\\<\\!\\-\\-\\{eval\\s+(.+?)\\s*\\}\\-\\-\\>/ies", "evaltags('\\1')", $template));
    //开始处理
    //变量
    $var_regexp = "((\\\$[a-zA-Z_-�][a-zA-Z0-9_-�]*)(\\[[a-zA-Z0-9_\\-\\.\"\\'\\[\\]\$-�]+\\])*)";
    @($template = preg_replace("/\\<\\!\\-\\-\\{(.+?)\\}\\-\\-\\>/s", "{\\1}", $template));
    @($template = preg_replace("/([\n\r]+)\t+/s", "\\1", $template));
    @($template = preg_replace("/(\\\$[a-zA-Z0-9_\\[\\]\\'\"\$-�]+)\\.([a-zA-Z_-�][a-zA-Z0-9_-�]*)/s", "\\1['\\2']", $template));
    @($template = preg_replace("/\\{(\\\$[a-zA-Z0-9_\\[\\]\\'\"\$\\.-�]+)\\}/s", "<?=\\1?>", $template));
    @($template = preg_replace("/{$var_regexp}/es", "addquote('<?=\\1?>')", $template));
    @($template = preg_replace("/\\<\\?\\=\\<\\?\\={$var_regexp}\\?\\>\\?\\>/es", "addquote('<?php echo \\1?>')", $template));
    //逻辑
    @($template = preg_replace("/\\{elseif\\s+(.+?)\\}/ies", "stripvtags('<?php } elseif(\\1) { ?>','')", $template));
    @($template = preg_replace("/\\{else\\}/is", "<?php } else { ?>", $template));
    //循环
    for ($i = 0; $i < 6; $i++) {
        @($template = preg_replace("/\\{foreach\\s+(\\S+)\\s+(\\S+)\\}(.+?)\\{\\/foreach\\}/ies", "stripvtags('<?php if(is_array(\\1)) { foreach(\\1 as \\2) { ?>','\\3<?php } } ?>')", $template));
        @($template = preg_replace("/\\{foreach\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\}(.+?)\\{\\/foreach\\}/ies", "stripvtags('<?php if(is_array(\\1)) { foreach(\\1 as \\2 => \\3) { ?>','\\4<?php } } ?>')", $template));
        @($template = preg_replace("/\\{if\\s+(.+?)\\}(.+?)\\{\\/if\\}/ies", "stripvtags('<?php if(\\1) { ?>','\\2<?php } ?>')", $template));
    }
    //常量
    @($template = preg_replace("/\\{([a-zA-Z_-�][a-zA-Z0-9_-�]*)\\}/s", "<?php echo \\1?>", $template));
    //替换
    if (!empty($_SGLOBAL['block_search'])) {
        @($template = str_replace($_SGLOBAL['block_search'], $_SGLOBAL['block_replace'], $template));
    }
    //换行
    @($template = preg_replace("/ \\?\\>[\n\r]*\\<\\? /s", " ", $template));
    //附加处理
    @($template = "<?php !defined('IN_CL') && exit('Forbidden');?><?php subtplcheck('" . implode('|', $_SGLOBAL['sub_tpls']) . "', '{$_SGLOBAL['timestamp']}', '{$tpl}');?>{$template}");
    //write
    if (!swritefile($objfile, $template, 'w')) {
        exit("File: {$objfile} can not be write!");
    }
}
开发者ID:nymbian,项目名称:codelib,代码行数:50,代码来源:function_template.php

示例3: parse_template

function parse_template($tpl)
{
    global $_SGLOBAL, $_SC, $_SCONFIG;
    //°üº¬Ä£°å
    $_SGLOBAL['sub_tpls'] = array($tpl);
    $tplfile = S_ROOT . './' . $tpl . '.htm';
    $objfile = S_ROOT . './data/tpl_cache/' . str_replace('/', '_', $tpl) . '.php';
    //read
    if (!file_exists($tplfile)) {
        $tplfile = str_replace('/' . $_SCONFIG['template'] . '/', '/default/', $tplfile);
    }
    $template = sreadfile($tplfile);
    if (empty($template)) {
        exit("Template file : {$tplfile} Not found or have no access!");
    }
    //Ä£°å
    $template = preg_replace("/\\<\\!\\-\\-\\{template\\s+([a-z0-9_\\/]+)\\}\\-\\-\\>/ie", "readtemplate('\\1')", $template);
    //´¦Àí×ÓÒ³ÃæÖеĴúÂë
    $template = preg_replace("/\\<\\!\\-\\-\\{template\\s+([a-z0-9_\\/]+)\\}\\-\\-\\>/ie", "readtemplate('\\1')", $template);
    //½âÎöÄ£¿éµ÷ÓÃ
    $template = preg_replace("/\\<\\!\\-\\-\\{block\\/(.+?)\\}\\-\\-\\>/ie", "blocktags('\\1')", $template);
    //½âÎö¹ã¸æ
    $template = preg_replace("/\\<\\!\\-\\-\\{ad\\/(.+?)\\}\\-\\-\\>/ie", "adtags('\\1')", $template);
    //ʱ¼ä´¦Àí
    $template = preg_replace("/\\<\\!\\-\\-\\{date\\((.+?)\\)\\}\\-\\-\\>/ie", "datetags('\\1')", $template);
    //Í·Ïñ´¦Àí
    $template = preg_replace("/\\<\\!\\-\\-\\{avatar\\((.+?)\\)\\}\\-\\-\\>/ie", "avatartags('\\1')", $template);
    //PHP´úÂë
    $template = preg_replace("/\\<\\!\\-\\-\\{eval\\s+(.+?)\\s*\\}\\-\\-\\>/ies", "evaltags('\\1')", $template);
    //¿ªÊ¼´¦Àí
    //±äÁ¿
    $var_regexp = "((\\\$[a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*)(\\[[a-zA-Z0-9_\\-\\.\"\\'\\[\\]\$-ÿ]+\\])*)";
    $template = preg_replace("/\\<\\!\\-\\-\\{(.+?)\\}\\-\\-\\>/s", "{\\1}", $template);
    $template = preg_replace("/([\n\r]+)\t+/s", "\\1", $template);
    $template = preg_replace("/(\\\$[a-zA-Z0-9_\\[\\]\\'\"\$-ÿ]+)\\.([a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*)/s", "\\1['\\2']", $template);
    $template = preg_replace("/\\{(\\\$[a-zA-Z0-9_\\[\\]\\'\"\$\\.-ÿ]+)\\}/s", "<?=\\1?>", $template);
    $template = preg_replace("/{$var_regexp}/es", "addquote('<?=\\1?>')", $template);
    $template = preg_replace("/\\<\\?\\=\\<\\?\\={$var_regexp}\\?\\>\\?\\>/es", "addquote('<?=\\1?>')", $template);
    //Âß¼­
    $template = preg_replace("/\\{elseif\\s+(.+?)\\}/ies", "stripvtags('<?php } elseif(\\1) { ?>','')", $template);
    $template = preg_replace("/\\{else\\}/is", "<?php } else { ?>", $template);
    //Ñ­»·
    for ($i = 0; $i < 5; $i++) {
        $template = preg_replace("/\\{loop\\s+(\\S+)\\s+(\\S+)\\}(.+?)\\{\\/loop\\}/ies", "stripvtags('<?php if(is_array(\\1)) { foreach(\\1 as \\2) { ?>','\\3<?php } } ?>')", $template);
        $template = preg_replace("/\\{loop\\s+(\\S+)\\s+(\\S+)\\s+(\\S+)\\}(.+?)\\{\\/loop\\}/ies", "stripvtags('<?php if(is_array(\\1)) { foreach(\\1 as \\2 => \\3) { ?>','\\4<?php } } ?>')", $template);
        $template = preg_replace("/\\{if\\s+(.+?)\\}(.+?)\\{\\/if\\}/ies", "stripvtags('<?php if(\\1) { ?>','\\2<?php } ?>')", $template);
    }
    //³£Á¿
    $template = preg_replace("/\\{([a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*)\\}/s", "<?=\\1?>", $template);
    //Ìæ»»
    if (!empty($_SGLOBAL['block_search'])) {
        $template = str_replace($_SGLOBAL['block_search'], $_SGLOBAL['block_replace'], $template);
    }
    //»»ÐÐ
    $template = preg_replace("/ \\?\\>[\n\r]*\\<\\? /s", " ", $template);
    //¸½¼Ó´¦Àí
    $template = "<?php if(!defined('IN_UCHOME')) exit('Access Denied');?><?php subtplcheck('" . implode('|', $_SGLOBAL['sub_tpls']) . "', '{$_SGLOBAL['timestamp']}', '{$tpl}');?>{$template}<?php ob_out();?>";
    //write
    if (!swritefile($objfile, $template)) {
        exit("File: {$objfile} can not be write!");
    }
}
开发者ID:xiaoxiaoleo,项目名称:ngintek,代码行数:62,代码来源:function_template.php

示例4: sreadfile

    $cache_mode = true;
    $multi = '';
    $start = 0;
    $perpage = $count;
    if ($cache_file && file_exists($cache_file) && $_SGLOBAL['timestamp'] - @filemtime($cache_file) < $cache_time * 60) {
        $list_cache = sreadfile($cache_file);
        $list = unserialize($list_cache);
    }
}
if ($count && empty($list)) {
    $query = $_SGLOBAL['db']->query("{$sql} LIMIT {$start},{$perpage}");
    while ($value = $_SGLOBAL['db']->fetch_array($query)) {
        $list[$value['uid']] = $value;
    }
    if ($cache_mode && $cache_file) {
        swritefile($cache_file, serialize($list));
    }
}
foreach ($list as $key => $value) {
    $value['isfriend'] = $value['uid'] == $space['uid'] || $space['friends'] && in_array($value['uid'], $space['friends']) ? 1 : 0;
    realname_set($value['uid'], $value['username'], $value['name'], $value['namestatus']);
    $fuids[] = $value['uid'];
    $list[$key] = $value;
}
//在线状态
$ols = array();
if ($fuids) {
    $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('session') . " WHERE uid IN (" . simplode($fuids) . ")");
    while ($value = $_SGLOBAL['db']->fetch_array($query)) {
        if (!$value['magichidden']) {
            $ols[$value['uid']] = $value['lastactivity'];
开发者ID:v998,项目名称:discuzx-en,代码行数:31,代码来源:space_top.php

示例5: strlen

         }
         if ($valid) {
             $n = strlen($line);
             $o = ftell($fp) - $n;
             $lines[] = $cursor . '-' . $o . '-' . $n;
             //Record information: the line number - the starting position - length
             if ($offset >= $start && $offset < $start + $perpage) {
                 $list[] = $loginfo;
             }
             $offset++;
         }
         $cursor++;
     }
     fclose($fp);
     $count = count($lines);
     swritefile($tmpfile, implode(';', $lines));
 }
 if ($fromcache) {
     $data = explode(';', sreadfile($tmpfile));
     $count = count($data);
     $lines = array_slice($data, $start, $perpage);
     if ($lines) {
         $fp = fopen(S_ROOT . './data/log/' . $_GET['file'], 'r');
         foreach ($lines as $line) {
             list($l, $o, $n) = explode('-', $line);
             fseek($fp, $o);
             $line = $n ? fread($fp, $n) : '';
             $loginfo = parselog($line);
             $loginfo['line'] = $l;
             $uids[] = $loginfo['uid'];
             $list[] = $loginfo;
开发者ID:v998,项目名称:discuzx-en,代码行数:31,代码来源:admincp_log.php

示例6: closedir

        closedir($dh);
    }
} elseif ($_GET['op'] == 'edit') {
    $filename = checkfilename($_GET['filename']);
    $filefullname = $tpldir . $filename;
    $fp = fopen($filefullname, 'rb');
    $content = trim(shtmlspecialchars(fread($fp, filesize($filefullname))));
    fclose($fp);
} elseif ($_GET['op'] == 'repair') {
    $filename = checkfilename($_GET['filename']);
    $filefullname = $tpldir . $filename;
    //复制当前的文件
    $d_file = $filefullname . '.bak';
    if (file_exists($d_file)) {
        if (!@copy($d_file, $filefullname)) {
            swritefile($filefullname, sreadfile($d_file));
            @unlink($d_file);
        } else {
            @unlink($d_file);
        }
    } else {
        cpmessage('designated_template_files_can_not_be_restored');
    }
    cpmessage('do_success', $turl);
}
function checkfilename($filename)
{
    global $tpldir;
    $isedit = false;
    if (!empty($filename)) {
        $filename = str_replace(array('..', '/', '\\'), array('', '', ''), $filename);
开发者ID:NaturalWill,项目名称:UCQA,代码行数:31,代码来源:admincp_template.php

示例7: deleteblocks

function deleteblocks($bids)
{
    global $_SGLOBAL;
    if (!checkperm('managead')) {
        return false;
    }
    $dels = $newids = array();
    $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('block') . " WHERE bid IN (" . simplode($bids) . ")");
    while ($value = $_SGLOBAL['db']->fetch_array($query)) {
        //删除模板与模板编译文件
        $tpl = S_ROOT . "./data/blocktpl/{$value['bid']}.htm";
        //原始
        swritefile($tpl, ' ');
        $newids[] = $value['bid'];
        $dels[] = $value;
    }
    if (empty($dels)) {
        return array();
    }
    //数据
    $_SGLOBAL['db']->query("DELETE FROM " . tname('block') . " WHERE bid IN (" . simplode($newids) . ")");
    return $dels;
}
开发者ID:NaturalWill,项目名称:UCQA,代码行数:23,代码来源:function_delete.php

示例8: array

	extract($sqlarr);

	//显示数量
	$shownum = 9;
	
	$polllist = array();
	$query = $_SGLOBAL['db']->query("SELECT main.*
		FROM ".tname('poll')." main
		WHERE ".implode(' AND ', $wherearr)."
		ORDER BY main.{$order} $sc LIMIT 0,$shownum");
	while ($value = $_SGLOBAL['db']->fetch_array($query)) {
		realname_set($value['uid'], $value['username']);
		$polllist[] = $value;
	}
	if($_SGLOBAL['network']['poll']['cache']) {
		swritefile($cachefile, serialize($polllist));
	}
}
foreach($polllist as $key => $value) {
	realname_set($value['uid'], $value['username']);
	$polllist[$key] = $value;
}

//记录
$dolist = array();
$query = $_SGLOBAL['db']->query("SELECT *
	FROM ".tname('doing')."
	ORDER BY dateline DESC LIMIT 0,5");
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
	realname_set($value['uid'], $value['username']);
	$value['title'] = getstr($value['message'], 0, 0, 0, 0, 0, -1);
开发者ID:NaturalWill,项目名称:UCQA,代码行数:31,代码来源:network.php

示例9: showmessage

    if (empty($result)) {
        showmessage('blog_import_no_result', '', 1, array(shtmlspecialchars($org_result)));
    }
    //解析结果
    $results = xmltoarray($result);
    $ones = array_pop(array_slice($results, -1));
    if (!isset($ones['postid'])) {
        if (empty($ones)) {
            $return = "<textarea name=\"tmp[]\" style=\"width:98%;\" rows=\"4\">" . shtmlspecialchars($result) . "</textarea>";
        } else {
            $return = implode(', ', $ones);
        }
        showmessage('blog_import_no_data', '', 1, array($return));
    }
    //缓存结果
    swritefile($userfile, serialize($results));
} elseif (submitcheck('import2submit')) {
    include_once S_ROOT . './source/function_blog.php';
    if (empty($results) || empty($_POST['ids'])) {
        showmessage('choose_at_least_one_log', 'cp.php?ac=import');
    }
    $allcount = $incount = 0;
    krsort($results);
    //倒序
    foreach ($results as $key => $value) {
        $allcount = $allcount + 1;
        if (in_array($key, $_POST['ids'])) {
            $value = saddslashes($value);
            $dateline = intval(sstrtotime($value['dateCreated']));
            $subject = getstr($value['title'], 80, 1, 1, 1);
            $message = isset($value['description']) ? $value['description'] : $value['content'];
开发者ID:xiaoxiaoleo,项目名称:ngintek,代码行数:31,代码来源:cp_import.php

示例10: showmessage

}
if ($_SGLOBAL['supe_uid']) {
    //已登录,直接跳转个人首页
    showmessage('enter_the_space', 'space.php?do=home', 0);
}
if (empty($_SCONFIG['networkpublic'])) {
    $cachefile = S_ROOT . './data/cache_index.txt';
    $cachetime = @filemtime($cachefile);
    $spacelist = array();
    if ($_SGLOBAL['timestamp'] - $cachetime > 900) {
        //20位热门用户
        $query = $_SGLOBAL['db']->query("SELECT s.*, sf.resideprovince, sf.residecity\r\n\t\t\tFROM " . tname('space') . " s\r\n\t\t\tLEFT JOIN " . tname('spacefield') . " sf ON sf.uid=s.uid\r\n\t\t\tORDER BY s.friendnum DESC LIMIT 0,20");
        while ($value = $_SGLOBAL['db']->fetch_array($query)) {
            $spacelist[] = $value;
        }
        swritefile($cachefile, serialize($spacelist));
    } else {
        $spacelist = unserialize(sreadfile($cachefile));
    }
    //应用
    $myappcount = 0;
    $myapplist = array();
    if ($_SCONFIG['my_status']) {
        $myappcount = $_SGLOBAL['db']->result($_SGLOBAL['db']->query("SELECT COUNT(*) FROM " . tname('myapp') . " WHERE flag>='0'"), 0);
        if ($myappcount) {
            $query = $_SGLOBAL['db']->query("SELECT appid,appname FROM " . tname('myapp') . " WHERE flag>=0 ORDER BY flag DESC, displayorder LIMIT 0,7");
            while ($value = $_SGLOBAL['db']->fetch_array($query)) {
                $myapplist[] = $value;
            }
        }
    }
开发者ID:AlexChien,项目名称:ey_uhome,代码行数:31,代码来源:index.php

示例11: obclean

    obclean();
    $s = array("/(\r|\n)/", "/\\<div\\s+class=\"pages\"\\>.+?\\<\\/div\\>/is", "/\\s+(href|src)=\"(.+?)\"/ie");
    $r = array("\n", '', "js_mkurl('\\1', '\\2')");
    $content = '';
    if ($obcontent) {
        $obcontent = preg_replace($s, $r, $obcontent);
        $lines = explode("\n", $obcontent);
        foreach ($lines as $line) {
            $line = addcslashes(trim($line), '/\'\\');
            $content .= "document.writeln('{$line}');\n";
        }
    } else {
        $content .= "document.writeln('NO DATA')";
    }
    if ($updatetime > 0) {
        swritefile($cachefile, $content);
    }
    echo $content;
} elseif ($adid) {
    //读取广告文件
    $file = './data/adtpl/' . $adid . '.htm';
    if (@($lines = file($file))) {
        foreach ($lines as $line) {
            $line = addcslashes(trim($line), '/\'\\');
            echo "document.writeln('{$line}');\n";
        }
    } else {
        echo "document.writeln('NO AD.')";
    }
}
function js_mkurl($tag, $url)
开发者ID:shiyake,项目名称:php-ihome,代码行数:31,代码来源:js.php

示例12: sub_gettables

function sub_gettables() {
	global $_SGLOBAL, $_SC;
	
	$file = S_ROOT.'./data/data_table_'.X_RELEASE.'.txt';
	
	$tables = array();
	$content = trim(sreadfile($file));
	if($content) {
		$tables = unserialize($content);
	} else {
		$query = $_SGLOBAL['db']->query("SHOW TABLES LIKE '$_SC[tablepre]%'");
		while ($value = $_SGLOBAL['db']->fetch_array($query)) {
			$values = array_values($value);
			if(!strexists($values[0], 'cache')) {
				$subquery = $_SGLOBAL['db']->query("SHOW CREATE TABLE $values[0]");
				$result = $_SGLOBAL['db']->fetch_array($subquery);
				$tables[$values[0]] = sub_getcolumn($result['Create Table']);
			}
		}
		swritefile($file, serialize($tables));
	}
	
	return $tables;
	
}
开发者ID:BGCX262,项目名称:zyyhong-svn-to-git,代码行数:25,代码来源:admincp_block.php

示例13: array

	
	$s = array("/(\r|\n)/", "/\<div\s+class=\"pages\"\>.+?\<\/div\>/is", "/\s+(href|src)=\"(.+?)\"/ie");
	$r = array("\n", '', 'js_mkurl("\\1", "\\2")');

	$content = '';
	if($obcontent) {
		$obcontent = preg_replace($s, $r, $obcontent);
		$lines = explode("\n", $obcontent);
		foreach ($lines as $line) {
			$line = addcslashes(trim($line), '/\'\\');
			$content .= "document.writeln('$line');\n";
		}
	} else {
		$content .= "document.writeln('NO DATA')";
	}
	if($updatetime > 0) swritefile($cachefile, $content);
	echo $content;

} elseif ($adid) {
	//读取广告文件
	$file = './data/adtpl/'.$adid.'.htm';
	if(@$lines = file($file)) {
		foreach ($lines as $line) {
			$line = addcslashes(trim($line), '/\'\\');
			echo "document.writeln('$line');\n";
		}
	} else {
		echo "document.writeln('NO AD.')";
	}
}
开发者ID:BGCX262,项目名称:zyyhong-svn-to-git,代码行数:29,代码来源:js.php

示例14: cpmessage

            break;
    }
    if (empty($adcodes)) {
        cpmessage('please_check_whether_the_option_complete_required');
    } else {
        $adcodes['type'] = $_POST['adcode']['type'];
    }
    $setarr = array('title' => $_POST['title'], 'pagetype' => $_POST['pagetype'], 'adcode' => addslashes(serialize(sstripslashes($adcodes))), 'system' => $_POST['system'], 'available' => empty($_POST['system']) ? 1 : intval($_POST['available']));
    if (empty($adid)) {
        $adid = inserttable('ad', $setarr, 1);
    } else {
        updatetable('ad', $setarr, array('adid' => $adid));
    }
    //写入模板
    $tpl = S_ROOT . './data/adtpl/' . $adid . '.htm';
    swritefile($tpl, $html);
    //缓存更新
    include_once S_ROOT . './source/function_cache.php';
    ad_cache();
    cpmessage('do_success', 'admincp.php?ac=ad');
} elseif (submitcheck('delsubmit')) {
    include_once S_ROOT . './source/function_delete.php';
    if (!empty($_POST['adids']) && deleteads($_POST['adids'])) {
        //缓存更新
        include_once S_ROOT . './source/function_cache.php';
        ad_cache();
        cpmessage('do_success', 'admincp.php?ac=ad');
    } else {
        cpmessage('please_choose_to_remove_advertisements', 'admincp.php?ac=ad');
    }
}
开发者ID:xiaoxiaoleo,项目名称:ngintek,代码行数:31,代码来源:admincp_ad.php

示例15: parse_template

function parse_template($tpl) {
	global $_SGLOBAL, $_SC, $_SCONFIG;

	//包含模板
	$_SGLOBAL['sub_tpls'] = array($tpl);

	$tplfile = S_ROOT.'./'.$tpl.'.htm';
	$objfile = S_ROOT.'./data/tpl_cache/'.str_replace('/','_',$tpl).'.php';
	
	//read
	if(!file_exists($tplfile)) {
		$tplfile = str_replace('/'.$_SCONFIG['template'].'/', '/default/', $tplfile);
	}
	$template = sreadfile($tplfile);
	if(empty($template)) {
		exit("Template file : $tplfile Not found or have no access!");
	}

	//模板
	$template = preg_replace("/\<\!\-\-\{template\s+([a-z0-9_\/]+)\}\-\-\>/ie", "readtemplate('\\1')", $template);
	//处理子页面中的代码
	$template = preg_replace("/\<\!\-\-\{template\s+([a-z0-9_\/]+)\}\-\-\>/ie", "readtemplate('\\1')", $template);
	//解析模块调用
	$template = preg_replace("/\<\!\-\-\{block\/(.+?)\}\-\-\>/ie", "blocktags('\\1')", $template);
	//解析广告
	$template = preg_replace("/\<\!\-\-\{ad\/(.+?)\}\-\-\>/ie", "adtags('\\1')", $template);
	//时间处理
	$template = preg_replace("/\<\!\-\-\{date\((.+?)\)\}\-\-\>/ie", "datetags('\\1')", $template);
	//头像处理
	$template = preg_replace("/\<\!\-\-\{avatar\((.+?)\)\}\-\-\>/ie", "avatartags('\\1')", $template);
	//PHP代码
	$template = preg_replace("/\<\!\-\-\{eval\s+(.+?)\s*\}\-\-\>/ies", "evaltags('\\1')", $template);

	//开始处理
	//变量
	$var_regexp = "((\\\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)(\[[a-zA-Z0-9_\-\.\"\'\[\]\$\x7f-\xff]+\])*)";
	$template = preg_replace("/\<\!\-\-\{(.+?)\}\-\-\>/s", "{\\1}", $template);
	$template = preg_replace("/([\n\r]+)\t+/s", "\\1", $template);
	$template = preg_replace("/(\\\$[a-zA-Z0-9_\[\]\'\"\$\x7f-\xff]+)\.([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/s", "\\1['\\2']", $template);
	$template = preg_replace("/\{(\\\$[a-zA-Z0-9_\[\]\'\"\$\.\x7f-\xff]+)\}/s", "<?=\\1?>", $template);
	$template = preg_replace("/$var_regexp/es", "addquote('<?=\\1?>')", $template);
	$template = preg_replace("/\<\?\=\<\?\=$var_regexp\?\>\?\>/es", "addquote('<?=\\1?>')", $template);
	//逻辑
	$template = preg_replace("/\{elseif\s+(.+?)\}/ies", "stripvtags('<?php } elseif(\\1) { ?>','')", $template);
	$template = preg_replace("/\{else\}/is", "<?php } else { ?>", $template);
	//循环
	for($i = 0; $i < 6; $i++) {
		$template = preg_replace("/\{loop\s+(\S+)\s+(\S+)\}(.+?)\{\/loop\}/ies", "stripvtags('<?php if(is_array(\\1)) { foreach(\\1 as \\2) { ?>','\\3<?php } } ?>')", $template);
		$template = preg_replace("/\{loop\s+(\S+)\s+(\S+)\s+(\S+)\}(.+?)\{\/loop\}/ies", "stripvtags('<?php if(is_array(\\1)) { foreach(\\1 as \\2 => \\3) { ?>','\\4<?php } } ?>')", $template);
		$template = preg_replace("/\{if\s+(.+?)\}(.+?)\{\/if\}/ies", "stripvtags('<?php if(\\1) { ?>','\\2<?php } ?>')", $template);
	}
	//常量
	$template = preg_replace("/\{([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\}/s", "<?=\\1?>", $template);
	
	//替换
	if(!empty($_SGLOBAL['block_search'])) {
		$template = str_replace($_SGLOBAL['block_search'], $_SGLOBAL['block_replace'], $template);
	}
	
	//换行
	$template = preg_replace("/ \?\>[\n\r]*\<\? /s", " ", $template);
	
	//附加处理
	$template = "<?php if(!defined('IN_UCHOME')) exit('Access Denied');?><?php subtplcheck('".implode('|', $_SGLOBAL['sub_tpls'])."', '$_SGLOBAL[timestamp]', '$tpl');?>$template<?php ob_out();?>";
	
	//write
	if(!swritefile($objfile, $template)) {
		exit("File: $objfile can not be write!");
	}
}
开发者ID:BGCX262,项目名称:zyyhong-svn-to-git,代码行数:70,代码来源:function_template.php


注:本文中的swritefile函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。