Exemplo n.º 1
0
 public function startMaintenance()
 {
     $this->setState(Ampoliros::STATE_MAINTENANCE);
     $this->setInterface(Ampoliros::INTERFACE_CONSOLE);
     $this->startRoot();
     import('com.solarix.ampoliros.maintenance.AmpolirosMaintenanceHandler');
     import('com.solarix.ampoliros.util.Hook');
     $hook = new Hook($GLOBALS['gEnv']['root']['db'], 'ampoliros', 'instance');
     switch ($hook->CallHooks('maintenance', $null, '')) {
         case Hook::RESULT_ABORT:
             AmpDie('Maintenance aborted');
             break;
     }
     $amp_mnt = new AmpolirosMaintenanceHandler();
     $GLOBALS['gEnv']['runtime']['maintenance']['result'] = $amp_mnt->DoMaintenance();
     $amp_mnt->SendReport($GLOBALS['gEnv']['runtime']['maintenance']['result']);
 }
Exemplo n.º 2
0
 public function logEvent($contest, $eventstring, $type = LOGGER_GENERIC)
 {
     $result = false;
     if (strlen($this->mLogFile) > 0) {
         global $gEnv;
         $timestamp = time();
         $date = getdate($timestamp);
         $log_event = false;
         switch ($type) {
             case LOGGER_NOTICE:
                 $evtype = 'NOTICE';
                 $log_event = true;
                 break;
             case LOGGER_WARNING:
                 $evtype = 'WARNING';
                 import('com.solarix.ampoliros.core.Ampoliros');
                 $amp = Ampoliros::instance('Ampoliros');
                 switch ($amp->getState()) {
                     case Ampoliros::STATE_DEBUG:
                     case Ampoliros::STATE_DEVELOPMENT:
                     case Ampoliros::STATE_SETUP:
                         $log_event = true;
                 }
                 break;
             case LOGGER_ERROR:
                 $evtype = 'ERROR';
                 $log_event = true;
                 break;
             case LOGGER_FAILURE:
                 $evtype = 'FAILURE';
                 $log_event = true;
                 break;
             case LOGGER_GENERIC:
                 $evtype = 'GENERIC';
                 $log_event = true;
                 break;
             case LOGGER_DEBUG:
                 $evtype = 'DEBUG';
                 import('com.solarix.ampoliros.core.Ampoliros');
                 $amp = Ampoliros::instance('Ampoliros');
                 if ($amp->getState() == Ampoliros::STATE_DEBUG) {
                     $log_event = true;
                 }
                 break;
             default:
                 $evtype = 'UNDEFINED';
                 $log_event = true;
                 break;
         }
         if ($log_event) {
             global $gEnv;
             $logstr = sprintf("%04s/%02s/%02s - %02s:%02s:%02s - %s - %s : %s", $date['year'], $date['mon'], $date['mday'], $date['hours'], $date['minutes'], $date['seconds'], $evtype, $contest, $eventstring);
             //$logstr = "$date[mday]/$date[mon]/$date[year] - $date[hours]:$date[minutes]:$date[seconds] - ".$evtype." - ".$contest." : ".$eventstring;
             @error_log($logstr . "\n", 3, $this->mLogFile);
             import('com.solarix.ampoliros.core.Ampoliros');
             $amp = Ampoliros::instance('Ampoliros');
             if ($amp->getState() == Ampoliros::STATE_DEBUG) {
                 $gEnv['runtime']['debug']['logs'][$this->mLogFile][] = $logstr;
             }
         }
         $result = $logstr;
         if ($evtype == LOGGER_FAILURE) {
             AmpDie($logstring);
         }
     }
     return $result;
 }
Exemplo n.º 3
0
 public function logEvent($destinations, $context, $eventString, $eventType = LOGGER_GENERIC, $die = false)
 {
     global $gEnv;
     // Root
     //
     if (isset($destinations['root'])) {
         $tmp_log = new Logger($gEnv['root']['log']);
         $tmp_log->LogEvent($context, $eventString, $eventType);
         unset($tmp_log);
     }
     // Root db
     //
     if (isset($destinations['rootdb'])) {
         $tmp_log = new Logger($gEnv['root']['dblog']);
         $tmp_log->LogEvent($context, $eventString, $eventType);
         unset($tmp_log);
     }
     // Remote
     //
     if (isset($destinations['remote'])) {
         $tmp_log = new Logger($gEnv['remote']['log']);
         $tmp_log->LogEvent($context, $eventString, $eventType);
         unset($tmp_log);
     }
     // PHP
     //
     if (isset($destinations['php'])) {
         $tmp_log = new Logger($gEnv['core']['error']['log']);
         $tmp_log->LogEvent($context, $eventString, $eventType);
         unset($tmp_log);
     }
     // Module
     //
     if (isset($destinations['module']) and is_dir(MODULE_PATH . $this->mModule)) {
         $tmp_log = new Logger(MODULE_PATH . $this->mModule . '/module.log');
         $tmp_log->LogEvent($context, $eventString, $eventType);
         unset($tmp_log);
     }
     // Site
     //
     if (isset($destinations['site'])) {
         $tmp_log = new Logger($gEnv['site']['log']);
         $tmp_log->LogEvent($context, $eventString, $eventType);
         unset($tmp_log);
     }
     // Site db
     //
     if (isset($destinations['sitedb'])) {
         $tmp_log = new Logger($gEnv['sit']['dblog']);
         $tmp_log->LogEvent($context, $eventString, $eventType);
         unset($tmp_log);
     }
     if ($die) {
         AmpDie($eventString);
     }
     return true;
 }
Exemplo n.º 4
0
 function DoAuth($wrong = false, $reason = '')
 {
     global $gEnv;
     $amp_locale = new Locale('amp_misc_auth', AMP_LANG);
     $amp = Ampoliros::instance('Ampoliros');
     $amp->startRoot();
     $hui = new Hui($gEnv['root']['db']);
     $hui->LoadWidget('button');
     $hui->LoadWidget('formarg');
     $hui->LoadWidget('form');
     $hui->LoadWidget('grid');
     $hui->LoadWidget('horizbar');
     $hui->LoadWidget('horizframe');
     $hui->LoadWidget('horizgroup');
     $hui->LoadWidget('image');
     $hui->LoadWidget('label');
     $hui->LoadWidget('link');
     $hui->LoadWidget('page');
     $hui->LoadWidget('sessionkey');
     $hui->LoadWidget('statusbar');
     $hui->LoadWidget('string');
     $hui->LoadWidget('submit');
     $hui->LoadWidget('titlebar');
     $hui->LoadWidget('vertframe');
     $hui->LoadWidget('vertgroup');
     $hui_page = new HuiPage('loginpage', array('title' => $amp_locale->GetStr('amplogin'), 'border' => 'false'));
     $hui_topgroup = new HuiVertGroup('topgroup', array('align' => 'center', 'groupalign' => 'center', 'groupvalign' => 'middle', 'height' => '100%'));
     $hui_maingroup = new HuiVertGroup('maingroup', array('align' => 'center'));
     $hui_titlebar = new HuiTitleBar('titlebar', array('title' => $amp_locale->GetStr('amplogin'), 'closewidget' => 'false', 'newwindowwidget' => 'false'));
     $hui_mainbframe = new HuiVertFrame('vframe', array('align' => 'center'));
     $hui_mainframe = new HuiHorizGroup('horizframe');
     $hui_mainstatus = new HuiStatusBar('mainstatusbar');
     // Main frame
     //
     $hui_grid = new HuiGrid('grid', array('rows' => '2', 'cols' => '2'));
     $hui_grid->AddChild(new HuiLabel('usernamelabel', array('label' => $amp_locale->GetStr('username'))), 0, 0);
     $hui_grid->AddChild(new HuiString('username', array('disp' => 'login')), 0, 1);
     $hui_grid->AddChild(new HuiLabel('passwordlabel', array('label' => $amp_locale->GetStr('password'))), 1, 0);
     $hui_grid->AddChild(new HuiString('password', array('disp' => 'login', 'password' => 'true')), 1, 1);
     $hui_vgroup = new HuiVertGroup('vertgroup', array('align' => 'center'));
     //$hui_vgroup->AddChild( new HuiLabel( 'titlelabel', array( 'label' => $amp_locale->GetStr( 'amprootlogin' ) ) ) );
     $hui_vgroup->AddChild($hui_grid);
     $hui_vgroup->AddChild(new HuiSubmit('submit', array('caption' => $amp_locale->GetStr('enter'))));
     $form_events_call = new HuiEventsCall();
     $form_events_call->AddEvent(new HuiEvent('login', 'login', ''));
     $form_events_call->AddEvent(new HuiEvent('main', 'default', ''));
     $hui_form = new HuiForm('form', array('action' => $form_events_call->GetEventsCallString()));
     $hui_hgroup = new HuiHorizGroup('horizgroup', array('align' => 'middle'));
     //        $hui_hgroup -> AddChild(new HuiButton('amplogo', array('image' => $hui_page -> mThemeHandler -> mStyle['middot'], 'action' => AMP_URL, 'highlight' => false)));
     $hui_hgroup->AddChild(new HuiButton('password', array('themeimage' => 'password', 'themeimagetype' => 'big', 'action' => AMP_URL, 'highlight' => false)));
     $hui_hgroup->AddChild($hui_vgroup);
     $hui_form->AddChild($hui_hgroup);
     $hui_mainframe->AddChild($hui_form);
     // Wrong account check
     //
     if ($wrong) {
         if ($gEnv['core']['config']->Value('ALERT_ON_WRONG_LOCAL_USER_LOGIN') == '1') {
             Carthag::import('com.solarix.ampoliros.security.SecurityLayer');
             global $login_disp;
             $event_data = $login_disp->GetEventData();
             $amp_security = new SecurityLayer();
             $amp_security->SendAlert('Wrong user local login for user ' . $event_data['username'] . ' from remote address ' . $_SERVER['REMOTE_ADDR']);
             $amp_security->LogFailedAccess($event_data['username'], false, $_SERVER['REMOTE_ADDR']);
             unset($amp_security);
         }
         $sleep_time = $gEnv['core']['config']->Value('WRONG_LOGIN_DELAY');
         if (!strlen($sleep_time)) {
             $sleep_time = 1;
         }
         $max_attempts = $gEnv['core']['config']->Value('MAX_WRONG_LOGINS');
         if (!strlen($max_attempts)) {
             $max_attempts = 3;
         }
         sleep($sleep_time);
         if (isset($_SESSION['site_login_attempts'])) {
             $_SESSION['site_login_attempts']++;
             if ($_SESSION['site_login_attempts'] >= $max_attempts) {
                 AmpDie($amp_locale->GetStr('wrongpwd'));
             }
         } else {
             $_SESSION['site_login_attempts'] = 1;
         }
         if ($reason) {
             $hui_mainstatus->mArgs['status'] = $amp_locale->GetStr($reason);
         } else {
             $hui_mainstatus->mArgs['status'] = $amp_locale->GetStr('wrongpwd');
         }
     } else {
         $_SESSION['site_login_attempts'] = 0;
     }
     // Page render
     //
     $hui_maingroup->AddChild($hui_titlebar);
     //$hui_maingroup->AddChild( new HuiButton( 'amplogo', array( 'image' => CGI_URL.'ampbigdot.gif', 'action' => AMP_URL ) ) );
     $hui_mainbframe->AddChild($hui_mainframe);
     $hui_mainbframe->AddChild(new HuiHorizBar('hb'));
     $hui_mainbframe->AddChild(new HuiLink('copyright', array('label' => $amp_locale->GetStr('auth_copyright.label'), 'link' => 'http://www.solarix.it/', 'target' => '_blank')));
     $hui_maingroup->AddChild($hui_mainbframe);
     $hui_maingroup->AddChild($hui_mainstatus);
     $hui_topgroup->AddChild($hui_maingroup);
     $hui_page->AddChild($hui_topgroup);
     $hui->AddChild($hui_page);
     $hui->Render();
     $carthag = Carthag::instance();
     $carthag->halt();
 }