Ejemplo n.º 1
0
function main_settings($eventData)
{
    global $gEnv, $gXml_def, $gLocale, $gPage_title;
    $amp_security = new SecurityLayer();
    $session_lifetime = $amp_security->GetSessionLifetime();
    $max_wrong_logins = $amp_security->GetMaxWrongLogins();
    $wrong_login_delay = $amp_security->GetWrongLoginDelay();
    $lock_unsecure_webservices = $amp_security->GetUnsecureWebServicesLock();
    $only_https_root = $amp_security->GetOnlyHttpsRootAccess();
    $only_https_site = $amp_security->GetOnlyHttpsSiteAccess();
    $alerts_on = $amp_security->GetAlertEvents();
    $wrong_local_root_login = $alerts_on['wronglocalrootlogin'] ? 'true' : 'false';
    $wrong_local_user_login = $alerts_on['wronglocaluserlogin'] ? 'true' : 'false';
    $wrong_remote_login = $alerts_on['wrongremotelogin'] ? 'true' : 'false';
    $module_operation = $alerts_on['moduleoperation'] ? 'true' : 'false';
    $sitemodule_operation = $alerts_on['modulesiteoperation'] ? 'true' : 'false';
    $site_operation = $alerts_on['siteoperation'] ? 'true' : 'false';
    $reports_interval = $amp_security->GetReportsInterval();
    $reports_enabled = $reports_interval ? 'true' : 'false';
    $report_destination_email = $amp_security->GetReportsEmail();
    $alert_destination_email = $amp_security->GetAlertsEmail();
    $tabs[0]['label'] = $gLocale->GetStr('security_presets.tab');
    $tabs[1]['label'] = $gLocale->GetStr('access_settings.tab');
    $tabs[2]['label'] = $gLocale->GetStr('alerts_settings.tab');
    $tabs[3]['label'] = $gLocale->GetStr('reports_settings.tab');
    $gXml_def = '<tab><name>security</name>
      <args>
        <tabs type="array">' . huixml_encode($tabs) . '</tabs>
        <tabactionfunction>settings_tab_builder</tabactionfunction>
        <activetab>' . (isset($eventData['tab']) ? $eventData['tab'] : '') . '</activetab>
      </args>
      <children>
    
        <vertgroup><name></name>
          <children>
    
            <table><name>presets</name>
              <args>
                <headers type="array">' . huixml_encode(array(0 => array('label' => $gLocale->GetStr('security_presets.label')))) . '</headers>
              </args>
              <children>
    
              <button row="0" col="0"><name>preset</name>
                <args>
                  <themeimage>decrypted</themeimage>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_low.label')) . '</label>
                  <horiz>true</horiz>
                  <frame>false</frame>
                  <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_security_preset', array('preset' => AMPOLIROS_SECURITY_PRESET_LOW))))) . '</action>
                </args>
              </button>
    
              <label row="0" col="1"><name>details</name>
                <args>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_low.text')) . '</label>
                  <nowrap>false</nowrap>
                </args>
              </label>
    
              <button row="1" col="0"><name>preset</name>
                <args>
                  <themeimage>encrypted</themeimage>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_normal.label')) . '</label>
                  <horiz>true</horiz>
                  <frame>false</frame>
                  <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_security_preset', array('preset' => AMPOLIROS_SECURITY_PRESET_NORMAL))))) . '</action>
                </args>
              </button>
    
              <label row="1" col="1"><name>details</name>
                <args>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_normal.text')) . '</label>
                  <nowrap>false</nowrap>
                </args>
              </label>
    
              <button row="2" col="0"><name>preset</name>
                <args>
                  <themeimage>encrypted</themeimage>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_high.label')) . '</label>
                  <horiz>true</horiz>
                  <frame>false</frame>
                  <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_security_preset', array('preset' => AMPOLIROS_SECURITY_PRESET_HIGH))))) . '</action>
                </args>
              </button>
    
              <label row="2" col="1"><name>details</name>
                <args>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_high.text')) . '</label>
                  <nowrap>false</nowrap>
                </args>
              </label>
    
              <button row="3" col="0"><name>preset</name>
                <args>
                  <themeimage>encrypted</themeimage>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_paranoid.label')) . '</label>
                  <horiz>true</horiz>
                  <frame>false</frame>
                  <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_security_preset', array('preset' => AMPOLIROS_SECURITY_PRESET_PARANOID))))) . '</action>
                </args>
              </button>
    
              <label row="3" col="1"><name>details</name>
                <args>
                  <label type="encoded">' . urlencode($gLocale->GetStr('level_paranoid.text')) . '</label>
                  <nowrap>false</nowrap>
                </args>
              </label>
    
              </children>
            </table>
    
          </children>
        </vertgroup>
    
        <vertgroup><name></name>
          <children>
    
            <table><name>access</name>
              <args>
                <headers type="array">' . huixml_encode(array(0 => array('label' => $gLocale->GetStr('access_settings.label')))) . '</headers>
              </args>
              <children>
    
                <form row="0" col="0"><name>access</name>
                  <args>
                    <method>post</method>
                    <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_access_prefs', '')))) . '</action>
                  </args>
                  <children>
                    <grid>
                      <children>
    
                        <label row="0" col="0"><name>sessionlifetime</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('session_lifetime.label')) . '</label>
                          </args>
                        </label>
    
                        <string row="0" col="1"><name>sessionlifetime</name>
                          <args>
                            <value>' . $session_lifetime . '</value>
                            <disp>action</disp>
                            <size>10</size>
                          </args>
                        </string>
    
                        <label row="1" col="0"><name>maxwronglogins</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('max_wrong_logins.label')) . '</label>
                          </args>
                        </label>
    
                        <string row="1" col="1"><name>maxwronglogins</name>
                          <args>
                            <value>' . $max_wrong_logins . '</value>
                            <disp>action</disp>
                            <size>4</size>
                          </args>
                        </string>
    
                        <label row="2" col="0"><name>wronglogindelay</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('wrong_login_delay.label')) . '</label>
                          </args>
                        </label>
    
                        <string row="2" col="1"><name>wronglogindelay</name>
                          <args>
                            <value>' . $wrong_login_delay . '</value>
                            <disp>action</disp>
                            <size>3</size>
                          </args>
                        </string>
    
                        <label row="3" col="0"><name>lockunsecurewebservices</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('block_unsecure_webservices.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="3" col="1"><name>lockunsecurewebservices</name>
                          <args>
                            <checked>' . ($lock_unsecure_webservices ? 'true' : 'false') . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="4" col="0"><name>onlyhttpsroot</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('only_https_root.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="4" col="1"><name>onlyhttpsroot</name>
                          <args>
                            <checked>' . ($only_https_root ? 'true' : 'false') . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="5" col="0"><name>onlyhttpssite</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('only_https_site.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="5" col="1"><name>onlyhttpssite</name>
                          <args>
                            <checked>' . ($only_https_site ? 'true' : 'false') . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                      </children>
                    </grid>
                  </children>
                </form>
    
                <button row="1" col="0"><name>apply</name>
                  <args>
                    <horiz>true</horiz>
                    <frame>false</frame>
                    <label type="encoded">' . urlencode($gLocale->GetStr('apply.submit')) . '</label>
                    <themeimage>button_ok</themeimage>
                    <formsubmit>access</formsubmit>
                    <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_access_prefs', '')))) . '</action>
                  </args>
                </button>
              </children>
            </table>
    
          </children>
        </vertgroup>
    
        <vertgroup><name></name>
          <children>
    
            <table><name>alerts</name>
              <args>
                <headers type="array">' . huixml_encode(array(0 => array('label' => $gLocale->GetStr('alerts_settings.label')))) . '</headers>
              </args>
              <children>
    
                <form row="0" col="0"><name>alerts</name>
                  <args>
                    <method>post</method>
                    <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_alerts_prefs', '')))) . '</action>
                  </args>
                  <children>
                    <grid>
                      <children>
    
                        <label row="0" col="0"><name>alertonevents</name>
                          <args>
                            <bold>true</bold>
                            <label type="encoded">' . urlencode($gLocale->GetStr('alert_on_events.label')) . '</label>
                          </args>
                        </label>
    
                        <label row="1" col="0"><name>wronglocalrootlogin</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('wrong_local_root_login.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="1" col="1"><name>wronglocalrootlogin</name>
                          <args>
                            <checked>' . $wrong_local_root_login . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="2" col="0"><name>wronglocaluserlogin</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('wrong_local_user_login.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="2" col="1"><name>wronglocaluserlogin</name>
                          <args>
                            <checked>' . $wrong_local_user_login . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="3" col="0"><name>wrongremotelogin</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('wrong_remote_login.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="3" col="1"><name>wrongremotelogin</name>
                          <args>
                            <checked>' . $wrong_remote_login . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="4" col="0"><name>moduleoperation</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('module_operation.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="4" col="1"><name>moduleoperation</name>
                          <args>
                            <checked>' . $module_operation . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="5" col="0"><name>sitemoduleoperation</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('sitemodule_operation.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="5" col="1"><name>sitemoduleoperation</name>
                          <args>
                            <checked>' . $sitemodule_operation . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="6" col="0"><name>siteoperation</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('site_operation.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="6" col="1"><name>siteoperation</name>
                          <args>
                            <checked>' . $site_operation . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="7" col="0"><name>alertdestinationemail</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('alert_destination_email.label')) . '</label>
                          </args>
                        </label>
    
                        <string row="7" col="1"><name>alertdestinationemail</name>
                          <args>
                            <value type="encoded">' . urlencode($alert_destination_email) . '</value>
                            <disp>action</disp>
                            <size>25</size>
                          </args>
                        </string>
    
                      </children>
                    </grid>
                  </children>
                </form>
    
                <button row="1" col="0"><name>apply</name>
                  <args>
                    <horiz>true</horiz>
                    <frame>false</frame>
                    <label type="encoded">' . urlencode($gLocale->GetStr('apply.submit')) . '</label>
                    <themeimage>button_ok</themeimage>
                    <formsubmit>alerts</formsubmit>
                    <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_alerts_prefs', '')))) . '</action>
                  </args>
                </button>
              </children>
            </table>
    
          </children>
        </vertgroup>
    
        <vertgroup><name></name>
          <children>
    
            <table><name>alerts</name>
              <args>
                <headers type="array">' . huixml_encode(array(0 => array('label' => $gLocale->GetStr('reports_settings.label')))) . '</headers>
              </args>
              <children>
    
                <form row="0" col="0"><name>alerts</name>
                  <args>
                    <method>post</method>
                    <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_reports_prefs', '')))) . '</action>
                  </args>
                  <children>
                    <grid>
                      <children>
    
                        <label row="0" col="0"><name>enablereports</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('enable_reports.label')) . '</label>
                          </args>
                        </label>
    
                        <checkbox row="0" col="1"><name>enablereports</name>
                          <args>
                            <checked>' . $reports_enabled . '</checked>
                            <disp>action</disp>
                          </args>
                        </checkbox>
    
                        <label row="1" col="0"><name>reportsinterval</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('reports_interval.label')) . '</label>
                          </args>
                        </label>
    
                        <string row="1" col="1"><name>reportsinterval</name>
                          <args>
                            <value>' . $reports_interval . '</value>
                            <disp>action</disp>
                            <size>3</size>
                          </args>
                        </string>
    
                        <label row="2" col="0"><name>reportdestinationemail</name>
                          <args>
                            <label type="encoded">' . urlencode($gLocale->GetStr('report_destination_email.label')) . '</label>
                          </args>
                        </label>
    
                        <string row="2" col="1"><name>reportdestinationemail</name>
                          <args>
                            <value type="encoded">' . urlencode($report_destination_email) . '</value>
                            <disp>action</disp>
                            <size>25</size>
                          </args>
                        </string>
    
                      </children>
                    </grid>
                  </children>
                </form>
    
                <button row="1" col="0"><name>apply</name>
                  <args>
                    <horiz>true</horiz>
                    <frame>false</frame>
                    <label type="encoded">' . urlencode($gLocale->GetStr('apply.submit')) . '</label>
                    <themeimage>button_ok</themeimage>
                    <formsubmit>alerts</formsubmit>
                    <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'settings', ''), array('action', 'set_reports_prefs', '')))) . '</action>
                  </args>
                </button>
              </children>
            </table>
    
          </children>
        </vertgroup>
    
      </children>
    </tab>';
    $gPage_title .= ' - ' . $gLocale->GetStr('settings.title');
}
Ejemplo n.º 2
0
 public function bootstrap($configuration)
 {
     if (!$this->bootstrapped) {
         import('com.solarix.ampoliros.core.AmpConfig');
         import('carthag.core.Registry');
         $registry = Registry::instance();
         $amp_cfg = new AmpConfig($configuration);
         $registry->setEntry('amp.config', $amp_cfg);
         // Ampoliros 3000 style environment variable. Usage is deprecated.
         $gEnv = array();
         $GLOBALS['gEnv'] =& $gEnv;
         $GLOBALS['gEnv']['runtime']['bootstrap'] = 0;
         // ****************************************************************************
         // Ampoliros filesystem and urls
         // ****************************************************************************
         // Trees
         define('PUBLIC_TREE', $amp_cfg->getKey('PUBLIC_TREE'));
         define('PRIVATE_TREE', $amp_cfg->getKey('PRIVATE_TREE'));
         define('SITES_TREE', $amp_cfg->getKey('SITES_TREE'));
         define('ADMIN_PATH', PUBLIC_TREE . 'admin/');
         define('AMP_PATH', PUBLIC_TREE . 'root/');
         define('CGI_PATH', PUBLIC_TREE . 'cgi/');
         define('CONFIG_PATH', PRIVATE_TREE . 'etc/');
         define('HANDLER_PATH', PRIVATE_TREE . 'var/handlers/');
         define('INITDB_PATH', PRIVATE_TREE . 'var/db/');
         define('LIBRARY_PATH', PRIVATE_TREE . 'var/lib/');
         define('MODULE_PATH', PRIVATE_TREE . 'var/modules/');
         define('SITESTUFF_PATH', PRIVATE_TREE . 'var/sites/');
         define('TMP_PATH', PRIVATE_TREE . 'tmp/');
         // Urls
         define('AMP_HOST', $amp_cfg->Value('AMP_HOST'));
         define('AMP_URL', $amp_cfg->Value('AMP_URL'));
         define('AMP_ROOTURL', $amp_cfg->Value('AMP_ROOTURL'));
         define('ADMIN_URL', $amp_cfg->Value('ADMIN_URL'));
         define('CGI_URL', $amp_cfg->Value('CGI_URL'));
         // ****************************************************************************
         // Environment
         // ****************************************************************************
         // PHP
         if (strlen($amp_cfg->Value('PHP_MEMORY_LIMIT'))) {
             $gEnv['core']['php']['memorylimit'] = $amp_cfg->Value('PHP_MEMORY_LIMIT');
         } else {
             $gEnv['core']['php']['memorylimit'] = '64M';
         }
         ini_set('memory_limit', $gEnv['core']['php']['memorylimit']);
         if (strlen($amp_cfg->Value('PHP_EXECUTION_TIME_LIMIT'))) {
             $gEnv['core']['php']['timelimit'] = $amp_cfg->Value('PHP_EXECUTION_TIME_LIMIT');
         } else {
             $gEnv['core']['php']['timelimit'] = 0;
         }
         set_time_limit($gEnv['core']['php']['timelimit']);
         ignore_user_abort(TRUE);
         set_magic_quotes_runtime(0);
         // ****************************************************************************
         // Ampoliros state, mode, interface and edition
         // ****************************************************************************
         // Defines
         define('AMP_SETUP_LOCK', TMP_PATH . '.setup');
         define('AMP_UPGRADINGSYSTEM_LOCK', TMP_PATH . '.upgrading_system');
         // Wait until system is in upgrade phase
         if (!defined('AMPOLIROS_OVERRIDE_LOCK')) {
             while (file_exists(AMP_UPGRADINGSYSTEM_LOCK)) {
                 $this->state = Ampoliros::STATE_UPGRADE;
                 clearstatcache();
                 sleep(1);
             }
         }
         // Check if system is in setup phase and set the state
         if (file_exists(AMP_SETUP_LOCK)) {
             define('AMPOLIROS_SETUP_PHASE', TRUE);
             $this->state = Ampoliros::STATE_SETUP;
             if (extension_loaded('APD')) {
                 apd_set_session_trace(35);
             }
         } else {
             switch ($amp_cfg->Value('AMP_STATE')) {
                 case 'debug':
                     $this->state = Ampoliros::STATE_DEBUG;
                     if (extension_loaded('APD')) {
                         apd_set_session_trace(35);
                     }
                     break;
                 case 'development':
                     $this->state = Ampoliros::STATE_DEVELOPMENT;
                     break;
                 case 'production':
                     $this->state = Ampoliros::STATE_PRODUCTION;
                     break;
                 default:
                     if ($amp_cfg->Value('DEBUG') == '1') {
                         $this->state = Ampoliros::STATE_DEBUG;
                         define('DEBUG', true);
                     } else {
                         $this->state = Ampoliros::STATE_PRODUCTION;
                     }
             }
         }
         // Interface
         $this->interface = Ampoliros::INTERFACE_UNKNOWN;
         // Mode
         $this->mode = Ampoliros::MODE_ROOT;
         // Edition
         if ($amp_cfg->Value('AMP_EDITION') == 'enterprise') {
             $this->edition = Ampoliros::EDITION_ENTERPRISE;
         } else {
             $this->edition = Ampoliros::EDITION_ASP;
         }
         // ****************************************************************************
         // Pid and shutdown function
         // ****************************************************************************
         if ($this->state != Ampoliros::STATE_SETUP) {
             $this->pid = md5(microtime());
             touch(TMP_PATH . 'pids/' . $this->pid, time());
             register_shutdown_function(array($this, 'shutdown'));
         }
         // ****************************************************************************
         // Session
         // ****************************************************************************
         // This must be before session_start
         if (strlen($amp_cfg->Value('SESSION_LIFETIME'))) {
             $gEnv['core']['session']['lifetime'] = $amp_cfg->Value('SESSION_LIFETIME') * 60;
         } else {
             $gEnv['core']['session']['lifetime'] = 1440 * 60 * 365;
         }
         // A year
         ini_set('session.gc_maxlifetime', $gEnv['core']['session']['lifetime']);
         ini_set('session.cookie_lifetime', $gEnv['core']['session']['lifetime']);
         // Start output buffer handler
         if ($amp_cfg->Value('AMP_COMPRESSED_OB') == '1') {
             define('AMP_COMPRESSED_OB', TRUE);
         } else {
             define('AMP_COMPRESSED_OB', FALSE);
         }
         if (!headers_sent()) {
             if (AMP_COMPRESSED_OB) {
                 ob_start('ob_gzhandler');
             }
             if ($this->state != Ampoliros::STATE_SETUP) {
                 ini_set('session.save_path', TMP_PATH . 'phpsessions/');
             }
             session_start();
         }
         $gEnv['runtime']['sessionid'] = session_id();
         // ****************************************************************************
         // Ampoliros network
         // ****************************************************************************
         define('AMP_NAME', $amp_cfg->Value('AMP_NAME'));
         $gEnv['core']['network']['name'] = AMP_NAME;
         define('AMP_DOMAIN', $amp_cfg->Value('AMP_DOMAIN'));
         $gEnv['core']['network']['domain'] = AMP_DOMAIN;
         define('AMP_DNS', $amp_cfg->Value('AMP_DNS'));
         $gEnv['core']['network']['dns'] = AMP_DNS;
         // ****************************************************************************
         // Ampoliros error handler
         // ****************************************************************************
         if ($this->state != Ampoliros::STATE_SETUP) {
             define('PHP_LOG', $amp_cfg->getKey('PRIVATE_TREE') . 'var/log/php.log');
         } else {
             define('PHP_LOG', $amp_cfg->getKey('PRIVATE_TREE') . 'var/log/amp.log');
         }
         $gEnv['core']['error']['log'] = PHP_LOG;
         set_error_handler(array($this, 'errorHandler'));
         // ****************************************************************************
         // Ampoliros root
         // ****************************************************************************
         define('AMP_COUNTRY', $amp_cfg->Value('AMP_COUNTRY'));
         $gEnv['root']['locale']['country'] = AMP_COUNTRY;
         define('AMP_LANG', $amp_cfg->Value('AMP_LANG'));
         $gEnv['root']['locale']['language'] = AMP_LANG;
         define('AMP_LOG', $amp_cfg->getKey('PRIVATE_TREE') . 'var/log/amp.log');
         $gEnv['root']['log'] = AMP_LOG;
         import('com.solarix.ampoliros.db.DBLayerFactory');
         define('AMP_DBTYPE', $amp_cfg->Value('AMP_DBTYPE'));
         define('AMP_DBNAME', $amp_cfg->Value('AMP_DBNAME'));
         define('AMP_DBHOST', $amp_cfg->Value('AMP_DBHOST'));
         define('AMP_DBPORT', $amp_cfg->Value('AMP_DBPORT'));
         define('AMP_DBUSER', $amp_cfg->Value('AMP_DBUSER'));
         define('AMP_DBPASS', $amp_cfg->Value('AMP_DBPASS'));
         define('AMP_DBLOG', $amp_cfg->getKey('PRIVATE_TREE') . 'var/log/ampdb.log');
         $gEnv['root']['dblog'] = AMP_DBLOG;
         if ($amp_cfg->Value('AMP_DBDEBUG') == '1') {
             define('AMP_DBDEBUG', true);
         }
         if ($this->state != Ampoliros::STATE_SETUP) {
             // Ampoliros central database
             //
             $amp_db_args = array();
             $amp_db_args['dbtype'] = AMP_DBTYPE;
             $amp_db_args['dbname'] = AMP_DBNAME;
             $amp_db_args['dbhost'] = AMP_DBHOST;
             $amp_db_args['dbport'] = AMP_DBPORT;
             $amp_db_args['dbuser'] = AMP_DBUSER;
             $amp_db_args['dbpass'] = AMP_DBPASS;
             $amp_db_args['dblog'] = AMP_DBLOG;
             $db_fact = new DBLayerFactory();
             $amp_db = $db_fact->NewDbLayer($amp_db_args);
             if (!$amp_db->Connect($amp_db_args)) {
                 $this->abort('Database not connected', Ampoliros::INTERFACE_CONSOLE);
             }
             unset($amp_db_args);
             $registry->setEntry('amp.root.db', $amp_db);
         }
         // ****************************************************************************
         // Ampoliros remote
         // ****************************************************************************
         define('AMP_REMOTE_LOG', $amp_cfg->getKey('PRIVATE_TREE') . 'var/log/remote.log');
         $gEnv['remote']['log'] = AMP_REMOTE_LOG;
         // ****************************************************************************
         // Run time state and interface defined data
         // ****************************************************************************
         // Debugger
         if ($this->state == Ampoliros::STATE_DEBUG) {
             import('carthag.dev.LoadTime');
             $loadtimer = new LoadTime(LoadTime::LOADTIME_MODE_CONTINUOUS);
             $registry->setEntry('amp.loadtime', $loadtimer);
             $loadtimer->Mark('start');
             $dbloadtimer = new LoadTime(LoadTime::LOADTIME_MODE_STARTSTOP);
             $registry->setEntry('amp.dbloadtime', $dbloadtimer);
         }
         $gEnv['runtime']['disp'] = $this->array_merge_clobber($this->array_merge_clobber($_GET, $_POST), $_FILES);
         // Interface settings
         if ($amp_cfg->Value('AMP_HUI_COMMENTS') == '1' or $this->state == Ampoliros::STATE_DEBUG) {
             define('AMP_HUI_COMMENTS', TRUE);
         } else {
             define('AMP_HUI_COMMENTS', FALSE);
         }
         $gEnv['hui']['theme']['default'] = 'amp4000';
         define('ROOTCRONTAB', $amp_cfg->Value('ROOTCRONTAB'));
         // Security
         $security_reports_interval = $amp_cfg->Value('SECURITY_REPORTS_INTERVAL');
         if ($security_reports_interval > 0) {
             $last_security_report = $amp_cfg->Value('LAST_SECURITY_REPORT');
             if (!$last_security_report or $last_security_report < time() - $security_reports_interval * 3600 * 24) {
                 import('com.solarix.ampoliros.security.SecurityLayer');
                 $amp_security = new SecurityLayer();
                 $amp_security->SendReport();
                 unset($amp_security);
             }
         }
         unset($security_reports_interval);
         // Maintenance
         $maintenance_interval = $amp_cfg->Value('MAINTENANCE_INTERVAL');
         if ($this->state != Ampoliros::STATE_MAINTENANCE and $maintenance_interval > 0) {
             $last_maintenance = $amp_cfg->Value('LAST_MAINTENANCE');
             if (!$last_maintenance or $last_maintenance < time() - $maintenance_interval * 3600 * 24) {
                 import('com.solarix.ampoliros.maintenance.AmpolirosMaintenanceHandler');
                 $amp_maintenance = new AmpolirosMaintenanceHandler();
                 $amp_maintenance->DoMaintenance();
                 $amp_maintenance->SendReport();
                 unset($amp_maintenance);
             }
         }
         unset($maintenance_interval);
         // ****************************************************************************
         // Backward compatibility
         // ****************************************************************************
         $gEnv['core']['config'] = $amp_cfg;
         // Web server
         define('HTTPD_GROUP', $amp_cfg->Value('HTTPD_GROUP'));
         define('HTTPD_USER', $amp_cfg->Value('HTTPD_USER'));
         $gEnv['core']['webserver']['group'] = HTTPD_GROUP;
         $gEnv['core']['webserver']['user'] = HTTPD_USER;
         // Ampoliros 2000 style environment variable. Usage is deprecated.
         global $env;
         $env = array();
         $env['ampcfg'] = $gEnv['core']['config'];
         $env['amplocale'] = AMP_LANG;
         $env['disp'] =& $gEnv['runtime']['disp'];
         // OOPHtml
         $env['defaultcss'] = 'default.css';
         $gEnv['runtime']['pid'] = $this->pid;
         define('AMP_STATE_SETUP', Ampoliros::STATE_SETUP);
         define('AMP_STATE_DEVELOPMENT', Ampoliros::STATE_DEVELOPMENT);
         define('AMP_STATE_DEBUG', Ampoliros::STATE_DEBUG);
         define('AMP_STATE_PRODUCTION', Ampoliros::STATE_PRODUCTION);
         define('AMP_STATE_UPGRADE', Ampoliros::STATE_UPGRADE);
         define('AMP_STATE_MAINTENANCE', Ampoliros::STATE_MAINTENANCE);
         define('AMP_INTERFACE_UNKNOWN', Ampoliros::INTERFACE_UNKNOWN);
         define('AMP_INTERFACE_CONSOLE', Ampoliros::INTERFACE_CONSOLE);
         define('AMP_INTERFACE_WEB', Ampoliros::INTERFACE_WEB);
         define('AMP_INTERFACE_REMOTE', Ampoliros::INTERFACE_REMOTE);
         define('AMP_INTERFACE_GUI', Ampoliros::INTERFACE_GUI);
         define('AMP_INTERFACE_EXTERNAL', Ampoliros::INTERFACE_EXTERNAL);
         define('AMP_MODE_ROOT', Ampoliros::MODE_ROOT);
         define('AMP_MODE_SITE', Ampoliros::MODE_SITE);
         define('AMP_EDITION_ASP', Ampoliros::EDITION_ASP);
         define('AMP_EDITION_ENTERPRISE', Ampoliros::EDITION_ENTERPRISE);
         define('STORESTUFF_PATH', PRIVATE_TREE . 'var/sites/');
         define('LOG_PATH', PRIVATE_TREE . 'var/log/');
         define('CATALOG_PATH', PRIVATE_TREE . 'var/locale/');
         define('BIN_PATH', PRIVATE_TREE . 'var/bin/');
         define('HELP_PATH', PRIVATE_TREE . 'var/help/');
         $gEnv['core']['filesystem']['public'] = PUBLIC_TREE;
         $gEnv['core']['filesystem']['private'] = PRIVATE_TREE;
         $gEnv['core']['filesystem']['sites'] = SITES_TREE;
         $gEnv['core']['state'] = $this->state;
         $gEnv['core']['mode'] = $this->mode;
         $gEnv['core']['interface'] = $this->interface;
         $gEnv['root']['db'] = $amp_db;
         $env['ampdb'] = $gEnv['root']['db'];
         $gEnv['runtime']['modules'] = array();
         $gEnv['runtime']['debug']['loadtime'] = $loadtimer;
         $env['debug']['loadtime'] = $gEnv['runtime']['debug']['loadtime'];
         $gEnv['runtime']['debug']['dbloadtime'] = $dbloadtimer;
         $env['hui'] =& $gEnv['hui'];
         $gEnv['core']['edition'] = $this->edition;
         // ****************************************************************************
         // Auto exec routines
         // ****************************************************************************
         // Module reupdate check
         if (file_exists(TMP_PATH . 'modinst/reupdate')) {
             import('com.solarix.ampoliros.module.Module');
             $tmp_mod = new Module($amp_db, '');
             $tmp_mod->Install(TMP_PATH . 'modinst/reupdate');
             clearstatcache();
             if (file_exists(TMP_PATH . 'modinst/reupdate')) {
                 unlink(TMP_PATH . 'modinst/reupdate');
             }
         }
         // Startup hook
         if ($this->state != Ampoliros::STATE_SETUP) {
             import('com.solarix.ampoliros.util.Hook');
             $hook = new Hook($amp_db, 'ampoliros', 'instance');
             switch ($hook->CallHooks('startup', $null, '')) {
                 case Hook::RESULT_ABORT:
                     $this->abort('Bootstrap aborted', Ampoliros::INTERFACE_CONSOLE);
                     break;
             }
         }
         // Bootstrap end
         $this->bootstrapped = true;
         $GLOBALS['gEnv']['runtime']['bootstrap'] = $this->bootstrapped;
     }
 }
Ejemplo n.º 3
0
 function Disable($siteid)
 {
     $result = FALSE;
     import('com.solarix.ampoliros.util.Hook');
     $hook = new Hook($this->ampdb, 'ampoliros', 'module.disable');
     if ($hook->CallHooks('calltime', $this, array('siteserial' => $siteid, 'modserial' => $this->serial)) == HOOK_RESULT_OK) {
         if ($this->serial) {
             // Checks if the module exists in modules table
             //
             $modquery =& $this->ampdb->Execute('SELECT * FROM modules WHERE id=' . (int) $this->serial);
             if ($modquery->NumRows() == 1) {
                 $moddata = $modquery->Fields();
                 if ($moddata['onlyextension'] != $this->ampdb->fmttrue) {
                     // Checks if the structure file still exists
                     //
                     if (file_exists(MODULE_PATH . $moddata['modid'] . '/' . Module::STRUCTURE_FILE)) {
                         $this->modname = $moddata['modid'];
                         $sitequery = $this->ampdb->Execute('SELECT * FROM sites WHERE id=' . $this->ampdb->Format_Text((int) $siteid));
                         $sitedata = $sitequery->Fields();
                         $args['dbtype'] = $sitedata['sitedbtype'];
                         $args['dbname'] = $sitedata['sitedbname'];
                         $args['dbhost'] = $sitedata['sitedbhost'];
                         $args['dbport'] = $sitedata['sitedbport'];
                         $args['dbuser'] = $sitedata['sitedbuser'];
                         $args['dbpass'] = $sitedata['sitedbpassword'];
                         $args['dblog'] = $sitedata['sitedblog'];
                         import('com.solarix.ampoliros.db.DBLayerFactory');
                         $db_fact = new DBLayerFactory();
                         $this->sitedb = $db_fact->NewDBLayer($args);
                         $this->sitedb->Connect($args);
                         // Dependencies check
                         //
                         $this->unmetdeps = array();
                         $this->unmetsuggs = array();
                         $moddeps = new ModuleDep($this->ampdb);
                         $pendingdeps = $moddeps->CheckSiteDependingModules($this->modname, $sitedata['siteid'], FALSE);
                         $modenabled = $moddeps->IsEnabled($this->modname, $sitedata['siteid']);
                         // If dependencies are ok, go on
                         //
                         if ($pendingdeps == FALSE and $modenabled == TRUE) {
                             $result = $this->HandleStructure(MODULE_PATH . $moddata['modid'] . '/' . Module::STRUCTURE_FILE, Module::INSTALL_MODE_DISABLE, MODULE_PATH . $moddata['modid'] . '/', $siteid);
                             $modquery = $this->ampdb->Execute('SELECT id FROM modules WHERE modid=' . $this->ampdb->Format_Text($this->modname));
                             $this->ampdb->Execute('DELETE FROM activemodules WHERE moduleid=' . (int) $this->serial . ' AND siteid=' . $this->ampdb->Format_Text($siteid));
                             $this->ampdb->Execute('DELETE FROM disabledsubmodules WHERE moduleid=' . (int) $this->serial . ' AND siteid=' . (int) $siteid);
                             if ($GLOBALS['gEnv']['core']['config']->Value('ALERT_ON_MODULE_SITE_OPERATION') == '1') {
                                 Carthag::import('com.solarix.ampoliros.security.SecurityLayer');
                                 $amp_security = new SecurityLayer();
                                 $amp_security->SendAlert('Module ' . $moddata['modid'] . ' has been disabled from site ' . $sitedata['siteid']);
                                 unset($amp_security);
                             }
                             if ($hook->CallHooks('moduledisabled', $this, array('siteserial' => $siteid, 'modserial' => $this->serial)) != HOOK_RESULT_OK) {
                                 $result = false;
                             }
                         } else {
                             if ($modenabled == FALSE) {
                             } else {
                                 $this->unmetdeps = $pendingdeps;
                             }
                         }
                         //if ( $result == TRUE ) $this->mLog->LogEvent( 'Ampoliros', 'Uninstalled module '.$this->modname, LOGGER_NOTICE );
                         $sitequery->Free();
                     } else {
                         import('com.solarix.ampoliros.io.log.Logger');
                         $log = new Logger(AMP_LOG);
                         $log->LogEvent('ampoliros.modules_library.modules_class.disable', 'Structure file ' . MODULE_PATH . $moddata['modid'] . '/' . Module::STRUCTURE_FILE . ' for module ' . $moddata['modid'] . ' was not found', LOGGER_ERROR);
                     }
                 } else {
                     import('com.solarix.ampoliros.io.log.Logger');
                     $log = new Logger(AMP_LOG);
                     $log->LogEvent('ampoliros.modules_library.modules_class.disable', 'Tried to disable module ' . $moddata['modid'] . ', but it is an extension only module', LOGGER_ERROR);
                 }
             } else {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger(AMP_LOG);
                 $log->LogEvent('ampoliros.modules_library.modules_class.disable', 'A module with serial ' . $this->serial . ' was not found in modules table', LOGGER_ERROR);
             }
             $modquery->Free();
         } else {
             import('com.solarix.ampoliros.io.log.Logger');
             $log = new Logger(AMP_LOG);
             $log->LogEvent('ampoliros.modules_library.modules_class.disable', 'Empty module serial', LOGGER_ERROR);
         }
     }
     return $result;
 }
Ejemplo n.º 4
0
 function login_logout($eventData)
 {
     Carthag::import('com.solarix.ampoliros.security.SecurityLayer');
     $amp_security = new SecurityLayer();
     $amp_security->LogAccess($_SESSION['AMP_AUTH_USER'], true, false, $_SERVER['REMOTE_ADDR']);
     session_unregister('AMP_AUTH_USER');
     unset($_SESSION['AMP_AUTH_USER']);
     unset($amp_security);
     DoAuth();
 }
Ejemplo n.º 5
0
    define('AMPREMOTE_PHP', true);
    require 'ampoliros.php';
    $amp = Ampoliros::instance('Ampoliros');
    $amp->setMode(Ampoliros::MODE_ROOT);
    $amp->setInterface(Ampoliros::INTERFACE_REMOTE);
    OpenLibrary('xmlrpc.library');
    OpenLibrary('misc.library');
    $env['db'] = $GLOBALS['gEnv']['root']['db'];
    $GLOBALS['gEnv']['remote']['methods'] = array();
    $xuser = new XmlRpcUser($GLOBALS['gEnv']['root']['db']);
    if ($xuser->SetByAccount($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])) {
        $GLOBALS['gEnv']['remote']['user'] = $_SERVER['PHP_AUTH_USER'];
        $GLOBALS['gEnv']['remote']['profile'] = $xuser->mProfileId;
        if ($xuser->mSiteId) {
            $site_query = $GLOBALS['gEnv']['root']['db']->Execute('SELECT siteid FROM sites WHERE id=' . $xuser->mSiteId);
            if ($site_query->NumRows()) {
                $amp = Ampoliros::instance('Ampoliros');
                $amp->startSite($site_query->Fields('siteid'));
            }
        }
        $xprofile = new XmlRpcProfile($GLOBALS['gEnv']['root']['db'], $GLOBALS['gEnv']['remote']['profile']);
        $GLOBALS['gEnv']['remote']['methods'] = $xprofile->AvailableMethods();
    } else {
        if ($GLOBALS['gEnv']['core']['config']->Value('ALERT_ON_WRONG_REMOTE_LOGIN') == '1') {
            import('com.solarix.ampoliros.security.SecurityLayer');
            $amp_security = new SecurityLayer();
            $amp_security->SendAlert('Wrong remote login for user ' . $_SERVER['PHP_AUTH_USER'] . ' from remote address ' . $_SERVER['REMOTE_ADDR']);
            unset($amp_security);
        }
    }
}
Ejemplo n.º 6
0
 public function remove()
 {
     $result = false;
     $hook = new Hook($this->ampdb, 'ampoliros', 'site.remove');
     if ($hook->CallHooks('calltime', $this, '') == HOOK_RESULT_OK) {
         $query = $this->ampdb->Execute('SELECT * ' . 'FROM sites ' . 'WHERE id=' . (int) $this->siteserial);
         $data = $query->Fields();
         // Disables all modules
         //
         $this->DisableAllModules($this->siteserial);
         $args['dbname'] = $data['sitedbname'];
         $args['dbhost'] = $data['sitedbhost'];
         $args['dbport'] = $data['sitedbport'];
         $args['dbuser'] = $data['sitedbuser'];
         $args['dbpass'] = $data['sitedbpass'];
         $args['dbtype'] = $data['sitedbtype'];
         $args['dblog'] = $data['sitedblog'];
         $this->sitedb->Close();
         $this->sitedb->DropDB($args);
         // Remove cached items
         //
         Carthag::import('com.solarix.ampoliros.datatransfer.cache.CacheGarbageCollector');
         $cache_gc = new CacheGarbageCollector();
         $cache_gc->RemoveSiteItems((int) $data['id']);
         // Removes site users
         //
         $this->RemoveAllUsers();
         // Removes site from amp database
         //
         $this->ampdb->Execute('DELETE FROM sites ' . 'WHERE id=' . (int) $data['id']);
         $this->ampdb->Execute('DELETE FROM disabledsubmodules ' . 'WHERE siteid=' . $this->siteserial);
         import('com.solarix.ampoliros.io.log.Logger');
         $log = new Logger(AMP_LOG);
         $log->LogEvent($data['siteid'], 'Removed site ' . $data['siteid'], LOGGER_NOTICE);
         if (!empty($data['siteid'])) {
             RecRemoveDir(SITESTUFF_PATH . $data['siteid']);
         }
         if ($hook->CallHooks('siteremoved', $this, '') == HOOK_RESULT_OK) {
             $result = true;
         }
         global $gEnv;
         if ($gEnv['core']['config']->Value('ALERT_ON_SITE_OPERATION') == '1') {
             Carthag::import('com.solarix.ampoliros.security.SecurityLayer');
             $amp_security = new SecurityLayer();
             $amp_security->SendAlert('Site ' . $data['siteid'] . ' has been removed');
             unset($amp_security);
         }
     }
     return $result;
 }