public static function generate_file($key, $message = null) { $user = Base_UserCommon::get_my_user_login(); $date = date('Y-m-d H:i:s'); $str = "<?php\n"; $str .= "// by {$user} on {$date}\n"; $str .= '$maintenance_mode_key = ' . var_export($key, true); $str .= ";\n"; $str .= '$maintenance_mode_message = ' . var_export($message, true); $str .= ";\n"; file_put_contents(self::get_file(), $str); }
public static function user_settings($just_retrieve = false) { if (!Variable::get('allow_lang_change')) { return null; } if (DEMO_MODE && Base_UserCommon::get_my_user_login() == 'admin') { $langs = array('en' => 'en'); } else { $langs = Base_LangCommon::get_installed_langs(); } if ($just_retrieve) { $group = $label1 = $label2 = ''; } else { $group = __('Regional Settings'); $label1 = __('Language'); $label2 = __('Language you want to use'); } return array($group => array(array('type' => 'header', 'label' => $label1, 'name' => null), array('name' => 'language', 'label' => $label2, 'type' => 'select', 'values' => $langs, 'default' => Variable::get('default_lang')))); }
public function body($tpl = null) { //check bans if (!Acl::is_user() && Base_User_LoginCommon::is_banned()) { print __('You have exceeded the number of allowed login attempts.') . '<br>'; print '<a href="' . get_epesi_url() . '">' . __('Host banned. Click here to refresh.') . '</a>'; return; } //if logged $this->theme->assign('is_logged_in', Acl::is_user()); $this->theme->assign('is_demo', DEMO_MODE); if (SUGGEST_DONATION) { $this->theme->assign('donation_note', __('If you find our software useful, please support us by making a %s.', array('<a href="http://epe.si/cost" target="_blank">' . __('donation') . '</a>')) . '<br>' . __('Your funding will help to ensure continued development of this project.')); } if (Acl::is_user()) { if ($this->get_unique_href_variable('logout')) { Base_User_LoginCommon::logout(); eval_js('document.location=\'index.php\';', false); } else { $this->theme->assign('logged_as', '<div class="logged_as">' . __('Logged as %s', array('</br><b class="green">' . Base_UserCommon::get_my_user_login() . '</b>')) . '</div>'); $this->theme->assign('logout', '<div class="logout_css3_box"><a class="logout_icon" ' . $this->create_unique_href(array('logout' => 1)) . '>' . __('Logout') . '<div class="logout_icon_img"></div></a></div>'); $this->theme->display(); } return; } if ($this->is_back()) { $this->unset_module_variable('mail_recover_pass'); } //if recover pass if ($this->get_module_variable_or_unique_href_variable('mail_recover_pass') == '1') { $this->recover_pass(); return; } if (isset($_REQUEST['password_recovered'])) { $this->theme->assign('message', __('An e-mail with a new password has been sent.') . '<br><a href="' . get_epesi_url() . '">' . __('Login') . '</a>'); $this->theme->display(); return; } if ($this->autologin()) { return; } //else just login form $form = $this->init_module('Libs/QuickForm', __('Logging in')); $form->addElement('header', 'login_header', __('Login')); if (DEMO_MODE) { global $demo_users; $form->addElement('select', 'username', __('Username'), $demo_users, array('id' => 'username', 'onChange' => 'this.form.elements["password"].value=this.options[this.selectedIndex].value;')); $form->addElement('hidden', 'password', key($demo_users)); } else { $form->addElement('text', 'username', __('Username'), array('id' => 'username')); $form->addElement('password', 'password', __('Password')); } // Display warning about storing a cookie if (Base_User_LoginCommon::is_autologin_forbidden() == false) { $warning = __('Keep this box unchecked if using a public computer'); $form->addElement('static', 'warning', null, $warning); $form->addElement('checkbox', 'autologin', '', __('Remember me')); } $form->addElement('static', 'recover_password', null, '<a ' . $this->create_unique_href(array('mail_recover_pass' => 1)) . '>' . __('Recover password') . '</a>'); $form->addElement('submit', 'submit_button', __('Login'), array('class' => 'submit')); // register and add a rule to check if user is banned $form->registerRule('check_user_banned', 'callback', 'rule_login_banned', 'Base_User_LoginCommon'); $form->addRule('username', __('You have exceeded the number of allowed login attempts for this username. Try again later.'), 'check_user_banned'); // register and add a rule to check if a username and password is ok $form->registerRule('check_login', 'callback', 'submit_login', 'Base_User_LoginCommon'); $form->addRule(array('username', 'password'), __('Login or password incorrect'), 'check_login'); $form->addRule('username', __('Field required'), 'required'); $form->addRule('password', __('Field required'), 'required'); if ($form->isSubmitted() && $form->validate()) { $user = $form->exportValue('username'); Base_User_LoginCommon::set_logged($user); if (Base_User_LoginCommon::is_autologin_forbidden() == false) { $autologin = $form->exportValue('autologin'); if ($autologin) { Base_User_LoginCommon::new_autologin_id(); } } location(array()); } else { $form->assign_theme('form', $this->theme); $this->theme->assign('mode', 'login'); $logo = $this->init_module('Base/MainModuleIndicator'); $logo->set_inline_display(); $this->theme->assign('logo', $this->get_html_of_module($logo, null, 'login_logo')); ob_start(); if (!$tpl) { $this->theme->set_inline_display(); $this->theme->display(); eval_js("focus_by_id('username')"); } else { Base_ThemeCommon::display_smarty($this->theme->get_smarty(), $tpl[0], $tpl[1]); } $ret = ob_get_clean(); if (stripos($ret, '<a href="http://www.telaxus.com">Telaxus LLC</a>') === false || stripos($ret, '<a href="http://epe.si/"><img src="images/epesi-powered.png" alt="EPESI powered" /></a>') === false) { trigger_error('Epesi terms of use have been violated', E_USER_ERROR); } print $ret; } }
* * @author Pawel Bukowski <*****@*****.**> * @copyright Copyright © 2015, Telaxus LLC * @license MIT * @version 2.0 * @package epesi-notify * */ define('CID', false); define('READ_ONLY_SESSION', true); require_once '../../../include.php'; ModuleManager::load_modules(); if (!Acl::is_user()) { exit; } $token = Base_NotifyCommon::get_session_token(true); if (!$token) { exit; } DB::Execute('UPDATE base_notify SET telegram=1 WHERE token=%s', array($token)); $domain_name = Base_UserCommon::get_my_user_login(); if (isset($_SERVER['HTTP_HOST']) && $_SERVER['HTTP_HOST']) { $domain_name .= '-' . $_SERVER['HTTP_HOST']; } else { if (isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME']) { $domain_name .= '-' . $_SERVER['SERVER_NAME']; } } $domain_name = preg_replace('/[^a-z0-9\\-\\_]/i', '-', $domain_name); header('Location: https://telegram.me/EpesiBot?' . http_build_query(array('start' => md5(Base_AclCommon::get_user() . '#' . Base_UserCommon::get_my_user_login() . '#' . $token) . '-' . substr($domain_name, 0, 31))));
public static function new_autologin_id($old_autologin_id = null) { $uid = Acl::get_user(); $user = Base_UserCommon::get_my_user_login(); $autologin_id = md5(mt_rand() . md5($user . $uid) . mt_rand()); setcookie('autologin_id', $user . ' ' . $autologin_id, time() + 60 * 60 * 24 * 30); $ip = get_client_ip_address(); if ($old_autologin_id) { DB::Execute('DELETE FROM user_autologin WHERE user_login_id=%d AND autologin_id=%s', array($uid, $old_autologin_id)); } DB::Execute('INSERT INTO user_autologin(user_login_id,autologin_id,description,last_log) VALUES(%d,%s,%s,%T)', array($uid, $autologin_id, $ip, time())); self::clean_old_autologins(); }
public function check_old_pass($pass) { return Base_User_LoginCommon::check_login(Base_UserCommon::get_my_user_login(), $pass); }
public static function new_autologin_id() { $uid = Acl::get_user(); $user = Base_UserCommon::get_my_user_login(); $autologin_id = md5(mt_rand() . md5($user . $uid) . mt_rand()); setcookie('autologin_id', $user . ' ' . $autologin_id, time() + 60 * 60 * 24 * 30); DB::Execute('INSERT INTO user_autologin(user_login_id,autologin_id,description,last_log) VALUES(%d,%s,%s,%T)', array($uid, $autologin_id, $_SERVER['REMOTE_ADDR'], time())); }