private function _pullConfigVariables() { $xmlHand = new class_xml(); // Load and read active config file $actConfig = $xmlHand->xml2array(ACTIVECONFIG); $actFileArray = $xmlHand->getValueByPath($actConfig, "config/file"); $actFile = $actFileArray['value']; // Load active Config $fileConfig = $xmlHand->xml2array(OPENSRSURI . OPENSRSCONFINGS . $actFile); $fileFileArray = $xmlHand->getValueByPath($fileConfig, "config/osrsFastLookup"); foreach ($fileFileArray as $ffa) { if ($ffa['name'] == "osrs_host" && isset($ffa['value'])) { $this->osrs_host = $ffa['value']; } if ($ffa['name'] == "osrs_port" && isset($ffa['value'])) { $this->osrs_port = $ffa['value']; } } if ($this->osrs_host == "" || $this->osrs_port == "") { if ($this->osrs_host == "") { trigger_error("oSRS Error - Incomplete config file - Missing osrs_host", E_USER_WARNING); } if ($this->osrs_port == "") { trigger_error("oSRS Error - Incomplete config file - Missing osrs_port", E_USER_WARNING); } die; } }
private function _pullConfigVariables() { $xmlHand = new class_xml(); // Load and read active config file $actConfig = $xmlHand->xml2array(ACTIVECONFIG); $actFileArray = $xmlHand->getValueByPath($actConfig, "config/file"); $actFile = $actFileArray['value']; // Load active Config $fileConfig = $xmlHand->xml2array(OPENSRSURI . OPENSRSCONFINGS . $actFile); $fileFileArray = $xmlHand->getValueByPath($fileConfig, "config/osrsEmail"); if ($fileFileArray == NULL) { trigger_error("oSRS-eMail Error - Could not fine the osrsEmail section in current config, please check your config file", E_USER_WARNING); } else { foreach ($fileFileArray as $ffa) { if ($ffa['name'] == "osrs_username" && isset($ffa['value'])) { $this->osrs_mailuser = $ffa['value']; } if ($ffa['name'] == "osrs_password" && isset($ffa['value'])) { $this->osrs_mailpassword = $ffa['value']; } if ($ffa['name'] == "osrs_domain" && isset($ffa['value'])) { $this->osrs_maildomain = $ffa['value']; } if ($ffa['name'] == "osrs_host" && isset($ffa['value'])) { $this->osrs_host = $ffa['value']; } if ($ffa['name'] == "osrs_port" && isset($ffa['value'])) { $this->osrs_port = $ffa['value']; } if ($ffa['name'] == "osrs_portwait" && isset($ffa['value'])) { $this->osrs_portwait = $ffa['value']; } if ($ffa['name'] == "osrs_processdelay" && isset($ffa['value'])) { $this->osrs_processdelay = $ffa['value']; } } // Verify all the variables if ($this->osrs_host == "" || $this->osrs_port == 0) { if ($this->osrs_host == "") { trigger_error("oSRS Error - Incomplete config file - Missing osrs_host", E_USER_WARNING); } if ($this->osrs_port == "") { trigger_error("oSRS Error - Incomplete config file - Missing osrs_port", E_USER_WARNING); } die; } } }
/** * Imports tasks from XML * * @access public * @param string $file Filename to import tasks from * @param bool $no_return Set to return true/false, instead of displaying results * @return void */ public function tasksImportFromXML($file = '', $no_return = 0) { /* INIT */ $file = $file ? $file : IPS_PUBLIC_PATH . 'resources/tasks.xml'; $inserted = 0; $updated = 0; $tasks = array(); /* Check to see if the file exists */ if (!file_exists($file)) { $this->registry->output->global_message = sprintf($this->lang->words['t_import404'], $file); $this->taskManagerOverview(); return; } /* Grab current tasks */ $this->DB->build(array('select' => '*', 'from' => 'task_manager')); $this->DB->execute(); while ($row = $this->DB->fetch()) { $tasks[$row['task_key']] = $row; } /* XML Class */ require_once IPS_KERNEL_PATH . 'class_xml.php'; $xml = new class_xml(); /* Read the xml file */ $skin_content = implode('', file($file)); /* Parse the xml file contents */ $xml->xml_parse_document($skin_content); /* Fix up */ if (!is_array($xml->xml_array['export']['group']['row'][0])) { /* Ensure [0] is populated */ $tmp = $xml->xml_array['export']['group']['row']; unset($xml->xml_array['export']['group']['row']); $xml->xml_array['export']['group']['row'][0] = $tmp; } /* Make sure we have some task data */ if (!is_array($xml->xml_array['export']['group']['row'][0]) or !count($xml->xml_array['export']['group']['row'][0])) { if ($no_return) { return FALSE; } else { $this->registry->output->global_message = $this->lang->words['t_noupdate']; $this->taskManagerOverview(); } } /* Loop through the tasks */ if (is_array($xml->xml_array['export']['group']['row']) and count($xml->xml_array['export']['group']['row'])) { foreach ($xml->xml_array['export']['group']['row'] as $id => $entry) { $newrow = array(); $_key = $entry['task_key']['VALUE']; foreach ($entry as $f => $data) { if ($f == 'VALUE' or $f == 'task_id') { continue; } if ($f == 'task_cronkey') { $entry[$f]['VALUE'] = $tasks[$_key]['task_cronkey'] ? $tasks[$_key]['task_cronkey'] : md5(uniqid(microtime())); } if ($f == 'task_next_run') { $entry[$f]['VALUE'] = $tasks[$_key]['task_next_run'] ? $tasks[$_key]['task_next_run'] : time(); } $newrow[$f] = $entry[$f]['VALUE']; } $newrow['task_description'] = $newrow['task_description'] ? $newrow['task_description'] : ''; if ($tasks[$_key]['task_key']) { $updated++; $this->DB->update('task_manager', $newrow, "task_key='" . $tasks[$_key]['task_key'] . "'"); } else { $inserted++; $this->DB->insert('task_manager', $newrow); } } } /* Return or Bounce */ if ($no_return) { $this->registry->output->global_message = sprintf($this->lang->words['t_inserted'], $inserted, $updated); return TRUE; } else { $this->registry->output->global_message = sprintf($this->lang->words['t_inserted'], $inserted, $updated); $this->taskManagerOverview(); } }
/** * If set to true, the output will be sent without the mandatory xml-head-element * * @param bool $bitSuppressXmlHeader * @return void */ public static function setBitSuppressXmlHeader($bitSuppressXmlHeader) { self::$bitRenderXmlHeader = !$bitSuppressXmlHeader; }
/** * Parse data * * @access protected * @param object Parser ref * @param string Tag name * @return @e void */ protected function _myDataElement(&$parser_obj, $data) { if ($this->tagname) { $this->stack[$this->array_id] = array('tag' => $this->tagname, 'type' => 'open', 'level' => $this->level, 'value' => class_xml::xmlUnconvertSafecdata($data), '_data' => 1); } //------------------------------- // Inc. array ID //------------------------------- $this->array_id++; }
/** * Exports the groups to a master XML file for distribution * * @access public * @return void [Outputs to screen] */ public function masterXMLExport() { //----------------------------------------- // INIT //----------------------------------------- $entry = array(); $skip = IPSLib::fetchNonDefaultGroupFields(); //----------------------------------------- // Get XML class //----------------------------------------- require_once IPS_KERNEL_PATH . 'class_xml.php'; $xml = new class_xml(); $xml->doc_type = IPS_DOC_CHAR_SET; $xml->xml_set_root('export', array('exported' => time())); //----------------------------------------- // Set group //----------------------------------------- $xml->xml_add_group('group'); //----------------------------------------- // Grab our default 6 groups //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'groups', 'order' => 'g_id ASC', 'limit' => array(0, 6))); $this->DB->execute(); while ($r = $this->DB->fetch()) { $content = array(); $r['g_icon'] = ''; //----------------------------------------- // Sort the fields... //----------------------------------------- foreach ($r as $k => $v) { if (!in_array($k, $skip)) { $content[] = $xml->xml_build_simple_tag($k, $v); } } $entry[] = $xml->xml_build_entry('row', $content); } $xml->xml_add_entry_to_group('group', $entry); $xml->xml_format_document(); //----------------------------------------- // Print to browser //----------------------------------------- $this->registry->output->showDownload($xml->xml_document, 'groups.xml', '', 0); }
/** * Export the settings * * @access private * @return void */ private function _finishExportingSettings() { $ids = array(); $groups = array(); //----------------------------------------- // get ids... //----------------------------------------- foreach ($_POST as $key => $value) { if (preg_match("/^id_(\\d+)\$/", $key, $match)) { if ($this->request[$match[0]]) { $ids[] = $match[1]; } } } $ids = IPSLib::cleanIntArray($ids); //----------------------------------------- // Got any? //----------------------------------------- if (!count($ids)) { $this->registry->output->global_message = $this->lang->words['s_sometoexport']; $this->_startExportingSettings(); return; } //----------------------------------------- // Get XML class //----------------------------------------- require_once IPS_KERNEL_PATH . 'class_xml.php'; $xml = new class_xml(); $xml->xml_set_root('settingexport', array('exported' => time())); //----------------------------------------- // Get groups //----------------------------------------- $xml->xml_add_group('settinggroup'); $this->_settingsGetGroups(); $entry = array(); $this->DB->build(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_id IN (" . implode(",", $ids) . ")", 'order' => 'conf_position, conf_title')); $this->DB->execute(); while ($r = $this->DB->fetch()) { $content = array(); $groups[$r['conf_group']] = $r['conf_group']; $r['conf_value'] = ''; //----------------------------------------- // Add in setting key //----------------------------------------- $r['conf_title_keyword'] = $this->setting_groups[$r['conf_group']]['conf_title_keyword']; foreach ($r as $k => $v) { $content[] = $xml->xml_build_simple_tag($k, $v); } $entry[] = $xml->xml_build_entry('setting', $content); } //----------------------------------------- // Add in groups... //----------------------------------------- if (is_array($groups) and count($groups)) { foreach ($groups as $conf_group_id) { $content = array(); $thisconf = array('conf_is_title' => 1, 'conf_title_keyword' => $this->setting_groups[$conf_group_id]['conf_title_keyword'], 'conf_title_title' => $this->setting_groups[$conf_group_id]['conf_title_title'], 'conf_title_desc' => $this->setting_groups[$conf_group_id]['conf_title_desc'], 'conf_title_noshow' => $this->setting_groups[$conf_group_id]['conf_title_noshow'], 'conf_title_module' => $this->setting_groups[$conf_group_id]['conf_title_module']); foreach ($thisconf as $k => $v) { $content[] = $xml->xml_build_simple_tag($k, $v); } $entry[] = $xml->xml_build_entry('setting', $content); } } $xml->xml_add_entry_to_group('settinggroup', $entry); $xml->xml_format_document(); $doc = $xml->xml_document; //----------------------------------------- // Print to browser //----------------------------------------- $this->registry->output->showDownload($doc, 'ipb_settings_partial.xml', '', 0); }
/** * Manage ACP restrictions - The meat and potatoes, so to speak * * @access private * @param string [member|group] * @return void * @since 2.1.0.2005-7-11 * @todo One of the only areas that still uses the old XML parser */ private function _restrictionsForm($type = 'member') { //------------------------------- // INIT //------------------------------- $row_id = $type == 'member' ? intval($this->request['mid']) : intval($this->request['gid']); $perms = array(); //------------------------------- // Check... //------------------------------- if (!$row_id) { $this->registry->output->global_message = sprintf($this->lang->words['r_notypeid'], $type); $this->_acppermsList(); return; } //------------------------------- // Grab member's row //------------------------------- $row = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'admin_permission_rows', 'where' => "row_id_type='{$type}' AND row_id=" . $row_id)); $row['current'] = unserialize($row['row_perm_cache']); if (!is_array($row['current']) or !count($row['current'])) { $row['current'] = array('applications' => array(), 'modules' => array(), 'items' => array()); } //------------------------------- // Grab XML library //------------------------------- require_once IPS_KERNEL_PATH . 'class_xml.php'; $xml = new class_xml(); //------------------------------- // Start the madness...err parsing //------------------------------- foreach (ipsRegistry::$applications as $app_dir => $app_data) { if (!is_array(ipsRegistry::$modules[$app_dir]) or !count(ipsRegistry::$modules[$app_dir])) { continue; } foreach (ipsRegistry::$modules[$app_dir] as $module) { $_file = IPSLib::getAppDir($app_dir) . '/modules_admin/' . $module['sys_module_key'] . '/xml/permissions.xml'; if (!$module['sys_module_admin']) { continue; } if (!file_exists($_file)) { continue; } $content = file_get_contents($_file); $xml->xml_parse_document($content); if (!is_array($xml->xml_array['permissions']['group'][0])) { //----------------------------------------- // Ensure [0] is populated //----------------------------------------- $xml->xml_array['permissions']['group'] = array(0 => $xml->xml_array['permissions']['group']); } //----------------------------------------- // Loop through and sort out permissions and groups... //----------------------------------------- $group = 0; foreach ($xml->xml_array['permissions']['group'] as $entry) { //----------------------------------------- // Do we have a row matching this already? //----------------------------------------- $_title = $entry['grouptitle']['VALUE']; $items = array(); $group++; if (is_array($entry['items']) and count($entry['items'])) { foreach ($entry['items'] as $item) { if (is_array($item) and count($item)) { if (isset($item['key'])) { $items[$item['key']['VALUE']] = $item['string']['VALUE']; } else { foreach ($item as $sub_item) { $items[$sub_item['key']['VALUE']] = $sub_item['string']['VALUE']; } } } } $perms[$app_data['app_id']][$module['sys_module_id']][$group]['title'] = $_title; $perms[$app_data['app_id']][$module['sys_module_id']][$group]['items'] = $items; } } } } //------------------------------- // Print //------------------------------- $this->registry->output->html .= $this->html->restrictionsForm($row_id, $type, $perms, $row['current']); }
/** * Install a login method * * @access private * @return void [Outputs to screen] */ private function _loginInstall() { //-------------------------------------------- // INIT //-------------------------------------------- require_once IPS_KERNEL_PATH . 'class_xml.php'; $xml = new class_xml(); $xml->doc_type = IPS_DOC_CHAR_SET; $login_id = basename(ipsRegistry::$request['login_folder']); //----------------------------------------- // Now get the XML data //----------------------------------------- $dh = opendir(IPS_PATH_CUSTOM_LOGIN); if ($dh !== false) { while (false !== ($file = readdir($dh))) { if (is_dir(IPS_PATH_CUSTOM_LOGIN . '/' . $file) and $file == $login_id) { if (file_exists(IPS_PATH_CUSTOM_LOGIN . '/' . $file . '/loginauth_install.xml')) { $file_content = file_get_contents(IPS_PATH_CUSTOM_LOGIN . '/' . $file . '/loginauth_install.xml'); $xml->xml_parse_document($file_content); if (is_array($xml->xml_array['export']['group']['row'])) { foreach ($xml->xml_array['export']['group']['row'] as $f => $entry) { if (is_array($entry)) { foreach ($entry as $k => $v) { if ($f == 'VALUE' or $f == 'login_id') { continue; } $data[$f] = $v; } } } } } else { closedir($dh); ipsRegistry::getClass('output')->global_message = $this->lang->words['l_installer404']; $this->_loginList(); return; } $dir_methods[$file] = $data; break; } } closedir($dh); } if (!is_array($dir_methods) or !count($dir_methods)) { ipsRegistry::getClass('output')->global_message = $this->lang->words['l_installer404']; $this->_loginList(); return; } //----------------------------------------- // Now verify it isn't installed //----------------------------------------- $login = $this->DB->buildAndFetch(array('select' => 'login_id', 'from' => 'login_methods', 'where' => "login_folder_name='" . $login_id . "'")); if ($login['login_id']) { ipsRegistry::getClass('output')->global_message = $this->lang->words['l_already']; $this->_loginList(); return; } //----------------------------------------- // Get the highest order and insert method //----------------------------------------- $max = $this->DB->buildAndFetch(array('select' => 'MAX(login_order) as highest_order', 'from' => 'login_methods')); $dir_methods[$login_id]['login_order'] = $max['highest_order'] + 1; $this->DB->insert('login_methods', $dir_methods[$login_id]); //----------------------------------------- // Recache //----------------------------------------- $this->loginsRecache(); ipsRegistry::getClass('output')->global_message = $this->lang->words['l_yesinstalled']; $this->_loginList(); }
/** * Builds the attachment type xml export * * @access public * @return void **/ public function attachmentTypeExport() { /* Get XML Class */ require_once IPS_KERNEL_PATH . 'class_xml.php'; $xml = new class_xml(); /* Set the root of the XML document */ $xml->xml_set_root('attachtypesexport'); /* Add the attachment type group */ $xml->xml_add_group('attachtypesgroup'); /* Query the attachment Types */ $this->DB->build(array('select' => 'atype_extension,atype_mimetype,atype_post,atype_photo,atype_img', 'from' => 'attachments_type', 'order' => "atype_extension")); $this->DB->execute(); /* Loop through the types */ $entry = array(); while ($r = $this->DB->fetch()) { /* INI */ $content = array(); /* Build the tag */ foreach ($r as $k => $v) { $content[] = $xml->xml_build_simple_tag($k, $v); } /* Add to the entry */ $entry[] = $xml->xml_build_entry('attachtype', $content); } /* Add entries to the group and build the document */ $xml->xml_add_entry_to_group('attachtypesgroup', $entry); $xml->xml_format_document(); /* Send for download */ $this->registry->output->showDownload($xml->xml_document, 'attachments.xml', "unknown/unknown", false); }
/** * Enable the converter's login method * * @access private * @return void */ private function enableLogin() { //-------------------------------------------- // INIT //-------------------------------------------- require_once IPS_KERNEL_PATH . 'class_xml.php'; $xml = new class_xml(); $xml->doc_type = IPS_DOC_CHAR_SET; $login_id = basename('convert'); //----------------------------------------- // Now get the XML data //----------------------------------------- $dh = opendir(IPS_PATH_CUSTOM_LOGIN); if ($dh !== false) { while (false !== ($file = readdir($dh))) { if (is_dir(IPS_PATH_CUSTOM_LOGIN . '/' . $file) and $file == $login_id) { if (file_exists(IPS_PATH_CUSTOM_LOGIN . '/' . $file . '/loginauth_install.xml')) { $file_content = file_get_contents(IPS_PATH_CUSTOM_LOGIN . '/' . $file . '/loginauth_install.xml'); $xml->xml_parse_document($file_content); if (is_array($xml->xml_array['export']['group']['row'])) { foreach ($xml->xml_array['export']['group']['row'] as $f => $entry) { if (is_array($entry)) { foreach ($entry as $k => $v) { if ($f == 'VALUE' or $f == 'login_id') { continue; } $data[$f] = $v; } } } } } else { ipsRegistry::getClass('output')->showError('Could not locate login method.'); } $dir_methods[$file] = $data; break; } } closedir($dh); } if (!is_array($dir_methods) or !count($dir_methods)) { ipsRegistry::getClass('output')->showError('An error occured while trying to enable the converter login method.'); } //----------------------------------------- // Now verify it isn't installed //----------------------------------------- $login = $this->DB->buildAndFetch(array('select' => 'login_id', 'from' => 'login_methods', 'where' => "login_folder_name='" . $login_id . "'")); if (!$login['login_id']) { $max = $this->DB->buildAndFetch(array('select' => 'MAX(login_order) as highest_order', 'from' => 'login_methods')); $dir_methods[$login_id]['login_order'] = $max['highest_order'] + 1; $dir_methods[$login_id]['login_enabled'] = 1; $this->DB->insert('login_methods', $dir_methods[$login_id]); } else { $this->DB->update('login_methods', array('login_enabled' => 1), 'login_id=' . $login['login_id']); } //----------------------------------------- // Recache //----------------------------------------- $cache = array(); $this->DB->build(array('select' => '*', 'from' => 'login_methods', 'where' => 'login_enabled=1')); $this->DB->execute(); while ($r = $this->DB->fetch()) { $cache[$r['login_id']] = $r; } ipsRegistry::cache()->setCache('login_methods', $cache, array('array' => 1, 'deletefirst' => 1)); //----------------------------------------- // Switch //----------------------------------------- IPSLib::updateSettings(array('conv_login' => 1)); }
private function _pullConfigVariables() { $xmlHand = new class_xml(); // Load and read active config file $actConfig = $xmlHand->xml2array(ACTIVECONFIG); if ($actConfig != false) { $actFileArray = $xmlHand->getValueByPath($actConfig, "config/file"); $actFile = $actFileArray['value']; // Load active Config $fileConfig = $xmlHand->xml2array(OPENSRSURI . OPENSRSCONFINGS . $actFile); if ($fileConfig != false) { $fileFileArray = $xmlHand->getValueByPath($fileConfig, "config/osrsRegular"); foreach ($fileFileArray as $ffa) { if ($ffa['name'] == "osrs_username" && isset($ffa['value'])) { $this->osrs_username = $ffa['value']; } if ($ffa['name'] == "osrs_password" && isset($ffa['value'])) { $this->osrs_password = $ffa['value']; } if ($ffa['name'] == "osrs_key" && isset($ffa['value'])) { $this->osrs_key = $ffa['value']; } if ($ffa['name'] == "osrs_environment" && isset($ffa['value'])) { $this->osrs_environment = $ffa['value']; } if ($ffa['name'] == "osrs_protocol" && isset($ffa['value'])) { $this->osrs_protocol = $ffa['value']; } if ($ffa['name'] == "osrs_host" && isset($ffa['value'])) { $this->osrs_host = $ffa['value']; } if ($ffa['name'] == "osrs_port" && isset($ffa['value'])) { $this->osrs_port = $ffa['value']; } if ($ffa['name'] == "osrs_sslPort" && isset($ffa['value'])) { $this->osrs_sslPort = $ffa['value']; } if ($ffa['name'] == "osrs_baseClassVersion" && isset($ffa['value'])) { $this->osrs_baseClassVersion = $ffa['value']; } if ($ffa['name'] == "osrs_version" && isset($ffa['value'])) { $this->osrs_version = $ffa['value']; } } // Verify all the variables if ($this->osrs_username == "" || $this->osrs_key == "" || $this->osrs_environment == "" || $this->osrs_protocol == "") { if ($this->osrs_username == "") { trigger_error("oSRS Error - Incomplete config file - Missing osrs_username", E_USER_WARNING); } if ($this->osrs_key == "") { trigger_error("oSRS Error - Incomplete config file - Missing osrs_key", E_USER_WARNING); } if ($this->osrs_environment == "") { trigger_error("oSRS Error - Incomplete config file - Missing osrs_environment", E_USER_WARNING); } if ($this->osrs_protocol == "") { trigger_error("oSRS Error - Incomplete config file - Missing osrs_protocol", E_USER_WARNING); } die; } if ($this->osrs_host == "" || $this->osrs_port == "" || $this->osrs_sslPort == "" || $this->osrs_baseClassVersion == "" || $this->osrs_version == "") { if ($this->osrs_host == "") { trigger_error("oSRS Error - Incomplete config file - Missing osrs_host", E_USER_WARNING); } if ($this->osrs_port == "") { trigger_error("oSRS Error - Incomplete config file - Missing osrs_port", E_USER_WARNING); } if ($this->osrs_sslPort == "") { trigger_error("oSRS Error - Incomplete config file - Missing osrs_sslPort", E_USER_WARNING); } if ($this->osrs_baseClassVersion == "") { trigger_error("oSRS Error - Incomplete config file - Missing osrs_baseClassVersion", E_USER_WARNING); } if ($this->osrs_version == "") { trigger_error("oSRS Error - Incomplete config file - Missing osrs_version", E_USER_WARNING); } die; } // Some variables should be in upper case if ($this->osrs_environment != "") { $this->osrs_environment = strtoupper($this->osrs_environment); } if ($this->osrs_protocol) { $this->osrs_protocol = strtoupper($this->osrs_protocol); } } } }