예제 #1
0
 public function init()
 {
     $table = '';
     $class = '';
     $min_level = 0;
     $per_page = 0;
     if (is_request('event_id')) {
         set_new_event(get_request('event_id'));
     }
     $this->table = MODEL . $table;
     $this->class = $class;
     $this->min_level = $min_level;
     $this->per_page = $per_page;
     $this->db = Zend_Registry::get('db');
     $this->messenger = $this->_helper->_flashMessenger;
     //   any session must be after flashMessenger
     if (Zend_Version::compareVersion('1.10.1')) {
         date_default_timezone_set(get_control_value('System Keys', 'Time Zone'));
     } else {
         set_session('language', Zend_Registry::get('language'));
     }
     putenv('TZ=' . get_control_value('System Keys', 'Time Zone'));
     $this->db->query('SET time_zone=' . preg_replace('/([+-]\\d{2})(\\d{2})/', '\'\\1:\\2\'', date('O')));
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $contr = $request->getControllerName();
     $action = $request->getActionName();
     set_session('table', $table);
     set_session('class', $class);
     set_session('contr', $contr);
     set_session('action', $action);
     logger($contr);
     //   set control_company from url's request
     if (is_request('control_company')) {
         set_session('control_company', get_request('control_company'));
     }
     //   set control_company from url's subdomain
     /*
          if( !is_session( 'control_company' )) {
               $http_host = $_SERVER[ 'HTTP_HOST' ];
               $names = explode( '.', $http_host );
               $model = MODEL . 'Companies';
               $Companies = new $model();
               $company_id = $Companies->getIdByName( $names[ 0 ]);
               if( !$company_id )
                    $company_id = COMPANY_ID;
               set_session( 'control_company', $company_id );
          }
     */
     if (!is_logged() and is_request('user_key') and $action != 'confirm') {
         self::check_user_key();
     }
     if ($contr != 'homelx' and $contr != 'index' and $contr != 'uploads' and $contr != 'user') {
         //        memorize return_login ( entry point of the system )
         #          if( ! is_session( 'return_login' ))
         #               set_session( 'return_login', get_session( 'contr' ) . '/' . get_session( 'action' ));
         if ($contr == 'orderstt2' and $action == 'show' and is_request('id')) {
             set_session('return_login', $contr . '/' . $action . '?id=' . get_request('id'));
         }
         if ($contr == 'transvn' and $action == 'response' and is_request('id')) {
             set_session('return_login', $contr . '/' . $action . '?id=' . get_request('id') . '&updated_at=' . get_request('updated_at'));
         }
         if ($contr == 'feesvn' and $action == 'show' and is_request('id')) {
             set_session('return_login', $contr . '/' . $action . '?id=' . get_request('id'));
         }
         //        required login
         if (!is_logged()) {
             $this->_redirect('user/login');
         }
         //        check user_level against minimum access level of each program
         if (!is_permitted($this->min_level)) {
             $model = MODEL . 'Users';
             $Users = new $model();
             $Users->setLogout();
             unset_session('return_login');
             //   clean up previous return to avoid login looping
             $this->_redirect('user/login');
         }
     }
     if (is_request('search')) {
         $search = get_request('search');
         set_claxx('search', $search);
         //   save [search] for returned page
         set_claxx('page', '1');
         //   always starts from page 1
     }
     if (is_request('s_tags')) {
         $s_tags = get_request('s_tags');
         set_claxx('s_tags', $s_tags);
         //   save [s_tags] for returned page
         set_claxx('page', '1');
         //   always starts from page 1
     }
 }
예제 #2
0
function get_pos_login()
{
    if (HAS_PROJECTS) {
        set_session('start', 'Start-' . get_user_type());
        return 'index.php/index/start';
    }
    if (HAS_VIDEOS) {
        if (get_session('user_level') == MINIMUM_TO_BROWSE) {
            return 'tvideos';
        } else {
            if (is_permitted(MINIMUM_TO_UPDATE)) {
                return POS_LOGIN_INTERNAL;
            } else {
                return POS_LOGIN_EXTERNAL;
            }
        }
    }
    if (HAS_EVENTS) {
        if (!is_session('event_id')) {
            if (is_permitted(MINIMUM_TO_UPDATE)) {
                $model = MODEL . 'Events';
                $Events = new $model();
                set_new_event($Events->getIdByCompany(COMPANY_ID));
                return INDEX . POS_LOGIN_INTERNAL;
            } else {
                if (is_session('start')) {
                    return 'index.php/index/start';
                } else {
                    //                       return INDEX . 'index/dashboard';            //   index.php is required in linux server
                    return 'index.php/index/dashboard';
                    //   index.php is required in linux server
                }
            }
        } else {
            if (is_permitted(MINIMUM_TO_UPDATE)) {
                return POS_LOGIN_INTERNAL;
            } else {
                return POS_LOGIN_EXTERNAL;
            }
        }
    } else {
        if (is_permitted(MINIMUM_TO_UPDATE)) {
            return POS_LOGIN_INTERNAL;
        } else {
            return POS_LOGIN_EXTERNAL;
        }
    }
}