/** * Special function for files including * * @param string $file * @param bool|Closure $show_errors If bool error will be processed, if Closure - only Closure will be called * * @return bool * @since 1.0.0 */ function _include_once($file, $show_errors = true) { return _include($file, true, $show_errors); }
rmdir($dir); } } } unset($fs, $file, $dir); /** * Updating of System */ if (file_exists("{$module_dir}/versions.json")) { $old_version = file_get_json("{$module_dir}/meta_old.json")['version']; foreach (file_get_json("{$module_dir}/versions.json") as $version) { if (version_compare($old_version, $version, '<')) { /** * PHP update script */ _include("{$module_dir}/meta/update/{$version}.php", true, false); /** * Database update */ if (isset($module_data['db']) && file_exists("{$module_dir}/meta/db.json")) { $db_json = file_get_json("{$module_dir}/meta/db.json"); time_limit_pause(); foreach ($db_json as $database) { if ($module_data['db'][$database] == 0) { $db_type = $Core->db_type; } else { $db_type = $Config->db[$module_data['db'][$database]]['type']; } $sql_file = "{$module_dir}/meta/update_db/{$database}/{$version}/{$db_type}.sql"; if (file_exists($sql_file)) { $db->{$module_data['db'][$database]}()->q(explode(';', file_get_contents($sql_file)));
<?php define("BASE_DIR", '/Applications/MAMP/htdocs/Sandbox/TCint'); function _include($file, $type = 'template') { $r = true; if (isset($file)) { $file_to_include = BASE_DIR . "/{$type}/" . $file; if (file_exists($file_to_include)) { require $file_to_include; } else { $r = false; } } else { $r = false; } return $r; } _include("startup.php"); if (isset($_GET['template_load'])) { if (!_include($_GET['template_load'])) { echo 'couldnt find page'; } } else { if (!_include("html.php")) { echo "File doesnt exist"; } }
function _theme(&$panel) { function _commentCompression($str) { $str = preg_replace('/<!-- BEGIN:(.*?) -->.*?<!-- END:\\1 -->/s', '##$1##', $str); $str = preg_replace('/##BEGIN:(.*?)##.*?##END:\\1##/s', '##$1##', $str); return $str; } function _replace($replace, $with, &$inside) { $inside = str_ireplace('<!-- ' . $replace . ' -->', $with, $inside); $inside = str_ireplace('##' . $replace . '##', $with, $inside); } function _include($u, $a) { foreach ($a as $b) { if (file_exists($u . $b)) { ob_start(); include $u . $b; $u = ob_get_contents(); ob_end_clean(); return _commentCompression($u); } } return false; } $current = $panel['current']; if (!$current) { $current = $panel['website']; } $theme = _include('themes/' . $current['opts']['theme'] . '/templates/' . $current['opts']['template'], array(0 => '', 1 => '.php', 2 => '.html', 3 => '.txt')); $page = _include('pages/' . $panel['website']['page'], array(0 => '.php', 1 => '.html', 2 => '.txt')); if (!$page) { $page = _include('pages/' . $current['opts']['missing'], array(0 => '.php', 1 => '.html', 2 => '.txt')); } _replace('content', $page, $theme); $theme = preg_replace('/(href|src)="\\.\\./', '$1="' . 'themes/' . $current['opts']['theme'], $theme); foreach ($panel['html'] as $a => $b) { _replace($a, $b, $theme); } if ($current['opts']) { foreach ($current['opts'] as $a => $b) { if (is_string($b)) { _replace($a, $b, $theme); } } } foreach ($panel['website']['opts'] as $a => $b) { if (is_string($b)) { _replace('site-' . $a, $b, $theme); } } $theme = preg_replace('/(<!--\\s|##).*?(\\s-->|##)/', '', $theme); echo $theme; }
$val = $vars[$m[1]] ? $vars[$m[1]] : $m[2]; //return "$prefix $val $suffix"; return $prefix . $val . $suffix; } return htmlspecialchars($prefix . $m[2] . $suffix); } function _include($fn) { return include $fn; } $vars = $_GET; $css = file_get_contents('theme.css'); if (isset($_GET['additional_css_file'])) { $files = explode(',', $_GET['additional_css_file']); foreach ($files as $fn) { $custom = basename(trim($fn), '.css'); if ($custom && file_exists("{$custom}.css.php")) { $vars = array_merge(_include("{$custom}.css.php"), $vars); } if ($custom && file_exists("{$custom}.css")) { $css .= "\n" . file_get_contents("{$custom}.css"); } } } $css = preg_replace_callback('/\\/\\*BEGIN:([a-zA-Z0-9_]+)\\*\\/(.*)\\/\\*END:(\\1)\\*\\//U', 'replacer', $css); # relace rgba to rgb on IE8 if (isset($vars['ie']) && $vars['ie']) { $css = preg_replace('/rgba\\(([0-9. ]*),([0-9. ]*),([0-9. ]*),([0-9. ]*)\\)/i', 'rgb($1,$2,$3)', $css); } header('Content-Type: text/css'); echo $css;
/** * Executes plugins processing, blocks and module page generation */ function __finish() { static $finished = false; if ($finished) { return; } $finished = true; $Config = Config::instance(); $Page = Page::instance(); /** * If site is closed, user is not admin, and it is not request for sign in */ if (!$Config->core['site_mode'] && !(User::instance()->admin() || API && $Config->route === ['user', 'sign_in'])) { code_header(503); return; } if (defined('ERROR_CODE')) { $Page->error(); } Trigger::instance()->run('System/Index/preload'); if (!IN_ADMIN && !$this->api && file_exists(MODULES . '/' . MODULE . '/index.html')) { ob_start(); _include(MODULES . '/' . MODULE . '/index.html', false, false); $Page->content(ob_get_clean()); if ($this->title_auto) { $Page->title(Language::instance()->{HOME ? 'home' : MODULE}); } } elseif (!defined('ERROR_CODE') && !$this->stop) { $this->init_auto && $this->init(); } if ($this->generate_auto) { $this->generate(); } if ($this->stop) { if (_getcookie('sign_out') && !(API && MODULE == 'System' && $Config->route == ['user', 'sign_out'])) { _setcookie('sign_out', ''); } return; } if (defined('ERROR_CODE')) { $Page->error(); } elseif (_getcookie('sign_out') && !(API && MODULE == 'System' && $Config->route == ['user', 'sign_out'])) { _setcookie('sign_out', ''); } Trigger::instance()->run('System/Index/postload'); }
<?php echo _include("@backend/views/nav.php"); _asset('@web/demo/css/site.css'); ?> hello word <?php echo _include("@backend/views/footer.php"); ?> <script type="text/javascript"> mysoft.prepare(function(){ console.log($("body")); }); </script>
rmdir($dir); } } } unset($fs, $file, $dir); /** * Updating of plugin */ if (file_exists("{$plugin_dir}/versions.json")) { $old_version = file_get_json("{$plugin_dir}/meta_old.json")['version']; foreach (file_get_json("{$plugin_dir}/versions.json") as $version) { if (version_compare($old_version, $version, '<')) { /** * PHP update script */ _include("{$plugin_dir}/meta/update/{$version}.php", true, false); } } unset($old_version); } unlink("{$plugin_dir}/fs_old.json"); unlink("{$plugin_dir}/meta_old.json"); /** * Restore previous plugin state */ if ($active) { $Config->components['plugins'][] = $plugin; $Config->save(); clean_pcache(); Trigger::instance()->run('admin/System/components/plugins/enable', ['name' => $plugin]); }
/** * Change language * * @param string $language * * @return bool */ function change($language) { static $changed_once = false; if ($this->fixed_language && $changed_once) { return false; } $changed_once = true; if ($language == $this->clanguage) { return true; } $Config = Config::instance(true); if (empty($language)) { if ($Config && $Config->core['multilingual']) { $language = $this->scan_aliases($Config->core['active_languages']) ?: $language; } } if (!$Config || $language == $Config->core['language'] || $Config->core['multilingual'] && in_array($language, $Config->core['active_languages'])) { $this->clanguage = $language; $return = false; $Cache = Cache::instance(); /** * If translations in cache */ if ($translate = $Cache->{"languages/{$this->clanguage}"}) { $this->set($translate); $return = true; /** * Otherwise check for system translations */ } elseif (file_exists(LANGUAGES . "/{$this->clanguage}.json")) { /** * Set system translations */ $this->set(file_get_json_nocomments(LANGUAGES . "/{$this->clanguage}.json")); $translate =& $this->translate; $translate['clanguage'] = $this->clanguage; if (!isset($translate['clang'])) { $translate['clang'] = mb_strtolower(mb_substr($this->clanguage, 0, 2)); } if (!isset($translate['clanguage_en'])) { $translate['clanguage_en'] = $this->clanguage; } if (!isset($translate['locale'])) { $translate['locale'] = $this->clang . '_' . strtoupper($this->clang); } /** * Set modules' translations */ foreach (get_files_list(MODULES, false, 'd') as $module) { if (file_exists(MODULES . "/{$module}/languages/{$this->clanguage}.json")) { $this->set(file_get_json_nocomments(MODULES . "/{$module}/languages/{$this->clanguage}.json") ?: []); } } unset($module); /** * Set plugins' translations */ foreach (get_files_list(PLUGINS, false, 'd') as $plugin) { if (file_exists(PLUGINS . "/{$plugin}/languages/{$this->clanguage}.json")) { $this->set(file_get_json_nocomments(PLUGINS . "/{$plugin}/languages/{$this->clanguage}.json") ?: []); } } unset($plugin); Trigger::instance()->run('System/general/languages/load', ['clanguage' => $this->clanguage, 'clang' => $this->clang, 'cregion' => $this->cregion, 'clanguage_en' => $this->clanguage_en]); $Cache->{"languages/{$this->clanguage}"} = $translate; $return = true; } _include(LANGUAGES . "/{$this->clanguage}.php", false, false); header("Content-Language: {$translate['content_language']}"); return $return; } return false; }
/** * Created by PhpStorm. * User: roman.turchenko * Date: 26.06.14 * Time: 16:42 */ function __autoload($class_name) { _include(CONTEROLLERS_DIR . '/' . $class_name . '.php'); _include(MODELS_DIR . '/' . $class_name . '.php'); _include(VIEWS_DIR . '/' . $class_name . '.php'); }
<?php echo Html::csrfMetaTags(); ?> <title><?php echo Html::encode($this->title); ?> </title> <?php $this->head(); ?> <?php echo _asset('@static/css/base.min.css'); ?> <script type="text/javascript"> <?php echo _include("@webroot/js/mysoft.js"); ?> </script> </head> <body> <?php $this->beginBody(); ?> <div class="wrap"> <div class="container"> <?php echo $content; ?> </div> </div> <?php
function _include_once($viewFile, $params = []) { static $_included = []; if (isset($_included[md5($viewFile)])) { return false; } else { $_included[md5($viewFile)] = $viewFile; return _include($viewFile, $params); } }