Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
 /**
  * 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());
 }
Exemplo n.º 3
0
    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 
        }
    }