/** * @see Form::save() */ public function save() { parent::save(); // send content type header('Content-Type: text/' . $this->fileType . '; charset=' . CHARSET); header('Content-Disposition: attachment; filename="export.' . $this->fileType . '"'); if ($this->fileType == 'xml') { echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<addresses>\n"; } // get users $sql = "SELECT\t\temail\n\t\t\tFROM\t\twcf" . WCF_N . "_user\n\t\t\tWHERE\t\tuserID IN (" . $this->userIDs . ")\n\t\t\tORDER BY\temail"; $result = WCF::getDB()->sendQuery($sql); $i = 0; $j = WCF::getDB()->countRows($result) - 1; while ($row = WCF::getDB()->fetchArray($result)) { if ($this->fileType == 'xml') { echo "<address><![CDATA[" . StringUtil::escapeCDATA($row['email']) . "]]></address>\n"; } else { echo $this->textSeparator . $row['email'] . $this->textSeparator . ($i < $j ? $this->separator : ''); } $i++; } if ($this->fileType == 'xml') { echo "</addresses>"; } UserEditor::unmarkAll(); $this->saved(); exit; }
/** * @see Action::execute(); */ public function execute() { parent::execute(); // check permissions WCF::getUser()->checkPermission('admin.system.canEditOption'); // header @header('Content-type: text/xml'); // file name @header('Content-disposition: attachment; filename="options.xml"'); // no cache headers @header('Pragma: no-cache'); @header('Expires: 0'); // content echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<options>\n"; $options = Options::getOptions(); foreach ($options as $option) { echo "\t<option>\n"; echo "\t\t<name><![CDATA[" . StringUtil::escapeCDATA($option['optionName']) . "]]></name>\n"; echo "\t\t<value><![CDATA[" . StringUtil::escapeCDATA($option['optionValue']) . "]]></value>\n"; echo "\t</option>\n"; } echo '</options>'; $this->executed(); exit; }
/** * @see ViewablePost::getFormattedMessage() */ public function getFormattedMessage() { $text = ''; if ($this->post) { $text = $this->post->getFormattedMessage(); } // replace relative urls $text = preg_replace('~(?<=href="|src=")(?![a-z0-9]+://)(?!mailto:)~i', PAGE_URL . '/', $text); return StringUtil::escapeCDATA($text); }
/** * @see Page::show() */ public function show() { parent::show(); header('Content-type: text/xml'); echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<suggestions>\n"; if (!empty($this->query)) { // get users $sql = "SELECT\t\tDISTINCT name\n\t\t\t\tFROM\t\twcf" . WCF_N . "_tag\n\t\t\t\tWHERE\t\t" . ($this->languageID ? "languageID = " . $this->languageID . " AND" : '') . "\n\t\t\t\t\t\tname LIKE '" . escapeString($this->query) . "%'\n\t\t\t\tORDER BY\tname"; $result = WCF::getDB()->sendQuery($sql, 10); while ($row = WCF::getDB()->fetchArray($result)) { echo "<tag><![CDATA[" . StringUtil::escapeCDATA($row['name']) . "]]></tag>\n"; } } echo '</suggestions>'; exit; }
/** * @see Page::show() */ public function show() { AbstractPage::show(); header('Content-type: text/xml'); echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<suggestions>\n"; if (!empty($this->query)) { // get suggestions $sql = "(SELECT\t\tusername AS name, 'user' AS type\n\t\t\t\tFROM\t\twcf" . WCF_N . "_user\n\t\t\t\tWHERE\t\tusername LIKE '" . escapeString($this->query) . "%')\n\t\t\t\tUNION ALL\n\t\t\t\t(SELECT\t\tgroupName AS name, 'group' AS type\n\t\t\t\tFROM\t\twcf" . WCF_N . "_group\n\t\t\t\tWHERE\t\tgroupName LIKE '" . escapeString($this->query) . "%')\n\t\t\t\tORDER BY\tname"; $result = WCF::getDB()->sendQuery($sql, 10); while ($row = WCF::getDB()->fetchArray($result)) { echo "<" . $row['type'] . "><![CDATA[" . StringUtil::escapeCDATA($row['name']) . "]]></" . $row['type'] . ">\n"; } } echo '</suggestions>'; exit; }
/** * @see Page::show() */ public function show() { parent::show(); // get smileys $smileys = WCF::getCache()->get('smileys', 'smileys'); if (isset($smileys[$this->smileyCategoryID])) { header('Content-type: text/xml'); echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<smileys>\n"; foreach ($smileys[$this->smileyCategoryID] as $smiley) { echo "\t<smiley>\n"; echo "\t\t<path><![CDATA[" . StringUtil::escapeCDATA($smiley->smileyPath) . "]]></path>\n"; echo "\t\t<title><![CDATA[" . StringUtil::escapeCDATA(WCF::getLanguage()->get($smiley->smileyTitle)) . "]]></title>\n"; echo "\t\t<code><![CDATA[" . StringUtil::escapeCDATA($smiley->smileyCode) . "]]></code>\n"; echo "\t</smiley>\n"; } echo '</smileys>'; } exit; }
/** * @see Page::show() */ public function show() { parent::show(); $photos = $this->photoList->getObjects(); // get photos if (count($photos)) { header('Content-type: text/xml'); echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<photos>\n"; foreach ($photos as $photo) { echo "\t<photo>\n"; echo "\t\t<path><![CDATA[" . StringUtil::escapeCDATA(PAGE_URL . '/' . $photo->getPhoto(self::convertSize(INLINE_IMAGE_MAX_WIDTH))) . "]]></path>\n"; echo "\t\t<title><![CDATA[" . StringUtil::escapeCDATA($photo->title) . "]]></title>\n"; echo "\t\t<link><![CDATA[" . PAGE_URL . "/index.php?page=UserGalleryPhoto&photoID=" . $photo->photoID . "]]></link>\n"; echo "\t\t<thumbnail><![CDATA[" . StringUtil::escapeCDATA(PAGE_URL . '/' . $photo->getPhoto('quadratic')) . "]]></thumbnail>\n"; echo "\t</photo>\n"; } echo '</photos>'; } exit; }
/** * @see Page::show() */ public function show() { parent::show(); header('Content-type: text/xml'); echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<objects>"; if (count($this->query)) { // get users $names = implode("','", array_map('escapeString', $this->query)); $sql = "(SELECT\t\tusername AS name, userID AS id, 'user' AS type \n\t\t\t\tFROM\t\twcf" . WCF_N . "_user\n\t\t\t\tWHERE\t\tusername IN ('" . $names . "'))\n\t\t\t\tUNION\n\t\t\t\t(SELECT\t\tgroupName AS name, groupID AS id, 'group' AS type \n\t\t\t\tFROM\t\twcf" . WCF_N . "_group\n\t\t\t\tWHERE\t\tgroupName IN ('" . $names . "'))\n\t\t\t\tORDER BY \tname"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { echo "<object>"; echo "<name><![CDATA[" . StringUtil::escapeCDATA($row['name']) . "]]></name>"; echo "<type>" . $row['type'] . "</type>"; echo "<id>" . $row['id'] . "</id>"; echo "</object>"; } } echo '</objects>'; exit; }
/** * @see Page::show() */ public function show() { if (!MODULE_CHEAT_DATABASE) { exit; } try { parent::show(); } catch (Exception $e) { exit; } header('Content-type: text/xml'); echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<suggestions>\n"; if (!empty($this->query)) { $sql = "SELECT\t\tDISTINCT languageItem, languageItemValue\n\t\t\t\tFROM\t\twcf" . WCF_N . "_language_item\n\t\t\t\tWHERE\t\t" . ($this->languageID ? "languageID = " . $this->languageID . " AND" : '') . "\n\t\t\t\t\t\tlanguageItem LIKE 'wcf.cheatDatabase.entry." . escapeString($this->type) . "%' AND\n\t\t\t\t\t\tlanguageItemValue LIKE '" . escapeString($this->query) . "%'\n\t\t\t\tORDER BY\tlanguageItemValue"; $result = WCF::getDB()->sendQuery($sql, 10); while ($row = WCF::getDB()->fetchArray($result)) { echo "\t<suggestion>\n\t\t<languageItem><![CDATA[" . StringUtil::escapeCDATA($row['languageItem']) . "]]></languageItem>\n\t\t<value><![CDATA[" . StringUtil::escapeCDATA($row['languageItemValue']) . "]]></value>\n\t</suggestion>\n"; } } echo '</suggestions>'; exit; }
/** * @see ViewablePM::getFormattedMessage() */ public function getFormattedMessage() { // replace relative urls $text = preg_replace('~(?<=href="|src=")(?![a-z0-9]+://)~i', PAGE_URL . '/', parent::getFormattedMessage()); return StringUtil::escapeCDATA($text); }
/** * Exports this style. * * @param boolean $templates * @param boolean $images * @param boolean $icons */ public function export($templates = false, $images = false, $icons = false) { // create style tar require_once WCF_DIR . 'lib/system/io/TarWriter.class.php'; $styleTarName = FileUtil::getTemporaryFilename('style_', '.tgz'); $styleTar = new TarWriter($styleTarName, true); // append style preview image if ($this->image && @file_exists(WCF_DIR . $this->image)) { $styleTar->add(WCF_DIR . $this->image, '', FileUtil::addTrailingSlash(dirname(WCF_DIR . $this->image))); } // create style info file $string = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE style SYSTEM \"http://www.woltlab.com/DTDs/SXF/style.dtd\">\n<style>\n"; // general block $string .= "\t<general>\n"; $string .= "\t\t<stylename><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->styleName) : $this->styleName) . "]]></stylename>\n"; // style name if ($this->styleDescription) { $string .= "\t\t<description><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->styleDescription) : $this->styleDescription) . "]]></description>\n"; } // style description if ($this->styleVersion) { $string .= "\t\t<version><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->styleVersion) : $this->styleVersion) . "]]></version>\n"; } // style version if ($this->styleDate) { $string .= "\t\t<date><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->styleDate) : $this->styleDate) . "]]></date>\n"; } // style date if ($this->image) { $string .= "\t\t<image><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', basename($this->image)) : basename($this->image)) . "]]></image>\n"; } // style preview image if ($this->copyright) { $string .= "\t\t<copyright><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->copyright) : $this->copyright) . "]]></copyright>\n"; } // copyright if ($this->license) { $string .= "\t\t<license><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->license) : $this->license) . "]]></license>\n"; } // license $string .= "\t</general>\n"; // author block $string .= "\t<author>\n"; if ($this->authorName) { $string .= "\t\t<authorname><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->authorName) : $this->authorName) . "]]></authorname>\n"; } // author name if ($this->authorURL) { $string .= "\t\t<authorurl><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $this->authorURL) : $this->authorURL) . "]]></authorurl>\n"; } // author URL $string .= "\t</author>\n"; // files block $string .= "\t<files>\n"; $string .= "\t\t<variables>variables.xml</variables>\n"; // variables if ($templates && $this->templatePackID) { $string .= "\t\t<templates>templates.tar</templates>\n"; } // templates if ($images) { $string .= "\t\t<images>images.tar</images>\n"; } // images if ($icons) { $string .= "\t\t<icons>icons.tar</icons>\n"; } // icons $string .= "\t</files>\n"; $string .= "</style>"; // append style info file to style tar $styleTar->addString(self::INFO_FILE, $string); unset($string); // create variable list $string = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE variables SYSTEM \"http://www.woltlab.com/DTDs/SXF/variables.dtd\">\n<variables>\n"; // get variables $variables = $this->getVariables(); $exportImages = array(); foreach ($variables as $name => $value) { // search images if ($images && $value) { if (preg_match_all('~([^/\\s\\$]+\\.(?:gif|jpg|jpeg|png))~i', $value, $matches)) { $exportImages = array_merge($exportImages, $matches[1]); } } $string .= "\t<variable name=\"" . StringUtil::encodeHTML($name) . "\"><![CDATA[" . StringUtil::escapeCDATA(CHARSET != 'UTF-8' ? StringUtil::convertEncoding(CHARSET, 'UTF-8', $value) : $value) . "]]></variable>\n"; } $string .= "</variables>"; // append variable list to style tar $styleTar->addString('variables.xml', $string); unset($string); if ($templates && $this->templatePackID) { require_once WCF_DIR . 'lib/data/template/TemplatePack.class.php'; $templatePack = new TemplatePack($this->templatePackID); // create templates tar $templatesTarName = FileUtil::getTemporaryFilename('templates', '.tar'); $templatesTar = new TarWriter($templatesTarName); @chmod($templatesTarName, 0777); // append templates to tar // get templates $sql = "SELECT\t\ttemplate.*, package.package, package.packageDir,\n\t\t\t\t\t\tparent_package.package AS parentPackage, parent_package.packageDir AS parentPackageDir\n\t\t\t\tFROM\t\twcf" . WCF_N . "_template template\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_package package\n\t\t\t\tON\t\t(package.packageID = template.packageID)\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_package parent_package\n\t\t\t\tON\t\t(parent_package.packageID = package.parentPackageID)\n\t\t\t\tWHERE\t\ttemplate.templatePackID = " . $this->templatePackID; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $packageDir = 'com.woltlab.wcf'; if (!empty($row['parentPackageDir'])) { $packageDir = $row['parentPackage']; } else { if (!empty($row['packageDir'])) { $packageDir = $row['package']; } } $filename = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $row['packageDir'] . 'templates/' . $templatePack->templatePackFolderName)) . $row['templateName'] . '.tpl'; $templatesTar->add($filename, $packageDir, dirname($filename)); } // append templates tar to style tar $templatesTar->create(); $styleTar->add($templatesTarName, 'templates.tar', $templatesTarName); @unlink($templatesTarName); } if ($images) { // create images tar $imagesTarName = FileUtil::getTemporaryFilename('images_', '.tar'); $imagesTar = new TarWriter($imagesTarName); @chmod($imagesTarName, 0777); // cache rtl versions foreach ($exportImages as $exportImage) { if (strpos($exportImage, '-ltr')) { $exportImages[] = str_replace('-ltr', '-rtl', $exportImage); } } // append images to tar $path = WCF_DIR . $variables['global.images.location']; if (file_exists($path) && is_dir($path)) { $handle = opendir($path); while (($file = readdir($handle)) !== false) { if (is_file($path . $file) && in_array($file, $exportImages)) { $imagesTar->add($path . $file, '', $path); } } } // append images tar to style tar $imagesTar->create(); $styleTar->add($imagesTarName, 'images.tar', $imagesTarName); @unlink($imagesTarName); } // export icons $iconsLocation = FileUtil::addTrailingSlash($variables['global.icons.location']); if ($icons && $iconsLocation != 'icon/') { // create icons tar $iconsTarName = FileUtil::getTemporaryFilename('icons_', '.tar'); $iconsTar = new TarWriter($iconsTarName); @chmod($iconsTar, 0777); // get package dirs $sql = "SELECT\tpackage, packageDir\n\t\t\t\tFROM\twcf" . WCF_N . "_package\n\t\t\t\tWHERE\tstandalone = 1\n\t\t\t\t\tAND (packageDir <> '' OR package = 'com.woltlab.wcf')"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $iconsDir = FileUtil::getRealPath(WCF_DIR . $row['packageDir']) . $iconsLocation; $packageIcons = array(); if (file_exists($iconsDir)) { $icons = glob($iconsDir . '*.png'); if (is_array($icons)) { foreach ($icons as $icon) { $packageIcons[] = $icon; } } } if (count($packageIcons)) { $iconsTar->add($packageIcons, $row['package'] . '/', $iconsDir); } } $iconsTar->create(); $styleTar->add($iconsTarName, 'icons.tar', $iconsTarName); @unlink($iconsTarName); } // output file content $styleTar->create(); readfile($styleTarName); @unlink($styleTarName); }
/** * @see Form::save() */ public function save() { parent::save(); // build conditions $this->conditions = new ConditionBuilder(); // static fields if (!empty($this->username)) { $this->conditions->add("user.username LIKE '%" . addcslashes(escapeString($this->username), '_%') . "%'"); } if (!empty($this->email)) { $this->conditions->add("user.email LIKE '%" . addcslashes(escapeString($this->email), '_%') . "%'"); } if (count($this->groupIDArray) > 0) { $this->conditions->add("user.userID " . ($this->invertGroupIDs == 1 ? 'NOT ' : '') . "IN (SELECT userID FROM wcf" . WCF_N . "_user_to_groups WHERE groupID IN (" . implode(',', $this->groupIDArray) . "))"); } if (count($this->languageIDArray) > 0) { $this->conditions->add("user.languageID IN (" . implode(',', $this->languageIDArray) . ")"); } // dynamic fields foreach ($this->activeOptions as $name => $option) { $value = isset($this->values[$option['optionName']]) ? $this->values[$option['optionName']] : null; $condition = $this->getTypeObject($option['optionType'])->getCondition($option, $value, isset($this->matchExactly[$name])); if ($condition !== false) { $this->conditions->add($condition); } } // call buildConditions event EventHandler::fireAction($this, 'buildConditions'); // execute action switch ($this->action) { case 'sendMail': WCF::getUser()->checkPermission('admin.user.canMailUser'); // get user ids $userIDArray = array(); $sql = "SELECT\t\tuser.userID\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user user\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value option_value USING (userID)\n\t\t\t\t\t" . $this->conditions->get(); $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $userIDArray[] = $row['userID']; $this->affectedUsers++; } // save config in session $userMailData = WCF::getSession()->getVar('userMailData'); if ($userMailData === null) { $userMailData = array(); } $mailID = count($userMailData); $userMailData[$mailID] = array('action' => '', 'userIDs' => implode(',', $userIDArray), 'groupIDs' => '', 'subject' => $this->subject, 'text' => $this->text, 'from' => $this->from, 'enableHTML' => $this->enableHTML); WCF::getSession()->register('userMailData', $userMailData); $this->saved(); // show worker template WCF::getTPL()->assign(array('pageTitle' => WCF::getLanguage()->get('wcf.acp.user.sendMail'), 'url' => 'index.php?action=UserMail&mailID=' . $mailID . '&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED)); WCF::getTPL()->display('worker'); exit; break; case 'exportMailAddress': WCF::getUser()->checkPermission('admin.user.canMailUser'); // send content type header('Content-Type: text/' . $this->fileType . '; charset=' . CHARSET); header('Content-Disposition: attachment; filename="export.' . $this->fileType . '"'); if ($this->fileType == 'xml') { echo "<?xml version=\"1.0\" encoding=\"" . CHARSET . "\"?>\n<addresses>\n"; } // get users $sql = "SELECT\t\tuser.email\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user user\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value option_value USING (userID)\n\t\t\t\t\t" . $this->conditions->get() . "\n\t\t\t\t\tORDER BY\tuser.email"; $result = WCF::getDB()->sendQuery($sql); $i = 0; $j = WCF::getDB()->countRows($result) - 1; while ($row = WCF::getDB()->fetchArray($result)) { if ($this->fileType == 'xml') { echo "<address><![CDATA[" . StringUtil::escapeCDATA($row['email']) . "]]></address>\n"; } else { echo $this->textSeparator . $row['email'] . $this->textSeparator . ($i < $j ? $this->separator : ''); } $i++; $this->affectedUsers++; } if ($this->fileType == 'xml') { echo "</addresses>"; } $this->saved(); exit; break; case 'assignToGroup': WCF::getUser()->checkPermission('admin.user.canEditUser'); $userIDArray = array(); $sql = "SELECT\t\tuser.*,\n\t\t\t\t\t\t\tGROUP_CONCAT(groupID SEPARATOR ',') AS groupIDs\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user user\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value option_value USING (userID)\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_to_groups groups\n\t\t\t\t\tON\t\t(groups.userID = user.userID)\n\t\t\t\t\t" . $this->conditions->get() . "\t\t\n\t\t\t\t\tGROUP BY\tuser.userID"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (!Group::isAccessibleGroup(explode(',', $row['groupIDs']))) { throw new PermissionDeniedException(); } $user = new UserEditor(null, $row); $user->addToGroups($this->assignToGroupIDArray, false, false); $userIDArray[] = $row['userID']; $this->affectedUsers++; } Session::resetSessions($userIDArray); break; case 'delete': WCF::getUser()->checkPermission('admin.user.canDeleteUser'); $userIDArray = array(); $sql = "SELECT\t\tuser.*,\n\t\t\t\t\t\t\tGROUP_CONCAT(groupID SEPARATOR ',') AS groupIDs\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user user\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_option_value option_value USING (userID)\n\t\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_user_to_groups groups\n\t\t\t\t\tON\t\t(groups.userID = user.userID)\n\t\t\t\t\t" . $this->conditions->get() . "\t\t\n\t\t\t\t\tGROUP BY\tuser.userID"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { if (!Group::isAccessibleGroup(explode(',', $row['groupIDs']))) { throw new PermissionDeniedException(); } $userIDArray[] = $row['userID']; $this->affectedUsers++; } UserEditor::deleteUsers($userIDArray); break; } $this->saved(); WCF::getTPL()->assign('affectedUsers', $this->affectedUsers); }
/** * Exports this language. */ public function export($packageIDArray = array(), $exportCustomValues = false) { // bom echo ""; // header echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<language xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com/XSD/language.xsd\" languagecode=\"" . $this->getLanguageCode() . "\">\n"; // get items $items = array(); if (count($packageIDArray)) { $sql = "SELECT\t\tlanguageItem, " . ($exportCustomValues ? "CASE WHEN languageUseCustomValue > 0 THEN languageCustomItemValue ELSE languageItemValue END AS languageItemValue" : "languageItemValue") . ", languageCategory\n\t\t\t\tFROM\t\twcf" . WCF_N . "_language_item language_item\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_language_category language_category\n\t\t\t\tON\t\t(language_category.languageCategoryID = language_item.languageCategoryID)\n\t\t\t\tWHERE \t\tlanguage_item.packageID IN (" . implode(',', $packageIDArray) . ")\n\t\t\t\t\t\tAND language_item.languageID = " . $this->languageID; } else { $sql = "SELECT\t\tlanguageItem, " . ($exportCustomValues ? "CASE WHEN languageUseCustomValue > 0 THEN languageCustomItemValue ELSE languageItemValue END AS languageItemValue" : "languageItemValue") . ", languageCategory\n\t\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency package_dependency,\n\t\t\t\t\t\twcf" . WCF_N . "_language_item language_item\n\t\t\t\tLEFT JOIN\twcf" . WCF_N . "_language_category language_category\n\t\t\t\tON\t\t(language_category.languageCategoryID = language_item.languageCategoryID)\n\t\t\t\tWHERE \t\tlanguage_item.packageID = package_dependency.dependency\n\t\t\t\t\t\tAND language_item.languageID = " . $this->languageID . "\n\t\t\t\t\t\tAND package_dependency.packageID = " . PACKAGE_ID . "\n\t\t\t\tORDER BY \tpackage_dependency.priority ASC"; } $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $items[$row['languageCategory']][$row['languageItem']] = $row['languageItemValue']; } // sort categories ksort($items); foreach ($items as $category => $categoryItems) { // sort items ksort($categoryItems); // category header echo "\t<category name=\"" . $category . "\">\n"; // items foreach ($categoryItems as $item => $value) { if (CHARSET != 'UTF-8') { $value = StringUtil::convertEncoding(CHARSET, 'UTF-8', $value); } echo "\t\t<item name=\"" . $item . "\"><![CDATA[" . StringUtil::escapeCDATA($value) . "]]></item>\n"; } // category footer echo "\t</category>\n"; } // footer echo "</language>"; }
/** * @see Action::execute() */ public function execute() { parent::execute(); // header $buffer = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; $buffer .= "<systeminfo xmlns=\"http://www.woltlab.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.woltlab.com/XSD/systeminfo.xsd\">\n"; // system block $buffer .= "\t<system>\n"; // os block $buffer .= "\t\t<os>\n"; // os type $buffer .= "\t\t\t<type><![CDATA[" . StringUtil::escapeCDATA(StringUtil::toLowerCase(PHP_OS)) . "]]></type>\n"; // try to get os version $osVersion = @exec('cat /proc/version'); // Linux if (empty($osVersion)) { $osVersion = @exec('uname -a'); } // FreeBSD / Darwin if (empty($osVersion)) { $osVersion = @exec('ver'); } // Windows $buffer .= "\t\t\t<version><![CDATA[" . StringUtil::escapeCDATA($osVersion) . "]]></version>\n"; $buffer .= "\t\t</os>\n"; // webserver block $buffer .= "\t\t<webserver>\n"; // webserver type $webserver = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : ''; $webserverType = 'other'; if (stripos($webserver, 'apache') !== false) { $webserverType = 'apache'; } else { if (stripos($webserver, 'iis') !== false) { $webserverType = 'iis'; } else { if (stripos($webserver, 'lighttpd') !== false) { $webserverType = 'lighttpd'; } else { if (stripos($webserver, 'zeus') !== false) { $webserverType = 'zeus'; } } } } $buffer .= "\t\t\t<type><![CDATA[" . $webserverType . "]]></type>\n"; // webserver version $buffer .= "\t\t\t<version><![CDATA[" . StringUtil::escapeCDATA($webserver) . "]]></version>\n"; // webserver modules $modules = ''; if (function_exists('apache_get_modules')) { $modules = @implode(', ', apache_get_modules()); } $buffer .= "\t\t\t<modules><![CDATA[" . StringUtil::escapeCDATA($modules) . "]]></modules>\n"; $buffer .= "\t\t</webserver>\n"; // php block $buffer .= "\t\t<php>\n"; // version $buffer .= "\t\t\t<version><![CDATA[" . StringUtil::escapeCDATA(PHP_VERSION) . "]]></version>\n"; // integration $buffer .= "\t\t\t<integration><![CDATA[" . StringUtil::escapeCDATA(php_sapi_name()) . "]]></integration>\n"; // safe-mode? $buffer .= "\t\t\t<safemode><![CDATA[" . FileUtil::getSafeMode() . "]]></safemode>\n"; // suhosin? $buffer .= "\t\t\t<suhosin><![CDATA[" . intval(extension_loaded('suhosin')) . "]]></suhosin>\n"; // php modules $buffer .= "\t\t\t<modules><![CDATA[" . StringUtil::escapeCDATA(implode(', ', get_loaded_extensions())) . "]]></modules>\n"; $buffer .= "\t\t</php>\n"; // sql block $buffer .= "\t\t<sql>\n"; // type $buffer .= "\t\t\t<type><![CDATA[" . StringUtil::escapeCDATA(str_replace('Database', '', WCF::getDB()->getDBType())) . "]]></type>\n"; // version $buffer .= "\t\t\t<version><![CDATA[" . StringUtil::escapeCDATA(WCF::getDB()->getVersion()) . "]]></version>\n"; $buffer .= "\t\t</sql>\n"; $buffer .= "\t</system>\n\n"; // wcf block $buffer .= "\t<wcf>\n"; $buffer .= "\t\t<packages>\n"; $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_package\n\t\t\tORDER BY\tpackage"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $buffer .= "\t\t\t<package>\n"; $buffer .= "\t\t\t\t<name><![CDATA[" . StringUtil::escapeCDATA($row['package']) . "]]></name>\n"; $buffer .= "\t\t\t\t<version><![CDATA[" . StringUtil::escapeCDATA($row['packageVersion']) . "]]></version>\n"; $buffer .= "\t\t\t</package>\n"; } $buffer .= "\t\t</packages>\n"; $buffer .= "\t</wcf>\n"; $buffer .= "</systeminfo>"; // output header('Content-Type: application/xml; charset=' . CHARSET); header('Content-Disposition: attachment; filename="systeminfo.xml"'); header('Content-Length: ' . strlen($buffer)); print $buffer; $this->executed(); exit; }