Esempio n. 1
0
 function CallHooks($event, &$obj, $args = '')
 {
     $result = false;
     if ($this->mAmpDb) {
         $query = $this->mAmpDb->Execute('SELECT * FROM hooks WHERE functionmodule=' . $this->mAmpDb->Format_Text($this->mModule) . ' AND function=' . $this->mAmpDb->Format_Text($this->mFunction) . ' AND event=' . $this->mAmpDb->Format_Text($event));
         if ($query) {
             global $gEnv;
             $result = HOOK_RESULT_OK;
             import('com.solarix.ampoliros.core.Ampoliros');
             $amp = Ampoliros::instance('Ampoliros');
             while (!$query->eof) {
                 $data = $query->Fields();
                 if ($amp->getState() == Ampoliros::STATE_DEBUG) {
                     $gEnv['runtime']['debug']['hooks'][$this->mModule . '::' . $this->mFunction . '::' . $event][] = $data['hookhandler'] . ' - ' . $data['hookfunction'];
                 }
                 OpenLibrary($data['hookhandler'], HANDLER_PATH);
                 $func_result = $data['hookfunction']($obj, $args);
                 if ($func_result == HOOK_RESULT_ABORT) {
                     $result = HOOK_RESULT_ABORT;
                 }
                 $query->MoveNext();
             }
         }
     }
     return $result;
 }
Esempio n. 2
0
 function main($args)
 {
     include 'ampconfigpath.php';
     import('com.solarix.ampoliros.core.Ampoliros');
     $amp = Ampoliros::instance('Ampoliros');
     $amp->bootstrap(AMP_CONFIG);
 }
Esempio n. 3
0
 public function isCurrentPid()
 {
     import('com.solarix.ampoliros.core.Ampoliros');
     $amp = Ampoliros::instance('Ampoliros');
     if ($this->mPid == $amp->getPid()) {
         return true;
     } else {
         return false;
     }
 }
 public static function getAuthHelper()
 {
     $amp = Ampoliros::instance('Ampoliros');
     switch ($amp->getMode()) {
         case Ampoliros::MODE_ROOT:
             import('com.solarix.ampoliros.hui.helpers.HuiRootAuthHelper');
             return new HuiRootAuthHelper();
             break;
         case Ampoliros::MODE_SITE:
             import('com.solarix.ampoliros.hui.helpers.HuiSiteAuthHelper');
             return new HuiSiteAuthHelper();
             break;
         default:
             return null;
     }
 }
 public static function validate()
 {
     static $validated = false;
     if (!${$validated}) {
         import('com.solarix.ampoliros.core.Ampoliros');
         $amp = Ampoliros::instance('Ampoliros');
         if ($amp->getState() != Ampoliros::STATE_SETUP) {
             $validators_query = $GLOBALS['gEnv']['root']['db']->Execute('SELECT file FROM huivalidators');
             if ($validators_query) {
                 global $gEnv;
                 // For compatibility with old validators
                 while (!$validators_query->eof) {
                     if (file_exists(HANDLER_PATH . $validators_query->Fields('file'))) {
                         include_once HANDLER_PATH . $validators_query->Fields('file');
                     }
                     $validators_query->MoveNext();
                 }
             }
             $validators_query->free();
             $validated = true;
         }
     }
 }
Esempio n. 6
0
function OpenLibrary($libraryFile, $libraryPath = LIBRARY_PATH)
{
    $result = FALSE;
    global $gEnv;
    $library_define = strtoupper($libraryFile);
    $library_define = strtr($library_define, '.', '_');
    if (substr($libraryPath, strlen($libraryPath) - 1) != '/') {
        $libraryPath .= '/';
    }
    if (!defined($library_define)) {
        $amp = Ampoliros::instance('Ampoliros');
        if ($amp->getState() == Ampoliros::STATE_DEBUG & isset($gEnv['runtime']['debug']['loadtime'])) {
            $gEnv['runtime']['debug']['loadtime']->Mark('start - OpenLibrary() for ' . $libraryFile);
        }
        //if ( file_exists( $libraryPath.$libraryFile ) )
        if (include $libraryPath . $libraryFile) {
            $gEnv['runtime']['libraries'][$library_define] = $libraryFile;
            /*
            while( list( $key, $val ) = each( $GLOBALS ) )
            {
            global $$key;
            //$$key = &$GLOBALS[$key];
            }
            */
            //include( $libraryPath.$libraryFile );
            $result = TRUE;
        } else {
            if (!defined('LOGGER_LIBRARY')) {
                if (file_exists(LIBRARY_PATH . 'logger.library')) {
                    import('com.solarix.ampoliros.io.log.Logger');
                    $tmp_log = new Logger(AMP_LOG);
                    $tmp_log->LogEvent('ampoliros.openlibrary', 'Library file ' . $libraryPath . $libraryFile . ' does not exists', LOGGER_ERROR);
                }
            }
        }
        if ($amp->getState() == Ampoliros::STATE_DEBUG & isset($gEnv['runtime']['debug']['loadtime'])) {
            $gEnv['runtime']['debug']['loadtime']->Mark('end - OpenLibrary() for ' . $libraryFile);
        }
    } else {
        $result = TRUE;
    }
    // Already opened, but return TRUE.
    return $result;
}
Esempio n. 7
0
 public function testGetInstance()
 {
     $amp = Ampoliros::instance('Ampoliros');
     Assert::assertTrue($amp instanceof Ampoliros);
 }
Esempio n. 8
0
 function init_amp_root($userId = 'amp')
 {
     $amp = Ampoliros::instance('Ampoliros');
     $amp->startRoot($userId);
 }
Esempio n. 9
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;
 }
Esempio n. 10
0
 function init_amp_site_by_md5id($md5Id, $userId = '')
 {
     $amp = Ampoliros::instance('Ampoliros');
     return $amp->startSiteByMd5Id($md5Id, $userId);
 }
Esempio n. 11
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();
 }
Esempio n. 12
0
 function DBLayer($params)
 {
     $this->dblog = $params['dblog'];
     import('com.solarix.ampoliros.core.Ampoliros');
     $this->amp = Ampoliros::instance('Ampoliros');
 }
Esempio n. 13
0
function main_debug($eventData)
{
    global $gEnv, $gLocale, $gPage_content;
    $amp = Ampoliros::instance('Ampoliros');
    if ($amp->getState == Ampoliros::STATE_DEBUG) {
        $amp->setState(Ampoliros::STATE_DEVELOPMENT);
    }
    $debugger = new Debugger($eventData['pid']);
    if ($debugger->CheckPidFile()) {
        $debugger->ReadPidFile();
        $moddata = $debugger->GuessModule();
        $country = new LocaleCountry($gEnv['root']['locale']['country']);
        $rowa = 0;
        $rowb = 0;
        $rowc = 0;
        $rowd = 0;
        $rowe = 0;
        $rowf = 0;
        $log_events = '';
        while (list(, $log_event) = each($debugger->mLogEvents)) {
            $log_events .= $log_event . "\n";
        }
        $hui_events = array();
        while (list($dispatcher, $event) = each($debugger->mHuiEvents)) {
            $hui_events[] = $dispatcher . '::' . $event['eventname'];
            if (is_array($event['eventdata'])) {
                while (list($eventdata_name, $eventdata_value) = each($event['eventdata'])) {
                    $hui_events[] = '- ' . $eventdata_name . ' -> ' . $eventdata_value;
                }
            }
        }
        $tabs[0]['label'] = $gLocale->GetStr('instance.label');
        $tabs[1]['label'] = $gLocale->GetStr('environment.label');
        $tabs[2]['label'] = $gLocale->GetStr('runtime.label');
        $tabs[3]['label'] = $gLocale->GetStr('source.label');
        $tabs[4]['label'] = $gLocale->GetStr('profiler.label');
        $tabs[5]['label'] = $gLocale->GetStr('bugreport.label');
        arsort($debugger->mDbProfiler);
        $xml_def = '<tab><name>debugger</name><args>' . (isset($eventData['activetab']) ? '<activetab>' . $eventData['activetab'] . '</activetab>' : '') . '<tabactionfunction>debugger_tab_action_builder</tabactionfunction><tabs type="array">' . huixml_encode($tabs) . '</tabs></args><children>
                
                  <grid><name>debugger</name><children>
                
                    <label row="' . $rowa++ . '" col="0"><name>instance</name><args><label type="encoded">' . urlencode($gLocale->GetStr('instance.label')) . '</label><bold>true</bold></args></label>
                
                    <label row="' . $rowa . '" col="0"><name>pid</name><args><label type="encoded">' . urlencode($gLocale->GetStr('pid.label')) . '</label></args></label>
                    <string row="' . $rowa++ . '" col="1"><name>pid</name><args><readonly>true</readonly><value>' . $eventData['pid'] . '</value><size>32</size></args></string>
                
                    <label row="' . $rowa . '" col="0"><name>sessionid</name><args><label type="encoded">' . urlencode($gLocale->GetStr('sessionid.label')) . '</label></args></label>
                    <string row="' . $rowa++ . '" col="1"><name>sessionid</name><args><readonly>true</readonly><value>' . $debugger->mSessionId . '</value><size>32</size></args></string>
                
                    <label row="' . $rowa . '" col="0"><name>state</name><args><label type="encoded">' . urlencode($gLocale->GetStr('state.label')) . '</label></args></label>
                    <string row="' . $rowa++ . '" col="1"><name>state</name><args><readonly>true</readonly><value>' . $debugger->mState . '</value><size>15</size></args></string>
                
                    <label row="' . $rowa . '" col="0"><name>interface</name><args><label type="encoded">' . urlencode($gLocale->GetStr('interface.label')) . '</label></args></label>
                    <string row="' . $rowa++ . '" col="1"><name>interface</name><args><readonly>true</readonly><value>' . $debugger->mInterface . '</value><size>15</size></args></string>
                
                    <label row="' . $rowa . '" col="0"><name>mode</name><args><label type="encoded">' . urlencode($gLocale->GetStr('mode.label')) . '</label></args></label>
                    <string row="' . $rowa++ . '" col="1"><name>mode</name><args><readonly>true</readonly><value>' . $debugger->mMode . '</value><size>15</size></args></string>
                
                    <label row="' . $rowa . '" col="0"><name>pagename</name><args><label type="encoded">' . urlencode($gLocale->GetStr('pagename.label')) . '</label></args></label>
                    <string row="' . $rowa++ . '" col="1"><name>pagename</name><args><readonly>true</readonly><value>' . $debugger->mPidStructure['gEnv']['runtime']['pagename'] . '</value><size>20</size></args></string>
                
                    <label row="' . $rowa . '" col="0"><name>siteid</name><args><label type="encoded">' . urlencode($gLocale->GetStr('siteid.label')) . '</label></args></label>
                    <string row="' . $rowa++ . '" col="1"><name>siteid</name><args><readonly>true</readonly><value>' . $debugger->mPidStructure['gEnv']['site']['id'] . '</value><size>20</size></args></string>
                
                    <label row="' . $rowa . '" col="0"><name>userid</name><args><label type="encoded">' . urlencode($gLocale->GetStr('userid.label')) . '</label></args></label>
                    <string row="' . $rowa++ . '" col="1"><name>userid</name><args><readonly>true</readonly><value>' . $debugger->mPidStructure['gEnv']['user']['id'] . '</value><size>20</size></args></string>
                
                  </children></grid>
                
                  <grid><name>environment</name><children>
                
                    <label row="' . $rowb++ . '" col="0"><name>environment</name><args><label type="encoded">' . urlencode($gLocale->GetStr('environment.label')) . '</label><bold>true</bold></args></label>
                
                    <label row="' . $rowb . '" col="0"><name>memory</name><args><label type="encoded">' . urlencode($gLocale->GetStr('memorylimit.label')) . '</label></args></label>
                    <string row="' . $rowb++ . '" col="1"><name>memory</name><args><readonly>true</readonly><value>' . $debugger->mPidStructure['gEnv']['core']['php']['memorylimit'] . '</value><size>15</size></args></string>
                
                    <label row="' . $rowb . '" col="0"><name>timelimit</name><args><label type="encoded">' . urlencode($gLocale->GetStr('timelimit.label')) . '</label></args></label>
                    <string row="' . $rowb++ . '" col="1"><name>timelimit</name><args><readonly>true</readonly><value>' . $debugger->mPidStructure['gEnv']['core']['php']['timelimit'] . '</value><size>15</size></args></string>
                
                    <label row="' . $rowb . '" col="0"><name>sessionlifetime</name><args><label type="encoded">' . urlencode($gLocale->GetStr('sessionlifetime.label')) . '</label></args></label>
                    <string row="' . $rowb++ . '" col="1"><name>sessionlifetime</name><args><readonly>true</readonly><value>' . $debugger->mPidStructure['gEnv']['core']['session']['lifetime'] . '</value><size>15</size></args></string>
                
                    <label row="' . $rowb . '" col="0"><name>extensions</name><args><label type="encoded">' . urlencode($gLocale->GetStr('extensions.label')) . '</label></args></label>
                    <listbox row="' . $rowb++ . '" col="1"><name>extensions</name><args><readonly>true</readonly><elements type="array">' . huixml_encode($debugger->mLoadedExtensions) . '</elements><size>10</size></args></listbox>
                
                  </children></grid>
                
                  <grid><name>runtime</name><children>
                
                    <label row="' . $rowc++ . '" col="0"><name>runtime</name><args><label type="encoded">' . urlencode($gLocale->GetStr('runtime.label')) . '</label><bold>true</bold></args></label>
                
                    <label row="' . $rowc . '" col="0"><name>libraries</name><args><label type="encoded">' . urlencode($gLocale->GetStr('libraries.label')) . '</label></args></label>
                    <listbox row="' . $rowc++ . '" col="1"><name>libraries</name><args><readonly>true</readonly><elements type="array">' . huixml_encode($debugger->mLibraries) . '</elements><size>10</size></args></listbox>
                
                    <label row="' . $rowc . '" col="0"><name>logevents</name><args><label type="encoded">' . urlencode($gLocale->GetStr('logevents.label')) . '</label></args></label>
                    <text row="' . $rowc++ . '" col="1"><name>logevents</name><args><readonly>true</readonly><value type="encoded">' . urlencode($log_events) . '</value><rows>15</rows><cols>100</cols></args></text>
                
                    <label row="' . $rowc . '" col="0"><name>calledhooks</name><args><label type="encoded">' . urlencode($gLocale->GetStr('calledhooks.label')) . '</label></args></label>
                    <listbox row="' . $rowc++ . '" col="1"><name>calledhooks</name><args><readonly>true</readonly><elements type="array">' . huixml_encode($debugger->mCalledHooks) . '</elements><size>5</size></args></listbox>
                
                    <label row="' . $rowc . '" col="0"><name>huievents</name><args><label type="encoded">' . urlencode($gLocale->GetStr('huievents.label')) . '</label></args></label>
                    <listbox row="' . $rowc++ . '" col="1"><name>huievents</name><args><readonly>true</readonly><elements type="array">' . huixml_encode($hui_events) . '</elements><size>5</size></args></listbox>
                
                    <label row="' . $rowc . '" col="0"><name>queries</name><args><label type="encoded">' . urlencode($gLocale->GetStr('queries.label')) . '</label></args></label>
                    <listbox row="' . $rowc++ . '" col="1"><name>queries</name><args><readonly>true</readonly><elements type="array">' . huixml_encode($debugger->mExecutedQueries) . '</elements><size>10</size></args></listbox>
                
                    <label row="' . $rowc . '" col="0"><name>includedfiles</name><args><label type="encoded">' . urlencode($gLocale->GetStr('includedfiles.label')) . '</label></args></label>
                    <listbox row="' . $rowc++ . '" col="1"><name>includedfiles</name><args><readonly>true</readonly><elements type="array">' . huixml_encode($debugger->mIncludedFiles) . '</elements><size>5</size></args></listbox>
                ';
        if (function_exists('memory_get_usage')) {
            $xml_def .= '    <label row="' . $rowc . '" col="0">
                              <args>
                                <label type="encoded">' . urlencode($gLocale->GetStr('memoryusage.label')) . '</label>
                              </args>
                            </label>';
        }
        $xml_def .= '    <string row="' . $rowc++ . '" col="1">
                      <args>
                        <value type="encoded">' . urlencode($country->FormatNumber($debugger->mMemoryUsage)) . '</value>
                        <readonly>true</readonly>
                        <size>15</size>
                      </args>
                    </string>
                
                  </children></grid>
                
                  <grid><name>source</name><children>
                
                    <label row="' . $rowe++ . '" col="0"><name>source</name><args><label type="encoded">' . urlencode($gLocale->GetStr('source.label')) . '</label><bold>true</bold></args></label>
                
                    <label row="' . $rowe . '" col="0"><name>classes</name><args><label type="encoded">' . urlencode($gLocale->GetStr('classes.label')) . '</label></args></label>
                    <listbox row="' . $rowe++ . '" col="1"><name>classes</name><args><readonly>true</readonly><elements type="array">' . huixml_encode($debugger->mDefinedClasses) . '</elements><size>10</size></args></listbox>
                
                    <label row="' . $rowe . '" col="0"><name>functions</name><args><label type="encoded">' . urlencode($gLocale->GetStr('functions.label')) . '</label></args></label>
                    <listbox row="' . $rowe++ . '" col="1"><name>functions</name><args><readonly>true</readonly><elements type="array">' . huixml_encode($debugger->mDefinedFunctions) . '</elements><size>5</size></args></listbox>
                
                  </children></grid>
                
                  <grid><name>profiler</name><children>
                
                    <label row="' . $rowd++ . '" col="0"><name>profiler</name><args><label type="encoded">' . urlencode($gLocale->GetStr('profiler.label')) . '</label><bold>true</bold></args></label>
                
                    <label row="' . $rowd . '" col="0"><name>markers</name><args><label type="encoded">' . urlencode($gLocale->GetStr('markers.label')) . '</label></args></label>
                    <listbox row="' . $rowd++ . '" col="1"><name>markers</name><args><readonly>true</readonly><elements type="array">' . huixml_encode($debugger->mProfiler) . '</elements><size>20</size></args></listbox>
                
                    <label row="' . $rowd . '" col="0"><name>markers</name><args><label type="encoded">' . urlencode($gLocale->GetStr('dbmarkers.label')) . '</label></args></label>
                    <listbox row="' . $rowd++ . '" col="1"><name>markers</name><args><readonly>true</readonly><elements type="array">' . huixml_encode($debugger->mDbProfiler) . '</elements><size>20</size></args></listbox>
                    
                    <label row="' . $rowd . '" col="0"><name>dbload</name><args><label type="encoded">' . urlencode($gLocale->GetStr('dbload.label')) . '</label></args></label>
                    <string row="' . $rowd++ . '" col="1"><name>dbload</name><args><readonly>true</readonly><value>' . $debugger->mDbTotalLoad . '</value><size>20</size></args></string>
                
                    <label row="' . $rowd . '" col="0"><args><label type="encoded">' . urlencode($gLocale->GetStr('executedqueries.label')) . '</label></args></label>
                    <string row="' . $rowd++ . '" col="1"><name>executedqueries</name><args><readonly>true</readonly><value>' . count($debugger->mDbProfiler) . '</value><size>6</size></args></string>
                
                  </children></grid>
                
                  <form><name>bugreport</name><args><method>post</method><action type="encoded"></action></args><children>
                
                    <vertgroup><name>bugreport</name><children>
                
                      <grid><name>bugreport</name><children>
                
                        <label row="' . $rowf++ . '" col="0"><name>bugreport</name><args><label type="encoded">' . urlencode($gLocale->GetStr('bugreport.label')) . '</label><bold>true</bold></args></label>
                
                        <label row="' . $rowf . '" col="0"><name>module</name><args><label type="encoded">' . urlencode($gLocale->GetStr('module.label')) . '</label></args></label>
                        <label row="' . $rowf++ . '" col="1"><name>module</name><args><label type="encoded">' . urlencode($moddata['module']) . '</label></args></label>
                
                        <label row="' . $rowf . '" col="0"><name>bugsemail</name><args><label type="encoded">' . urlencode($gLocale->GetStr('bugsemail.label')) . '</label></args></label>
                        <label row="' . $rowf++ . '" col="1"><name>to</name><args><label type="encoded">' . urlencode($moddata['email']) . '</label></args></label>';
        if ($moddata['ampolirosemail'] != $moddata['email']) {
            $xml_def .= '        <label row="' . $rowf . '" col="0"><name>notify</name><args><label type="encoded">' . urlencode($gLocale->GetStr('sendnotify.label')) . '</label></args></label>
                                <checkbox row="' . $rowf++ . '" col="1"><name>notify</name><args><disp>pass</disp></args></checkbox>';
        }
        $xml_def .= '        <label row="' . $rowf . '" col="0"><name>email</name><args><label type="encoded">' . urlencode($gLocale->GetStr('submitteremail.label')) . '</label></args></label>
                        <string row="' . $rowf++ . '" col="1"><name>email</name><args><size>25</size><disp>pass</disp></args></string>
                
                        <label row="' . $rowf . '" col="0"><name>message</name><args><label type="encoded">' . urlencode($gLocale->GetStr('message.label')) . '</label></args></label>
                        <text row="' . $rowf++ . '" col="1"><name>message</name><args><cols>80</cols><rows>10</rows><disp>pass</disp></args></text>
                
                      </children></grid>
                
                      <horizbar><name>hb</name></horizbar>
                
                      <button><name>submit</name>
                        <args>
                          <formsubmit>bugreport</formsubmit>
                          <themeimage>button_ok</themeimage>
                          <frame>false</frame>
                          <horiz>true</horiz>
                          <label type="encoded">' . urlencode($gLocale->GetStr('bugreport.submit')) . '</label>
                          <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'debug', array('pid' => $eventData['pid'])), array('pass', 'submitbugreport', array('pid' => $eventData['pid']))))) . '</action>
                        </args>
                      </button>
                
                    </children></vertgroup>
                
                  </children></form>
                
                </children></tab>';
    }
    $gPage_content = new HuiXml('page', array('definition' => $xml_def));
}
Esempio n. 14
0
 /**
  * Imposta lo stato della risorsa.
  * @param string $status
  * @access private
  * @return bool
  */
 public function setStatus($status)
 {
     if ($this->mResource) {
         switch ($status) {
             case Semaphore::STATUS_GREEN:
                 clearstatcache();
                 if (file_exists($this->GetFileName())) {
                     unlink($this->GetFileName());
                 }
                 return true;
                 break;
             case Semaphore::STATUS_RED:
                 clearstatcache();
                 if (!file_exists($this->GetFileName())) {
                     if ($fh = fopen($this->GetFileName(), 'w')) {
                         import('com.solarix.ampoliros.core.Ampoliros');
                         $amp = Ampoliros::instance('Ampoliros');
                         fputs($fh, serialize(array('pid' => $amp->getPid(), 'time' => time(), 'resource' => $this->mResource)));
                         fclose($fh);
                     } else {
                         if (!file_exists(TMP_PATH . 'semaphores/')) {
                             mkdir(TMP_PATH . 'semaphores/');
                         }
                         return false;
                     }
                 }
                 return true;
                 break;
         }
     }
     return false;
 }
Esempio n. 15
0
 public function initTheme()
 {
     $result = false;
     if (strlen($this->mTheme)) {
         global $gEnv;
         import('com.solarix.ampoliros.core.Ampoliros');
         $amp = Ampoliros::instance('Ampoliros');
         if ($this->mTheme == 'default') {
             $this->mTheme = $gEnv['hui']['theme']['default'];
         }
         if ($this->mTheme != 'userdefined') {
             if (file_exists(CONFIG_PATH . $this->mTheme . '.huitheme')) {
                 $this->mThemeFile = CONFIG_PATH . $this->mTheme . '.huitheme';
             } else {
                 $this->mTheme = $gEnv['hui']['theme']['default'];
                 $this->mThemeFile = CONFIG_PATH . $gEnv['hui']['theme']['default'] . '.huitheme';
             }
             OpenLibrary('configman.library');
             $cfg_file = new ConfigFile($this->mThemeFile);
             if ($cfg_file->opened()) {
                 $this->mIconsSetName = $cfg_file->Value('THEME.ICONSSET');
                 $this->mColorsSetName = $cfg_file->Value('THEME.COLORSSET');
                 $this->mStyleName = $cfg_file->Value('THEME.STYLE');
             } else {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger(AMP_LOG);
                 $log->LogEvent('ampoliros.huithemes_library.huitheme_class.inittheme', 'Unable to open theme configuration file ' . $this->mThemeFile, LOGGER_ERROR);
             }
         } else {
             $this->mIconsSetName = $this->mUserSettings['iconsset'];
             $this->mColorsSetName = $this->mUserSettings['colorsset'];
             $this->mStyleName = $this->mUserSettings['stylename'];
         }
         $this->mIconsSetBase = CGI_URL . 'icons/' . $this->mIconsSetName . '/';
         $this->mIconsBase = CGI_URL . 'icons/';
         $this->mIconsSetDir = CGI_PATH . 'icons/' . $this->mIconsSetName . '/';
         $this->mStyleBase = CGI_URL . 'styles/';
         $this->mStyleDir = CGI_PATH . 'styles/' . $this->mStyleName . '/';
         $hui_colors = new HuiColorsSet($this->mrAmpDb, $this->mColorsSetName);
         $hui_icons = new HuiIconsSet($this->mrAmpDb, $this->mIconsSetName);
         $hui_style = new HuiStyle($this->mrAmpDb, $this->mStyleName);
         if ($amp->getState() != Ampoliros::STATE_SETUP) {
             $cached_iconsset = new CachedItem($this->mrAmpDb, 'ampoliros', 'huiiconsset-' . $this->mIconsSetName);
             $cached_colorsset = new CachedItem($this->mrAmpDb, 'ampoliros', 'huicolorsset-' . $this->mColorsSetName);
             $cached_style = new CachedItem($this->mrAmpDb, 'ampoliros', 'huistyle-' . $this->mStyleName);
             $this->mIconsSet = unserialize($cached_iconsset->Retrieve());
             $this->mColorsSet = unserialize($cached_colorsset->Retrieve());
             $this->mStyle = unserialize($cached_style->Retrieve());
         }
         if (!$this->mIconsSet or !$this->mColorsSet or !$this->mStyle) {
             if ($gEnv['hui']['theme']['default'] == $this->mTheme) {
                 $this->mColorsSet = $hui_colors->GetColorsSet();
                 $this->mIconsSet = $hui_icons->GetIconsSet();
                 $this->mStyle = $hui_style->GetStyle();
             } else {
                 OpenLibrary('configman.library');
                 $def_cfg_file = new ConfigFile(CONFIG_PATH . $gEnv['hui']['theme']['default'] . '.huitheme');
                 if ($def_cfg_file->Opened()) {
                     $def_icons_set_name = $def_cfg_file->Value('THEME.ICONSSET');
                     $def_colors_set_name = $def_cfg_file->Value('THEME.COLORSSET');
                     $def_style_name = $def_cfg_file->Value('THEME.STYLE');
                 } else {
                     import('com.solarix.ampoliros.io.log.Logger');
                     $log = new Logger(AMP_LOG);
                     $log->LogEvent('ampoliros.huithemes_library.huitheme_class.inittheme', 'Unable to open default theme configuration file ' . CONFIG_PATH . $gEnv['hui']['theme']['default'] . '.huitheme', LOGGER_ERROR);
                 }
                 $hui_def_colors = new HuiColorsSet($this->mrAmpDb, $def_colors_set_name);
                 $hui_def_icons = new HuiIconsSet($this->mrAmpDb, $def_icons_set_name);
                 $hui_def_style = new HuiStyle($this->mrAmpDb, $def_style_name);
                 $this->mColorsSet = $this->DefOpts($hui_def_colors->GetColorsSet(), $hui_colors->GetColorsSet());
                 $this->mIconsSet = $this->DefOpts($hui_def_icons->GetIconsSet(), $hui_icons->GetIconsSet());
                 $this->mStyle = $this->DefOpts($hui_def_style->GetStyle(), $hui_style->GetStyle());
             }
             while (list($style_name, $style_item) = each($this->mStyle)) {
                 $this->mStyle[$style_name] = $this->mStyleBase . $style_item['base'] . '/' . $style_item['value'];
             }
             if ($amp->getState() != Ampoliros::STATE_SETUP) {
                 $cached_iconsset->Store(serialize($this->mIconsSet));
                 $cached_colorsset->Store(serialize($this->mColorsSet));
                 $cached_style->Store(serialize($this->mStyle));
             }
         }
     }
     return $result;
 }
Esempio n. 16
0
 public function newDBLayer($params)
 {
     // Checks for database layer type
     //
     if (!isset($params['dbtype']) or !strlen($params['dbtype'])) {
         global $gEnv;
         import('com.solarix.ampoliros.core.Ampoliros');
         $amp = Ampoliros::instance('Ampoliros');
         if ($amp->getState() != Ampoliros::STATE_SETUP) {
             $params['dbtype'] = AMP_DBTYPE;
         } else {
             return false;
         }
     }
     // Creates a new instance of the specified database layer object
     //
     import('com.solarix.ampoliros.db.drivers.' . $params['dbtype'] . '.DBLayer_' . $params['dbtype']);
     import('com.solarix.ampoliros.db.drivers.' . $params['dbtype'] . '.RecordSet_' . $params['dbtype']);
     $objname = 'dblayer_' . $params['dbtype'];
     return new $objname($params);
 }
Esempio n. 17
0
 function Install($tmpfilepath, $updateOnce = false)
 {
     $result = FALSE;
     import('com.solarix.ampoliros.core.Ampoliros');
     $amp = Ampoliros::instance('Ampoliros');
     if ($amp->GetState() == Ampoliros::STATE_DEBUG) {
         $GLOBALS['gEnv']['runtime']['debug']['loadtime']->Mark('moduleinstallstart');
     }
     if (file_exists($tmpfilepath)) {
         import('carthag.io.archive.Archive');
         // Moves temp file to modules repository and extracts it
         //
         $fname = MODULE_PATH . basename($tmpfilepath);
         @copy($tmpfilepath, $fname);
         $basetmpdir = $tmpdir = TMP_PATH . 'modinst/' . md5(microtime());
         @mkdir($tmpdir, 0755);
         $olddir = getcwd();
         @chdir($tmpdir);
         //@system( escapeshellcmd( 'tar zxf '.$fname ) );
         $archive_format = ARCHIVE_TGZ;
         if (substr($fname, -4) == '.zip') {
             $archive_format = ARCHIVE_ZIP;
         }
         $mod_archive = new Archive($fname, $archive_format);
         $mod_archive->Extract($tmpdir);
         // Checks if the files are into a directory instead of the root
         //
         if (!@is_dir($tmpdir . '/defs')) {
             $dhandle = opendir($tmpdir);
             while (FALSE != ($file = readdir($dhandle))) {
                 if ($file != '.' && $file != '..' && is_dir($tmpdir . '/' . $file . '/defs')) {
                     $tmpdir = $tmpdir . '/' . $file;
                 }
             }
             closedir($dhandle);
         }
         $this->basedir = $tmpdir;
         // Checks for definition and structure files
         //
         if (file_exists($tmpdir . '/defs/' . Module::BUNDLEDEF_FILE)) {
             $modules_array = file($tmpdir . '/defs/' . Module::BUNDLEDEF_FILE);
             $result = TRUE;
             while (list(, $module) = each($modules_array)) {
                 $module = trim($module);
                 if (strlen($module) and file_exists($tmpdir . '/modules/' . $module)) {
                     $temp_module = new Module($this->ampdb);
                     if (!$temp_module->Install($tmpdir . '/modules/' . $module)) {
                         $result = FALSE;
                     }
                 }
             }
         } else {
             if (file_exists($tmpdir . '/defs/' . Module::STRUCTURE_FILE) and file_exists($tmpdir . '/defs/' . Module::GENERALDEF_FILE)) {
                 $genconfig = new ConfigFile($tmpdir . '/defs/' . Module::GENERALDEF_FILE);
                 $this->modname = $genconfig->Value('MODULEIDNAME');
                 // Checks if the module has been already installed
                 //
                 $tmpquery = $this->ampdb->Execute('SELECT id,modfile FROM modules WHERE modid=' . $this->ampdb->Format_Text($this->modname));
                 if (!$tmpquery->NumRows()) {
                     // Module is new, so it will be installed
                     //
                     // Dependencies check
                     //
                     $this->unmetdeps = array();
                     $this->unmetsuggs = array();
                     $moddeps = new ModuleDep($this->ampdb);
                     $deps = $moddeps->ExplodeDeps($genconfig->Value('MODULEDEPENDENCIES'));
                     $suggs = $moddeps->ExplodeDeps($genconfig->Value('MODULESUGGESTIONS'));
                     if ($deps != FALSE) {
                         $this->unmetdeps = $moddeps->CheckModuleDeps(0, '', $deps);
                     } else {
                         $this->unmetdeps == FALSE;
                     }
                     // Suggestions check
                     //
                     if ($suggs != FALSE) {
                         $unmetsuggs = $moddeps->CheckModuleDeps(0, '', $suggs);
                         if (is_array($unmetsuggs)) {
                             $this->unmetsuggs = $unmetsuggs;
                         }
                     }
                     // If dependencies are ok, go on
                     //
                     if ($this->unmetdeps == FALSE) {
                         // Gets serial number for the module
                         //
                         $this->serial = $this->ampdb->NextSeqValue('modules_id_seq');
                         $this->ampdb->Execute('INSERT INTO modules VALUES ( ' . $this->serial . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULEIDNAME')) . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULEVERSION')) . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULEDATE')) . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULEDESCRIPTION')) . ',' . $this->ampdb->Format_Text(basename($tmpfilepath)) . ',' . $this->ampdb->Format_Text($this->ampdb->fmtfalse) . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULE_AUTHOR')) . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULE_AUTHOR_EMAIL')) . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULE_AUTHOR_SITE')) . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULE_SUPPORT_EMAIL')) . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULE_BUGS_EMAIL')) . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULE_COPYRIGHT')) . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULE_LICENSE')) . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULE_LICENSE_FILE')) . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULE_MAINTAINER')) . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULE_MAINTAINER_EMAIL')) . ',' . $this->ampdb->Format_Text($genconfig->Value('MODULE_CATEGORY')) . ')');
                         // Module dir creation
                         //
                         @mkdir(MODULE_PATH . $genconfig->Value('MODULEIDNAME'), 0755);
                         // Defs files
                         //
                         if ($dhandle = @opendir($tmpdir . '/defs')) {
                             while (FALSE != ($file = readdir($dhandle))) {
                                 if ($file != '.' && $file != '..' && is_file($tmpdir . '/defs/' . $file)) {
                                     @copy($tmpdir . '/defs/' . $file, MODULE_PATH . $genconfig->Value('MODULEIDNAME') . '/' . $file);
                                 }
                             }
                             closedir($dhandle);
                         }
                         // Adds modules dependencies
                         //
                         $moddeps->AddDepsArray($genconfig->Value('MODULEIDNAME'), $deps, DEPTYPE_DEP);
                         $moddeps->AddDepsArray($genconfig->Value('MODULEIDNAME'), $suggs, DEPTYPE_SUGG);
                         $this->SetSubModules(explode(',', trim($genconfig->Value('MODULE_SUBMODULES'), ' ,')));
                         $this->HandleStructure($tmpdir . '/defs/' . Module::STRUCTURE_FILE, Module::INSTALL_MODE_INSTALL, $tmpdir);
                         if (strlen($genconfig->Value('MODULE_LICENSE_FILE')) and file_exists($tmpdir . '/' . $genconfig->Value('MODULE_LICENSE_FILE'))) {
                             @copy($tmpdir . '/' . $genconfig->Value('MODULE_LICENSE_FILE'), MODULE_PATH . $genconfig->Value('MODULEIDNAME') . '/' . $genconfig->Value('MODULE_LICENSE_FILE'));
                         }
                         // Checks if it is an extension module
                         //
                         $genconfig = new ConfigFile($tmpdir . '/defs/' . Module::GENERALDEF_FILE);
                         $ext = $this->ampdb->fmtfalse;
                         if ($genconfig->Value('ONLYEXTENSION') == 'y') {
                             $ext = $this->ampdb->fmttrue;
                             $this->onlyextension = TRUE;
                         } else {
                             if ($genconfig->Value('ONLYEXTENSION') == 'n') {
                                 $ext = $this->ampdb->fmtfalse;
                                 $this->onlyextension = FALSE;
                             } else {
                                 if ($this->onlyextension) {
                                     $ext = $this->ampdb->fmttrue;
                                 }
                             }
                         }
                         $this->ampdb->Execute('UPDATE modules SET onlyextension=' . $this->ampdb->Format_Text($ext) . ' WHERE modid=' . $this->ampdb->Format_Text($this->modname));
                         $result = TRUE;
                         if ($GLOBALS['gEnv']['core']['config']->Value('ALERT_ON_MODULE_OPERATION') == '1') {
                             import('com.solarix.ampoliros.security.SecurityLayer');
                             $amp_security = new SecurityLayer();
                             $amp_security->SendAlert('Module ' . $this->modname . ' has been installed');
                             unset($amp_security);
                         }
                         if ($result == true) {
                             if ($GLOBALS['gEnv']['core']['edition'] == AMP_EDITION_ENTERPRISE and $this->modname != 'ampoliros' and $ext != $this->ampdb->fmttrue) {
                                 $sites_query = $GLOBALS['gEnv']['root']['db']->Execute('SELECT id FROM sites');
                                 if ($sites_query->NumRows()) {
                                     $this->Enable($sites_query->Fields('id'));
                                 }
                             }
                             import('com.solarix.ampoliros.io.log.Logger');
                             $log = new Logger(AMP_LOG);
                             $log->LogEvent('Ampoliros', 'Installed module ' . $this->modname, LOGGER_NOTICE);
                         }
                     }
                 } else {
                     $moddata = $tmpquery->Fields();
                     $this->serial = $moddata['id'];
                     // Module will be updated
                     //
                     if ($this->serial) {
                         // Dependencies check
                         //
                         $this->unmetdeps = array();
                         $this->unmetsuggs = array();
                         $moddeps = new ModuleDep($this->ampdb);
                         $deps = $moddeps->ExplodeDeps($genconfig->Value('MODULEDEPENDENCIES'));
                         $suggs = $moddeps->ExplodeDeps($genconfig->Value('MODULESUGGESTIONS'));
                         if ($deps != FALSE) {
                             $this->unmetdeps = $moddeps->CheckModuleDeps(0, '', $deps);
                         } else {
                             $this->unmetdeps == FALSE;
                         }
                         // Suggestions check
                         //
                         if ($suggs != FALSE) {
                             $unmetsuggs = $moddeps->CheckModuleDeps(0, '', $suggs);
                             if (is_array($unmetsuggs)) {
                                 $this->unmetsuggs = $unmetsuggs;
                             }
                         }
                         // If dependencies are ok, go on
                         //
                         if ($this->unmetdeps == FALSE) {
                             // Creates lock file
                             //
                             touch(TMP_PATH . '.upgrading_system');
                             // :WARNING: evil 20020506: possible problems on Windows systems
                             // It has a 'permission denied'.
                             // Removes old module file
                             //
                             if (basename($fname) != $moddata['modfile'] and file_exists(MODULE_PATH . $moddata['modfile'])) {
                                 @unlink(MODULE_PATH . $moddata['modfile']);
                             }
                             // Updates modules table
                             //
                             $this->ampdb->Execute('UPDATE modules SET modversion=' . $this->ampdb->Format_Text($genconfig->Value('MODULEVERSION')) . ', moddate=' . $this->ampdb->Format_Text($genconfig->Value('MODULEDATE')) . ', moddesc=' . $this->ampdb->Format_Text($genconfig->Value('MODULEDESCRIPTION')) . ', modfile=' . $this->ampdb->Format_Text(basename($tmpfilepath)) . ', author=' . $this->ampdb->Format_Text($genconfig->Value('MODULE_AUTHOR')) . ', authoremail=' . $this->ampdb->Format_Text($genconfig->Value('MODULE_AUTHOR_EMAIL')) . ', authorsite=' . $this->ampdb->Format_Text($genconfig->Value('MODULE_AUTHOR_SITE')) . ', supportemail=' . $this->ampdb->Format_Text($genconfig->Value('MODULE_SUPPORT_EMAIL')) . ', bugsemail=' . $this->ampdb->Format_Text($genconfig->Value('MODULE_BUGS_EMAIL')) . ', copyright=' . $this->ampdb->Format_Text($genconfig->Value('MODULE_COPYRIGHT')) . ', license=' . $this->ampdb->Format_Text($genconfig->Value('MODULE_LICENSE')) . ', licensefile=' . $this->ampdb->Format_Text($genconfig->Value('MODULE_LICENSE_FILE')) . ', maintainer=' . $this->ampdb->Format_Text($genconfig->Value('MODULE_MAINTAINER')) . ', maintaineremail=' . $this->ampdb->Format_Text($genconfig->Value('MODULE_MAINTAINER_EMAIL')) . ', category=' . $this->ampdb->Format_Text($genconfig->Value('MODULE_CATEGORY')) . ' WHERE id=' . (int) $this->serial);
                             $genconfig = new ConfigFile($tmpdir . '/defs/' . Module::GENERALDEF_FILE);
                             // Script files - only before handlestructure
                             //
                             if ($dhandle = @opendir($tmpdir . '/defs')) {
                                 while (FALSE != ($file = readdir($dhandle))) {
                                     if ($file != '.' and $file != '..' and $file != Module::STRUCTURE_FILE and $file != Module::GENERALDEF_FILE and is_file($tmpdir . '/defs/' . $file)) {
                                         @copy($tmpdir . '/defs/' . $file, MODULE_PATH . $genconfig->Value('MODULEIDNAME') . '/' . $file);
                                     }
                                 }
                                 closedir($dhandle);
                             }
                             $this->HandleStructure($tmpdir . '/defs/' . Module::STRUCTURE_FILE, Module::INSTALL_MODE_UPDATE, $tmpdir);
                             if (strlen($genconfig->Value('MODULE_LICENSE_FILE')) and file_exists($tmpdir . '/' . $genconfig->Value('MODULE_LICENSE_FILE'))) {
                                 @copy($tmpdir . '/' . $genconfig->Value('MODULE_LICENSE_FILE'), MODULE_PATH . $genconfig->Value('MODULEIDNAME') . '/' . $genconfig->Value('MODULE_LICENSE_FILE'));
                             }
                             // Defs files - only after handlestructure
                             //
                             @copy($tmpdir . '/defs/' . Module::STRUCTURE_FILE, MODULE_PATH . $genconfig->Value('MODULEIDNAME') . '/' . Module::STRUCTURE_FILE);
                             @copy($tmpdir . '/defs/' . Module::GENERALDEF_FILE, MODULE_PATH . $genconfig->Value('MODULEIDNAME') . '/' . Module::GENERALDEF_FILE);
                             // Checks if it is an extension module
                             //
                             $ext = $this->ampdb->fmtfalse;
                             if ($genconfig->Value('ONLYEXTENSION') == 'y') {
                                 $ext = $this->ampdb->fmttrue;
                                 $this->onlyextension = TRUE;
                             } else {
                                 if ($genconfig->Value('ONLYEXTENSION') == 'n') {
                                     $ext = $this->ampdb->fmtfalse;
                                     $this->onlyextension = FALSE;
                                 } else {
                                     if ($this->onlyextension) {
                                         $ext = $this->ampdb->fmttrue;
                                     }
                                 }
                             }
                             $this->ampdb->Execute('UPDATE modules SET onlyextension=' . $this->ampdb->Format_Text($ext) . ' WHERE modid=' . $this->ampdb->Format_Text($this->modname));
                             $this->SetSubModules(explode(',', trim($genconfig->Value('MODULE_SUBMODULES'), ' ,')));
                             if ($this->modname != 'ampoliros') {
                                 // Remove old dependencies
                                 //
                                 $moddeps->RemAllDep($this->serial);
                                 // Adds new modules dependencies
                                 //
                                 $moddeps->AddDepsArray($genconfig->Value('MODULEIDNAME'), $deps, DEPTYPE_DEP);
                                 $moddeps->AddDepsArray($genconfig->Value('MODULEIDNAME'), $suggs, DEPTYPE_SUGG);
                             }
                             $result = TRUE;
                             if (function_exists('apc_reset_cache')) {
                                 apc_reset_cache();
                             }
                             if ($updateOnce == FALSE) {
                                 $this->Install($tmpfilepath, true);
                                 // Removes lock file
                                 //
                                 unlink(TMP_PATH . '.upgrading_system');
                                 if ($GLOBALS['gEnv']['core']['config']->Value('ALERT_ON_MODULE_OPERATION') == '1') {
                                     Carthag::import('com.solarix.ampoliros.security.SecurityLayer');
                                     $amp_security = new SecurityLayer();
                                     $amp_security->SendAlert('Module ' . $this->modname . ' has been updated');
                                     unset($amp_security);
                                 }
                                 if ($result == TRUE) {
                                     import('com.solarix.ampoliros.io.log.Logger');
                                     $log = new Logger(AMP_LOG);
                                     $log->LogEvent('Ampoliros', 'Updated module ' . $this->modname, LOGGER_NOTICE);
                                 }
                             }
                         }
                         /*
                         else $this->mLog->LogEvent( 'ampoliros.modules_library.modules_class.install',
                         'Structure definition file for module '.$this->modname.' does not exists', LOGGER_ERROR );
                         */
                     } else {
                         import('com.solarix.ampoliros.io.log.Logger');
                         $log = new Logger(AMP_LOG);
                         $log->LogEvent('ampoliros.modules_library.modules_class.install', 'Empty module serial', LOGGER_ERROR);
                     }
                 }
             } else {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger(AMP_LOG);
                 if (!file_exists($tmpdir . '/defs/' . Module::STRUCTURE_FILE)) {
                     $log->LogEvent('ampoliros.modules_library.modules_class.install', 'Module structure file ' . $tmpdir . '/defs/' . Module::STRUCTURE_FILE . ' not found', LOGGER_ERROR);
                 }
                 if (!file_exists($tmpdir . '/defs/' . Module::GENERALDEF_FILE)) {
                     $log->LogEvent('ampoliros.modules_library.modules_class.install', 'Module definition file ' . $tmpdir . '/defs/' . Module::GENERALDEF_FILE . ' not found', LOGGER_ERROR);
                 }
             }
         }
         // Cleans up temp stuff
         //
         @chdir($olddir);
         RecRemoveDir($basetmpdir);
         if (file_exists($tmpfilepath)) {
             @unlink($tmpfilepath);
         }
     } else {
         if (!file_exists($tmpfilepath)) {
             import('com.solarix.ampoliros.io.log.Logger');
             $log = new Logger(AMP_LOG);
             $log->LogEvent('ampoliros.modules_library.modules_class.install', 'Temporary module file (' . $tmpfilepath . ') does not exists', LOGGER_ERROR);
         }
     }
     if ($amp->getState() == Ampoliros::STATE_DEBUG) {
         $GLOBALS['gEnv']['runtime']['debug']['loadtime']->Mark('moduleinstallend');
         import('com.solarix.ampoliros.io.log.Logger');
         $log = new Logger(AMP_LOG);
         $log->LogEvent('ampoliros.modules_library.module_class.install', 'Module installation load time: ' . $GLOBALS['gEnv']['runtime']['debug']['loadtime']->GetSectionLoad('moduleinstallend'), LOGGER_DEBUG);
     }
     return $result;
 }
Esempio n. 18
0
 *
 *                    Ampoliros Application Server
 *
 *                      http://www.ampoliros.com
 *
 *
 *
 *   Copyright (C) 2000-2004 Solarix
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
// $Id: ampmaintenance.php,v 1.15 2004-07-08 15:04:25 alex Exp $
if (!defined('AMPMAINTENANCE_PHP')) {
    define('AMPMAINTENANCE_PHP', true);
    require 'amproot.php';
    $amp = Ampoliros::instance('Ampoliros');
    $amp->startMaintenance();
}
Esempio n. 19
0
 public function build()
 {
     $result = false;
     if (!$this->mBuilt) {
         import('com.solarix.ampoliros.core.Ampoliros');
         $amp = Ampoliros::instance('Ampoliros');
         if ($amp->getState() == Ampoliros::STATE_DEBUG) {
             $GLOBALS['gEnv']['runtime']['debug']['loadtime']->Mark('start - Hui::Build()');
         }
         $children_count = count($this->mChilds);
         if ($children_count) {
             // Builds the structure
             //
             for ($i = 0; $i < $children_count; $i++) {
                 if ($this->mChilds[$i]->Build($this->mDisp)) {
                     $this->mLayout .= $this->mChilds[$i]->Render();
                 }
                 $this->mChilds[$i]->Destroy();
             }
             $this->mBuilt = true;
             $result = true;
         }
         // Call the internal dispatcher, if not alread called
         //
         $this->mDisp->Dispatch();
         if ($amp->getState() == Ampoliros::STATE_DEBUG) {
             $GLOBALS['gEnv']['runtime']['debug']['loadtime']->Mark('stop - Hui::Build()');
         }
     }
     return $result;
 }