/** * Write a configuration object to * the configuration XML file. * * @param Configuration $config object * to write to the XML file. * @return boolean Whether or not the * configuration was installed and configured. */ function config_setConfiguration($config) { $xml = new SimpleXMLElement(genXML()); $xml->downloadLocation = (string) $config->getDownloadLocation(); $xml->torrentModule = (string) $config->getTorrentModule(); $xml->maxDownloadSpeed = (string) $config->getMaxDownloadSpeed(); $xml->maxUploadSpeed = (string) $config->getMaxUploadSpeed(); $xml->maxDownloads = (string) $config->getMaxDownloads(); $xml->maxUploads = (string) $config->getMaxUploads(); $xml->maxActiveTorrents = (string) $config->getMaxActiveTorrents(); $xml->tcpPort = (string) $config->getTcpPort(); $xml->udpPort = (string) $config->getUdpPort(); $xml->hideOtherUsers = (string) $config->getHideOtherUsers(); $xml->allowDirectDownload = (string) $config->getAllowDirectDownload(); if (@file_put_contents(APPPATH . "../../config/configuration.xml", $xml->asXML())) { return true; } else { return false; } }
function genXML(&$menu, &$labels, $i = 0) { static $x = 0; $xml = ""; foreach ($menu as $key => $value) { $indentation = str_repeat(" ", $i); if (is_string($key)) { // recursion list($label, ) = each($labels); // advance pointer no matter what if (empty($value)) { continue; } // menu is empty, there's no point in displaying it $xml .= $indentation . "<menu id=\"gnome-menu-{$x}\" label=\"{$label}\">\n"; $xml .= genXML($menu[$key], $labels[$label], $i + 1, ++$x); $xml .= $indentation . "</menu>\n"; } else { if (empty($value)) { continue; } $xml .= $indentation . "<item label=\"{$value["appname"]}\"><action name=\"Execute\">" . "<execute>{$value["appexec"]}</execute></action></item>\n"; } } return $xml; }