예제 #1
0
 public static function login_check_exit()
 {
     $after = Base_AclCommon::is_user();
     if ($after !== self::$logged) {
         if ($after) {
             Base_HomePageCommon::load();
         } else {
             Base_BoxCommon::location(Base_BoxCommon::get_main_module_name());
         }
     }
 }
예제 #2
0
 public static function init()
 {
     if (Base_AclCommon::is_user() == false || self::$initialized) {
         return;
     }
     DB::Execute('DELETE FROM base_notify WHERE single_cache_uid is null AND last_refresh < %d', array(strtotime('-24 hours')));
     load_js('modules/Base/Notify/js/desktop-notify.js');
     load_js('modules/Base/Notify/js/main.js');
     $disabled_message = __('Notifications disabled or not supported!') . '\\n' . __('Check your browser settings and allow notifications to use this feature...');
     $disabled_message = json_encode($disabled_message);
     eval_js_once("Base_Notify.init (" . self::refresh_rate * 1000 . ", {$disabled_message});");
     self::$initialized = true;
 }
예제 #3
0
파일: Handle.php 프로젝트: cretzu89/EPESI
 protected function load_epesi()
 {
     if (self::$epesi_loaded) {
         return;
     }
     define('CID', false);
     define('READ_ONLY_SESSION', true);
     require_once '../../../include.php';
     ModuleManager::load_modules();
     self::$epesi_loaded = true;
     if (!Base_AclCommon::is_user()) {
         throw new ErrorException('Not logged in');
     }
 }
예제 #4
0
 static function form()
 {
     try {
         $anonymous = Variable::get('anonymous_setup');
     } catch (NoSuchVariableException $e) {
         $anonymous = true;
     }
     if (!Base_AclCommon::is_user() && Base_User_LoginCommon::is_banned()) {
         return self::t('You have exceeded the number of allowed login attempts.');
     }
     require_once 'modules/Libs/QuickForm/requires.php';
     if (!Base_AclCommon::is_user() && !$anonymous) {
         Base_User_LoginCommon::autologin();
     }
     if (!Base_AclCommon::is_user() && !$anonymous) {
         $get = count($_GET) ? '?' . http_build_query($_GET) : '';
         $form = new HTML_QuickForm('loginform', 'post', $_SERVER['PHP_SELF'] . $get);
         $form->setRequiredNote('<span style="font-size:80%; color:#ff0000;">*</span><span style="font-size:80%;">' . self::t('denotes required field') . '</span>');
         $form->addElement('text', 'username', self::t('Username'));
         $form->addRule('username', 'Field required', 'required');
         $form->addElement('password', 'password', self::t('Password'));
         $form->addRule('password', 'Field required', 'required');
         // 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', self::t('You have exceeded the number of allowed login attempts.'), 'check_user_banned');
         // register and add a rule to check if user and password exists
         $form->registerRule('check_login', 'callback', 'submit_login', 'Base_User_LoginCommon');
         $form->addRule(array('username', 'password'), self::t('Login or password incorrect'), 'check_login', $form);
         $form->addElement('submit', null, self::t('Login'));
         if ($form->validate()) {
             $user = $form->exportValue('username');
             Base_AclCommon::set_user(Base_UserCommon::get_user_id($user), true);
             // redirect below is used to better browser refresh behavior.
             header('Location: ' . $_SERVER['REQUEST_URI']);
         } else {
             return "<center>" . $form->toHtml() . "</center>";
         }
     }
 }
예제 #5
0
파일: refresh.php 프로젝트: 62BRAINS/EPESI
<?php

/**
 * 
 * @author Georgi Hristov <*****@*****.**>
 * @copyright Copyright &copy; 2014, Xoff Software GmbH
 * @license MIT
 * @version 1.0
 * @package epesi-notify
 * 
 */
ob_start();
define('CID', $_REQUEST['cid']);
require_once '../../../include.php';
ModuleManager::load_modules();
if (!Base_AclCommon::is_user()) {
    exit;
}
$general_setting = Base_NotifyCommon::get_general_setting();
if ($general_setting == -1) {
    echo json_encode(array('disable' => 1));
    exit;
}
$ret = null;
$notify_count = 0;
$group_similar = Base_NotifyCommon::group_similar();
$notifications = Base_NotifyCommon::get_notifications();
foreach ($notifications as $module => $notify) {
    if (!isset($notify['tray'])) {
        continue;
    }
예제 #6
0
파일: Box_0.php 프로젝트: cretzu89/EPESI
 public function body()
 {
     if (isset(Base_BoxCommon::$override_box_main)) {
         $this->pack_module(Base_BoxCommon::$override_box_main);
         return;
     }
     $theme = $this->pack_module(Base_Theme::module_name());
     $ini = Base_BoxCommon::get_ini_file();
     if (!$ini) {
         print __('Unable to read Base/Box/default.ini file! Please create one, or change theme.');
         $this->pack_module(Base_Theme_Administrator::module_name(), null, 'admin');
         return;
     }
     $ini_file = parse_ini_file($ini, true);
     $logged = Base_AclCommon::is_user();
     $theme->assign('logged', $logged);
     $containers = array();
     $containers['main'] = array('module' => null, 'name' => '');
     //so 'main' is first in array
     $name = 0;
     foreach ($ini_file as $tag => $opts) {
         $name++;
         if ($logged && $opts['display'] == 'anonymous' || !$logged && $opts['display'] == 'logged') {
             continue;
         }
         if (isset($opts['function'])) {
             $containers[$tag]['function'] = $opts['function'];
             $containers[$tag]['arguments'] = null;
         }
         if (isset($opts['arguments'])) {
             $containers[$tag]['arguments'] = $opts['arguments'];
         }
         if (isset($opts['module'])) {
             $containers[$tag]['module'] = $opts['module'];
         } else {
             trigger_error('No module specified.', E_USER_ERROR);
         }
         $containers[$tag]['name'] = $tag;
     }
     if (isset($containers['main'])) {
         $containers['main']['name'] = 'main_0';
     }
     if (isset($_REQUEST['base_box_pop_main'])) {
         $pop_main = $_REQUEST['base_box_pop_main'];
         unset($_REQUEST['base_box_pop_main']);
     } else {
         $pop_main = false;
     }
     if ($this->isset_module_variable('main')) {
         $mains = $this->get_module_variable('main');
         if ($pop_main) {
             while ($pop_main--) {
                 array_pop($mains);
             }
             $pop_main = true;
         }
         $main = array_pop($mains);
         if (isset($main['module']) && $main['module'] != null) {
             $containers['main'] =& $main;
         }
         foreach ($mains as $k => $m) {
             if (ModuleManager::is_installed($m['module']) >= 0) {
                 $this->freeze_module($m['module'], isset($m['name']) ? $m['name'] : null);
             }
         }
     } else {
         $mains = array();
     }
     if (isset($_REQUEST['box_main_href'])) {
         if (!isset($_SESSION['client']['base_box_hrefs'])) {
             $_SESSION['client']['base_box_hrefs'] = array();
         }
         $hs =& $_SESSION['client']['base_box_hrefs'];
         if (isset($hs[$_REQUEST['box_main_href']])) {
             $rh = $hs[$_REQUEST['box_main_href']];
             $href = $rh['m'];
             $containers['main']['module'] = $href;
             if (isset($rh['f'])) {
                 $containers['main']['function'] = $rh['f'];
             } else {
                 unset($containers['main']['function']);
             }
             if (isset($rh['a'])) {
                 $containers['main']['arguments'] = $rh['a'];
             } else {
                 unset($containers['main']['arguments']);
             }
             if (isset($rh['c'])) {
                 $containers['main']['constructor_arguments'] = $rh['c'];
             } else {
                 unset($containers['main']['constructor_arguments']);
             }
             $mains = array();
             $pop_main = true;
         }
         unset($_REQUEST['box_main_href']);
         $hs = array();
     }
     array_push($mains, $containers['main']);
     $main_length = count($mains);
     $this->set_module_variable('main', $mains);
     //      Epesi::alert(print_r($mains,true));
     //      $containers['main']['name'] .= '_'.$main_length;
     //print_r($containers);
     $this->modules = array();
     foreach ($containers as $k => $v) {
         ob_start();
         if (ModuleManager::is_installed($v['module']) != -1) {
             $module_type = str_replace('/', '_', $v['module']);
             if (!isset($v['name'])) {
                 $v['name'] = null;
             }
             if (isset($href) && $k == 'main') {
                 $this->modules[$k] = $this->init_module($module_type, isset($v['constructor_arguments']) ? $v['constructor_arguments'] : null, $v['name'], true);
             } else {
                 $this->modules[$k] = $this->init_module($module_type, isset($v['constructor_arguments']) ? $v['constructor_arguments'] : null, $v['name']);
             }
             if ($k == 'main' && $pop_main) {
                 $this->modules[$k]->set_reload(true);
             }
             if (isset($v['function'])) {
                 $this->display_module($this->modules[$k], isset($v['arguments']) ? $v['arguments'] : null, $v['function']);
             } elseif (isset($v['arguments'])) {
                 $this->display_module($this->modules[$k], $v['arguments']);
             } else {
                 $this->display_module($this->modules[$k]);
             }
         }
         $theme->assign($k, ob_get_contents());
         ob_end_clean();
     }
     //main output
     $version_no = Base_BoxCommon::update_version_check_indicator();
     if (SUGGEST_DONATION) {
         $theme->assign('donate', Utils_TooltipCommon::create('<a target="_blank" href="http://epe.si/donate/">' . __('Support EPESI!') . '</a>', '<center>' . __('If you find our software useful, please support us by making a %s.', array(__('donation'))) . '<br/>' . __('Your funding will help to ensure continued development of this project.') . '<br/>' . __('Click for details.') . '</center>', false, 500));
     }
     // Consider moving this code properly as initated module by *.ini file
     $theme->assign('home', array('href' => Base_HomePageCommon::get_href(), 'label' => __('Home')));
     $theme->assign('version_no', $version_no);
     $theme->display();
 }
예제 #7
0
 public static function get_lang_code()
 {
     if (defined('FORCE_LANG_CODE')) {
         return FORCE_LANG_CODE;
     }
     if (!isset(self::$lang_code)) {
         if (!Base_AclCommon::is_user() || Base_User_SettingsInstall::is_installed() == false || !Variable::get('allow_lang_change', false)) {
             return Variable::get('default_lang');
         }
         if (class_exists('Base_User_SettingsCommon')) {
             self::$lang_code = Base_User_SettingsCommon::get('Base_Lang_Administrator', 'language');
         }
     }
     return self::$lang_code;
 }
예제 #8
0
 public static function body_access()
 {
     return Base_AclCommon::is_user();
 }
예제 #9
0
 /**
  * Displays action bar.
  */
 public function body()
 {
     $this->help('ActionBar basics', 'main');
     $icons = Base_ActionBarCommon::get();
     //sort
     usort($icons, array($this, 'compare'));
     //translate
     foreach ($icons as &$i) {
         $description = $i['description'];
         if ($i['description']) {
             $t = Utils_TooltipCommon::open_tag_attrs($description);
         } else {
             $t = '';
         }
         $i['open'] = '<a ' . $i['action'] . ' ' . $t . '>';
         $i['close'] = '</a>';
         $i['helpID'] = 'ActionBar_' . $i['icon'];
         if (strpos($i['icon'], '/') !== false && file_exists($i['icon'])) {
             $i['icon_url'] = $i['icon'];
             unset($i['icon']);
         }
         //if (isset(Base_ActionBarCommon::$available_icons[$i['icon']]))
         //	$i['icon'] = Base_ThemeCommon::get_template_file('Base_ActionBar','icons/'.$i['icon'].'.png');
     }
     $launcher = array();
     if (Base_AclCommon::is_user()) {
         $opts = Base_Menu_QuickAccessCommon::get_options();
         if (!empty($opts)) {
             self::$launchpad = array();
             foreach ($opts as $k => $v) {
                 if (Base_ActionBarCommon::$quick_access_shortcuts && Base_User_SettingsCommon::get(Base_Menu_QuickAccessCommon::module_name(), $v['name'] . '_d')) {
                     $ii = array();
                     $trimmed_label = trim(substr(strrchr($v['label'], ':'), 1));
                     $ii['label'] = $trimmed_label ? $trimmed_label : $v['label'];
                     $ii['description'] = $v['label'];
                     $arr = $v['link'];
                     if (isset($arr['__url__'])) {
                         $ii['open'] = '<a href="' . $arr['__url__'] . '" target="_blank">';
                     } else {
                         $ii['open'] = '<a ' . Base_MenuCommon::create_href($this, $arr) . '>';
                     }
                     $ii['close'] = '</a>';
                     if (isset($v['link']['__icon__'])) {
                         $icon = Base_ThemeCommon::get_template_file($v['module'], $v['link']['__icon__']);
                     } else {
                         $icon = Base_ThemeCommon::get_template_file($v['module'], 'icon.png');
                     }
                     if (!$icon) {
                         $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'default_icon.png');
                     }
                     $ii['icon'] = $icon;
                     $launcher[] = $ii;
                 }
                 if (Base_User_SettingsCommon::get(Base_Menu_QuickAccessCommon::module_name(), $v['name'] . '_l')) {
                     $ii = array();
                     $trimmed_label = trim(substr(strrchr($v['label'], ':'), 1));
                     $ii['label'] = $trimmed_label ? $trimmed_label : $v['label'];
                     $ii['description'] = $v['label'];
                     $arr = $v['link'];
                     if (isset($arr['__url__'])) {
                         $ii['open'] = '<a href="' . $arr['__url__'] . '" target="_blank" onClick="actionbar_launchpad_deactivate()">';
                     } else {
                         $ii['open'] = '<a onClick="actionbar_launchpad_deactivate();' . Base_MenuCommon::create_href_js($this, $arr) . '" href="javascript:void(0)">';
                     }
                     $ii['close'] = '</a>';
                     if (isset($v['link']['__icon__'])) {
                         $icon = Base_ThemeCommon::get_template_file($v['module'], $v['link']['__icon__']);
                     } else {
                         $icon = Base_ThemeCommon::get_template_file($v['module'], 'icon.png');
                     }
                     if (!$icon) {
                         $icon = Base_ThemeCommon::get_template_file($this->get_type(), 'default_icon.png');
                     }
                     $ii['icon'] = $icon;
                     self::$launchpad[] = $ii;
                 }
             }
         }
     }
     //display
     $th = $this->pack_module(Base_Theme::module_name());
     $th->assign('icons', $icons);
     $th->assign('launcher', array_reverse($launcher));
     $th->display();
 }
예제 #10
0
 public function chat($big = false, $uid = null)
 {
     $to =& $this->get_module_variable('to', "all");
     eval_js('shoutbox_uid="' . $to . '"');
     if (Base_AclCommon::is_user()) {
         //initialize HTML_QuickForm
         $qf = $this->init_module(Libs_QuickForm::module_name());
         /*            $myid = Base_AclCommon::get_user();
                 	if(Base_User_SettingsCommon::get('Apps_Shoutbox','enable_im')) {
                 	    $adm = Base_User_SettingsCommon::get_admin('Apps_Shoutbox','enable_im');
                 	    if(ModuleManager::is_installed('CRM_Contacts')>=0) {
                     	    $emps = DB::GetAssoc('SELECT l.id,IF(cd.f_last_name!=\'\',CONCAT(cd.f_last_name,\' \',cd.f_first_name,\' (\',l.login,\')\'),l.login) as name FROM user_login l LEFT JOIN contact_data_1 cd ON (cd.f_login=l.id AND cd.active=1) LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is '.($adm?'':'not ').'null) ORDER BY name',array($myid,serialize(1)));			    
         		        } else
             		        $emps = DB::GetAssoc('SELECT l.id,l.login FROM user_login l LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is '.($adm?'':'not ').'null) ORDER BY l.login',array($myid,serialize(1)));
             		} else $emps = array();
             		if(ModuleManager::is_installed('Tools_WhoIsOnline')>=0) {
             		    $online = Tools_WhoIsOnlineCommon::get_ids();
             		    foreach($online as $id) {
             		        if(isset($emps[$id])) 
             		            $emps[$id] = '* '.$emps[$id] ;
             		    }
             		}
                		$qf->addElement('select','to',__('To'),array('all'=>'['.__('All').']')+$emps,array('id'=>'shoutbox_to'.($big?'_big':''),'onChange'=>'shoutbox_uid=this.value;shoutbox_refresh'.($big?'_big':'').'()'));*/
         $myid = Base_AclCommon::get_user();
         if (Base_User_SettingsCommon::get('Apps_Shoutbox', 'enable_im') && ModuleManager::is_installed('Tools_WhoIsOnline') >= 0) {
             $adm = Base_User_SettingsCommon::get_admin('Apps_Shoutbox', 'enable_im');
             $online = Tools_WhoIsOnlineCommon::get_ids();
             if ($online) {
                 if (ModuleManager::is_installed('CRM_Contacts') >= 0) {
                     $emps = DB::GetAssoc('SELECT l.id,' . DB::Concat(DB::qstr("* "), DB::ifelse('cd.f_last_name!=\'\'', DB::concat('cd.f_last_name', DB::qstr(' '), 'cd.f_first_name', DB::qstr(' ('), 'l.login', DB::qstr(')')), 'l.login')) . ' as name FROM user_login l LEFT JOIN contact_data_1 cd ON (cd.f_login=l.id AND cd.active=1) LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is ' . ($adm ? '' : 'not ') . 'null) AND l.id IN (' . implode(',', $online) . ') ORDER BY name', array($myid, serialize(1)));
                 } else {
                     $emps = DB::GetAssoc('SELECT l.id,' . DB::Concat(DB::qstr("* "), 'l.login') . ' FROM user_login l LEFT JOIN base_user_settings us ON (us.user_login_id=l.id AND module=\'Apps_Shoutbox\' AND variable=\'enable_im\') WHERE l.active=1 AND l.id!=%d AND (us.value=%s OR us.value is ' . ($adm ? '' : 'not ') . 'null) AND l.id IN (' . implode(',', $online) . ') ORDER BY l.login', array($myid, serialize(1)));
                 }
             } else {
                 $emps = array();
             }
         } else {
             $emps = array();
         }
         $e = $qf->addElement('autoselect', 'shoutbox_to', __('To'), array('all' => '[' . __('All') . ']') + $emps, array(array($this->get_type() . 'Common', 'user_search'), array()), array($this->get_type() . 'Common', 'user_format'));
         $e->setAttribute('id', 'shoutbox_to' . ($big ? '_big' : ''));
         $e->setAttribute('onChange', 'shoutbox_uid=this.value;shoutbox_refresh' . ($big ? '_big' : '') . '()');
         if (!Base_User_SettingsCommon::get('Apps_Shoutbox', 'enable_im')) {
             $qf->freeze(array('shoutbox_to'));
         }
         //create text box
         $qf->addElement($big ? 'textarea' : 'textarea', 'post', __('Message'), 'class="border_radius_6px" id="shoutbox_text' . ($big ? '_big' : '') . '"');
         $qf->addRule('post', __('Field required'), 'required');
         //create submit button
         $qf->addElement('submit', 'submit_button', __('Send'), 'id="shoutbox_button' . ($big ? '_big' : '') . '"');
         //add it
         $qf->setRequiredNote(null);
         $qf->setDefaults(array('shoutbox_to' => $to));
         $theme = $this->init_module(Base_Theme::module_name());
         $qf->assign_theme('form', $theme);
         //confirm when sending messages to all
         eval_js("jq('#shoutbox_button, #shoutbox_button_big').click(function() {\n      \t\t\t\t\tvar submit = true;\n\t\t    \t\t\tif (jq('#shoutbox_to').val() == 'all' && !confirm('" . __('Send message to all?') . "')) {\n         \t\t\t\t\tsubmit = false;\n      \t\t\t\t\t}\n\t\t    \n\t\t    \t\t\treturn submit;\t\t    \t\t\t\n\t\t\t\t\t});");
         //if submited
         if ($qf->validate()) {
             //get post group
             $msg = $qf->exportValue('post');
             $to = $qf->exportValue('shoutbox_to');
             //get msg from post group
             $msg = Utils_BBCodeCommon::optimize($msg);
             //get logged user id
             $user_id = Base_AclCommon::get_user();
             //clear text box and focus it
             eval_js('$(\'shoutbox_text' . ($big ? '_big' : '') . '\').value=\'\';focus_by_id(\'shoutbox_text' . ($big ? '_big' : '') . '\');shoutbox_uid="' . $to . '"');
             //insert to db
             DB::Execute('INSERT INTO apps_shoutbox_messages(message,base_user_login_id,to_user_login_id) VALUES(%s,%d,%d)', array(htmlspecialchars($msg, ENT_QUOTES, 'UTF-8'), $user_id, is_numeric($to) ? $to : null));
         }
     } else {
         print __('Please log in to post message') . '<br>';
         return;
     }
     $theme->assign('board', '<div id=\'shoutbox_board' . ($big ? '_big' : '') . '\'></div>');
     $theme->assign('header', __('Shoutbox'));
     $theme->display('chat_form' . ($big ? '_big' : ''));
     //if shoutbox is diplayed, call myFunctions->refresh from refresh.php file every 5s
     eval_js_once('shoutbox_refresh' . ($big ? '_big' : '') . ' = function(){if(!$(\'shoutbox_board' . ($big ? '_big' : '') . '\')) return;' . 'new Ajax.Updater(\'shoutbox_board' . ($big ? '_big' : '') . '\',\'modules/Apps/Shoutbox/refresh.php\',{method:\'get\', parameters: { uid: shoutbox_uid }});' . '};setInterval(\'shoutbox_refresh' . ($big ? '_big' : '') . '()\',' . ($big ? '10000' : '30000') . ')');
     eval_js('shoutbox_refresh' . ($big ? '_big' : '') . '()');
 }
예제 #11
0
 private function get_values($id, $mod)
 {
     if (!isset(self::$settings_cache)) {
         self::$settings_cache = array('default' => array(), 'user' => array());
         $ret = DB::Execute('SELECT applet_id,name,value FROM base_dashboard_default_settings');
         while ($row = $ret->FetchRow()) {
             self::$settings_cache['default'][$row['applet_id']][] = $row;
         }
         self::$settings_cache['user'] = array();
         if (Base_AclCommon::is_user()) {
             $ret = DB::Execute('SELECT s.applet_id,s.name,s.value FROM base_dashboard_settings s INNER JOIN base_dashboard_applets a ON a.id=s.applet_id WHERE a.user_login_id=%d', array(Base_AclCommon::get_user()));
             while ($row = $ret->FetchRow()) {
                 self::$settings_cache['user'][$row['applet_id']][] = $row;
             }
         }
     }
     if ($this->get_module_variable('default')) {
         $c = self::$settings_cache['default'];
     } else {
         $c = self::$settings_cache['user'];
     }
     if (!isset($c[$id])) {
         $c = array();
     } else {
         $c = $c[$id];
     }
     $variables = $this->get_default_values($mod);
     foreach ($c as $v) {
         $variables[$v['name']] = $v['value'];
     }
     return $variables;
 }