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;
 }
Beispiel #2
0
 /**
  * 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);
 }
Beispiel #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 
        }
    }