function main_default($eventData) { global $gEnv, $gLocale, $gPage_content; $jp_cfg = new ConfigFile(CONFIG_PATH . 'jpcache.cfg', true); $xml_def = '<vertgroup><name>prefs</name><children> <form><name>prefs</name><args><method>post</method><action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'default', ''), array('action', 'setprefs', '')))) . '</action></args><children> <grid><name>prefs</name><children> <label row="0" col="0"><name>cachetime</name><args><label type="encoded">' . urlencode($gLocale->GetStr('cachetime.label')) . '</label></args></label> <string row="0" col="1"><name>cachetime</name><args><disp>action</disp><size>5</size><value>' . $jp_cfg->Value('CACHE_TIME') . '</value></args></string> <label row="1" col="0"><name>cacheon</name><args><label type="encoded">' . urlencode($gLocale->GetStr('cacheon.label')) . '</label></args></label> <checkbox row="1" col="1"><name>cacheon</name><args><disp>action</disp><checked>' . ($jp_cfg->Value('CACHE_ON') == '1' ? 'true' : 'false') . '</checked></args></checkbox> <label row="2" col="0"><name>usegzip</name><args><label type="encoded">' . urlencode($gLocale->GetStr('usegzip.label')) . '</label></args></label> <checkbox row="2" col="1"><name>usegzip</name><args><disp>action</disp><checked>' . ($jp_cfg->Value('USE_GZIP') == '1' ? 'true' : 'false') . '</checked></args></checkbox> <label row="3" col="0"><name>cachepost</name><args><label type="encoded">' . urlencode($gLocale->GetStr('cachepost.label')) . '</label></args></label> <checkbox row="3" col="1"><name>cachepost</name><args><disp>action</disp><checked>' . ($jp_cfg->Value('CACHE_POST') == '1' ? 'true' : 'false') . '</checked></args></checkbox> </children></grid> </children></form> <horizbar><name>hb</name></horizbar> <button><name>submit</name> <args> <label type="encoded">' . urlencode($gLocale->GetStr('setprefs.submit')) . '</label> <themeimage>button_ok</themeimage> <horiz>true</horiz> <frame>true</frame> <formsubmit>prefs</formsubmit> <action type="encoded">' . urlencode(build_events_call_string('', array(array('main', 'default', ''), array('action', 'setprefs', '')))) . '</action> </args> </button> </children></vertgroup>'; $gPage_content = new HuiXml('page', array('definition' => $xml_def)); }
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; }
public function getColorsSet() { $result = array(); OpenLibrary('configman.library'); $cfg_file = new ConfigFile(CONFIG_PATH . $this->mSetName . '.huicolorsset'); if ($cfg_file->Opened()) { $result['pages']['bgcolor'] = $cfg_file->Value('COLORSET.PAGES.BGCOLOR'); $result['pages']['border'] = $cfg_file->Value('COLORSET.PAGES.BORDER'); $result['buttons']['text'] = $cfg_file->Value('COLORSET.BUTTONS.TEXT'); $result['buttons']['disabledtext'] = $cfg_file->Value('COLORSET.BUTTONS.DISABLEDTEXT'); $result['buttons']['selected'] = $cfg_file->Value('COLORSET.BUTTONS.SELECTED'); $result['buttons']['notselected'] = $cfg_file->Value('COLORSET.BUTTONS.NOTSELECTED'); $result['bars']['color'] = $cfg_file->Value('COLORSET.BARS.COLOR'); $result['bars']['shadow'] = $cfg_file->Value('COLORSET.BARS.SHADOW'); $result['frames']['border'] = $cfg_file->Value('COLORSET.FRAMES.BORDER'); $result['statusbars']['bgcolor'] = $cfg_file->Value('COLORSET.STATUSBARS.BGCOLOR'); $result['titlebars']['bgcolor'] = $cfg_file->Value('COLORSET.TITLEBARS.BGCOLOR'); $result['titlebars']['textcolor'] = $cfg_file->Value('COLORSET.TITLEBARS.TEXTCOLOR'); $result['toolbars']['separator'] = $cfg_file->Value('COLORSET.TOOLBARS.SEPARATOR'); $result['tables']['bgcolor'] = $cfg_file->Value('COLORSET.TABLES.BGCOLOR'); $result['tables']['headerbgcolor'] = $cfg_file->Value('COLORSET.TABLES.HEADERBGCOLOR'); $result['tables']['gridcolor'] = $cfg_file->Value('COLORSET.TABLES.GRIDCOLOR'); } else { import('com.solarix.ampoliros.io.log.Logger'); $log = new Logger(AMP_LOG); $log->LogEvent('ampoliros.huithemes_library.huicolorsset_class.getcolorsset', 'Unable to open colors set file ' . CONFIG_PATH . $this->mSetName . '.huicolorsset', LOGGER_ERROR); } return $result; }
public function open() { $result = false; import('carthag.core.Registry'); $reg = Registry::instance(); OpenLibrary('configman.library'); $country_file = new ConfigFile($reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/locale/' . $this->mCountry . '.country'); if ($country_file->Opened()) { $this->mCountryShort = $country_file->Value('COUNTRYSHORT'); $this->mLanguage = $country_file->Value('LANGUAGE'); $this->mDecimalSeparator = $country_file->Value('DECIMALSEPARATOR'); $this->mThousandsSeparator = $country_file->Value('THOUSANDSSEPARATOR'); $this->mPositiveSign = $country_file->Value('POSITIVESIGN'); $this->mNegativeSign = $country_file->Value('NEGATIVESIGN'); $this->mCurrencySymbol = $country_file->Value('CURRENCYSYMBOL'); $this->mMoneyDecimalSeparator = $country_file->Value('MONEYDECIMALSEPARATOR'); $this->mMoneyThousandsSeparator = $country_file->Value('MONEYTHOUSANDSSEPARATOR'); $this->mFractDigits = $country_file->Value('FRACTDIGITS'); $this->mPositivePrefixCurrency = $country_file->Value('POSITIVEPREFIXCURRENCY'); $this->mPositiveSignPosition = $country_file->Value('POSITIVESIGNPOSITION'); $this->mNegativePrefixCurrency = $country_file->Value('NEGATIVEPREFIXCURRENCY'); $this->mNegativeSignPosition = $country_file->Value('NEGATIVESIGNPOSITION'); $this->mTimeFormat = $country_file->Value('TIMEFORMAT'); $this->mDateFormat = $country_file->Value('DATEFORMAT'); $this->mShortDateFormat = $country_file->Value('SHORTDATEFORMAT'); $this->mStartWeekOnMonday = $country_file->Value('STARTWEEKONMONDAY'); $this->mDateSeparator = $country_file->Value('DATESEPARATOR'); $this->mDateOrder = $country_file->Value('DATEORDER'); $this->mCharSet = $country_file->Value('CHARSET'); $result = true; } else { import('com.solarix.ampoliros.io.log.Logger'); $log = new Logger(AMP_LOG); $log->LogEvent('ampoliros.locale_library.country_class.open', 'Unable to open country file ' . $reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/locale/' . $this->mCountry . '.country', LOGGER_ERROR); } return $result; }
function Setup($tmpdir) { $result = FALSE; // Checks for definition and structure files // 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 Ampoliros has been already installed // $tmpquery = $this->ampdb->Execute('SELECT id FROM modules WHERE modid=' . $this->ampdb->Format_Text($this->modname)); if (!$tmpquery->NumRows()) { // Gets serial number for the module // $this->serial = $this->ampdb->NextSeqValue('modules_id_seq'); if ($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 // if (!file_exists(MODULE_PATH . $genconfig->Value('MODULEIDNAME'))) { @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); } $result = $this->HandleStructure($tmpdir . 'defs/' . Module::STRUCTURE_FILE, Module::INSTALL_MODE_INSTALL, $tmpdir, 0, TRUE); 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')); } else { import('com.solarix.ampoliros.io.log.Logger'); $log = new Logger(AMP_LOG); $log->LogEvent('Ampoliros', 'Unable to install Ampoliros', LOGGER_ERROR); } } else { import('com.solarix.ampoliros.io.log.Logger'); $log = new Logger(AMP_LOG); $log->LogEvent('ampoliros.modules_library.modules_class.setup', 'Unable to insert Ampoliros module row in modules table', LOGGER_ERROR); } } else { import('com.solarix.ampoliros.io.log.Logger'); $log = new Logger(AMP_LOG); $log->LogEvent('ampoliros.modules_library.modules_class.setup', 'Attempted to resetup Ampoliros', 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.setup', 'Ampoliros 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.setup', 'Ampoliros definition file ' . $tmpdir . 'defs/' . Module::GENERALDEF_FILE . ' not found', LOGGER_ERROR); } } return $result; }
function SendReport($maintenanceResult) { $result = false; $cfg = new ConfigFile(AMP_CONFIG); $email = $cfg->Value('MAINTENANCE_REPORTS_EMAIL'); if ($cfg->Value('MAINTENANCE_REPORTS_ENABLED') == '1' and strlen($email) and is_array($maintenanceResult)) { $result_text = ''; Carthag::import('com.solarix.ampoliros.locale.Locale'); $locale = new Locale('amp_root_maintenance', $GLOBALS['gEnv']['root']['locale']['language']); $tasks_list = $this->GetTasksList(); foreach ($maintenanceResult as $task => $result) { $result_text .= "\n" . '--> ' . $tasks_list[$task]['description'] . "\n" . ($result ? $locale->GetStr('report_task_ok.label') : $locale->GetStr('report_task_failed.label')) . "\n"; } $result = mail($email, '[AMPOLIROS MAINTENANCE REPORT] - Scheduled maintenance report about ' . AMP_NAME . '.' . AMP_DOMAIN, 'This is the scheduled maintenance report about ' . AMP_NAME . '.' . AMP_DOMAIN . "\n\n" . '== MAINTENANCE RESULTS ==' . "\n" . $result_text); } return $result; }
public function getAlertEvents() { $result = array(); $cfg = new ConfigFile(AMP_CONFIG); $result['wronglocalrootlogin'] = $cfg->Value('ALERT_ON_WRONG_LOCAL_ROOT_LOGIN') == '1' ? true : false; $result['wronglocaluserlogin'] = $cfg->Value('ALERT_ON_WRONG_LOCAL_USER_LOGIN') == '1' ? true : false; $result['wrongremotelogin'] = $cfg->Value('ALERT_ON_WRONG_REMOTE_LOGIN') == '1' ? true : false; $result['moduleoperation'] = $cfg->Value('ALERT_ON_MODULE_OPERATION') == '1' ? true : false; $result['modulesiteoperation'] = $cfg->Value('ALERT_ON_MODULE_SITE_OPERATION') == '1' ? true : false; $result['siteoperation'] = $cfg->Value('ALERT_ON_SITE_OPERATION') == '1' ? true : false; return $result; }