/** * 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(); } }
/** * 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']); }
/** * Imports attachment types from an xml document * * @access public * @return void **/ public function attachmentTypeImport() { /* Get the XML Content */ $content = $this->registry->adminFunctions->importXml('ipb_attachtypes.xml'); /* Check to make sure we have content */ if (!$content) { $this->registry->output->global_message = $this->lang->words['ty_failed']; $this->attachmentTypesOverview(); } /* Get the XML class */ require_once IPS_KERNEL_PATH . 'class_xml.php'; $xml = new class_xml(); /* Parse the XML document */ $xml->xml_parse_document($content); /* Get a list of the types already installed */ $types = array(); $this->DB->build(array('select' => '*', 'from' => 'attachments_type', 'order' => "atype_extension")); $this->DB->execute(); while ($r = $this->DB->fetch()) { $types[$r['atype_extension']] = 1; } /* Loop through the xml document and insert new types */ foreach ($xml->xml_array['attachtypesexport']['attachtypesgroup']['attachtype'] as $entry) { /* Build the insert array */ $insert_array = array('atype_extension' => $entry['atype_extension']['VALUE'], 'atype_mimetype' => $entry['atype_mimetype']['VALUE'], 'atype_post' => $entry['atype_post']['VALUE'], 'atype_photo' => $entry['atype_photo']['VALUE'], 'atype_img' => $entry['atype_img']['VALUE']); /* Bypass if this type has already been added */ if ($types[$entry['atype_extension']['VALUE']]) { continue; } /* Insert the new type */ if ($entry['atype_extension']['VALUE'] and $entry['atype_mimetype']['VALUE']) { $this->DB->insert('attachments_type', $insert_array); } } /* Rebuild the cache and bounce */ $this->attachmentTypeCacheRebuild(); $this->registry->output->global_message = $this->lang->words['ty_imported']; $this->attachmentTypesOverview(); }
/** * 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(); }
/** * 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)); }