コード例 #1
0
ファイル: VisualEdit.php プロジェクト: neTpyceB/TMCms-core
 public function init()
 {
     if ((isset($_GET['cms_visual_edit']) || isset($_SESSION['visual_edit'])) && Users::getInstance()->isLogged() && Settings::get('enable_visual_edit')) {
         self::$enabled = true;
         $_SESSION['visual_edit'] = true;
     }
 }
コード例 #2
0
 public function __construct($ids = [])
 {
     if (!Settings::isProductionState()) {
         // Create or update table
         $this->ensureDbTableExists();
     }
     if ($ids) {
         $this->setIds($ids);
     }
     return $this;
 }
コード例 #3
0
 public function endLog()
 {
     // Do nothing if log is disabled
     if (!Settings::get('save_frontend_log')) {
         return;
     }
     new FrontLogEntityRepository();
     // Check bd exists
     foreach ($this->stack as $v) {
         $log = new FrontLogEntity();
         $log->setText($v['text']);
         $log->setFlag($v['flag']);
         $log->save();
     }
 }
コード例 #4
0
 private function init_data()
 {
     if (Settings::getInstance()->get('disable_cms_translations')) {
         return;
         // No translations
     }
     $data = [];
     foreach (Finder::getInstance()->getPathFolders(Finder::TYPE_TRANSLATIONS) as $file) {
         $file_path = $file . Users::getInstance()->getUserLng() . '.php';
         if (stripos($file_path, DIR_BASE) === false) {
             $file_path = DIR_BASE . $file_path;
         }
         if (file_exists($file_path)) {
             $data += (require_once $file_path);
         }
     }
     self::$init_data = $data;
 }
コード例 #5
0
ファイル: Usage.php プロジェクト: neTpyceB/TMCms-core
 /**
  *
  */
 public function __destruct()
 {
     if (Settings::get('do_not_log_cms_usage')) {
         return;
     }
     // This is required for db autocreate
     new AdminUsageEntityRepository();
     foreach ($this->usage as $class_name => $class) {
         foreach ($class as $function_name => $count) {
             $usage = AdminUsageEntityRepository::findOneEntityByCriteria(['function_class' => $class_name, 'function_name' => $function_name]);
             if (!$usage) {
                 $usage = new AdminUsageEntity();
                 $usage->setFunctionClass($class_name);
                 $usage->setFunctionName($function_name);
             }
             $usage->setCounter($usage->getCounter() + $count);
             $usage->save();
         }
     }
 }
コード例 #6
0
 public static function addNewFeedback(array $data, $need_to_save_in_db = true, $send_to_emails = [], $files = [])
 {
     $send_to_emails = (array) $send_to_emails;
     $cacher = Cacher::getInstance()->getDefaultCacher();
     $cache_key = 'module_feedback_add_new_feedback_last_send_ts' . VISITOR_HASH;
     // Check message is not sent too quick
     $last_sent_ts = $cacher->get($cache_key);
     if (NOW - $last_sent_ts < self::$sending_period_seconds) {
         return false;
     }
     // Autocreate db
     $feedbacks = new FeedbackRepository();
     $feedback = NULL;
     // Save to Db
     if ($need_to_save_in_db) {
         $feedback = new Feedback();
         $feedback->loadDataFromArray($data);
         $feedback->save();
     }
     // Send email to manager
     if ($send_to_emails) {
         $msg = '<table><tr><th>Field</th><th>Value</th></tr>';
         foreach ($data as $k => $v) {
             if ($v) {
                 $msg .= '<tr><td>' . $k . '</td><td>' . htmlspecialchars($v) . '</td></tr>';
             }
         }
         $msg .= '</table>';
         $mailer = Mailer::getInstance()->setSubject('New feedback from ' . CFG_DOMAIN)->setSender(Settings::getCommonEmail())->setMessage($msg);
         foreach ($send_to_emails as $email) {
             $mailer->setRecipient($email);
         }
         foreach ($files as $file) {
             $mailer->addAttachment($file);
         }
         $mailer->send();
     }
     // Save last send ts
     $cacher->set($cache_key, NOW);
     return $feedback;
 }
コード例 #7
0
ファイル: App.php プロジェクト: neTpyceB/TMCms-core
 /**
  * Save log into file, and try to send via email to Developers
  */
 public static function flushLog()
 {
     $last_flush_time = Settings::get('cms_tools_application_log_flush');
     if (NOW - $last_flush_time < 453600) {
         return;
         // We do not need stats too often, wait 7 days
     }
     // Send data to original developer site of the existing domain
     self::sendInformation();
     // Now prepare file with aggregated data
     $app_log = new AppLogEntityRepository();
     $app_log->addSimpleSelectFields(['id', 'ts', 'user_id', 'url', 'msg', 'p', 'do']);
     if ($last_flush_time) {
         $app_log->setWhereOld($last_flush_time);
     }
     $app_log->addOrderByField('ts', true);
     $app_log->setGenerateOutputWithIterator(false);
     $users = new AdminUserRepository();
     $users->setGenerateOutputWithIterator(false);
     $users->addSimpleSelectFieldsAsString('CONCAT(`' . $users->getDbTableName() . '`.`name`, " ", `' . $users->getDbTableName() . '`.`surname`) AS `user`');
     $app_log->mergeWithCollection($users, 'user_id');
     $data_log = $app_log->getAsArrayOfObjectData(true);
     $usage = new AdminUsageEntityRepository();
     $data_usage = $usage->getAsArrayOfObjectData(true);
     if ($data_log || $data_usage) {
         $data = ['data' => ['domain' => CFG_DOMAIN, 'ts' => NOW], 'logs' => ['app_log' => $data_log, 'usage' => $data_usage]];
         // Save in file
         if (!file_exists(DIR_CACHE)) {
             FileSystem::mkDir(DIR_CACHE);
         }
         file_put_contents(DIR_CACHE . 'log_data', gzencode(json_encode($data)));
         // Send stats
         Mailer::getInstance()->setSubject('Application and Usage log from ' . Configuration::getInstance()->get('site')['name'] . '(till ' . date(CFG_CMS_DATETIME_FORMAT, NOW) . ')')->setSender(Configuration::getInstance()->get('site')['email'])->setRecipient(CMS_SUPPORT_EMAIL)->setMessage('View attached file')->addAttachment(DIR_CACHE . 'log_data')->send();
         $usage->deleteObjectCollection();
     }
     Settings::getInstance()->set('cms_tools_application_log_flush', NOW);
 }
コード例 #8
0
ファイル: SQL.php プロジェクト: neTpyceB/TMCms-core
 /**
  * Show all columns in table
  * @param string $tbl - table name
  * @return array - list
  */
 public static function getFields($tbl)
 {
     if (Settings::isCacheEnabled()) {
         $cache_key = 'db_table_columns_' . $tbl;
         $cacher = Cacher::getInstance()->getDefaultCacher();
         if (!isset(self::$_cached_tbl_columns[$tbl])) {
             self::$_cached_tbl_columns[$tbl] = $cacher->get($cache_key);
         }
     }
     if (isset(self::$_cached_tbl_columns[$tbl])) {
         return self::$_cached_tbl_columns[$tbl];
     }
     $res = [];
     $sql = self::getInstance()->sql_query("SHOW COLUMNS FROM `{$tbl}`");
     while ($q = $sql->fetch(PDO::FETCH_NUM)) {
         $res[] = $q[0];
     }
     if (Settings::isCacheEnabled()) {
         $cacher->set($cache_key, $res, 86400);
     }
     return self::$_cached_tbl_columns[$tbl] = $res;
 }
コード例 #9
0
            }
            $save_ext = $params;
            break;
        case 'watermark':
            if (!$params) {
                break;
            }
            $check_size_allowed($params);
            if (!preg_match('/^[0-9]+$/', $params)) {
                if (!Settings::isProductionState()) {
                    exit('Error processing params for action "watermark". Example: 1 or main');
                }
                die;
            }
            $data = q_assoc_row('SELECT `image`, `image_pos` FROM `cms_img_proc_perms` WHERE `rule` = "&watermark=' . sql_prepare($params) . '" LIMIT 1');
            if (!$data || !$data['image'] || !$data['image_pos']) {
                if (!Settings::isProductionState()) {
                    exit('Error. Incorrect parameters for action "watermark"');
                }
                die;
            }
            $image->watermark($data['image'], $data['image_pos']);
            break;
    }
}
FileSystem::mkdir(DIR_CACHE . 'images/' . $path);
if (!$image->save(DIR_CACHE . 'images/' . QUERY, $ext, 90) && !Settings::isProductionState()) {
    dump('Not enough memory to resize and sharpen image "' . $path . $file . '".');
}
unset($image);
go('/' . QUERY);
コード例 #10
0
ファイル: Frontend.php プロジェクト: neTpyceB/TMCms-core
 /**
  * Print processed page template with all data
  * @return string
  */
 public function __toString()
 {
     // If content is is rendered from cache
     if (Settings::isCacheEnabled() && $this->cached_page_html) {
         return $this->cached_page_html;
     }
     // Using clickmap script for client click tracking
     if (Settings::get('clickmap')) {
         // Show map on page
         if (isset($_GET['cms_view_clickmap'])) {
             // Load script to show clickmap container
             PageTail::getInstance()->addJsUrl('clickmap_frontend.js');
             PageHead::getInstance()->addJs('cms_page_id = ' . PAGE_ID);
         } else {
             // Just saving clicks - request scripts for registering clicks
             PageTail::getInstance()->addJsUrl('clickmap_register.js');
             PageHead::getInstance()->addJs('cms_page_id = ' . PAGE_ID);
         }
     }
     // Require js for Visual editor
     if (VisualEdit::getInstance()->isEnabled()) {
         PageHead::getInstance()->addJsUrl('visual_edit.js');
         PageHead::getInstance()->addJs('cms_page_id = "' . PAGE_ID . '"');
     }
     // Render HTML
     ob_start();
     // Static page from file
     if ($this->use_html_file_without_parse) {
         echo $this->html;
     } else {
         // Parse content
         // Hide e-mails from bots
         if (strpos($this->html, '@') !== false && preg_match_all('`\\<a([^>]+)href\\=\\"mailto\\:([^">]+)\\"([^>]*)\\>(.+)\\<\\/a\\>`ismU', $this->html, $matches)) {
             PageHead::getInstance()->addJsUrl('email_rewrite.js');
             $matches[5] = [];
             // Replace emails in content with script calls
             foreach ($matches[0] as $k => $v) {
                 // No email?
                 if (isset($matches[5][$v])) {
                     continue;
                 }
                 // No @ symbol?
                 $s = explode('@', $matches[2][$k]);
                 if (count($s) !== 2) {
                     continue;
                 }
                 // No zone?
                 $domain1 = explode('.', $s[1]);
                 $s = $s[0];
                 if (count($domain1) < 2) {
                     continue;
                 }
                 // Now can replace
                 $domain0 = array_pop($domain1);
                 $s = '<script>rewem2nortex("' . preg_replace('/\\sclass=\\"(.+)\\"/', '\\1', str_replace('"', '\'', $matches[3][$k])) . '","' . $s . '","' . implode('.', $domain1) . '","' . $domain0 . '"';
                 if ($matches[2][$k] !== $matches[4][$k]) {
                     $s .= ',"' . trim(str_replace(['@', '.'], ['"+"@"+"', '"+"."+"'], preg_replace('`\\<([a-z])`', '<"+"\\1', str_replace('"', '\\"', $matches[4][$k])))) . '"';
                 }
                 $s .= ');</script>';
                 $matches[5][$v] = $s;
             }
             $matches = $matches[5];
             // Replace found emails with scripts in content
             $this->html = str_replace(array_keys($matches), $matches, $this->html);
         }
         // For developers using git - site version from latest git commit, add to last meta tag
         if (function_exists('exec')) {
             $output = [];
             exec('git log -1 --pretty=format:\'%h (%ci)\' --abbrev-commit', $output);
             if ($output && isset($output[0])) {
                 PageHead::getInstance()->addMeta($output[0], 'X-Version');
             }
         }
         // Page with components itself
         $this->outputHead();
         // Put body tag if not found in template
         if (!strpos($this->html, '<body')) {
             // No trailing bracket ! may have class
             $classes = PageHead::getInstance()->getBodyCssClasses();
             echo '<body' . ($classes ? ' class="' . implode(' ', $classes) . '"' : '') . '>';
         }
         // Main page content
         $this->outputHtml();
         // Post-scripts
         $this->outputTail();
         // Put closing body tag if not found in template
         if (!strpos($this->html, '</body>')) {
             echo '</body>';
         }
         echo '</html>';
     }
     $html = ob_get_clean();
     // HTML optimization in rendered content
     if (Settings::get('optimize_html')) {
         $html = Optimize::HTML($html);
     }
     // Put in cache
     if (Settings::get('use_file_cache_for_all_pages') && Settings::isCacheEnabled()) {
         Cacher::getInstance()->getDefaultCacher()->set('html_' . PATH_INTERNAL_MD5, $html);
     }
     // Encode ff browser supports gzip
     if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) {
         $html = gzencode($html, 6);
         // 6 is ok with speed and compression rate
         header('Content-Encoding: gzip');
     }
     // Set cache headers for one hour
     if (Settings::isCacheEnabled() && !headers_sent()) {
         header("Cache-Control: max-age=2592000");
         header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 3600));
     }
     return $html;
 }
コード例 #11
0
 /**
  * Get Setting object
  * @param string $module
  * @param string $key
  * @return CustomSetting
  */
 public static function getCustomSetting($module, $key)
 {
     // Check cache
     if (Settings::isCacheEnabled()) {
         $cache_key = 'module_custom_settings_all';
         $cacher = Cacher::getInstance()->getDefaultCacher();
         if (!self::$cached_settings) {
             self::$cached_settings = $cacher->get($cache_key);
         }
     }
     if (!self::$cached_settings) {
         // To prevent more iterations
         self::$cached_settings['empty']['empty'] = '';
         $settings = new CustomSettingRepository();
         foreach ($settings->getAsArrayOfObjects() as $setting) {
             /** @var CustomSetting $setting */
             self::$cached_settings[$setting->getModule()][$setting->getKey()] = $setting;
         }
     }
     // Save cache
     if (Settings::isCacheEnabled()) {
         $cacher->set($cache_key, self::$cached_settings, 86400);
     }
     return isset(self::$cached_settings[$module][$key]) ? self::$cached_settings[$module][$key] : NULL;
 }
コード例 #12
0
<?php

use TMCms\Admin\Menu;
use TMCms\Admin\Users;
use TMCms\Config\Settings;
if (!Settings::get('admin_panel_on_site') || !Users::getInstance()->isLogged()) {
    die;
}
ob_start();
?>
<style>
	#admin_front_panel table {
		border-collapse: collapse;
	}
	#admin_front_panel td {
		border: 2px solid #000; padding: 3px;
	}
</style>
<div id="admin_front_panel" style="position: fixed; top: 0; left: 0; opacity: 0.9; width: 100%; height: 25px; background: #fff; z-index: 99998; font-size: 16px; font-family: Arial, sans-serif">
	<table cellpadding="0" cellspacing="0">
		<tr>
			<td style="text-align: right">
				<a href="<?php 
echo DIR_CMS_URL;
?>
" title="Open Admin panel">CMS</a>
			</td>
			<td style="text-align: right">
				<a href="<?php 
echo DIR_CMS_URL;
?>
コード例 #13
0
ファイル: Finder.php プロジェクト: neTpyceB/TMCms-core
 public function searchForRealPath($real_file_path, $type = self::TYPE_ASSETS)
 {
     $search_array = $this->getPathFolders($type);
     $found_path = false;
     $external = false;
     // External path?
     if (($url = @parse_url($real_file_path)) && isset($url['host']) && $url['host'] != CFG_DOMAIN) {
         $found_path = $real_file_path;
         $external = true;
     }
     // Straight path to local file
     if (!$found_path && file_exists(DIR_BASE . $real_file_path)) {
         $found_path = $real_file_path;
     }
     if (!$found_path) {
         foreach ($search_array as $folder) {
             // Search folders with relative path
             if (file_exists(rtrim(DIR_BASE, '/') . $folder . $real_file_path)) {
                 $found_path = rtrim(DIR_BASE_URL, '/') . $folder . $real_file_path;
                 break;
             }
             // Search folders with basename
             $basename = basename($real_file_path);
             if (file_exists(rtrim(DIR_BASE, '/') . $folder . $basename)) {
                 $found_path = rtrim(DIR_BASE_URL, '/') . $folder . $basename;
                 break;
             }
         }
     }
     /*
     		// If file from external composer vendor - should copy to public dir
     		if (stripos($found_path, '/vendor/') === 0) {
     			$copy_from = DIR_BASE . ltrim($found_path, '/');
     			$copy_to = DIR_ASSETS . ltrim($real_file_path, '/');
     			if (file_exists($copy_from) && !file_exists($copy_to)) {
     				FileSystem::mkDir(pathinfo($copy_to, PATHINFO_DIRNAME));
     				copy($copy_from, $copy_to);
     			}
     			$found_path = DIR_ASSETS_URL . ltrim($real_file_path, '/');
     		}
     */
     // Add cache stamp for frontend assets
     if (!$external && $type == self::TYPE_ASSETS && $found_path) {
         $found_path .= '?' . Settings::get('last_assets_invalidate_time');
     }
     if (!$found_path) {
         dump('File "' . $real_file_path . '" with type "' . $type . '" not found');
     }
     return $found_path;
 }
コード例 #14
0
ファイル: Plugin.php プロジェクト: neTpyceB/TMCms-core
 /**
  * Preload all data of plugins
  */
 private static function init()
 {
     if (!self::$data_initialized) {
         self::$data_initialized = true;
         $page_components_collection = new PageComponentRepository();
         $page_components_collection->setWherePageId(PAGE_ID);
         $page_components_collection->addWhereFieldIsLike('component', 'select_plugin');
         if (Settings::isCacheEnabled()) {
             $page_components_collection->enableUsingCache();
         }
         self::$data = $page_components_collection->getPairs('data', 'component');
     }
 }
コード例 #15
0
ファイル: Backend.php プロジェクト: neTpyceB/TMCms-core
 /**
  * Data for HTML <head> generation
  */
 private function prepareHead()
 {
     $config = Configuration::getInstance();
     // Favicon url
     $favicon = !empty($config->get('cms')['favicon']) ? $config->get('cms')['favicon'] : DIR_CMS_IMAGES_URL . 'logo_square.png';
     // Prepare page HTML for head
     PageHead::getInstance()->addHtmlTagAttributes('lang="en" class="no-js"')->setTitle((P_DO !== '_default' ? Converter::symb2Ttl(P_DO) : 'Main') . ' / ' . Converter::symb2Ttl(P) . ' / ' . $config->get('site')['name'] . ' / ' . CMS_NAME . ' v. ' . CMS_VERSION)->setFavicon($favicon)->addMeta('name=' . CMS_NAME . ' - ' . $config->get('site')['name'] . '; action-uri=http://' . CFG_DOMAIN . '/cms/; icon-uri=http://' . DIR_CMS_IMAGES_URL . 'logo_square.png', 'msapplication-task')->addMeta('width=device-width, initial-scale=1', 'viewport')->addMeta('IE=edge', '', 'X-UA-Compatible')->addClassToBody('page-header-fixed')->addClassToBody('page-quick-sidebar-over-content')->addCssUrl('cms/fonts/open-sans.css')->addCssUrl('cms/plugins/font-awesome/font-awesome.css')->addCssUrl('cms/plugins/simple-line-icons/simple-line-icons.css')->addCssUrl('cms/plugins/bootstrap/css/bootstrap.css')->addCssUrl('cms/plugins/uniform/css/uniform.default.css')->addCssUrl('cms/plugins/bootstrap-switch/css/bootstrap-switch.css')->addCssUrl('cms/plugins/pace/pace-theme-minimal.css')->addCssUrl('cms/plugins/select2/select2.css')->addCssUrl('cms/css/components.css')->addCssUrl('cms/css/plugins.css')->addCssUrl('cms/layout/css/layout.css')->addCssUrl('cms/layout/css/themes/default.css')->addCssUrl('cms/layout/css/custom.css')->addCssUrl('plugins/toastr/toastr.min.css')->addJsUrl('cms/jquery-1.11.0.min.js')->addJsUrl(DIR_CMS_SCRIPTS_URL . 'jquery.form.min.js')->addJs('var cms_data = {};')->addJs('cms_data.cfg_domain="' . CFG_DOMAIN . '"')->addJs('cms_data.site_name="' . $config->get('site')['name'] . '"')->addJsUrl('cms_js.js')->addJsUrl('plupload/plupload.full.min.js');
     // Script for sending JS errors
     if (CFG_MAIL_ERRORS && Settings::isProductionState() && !Settings::get('do_not_send_js_errors')) {
         PageHead::getInstance()->addJsUrl('send_error.js')->addJs('register_js_error.ini(\'' . DIR_CMS_URL . '\');');
     }
     PageTail::getInstance()->addJsUrl('cms/jquery-migrate-1.2.1.min.js')->addJsUrl('cms/plugins/jquery-ui/jquery-ui-1.10.3.custom.min.js')->addJsUrl('cms/plugins/bootstrap/js/bootstrap.min.js')->addJsUrl('cms/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js')->addJsUrl('cms/plugins/jquery-slimscroll/jquery.slimscroll.min.js')->addJsUrl('cms/jquery.blockui.min.js')->addJsUrl('cms/jquery.cokie.min.js')->addJsUrl('cms/plugins/uniform/jquery.uniform.min.js')->addJsUrl('cms/plugins/bootstrap-switch/js/bootstrap-switch.min.js')->addCssUrl('cms/plugins/jquery-contextmenu/jquery.contextMenu.css')->addJsUrl('cms/plugins/jquery-contextmenu/jquery.contextMenu.js')->addJsUrl('cms/plugins/jquery-validation/js/jquery.validate.min.js')->addJsUrl('cms/plugins/backstretch/jquery.backstretch.min.js')->addJsUrl('cms/plugins/select2/select2.min.js')->addJsUrl('cms/metronic.js')->addJsUrl('cms/layout/scripts/layout.js')->addJsUrl('cms/layout/scripts/quick-sidebar.js')->addJsUrl('cms/plugins/pace/pace.js')->addCssUrl('cms/cms_css.css')->addJsUrl('plugins/toastr/toastr.min.js')->addJsUrl('plugins/parsley.min.js')->addJsUrl('cms/respond.min.js')->addJsUrl('cms/excanvas.min.js')->addJs('$(function() {
            $(".chosen").select2();
            Metronic.init();
            Layout.init();
            QuickSidebar.init();
         });');
     // Search for custom css
     $custom_css_url = DIR_ASSETS_URL . 'cms.css';
     if (file_exists(DIR_BASE . $custom_css_url)) {
         PageHead::getInstance()->addCssUrl($custom_css_url);
     } else {
         PageHead::getInstance()->addCustomString('<!--Create file "' . $custom_css_url . '" if you wish to use custom css file-->');
     }
     // Set head for page
     Page::setHead(PageHead::getInstance());
 }
コード例 #16
0
ファイル: PageHead.php プロジェクト: neTpyceB/TMCms-core
    /**
     * @return string
     */
    public function __toString()
    {
        if (!$this->enabled) {
            return '';
        }
        ob_start();
        echo $this->doctype . "\n";
        if ($this->replace_for_standard_html_tag) {
            echo $this->replace_for_standard_html_tag;
        } else {
            ?>
<html<?php 
            echo $this->html_tag_attributes ? ' ' . implode(' ', $this->html_tag_attributes) : '';
            ?>
>
        <?php 
        }
        ?>
        <head>
            <?php 
        if (!Settings::get('do_not_expose_generator')) {
            ?>
                <meta name="generator" content="<?php 
            echo CMS_NAME;
            ?>
, <?php 
            echo CMS_SITE;
            ?>
">
            <?php 
        }
        ?>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <meta charset="utf-8">
            <title><?php 
        echo htmlspecialchars($this->title, ENT_QUOTES);
        ?>
</title><?php 
        // META
        foreach ($this->meta as $v) {
            ?>
                <meta<?php 
            echo ($v['name'] ? ' name="' . $v['name'] . '" ' : '') . ($v['http_equiv'] ? ' http-equiv="' . $v['http_equiv'] . '"' : '') . ($v['property'] ? ' property="' . $v['property'] . '"' : '');
            ?>
 content="<?php 
            echo $v['content'];
            ?>
">
            <?php 
        }
        // CSS files
        foreach ($this->css_urls as $k => $v) {
            $k = Finder::getInstance()->searchForRealPath($k);
            ?>
                <link rel="stylesheet" type="text/css" href="<?php 
            echo $k;
            ?>
" media="<?php 
            echo $v;
            ?>
">
            <?php 
        }
        // CSS files
        foreach ($this->css as $v) {
            ?>
                <style>
                    <?php 
            echo $v;
            ?>
                </style>
            <?php 
        }
        // JS files and scripts
        for ($i = 1; $i <= $this->js_sequence; $i++) {
            if (isset($this->js_urls[$i])) {
                $this->js_urls[$i] = Finder::getInstance()->searchForRealPath($this->js_urls[$i]);
                ?>
                    <script src="<?php 
                echo $this->js_urls[$i];
                ?>
"></script>
                <?php 
            } elseif (isset($this->js[$i])) {
                ?>
                    <script><?php 
                echo $this->js[$i];
                ?>
</script>
                <?php 
            }
        }
        // RSS feeds
        foreach ($this->rss as $v) {
            ?>
                <link rel="alternate" type="application/rss+xml"
                      title="<?php 
            echo htmlspecialchars($v['title'], ENT_QUOTES);
            ?>
" href="<?php 
            echo $v['href'];
            ?>
">
            <?php 
        }
        // RSS feeds
        if ($this->apple_touch_icon_url) {
            ?>
                <link rel="apple-touch-icon"
                      href="<?php 
            echo Finder::getInstance()->searchForRealPath($this->apple_touch_icon_url);
            ?>
">
            <?php 
        }
        // META keywords
        if ($this->keywords) {
            ?>
                <meta name="keywords" content="<?php 
            echo htmlspecialchars($this->keywords, ENT_QUOTES);
            ?>
">
            <?php 
        }
        // META description
        if ($this->description) {
            ?>
                <meta name="description" content="<?php 
            echo htmlspecialchars($this->description, ENT_QUOTES);
            ?>
">
            <?php 
        }
        // Any custom string appended into <head>
        foreach ($this->custom_strings as $v) {
            ?>
                <?php 
            echo $v;
            ?>
            <?php 
        }
        // Favicon
        if ($this->favicon) {
            $this->favicon['href'] = ltrim($this->favicon['href'], '/');
            ?>
                <link rel="icon" href="http<?php 
            echo $this->ssl ? 's' : '';
            ?>
://<?php 
            echo CFG_DOMAIN . '/' . $this->favicon['href'];
            ?>
" type="<?php 
            echo $this->favicon['type'];
            ?>
">
                <link rel="shortcut icon" href="http<?php 
            echo $this->ssl ? 's' : '';
            ?>
://<?php 
            echo CFG_DOMAIN . '/' . $this->favicon['href'];
            ?>
" type="<?php 
            echo $this->favicon['type'];
            ?>
">
                <?php 
        }
        // Google Analytics
        if ($ga = Settings::get('google_analytics_code')) {
            ?>
                <script>
                    (function (i, s, o, g, r, a, m) {
                        i['GoogleAnalyticsObject'] = r;
                        i[r] = i[r] || function () {
                                (i[r].q = i[r].q || []).push(arguments)
                            }, i[r].l = 1 * new Date();
                        a = s.createElement(o),
                            m = s.getElementsByTagName(o)[0];
                        a.async = 1;
                        a.src = g;
                        m.parentNode.insertBefore(a, m)
                    })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

                    ga('create', 'UA-<?php 
            echo $ga;
            ?>
', '<?php 
            echo CFG_DOMAIN;
            ?>
');
                    ga('send', 'pageview');

                </script>
            <?php 
        }
        unset($ga);
        ?>
        </head>
        <?php 
        return ob_get_clean();
    }
コード例 #17
0
ファイル: CmsGuest.php プロジェクト: neTpyceB/TMCms-panel
    public function _default()
    {
        // If only unique access allowed
        if (Settings::getInstance()->get('unique_admin_address')) {
            // No correct key provided?
            if (!isset($_GET['admin_key']) || $_GET['admin_key'] != Configuration::getInstance()->get('cms')['unique_key']) {
                back();
            }
        }
        // Authorize user by provided token (used by our mobile application)
        if (isset($_GET['token'])) {
            try {
                $payload = JWT::decode($_GET['token'], date('Y-m-d', NOW), true);
                if ($payload->created_at > strtotime('-5 minutes')) {
                    $user_collection = new AdminUserRepository();
                    $user_collection->setWhereLogin($payload->login);
                    $user_collection->setWherePassword($payload->password);
                    $user_collection->setWhereActive(1);
                    /** @var AdminUser $user */
                    $user = $user_collection->getFirstObjectFromCollection();
                    if ($user) {
                        $this->initLogInProcess($user);
                    }
                }
            } catch (Exception $exception) {
                // Do nothing, I guess...
            }
        }
        // Redirect if user is already logged in
        if (Users::getInstance()->isLogged()) {
            go('/cms/?p=home');
        }
        $config = Configuration::getInstance();
        $expose = $config->get('options');
        $hide_license = $expose && isset($expose['hide_license']) && $expose['hide_license'];
        PageHead::getInstance()->addClassToBody('login')->addCssUrl('cms/css/login-soft.css');
        PageTail::getInstance()->addJsUrl('cms/layout/scripts/login-soft.js')->addJs('
                Login.init();
            ');
        // Logo image and link
        $logo = '';
        if (array_key_exists('logo', Configuration::getInstance()->get('cms'))) {
            $logo = Configuration::getInstance()->get('cms')['logo'];
        }
        $logo_link = DIR_CMS_URL;
        if (array_key_exists('logo_link', Configuration::getInstance()->get('cms'))) {
            $logo_link = Configuration::getInstance()->get('cms')['logo_link'];
        }
        // Registration form
        $registration_allowed = Settings::get('allow_registration');
        ?>

        <?php 
        if ($logo) {
            ?>
            <div class="logo">
                <a href="<?php 
            echo $logo_link;
            ?>
" target="_blank">
                    <img src="<?php 
            echo $logo;
            ?>
" alt="DEVP Web Development">
                </a>
            </div>
        <?php 
        }
        ?>
        <div class="content">
            <form class="login-form" action="?p=<?php 
        echo P;
        ?>
&do=_login" method="post">
                <?php 
        if (isset($_GET['registered'])) {
            ?>
                    <h3 class="form-title">User created. Contact admins to activate your account.</h3>
                    <script>
                        setTimeout(function() {
                            window.location = window.history.back();
                        }, 3000);
                    </script>';
                <?php 
        }
        ?>

                <h3 class="form-title">Login to your account</h3>
                <div class="alert alert-danger display-hide">
                    <button class="close" data-close="alert"></button>
                    <span>Enter any username and password.</span>
                </div>
                <div class="form-group">
                    <label class="control-label visible-ie8 visible-ie9">Username</label>
                    <div class="input-icon">
                        <i class="fa fa-user"></i>
                        <input class="form-control placeholder-no-fix" type="text" autofocus placeholder="Username" name="login" <?php 
        echo isset($_GET['login']) ? $_GET['login'] : '';
        ?>
>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label visible-ie8 visible-ie9">Password</label>
                    <div class="input-icon">
                        <i class="fa fa-lock"></i>
                        <input class="form-control placeholder-no-fix" type="password" placeholder="Password" name="password">
                    </div>
                </div>
                <input type="hidden" name="go" value="<?php 
        echo SELF;
        ?>
">
                <div class="forget-password">
                    <h4>Forgot your password ?</h4>
                    <p>no worries, click <a href="javascript:;" id="forget-password">
                            here </a>
                        to reset your password.
                    </p>
                </div>
                <?php 
        if ($registration_allowed) {
            ?>
                    <div class="create-account">
                        <p>Don't have an account yet?&nbsp;
                            <a href="javascript:;" id="register-btn">Create an account </a>
                        </p>
                    </div>
                <?php 
        }
        ?>
            </form>
            <form class="forget-form" action="?p=<?php 
        echo P;
        ?>
&do=_reset_password" method="post">
                <h3>Forget Password ?</h3>
                <p>Enter your e-mail address below to reset your password.</p>
                <div class="form-group">
                    <div class="input-icon">
                        <i class="fa fa-envelope"></i>
                        <input class="form-control placeholder-no-fix" type="text" placeholder="Email" name="email">
                    </div>
                </div>
                <div class="form-actions">
                    <button type="button" id="back-btn" class="btn">
                        <i class="m-icon-swapleft"></i> Back </button>
                    <button type="submit" class="btn blue pull-right">
                        Submit <i class="m-icon-swapright m-icon-white"></i>
                    </button>
                </div>
            </form>
            <?php 
        if ($registration_allowed) {
            ?>
                <form class="register-form" action="?p=<?php 
            echo P;
            ?>
&do=_register" method="post">
                    <h3>Sign Up</h3>
                    <p>
                        Enter your personal details below:
                    </p>
                    <div class="form-group">
                        <label class="control-label visible-ie8 visible-ie9">Full Name</label>
                        <div class="input-icon">
                            <i class="fa fa-font"></i>
                            <input class="form-control placeholder-no-fix" type="text" placeholder="Full Name" name="name"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label visible-ie8 visible-ie9">Email</label>
                        <div class="input-icon">
                            <i class="fa fa-envelope"></i>
                            <input class="form-control placeholder-no-fix" type="text" placeholder="Email" name="email"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label visible-ie8 visible-ie9">Phone</label>
                        <div class="input-icon">
                            <i class="fa fa-envelope"></i>
                            <input class="form-control placeholder-no-fix" type="text" placeholder="Phone" name="phone"/>
                        </div>
                    </div>
                    <p>
                        Enter your account details below:
                    </p>
                    <div class="form-group">
                        <label class="control-label visible-ie8 visible-ie9">Username</label>
                        <div class="input-icon">
                            <i class="fa fa-user"></i>
                            <input class="form-control placeholder-no-fix" type="text" placeholder="Username" name="login">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label visible-ie8 visible-ie9">Password</label>
                        <div class="input-icon">
                            <i class="fa fa-lock"></i>
                            <input class="form-control placeholder-no-fix" type="password" id="register_password" placeholder="Password" name="password"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label visible-ie8 visible-ie9">Re-type Your Password</label>
                        <div class="controls">
                            <div class="input-icon">
                                <i class="fa fa-check"></i>
                                <input class="form-control placeholder-no-fix" type="password" placeholder="Re-type Your Password" name="rpassword"/>
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <button id="register-back-btn" type="button" class="btn">
                            <i class="m-icon-swapleft"></i>Back
                        </button>
                        <button type="submit" id="register-submit-btn" class="btn blue pull-right">
                            Sign Up <i class="m-icon-swapright m-icon-white"></i>
                        </button>
                    </div>
                </form>
            <?php 
        }
        ?>
        </div>
        <?php 
        if ($hide_license) {
            ?>
            <!--
        <?php 
        }
        ?>
        <div class="copyright">
            2007 - <?php 
        echo Y;
        ?>
 &copy; <?php 
        echo CMS_NAME;
        ?>
 | <a href="<?php 
        echo CMS_SITE;
        ?>
" target="_blank"><?php 
        echo CMS_SITE;
        ?>
</a>
        </div>
        <?php 
        if ($hide_license) {
            ?>
            -->
        <?php 
        }
    }