Example #1
0
 public function ModuleConfig(DBLayer $ampdb, $modname)
 {
     $this->ampdb = $ampdb;
     if ($modname) {
         $this->modname = $modname;
     } else {
         import('com.solarix.ampoliros.io.log.Logger');
         $log = new Logger(AMP_LOG);
         $log->LogEvent('ampoliros.modules_library.moduleconfig_class.moduleconfig', 'Empty module name', LOGGER_WARNING);
     }
 }
Example #2
0
 public function getContent()
 {
     $result = false;
     if (strlen($this->mNode)) {
         import('carthag.core.Registry');
         $reg = Registry::instance();
         // Tries specified language catalog
         //
         if (file_exists($reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '_' . $this->mLanguage . '.helpnode')) {
             $help_node_file = $reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '_' . $this->mLanguage . '.helpnode';
         } else {
             if (file_exists($reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '.helpnode')) {
                 $help_node_file = $reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '.helpnode';
             } else {
                 if (file_exists($reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '_' . AMP_LANG . '.helpnode')) {
                     $help_node_file = $reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '_' . AMP_LANG . '.helpnode';
                 } else {
                     if (file_exists($reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '_en.helpnode')) {
                         $help_node_file = $reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/help/' . $this->mNode . '_en.helpnode';
                     } else {
                         import('com.solarix.ampoliros.io.log.Logger');
                         $log = new Logger(AMP_LOG);
                         $log->LogEvent('ampoliros.helpnode_library.helpnode_class.getcontent', 'Unable to find an help node file for the specified help node (' . $this->mNode . ') and language (' . $this->mLanguage . ') or fallback to another language', LOGGER_ERROR);
                     }
                 }
             }
         }
         if (!empty($help_node_file)) {
             $fh = @fopen($help_node_file, 'r');
             if ($fh) {
                 $result = file_get_contents($help_node_file);
                 @fclose($fh);
             }
         }
     }
     return $result;
 }
Example #3
0
 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;
 }
Example #4
0
 public function checkDiffs()
 {
     $result = FALSE;
     if (strlen($this->mOldTable) and strlen($this->mNewTable)) {
         $this->mOldTableHandler->Parse($this->mOldTableHandler->mData);
         $this->mNewTableHandler->Parse($this->mNewTableHandler->mData);
         if (is_array($this->mOldTableHandler->mFieldsList)) {
             reset($this->mOldTableHandler->mFieldsList);
             while (list(, $old_column) = each($this->mOldTableHandler->mFieldsList)) {
                 if (!isset($this->mNewTableHandler->mFieldsList[$old_column])) {
                     $this->mDiffOldColumns[] = $old_column;
                 }
             }
         }
         if (is_array($this->mNewTableHandler->mFieldsList)) {
             reset($this->mNewTableHandler->mFieldsList);
             while (list(, $new_column) = each($this->mNewTableHandler->mFieldsList)) {
                 if (!isset($this->mOldTableHandler->mFieldsList[$new_column])) {
                     $this->mDiffNewColumns[$new_column] = $this->mNewTableHandler->mFields[$new_column];
                 }
             }
         }
         $this->mParsed = $result = TRUE;
     } else {
         import('com.solarix.ampoliros.io.log.Logger');
         $log = new Logger(AMP_LOG);
         $log->LogEvent('ampoliros.dblayer_parser_library.xmldbupdater_class.checkdiffs', 'Old and new table files not specified', LOGGER_ERROR);
     }
     return $result;
 }
Example #5
0
 public function removeGroup($deleteuserstoo)
 {
     $result = false;
     import('com.solarix.ampoliros.util.Hook');
     $hook = new Hook($this->mrAmpDb, 'ampoliros', 'site.group.remove');
     if ($hook->CallHooks('calltime', $this, array('siteserial' => $this->siteserial, 'groupid' => $this->groupid)) == HOOK_RESULT_OK) {
         if ($this->groupid != 0) {
             if ($this->mrSiteDb->Execute('DELETE FROM groups ' . 'WHERE id=' . (int) $this->groupid)) {
                 // Check if we must delete users in this group
                 if ($deleteuserstoo == true) {
                     $usersquery =& $this->mrAmpDb->Execute('SELECT id ' . 'FROM users ' . 'WHERE siteid=' . (int) $this->siteserial . ' AND groupid=' . (int) $this->groupid);
                     $numusers = $usersquery->NumRows();
                     if ($numusers > 0) {
                         // Remove users in this group
                         while (!$usersquery->eof) {
                             $usdata = $usersquery->Fields();
                             Carthag::import('com.solarix.ampoliros.site.user.User');
                             $tmpuser = new user($this->mrAmpDb, $this->siteserial, $usdata['id']);
                             $tmpuser->removeuser();
                             $usersquery->MoveNext();
                             //delete $tmpuser;
                         }
                     }
                 } else {
                     $this->mrAmpDb->Execute("UPDATE users SET groupid = '0' WHERE groupid=" . (int) $this->groupid . ' AND siteid =' . $this->siteserial);
                 }
                 if ($hook->CallHooks('groupremoved', $this, array('siteserial' => $this->siteserial, 'groupid' => $this->groupid)) != HOOK_RESULT_OK) {
                     $result = false;
                 }
                 $this->groupid = 0;
             }
         } else {
             import('com.solarix.ampoliros.io.log.Logger');
             $log = new Logger(AMP_LOG);
             $log->LogEvent('ampoliros.users_library.group_class.removegroup', "Attempted to call a member of an object that doesn't refer to any group", LOGGER_ERROR);
         }
     }
     return $result;
 }
Example #6
0
 public function logEvent($destinations, $context, $eventString, $eventType = LOGGER_GENERIC, $die = false)
 {
     global $gEnv;
     // Root
     //
     if (isset($destinations['root'])) {
         $tmp_log = new Logger($gEnv['root']['log']);
         $tmp_log->LogEvent($context, $eventString, $eventType);
         unset($tmp_log);
     }
     // Root db
     //
     if (isset($destinations['rootdb'])) {
         $tmp_log = new Logger($gEnv['root']['dblog']);
         $tmp_log->LogEvent($context, $eventString, $eventType);
         unset($tmp_log);
     }
     // Remote
     //
     if (isset($destinations['remote'])) {
         $tmp_log = new Logger($gEnv['remote']['log']);
         $tmp_log->LogEvent($context, $eventString, $eventType);
         unset($tmp_log);
     }
     // PHP
     //
     if (isset($destinations['php'])) {
         $tmp_log = new Logger($gEnv['core']['error']['log']);
         $tmp_log->LogEvent($context, $eventString, $eventType);
         unset($tmp_log);
     }
     // Module
     //
     if (isset($destinations['module']) and is_dir(MODULE_PATH . $this->mModule)) {
         $tmp_log = new Logger(MODULE_PATH . $this->mModule . '/module.log');
         $tmp_log->LogEvent($context, $eventString, $eventType);
         unset($tmp_log);
     }
     // Site
     //
     if (isset($destinations['site'])) {
         $tmp_log = new Logger($gEnv['site']['log']);
         $tmp_log->LogEvent($context, $eventString, $eventType);
         unset($tmp_log);
     }
     // Site db
     //
     if (isset($destinations['sitedb'])) {
         $tmp_log = new Logger($gEnv['sit']['dblog']);
         $tmp_log->LogEvent($context, $eventString, $eventType);
         unset($tmp_log);
     }
     if ($die) {
         AmpDie($eventString);
     }
     return true;
 }
Example #7
0
 public function checkEnabledSites($modserial)
 {
     $result = FALSE;
     if (!empty($modserial)) {
         $ensites = array();
         $query = $this->mrAmpDb->Execute('SELECT sites.siteid FROM sites,activemodules WHERE ' . 'activemodules.siteid=sites.id AND activemodules.moduleid=' . (int) $modserial);
         if ($query->NumRows()) {
             while (!$query->eof) {
                 $ensites[] = $query->Fields('siteid');
                 $query->MoveNext();
             }
             $result = $ensites;
         }
     } else {
         import('com.solarix.ampoliros.io.log.Logger');
         $log = new Logger(AMP_LOG);
         $log->LogEvent('ampoliros.modules_library.moddeps_class.checkenabledsites', 'Empty module serial', LOGGER_ERROR);
     }
     return $result;
 }
Example #8
0
 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;
 }
Example #9
0
function pass_setcountry($eventData)
{
    global $hui_mainstatus, $amp_locale, $hui_page;
    $log = new Logger(AMP_LOG);
    $amp_config = new ConfigFile(AMP_CONFIG);
    $amp_config->SetValue('AMP_COUNTRY', $eventData['country']);
    $log->LogEvent('Ampoliros', 'Changed Ampoliros root country', LOGGER_NOTICE);
    $hui_mainstatus->mArgs['status'] = $amp_locale->GetStr('countryset_status');
    $hui_page->mArgs['javascript'] = 'parent.frames.sum.location.reload()';
}
Example #10
0
 public function logFailedAccess($user = '', $root = false, $ip = '')
 {
     Carthag::import('com.solarix.ampoliros.io.log.Logger');
     $log = new Logger($this->mAccessLog);
     $log->LogEvent('ampoliros', 'Wrong access from ' . ($root ? 'root ' : 'user ' . $user . ' ') . (strlen($ip) ? 'from address ' . $ip : ''), LOGGER_NOTICE);
     return true;
 }
Example #11
0
 public function disableAllModules($ampolirosToo = true)
 {
     $result = false;
     if ($this->ampdb) {
         // Checks the enabled modules
         //
         $modsquery =& $this->ampdb->Execute('SELECT id ' . 'FROM activemodules,modules ' . 'WHERE activemodules.siteid=' . (int) $this->siteserial . ' ' . 'AND activemodules.moduleid=modules.id');
         $modules = array();
         while (!$modsquery->eof) {
             $modules[$modsquery->Fields('id')] = $modsquery->Fields('id');
             $modsquery->MoveNext();
         }
         $nummodules = $modsquery->NumRows();
         $ampquery = $this->ampdb->Execute('SELECT id ' . 'FROM modules ' . 'WHERE modid=' . $this->ampdb->Format_Text('ampoliros'));
         if (!$ampolirosToo) {
             unset($modules[$ampquery->Fields('id')]);
             $nummodules--;
         }
         // Tries to disable every module since all modules are disabled, following dependencies
         //
         while (count($modules) > 0) {
             $modid = current($modules);
             if (count($modules) == 1 and $modid == $ampquery->Fields('id') or count($modules) > 1 and $modid != $ampquery->Fields('id') or !$ampolirosToo) {
                 OpenLibrary('modulesbase.library');
                 $tmpmod = new Module($this->ampdb, $modid);
                 if ($tmpmod->Disable($this->siteserial)) {
                     import('com.solarix.ampoliros.io.log.Logger');
                     $log = new Logger(AMP_LOG);
                     $log->LogEvent($this->siteid, 'Disabled module ' . $tmpmod->modname, LOGGER_NOTICE);
                     $this->sitelog->LogEvent($this->siteid, 'Disabled module ' . $tmpmod->modname, LOGGER_NOTICE);
                     unset($modules[$modid]);
                 }
             }
             if (!next($modules)) {
                 reset($modules);
             }
         }
         $result = true;
     }
     return $result;
 }
Example #12
0
 public function getStyle()
 {
     $result = array();
     OpenLibrary('configman.library');
     $cfg_file = new ConfigFile(CONFIG_PATH . $this->mStyleName . '.huistyle');
     if ($cfg_file->Opened()) {
         $values = $cfg_file->ValuesArray();
         while (list($key, $val) = each($values)) {
             $key = trim($key);
             $val = trim($val);
             $realkey = strtolower(substr($key, strpos($key, '.') + 1));
             if ($realkey != 'name') {
                 $result[$realkey]['value'] = $val;
                 $result[$realkey]['base'] = $this->mStyleName;
             }
         }
     } else {
         import('com.solarix.ampoliros.io.log.Logger');
         $log = new Logger(AMP_LOG);
         $log->LogEvent('ampoliros.huithemes_library.huistyle_class.getstyle', 'Unable to open style file ' . CONFIG_PATH . $this->mStyleName . '.huistyle', LOGGER_ERROR);
     }
     return $result;
 }
Example #13
0
function pass_setadvanced($eventData)
{
    global $hui_mainstatus, $amp_locale, $hui_page, $env, $hui_comments, $compressed_ob;
    $log = new Logger(AMP_LOG);
    $amp_cfg = new ConfigFile(AMP_CONFIG);
    $amp_cfg->SetValue('AMP_HUI_COMMENTS', $eventData['hui-comments'] == 'on' ? '1' : '0');
    $amp_cfg->SetValue('AMP_COMPRESSED_OB', $eventData['compressed-ob'] == 'on' ? '1' : '0');
    $hui_comments = 'false';
    $compressed_ob = 'false';
    if ($eventData['hui-comments'] == 'on') {
        $hui_comments = 'true';
    }
    if ($eventData['compressed-ob'] == 'on') {
        $compressed_ob = 'true';
    }
    $log->LogEvent('Ampoliros', 'Changed Ampoliros advanced interface settings', LOGGER_NOTICE);
    $hui_mainstatus->mArgs['status'] = $amp_locale->GetStr('advancedset_status');
    $hui_page->mArgs['javascript'] = 'parent.frames.sum.location.reload()';
}
Example #14
0
 public function openCatalog()
 {
     $result = false;
     import('carthag.core.Registry');
     $reg = Registry::instance();
     if ($this->catalog != null and $this->lang != null) {
         // Tries specified language catalog
         //
         if (file_exists($reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/locale/' . $this->catalog . '_' . $this->lang . '.catalog')) {
             $catfile = $reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/locale/' . $this->catalog . '_' . $this->lang . '.catalog';
         } else {
             if (file_exists($reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . '/var/locale/' . $this->catalog . '.catalog')) {
                 $catfile = $reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/locale/' . $this->catalog . '.catalog';
             } else {
                 if (file_exists($reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/locale/' . $this->catalog . '_' . AMP_LANG . '.catalog')) {
                     $catfile = $reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/locale/' . $this->catalog . '_' . AMP_LANG . '.catalog';
                 } else {
                     if (file_exists($reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/locale/' . $this->catalog . '_en.catalog')) {
                         $catfile = $reg->getEntry('amp.config')->getKey('PRIVATE_TREE') . 'var/locale/' . $this->catalog . '_en.catalog';
                     } else {
                         import('com.solarix.ampoliros.io.log.Logger');
                         $log = new Logger(AMP_LOG);
                         $log->LogEvent('ampoliros.locale_library.locale_class.opencatalog', 'Unable to find a catalog file for the specified catalog (' . $this->catalog . ') and language (' . $this->lang . ') or fallback to another language', LOGGER_ERROR);
                     }
                 }
             }
         }
         if (!empty($catfile)) {
             // New way to read locale catalogs
             //
             OpenLibrary('configman.library');
             $loc = new configfile($catfile);
             $this->locales = $loc->valuesarray();
             $result = true;
             /*
             if ( sizeof( $this->locales ) == 0 )
             {
                 if ( $fh = @fopen( $catfile, 'r' ) )
                 {
                     fclose( $fh );
             
                     include( $catfile );
                     $this->catversion = $catversion;
                     $this->catdate    = $catdate;
                     $this->locales    = $locale;
                 }
             }
             */
         }
     }
     return $result;
 }
Example #15
0
 private function &_getElementStructure(&$element)
 {
     $result = false;
     $element_type = 'Hui' . strtolower($element['tag']);
     $element_name = '';
     $element_args = array();
     $element_children = array();
     // Parse the element definition
     //
     if (isset($element['children']) and is_array($element['children'])) {
         while (list(, $node) = each($element['children'])) {
             switch ($node['tag']) {
                 case 'NAME':
                     $element_name = $node['value'];
                     break;
                 case 'ARGS':
                     if (isset($node['children']) and is_array($node['children'])) {
                         while (list(, $arg) = each($node['children'])) {
                             $attrs = isset($arg['attributes']) ? $arg['attributes'] : '';
                             $type = 'text';
                             if (is_object($attrs) or is_array($attrs)) {
                                 while (list($attr, $value) = each($attrs)) {
                                     if ($attr == 'TYPE' and $value == 'array') {
                                         $type = 'array';
                                     }
                                     if ($attr == 'TYPE' and $value == 'encoded') {
                                         $type = 'encoded';
                                     }
                                 }
                             }
                             if ($type == 'array') {
                                 $value = huixml_decode($arg['value']);
                             } else {
                                 if ($type == 'encoded') {
                                     $value = urldecode($arg['value']);
                                 } else {
                                     $value = $arg['value'];
                                 }
                             }
                             $element_args[strtolower($arg['tag'])] = $value;
                         }
                     }
                     break;
                 case 'CHILDREN':
                     if (isset($node['children']) and is_array($node['children'])) {
                         while (list(, $child_node) = each($node['children'])) {
                             $relem =& $element_children[];
                             $relem['args'] = array();
                             if (strtolower($child_node['tag']) == 'huiobject') {
                                 $relem['element'] = unserialize(urldecode($child_node['value']));
                             } else {
                                 $relem['element'] =& $this->_GetElementStructure($child_node);
                             }
                             // Add not standard parameters
                             //
                             if (isset($child_node['attributes']) and is_array($child_node['attributes'])) {
                                 while (list($attr, $value) = each($child_node['attributes'])) {
                                     $relem['args'][strtolower($attr)] = $value;
                                 }
                             }
                         }
                     }
                     break;
             }
         }
     }
     if (!strlen($element_name)) {
         $element_name = $element_type . rand();
     }
     // Build element arguments array
     //
     while (list($key, $val) = each($element_args)) {
         $element_args[$key] = $val;
     }
     // Tries to load the widget if it wasn't loaded.
     //
     if (!class_exists($element_type)) {
         $widget_name = strtolower($element['tag']);
         if (!defined(strtoupper($widget_name . '_HUI')) and file_exists(HANDLER_PATH . $widget_name . '.hui')) {
             include_once HANDLER_PATH . $widget_name . '.hui';
         }
     }
     // Create the element and add children if any
     //
     if (class_exists($element_type)) {
         $result = new $element_type($element_name, $element_args);
         while (list(, $child_element) = each($element_children)) {
             if (isset($child_element['element']) and is_object($child_element['element'])) {
                 unset($tmp_array);
                 $tmp_array[] = $child_element['element'];
                 $args = array_merge($tmp_array, $child_element['args']);
                 call_user_func_array(array(&$result, 'AddChild'), $args);
             }
         }
     } else {
         import('com.solarix.ampoliros.io.log.Logger');
         $log = new Logger(AMP_LOG);
         $log->LogEvent('ampoliros.xml_hui.huixml_class._getelementstructure', 'Element of type ' . $element_type . ' is not defined', LOGGER_WARNING);
     }
     return $result;
 }
Example #16
0
 public function editUser($userdata)
 {
     $result = false;
     if ($this->userid != 0) {
         if (!empty($userdata['username']) & strlen($userdata['groupid']) > 0) {
             $upd = 'UPDATE users SET groupid = ' . $userdata['groupid'];
             $upd .= ', username = ' . $this->mrAmpDb->Format_Text($userdata['username']);
             $upd .= ', fname = ' . $this->mrAmpDb->Format_Text($userdata['fname']);
             $upd .= ', lname = ' . $this->mrAmpDb->Format_Text($userdata['lname']);
             $upd .= ', otherdata = ' . $this->mrAmpDb->Format_Text($userdata['otherdata']);
             $upd .= ', email = ' . $this->mrAmpDb->Format_Text($userdata['email']);
             $upd .= ' WHERE id=' . (int) $this->userid;
             //$this->htp->chpasswd( $userdata['username'], $userdata['password'] );
             unset($GLOBALS['gEnv']['runtime']['ampoliros']['users']['username_check'][(int) $this->userid]);
             unset($GLOBALS['gEnv']['runtime']['ampoliros']['users']['getgroup'][(int) $this->userid]);
             $result =& $this->mrAmpDb->Execute($upd);
             if (strlen($userdata['password'])) {
                 $this->ChPasswd($userdata['password']);
             }
         } else {
             import('com.solarix.ampoliros.io.log.Logger');
             $log = new Logger(AMP_LOG);
             $log->LogEvent('ampoliros.users_library.users_class.edituser', 'Empty username or group id', LOGGER_WARNING);
         }
     } else {
         import('com.solarix.ampoliros.io.log.Logger');
         $log = new Logger(AMP_LOG);
         $log->LogEvent('ampoliros.users_library.users_class.edituser', 'Invalid user id ' . $this->userid, LOGGER_WARNING);
     }
     return $result;
 }
 public function uninstall($elementData)
 {
     $result = FALSE;
     $filepath = $elementData['filepath'];
     if ($this->ampdb and file_exists($filepath)) {
         include $filepath;
         if ($element['type'] and $element['classname']) {
             $result = $this->ampdb->Execute('DELETE FROM elementtypes WHERE typename=' . $this->ampdb->Format_Text($element['type']));
         }
     } else {
         if (!file_exists($filepath)) {
             import('com.solarix.ampoliros.io.log.Logger');
             $log = new Logger(AMP_LOG);
             $log->LogEvent('ampoliros.modules_library.moduleelementfactory_class.uninstall', 'Given file (' . $filepath . ') does not exists', LOGGER_ERROR);
         }
     }
     return $result;
 }
Example #18
0
 *
 */
// $Id: unlock.php,v 1.16 2004-07-08 15:04:26 alex Exp $
define('AMPOLIROS_OVERRIDE_LOCK', TRUE);
require 'amproot.php';
require AMP_PATH . 'auth.php';
$amp = Ampoliros::instance('Ampoliros');
$amp->setInterface(Ampoliros::INTERFACE_WEB);
// Erase all semaphores
if ($handle = opendir(TMP_PATH . 'semaphores')) {
    while (($file = readdir($handle)) !== false) {
        if ($file != '.' and $file != '..') {
            @unlink(TMP_PATH . 'semaphores/' . $file);
        }
    }
    closedir($handle);
}
// Erase system upgrading lock if it exists
if (file_exists(AMP_UPGRADINGSYSTEM_LOCK)) {
    if (@unlink(AMP_UPGRADINGSYSTEM_LOCK)) {
        Carthag::import('com.solarix.ampoliros.io.log.Logger');
        $tmp_log = new Logger($gEnv['root']['log']);
        $tmp_log->LogEvent('Ampoliros', 'Ampoliros has been unlocked.', LOGGER_NOTICE);
        $message = 'System unlocked.';
    } else {
        $message = 'Unable to unlock system.';
    }
} else {
    $message = 'System was not locked.';
}
$amp->abort($message);
Example #19
0
function pass_setadvanced($eventData)
{
    global $gPage_status, $gLocale, $gEnv, $gState;
    $amp_state = '';
    switch ($eventData['ampstate']) {
        case Ampoliros::STATE_DEBUG:
            $amp_state_str = 'DEBUG';
            $amp_state = 'debug';
            $amp = Ampoliros::instance('Ampoliros');
            $amp->setState(Ampoliros::STATE_DEVELOPMENT);
            // Do not set it to DEBUG
            break;
        case Ampoliros::STATE_DEVELOPMENT:
            $amp_state_str = 'DEVELOPMENT';
            $amp_state = 'development';
            $amp = Ampoliros::instance('Ampoliros');
            $amp->setState(Ampoliros::STATE_DEVELOPMENT);
            break;
        case AMP_STATE_PRODUCTION:
            $amp_state_str = 'PRODUCTION';
            $amp_state = 'production';
            $amp = Ampoliros::instance('Ampoliros');
            $amp->setState(Ampoliros::STATE_PRODUCTION);
            break;
    }
    if (strlen($amp_state)) {
        $gState = $eventData['ampstate'];
        $log = new Logger($gEnv['root']['log']);
        $amp_cfg = new ConfigFile(AMP_CONFIG);
        $amp_cfg->SetValue('AMP_STATE', $amp_state);
        //$gEnv['core']['state'] = $eventData['ampstate'];
        $log->LogEvent('Ampoliros', 'Changed Ampoliros state to ' . $amp_state_str, LOGGER_NOTICE);
        $gPage_status = $gLocale->GetStr('advancedset.status');
        //$hui_page->mJavascript = 'parent.frames.sum.location.reload()';
    } else {
        $gPage_status = $gLocale->GetStr('advancednotset.status');
    }
}
Example #20
0
 public function getIconsSet()
 {
     $result = array();
     $cfg_file = new ConfigFile(CONFIG_PATH . $this->mSetName . '.huiiconsset');
     if ($cfg_file->Opened()) {
         $values = $cfg_file->ValuesArray();
         while (list($key, $val) = each($values)) {
             $key = trim($key);
             $val = trim($val);
             if (substr_count($key, '.') == 2) {
                 $tmpkey = strtolower(substr($key, strpos($key, '.') + 1));
                 $type = substr($tmpkey, 0, strpos($tmpkey, '.'));
                 $realkey = substr($tmpkey, strpos($tmpkey, '.') + 1);
                 $result[$type][$realkey]['file'] = $val;
                 $result[$type][$realkey]['base'] = $this->mSetName;
             }
         }
     } else {
         import('com.solarix.ampoliros.io.log.Logger');
         $log = new Logger(AMP_LOG);
         $log->LogEvent('ampoliros.huithemes_library.huistyle_class.getstyle', 'Unable to open icons set file ' . CONFIG_PATH . $this->mSetName . '.huiiconsset', LOGGER_ERROR);
     }
     return $result;
 }
Example #21
0
function pass_edit($eventData)
{
    global $hui_page;
    $log = new Logger(AMP_LOG);
    $ampcfg = new ConfigFile(AMP_CONFIG);
    $ampcfg->SetValue('AMP_NAME', $eventData['name']);
    $ampcfg->SetValue('AMP_DOMAIN', $eventData['domain']);
    $ampcfg->SetValue('AMP_DNS', $eventData['dns']);
    $log->LogEvent('Ampoliros', 'Changed Ampoliros network settings', LOGGER_NOTICE);
    $hui_page->mJavascript = 'parent.frames.header.location.reload()';
}
Example #22
0
 public function errorHandler($errorType, $errorMessage, $errorFile, $errorLine, $errorContext)
 {
     global $gEnv;
     $log_err[E_ERROR]['log'] = true;
     $log_err[E_ERROR]['die'] = true;
     $log_err[E_WARNING]['log'] = false;
     $log_err[E_WARNING]['die'] = false;
     $log_err[E_PARSE]['log'] = true;
     $log_err[E_PARSE]['die'] = false;
     $log_err[E_NOTICE]['log'] = false;
     $log_err[E_NOTICE]['die'] = false;
     $log_err[E_CORE_ERROR]['log'] = true;
     $log_err[E_CORE_ERROR]['die'] = true;
     $log_err[E_CORE_WARNING]['log'] = false;
     $log_err[E_CORE_WARNING]['die'] = false;
     $log_err[E_COMPILE_ERROR]['log'] = true;
     $log_err[E_COMPILE_ERROR]['die'] = true;
     $log_err[E_COMPILE_WARNING]['log'] = false;
     $log_err[E_COMPILE_WARNING]['die'] = false;
     $log_err[E_USER_ERROR]['log'] = true;
     $log_err[E_USER_ERROR]['die'] = true;
     $log_err[E_USER_WARNING]['log'] = false;
     $log_err[E_USER_WARNING]['die'] = false;
     $log_err[E_USER_NOTICE]['log'] = false;
     $log_err[E_USER_NOTICE]['die'] = false;
     switch ($this->state) {
         case Ampoliros::STATE_DEBUG:
             $log_err[E_NOTICE]['log'] = true;
             $log_err[E_USER_NOTICE]['log'] = true;
             $log_err[E_WARNING]['log'] = true;
             $log_err[E_CORE_WARNING]['log'] = true;
             $log_err[E_COMPILE_WARNING]['die'] = true;
             $log_err[E_USER_WARNING]['log'] = true;
             break;
         case Ampoliros::STATE_SETUP:
         case Ampoliros::STATE_DEVELOPMENT:
             $log_err[E_WARNING]['log'] = true;
             $log_err[E_CORE_WARNING]['log'] = true;
             $log_err[E_COMPILE_WARNING]['die'] = true;
             $log_err[E_USER_WARNING]['log'] = true;
             break;
         case Ampoliros::STATE_PRODUCTION:
         case Ampoliros::STATE_UPGRADE:
             break;
     }
     switch ($errorType) {
         case E_ERROR:
             if ($log_err[E_ERROR]['log']) {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger($gEnv['core']['error']['log']);
                 $log->LogEvent('Ampoliros error handler', 'PHP generated an ERROR at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage, LOGGER_FAILURE);
             }
             if ($log_err[E_ERROR]['die']) {
                 $this->abort('A fatal error occured at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage);
             }
             break;
         case E_WARNING:
             if ($log_err[E_WARNING]['log']) {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger($gEnv['core']['error']['log']);
                 $log->LogEvent('Ampoliros error handler', 'PHP generated a WARNING at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage, LOGGER_WARNING);
             }
             if ($log_err[E_WARNING]['die']) {
                 $this->abort('A warning occured at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage);
             }
             break;
         case E_PARSE:
             if ($log_err[E_PARSE]['log']) {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger($gEnv['core']['error']['log']);
                 $log->LogEvent('Ampoliros error handler', 'PHP generated a PARSE error at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage, LOGGER_ERROR);
             }
             if ($log_err[E_PARSE]['die']) {
                 $this->abort('A parse error occured at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage);
             }
             break;
         case E_NOTICE:
             if ($log_err[E_NOTICE]['log']) {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger($gEnv['core']['error']['log']);
                 $log->LogEvent('Ampoliros error handler', 'PHP generated a notice at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage, LOGGER_NOTICE);
             }
             if ($log_err[E_NOTICE]['die']) {
                 $this->abort('A notice occured at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage);
             }
             break;
         case E_CORE_ERROR:
             if ($log_err[E_CORE_ERROR]['log']) {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger($gEnv['core']['error']['log']);
                 $log->LogEvent('Ampoliros error handler', 'PHP generated a CORE ERROR at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage, LOGGER_ERROR);
             }
             if ($log_err[E_CORE_ERROR]['die']) {
                 $this->abort('A core error occured at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage);
             }
             break;
         case E_CORE_WARNING:
             if ($log_err[E_CORE_WARNING]['log']) {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger($gEnv['core']['error']['log']);
                 $log->LogEvent('Ampoliros error handler', 'PHP generated a CORE WARNING at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage, LOGGER_ERROR);
             }
             if ($log_err[E_CORE_WARNING]['die']) {
                 $this->abort('A core warning occured at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage);
             }
             break;
         case E_COMPILE_ERROR:
             if ($log_err[E_COMPILE_ERROR]['log']) {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger($gEnv['core']['error']['log']);
                 $log->LogEvent('Ampoliros error handler', 'PHP generated a COMPILE ERROR at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage, LOGGER_ERROR);
             }
             if ($log_err[E_COMPILE_ERROR]['die']) {
                 $this->abort('A compile error occured at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage);
             }
             break;
         case E_COMPILE_WARNING:
             if ($log_err[E_COMPILE_WARNING]['log']) {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger($gEnv['core']['error']['log']);
                 $log->LogEvent('Ampoliros error handler', 'PHP generated a COMPILE WARNING at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage, LOGGER_ERROR);
             }
             if ($log_err[E_COMPILE_WARNING]['die']) {
                 $this->abort('A compile warning occured at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage);
             }
             break;
         case E_USER_ERROR:
             if ($log_err[E_USER_ERROR]['log']) {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger($gEnv['core']['error']['log']);
                 $log->LogEvent('Ampoliros error handler', 'PHP generated an USER ERROR at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage, LOGGER_ERROR);
             }
             if ($log_err[E_USER_ERROR]['die']) {
                 $this->abort('An user error occured at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage);
             }
             break;
         case E_USER_WARNING:
             if ($log_err[E_USER_WARNING]['log']) {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger($gEnv['core']['error']['log']);
                 $log->LogEvent('Ampoliros error handler', 'PHP generated an USER WARNING at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage, LOGGER_ERROR);
             }
             if ($log_err[E_USER_WARNING]['die']) {
                 $this->abort('An user warning occured at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage);
             }
             break;
         case E_USER_NOTICE:
             if ($log_err[E_USER_NOTICE]['log']) {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger($gEnv['core']['error']['log']);
                 $log->LogEvent('Ampoliros error handler', 'PHP generated an USER NOTICE at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage, LOGGER_ERROR);
             }
             if ($log_err[E_USER_NOTICE]['die']) {
                 $this->abort('An user notice occured at line ' . $errorLine . ' of file ' . $errorFile . '. The error message was: ' . $errorMessage);
             }
             break;
         default:
             break;
     }
 }
Example #23
0
 function MergeStructureFiles($filea, $fileb, $tmpdir = '')
 {
     $result = array();
     if (file_exists($filea) and file_exists($fileb)) {
         // Load structure files
         //
         $deffilea = new XMLDefFile($this->ampdb, $tmpdir);
         $deffilea->Load_DefFile($filea);
         $structurea = $deffilea->Get_Structure();
         $deffileb = new XMLDefFile($this->ampdb);
         $deffileb->Load_DefFile($fileb);
         $structureb = $deffileb->Get_Structure();
         // Fill scripts array
         //
         $scripts = array();
         if (isset($structureb['generalpreinstall'])) {
             $scripts['generalpreinstall'] = $structureb['generalpreinstall'];
         }
         if (isset($structureb['generalpreuninstall'])) {
             $scripts['generalpreuninstall'] = $structureb['generalpreuninstall'];
         }
         if (isset($structureb['generalpostinstall'])) {
             $scripts['generalpostinstall'] = $structureb['generalpostinstall'];
         }
         if (isset($structureb['generalpostuninstall'])) {
             $scripts['generalpostuninstall'] = $structureb['generalpostuninstall'];
         }
         if (isset($structureb['sitepreinstall'])) {
             $scripts['sitepreinstall'] = $structureb['sitepreinstall'];
         }
         if (isset($structureb['sitepreuninstall'])) {
             $scripts['sitepreuninstall'] = $structureb['sitepreuninstall'];
         }
         if (isset($structureb['sitepostinstall'])) {
             $scripts['sitepostinstall'] = $structureb['sitepostinstall'];
         }
         if (isset($structureb['sitepostuninstall'])) {
             $scripts['sitepostuninstall'] = $structureb['sitepostuninstall'];
         }
         if (isset($structureb['generalpreupdate'])) {
             $scripts['generalpreupdate'] = $structureb['generalpreupdate'];
         }
         if (isset($structureb['generalpostupdate'])) {
             $scripts['generalpostupdate'] = $structureb['generalpostupdate'];
         }
         if (isset($structureb['sitepreupdate'])) {
             $scripts['sitepreupdate'] = $structureb['sitepreupdate'];
         }
         if (isset($structureb['sitepostupdate'])) {
             $scripts['sitepostupdate'] = $structureb['sitepostupdate'];
         }
         // Remove scripts and odd entries
         //
         while (list($key, $val) = each($structurea)) {
             if (!is_array($val)) {
                 unset($structurea[$key]);
             }
         }
         reset($structurea);
         while (list($key, $val) = each($structureb)) {
             if (!is_array($val)) {
                 unset($structureb[$key]);
             }
         }
         reset($structureb);
         $tmpstructure = array();
         // Scan structure a
         //
         while (list($eltypea, $arraycontenta) = each($structurea)) {
             if (isset($structureb[$eltypea])) {
                 // This element type is in both structures
                 //
                 $arraycontentb = $structureb[$eltypea];
                 reset($arraycontenta);
                 // Checks every element in current structure a element type
                 //
                 while (list($keya, $vala) = each($arraycontenta)) {
                     reset($arraycontentb);
                     $found = FALSE;
                     while (list($keyb, $valb) = each($arraycontentb)) {
                         if ($valb['file'] == $vala['file']) {
                             $found = TRUE;
                             $tmpkey = $keyb;
                         }
                     }
                     if ($found) {
                         // This element must be updated
                         //
                         $tmparray = array();
                         $tmparray = $vala;
                         $tmparray['updatemode'] = Module::UPDATE_MODE_CHANGE;
                         $tmpstructure[$eltypea][] = $tmparray;
                         unset($structurea[$eltypea][$keya]);
                         unset($structureb[$eltypea][$tmpkey]);
                     } else {
                         // This element must be added
                         //
                         $tmparray = array();
                         $tmparray = $vala;
                         $tmparray['updatemode'] = Module::UPDATE_MODE_ADD;
                         $tmpstructure[$eltypea][] = $tmparray;
                     }
                 }
             } else {
                 // It is a completely new element type for structure file b, so add it
                 //
                 array_walk($arraycontenta, array($this, '_elem_add'));
                 $tmpstructure[$eltypea] = $arraycontenta;
                 unset($structurea[$eltypea]);
             }
         }
         reset($structureb);
         // Scan structure b
         //
         while (list($eltypeb, $arraycontentb) = each($structureb)) {
             if (isset($structurea[$eltypeb])) {
                 // This element type is in both structures
                 //
                 $arraycontenta = $structurea[$eltypeb];
                 reset($arraycontentb);
                 // Check every remaining element in current structure b element type
                 //
                 while (list($keyb, $valb) = each($arraycontentb)) {
                     reset($arraycontenta);
                     $found = FALSE;
                     // This is just a check
                     //
                     while (list($keya, $vala) = each($arraycontenta)) {
                         if ($vala['file'] == $valb['file']) {
                             $found = TRUE;
                         }
                     }
                     if ($found) {
                         // Should never happen
                         //
                         $tmparray = array();
                         $tmparray = $valb;
                         $tmparray['updatemode'] = Module::UPDATE_MODE_CHANGE;
                         $tmpstructure[$eltypeb][] = $tmparray;
                     } else {
                         // This element must be removed
                         //
                         $tmparray = array();
                         $tmparray = $valb;
                         $tmparray['updatemode'] = Module::UPDATE_MODE_REMOVE;
                         $tmpstructure[$eltypeb][] = $tmparray;
                     }
                     if (isset($structurea[$eltypea][$keya])) {
                         unset($structurea[$eltypea][$keya]);
                     }
                     if (isset($structureb[$eltypea][$keya])) {
                         unset($structureb[$eltypea][$keya]);
                     }
                 }
             } else {
                 // It is a completely old element type for structure file b, so remove it
                 //
                 array_walk($arraycontentb, array($this, '_elem_remove'));
                 $tmpstructure[$eltypeb] = $arraycontentb;
             }
         }
         $result = array_merge($tmpstructure, $scripts);
     } else {
         import('com.solarix.ampoliros.io.log.Logger');
         $log = new Logger(AMP_LOG);
         if (!file_exists($filea)) {
             $log->LogEvent('ampoliros.modules_library.module_class.mergestructurefiles', 'Structure file ' . $filea . ' not found', LOGGER_ERROR);
         }
         if (!file_exists($fileb)) {
             $log->LogEvent('ampoliros.modules_library.module_class.mergestructurefiles', 'Structure file ' . $fileb . ' not found', LOGGER_ERROR);
         }
     }
     return $result;
 }
Example #24
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;
 }
Example #25
0
 public function update($updatemode, $params, $siteprescript = '', $sitepostscript = '')
 {
     $result = FALSE;
     if ($this->site) {
         $sitesquery = $this->ampdb->Execute('SELECT * FROM sites');
         $modquery = $this->ampdb->Execute('SELECT id FROM modules WHERE modid=' . $this->ampdb->Format_Text($this->modname));
         $modid = $modquery->Fields('id');
     }
     switch ($updatemode) {
         case Module::UPDATE_MODE_ADD:
             if ($this->DoInstallAction($params)) {
                 $result = TRUE;
                 if ($this->site) {
                     if ($sitesquery->NumRows() > 0) {
                         while (!$sitesquery->eof) {
                             $sitedata = $sitesquery->Fields();
                             $actquery = $this->ampdb->Execute('SELECT * FROM activemodules WHERE siteid=' . (int) $sitedata['id'] . ' AND moduleid=' . (int) $modid);
                             if ($actquery->NumRows()) {
                                 $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);
                                 if (!$this->Enable($sitesquery->Fields('id'), $params)) {
                                     $result = FALSE;
                                 }
                             }
                             $actquery->Free();
                             $sitesquery->MoveNext();
                         }
                     }
                 }
             }
             break;
         case Module::UPDATE_MODE_REMOVE:
             if ($this->DoUninstallAction($params)) {
                 $result = TRUE;
                 if ($this->site) {
                     if ($sitesquery->NumRows() > 0) {
                         while (!$sitesquery->eof) {
                             $sitedata = $sitesquery->Fields();
                             $actquery = $this->ampdb->Execute('SELECT * FROM activemodules WHERE siteid=' . (int) $sitedata['id'] . ' AND moduleid=' . (int) $modid);
                             if ($actquery->NumRows()) {
                                 $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);
                                 if (!$this->Disable($sitesquery->Fields('id'), $params)) {
                                     $result = FALSE;
                                 }
                             }
                             $actquery->Free();
                             $sitesquery->MoveNext();
                         }
                     }
                 }
             }
             break;
         case Module::UPDATE_MODE_CHANGE:
             if ($this->DoUpdateAction($params)) {
                 $result = TRUE;
                 if ($this->site) {
                     if ($sitesquery->NumRows() > 0) {
                         while (!$sitesquery->eof) {
                             $sitedata = $sitesquery->Fields();
                             $actquery = $this->ampdb->Execute('SELECT * FROM activemodules WHERE siteid=' . (int) $sitedata['id'] . ' AND moduleid=' . (int) $modid);
                             if ($actquery->NumRows()) {
                                 $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);
                                 if (strlen($siteprescript) and file_exists($siteprescript)) {
                                     include $siteprescript;
                                 }
                                 if (!$this->DoUpdateSiteAction($sitesquery->Fields('id'), $params)) {
                                     $result = FALSE;
                                 }
                                 if (strlen($sitepostscript) and file_exists($sitepostscript)) {
                                     include $sitepostscript;
                                 }
                             }
                             $actquery->Free();
                             $sitesquery->MoveNext();
                         }
                     }
                 }
             }
             break;
         default:
             import('com.solarix.ampoliros.io.log.Logger');
             $log = new Logger(AMP_LOG);
             $log->LogEvent('ampoliros.modules_library.moduleelement_class.update', 'Invalid update mode', LOGGER_ERROR);
             break;
     }
     if ($this->site) {
         $sitesquery->Free();
         $modquery->Free();
     }
     return $result;
 }
Example #26
0
 function dispatch()
 {
     if (!$this->mDispatched) {
         if (count($this->mEvents) and isset($GLOBALS['gEnv']['runtime']['disp']['hui'][$this->mName]['eventname']) and isset($this->mEvents[$GLOBALS['gEnv']['runtime']['disp']['hui'][$this->mName]['eventname']])) {
             if (function_exists($this->mEvents[$GLOBALS['gEnv']['runtime']['disp']['hui'][$this->mName]['eventname']])) {
                 $func = $this->mEvents[$GLOBALS['gEnv']['runtime']['disp']['hui'][$this->mName]['eventname']];
                 $func(isset($GLOBALS['gEnv']['runtime']['disp']['hui'][$this->mName]['eventdata']) ? $GLOBALS['gEnv']['runtime']['disp']['hui'][$this->mName]['eventdata'] : array());
                 return true;
             } else {
                 import('com.solarix.ampoliros.io.log.Logger');
                 $log = new Logger(AMP_LOG);
                 $log->LogEvent('ampoliros.hui_library.huidispatcher_class.dispatch', 'Function ' . $this->mEvents[$GLOBALS['gEnv']['runtime']['disp']['hui'][$this->mName]['eventname']] . " doesn't exists", LOGGER_ERROR);
                 return false;
             }
         }
     }
 }
Example #27
0
 public function render()
 {
     if (!$this->mBuilt) {
         $this->Build();
     }
     if ($this->mBuilt) {
         @header('P3P: CP="CUR ADM OUR NOR STA NID"');
         $carthag = Carthag::instance();
         $carthag->out->println($this->mLayout);
         return true;
     } else {
         import('com.solarix.ampoliros.io.log.Logger');
         $log = new Logger(AMP_LOG);
         $log->LogEvent('ampoliros.hui_library.hui_class.render', 'Unable to render hui', LOGGER_ERROR);
         $this->mLastError = Hui::RENDER_UNABLE_TO_RENDER;
     }
     return false;
 }