本文整理汇总了PHP中strip_whitespace函数的典型用法代码示例。如果您正苦于以下问题:PHP strip_whitespace函数的具体用法?PHP strip_whitespace怎么用?PHP strip_whitespace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strip_whitespace函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: build_runtime
function build_runtime()
{
// 加载常量定义文件
require CORE_PATH . '/sociax/defines.php';
// 加载路径定义文件
require CORE_PATH . '/sociax/paths.php';
// 定义核心编译的文件
$runtime[] = CORE_PATH . '/sociax/functions.php';
// 系统函数
$runtime[] = CORE_PATH . '/sociax/extend.php';
// 扩展函数库
if (version_compare(PHP_VERSION, '5.2.0', '<')) {
// 加载兼容函数
$runtime[] = THINK_PATH . '/Common/compat.php';
}
// 核心基类必须加载
$runtime[] = THINK_PATH . '/Core/Think.class.php';
// 读取核心编译文件列表
if (is_file(CONFIG_PATH . 'core.php')) {
// 加载项目自定义的核心编译文件列表
$list = (include CONFIG_PATH . 'core.php');
} else {
// 加载核心编译文件
$list = (include CORE_PATH . '/sociax/core.php');
}
$runtime = array_merge($runtime, $list);
// 加载核心编译文件列表
foreach ($runtime as $key => $file) {
if (is_file($file)) {
require $file;
}
}
// 检查项目目录结构 如果不存在则自动创建
if (!is_dir(RUNTIME_PATH)) {
// 创建项目目录结构
build_app_dir();
} else {
// 检查缓存目录
check_runtime();
}
// 生成核心编译缓存 去掉文件空白以减少大小
// ALL_IN_ONE模式时, NO_CACHE_RUNTIME无效
if (!defined('NO_CACHE_RUNTIME')) {
define('NO_CACHE_RUNTIME', false);
}
if (RUNTIME_ALLINONE || !NO_CACHE_RUNTIME) {
$compile = RUNTIME_ALLINONE;
$content = compile(CORE_PATH . '/sociax/defines.php', $compile);
$content .= compile(CORE_PATH . '/sociax/paths.php', $compile);
foreach ($runtime as $file) {
$content .= compile($file, $compile);
}
if (defined('STRIP_RUNTIME_SPACE') && STRIP_RUNTIME_SPACE == false) {
file_put_contents(RUNTIME_PATH . '/~runtime.php', '<?php' . $content);
} else {
file_put_contents(RUNTIME_PATH . '/~runtime.php', strip_whitespace('<?php' . $content));
}
unset($content);
}
}
开发者ID:armebayelm,项目名称:thinksns-vietnam,代码行数:60,代码来源:runtime.php
示例2: build_runtime
function build_runtime()
{
// 加载常量定义文件
require THINK_PATH . '/Common/defines.php';
// 加载路径定义文件
require defined('PATH_DEFINE_FILE') ? PATH_DEFINE_FILE : THINK_PATH . '/Common/paths.php';
// 定义核心编译的文件
$runtime[] = THINK_PATH . '/Common/functions.php';
// 系统函数
if (version_compare(PHP_VERSION, '5.2.0', '<')) {
// 加载兼容函数
$runtime[] = THINK_PATH . '/Common/compat.php';
}
// 核心基类必须加载
$runtime[] = THINK_PATH . '/Lib/Think/Core/Think.class.php';
// 读取核心编译文件列表
if (is_file(CONFIG_PATH . 'core.php')) {
// 加载项目自定义的核心编译文件列表
$list = (include CONFIG_PATH . 'core.php');
} else {
if (defined('THINK_MODE')) {
// 根据设置的运行模式加载不同的核心编译文件
$list = (include THINK_PATH . '/Mode/' . strtolower(THINK_MODE) . '.php');
} else {
// 默认核心
$list = (include THINK_PATH . '/Common/core.php');
}
}
$runtime = array_merge($runtime, $list);
// 加载核心编译文件列表
foreach ($runtime as $key => $file) {
if (is_file($file)) {
require $file;
}
}
// 检查项目目录结构 如果不存在则自动创建
if (!is_dir(RUNTIME_PATH)) {
// 创建项目目录结构
build_app_dir();
} else {
// 检查缓存目录
check_runtime();
}
// 生成核心编译缓存 去掉文件空白以减少大小
if (!defined('NO_CACHE_RUNTIME')) {
echo "gggggg";
$compile = defined('RUNTIME_ALLINONE');
$content = compile(THINK_PATH . '/Common/defines.php', $compile);
$content .= compile(defined('PATH_DEFINE_FILE') ? PATH_DEFINE_FILE : THINK_PATH . '/Common/paths.php', $compile);
foreach ($runtime as $file) {
$content .= compile($file, $compile);
}
if (defined('STRIP_RUNTIME_SPACE') && STRIP_RUNTIME_SPACE == false) {
file_put_contents(RUNTIME_PATH . '~runtime.php', '<?php' . $content);
} else {
file_put_contents(RUNTIME_PATH . '~runtime.php', strip_whitespace('<?php' . $content));
}
unset($content);
}
}
开发者ID:bennylii,项目名称:waterfall,代码行数:60,代码来源:runtime.php
示例3: run
public function run(&$params)
{
if (!defined('BUILD_LITE_FILE')) {
return;
}
$litefile = C('RUNTIME_LITE_FILE', null, RUNTIME_PATH . 'lite.php');
if (is_file($litefile)) {
return;
}
$defs = get_defined_constants(true);
$content = 'namespace {$GLOBALS[\'_beginTime\'] = microtime(TRUE);';
if (MEMORY_LIMIT_ON) {
$content .= '$GLOBALS[\'_startUseMems\'] = memory_get_usage();';
}
// 生成数组定义
unset($defs['user']['BUILD_LITE_FILE']);
$content .= $this->buildArrayDefine($defs['user']) . '}';
// 读取编译列表文件
$filelist = is_file(CONF_PATH . 'lite.php') ? include CONF_PATH . 'lite.php' : array(THINK_PATH . 'Common/functions.php', COMMON_PATH . 'Common/function.php', CORE_PATH . 'Think' . EXT, CORE_PATH . 'Hook' . EXT, CORE_PATH . 'App' . EXT, CORE_PATH . 'Dispatcher' . EXT, CORE_PATH . 'Log' . EXT, CORE_PATH . 'Log/Driver/File' . EXT, CORE_PATH . 'Route' . EXT, CORE_PATH . 'Controller' . EXT, CORE_PATH . 'View' . EXT, CORE_PATH . 'Storage' . EXT, CORE_PATH . 'Storage/Driver/File' . EXT, CORE_PATH . 'Exception' . EXT, BEHAVIOR_PATH . 'ParseTemplateBehavior' . EXT, BEHAVIOR_PATH . 'ContentReplaceBehavior' . EXT);
// 编译文件
foreach ($filelist as $file) {
if (is_file($file)) {
$content .= compile($file);
}
}
// 处理Think类的start方法
$content = preg_replace('/\\$runtimefile = RUNTIME_PATH(.+?)(if\\(APP_STATUS)/', '\\2', $content, 1);
$content .= "\nnamespace { Think\\Think::addMap(" . var_export(\Think\Think::getMap(), true) . ");";
$content .= "\nL(" . var_export(L(), true) . ");\nC(" . var_export(C(), true) . ');Think\\Hook::import(' . var_export(\Think\Hook::get(), true) . ');Think\\Think::start();}';
// 生成运行Lite文件
file_put_contents($litefile, strip_whitespace('<?php ' . $content));
}
开发者ID:beyondzgz,项目名称:thinkphp,代码行数:32,代码来源:BuildLiteBehavior.class.php
示例4: run
/**
* 静态方法 启用框架的入口方法
*/
public static function run()
{
self::debug();
//启用Debug模块
self::pathinfo();
//启用pathinfo
self::initfile();
//检测并初始化系统
$controler_src = C('APP_PATH') . '/Action/' . $_GET['m'] . 'Action.class.php';
$runfile = C('RUN_PATH') . '/Action/' . $_GET['m'] . 'Action.class.php';
if (file_exists($controler_src)) {
self::touch($runfile, strip_whitespace(file_get_contents($controler_src)), C('DEBUG'));
$m = $_GET['m'] . 'Action';
$tmp = new $m();
Debug::addmsg("当前访问的控制器类: {$controler_src}");
method_exists($tmp, 'init') ? $tmp->init() : '';
method_exists($tmp, $_GET['a']) ? $tmp->{$_GET}['a']() : Debug::addmsg('<font color="red">当前访问的控制器类: ' . $controler_src . ' 不存在 ' . $_GET['a'] . ' 操作</font>');
} else {
Debug::addmsg("<font color='red'>当前访问的控制器类: {$controler_src} 不存在!</font>");
}
if (C('DEBUG')) {
//DEBGU检测输出
Debug::message();
}
}
开发者ID:sayi21cn,项目名称:cxphp,代码行数:28,代码来源:Action.class.php
示例5: set
/**
* 设置缓存
* @param str $filename
* @param mix $data
* @return mix
*/
public function set($filename, $data)
{
$file = $this->dir . $filename . '.php';
$dir = dirname($filename);
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
return file_put_contents($file, strip_whitespace("<?php\treturn " . var_export($data, true) . ";?>"));
}
开发者ID:jackycgq,项目名称:ppphp,代码行数:15,代码来源:cache.class.php
示例6: test_paramsToSparql
function test_paramsToSparql()
{
$params = queryStringToParams("foo.bar={school}");
$expected = " ?item gc:testPropWithApiLabel ?foo . ?foo gc:testPropWithRdfsLabel <http://education.data.gov.uk/id/school/12345> . ";
$actual = $this->SW->paramsToSparql($params);
$this->assertEquals(strip_whitespace($expected), strip_whitespace($actual), " Failed translating foo.bar={school}");
$params = queryStringToParams("bar.foo.age={school}");
$expected = "\n ?item gc:testPropWithRdfsLabel ?bar .\n ?bar gc:testPropWithApiLabel ?bar_foo . \n ?bar_foo gc:age <http://education.data.gov.uk/id/school/12345> . ";
$actual = $this->SW->paramsToSparql($params);
$this->assertEquals(strip_whitespace($expected), strip_whitespace($actual), " Failed translating bar.foo.age={school}");
}
开发者ID:asavagar,项目名称:EU-data-cloud,代码行数:11,代码来源:sparqlwriter.test.php
示例7: test_css
public function test_css()
{
$this->_reset();
$test = trim($this->CI->asset->css('test'));
$expected = '<link href="' . WEB_PATH . 'assets/css/test.css" media="all" rel="stylesheet"/>';
$this->run($test, $expected, 'Asset css() test 1');
// strip tabs to make it easier to test
$test = strip_whitespace($this->CI->asset->css('test1, test2'));
$expected = "<link href=\"" . WEB_PATH . "assets/css/test1.css\" media=\"all\" rel=\"stylesheet\"/>";
$expected .= "<link href=\"" . WEB_PATH . "assets/css/test2.css\" media=\"all\" rel=\"stylesheet\"/>";
$this->run($test, $expected, 'Asset css() test 2');
}
开发者ID:huayuxian,项目名称:FUEL-CMS,代码行数:12,代码来源:Asset_test.php
示例8: testfunc
public function testfunc()
{
$start_time = microtime(true);
$code = "//\$a='b';\n\$b='c';";
for ($i = 0; $i < 10; $i++) {
$code .= "//\$a='b';\n\$b='c';";
}
$start_time = microtime(true);
$res = strip_whitespace($code);
var_dump($res);
var_dump(microtime(true) - $start_time);
}
开发者ID:fixbugs,项目名称:tips,代码行数:12,代码来源:test.php
示例9: set
public static function set($name, $value)
{
$filename = static::parse_name($name);
// 缓存数据
$dir = dirname($filename);
// 目录不存在则创建
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
// 放入内存缓存
$_cache[$name] = $value;
return file_put_contents($filename, strip_whitespace("<?php\treturn " . var_export($value, true) . ";?>"));
}
开发者ID:minowu,项目名称:smartthink,代码行数:13,代码来源:File.php
示例10: build_runtime_cache
function build_runtime_cache($append = '')
{
// 生成编译文件
$defs = get_defined_constants(TRUE);
$content = '$GLOBALS[\'_beginTime\'] = microtime(TRUE);';
//[sae]编译SaeMC核心
$content .= compile(SAE_PATH . 'Lib/Core/SaeMC.class.php');
if (defined('RUNTIME_DEF_FILE')) {
//[sae] 编译后的常量文件外部引入
//SaeMC::set(RUNTIME_DEF_FILE, '<?php '.array_define($defs['user']));
//[saebuilder] 生成常量文件
$defs['user']['APP_DEBUG'] = false;
//[saebuilder] APP_DEBUG固定为false
unset($defs['user']['SAE_CACHE_BUILDER']);
//[saebuilder]去掉SAE_CACHE_BUILDER常量
file_put_contents(RUNTIME_DEF_FILE, '<?php ' . array_define($defs['user']));
echo 'build runtime_def_file:' . RUNTIME_DEF_FILE . PHP_EOL;
$content .= 'SaeMC::include_file(\'' . RUNTIME_DEF_FILE . '\');';
} else {
$content .= array_define($defs['user']);
}
$content .= 'set_include_path(get_include_path() . PATH_SEPARATOR . VENDOR_PATH);';
//[sae] 读取核心编译文件列表
$list = array(SAE_PATH . 'Common/common.php', SAE_PATH . 'Lib/Core/Think.class.php', CORE_PATH . 'Core/ThinkException.class.php', CORE_PATH . 'Core/Behavior.class.php');
foreach ($list as $file) {
$content .= compile($file);
}
// 系统行为扩展文件统一编译
if (C('APP_TAGS_ON')) {
$content .= build_tags_cache();
}
//[sae] 编译SAE的alias
$alias = (include SAE_PATH . 'Conf/alias.php');
$content .= 'alias_import(' . var_export($alias, true) . ');';
// 编译框架默认语言包和配置参数
//[saebuilder] 处理配置项,将SAE常量原样输出
$content .= $append . "\nL(" . var_export(L(), true) . ");C(" . preg_replace(array('/\'SAE_(.*?)\'/e', '/\'~([a-zA-Z_][a-zA-Z0-9_]*)\\((.*?)\\)\'/'), array('parse_sae_define("\\1")', '\\1(\\2)'), var_export(C(), true)) . ');G(\'loadTime\');Think::Start();';
//[saebuilder] 生成缓存文件
//SaeMC::set(RUNTIME_FILE, strip_whitespace('<?php '.$content));
file_put_contents(RUNTIME_FILE, strip_whitespace('<?php ' . $content));
echo 'build core file:' . RUNTIME_FILE . PHP_EOL;
}
开发者ID:sdgdsffdsfff,项目名称:cardmanage,代码行数:42,代码来源:runtime.php
示例11: build
private static function build()
{
C(include THINK_PATH . '/Common/convention.php');
if (is_file(CONFIG_PATH . 'config.php')) {
C(include CONFIG_PATH . 'config.php');
}
$runtime = defined('RUNTIME_ALLINONE');
$common = '';
$debug = C('APP_DEBUG') && !$runtime;
if (is_file(COMMON_PATH . 'common.php')) {
include COMMON_PATH . 'common.php';
if (!$debug) {
$common .= compile(COMMON_PATH . 'common.php', $runtime);
}
}
if (is_file(CONFIG_PATH . 'app.php')) {
$list = (include CONFIG_PATH . 'app.php');
foreach ($list as $file) {
require $file;
if (!$debug) {
$common .= compile($file, $runtime);
}
}
}
$list = C('APP_CONFIG_LIST');
foreach ($list as $val) {
if (is_file(CONFIG_PATH . $val . '.php')) {
C('_' . $val . '_', array_change_key_case(include CONFIG_PATH . $val . '.php'));
}
}
if ($debug) {
C(include THINK_PATH . '/Common/debug.php');
if (is_file(CONFIG_PATH . 'debug.php')) {
C(include CONFIG_PATH . 'debug.php');
}
} else {
if (defined('RUNTIME_ALLINONE')) {
$defs = get_defined_constants(TRUE);
$content = array_define($defs['user']);
$content .= substr(file_get_contents(RUNTIME_PATH . '~runtime.php'), 5);
$content .= $common . "\nreturn " . var_export(C(), true) . ';';
file_put_contents(RUNTIME_PATH . '~allinone.php', strip_whitespace('<?php ' . $content));
} else {
$content = "<?php " . $common . "\nreturn " . var_export(C(), true) . ";\n?>";
file_put_contents(RUNTIME_PATH . '~app.php', strip_whitespace($content));
}
}
return;
}
开发者ID:huangwei2wei,项目名称:kfxt,代码行数:49,代码来源:~runtime.php
示例12: find_includes
/**
* Gets all defined includes
*
* @param array $seetags (reference)
* @param string $content
* @param string $file
*/
function find_includes(&$seetags, &$content, $file)
{
$tokens = get_tokens($content);
foreach ($tokens as $key => &$token) {
if (is_string($token)) {
continue;
}
if (!in_array($token[0], array(T_REQUIRE, T_REQUIRE_ONCE, T_INCLUDE, T_INCLUDE_ONCE))) {
continue;
}
$t = get_argument_tokens($tokens, $key);
strip_whitespace($t);
// Strip round brackets
if ($t[0] === "(" and $t[count($t) - 1] === ")") {
$t = array_splice($t, 1, -1);
}
if (!$t) {
possible_syntax_error($tokens, $key, "Missing argument");
continue;
}
if (!is_array($t[0])) {
continue;
}
// Strip leading docroot variable or constant
if (($t[0][0] === T_VARIABLE or $t[0][0] === T_STRING) and in_array($t[0][1], $GLOBALS['docrootvars']) and $t[1] === ".") {
$t = array_splice($t, 2);
}
if (count($t) == 1 and $t[0][0] === T_CONSTANT_ENCAPSED_STRING) {
$includedfile = substr($t[0][1], 1, -1);
$seetags[$includedfile][] = array($file);
continue;
}
if (!$t) {
possible_syntax_error($tokens, $key, "String concatenator without following string");
}
}
}
开发者ID:excelle08,项目名称:SublimePhpTidy,代码行数:44,代码来源:wp-phptidy.php
示例13: cache
/**
* 文件缓存与文件读取
* @param $name 文件名
* @param $value 文件内容,为空则获取缓存
* @param $path 文件所在目录,默认是当前应用的DATA目录
* @param $cached 是否缓存结果,默认缓存
* @return 返回缓存内容
*/
function cache($name, $value = '', $path = DATA_PATH, $cached = true)
{
static $_cache = array();
$filename = $path . $name . '.php';
if ('' !== $value) {
if (is_null($value)) {
// 删除缓存
return false !== strpos($name, '*') ? array_map("unlink", glob($filename)) : unlink($filename);
} else {
// 缓存数据
$dir = dirname($filename);
// 目录不存在则创建
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
}
$_cache[$name] = $value;
return file_put_contents($filename, strip_whitespace("<?php\treturn " . var_export($value, true) . ";?>"));
}
}
if (isset($_cache[$name]) && $cached == true) {
return $_cache[$name];
}
// 获取缓存数据
if (is_file($filename)) {
$value = (include $filename);
$_cache[$name] = $value;
} else {
$value = false;
}
return $value;
}
开发者ID:cwcw,项目名称:cms,代码行数:39,代码来源:File.class.php
示例14: start
/**
* 应用程序初始化
* @access public
* @return void
*/
public static function start()
{
// 注册AUTOLOAD方法
spl_autoload_register('Think\\Think::autoload');
// 设定错误和异常处理
register_shutdown_function('Think\\Think::fatalError');
set_error_handler('Think\\Think::appError');
set_exception_handler('Think\\Think::appException');
// 初始化文件存储方式
Storage::connect(STORAGE_TYPE);
$runtimefile = RUNTIME_PATH . APP_MODE . '~runtime.php';
if (!APP_DEBUG && Storage::has($runtimefile)) {
Storage::load($runtimefile);
} else {
if (Storage::has($runtimefile)) {
Storage::unlink($runtimefile);
}
$content = '';
// 读取应用模式
$mode = (include is_file(CONF_PATH . 'core.php') ? CONF_PATH . 'core.php' : MODE_PATH . APP_MODE . '.php');
// 加载核心文件
foreach ($mode['core'] as $file) {
if (is_file($file)) {
include $file;
if (!APP_DEBUG) {
$content .= compile($file);
}
}
}
// 加载应用模式配置文件
foreach ($mode['config'] as $key => $file) {
is_numeric($key) ? C(include $file) : C($key, include $file);
}
// 读取当前应用模式对应的配置文件
if ('common' != APP_MODE && is_file(CONF_PATH . 'config_' . APP_MODE . '.php')) {
C(include CONF_PATH . 'config_' . APP_MODE . '.php');
}
// 加载模式别名定义
if (isset($mode['alias'])) {
self::addMap(is_array($mode['alias']) ? $mode['alias'] : (include $mode['alias']));
}
// 加载应用别名定义文件
if (is_file(CONF_PATH . 'alias.php')) {
self::addMap(include CONF_PATH . 'alias.php');
}
// 加载模式行为定义
if (isset($mode['tags'])) {
Hook::import(is_array($mode['tags']) ? $mode['tags'] : (include $mode['tags']));
}
// 加载应用行为定义
if (is_file(CONF_PATH . 'tags.php')) {
// 允许应用增加开发模式配置定义
Hook::import(include CONF_PATH . 'tags.php');
}
// 加载框架底层语言包
L(include THINK_PATH . 'Lang/' . strtolower(C('DEFAULT_LANG')) . '.php');
if (!APP_DEBUG) {
$content .= "\nnamespace { Think\\Think::addMap(" . var_export(self::$_map, true) . ");";
$content .= "\nL(" . var_export(L(), true) . ");\nC(" . var_export(C(), true) . ');Think\\Hook::import(' . var_export(Hook::get(), true) . ');}';
Storage::put($runtimefile, strip_whitespace('<?php ' . $content));
} else {
// 调试模式加载系统默认的配置文件
C(include THINK_PATH . 'Conf/debug.php');
// 读取应用调试配置文件
if (is_file(CONF_PATH . 'debug.php')) {
C(include CONF_PATH . 'debug.php');
}
}
}
// 读取当前应用状态对应的配置文件
if (APP_STATUS && is_file(CONF_PATH . APP_STATUS . '.php')) {
C(include CONF_PATH . APP_STATUS . '.php');
}
// 设置系统时区
date_default_timezone_set(C('DEFAULT_TIMEZONE'));
// 检查应用目录结构 如果不存在则自动创建
if (C('CHECK_APP_DIR') && !is_dir(LOG_PATH)) {
// 创建应用目录结构
require THINK_PATH . 'Common/build.php';
}
// 记录加载文件时间
G('loadTime');
// 运行应用
App::run();
}
开发者ID:dlpc,项目名称:shop,代码行数:90,代码来源:Think.class.php
示例15: get_xpub_list
function get_xpub_list($params, $empty_ok = false)
{
$list = array();
if (@$params['xpub']) {
$list = explode(',', strip_whitespace($params['xpub']));
}
if (@$params['xpubfile']) {
$csv = implode(',', file($params['xpubfile']));
$list = explode(',', strip_whitespace($csv));
}
foreach ($list as $idx => $xpub) {
if (!$xpub) {
unset($list[$idx]);
continue;
}
// todo: validate length/form.
if (!is_valid_xpub($xpub)) {
// code 2 means an input validation exception.
throw new Exception("xpub is invalid: {$xpub}", 2);
}
}
if (!count($list) && !$empty_ok) {
// code 2 means an input validation exception.
throw new Exception("No valid xpub keys to process.", 2);
}
return $list;
}
开发者ID:dan-da,项目名称:hd-wallet-addrs,代码行数:27,代码来源:hd-wallet-addrs.php
示例16: get_page_meta_desc
/**
* Get Page Meta Description
*
* @since 2.0
* @uses $metad
* @uses strip_decode
*
* @param bool $echo Optional, default is true. False will 'return' value
* @return string Echos or returns based on param $echo
*/
function get_page_meta_desc($echo = true)
{
$metad = getPageGlobal('metad');
$desc = '';
if ($metad != '') {
$desc = encode_quotes(strip_decode($metad));
} else {
if (getDef('GSAUTOMETAD', true)) {
// use content excerpt, NOT filtered
$desc = strip_decode($content);
if (getDef('GSCONTENTSTRIP', true)) {
$desc = strip_content($desc);
}
$desc = cleanHtml($desc, array('style', 'script'));
// remove unwanted elements that strip_tags fails to remove
$desc = getExcerpt($desc, 160);
// grab 160 chars
$desc = strip_whitespace($desc);
// remove newlines, tab chars
$desc = encode_quotes($desc);
$desc = trim($desc);
}
}
$str = exec_filter('metad', $desc);
// @filter metad (str) meta description in get_page_meta_desc
return echoReturn($str, $echo);
}
开发者ID:HelgeSverre,项目名称:GetSimpleCMS,代码行数:37,代码来源:theme_functions.php
示例17: jiamiFile
function jiamiFile()
{
// 取当前用户的网站信息
$map['uid'] = $this->mid;
$info = M('web_info')->where($map)->find();
// 第一步:取文件内容
$file = SITE_PATH . '/test.php';
$get = trim(wp_file_get_contents($file));
if ('<?php' == strtolower(substr($get, 0, 5))) {
$get = substr($get, 5);
} else {
$get = substr($get, 2);
}
if ('?>' == substr($get, -2)) {
$get = substr($get, 0, -2);
}
// 第二步:取加密的KEY
$key = substr($info['web_key'], 0, 5);
$license = substr($info['web_key'], 5);
// 代码里插入判断授权的代码段
$pre_code = <<<str
\t\t\$ip = gethostbyname ( SITE_DOMAIN );
\t\t\$fip = strtok ( \$ip, '.' );
\t\t\$is_free = \$fip == '10' || \$fip == '127' || \$fip == '168' || \$fip == '192';
\t\tif (! \$is_free) {
\t\t\t\$license = C ( 'WEIPHP_STORE_LICENSE' );
\t\t\t\$key = substr ( \$license, 0, 5 );
\t\t\t\$license = substr ( \$license, 5 );\t\t\t
\t\t\t
\t\t\t\$domain_str = md5 ( think_encrypt ( SITE_DOMAIN, \$key ) );
\t\t\t\$ip_str = md5 ( think_encrypt ( \$ip, \$key ) );
\t\t\tif (\$license != \$domain_str && \$license != \$ip_str) {
\t\t\t\theader("Content-Type: text/html;charset=utf-8");
\t\t\t\techo '禁止访问未授权的应用';
\t\t\t\texit ();
\t\t\t}
\t\t}
str;
$content = strip_whitespace($pre_code . $get);
$content = think_encrypt($content, $key);
$content = "<?php eval(code_decode('{$content}'));";
dump($content);
file_put_contents(SITE_PATH . '/test2.php', $content);
}
开发者ID:chenpusn,项目名称:haozhixian_bak,代码行数:44,代码来源:TestController.class.php
示例18: compiler
/**
* Compile the template file contents
* @access protected
* @param mixed $tmplContent Template content
* @return string
*/
protected function compiler($tmplContent)
{
//Template parsing
$tmplContent = $this->parse($tmplContent);
// Restore is replaced Literal tags
$tmplContent = preg_replace('/<!--###literal(\\d+)###-->/eis', "\$this->restoreLiteral('\\1')", $tmplContent);
// Add Security Code
$tmplContent = '<?php if (!defined(\'SEN_PATH\')) exit();?>' . $tmplContent;
if (C('TMPL_STRIP_SPACE')) {
/* Strip html whitespace and newline */
$find = array('~>\\s+<~', '~>(\\s+\\n|\\r)~');
$replace = array('><', '>');
$tmplContent = preg_replace($find, $replace, $tmplContent);
}
// Optimize the generated php code
$tmplContent = str_replace('?><?php', '', $tmplContent);
return strip_whitespace($tmplContent);
}
开发者ID:davidpersson,项目名称:FrameworkBenchmarks,代码行数:24,代码来源:SenTemplate.class.php
示例19: build_runtime_cache
function build_runtime_cache($append = '')
{
// 生成编译文件
$defs = get_defined_constants(TRUE);
$content = '$GLOBALS[\'_beginTime\'] = microtime(TRUE);';
if (defined('RUNTIME_DEF_FILE')) {
// 编译后的常量文件外部引入
file_put_contents(RUNTIME_DEF_FILE, '<?php ' . array_define($defs['user']));
$content .= 'require \'' . RUNTIME_DEF_FILE . '\';';
} else {
$content .= array_define($defs['user']);
}
$content .= 'set_include_path(get_include_path() . PATH_SEPARATOR . VENDOR_PATH);';
// 读取核心编译文件列表
$list = array(THINK_PATH . 'Common/common.php', CLUSTER_PATH . 'Lib/Core/Think.class.php', CORE_PATH . 'Core/ThinkException.class.php', CORE_PATH . 'Core/Behavior.class.php');
//[cluster] 判断加载IO.php文件
$content .= 'if(!function_exists(\'runtime_set\')){' . compile(IO_PATH) . '}';
//[cluster] 判断加载ThinkFS文件
$content .= 'if(!class_exists(\'ThinkFS\')){' . compile(CLUSTER_PATH . 'Lib/Core/ThinkFS.class.php') . '}';
foreach ($list as $file) {
$content .= compile($file);
}
// 系统行为扩展文件统一编译
$content .= build_tags_cache();
$alias = (include CLUSTER_PATH . 'Conf/alias.php');
$content .= 'alias_import(' . var_export($alias, true) . ');';
// 编译框架默认语言包和配置参数
$content .= $append . "\nL(" . var_export(L(), true) . ");C(" . var_export(C(), true) . ');G(\'loadTime\');Think::Start();';
//[cluster] 生成核心缓存
ThinkFS::set(RUNTIME_FILE, strip_whitespace('<?php ' . str_replace("defined('THINK_PATH') or exit();", ' ', $content)));
}
开发者ID:ysking,项目名称:commlib,代码行数:31,代码来源:runtime.php
示例20: checkCompile
protected function checkCompile()
{
$tplfile = ltrim(str_replace(array(PT_ROOT, '/application/', '/template/'), '/', $this->tplFile), '/');
$compiledFile = CACHE_PATH . '/template/' . substr(str_replace('/', ',', $tplfile), 0, -5) . '.php';
$compile = true;
if (APP_MODE == 'sae') {
$timekey = md5($compiledFile . '_time');
$compiledFile = 'saekv://' . md5($compiledFile);
if (!APP_DEBUG && Cache::get($timekey) > filemtime($this->tplFile)) {
$compile = false;
}
} else {
if (!APP_DEBUG && is_file($compiledFile) && filemtime($compiledFile) > filemtime($this->tplFile)) {
$compile = false;
}
}
if ($compile) {
$content = file_get_contents($this->tplFile);
plugin::call('template_compile_start', $content);
$content = $this->compile($content);
if (!APP_DEBUG) {
$content = preg_replace_callback('/<style[^>]*>([^<]*)<\\/style>/isU', array('self', 'compressCss'), $content);
$content = preg_replace_callback('/<script[^>]*>([^<]+?)<\\/script>/isU', array('self', 'compressJs'), $content);
$content = preg_replace(array("/>\\s+</"), array('> <'), $content);
$content = preg_replace('/\\?>\\s*<\\?php/', '', $content);
$content = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' '), ' ', $content);
$content = strip_whitespace($content);
}
//判断是否开启layout
if (C('LAYOUT', null, false)) {
$includeFile = $this->getTplFile(C('LAYOUT_NAME', null, 'layout'));
$truereturn = realpath($includeFile);
if ($truereturn) {
$layout = $this->compile(file_get_contents($truereturn));
$content = str_replace('__CONTENT__', $content, $layout);
} else {
halt("无法找到对应的layout模版:{$truereturn}");
}
}
$content = '<?php defined(\'PT_ROOT\') || exit(\'Permission denied\');?>' . $this->replace($content);
if (APP_MODE == 'sae') {
Cache::set($timekey, NOW_TIME);
}
plugin::call('template_compile_end', $content);
F($compiledFile, $content);
}
return $compiledFile;
}
开发者ID:oohook,项目名称:PTFrameWork,代码行数:48,代码来源:view.php
注:本文中的strip_whitespace函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论