/**
  * Export a mediaTag XML file
  *
  * @access	private
  * @return	void		[Outputs to screen]
  */
 private function _mediaTagExport()
 {
     //-----------------------------------------
     // Get xml mah-do-dah
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXML.php';
     $xml = new classXML(IPS_DOC_CHAR_SET);
     $xml->newXMLDocument();
     $xml->addElement('mediatagexport');
     $xml->addElement('mediataggroup', 'mediatagexport');
     $select = array('select' => '*', 'from' => 'bbcode_mediatag');
     if ($this->request['id']) {
         $select['where'] = 'mediatag_id=' . intval($this->request['id']);
     }
     $this->DB->build($select);
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $xml->addElementAsRecord('mediataggroup', 'mediatag', $r);
     }
     $xmlData = $xml->fetchDocument();
     //-----------------------------------------
     // Send to browser.
     //-----------------------------------------
     $this->registry->output->showDownload($xmlData, 'mediatag.xml', '', 0);
 }
Esempio n. 2
0
 /**
  * Build XML file from array of data
  *
  * @param	array 		Entries to add
  * @return	string		XML Document
  */
 protected function _buildXML($data = array())
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $entry = array();
     //-----------------------------------------
     // Get XML class
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXML.php';
     /*noLibHook*/
     $xml = new classXML(IPS_DOC_CHAR_SET);
     $xml->newXMLDocument();
     $xml->addElement('export');
     $xml->addElement('group', 'export');
     //-----------------------------------------
     // Set group
     //-----------------------------------------
     foreach ($data as $thisentry => $r) {
         $r['login_enabled'] = 0;
         if ($r['login_folder_name'] == 'internal') {
             $r['login_enabled'] = 1;
         }
         unset($r['login_id']);
         $xml->addElementAsRecord('group', 'row', $r);
     }
     return $xml->fetchDocument();
 }
 /**
  * Export language entries to xml file
  *
  * @param	integer	$lang_id	Language pack to export
  * @param	bool	$disk		Save to disk instead
  * @return void
  */
 public function languageExportToXML($lang_id, $disk = false)
 {
     //-----------------------------------------
     // Init
     //-----------------------------------------
     $app_dir = trim($this->request['app_dir']);
     $type = trim($this->request['type']);
     $_where = '';
     $_name = 'language.xml';
     $LATESTVERSION = IPSLib::fetchVersionNumber();
     $doPack = true;
     //-----------------------------------------
     // Filter
     //-----------------------------------------
     if ($app_dir) {
         $_where = " AND word_app='" . $app_dir . "'";
         $_name = $app_dir . '_language_pack.xml';
         $doPack = false;
     }
     if ($type) {
         if ($type == 'admin') {
             $_where .= " AND word_pack LIKE 'admin_%'";
             $_name = 'admin_' . $_name;
         } else {
             $_where .= " AND word_pack LIKE 'public_%'";
             $_name = 'public_' . $_name;
         }
         $doPack = false;
     }
     //-----------------------------------------
     // Create the XML library
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXML.php';
     /*noLibHook*/
     $xml = new classXML(IPS_DOC_CHAR_SET);
     $xml->newXMLDocument();
     $xml->addElement('languageexport');
     $xml->addElement('languagegroup', 'languageexport');
     //-----------------------------------------
     // Get language pack
     //-----------------------------------------
     $data = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_sys_lang', 'where' => "lang_id={$lang_id}"));
     //-----------------------------------------
     // Add pack if necessary
     //-----------------------------------------
     if ($doPack) {
         $xml->addElementAsRecord('languagegroup', 'langinfo', $data);
     }
     //-----------------------------------------
     // Get the words
     //-----------------------------------------
     $this->DB->build(array('select' => '*', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$lang_id}" . $_where));
     $this->DB->execute();
     //-----------------------------------------
     // Add words to export
     //-----------------------------------------
     $word_packs = array();
     $_strings = 0;
     while ($r = $this->DB->fetch()) {
         $content = array();
         $_strings++;
         if ($disk) {
             $content = array('word_app' => $r['word_app'], 'word_pack' => $r['word_pack'], 'word_key' => $r['word_key'], 'word_default' => $r['word_default']);
             if ($r['word_js']) {
                 $content['word_js'] = $r['word_js'];
             }
         } else {
             $content = array('word_app' => $r['word_app'], 'word_pack' => $r['word_pack'], 'word_key' => $r['word_key'], 'word_default' => $r['word_default'], 'word_custom' => $r['word_custom'], 'word_default_version' => $r['word_default_version'] >= 30000 ? $r['word_default_version'] : $LATESTVERSION['long'], 'word_custom_version' => $r['word_custom_version'], 'word_js' => $r['word_js']);
         }
         $xml->addElementAsRecord('languagegroup', 'lang', $content);
     }
     //-----------------------------------------
     // Got any strings?
     //-----------------------------------------
     if (!$_strings) {
         if ($disk) {
             return false;
         } else {
             $this->registry->output->global_message = $this->lang->words['l_nolangbits'];
             $this->languagesList();
             return;
         }
     }
     //-----------------------------------------
     // Write to disk or output to browser
     //-----------------------------------------
     if ($disk) {
         @unlink(IPSLib::getAppDir($app_dir) . '/xml/' . $_name);
         @file_put_contents(IPSLib::getAppDir($app_dir) . '/xml/' . $_name, $xml->fetchDocument());
         return true;
     } else {
         //-----------------------------------------
         // Create xml archive
         //-----------------------------------------
         require_once IPS_KERNEL_PATH . 'classXMLArchive.php';
         /*noLibHook*/
         $xmlArchive = new classXMLArchive();
         //-----------------------------------------
         // Add XML document
         //-----------------------------------------
         $xmlArchive->add($xml->fetchDocument(), 'language_entries.xml');
         //-----------------------------------------
         // Print to browser
         //-----------------------------------------
         $this->registry->output->showDownload($xmlArchive->getArchiveContents(), $_name);
         exit;
     }
 }
Esempio n. 4
0
 /**
  * Exports the groups to a master XML file for distribution
  *
  * @return	@e void		[Outputs to screen]
  */
 public function masterXMLExport()
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $entry = array();
     $skip = IPSLib::fetchNonDefaultGroupFields();
     //-----------------------------------------
     // Get xml class
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXML.php';
     /*noLibHook*/
     $xml = new classXML(IPS_DOC_CHAR_SET);
     $xml->newXMLDocument();
     $xml->addElement('export');
     $xml->addElement('group', 'export');
     //-----------------------------------------
     // 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'] = '';
         if (is_array($skip) and count($skip)) {
             foreach ($skip as $_kk) {
                 unset($r[$_kk]);
             }
         }
         $xml->addElementAsRecord('group', 'row', $r);
     }
     //-----------------------------------------
     // Print to browser
     //-----------------------------------------
     $this->registry->output->showDownload($xml->fetchDocument(), 'groups.xml', '', 0);
 }
Esempio n. 5
0
 /**
  * Export tasks to XML
  *
  * @return	@e void
  */
 public function tasksExportToXML()
 {
     /* INIT */
     $entry = array();
     require_once IPS_KERNEL_PATH . 'classXML.php';
     /*noLibHook*/
     /* Loop through all the applications */
     foreach ($this->registry->getApplications() as $app => $__data) {
         $_c = 0;
         $xml = new classXML(IPS_DOC_CHAR_SET);
         $xml->newXMLDocument();
         $xml->addElement('export');
         $xml->addElement('group', 'export');
         /* Query tasks */
         $this->DB->build(array('select' => '*', 'from' => 'task_manager', 'where' => "task_application='{$app}'"));
         $this->DB->execute();
         /* Loop through and add tasks to XML */
         while ($r = $this->DB->fetch()) {
             $_c++;
             $xml->addElementAsRecord('group', 'row', $r);
         }
         /* Finish XML */
         $doc = $xml->fetchDocument();
         /* Write */
         if ($doc and $_c) {
             file_put_contents(IPSLib::getAppDir($app) . '/xml/' . $app . '_tasks.xml', $doc);
         }
     }
     $this->registry->output->setMessage($this->lang->words['t_exported'], 1);
     $this->taskManagerOverview();
 }
 /**
  * Export skin templates from a plugin block
  *
  * @access	protected
  * @return	void
  */
 protected function _exportBlock()
 {
     $id = preg_replace("#[^a-zA-Z0-9_\\-]#", "", $this->request['block']);
     if (!$id) {
         $this->registry->output->showError($this->lang->words['noblock_export']);
     }
     //-----------------------------------------
     // Build default block templates for release
     //-----------------------------------------
     if ($id == '_all_') {
         require_once IPS_KERNEL_PATH . 'classXml.php';
         $xml = new classXML(IPS_DOC_CHAR_SET);
         $xml->newXMLDocument();
         $xml->addElement('blockexport');
         $xml->addElement('blocktemplate', 'blockexport');
         $this->DB->build(array('select' => '*', 'from' => 'ccs_template_blocks'));
         $outer = $this->DB->execute();
         while ($r = $this->DB->fetch($outer)) {
             if (!preg_match("/_(\\d+)\$/", $r['tpb_name'])) {
                 $xml->addElementAsRecord('blocktemplate', 'template', $r);
             }
         }
         $this->registry->output->showDownload($xml->fetchDocument(), 'block_templates.xml', '', 0);
         exit;
     }
     //-----------------------------------------
     // Allow exporting of single block templates
     //-----------------------------------------
     require_once IPSLib::getAppDir('ccs') . '/sources/blocks/plugin/pluginInterface.php';
     require_once IPSLib::getAppDir('ccs') . '/sources/blocks/plugin/' . $id . '/plugin.php';
     $_className = "plugin_" . $id;
     $_class = new $_className($this->registry);
     $_pluginConfig = $_class->returnPluginInfo();
     if (!$_pluginConfig['templateBit']) {
         $this->registry->output->showError($this->lang->words['nothingto_export']);
     }
     $template = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'ccs_template_blocks', 'where' => "tpb_name='{$_pluginConfig['templateBit']}'"));
     if (!$template['tpb_id']) {
         $this->registry->output->showError($this->lang->words['couldnot_find_export']);
     }
     require_once IPS_KERNEL_PATH . 'classXml.php';
     $xml = new classXML(IPS_DOC_CHAR_SET);
     $xml->newXMLDocument();
     $xml->addElement('blockexport');
     $xml->addElement('blocktemplate', 'blockexport');
     $xml->addElementAsRecord('blocktemplate', 'template', $template);
     $this->registry->output->showDownload($xml->fetchDocument(), 'block_' . $_pluginConfig['key'] . '.xml', '', 0);
 }
Esempio n. 7
0
 /**
  * Sends forum data in xml format
  *
  * @param	array	$dataArray
  * @return	@e void
  */
 protected function _returnXml($dataArray)
 {
     /* XML Parser */
     require_once IPS_KERNEL_PATH . 'classXML.php';
     /*noLibHook*/
     $xml = new classXML('utf-8');
     $xml->newXMLDocument();
     /* Build Document */
     $xml->addElement('forum');
     $xml->addElementAsRecord('forum', 'capabilites', array('gallery' => $dataArray['gallery']));
     $xml->addElementAsRecord('forum', 'capabilites', array('facebook' => $dataArray['facebook']));
     $xml->addElementAsRecord('forum', 'capabilites', array('twitter' => $dataArray['twitter']));
     $xml->addElementAsRecord('forum', 'capabilites', array('status' => $dataArray['status']));
     $xml->addElementAsRecord('forum', 'capabilites', array('notifications' => $dataArray['notifications']));
     $xml->addElement('albums', 'forum');
     $xml->addElementAsRecord('forum', 'security', array('form_hash' => $dataArray['form_hash']));
     /* Loop through albums */
     if (is_array($dataArray['albums']) && count($dataArray['albums'])) {
         foreach ($dataArray['albums'] as $r) {
             $xml->addElementAsRecord('albums', array('album'), array('id' => $r['id'], 'name' => $r['name']));
         }
     }
     $xml->addElementAsRecord('forum', 'version', array('version_id' => $dataArray['version_id']));
     $xml->addElementAsRecord('forum', 'version', array('version_text' => $dataArray['version_text']));
     /* Output */
     echo $xml->fetchDocument();
     exit;
 }
Esempio n. 8
0
 /**
  * Exports badwords to an xml file
  *
  * @return	@e void
  */
 public function badwordsExport()
 {
     //-----------------------------------------
     // Get xml class
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXML.php';
     /*noLibHook*/
     $xml = new classXML(IPS_DOC_CHAR_SET);
     $xml->newXMLDocument();
     $xml->addElement('badwordexport');
     $xml->addElement('badwordgroup', 'badwordexport');
     /* Query the badwords */
     $this->DB->build(array('select' => 'type, swop, m_exact', 'from' => 'badwords', 'order' => 'type'));
     $this->DB->execute();
     /* Add the bad word entries to the xml file */
     while ($r = $this->DB->fetch()) {
         $xml->addElementAsRecord('badwordgroup', 'badword', $r);
     }
     /* Create the xml document and send to the browser */
     $xmlData = $xml->fetchDocument();
     $this->registry->output->showDownload($xmlData, 'ipb_badwords.xml');
 }
 /**
  * Actually export the damn hook already
  * Sorry, it has been a long day...
  *
  * @access	private
  * @return	void
  */
 private function _doExportHook()
 {
     //-----------------------------------------
     // Get hook
     //-----------------------------------------
     $id = intval($this->request['id']);
     if (!$id) {
         $this->registry->output->showError($this->lang->words['h_noexport'], 1114);
     }
     $hookData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id));
     if (!$hookData['hook_id']) {
         $this->registry->output->showError($this->lang->words['h_noexport'], 1115);
     }
     $extra_data = unserialize($hookData['hook_extra_data']);
     //-----------------------------------------
     // Get hook files
     //-----------------------------------------
     $files = array();
     $index = 1;
     $this->DB->build(array('select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $id));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $files[$index] = $r;
         $index++;
     }
     //-----------------------------------------
     // Get XML class
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXML.php';
     $xml = new classXML(IPS_DOC_CHAR_SET);
     $xml->newXMLDocument();
     $xml->addElement('hookexport');
     //-----------------------------------------
     // Put hook data in export
     //-----------------------------------------
     $xml->addElement('hookdata', 'hookexport');
     $content = array();
     foreach ($hookData as $k => $v) {
         if (in_array($k, array('hook_id', 'hook_enabled', 'hook_installed', 'hook_updated', 'hook_position'))) {
             continue;
         }
         $content[$k] = $v;
     }
     $xml->addElementAsRecord('hookdata', 'config', $content);
     //-----------------------------------------
     // Put hook files in export
     //-----------------------------------------
     $xml->addElement('hookfiles', 'hookexport');
     foreach ($files as $index => $r) {
         $content = array();
         foreach ($r as $k => $v) {
             if (in_array($k, array('hook_file_id', 'hook_hook_id', 'hook_file_stored', 'hooks_source'))) {
                 continue;
             }
             $content[$k] = $v;
         }
         $source = file_exists(IPS_HOOKS_PATH . $r['hook_file_stored']) ? file_get_contents(IPS_HOOKS_PATH . $r['hook_file_stored']) : '';
         if ($r['hook_type'] == 'commandHooks') {
             $source = $this->_cleanSource($source);
         }
         $content['hooks_source'] = $source;
         $xml->addElementAsRecord('hookfiles', 'file', $content);
     }
     //-----------------------------------------
     // Custom install/uninstall script?
     //-----------------------------------------
     if ($extra_data['custom']) {
         $content = array();
         $xml->addElement('hookextras_custom', 'hookexport');
         $content['filename'] = $extra_data['custom'];
         $content['source'] = file_exists(IPS_HOOKS_PATH . 'install_' . $extra_data['custom']) ? file_get_contents(IPS_HOOKS_PATH . 'install_' . $extra_data['custom']) : '';
         $xml->addElementAsRecord('hookextras_custom', 'file', $content);
     }
     //-----------------------------------------
     // Settings or setting groups?
     //-----------------------------------------
     $entry = array();
     $_groups = array();
     $_settings = array();
     $titles = array();
     $content = array();
     $xml->addElement('hookextras_settings', 'hookexport');
     # Store group ids and setting ids for entire setting groups
     if (is_array($extra_data['settingGroups']) and count($extra_data['settingGroups'])) {
         $_groups = $extra_data['settingGroups'];
         $this->DB->build(array('select' => 'conf_id', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group IN(' . implode(',', $_groups) . ')'));
         $this->DB->execute();
         while ($setting = $this->DB->fetch()) {
             $_settings[] = $setting['conf_id'];
         }
     }
     # Store group ids and setting ids for indvidual settings
     if (is_array($extra_data['settings']) and count($extra_data['settings'])) {
         foreach ($extra_data['settings'] as $settingId) {
             $_settings[] = $settingId;
         }
         $this->DB->build(array('select' => 'conf_group', 'from' => 'core_sys_conf_settings', 'where' => 'conf_id IN(' . implode(',', $extra_data['settings']) . ')'));
         $this->DB->execute();
         while ($group = $this->DB->fetch()) {
             $_groups[] = $group['conf_group'];
         }
     }
     if (count($_groups)) {
         # Now get the group data for the XML file
         $this->DB->build(array('select' => '*', 'from' => 'core_sys_settings_titles', 'where' => 'conf_title_id IN(' . implode(',', $_groups) . ')'));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             $content = array();
             $titles[$r['conf_title_id']] = $r['conf_title_keyword'];
             $content['conf_is_title'] = 1;
             foreach ($r as $k => $v) {
                 if (in_array($k, array('conf_title_tab', 'conf_title_keyword', 'conf_title_title', 'conf_title_desc', 'conf_title_app', 'conf_title_noshow'))) {
                     $content[$k] = $v;
                 }
             }
             $xml->addElementAsRecord('hookextras_settings', 'setting', $content);
         }
     }
     if (count($_settings)) {
         # Now get the group data for the XML file
         $this->DB->build(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => 'conf_id IN(' . implode(',', $_settings) . ')'));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             $r['conf_value'] = '';
             $r['conf_title_keyword'] = $titles[$r['conf_group']];
             $r['conf_is_title'] = 0;
             $xml->addElementAsRecord('hookextras_settings', 'setting', $r);
         }
     }
     //-----------------------------------------
     // Language strings/files
     //-----------------------------------------
     $entry = array();
     $xml->addElement('hookextras_language', 'hookexport');
     if (is_array($extra_data['language']) and count($extra_data['language'])) {
         foreach ($extra_data['language'] as $file => $strings) {
             $this->DB->build(array('select' => '*', 'from' => 'core_sys_lang_words', 'where' => "word_pack='{$file}' AND word_key IN('" . implode("','", $strings) . "')"));
             $this->DB->execute();
             while ($r = $this->DB->fetch()) {
                 $content = array();
                 foreach ($r as $k => $v) {
                     if (in_array($k, array('word_id', 'lang_id', 'word_default_version', 'word_custom_version'))) {
                         continue;
                     }
                     $content[$k] = $v;
                 }
                 $xml->addElementAsRecord('hookextras_language', 'language', $content);
             }
         }
     }
     //-----------------------------------------
     // Modules
     //-----------------------------------------
     $xml->addElement('hookextras_modules', 'hookexport');
     if (is_array($extra_data['modules']) and count($extra_data['modules'])) {
         $this->DB->build(array('select' => '*', 'from' => 'core_sys_module', 'where' => "sys_module_key IN('" . implode("','", $extra_data['modules']) . "')"));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             unset($r['sys_module_id']);
             $xml->addElementAsRecord('hookextras_modules', 'module', $r);
         }
     }
     //-----------------------------------------
     // Help files
     //-----------------------------------------
     $xml->addElement('hookextras_help', 'hookexport');
     if (is_array($extra_data['help']) and count($extra_data['help'])) {
         $this->DB->build(array('select' => '*', 'from' => 'faq', 'where' => "id IN(" . implode(",", $extra_data['help']) . ")"));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             unset($r['id']);
             $xml->addElementAsRecord('hookextras_help', 'help', $r);
         }
     }
     //-----------------------------------------
     // Skin templates
     //-----------------------------------------
     $xml->addElement('hookextras_templates', 'hookexport');
     if (is_array($extra_data['templates']) and count($extra_data['templates'])) {
         foreach ($extra_data['templates'] as $file => $templates) {
             $this->DB->build(array('select' => '*', 'from' => 'skin_templates', 'where' => "template_set_id=0 AND template_group='{$file}' AND template_name IN('" . implode("','", $templates) . "')"));
             $this->DB->execute();
             while ($r = $this->DB->fetch()) {
                 unset($r['template_id']);
                 $xml->addElementAsRecord('hookextras_templates', 'templates', $r);
             }
         }
     }
     //-----------------------------------------
     // Tasks
     //-----------------------------------------
     $xml->addElement('hookextras_tasks', 'hookexport');
     if (is_array($extra_data['tasks']) and count($extra_data['tasks'])) {
         $this->DB->build(array('select' => '*', 'from' => 'task_manager', 'where' => "task_id IN(" . implode(",", $extra_data['tasks']) . ")"));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             unset($r['task_id']);
             unset($r['task_next_run']);
             $xml->addElementAsRecord('hookextras_tasks', 'tasks', $r);
         }
     }
     //-----------------------------------------
     // Database changes
     //-----------------------------------------
     $xml->addElement('hookextras_database_create', 'hookexport');
     if (is_array($extra_data['database']['create']) and count($extra_data['database']['create'])) {
         foreach ($extra_data['database']['create'] as $create_query) {
             $xml->addElementAsRecord('hookextras_database_create', 'create', $create_query);
         }
     }
     $xml->addElement('hookextras_database_alter', 'hookexport');
     if (is_array($extra_data['database']['alter']) and count($extra_data['database']['alter'])) {
         foreach ($extra_data['database']['alter'] as $alter_query) {
             $xml->addElementAsRecord('hookextras_database_alter', 'alter', $alter_query);
         }
     }
     $xml->addElement('hookextras_database_update', 'hookexport');
     if (is_array($extra_data['database']['update']) and count($extra_data['database']['update'])) {
         foreach ($extra_data['database']['update'] as $update_query) {
             $xml->addElementAsRecord('hookextras_database_update', 'update', $update_query);
         }
     }
     $xml->addElement('hookextras_database_insert', 'hookexport');
     if (is_array($extra_data['database']['insert']) and count($extra_data['database']['insert'])) {
         foreach ($extra_data['database']['insert'] as $insert_query) {
             $xml->addElementAsRecord('hookextras_database_update', 'insert', $insert_query);
         }
     }
     //-----------------------------------------
     // Print to browser
     //-----------------------------------------
     $this->registry->output->showDownload($xml->fetchDocument(), 'hook.xml', '', 0);
 }
Esempio n. 10
0
 /**
  * Export the specified emoticon directory
  *
  * @return	@e void
  */
 public function emoticonsPackExport()
 {
     /* Setup XML */
     require_once IPS_KERNEL_PATH . 'classXML.php';
     /*noLibHook*/
     $xml = new classXML(IPS_DOC_CHAR_SET);
     require_once IPS_KERNEL_PATH . 'classXMLArchive.php';
     /*noLibHook*/
     $xmlarchive = new classXMLArchive();
     /* Check the emoticon set */
     if (!$this->request['emo_set']) {
         $this->registry->output->global_message = $this->lang->words['emo_specify_exS'];
         $this->emoticonsOverview();
         return;
     }
     /* Get emoticons from the database */
     $emo_db = array();
     $this->DB->build(array('select' => '*', 'from' => 'emoticons', 'where' => "emo_set='{$this->request['emo_set']}'"));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $emo_db[$r['image']] = $r;
     }
     /* Get Emoticon Folders */
     $emodirs = array();
     $emodd = array();
     $files_to_add = array();
     try {
         foreach (new DirectoryIterator(DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $this->request['emo_set']) as $file) {
             if (!$file->isDot()) {
                 if ($emo_db[$file->getFilename()] != "") {
                     $files_to_add[] = DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $this->request['emo_set'] . '/' . $file->getFilename();
                 }
             }
         }
     } catch (Exception $e) {
     }
     /* Add each file to the xml archive */
     foreach ($files_to_add as $f) {
         $xmlarchive->add($f);
     }
     $xml->newXMLDocument();
     $xml->addElement('emoticonexport');
     $xml->addElement('emogroup', 'emoticonexport');
     foreach ($emo_db as $r) {
         $content = array();
         $content['typed'] = $r['typed'];
         $content['image'] = $r['image'];
         $content['clickable'] = $r['clickable'];
         $xml->addElementAsRecord('emogroup', 'emoticon', $content);
     }
     /* Create the XML Document */
     $xmlData = $xml->fetchDocument();
     /* Add the xml document to the archive */
     $xmlarchive->add($xmlData, 'emoticon_data.xml');
     /* Send the archive to the browser */
     $imagearchive = $xmlarchive->getArchiveContents();
     $this->registry->output->showDownload($imagearchive, 'ipb_emoticons.xml');
 }
Esempio n. 11
0
 /**
  * Export help files XML
  *
  * @return	@e void
  */
 public function helpFilesXMLExport()
 {
     /* INIT */
     $entry = array();
     require_once IPS_KERNEL_PATH . 'classXML.php';
     /*noLibHook*/
     /* Loop through all the applications */
     foreach ($this->registry->getApplications() as $app => $__data) {
         $c = 0;
         $xml = new classXML(IPS_DOC_CHAR_SET);
         $xml->newXMLDocument();
         $xml->addElement('export');
         $xml->addElement('help', 'export');
         /* Query tasks */
         $this->DB->build(array('select' => '*', 'from' => 'faq', 'where' => "app='{$app}'"));
         $this->DB->execute();
         /* Loop through and add tasks to XML */
         while ($r = $this->DB->fetch()) {
             $c++;
             unset($r['id']);
             $r['text'] = str_replace('%7Bstyle_image_url%7D', '{style_image_url}', $r['text']);
             $xml->addElementAsRecord('help', 'row', $r);
         }
         /* Finish XML */
         $doc = $xml->fetchDocument();
         @unlink(IPSLib::getAppDir($app) . '/xml/' . $app . '_help.xml');
         /* Write */
         if ($doc and $c) {
             $fh = @fopen(IPSLib::getAppDir($app) . '/xml/' . $app . '_help.xml', 'w');
             @fwrite($fh, $doc);
             @fclose($fh);
         }
         /* In dev time stamp? */
         if (IN_DEV) {
             $cache = $this->caches['indev'];
             $cache['import']['help'][$app] = time();
             $this->cache->setCache('indev', $cache, array('donow' => 1, 'array' => 1));
         }
     }
     $this->registry->output->global_message = $this->lang->words['h_exported'];
     $this->helpFilesList();
 }
 /**
  * Export all settings to XML (IN_DEV mode)
  *
  * @access	private
  * @param	string		Application directory
  * @return	boolean
  */
 private function _exportXML($app_dir = 'core')
 {
     //-----------------------------------------
     // Get setting groups
     //-----------------------------------------
     $this->_settingsGetGroups(true);
     //-----------------------------------------
     // Get xml class
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXML.php';
     $xml = new classXML(IPS_DOC_CHAR_SET);
     $xml->newXMLDocument();
     $xml->addElement('settingexport');
     $xml->addElement('settinggroup', 'settingexport');
     foreach ($this->setting_groups as $i => $roar) {
         //-----------------------------------------
         // App check?
         //-----------------------------------------
         if ($app_dir != $roar['conf_title_app']) {
             continue;
         }
         //-----------------------------------------
         // First, add in setting group title
         //-----------------------------------------
         $thisconf = array('conf_is_title' => 1, 'conf_title_keyword' => $roar['conf_title_keyword'], 'conf_title_title' => $roar['conf_title_title'], 'conf_title_desc' => $roar['conf_title_desc'], 'conf_title_tab' => $roar['conf_title_tab'], 'conf_title_app' => $roar['conf_title_app'] ? $roar['conf_title_app'] : $app_dir, 'conf_title_noshow' => $roar['conf_title_noshow']);
         $xml->addElementAsRecord('settinggroup', 'setting', $thisconf);
         //-----------------------------------------
         // Get settings...
         //-----------------------------------------
         $this->DB->build(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_group='{$roar['conf_title_id']}'", 'order' => 'conf_position, conf_title'));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             //-----------------------------------------
             // Clean up...
             //-----------------------------------------
             unset($r['conf_value'], $r['conf_id']);
             $r['conf_title_keyword'] = $roar['conf_title_keyword'];
             $r['conf_is_title'] = 0;
             $xml->addElementAsRecord('settinggroup', 'setting', $r);
         }
     }
     //-----------------------------------------
     // Grab the XML document
     //-----------------------------------------
     $xmlData = $xml->fetchDocument();
     //-----------------------------------------
     // Attempt to write...
     //-----------------------------------------
     $file = IPSLib::getAppDir($app_dir) . '/xml/' . $app_dir . '_settings.xml';
     @unlink($file);
     @file_put_contents($file, $xmlData);
 }
    /**
     * Export information.xml files
     * for every application
     *
     * @return	@e void	[Returns to the applications list]
     */
    protected function inDevApplicationsExport()
    {
        /* Not IN_DEV? */
        if (!IN_DEV) {
            $this->applicationsOverview();
            return;
        }
        /* Get our libs! */
        require_once IPS_KERNEL_PATH . 'classXML.php';
        /*noLibHook*/
        require_once IPS_ROOT_PATH . 'setup/sources/base/setup.php';
        /*noLibHook*/
        /* Do each app */
        $this->DB->build(array('select' => '*', 'from' => 'core_applications'));
        $outer = $this->DB->execute();
        /* Loop */
        while ($app = $this->DB->fetch($outer)) {
            /* Set some vars */
            $oldXml = array();
            $newXml = null;
            $infoFile = IPSLib::getAppDir($app['app_directory']) . '/xml/information.xml';
            /* Got some 'old' template data to retain? */
            if (is_file($infoFile)) {
                if (!is_writeable($infoFile)) {
                    $output[] = "Cannot write to {$infoFile}";
                    continue;
                }
                $oldXml = IPSSetUp::fetchXmlAppInformation($app['app_directory'], $this->settings['gb_char_set']);
            }
            $data = array('name' => trim($app['app_title']), 'public_name' => trim($app['app_public_title']), 'hide_tab' => intval($app['app_hide_tab']), 'author' => trim($app['app_author']), 'description' => trim($app['app_description']), 'disabledatinstall' => isset($oldXml['disabledatinstall']) && $oldXml['disabledatinstall'] ? intval($oldXml['disabledatinstall']) : 0, 'ipskey' => '', 'global_caches' => trim($app['app_global_caches']), 'website' => trim($app['app_website']), 'update_check' => trim($app['app_update_check']));
            /* Got an IPS key to add? */
            if ($app['app_location'] == 'ips') {
                $data['ipskey'] = md5('ips_' . $app['app_directory']);
            } else {
                unset($data['ipskey']);
            }
            /* Create xml object */
            $newXml = new classXML(IPS_DOC_CHAR_SET);
            $newXml->newXMLDocument();
            /* Create elements */
            $newXml->addElement('information');
            $newXml->addElementAsRecord('information', 'data', $data);
            /* Get data till now */
            $xmlData = $newXml->fetchDocument();
            /* Got templates? */
            if (isset($oldXml['templates']) && count($oldXml['templates'])) {
                $XML_TEMPLATES = <<<XML
    <templategroups>

XML;
                foreach ($oldXml['templates'] as $k => $v) {
                    $XML_TEMPLATES .= <<<XML
        <template match="{$v}">{$k}</template>

XML;
                }
                $XML_TEMPLATES .= <<<XML
    </templategroups>
XML;
            } else {
                $XML_TEMPLATES = <<<XML
    <templategroups/>
XML;
            }
            /* Add templates into our XML - yeah I know.. a bit hackish.. */
            if ($data['update_check']) {
                $xmlData = str_replace('</update_check>', "</update_check>\n{$XML_TEMPLATES}", $xmlData);
            } else {
                $xmlData = str_replace('<update_check/>', "<update_check/>\n{$XML_TEMPLATES}", $xmlData);
            }
            file_put_contents($infoFile, $xmlData);
            $output[] = $app['app_title'] . " information exported in '" . str_replace(DOC_IPS_ROOT_PATH, '', $infoFile) . "'";
        }
        /* Done, setup message and redirect */
        $this->registry->output->setMessage(implode("<br />", $output), 1);
        $this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . $this->form_code . '&amp;do=applications_overview');
    }
 /**
  * Generate XML Information data file
  *
  * @access	public
  * @param	int			Set ID
  * @return	string		XML
  */
 public function generateInfoXML($setID = 0)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $data = array();
     $setData = $this->fetchSkinData($setID);
     //-----------------------------------------
     // Grab the XML parser
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXML.php';
     $xml = new classXML(IPS_DOC_CHAR_SET);
     //-----------------------------------------
     // Loop through...
     //-----------------------------------------
     $xml->newXMLDocument();
     $xml->addElement('info');
     $xml->addElementAsRecord('info', 'data', array('set_name' => $setData['set_name'], 'set_author_name' => $setData['set_author_name'], 'set_author_url' => $setData['set_author_url'], 'set_output_format' => $setData['set_output_format'], 'ipb_major_version' => '3'));
     return $xml->fetchDocument();
 }
Esempio n. 15
0
 /**
  * Export a bbcode XML file
  *
  * @return	@e void		[Outputs to screen]
  */
 protected function _bbcodeExport()
 {
     //-----------------------------------------
     // Get xml class
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXML.php';
     /*noLibHook*/
     $xml = new classXML(IPS_DOC_CHAR_SET);
     $xml->newXMLDocument();
     $xml->addElement('bbcodeexport');
     $xml->addElement('bbcodegroup', 'bbcodeexport');
     //-----------------------------------------
     // Get bbcodes
     //-----------------------------------------
     $select = array('select' => '*', 'from' => 'custom_bbcode');
     if ($this->request['id']) {
         $select['where'] = 'bbcode_id=' . intval($this->request['id']);
     }
     $this->DB->build($select);
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $xml->addElementAsRecord('bbcodegroup', 'bbcode', $r);
     }
     $xmlData = $xml->fetchDocument();
     //-----------------------------------------
     // Send to browser.
     //-----------------------------------------
     $this->registry->output->showDownload($xmlData, 'bbcode.xml', '', 0);
 }
Esempio n. 16
0
 /**
  * Actually export the damn hook already
  * Sorry, it has been a long day...
  *
  * @return	@e void
  */
 protected function _doExportHook()
 {
     //-----------------------------------------
     // Get hook
     //-----------------------------------------
     $id = intval($this->request['id']);
     if (!$id) {
         $this->registry->output->showError($this->lang->words['h_noexport'], 1114);
     }
     $hookData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id));
     if (!$hookData['hook_id']) {
         $this->registry->output->showError($this->lang->words['h_noexport'], 1115);
     }
     $extra_data = unserialize($hookData['hook_extra_data']);
     //-----------------------------------------
     // Get hook files
     //-----------------------------------------
     $files = array();
     $index = 1;
     $this->DB->build(array('select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $id, 'order' => 'hook_file_id ASC'));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         $files[$index] = $r;
         $index++;
     }
     //-----------------------------------------
     // Get XML class
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXML.php';
     /*noLibHook*/
     $xml = new classXML(IPS_DOC_CHAR_SET);
     $xml->newXMLDocument();
     $xml->addElement('hookexport');
     //-----------------------------------------
     // Put hook data in export
     //-----------------------------------------
     $xml->addElement('hookdata', 'hookexport');
     $content = array();
     foreach ($hookData as $k => $v) {
         if (in_array($k, array('hook_id', 'hook_enabled', 'hook_installed', 'hook_updated', 'hook_position'))) {
             continue;
         }
         $content[$k] = $v;
     }
     $xml->addElementAsRecord('hookdata', 'config', $content);
     //-----------------------------------------
     // Put hook files in export
     //-----------------------------------------
     $xml->addElement('hookfiles', 'hookexport');
     foreach ($files as $index => $r) {
         $content = array();
         foreach ($r as $k => $v) {
             if (in_array($k, array('hook_file_id', 'hook_hook_id', 'hook_file_stored', 'hooks_source'))) {
                 continue;
             }
             $content[$k] = $v;
         }
         $source = is_file(IPS_HOOKS_PATH . $r['hook_file_stored']) ? file_get_contents(IPS_HOOKS_PATH . $r['hook_file_stored']) : '';
         if (!empty($source) && in_array($r['hook_type'], array('skinHooks', 'commandHooks', 'libraryHooks'))) {
             $source = $this->_cleanSource($source);
         }
         $content['hooks_source'] = $source;
         $xml->addElementAsRecord('hookfiles', 'file', $content);
     }
     //-----------------------------------------
     // Custom install/uninstall script?
     //-----------------------------------------
     if ($extra_data['custom']) {
         $content = array();
         $xml->addElement('hookextras_custom', 'hookexport');
         $content['filename'] = $extra_data['custom'];
         $content['source'] = is_file(IPS_HOOKS_PATH . 'install_' . $extra_data['custom']) ? file_get_contents(IPS_HOOKS_PATH . 'install_' . $extra_data['custom']) : '';
         $xml->addElementAsRecord('hookextras_custom', 'file', $content);
     }
     //-----------------------------------------
     // Settings or setting groups?
     //-----------------------------------------
     $entry = array();
     $_groups = array();
     $_settings = array();
     $titles = array();
     $content = array();
     $xml->addElement('hookextras_settings', 'hookexport');
     # Store group ids and setting ids for entire setting groups
     if (is_array($extra_data['settingGroups']) and count($extra_data['settingGroups'])) {
         $_groups = $extra_data['settingGroups'];
         $_groupIds = array();
         $this->DB->build(array('select' => 'conf_title_id', 'from' => 'core_sys_settings_titles', 'where' => "conf_title_keyword IN('" . implode("','", $_groups) . "')"));
         $this->DB->execute();
         while ($rr = $this->DB->fetch()) {
             $_groupIds[] = $rr['conf_title_id'];
         }
         if (count($_groupIds)) {
             $this->DB->build(array('select' => 'conf_key', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group IN(' . implode(',', $_groupIds) . ')'));
             $this->DB->execute();
             while ($setting = $this->DB->fetch()) {
                 $_settings[] = $setting['conf_key'];
             }
         }
     }
     # Store group ids and setting ids for indvidual settings
     if (is_array($extra_data['settings']) and count($extra_data['settings'])) {
         foreach ($extra_data['settings'] as $_aSetting) {
             $_settings[] = $_aSetting;
         }
         $this->DB->build(array('select' => 't.conf_title_keyword', 'from' => array('core_sys_settings_titles' => 't'), 'where' => "c.conf_key IN('" . implode("','", $extra_data['settings']) . "')", 'add_join' => array(array('from' => array('core_sys_conf_settings' => 'c'), 'where' => 'c.conf_group=t.conf_title_id', 'type' => 'left'))));
         $this->DB->execute();
         while ($group = $this->DB->fetch()) {
             $_groups[] = $group['conf_title_keyword'];
         }
     }
     if (count($_groups)) {
         # Now get the group data for the XML file
         $this->DB->build(array('select' => '*', 'from' => 'core_sys_settings_titles', 'where' => "conf_title_keyword IN('" . implode("','", $_groups) . "')"));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             $content = array();
             $titles[$r['conf_title_id']] = $r['conf_title_keyword'];
             $content['conf_is_title'] = 1;
             foreach ($r as $k => $v) {
                 if (in_array($k, array('conf_title_tab', 'conf_title_keyword', 'conf_title_title', 'conf_title_desc', 'conf_title_app', 'conf_title_noshow'))) {
                     $content[$k] = $v;
                 }
             }
             $xml->addElementAsRecord('hookextras_settings', 'setting', $content);
         }
     }
     if (count($_settings)) {
         # Now get the group data for the XML file
         $this->DB->build(array('select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_key IN('" . implode("','", $_settings) . "')"));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             $r['conf_value'] = '';
             $r['conf_title_keyword'] = $titles[$r['conf_group']];
             $r['conf_is_title'] = 0;
             $xml->addElementAsRecord('hookextras_settings', 'setting', $r);
         }
     }
     //-----------------------------------------
     // Language strings/files
     //-----------------------------------------
     $entry = array();
     $xml->addElement('hookextras_language', 'hookexport');
     if (is_array($extra_data['language']) and count($extra_data['language'])) {
         foreach ($extra_data['language'] as $file => $strings) {
             $bits = explode('_', $file);
             $app = $bits[0];
             $pack = str_replace($app . '_', '', $file);
             $this->DB->build(array('select' => '*', 'from' => 'core_sys_lang_words', 'where' => "word_app='{$app}' AND word_pack='{$pack}' AND word_key IN('" . implode("','", $strings) . "')"));
             $this->DB->execute();
             while ($r = $this->DB->fetch()) {
                 $content = array();
                 foreach ($r as $k => $v) {
                     if (!in_array($k, array('word_app', 'word_pack', 'word_key', 'word_default'))) {
                         continue;
                     }
                     $content[$k] = $v;
                 }
                 $xml->addElementAsRecord('hookextras_language', 'language', $content);
             }
         }
     }
     //-----------------------------------------
     // Modules
     //-----------------------------------------
     $xml->addElement('hookextras_modules', 'hookexport');
     if (is_array($extra_data['modules']) and count($extra_data['modules'])) {
         foreach ($extra_data['modules'] as $module) {
             list($_side, $_app, $_module) = explode('-', $module);
             $_is_admin = $_side == 'admin' ? 1 : 0;
             $this->DB->build(array('select' => '*', 'from' => 'core_sys_module', 'where' => "sys_module_application='{$_app}' AND sys_module_key='{$_module}' AND sys_module_admin={$_is_admin}"));
             $this->DB->execute();
             while ($r = $this->DB->fetch()) {
                 unset($r['sys_module_id']);
                 $xml->addElementAsRecord('hookextras_modules', 'module', $r);
             }
         }
     }
     //-----------------------------------------
     // Help files
     //-----------------------------------------
     $xml->addElement('hookextras_help', 'hookexport');
     if (is_array($extra_data['help']) and count($extra_data['help'])) {
         $this->DB->build(array('select' => '*', 'from' => 'faq', 'where' => "title IN('" . implode("','", $extra_data['help']) . "')"));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             unset($r['id']);
             $xml->addElementAsRecord('hookextras_help', 'help', $r);
         }
     }
     //-----------------------------------------
     // Skin templates
     //-----------------------------------------
     $remapData = $this->registry->output->buildRemapData(true);
     $xml->addElement('hookextras_templates', 'hookexport');
     if (is_array($extra_data['templates']) and count($extra_data['templates'])) {
         foreach ($extra_data['templates'] as $file => $templates) {
             $this->DB->build(array('select' => '*', 'from' => 'skin_templates', 'where' => "template_set_id IN ('" . implode("','", $remapData['export']) . "') AND template_master_key != '' AND template_group='{$file}' AND template_name IN('" . implode("','", $templates) . "')"));
             $this->DB->execute();
             while ($r = $this->DB->fetch()) {
                 unset($r['template_id']);
                 unset($r['template_set_id']);
                 $xml->addElementAsRecord('hookextras_templates', 'templates', $r);
             }
         }
     }
     //-----------------------------------------
     // CSS
     //-----------------------------------------
     $xml->addElement('hookextras_css', 'hookexport');
     if (is_array($extra_data['css']) and count($extra_data['css'])) {
         $this->DB->build(array('select' => '*', 'from' => 'skin_css', 'where' => "css_set_id IN ('" . implode("','", $remapData['export']) . "') AND css_master_key != '' AND css_group IN('" . implode("','", $extra_data['css']) . "')"));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             unset($r['css_id']);
             unset($r['css_set_id']);
             $xml->addElementAsRecord('hookextras_css', 'css', $r);
         }
     }
     //-----------------------------------------
     // Replacements
     //-----------------------------------------
     $xml->addElement('hookextras_replacements', 'hookexport');
     if (is_array($extra_data['replacements']) and count($extra_data['replacements'])) {
         $this->DB->build(array('select' => '*', 'from' => 'skin_replacements', 'where' => "replacement_key IN('" . implode("','", $extra_data['replacements']) . "')", 'group' => 'replacement_key'));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             unset($r['replacement_id']);
             unset($r['replacement_set_id']);
             $xml->addElementAsRecord('hookextras_replacements', 'replacements', $r);
         }
     }
     //-----------------------------------------
     // Tasks
     //-----------------------------------------
     $xml->addElement('hookextras_tasks', 'hookexport');
     if (is_array($extra_data['tasks']) and count($extra_data['tasks'])) {
         $this->DB->build(array('select' => '*', 'from' => 'task_manager', 'where' => "task_key IN('" . implode("','", $extra_data['tasks']) . "')"));
         $this->DB->execute();
         while ($r = $this->DB->fetch()) {
             unset($r['task_id']);
             unset($r['task_next_run']);
             $xml->addElementAsRecord('hookextras_tasks', 'tasks', $r);
         }
     }
     //-----------------------------------------
     // Database changes
     //-----------------------------------------
     $xml->addElement('hookextras_database_create', 'hookexport');
     if (is_array($extra_data['database']['create']) and count($extra_data['database']['create'])) {
         foreach ($extra_data['database']['create'] as $create_query) {
             $xml->addElementAsRecord('hookextras_database_create', 'create', $create_query);
         }
     }
     $xml->addElement('hookextras_database_alter', 'hookexport');
     if (is_array($extra_data['database']['alter']) and count($extra_data['database']['alter'])) {
         foreach ($extra_data['database']['alter'] as $alter_query) {
             $xml->addElementAsRecord('hookextras_database_alter', 'alter', $alter_query);
         }
     }
     $xml->addElement('hookextras_database_update', 'hookexport');
     if (is_array($extra_data['database']['update']) and count($extra_data['database']['update'])) {
         foreach ($extra_data['database']['update'] as $update_query) {
             $xml->addElementAsRecord('hookextras_database_update', 'update', $update_query);
         }
     }
     $xml->addElement('hookextras_database_insert', 'hookexport');
     if (is_array($extra_data['database']['insert']) and count($extra_data['database']['insert'])) {
         foreach ($extra_data['database']['insert'] as $insert_query) {
             $xml->addElementAsRecord('hookextras_database_insert', 'insert', $insert_query);
         }
     }
     //-----------------------------------------
     // Print to browser
     //-----------------------------------------
     $this->registry->output->showDownload($xml->fetchDocument(), $hookData['hook_key'] . '.xml', '', 0);
 }
Esempio n. 17
0
 /**
  * Builds the attachment type xml export
  *
  * @return	@e void
  */
 public function attachmentTypeExport()
 {
     //-----------------------------------------
     // Get xml class
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXML.php';
     /*noLibHook*/
     $xml = new classXML(IPS_DOC_CHAR_SET);
     $xml->newXMLDocument();
     $xml->addElement('attachtypesexport');
     $xml->addElement('attachtypesgroup', 'attachtypesexport');
     /* Query the attachment Types */
     $this->DB->build(array('select' => 'atype_extension,atype_mimetype,atype_post,atype_img', 'from' => 'attachments_type', 'order' => "atype_extension"));
     $this->DB->execute();
     /* Loop through the types */
     $entry = array();
     while ($r = $this->DB->fetch()) {
         $xml->addElementAsRecord('attachtypesgroup', 'attachtype', $r);
     }
     /* Send for download */
     $this->registry->output->showDownload($xml->fetchDocument(), 'attachments.xml', "unknown/unknown", false);
 }
 /**
  * Export an application
  *
  * @access	private
  * @param	integer		Return XML [1] or print to browser [0]
  * @return	mixed		XML content or void [Outputs to screen]
  */
 private function applicationExport($return_xml = 0)
 {
     //-----------------------------------------
     // INIT
     //-----------------------------------------
     $xml = '';
     //-----------------------------------------
     // Get xml mah-do-dah
     //-----------------------------------------
     require_once IPS_KERNEL_PATH . 'classXML.php';
     $xml = new classXML(IPS_DOC_CHAR_SET);
     $xml->newXMLDocument();
     $xml->addElement('applicationexport');
     $xml->addElement('applicationgroup', 'applicationexport');
     //-----------------------------------------
     // Get applications
     //-----------------------------------------
     $this->DB->build(array('select' => '*', 'from' => 'core_applications'));
     $this->DB->execute();
     while ($r = $this->DB->fetch()) {
         unset($r['app_id']);
         $xml->addElementAsRecord('applicationgroup', 'application', $r);
     }
     //-----------------------------------------
     // Send to browser.
     //-----------------------------------------
     if ($return_xml) {
         return array('title' => 'applications.xml', 'xml' => $xml->fetchDocument());
     } else {
         $this->registry->output->showDownload($xml->fetchDocument(), 'applications.xml', '', 0);
     }
 }