Example #1
0
if(!isset($_POST['url']) || !isset($_SERVER['HTTP_X_CLIENT_ID']))
	die('alert(\'Invalid request\');');


define('JS_OUTPUT',1);
define('EPESI_PROCESS',1);
require_once('include.php');

if (epesi_requires_update()) {
    die ('window.location = "index.php";');
}

if(!isset($_SESSION['num_of_clients'])) {
	Epesi::alert('Session expired, restarting epesi');
	Epesi::redirect();
	Epesi::send_output();
	define('SESSION_EXPIRED',1);
	//session_commit();
	//DBSession::destroy(session_id());
} else {
	Epesi::process($_POST['url'],isset($_POST['history'])?$_POST['history']:false);
}
$content = ob_get_contents();
ob_end_clean();

require_once('libs/minify/HTTP/Encoder.php');
$he = new HTTP_Encoder(array('content' => $content));
if (MINIFY_ENCODE)
	$he->encode();
$he->sendAll();
Example #2
0
 * @copyright Copyright © 2008, Telaxus LLC
 * @license MIT
 * @version 1.0
 * @package epesi-base
 * @subpackage dashboard
 */
header("Content-type: text/javascript");
define('JS_OUTPUT', 1);
define('CID', false);
//don't load user session
define('READ_ONLY_SESSION', true);
require_once '../../../include.php';
ModuleManager::load_modules();
if (!Base_AclCommon::is_user()) {
    Epesi::alert('Session expired, logged out - reloading epesi.');
    Epesi::redirect('');
    Epesi::send_output();
    exit;
}
$default = isset($_POST['default_dash']) && $_POST['default_dash'];
if ($default && !Base_AdminCommon::get_access('Base_Dashboard') || !isset($_POST['col']) || !isset($_POST['data'])) {
    Epesi::alert('Permission denied');
    Epesi::send_output();
    exit;
}
if (!$default) {
    $user = Base_AclCommon::get_user();
}
$tab = json_decode($_POST['tab']);
parse_str($_POST['data'], $x);
if (!isset($x['ab_item'])) {
Example #3
0
 public function validate($data)
 {
     if (DEMO_MODE) {
         print 'You cannot modify installed modules in demo';
         return false;
     }
     @set_time_limit(0);
     $installed = array();
     $install = array();
     $uninstall = array();
     $anonymous_setup = false;
     foreach ($data as $k => $v) {
         ${$k} = $v;
     }
     foreach ($installed as $name => $new_version) {
         $old_version = ModuleManager::is_installed($name);
         if ($old_version == $new_version) {
             continue;
         }
         if ($old_version == -1 && $new_version >= 0) {
             $install[$name] = $new_version;
             continue;
         }
         if ($new_version == -2) {
             $uninstall[$name] = 1;
             $install[$name] = $old_version;
             continue;
         }
         if ($old_version >= 0 && $new_version == -1) {
             $uninstall[$name] = 1;
             continue;
         }
         if ($old_version < $new_version) {
             if (!ModuleManager::upgrade($name, $new_version)) {
                 return false;
             }
             continue;
         }
         if ($old_version > $new_version) {
             if (!ModuleManager::downgrade($name, $new_version)) {
                 return false;
             }
             continue;
         }
     }
     //uninstall
     $modules_prio_rev = array();
     foreach (ModuleManager::$modules as $k => $v) {
         $modules_prio_rev[] = $k;
     }
     $modules_prio_rev = array_reverse($modules_prio_rev);
     foreach ($modules_prio_rev as $k) {
         if (array_key_exists($k, $uninstall)) {
             if (!ModuleManager::uninstall($k)) {
                 return false;
             }
             if (count(ModuleManager::$modules) == 0) {
                 print 'No modules installed';
             }
         }
     }
     //install
     foreach ($install as $i => $v) {
         $post_install[$i] = $v;
         if (isset($uninstall[$i])) {
             if (!ModuleManager::install($i, $v, true, false)) {
                 return false;
             }
         } else {
             if (!ModuleManager::install($i, $v)) {
                 return false;
             }
         }
     }
     $processed = ModuleManager::get_processed_modules();
     $this->set_module_variable('post-install', $processed['install']);
     Base_ThemeCommon::create_cache();
     if (empty($post_install)) {
         Epesi::redirect();
     }
     return true;
 }
Example #4
0
 public static function QFfield_login(&$form, $field, $label, $mode, $default, $desc, $rb = null)
 {
     $label = __('EPESI User');
     if (!Base_AclCommon::i_am_admin()) {
         return;
     }
     if ($mode == 'view') {
         if (!$default) {
             return;
         }
         if (Base_AclCommon::i_am_sa()) {
             Base_ActionBarCommon::add('settings', __('Log as user'), Module::create_href(array('log_as_user' => $default)));
             if (isset($_REQUEST['log_as_user']) && $_REQUEST['log_as_user'] == $default) {
                 Acl::set_user($default, true);
                 //tag who is logged
                 Epesi::redirect();
                 return;
             }
         }
         $form->addElement('static', $field, $label);
         $form->setDefaults(array($field => self::display_login(array('login' => $default), true, array('id' => 'login'))));
         return;
     }
     $ret = DB::Execute('SELECT id, login FROM user_login ORDER BY login');
     $users = array('' => '---', 'new' => '[' . __('Create new user') . ']');
     while ($row = $ret->FetchRow()) {
         $contact_id = Utils_RecordBrowserCommon::get_id('contact', 'login', $row['id']);
         if ($contact_id === false || $contact_id === null || $row['id'] === $default && $mode != 'add') {
             if (Base_AclCommon::i_am_admin() || $row['id'] == Acl::get_user()) {
                 $users[$row['id']] = $row['login'];
             }
         }
     }
     $form->addElement('select', $field, $label, $users, array('id' => 'crm_contacts_select_user'));
     $form->setDefaults(array($field => $default));
     if ($default !== '') {
         $form->freeze($field);
     } else {
         eval_js('new_user_textfield = function(){' . '($("crm_contacts_select_user").value=="new"?"":"none");' . '$("username").up("tr").style.display = $("set_password").up("tr").style.display = $("confirm_password").up("tr").style.display = $("_access__data").up("tr").style.display = ($("crm_contacts_select_user").value==""?"none":"");' . 'if ($("contact_admin")) $("contact_admin").up("tr").style.display = ($("crm_contacts_select_user").value==""?"none":"");' . '}');
         eval_js('new_user_textfield();');
         eval_js('Event.observe("crm_contacts_select_user","change",function(){new_user_textfield();});');
     }
     if ($default) {
         eval_js('$("_login__data").up("tr").style.display = "none";');
     }
 }
Example #5
0
 public function body()
 {
     // init lang from install process
     $install_lang_code =& $_GET['install_lang'];
     if (isset($install_lang_code)) {
         // set anonymous setup to true at very first run to allow use admin tools.
         Variable::set('anonymous_setup', true);
         //
         Variable::set('default_lang', $install_lang_code);
         Epesi::redirect('index.php');
         return;
     }
     Base_LangCommon::load();
     $th = $this->init_module('Base/Theme');
     ob_start();
     print '<center>';
     $post_install =& $_SESSION['first-run_post-install'];
     if (!empty($post_install)) {
         foreach ($post_install as $i => $v) {
             $i = str_replace('/', '_', $i);
             ModuleManager::include_install($i);
             $f = array($i . 'Install', 'post_install');
             $fs = array($i . 'Install', 'post_install_process');
             if (!is_callable($f) || !is_callable($fs)) {
                 unset($post_install[$i]);
                 continue;
             }
             $ret = call_user_func($f);
             $form = $this->init_module('Libs/QuickForm', null, $i);
             $form->addElement('header', null, __('Post installation of %s', array(str_replace('_', '/', $i))));
             $form->add_array($ret);
             $form->addElement('submit', null, 'OK');
             if ($form->validate()) {
                 $form->process($fs);
                 unset($post_install[$i]);
             } else {
                 $form->display();
                 break;
             }
         }
         if (ModuleManager::is_installed('Base') >= 0 && empty($post_install)) {
             Variable::set('default_module', 'Base_Box');
             Epesi::redirect();
         }
     }
     if (empty($post_install) && ModuleManager::is_installed('Base') < 0) {
         $wizard = $this->init_module('Utils/Wizard');
         /////////////////////////////////////////////////////////////
         $this->ini = parse_ini_file('modules/FirstRun/distros.ini', true);
         if (count($this->ini) > 1) {
             $f =& $wizard->begin_page();
             $f->addElement('header', null, __('Welcome to EPESI first run wizard'));
             $f->setDefaults(array('setup_type' => key($this->ini)));
             foreach ($this->ini as $name => $pkgs) {
                 switch ($name) {
                     case 'CRM installation':
                         $label = __('CRM installation');
                         break;
                     case 'CRM and Sales Opportunity':
                         $label = __('CRM and Sales Opportunity');
                         break;
                     case 'CRM and Bug Tracker installation':
                         $label = __('CRM and Bug Tracker installation');
                         break;
                     default:
                         $label = $name . ' (* missing translation)';
                         break;
                 }
                 $f->addElement('radio', 'setup_type', '', $label, $name);
             }
             $f->addElement('html', '<tr><td colspan=2><br /><strong>If you are not sure which package to choose select CRM Installation.<br>You can customize your installation later.</strong><br><br></td></tr>');
             $wizard->next_page();
         }
         /////////////////////////////////////////////////////////////////
         $f = $wizard->begin_page('simple_user');
         $f->addElement('header', null, __('Please enter administrator user login and password'));
         $f->addElement('text', 'login', __('Login'));
         $f->addRule('login', __('A username must be between 3 and 32 chars'), 'rangelength', array(3, 32));
         $f->addRule('login', __('Field required'), 'required');
         $f->addElement('text', 'mail', __('E-mail'));
         $f->addRule('mail', __('Field required'), 'required');
         $f->addRule('mail', __('Invalid e-mail address'), 'email');
         $f->addElement('password', 'pass', __('Password'));
         $f->addElement('password', 'pass_c', __('Confirm Password'));
         $f->addRule('pass', __('Field required'), 'required');
         $f->addRule('pass_c', __('Field required'), 'required');
         $f->addRule(array('pass', 'pass_c'), __('Passwords don\'t match'), 'compare');
         $f->addRule('pass', __('Your password must be longer then 5 chars'), 'minlength', 5);
         $wizard->next_page();
         /////////////////////////////////////////////////////
         $f = $wizard->begin_page('simple_mail');
         $f->addElement('header', null, __('Mail settings'));
         $f->addElement('html', '<tr><td colspan=2>' . __('If you are on a hosted server it probably should stay as it is now.') . '</td></tr>');
         $f->addElement('select', 'mail_method', __('Choose method'), array('smtp' => __('remote smtp server'), 'mail' => __('local php.ini settings')));
         $f->setDefaults(array('mail_method' => 'mail'));
         $wizard->next_page(array($this, 'choose_mail_method'));
         //////////////////////
         $f = $wizard->begin_page('simple_mail_smtp');
         $f->addElement('header', null, __('Mail settings'));
         $f->addElement('text', 'mail_host', __('SMTP host address'));
         $f->addRule('mail_host', __('Field required'), 'required');
         $f->addElement('header', null, __('If your server needs authorization...'));
         $f->addElement('text', 'mail_user', __('Login'));
         $f->addElement('password', 'mail_password', __('Password'));
         $wizard->next_page();
         ////////////////////////////////////////////////////////////
         $f = $wizard->begin_page('setup_warning');
         $f->addElement('header', null, __('Warning'));
         $f->addElement('html', '<tr><td colspan=2><br />' . __('Setup will now check for available modules and will install them.') . '<br>' . __('This operation may take several minutes.') . '<br><br></td></tr>');
         $wizard->next_page();
         /////////////////////////////////////////
         $this->display_module($wizard, array(array($this, 'done')));
     }
     print '</center>';
     $th->assign('wizard', ob_get_clean());
     $th->display();
 }
Example #6
0
 public function user_actions($r, $gb_row)
 {
     static $admin_levels = false;
     static $my_level = false;
     if ($admin_levels === false) {
         $admin_levels = DB::GetAssoc('SELECT id,admin FROM user_login');
     }
     if ($my_level === false) {
         $my_level = isset($admin_levels[Base_AclCommon::get_user()]) ? $admin_levels[Base_AclCommon::get_user()] : 0;
     }
     $mod = 'Base_User_Administrator';
     $log_as_user = Base_AdminCommon::get_access($mod, 'log_as_user');
     $log_as_admin = Base_AdminCommon::get_access($mod, 'log_as_admin');
     $user_level = isset($admin_levels[$r['login']]) ? $admin_levels[$r['login']] : 0;
     // 2 is superadmin, 1 admin, 0 user
     if ($my_level == 2 || $my_level == 1 && ($user_level == 0 && $log_as_user || $user_level == 1 && $log_as_admin)) {
         // contact is admin and I can login as admin
         if (Base_UserCommon::is_active($r['login'])) {
             $gb_row->add_action($this->create_callback_href(array($this, 'change_user_active_state'), array($r['login'], false)), 'Deactivate user', null, Base_ThemeCommon::get_template_file('Utils_GenericBrowser', 'active-on.png'));
             $gb_row->add_action(Module::create_href(array('log_as_user' => $r['login'])), 'Log as user', null, Base_ThemeCommon::get_template_file('Utils_GenericBrowser', 'restore.png'));
             // action!
             if (isset($_REQUEST['log_as_user']) && $_REQUEST['log_as_user'] == $r['login']) {
                 Acl::set_user($r['login'], true);
                 Epesi::redirect();
                 return;
             }
         } else {
             $gb_row->add_action($this->create_callback_href(array($this, 'change_user_active_state'), array($r['login'], true)), 'Activate user', null, Base_ThemeCommon::get_template_file('Utils_GenericBrowser', 'active-off.png'));
         }
     }
 }
Example #7
0
 public function log_as_user($id)
 {
     Acl::set_user($id, true);
     //tag who is logged
     Epesi::redirect();
 }