public function update_observer($type, $message, $errfile, $errline, $errcontext, $backtrace) { $mail = Variable::get('error_mail'); if ($mail) { $backtrace = htmlspecialchars_decode(str_replace(array('<br />', ' '), array("\n", ' '), $backtrace)); $x = "who=" . Base_AclCommon::get_user() . "\ntype=" . $type . "\nmessage=" . $message . "\nerror file=" . $errfile . "\nerror line=" . $errline . "\n" . $backtrace; $d = ModuleManager::get_data_dir('Base/Error') . md5($x) . '.txt'; file_put_contents($d, $x); $url = get_epesi_url(); Base_MailCommon::send($mail, 'Epesi Error - ' . $url, substr($x, 0, strpos($x, "error backtrace")) . "\n" . $url . '/' . $d, null, null, false, true); } return true; }
private function list_admin_modules() { $mod_ok = array(); $sections = array(); $cmr = ModuleManager::call_common_methods('admin_caption'); foreach ($cmr as $name => $caption) { if (!ModuleManager::check_access($name, 'admin') || $name == 'Base_Admin') { continue; } if (Base_AdminCommon::get_access($name) == false) { continue; } if (!isset($caption)) { continue; } if (!is_array($caption)) { $caption = array('label' => $caption); } if (!isset($caption['section'])) { $caption['section'] = __('Misc'); } $mod_ok[$name] = $caption; } if (Base_AclCommon::i_am_sa()) { Base_ActionBarCommon::add('settings', __('Admin Panel Access'), $this->create_callback_href(array($this, 'set_module'), array('Base_Admin'))); if (!DEMO_MODE && !HOSTING_MODE) { $admin_tools_url = rtrim(get_epesi_url(), '/') . '/admin/'; Base_ActionBarCommon::add('settings', __('Admin Tools'), 'href="' . htmlspecialchars($admin_tools_url) . '" target="_blank"'); } } $buttons = array(); foreach ($mod_ok as $name => $caption) { if (method_exists($name . 'Common', 'admin_icon')) { $icon = call_user_func(array($name . 'Common', 'admin_icon')); } else { $icon = Base_ThemeCommon::get_template_file($name, 'icon.png'); if (!file_exists($icon)) { $icon = Base_ThemeCommon::get_template_file('Base_Admin', 'icon.png'); } } $buttons[$caption['section']][] = array('link' => '<a ' . $this->create_callback_href(array($this, 'set_module'), array($name)) . '>' . $caption['label'] . '</a>', 'icon' => $icon); } foreach ($buttons as $section => $b) { $sections[$section] = array('header' => $section, 'buttons' => $b); } $sections = $this->sort_sections($sections); $theme = $this->pack_module('Base/Theme'); $theme->assign('sections', $sections); $theme->display(); }
private function print_info() { print '<div class="title">' . __('PHP environment check') . '</div>'; $this->startTable(); $data_dir_ok = is_writable('data'); $data_writable = $data_dir_ok ? "OK" : '<strong>WARNING!</strong> Please fix privileges for data directory.'; $color = $data_dir_ok ? 'green' : 'red'; $this->printTD("Data directory is writeable", $data_writable, $color, $data_dir_ok); $version_ok = version_compare(phpversion(), '5.1.0') >= 0; $text = $version_ok ? 'OK' : '<strong>WARNING!</strong> You are running an old version of PHP, minimum version 5.1 required.'; $color = $version_ok ? 'green' : 'red'; $this->printTD('PHP version: ' . phpversion(), $text, $color, $version_ok); $curl_ok = extension_loaded('curl'); $curl_loaded = $curl_ok ? 'OK' : 'Curl extension not found - Please uncomment <pre><strong>;extension=php_curl.dll</strong></pre> line in your php.ini'; $color = $curl_ok ? 'green' : 'red'; $this->printTD("Curl loaded", $curl_loaded, $color, $curl_ok); $this->closeTable(); print '<br/><br/><div class="title">EPESI config.php</div>'; $this->startTable(); $this->printTD('epesi version:', EPESI_VERSION); $this->printTD('epesi revison:', EPESI_REVISION); $this->printTD('Database Name:', DATABASE_NAME); $this->printTD('Database Driver:', DATABASE_DRIVER); $this->printTD('epesi Local Dir:', EPESI_LOCAL_DIR); $this->printTD('epesi Dir:', EPESI_DIR); $this->printTD('epesi URL:', get_epesi_url()); $this->printTD('System Timezone:', SYSTEM_TIMEZONE); $this->printTD('Debug:', DEBUG ? 'YES' : 'NO'); $this->printTD('Module Times:', MODULE_TIMES ? 'YES' : 'NO'); $this->printTD('Display sql queries processing times: ', SQL_TIMES ? 'YES' : 'NO'); $this->printTD('Strip output html from comments: ', STRIP_OUTPUT ? 'YES' : 'NO'); $this->printTD('Display additional error info: ', DISPLAY_ERRORS ? 'YES' : 'NO'); $this->printTD('Report all errors (E_ALL): ', REPORT_ALL_ERRORS ? 'YES' : 'NO'); $this->printTD('GZIP client web browser history: ', GZIP_HISTORY ? 'YES' : 'NO'); $this->printTD('Reducing Transfer: ', REDUCING_TRANSFER ? 'YES' : 'NO'); $this->printTD('Minify Encode: ', MINIFY_ENCODE ? 'YES' : 'NO'); $this->printTD('Minify sources: ', MINIFY_SOURCES ? 'YES' : 'NO'); $this->printTD('Suggest Donation: ', SUGGEST_DONATION ? 'YES' : 'NO'); $this->printTD('Check epesi version: ', CHECK_VERSION ? 'YES' : 'NO'); $this->printTD('JS Output: ', JS_OUTPUT ? 'YES' : 'NO'); $this->printTD('Set Session: ', SET_SESSION ? 'YES' : 'NO'); $this->printTD('Read Only Session: ', READ_ONLY_SESSION ? 'YES' : 'NO'); $this->printTD('Mobile Device: ', MOBILE_DEVICE ? 'YES' : 'NO'); $this->printTD('First Run: ', FIRST_RUN ? 'YES' : 'NO'); $this->printTD('Hosting Mode: ', HOSTING_MODE ? 'YES' : 'NO'); $this->printTD('Trial Mode: ', TRIAL_MODE ? 'YES' : 'NO'); $this->printTD('Demo Mode: ', DEMO_MODE ? 'YES' : 'NO'); $this->closeTable(); }
public function test_mail_config($email) { ob_start(); $ret = Base_MailCommon::send($email, __('E-mail configuration test'), __('If you are reading this, it means that your e-mail server configuration at %s is working properly.', array(get_epesi_url()))); $msg = ob_get_clean(); if ($msg) { print '<span class="important_notice">' . $msg . '</span>'; } if ($ret) { Base_StatusBarCommon::message(__('E-mail was sent successfully')); } else { Base_StatusBarCommon::message(__('An error has occured'), 'error'); } return false; }
public static function display($header, $content, $info = false) { $l = Variable::get('logo_file', false); if (!$l) { $l = Base_ThemeCommon::get_template_file('images/logo-small.png'); } $smarty = Base_ThemeCommon::init_smarty(); $smarty->assign('header', $header); $smarty->assign('contents', $content); $smarty->assign('info', $info); $smarty->assign('footer', ''); $smarty->assign('logo', $l); $smarty->assign('url', get_epesi_url()); Base_ThemeCommon::display_smarty($smarty, 'Utils_FrontPage', 'default'); }
private function terms_and_conditions() { if ($this->get_module_variable('t_and_c_accepted')) { $this->register_form(); return; } if (!Base_EssClientCommon::test_connection()) { $this->connection_problem_form(); return; } $form = $this->init_module('Libs_QuickForm'); $form->addElement('checkbox', 'agree', __('I agree to Terms and Conditions')); $form->addRule('agree', __('You must accept Terms and Conditions to proceed'), 'required'); $form->addElement('submit', 'submit', __('Obtain Epesi License Key'), array('style' => 'width:200px')); if ($form->validate()) { $this->set_module_variable('t_and_c_accepted', true); location(array()); return; } print '<div class="important_notice">'; print '<center><H1>'; print __('EPESI Registration'); print '</H1></center><br>'; print __('Registration of your EPESI installation with %s will allow you to browse and make purchases in %sEPESI Store%s and receive notifications via e-mail about important updates.', array('<a href="http://www.telaxus.com" target="_blank">Telaxus LLC </a>', '<strong>', '</strong>')); print '<br>'; print __('Once the registration is complete you will receive a %sLicense Key%s.', array('<strong>', '</strong>')) . ' '; print __('This unique License Key will be used to identify your installation and allow you to download and use modules you purchase. Please note that %sEPESI License Key%s can not be copied to any other EPESI installation.', array('<strong>', '</strong>')) . ' '; print __('All purchases and downloads you make using your EPESI License Key can be used for this installation only.'); print '<br><br>'; print __('If necessary, you can move your installation to another server and keep your EPESI License Key, but at any given time no two installations can use the same EPESI License Key.') . ' '; print __('Sharing your License Key with unauthorized users is a violation of this agreement and will result in revoking the License Key.'); print '<br><br>'; print '<strong>' . __('If you already have a License Key for this installation, you can enter it here:') . ' <a ' . $this->create_callback_href(array($this, 'license_key_form')) . '>' . __('enter License Key') . '</a></strong>'; print '<br><br>'; print __('Full Terms and Conditions are available here:'); $url = get_epesi_url() . '/modules/Base/EssClient/tos/tos.php'; print ' <a target="_blank" href="' . $url . '">' . __('Terms and Conditions') . '</a>'; print '<center>'; $form->display(); print '</center>'; print '</div>'; return; }
public static function get_cron_url() { $token = self::load_token(); $url = get_epesi_url() . '/cron.php?token=' . $token; return $url; }
protected function update_process_info_msg() { $do_not_close = __('Please do not close this window until process will be fully finished.'); $url_text = __('help file'); $url = get_epesi_url() . '/docs/UPDATE.md'; $url = htmlspecialchars($url); $link = "<a href=\"$url\" target=\"_blank\">$url_text</a>"; $info = __('Your browser drives update process. For more information read %s', array($link)); $msg = "<p><strong>$do_not_close</strong></p><p>$info</p>"; return "$msg"; }
private function go_to_update_button() { $url = rtrim(get_epesi_url(), '/') . '/update.php'; print "Navigate to <a href=\"{$url}\">update.php</a>"; }
public function submit_recover($data) { $mail = $data['mail']; $username = $data['username']; if (DEMO_MODE && $username == 'admin') { print 'In demo you cannot recover \'admin\' user password. If you want to login please type \'admin\' as password.'; return false; } $user_id = Base_UserCommon::get_user_id($username); DB::Execute('DELETE FROM user_reset_pass WHERE created_on<%T', array(time() - 3600 * 2)); if ($user_id === false) { print 'No such user!'; return false; } $hash = md5($user_id . '' . time()); DB::Execute('INSERT INTO user_reset_pass(user_login_id,hash_id,created_on) VALUES (%d,%s,%T)', array($user_id, $hash, time())); $subject = __('Password recovery'); $message = __('A password recovery for the account with the e-mail address %s has been requested.', array($mail)) . "\n\n" . __('If you want to reset your password, visit the following URL:') . "\n" . get_epesi_url() . '/modules/Base/User/Login/reset_pass.php?hash=' . $hash . "\n" . __('or just ignore this message and your login and password will remain unchanged.') . "\n\n" . __('If you did not use the Password Recovery form, inform your administrator about a potential unauthorized attempt to login using your credentials.') . "\n\n" . __('This e-mail was generated automatically and you do not need to respond to it.'); $sendMail = Base_MailCommon::send_critical($mail, $subject, $message); return true; }
public static function mobile_login() { $t = Variable::get('host_ban_time'); if ($t > 0) { $fails = DB::GetOne('SELECT count(*) FROM user_login_ban WHERE failed_on>%d AND from_addr=%s', array(time() - $t, get_client_ip_address())); if ($fails >= 3) { 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; } } $qf = new HTML_QuickForm('login', 'post', 'mobile.php?' . http_build_query($_GET)); $qf->addElement('text', 'username', __('Login')); $qf->addElement('password', 'password', __('Password')); $qf->addElement('submit', 'submit_button', __('Login')); $qf->registerRule('check_login', 'callback', 'submit_login', 'Base_User_LoginCommon'); $qf->addRule(array('username', 'password'), __('Login or password incorrect'), 'check_login'); $qf->addRule('username', __('Field required'), 'required'); $qf->addRule('password', __('Field required'), 'required'); if ($qf->validate()) { self::set_logged($qf->exportValue('username')); self::new_autologin_id(); return false; } $qf->display(); }
public static function create_remote($file_id, $description, $expires_on) { $r = DB::GetRow('SELECT id, token FROM utils_attachment_download WHERE remote=1 AND attach_file_id=%d AND created_on>'.DB::DBTimeStamp(time()-3600).' AND created_by=%d',array($file_id,Acl::get_user())); if (!empty($r)) { $id = $r['id']; $token = $r['token']; } else { $token = md5($file_id.$expires_on.mt_rand().$description); DB::Execute('INSERT INTO utils_attachment_download(remote,attach_file_id,created_by,created_on,expires_on,description,token) VALUES (1,%d,%d,%T,%T,%s,%s)',array($file_id,Acl::get_user(),time(),$expires_on,$description,$token)); $id = DB::Insert_ID('utils_attachment_download','id'); } return get_epesi_url().'/modules/Utils/Attachment/get_remote.php?'.http_build_query(array('id'=>$id,'token'=>$token)); }
<?php if (!isset($_GET['hash'])) { die(''); } header("Content-Type: text/html; charset=UTF-8"); define('READ_ONLY_SESSION', true); define('CID', false); require_once '../../../../include.php'; ModuleManager::load_modules(); DB::Execute('DELETE FROM user_reset_pass WHERE created_on<%T', array(time() - 3600 * 2)); $user_id = DB::GetOne('SELECT user_login_id FROM user_reset_pass WHERE hash_id=%s', array($_GET['hash'])); if ($user_id == false) { die(__('Request failed. Authentication link is valid for 2 hours since sending request.')); } $pass = generate_password(); $pass_hash = function_exists('password_hash') ? password_hash($pass, PASSWORD_DEFAULT) : md5($pass); if (!DB::Execute('UPDATE user_password SET password=%s WHERE user_login_id=%d', array($pass_hash, $user_id))) { die(__('Unable to update password. Please contact system administrator.')); } if (!Base_User_LoginCommon::send_mail_with_password(Base_UserCommon::get_user_login($user_id), $pass, Base_User_LoginCommon::get_mail($user_id), true)) { die(__('Unable to send e-mail with password. Mail module configuration invalid. Please contact system administrator.')); } DB::Execute('DELETE FROM user_reset_pass WHERE hash_id =%s', array($_GET['hash'])); header('Location: ' . get_epesi_url() . '?' . http_build_query(array('password_recovered' => 1)));
public static function QFfield_attachments(&$form, $field, $label, $mode, $default, $desc, $rb_obj) { if (isset($_GET['rc_reply']) || isset($_GET['rc_replyall']) || isset($_GET['rc_forward'])) { $attachments = DB::GetAssoc('SELECT mime_id,name FROM rc_mails_attachments WHERE mail_id=%d AND attachment=1', array($rb_obj->record['id'])); $data = array(); if ($attachments) { $hash = md5(time() . ' ' . serialize($rb_obj->record)); DB::Execute('INSERT INTO rc_mails_attachments_download(mail_id,hash) VALUES(%d,%s)', array($rb_obj->record['id'], $hash)); foreach ($attachments as $k => &$n) { $filename = DATA_DIR . '/CRM_Roundcube/attachments/' . $rb_obj->record['id'] . '/' . $k; if (file_exists($filename)) { $data[] = '<a href="' . rtrim(get_epesi_url() . '/') . '/modules/CRM/Roundcube/get_remote.php?' . http_build_query(array('mime_id' => $k, 'mail_id' => $rb_obj->record['id'], 'hash' => $hash)) . '" target="_blank">' . $n . '</a>'; } } } $attachments = implode('<br />', $data); } else { $attachments = ''; } if (isset($_GET['rc_reply']) && $_GET['rc_reply'] == $rb_obj->record['id']) { Base_BoxCommon::push_module('CRM_Roundcube', 'new_mail', array(html_entity_decode($rb_obj->record['from']), (preg_match('/^Re:/i', $rb_obj->record['subject']) ? '' : 'Re: ') . $rb_obj->record['subject'], '<br /><br /><strong>' . __('On %s wrote', array(Base_RegionalSettingsCommon::time2reg($rb_obj->record['date']) . ', ' . $rb_obj->record['from'])) . ':</strong><br/>' . $rb_obj->record['body'] . ($attachments ? '<hr /><strong>' . __('Attachments') . ':</strong><br/>' . $attachments : ''), $rb_obj->record['message_id'], html_entity_decode($rb_obj->record['references']))); } elseif (isset($_GET['rc_replyall']) && $_GET['rc_replyall'] == $rb_obj->record['id']) { $to = explode(',', $rb_obj->record['to']); $to[] = $rb_obj->record['from']; $mails = Utils_RecordBrowserCommon::get_records('rc_accounts', array('epesi_user' => Acl::get_user()), array('email')); foreach ($to as $k => $t) { $to[$k] = trim($t); foreach ($mails as $m) { if (strpos($t, $m['email']) !== false) { unset($to[$k]); break; } } } Base_BoxCommon::push_module('CRM_Roundcube', 'new_mail', array(html_entity_decode(implode(', ', $to)), (preg_match('/^Re:/i', $rb_obj->record['subject']) ? '' : 'Re: ') . $rb_obj->record['subject'], '<br /><br /><strong>' . __('On %s wrote', array(Base_RegionalSettingsCommon::time2reg($rb_obj->record['date']) . ', ' . $rb_obj->record['from'])) . ':</strong><br/>' . $rb_obj->record['body'] . ($attachments ? '<hr /><strong>' . __('Attachments') . ':</strong><br/>' . $attachments : ''), $rb_obj->record['message_id'], html_entity_decode($rb_obj->record['references']))); } elseif (isset($_GET['rc_forward']) && $_GET['rc_forward'] == $rb_obj->record['id']) { Base_BoxCommon::push_module('CRM_Roundcube', 'new_mail', array('', (preg_match('/^Re:/i', $rb_obj->record['subject']) ? '' : 'Re: ') . $rb_obj->record['subject'], '<br /><br /><strong>' . __('On %s wrote', array(Base_RegionalSettingsCommon::time2reg($rb_obj->record['date']) . ', ' . $rb_obj->record['from'])) . ':</strong><br/>' . $rb_obj->record['body'] . ($attachments ? '<hr /><strong>' . __('Attachments') . ':</strong><br/>' . $attachments : ''))); } Base_ActionBarCommon::add('reply', __('Reply'), Module::create_href(array('rc_reply' => $rb_obj->record['id']))); Base_ActionBarCommon::add('reply', __('Reply All'), Module::create_href(array('rc_replyall' => $rb_obj->record['id']))); Base_ActionBarCommon::add('forward', __('Forward'), Module::create_href(array('rc_forward' => $rb_obj->record['id']))); }