/**
  * @see CacheBuilder::getData()
  */
 public function getData($cacheResource)
 {
     list($cache, $boardID, $languageIDs) = explode('-', $cacheResource['cache']);
     $data = array();
     // get taggable
     require_once WCF_DIR . 'lib/data/tag/TagEngine.class.php';
     $taggable = TagEngine::getInstance()->getTaggable('com.woltlab.wbb.thread');
     // get tag ids
     $tagIDArray = array();
     $sql = "SELECT\t\tCOUNT(*) AS counter, object.tagID\n\t\t\tFROM \t\twbb" . WBB_N . "_thread thread,\n\t\t\t\t\twcf" . WCF_N . "_tag_to_object object\n\t\t\tWHERE \t\tthread.boardID = " . $boardID . "\n\t\t\t\t\tAND object.taggableID = " . $taggable->getTaggableID() . "\n\t\t\t\t\tAND object.languageID IN (" . $languageIDs . ")\n\t\t\t\t\tAND object.objectID = thread.threadID\n\t\t\tGROUP BY \tobject.tagID\n\t\t\tORDER BY \tcounter DESC";
     $result = WCF::getDB()->sendQuery($sql, 500);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $tagIDArray[$row['tagID']] = $row['counter'];
     }
     // get tags
     if (count($tagIDArray)) {
         $sql = "SELECT\t\tname, tagID\n\t\t\t\tFROM\t\twcf" . WCF_N . "_tag\n\t\t\t\tWHERE\t\ttagID IN (" . implode(',', array_keys($tagIDArray)) . ")";
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             $row['counter'] = $tagIDArray[$row['tagID']];
             $this->tags[StringUtil::toLowerCase($row['name'])] = new Tag(null, $row);
         }
         // sort by counter
         uasort($this->tags, array('self', 'compareTags'));
         $data = $this->tags;
     }
     return $data;
 }
 /**
  * Checks the condition.
  *
  * @param	PMRuleCondition		$condition
  * @param	string			$string
  * @return	boolean
  */
 protected function checkCondition(PMRuleCondition $condition, $string)
 {
     $value = StringUtil::toLowerCase($condition->ruleConditionValue);
     $string = StringUtil::toLowerCase($string);
     switch ($condition->ruleCondition) {
         case 'contains':
             if (StringUtil::indexOf($string, $value) !== false) {
                 return true;
             }
             break;
         case 'dontContains':
             if (StringUtil::indexOf($string, $value) === false) {
                 return true;
             }
             break;
         case 'beginsWith':
             if (StringUtil::indexOf($string, $value) === 0) {
                 return true;
             }
             break;
         case 'endsWith':
             if (StringUtil::substring($string, -1 * StringUtil::length($value)) == $value) {
                 return true;
             }
             break;
         case 'isEqualTo':
             if ($value == $string) {
                 return true;
             }
             break;
     }
     return false;
 }
 /**
  * @see CacheBuilder::getData()
  */
 public function getData($cacheResource)
 {
     list($cache, $packageID, $languageIDs) = explode('-', $cacheResource['cache']);
     $data = array();
     // get all taggable types
     $sql = "SELECT\t\ttaggable.taggableID, taggable.name\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency package_dependency,\n\t\t\t\t\twcf" . WCF_N . "_tag_taggable taggable\n\t\t\tWHERE \t\ttaggable.packageID = package_dependency.dependency\n\t\t\t\t\tAND package_dependency.packageID = " . $packageID . "\n\t\t\tORDER BY\tpackage_dependency.priority";
     $result = WCF::getDB()->sendQuery($sql);
     $itemIDs = array();
     while ($row = WCF::getDB()->fetchArray($result)) {
         $itemIDs[$row['name']] = $row['taggableID'];
     }
     if (count($itemIDs) > 0) {
         // get tag ids
         $tagIDs = array();
         $sql = "SELECT\t\tCOUNT(*) AS counter, object.tagID\n\t\t\t\tFROM \t\twcf" . WCF_N . "_tag_to_object object\n\t\t\t\tWHERE \t\tobject.taggableID IN (" . implode(',', $itemIDs) . ")\n\t\t\t\t\t\tAND object.languageID IN (" . $languageIDs . ")\n\t\t\t\tGROUP BY \tobject.tagID\n\t\t\t\tORDER BY \tcounter DESC";
         $result = WCF::getDB()->sendQuery($sql, 500);
         while ($row = WCF::getDB()->fetchArray($result)) {
             $tagIDs[$row['tagID']] = $row['counter'];
         }
         // get tags
         if (count($tagIDs)) {
             $sql = "SELECT\t\tname, tagID\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_tag\n\t\t\t\t\tWHERE\t\ttagID IN (" . implode(',', array_keys($tagIDs)) . ")";
             $result = WCF::getDB()->sendQuery($sql);
             while ($row = WCF::getDB()->fetchArray($result)) {
                 $row['counter'] = $tagIDs[$row['tagID']];
                 $this->tags[StringUtil::toLowerCase($row['name'])] = new Tag(null, $row);
             }
             // sort by counter
             uasort($this->tags, array('self', 'compareTags'));
             $data = $this->tags;
         }
     }
     return $data;
 }
Пример #4
0
 /**
  * Returns class name if scm is known
  *
  * @param	string	$scm	Source Code Management System
  * @return	string	Class name
  */
 public static function getSCM($scm = '')
 {
     self::getCache();
     $scm = StringUtil::toLowerCase($scm);
     if (empty($scm)) {
         return self::$data;
     }
     if (isset(self::$data[$scm])) {
         return self::$data[$scm];
     }
     return null;
 }
 /**
  * @see CacheBuilder::getData()
  */
 public function getData($cacheResource)
 {
     $data = array();
     // read available scm
     $sql = "SELECT\tscm\n\t\t\tFROM\twcf" . WCF_N . "_scm";
     $result = WCF::getDB()->sendQuery($sql);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $key = StringUtil::toLowerCase($row['scm']);
         $data[$key] = $row['scm'];
     }
     return $data;
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // get style filename
     $filename = str_replace(' ', '-', preg_replace('/[^a-z0-9 _-]/', '', StringUtil::toLowerCase($this->style->styleName)));
     // send headers
     header('Content-Type: application/x-gzip; charset=' . CHARSET);
     header('Content-Disposition: attachment; filename="' . $filename . '-style.tgz"');
     // export style
     $this->style->export($this->exportTemplates, $this->exportImages, $this->exportIcons);
     $this->saved();
     exit;
 }
 /**
  * @see Page::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['format'])) {
         $this->format = StringUtil::toLowerCase($_REQUEST['format']);
     }
     if (isset($_REQUEST['hours'])) {
         $this->hours = intval($_REQUEST['hours']);
     }
     if (isset($_REQUEST['limit'])) {
         $this->limit = intval($_REQUEST['limit']);
         if ($this->limit < 1) {
             $this->limit = 1;
         }
     }
 }
 /**
  * Creates a new entry event.
  *
  * @param	integer		$contestID
  * @param	integer		$userID
  * @param	integer		$groupID
  * @param	string		$eventName
  * @param	mixed		$placeholders
  * @param	integer		$time
  * @return	ContestEventEditor
  */
 public static function create($contestID, $userID, $groupID, $eventName, array $placeholders = array(), $time = TIME_NOW)
 {
     $eventName = preg_replace('/^Contest(.*)Editor(.*)$/', '$1$2', $eventName);
     $eventName = empty($eventName) ? 'contest' : StringUtil::toLowerCase($eventName);
     $sql = "INSERT INTO\twcf" . WCF_N . "_contest_event\n\t\t\t\t\t(contestID, userID, groupID, eventName, placeholders, time)\n\t\t\tVALUES\t\t(" . intval($contestID) . ", " . intval($userID) . ", " . intval($groupID) . ", '" . escapeString($eventName) . "', \n\t\t\t\t\t'" . escapeString(serialize($placeholders)) . "', " . intval($time) . ")";
     WCF::getDB()->sendQuery($sql);
     // get id
     $eventID = WCF::getDB()->getInsertID("wcf" . WCF_N . "_contest_event", 'eventID');
     // update entry
     $sql = "UPDATE\twcf" . WCF_N . "_contest\n\t\t\tSET\tevents = events + 1\n\t\t\tWHERE\tcontestID = " . intval($contestID);
     WCF::getDB()->sendQuery($sql);
     $event = new ContestEventEditor($eventID);
     // any event handlers?
     EventHandler::fireAction($event, 'create');
     return $event;
 }
 /**
  * @see Form::readFormParameters()
  */
 public function readFormParameters()
 {
     parent::readFormParameters();
     if (isset($_POST['subject'])) {
         $this->subject = StringUtil::trim($_POST['subject']);
     }
     if (isset($_POST['text'])) {
         $this->text = MessageUtil::stripCrap(StringUtil::trim($_POST['text']));
     }
     if (isset($_POST['activeTab'])) {
         $this->activeTab = $_POST['activeTab'];
     }
     // wysiwyg
     if (isset($_POST['wysiwygEditorMode'])) {
         $this->wysiwygEditorMode = intval($_POST['wysiwygEditorMode']);
     }
     if (isset($_POST['wysiwygEditorHeight'])) {
         $this->wysiwygEditorHeight = intval($_POST['wysiwygEditorHeight']);
     }
     // settings
     $this->enableSmilies = $this->enableHtml = $this->enableBBCodes = $this->parseURL = $this->showSignature = 0;
     if (isset($_POST['parseURL'])) {
         $this->parseURL = intval($_POST['parseURL']);
     }
     if (isset($_POST['enableSmilies'])) {
         $this->enableSmilies = intval($_POST['enableSmilies']);
     }
     $this->enableSmilies = intval($this->enableSmilies && WCF::getUser()->getPermission('user.' . $this->permissionType . '.canUseSmilies'));
     if (isset($_POST['enableHtml'])) {
         $this->enableHtml = intval($_POST['enableHtml']);
     }
     $this->enableHtml = intval($this->enableHtml && WCF::getUser()->getPermission('user.' . $this->permissionType . '.canUseHtml'));
     if (isset($_POST['enableBBCodes'])) {
         $this->enableBBCodes = intval($_POST['enableBBCodes']);
     }
     $this->enableBBCodes = intval($this->enableBBCodes && WCF::getUser()->getPermission('user.' . $this->permissionType . '.canUseBBCodes'));
     if (isset($_POST['showSignature'])) {
         $this->showSignature = intval($_POST['showSignature']);
     }
     // stop shouting
     if (StringUtil::length($this->subject) >= MESSAGE_SUBJECT_STOP_SHOUTING && StringUtil::toUpperCase($this->subject) == $this->subject) {
         $this->subject = StringUtil::wordsToUpperCase(StringUtil::toLowerCase($this->subject));
     }
 }
 /**
  * Returns the name of the user agent icon.
  *
  * @param	string		$userAgentString
  * @return	string		icon name
  */
 public static function getUserAgentIcon($userAgentString)
 {
     $userAgentString = StringUtil::toLowerCase($userAgentString);
     // ie
     if (strpos($userAgentString, 'msie') !== false) {
         return 'browserInternetExplorer';
     } else {
         if (strpos($userAgentString, 'firefox') !== false) {
             return 'browserFirefox';
         } else {
             if (strpos($userAgentString, 'chrome') !== false) {
                 return 'browserChrome';
             } else {
                 if (strpos($userAgentString, 'safari') !== false) {
                     return 'browserSafari';
                 } else {
                     if (strpos($userAgentString, 'opera') !== false) {
                         return 'browserOpera';
                     } else {
                         if (strpos($userAgentString, 'konqueror') !== false) {
                             return 'browserKonqueror';
                         } else {
                             if (strpos($userAgentString, 'netscape') !== false) {
                                 return 'browserNetscape';
                             } else {
                                 if (strpos($userAgentString, 'webkit') !== false) {
                                     return 'browserSafari';
                                 } else {
                                     if (strpos($userAgentString, 'gecko') !== false) {
                                         return 'browserMozilla';
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return '';
 }
Пример #11
0
 /**
  * @see	BotDetectorInterface::checkBot()
  */
 public function checkBot()
 {
     $text = StringUtil::trim($_POST['text']);
     // string to lower case
     $text = StringUtil::toLowerCase($text);
     // split the text in single words
     $textSplit = preg_split('/' . $this->delimiters . '+/', $text);
     // check each word if it censored.
     foreach ($textSplit as $word) {
         foreach ($this->badWordList as $censoredWord) {
             $maxDiff = ceil(strlen($censoredWord) / 4);
             $diff = levenshtein($censoredWord, $word);
             if ($diff <= $maxDiff) {
                 $this->information .= '"' . $word . '" matched "' . $censoredWord . '" with ld ' . $diff . ';';
                 continue 2;
             }
         }
     }
     if (!empty($this->information)) {
         return true;
     }
     return false;
 }
 /**
  * @see Cronjob::execute()
  */
 public function execute($data)
 {
     $filename = FileUtil::downloadFileFromHttp('http://www.woltlab.com/spiderlist/spiderlist.xml', 'spiders');
     $xml = new XML($filename);
     $spiders = $xml->getElementTree('spiderlist');
     if (count($spiders['children'])) {
         // delete old entries
         $sql = "TRUNCATE TABLE wcf" . WCF_N . "_spider";
         WCF::getDB()->sendQuery($sql);
         $inserts = '';
         foreach ($spiders['children'] as $spider) {
             $identifier = $spider['attrs']['ident'];
             // get attributes
             foreach ($spider['children'] as $values) {
                 $spider[$values['name']] = $values['cdata'];
             }
             $name = $spider['name'];
             $info = '';
             if (isset($spider['info'])) {
                 $info = $spider['info'];
             }
             if (!empty($inserts)) {
                 $inserts .= ',';
             }
             $inserts .= "('" . escapeString(StringUtil::toLowerCase($identifier)) . "', '" . escapeString($name) . "', '" . escapeString($info) . "')";
         }
         if (!empty($inserts)) {
             $sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_spider\n\t\t\t\t\t\t\t\t(spiderIdentifier, spiderName, spiderURL)\n\t\t\t\t\tVALUES\t\t\t" . $inserts;
             WCF::getDB()->sendQuery($sql);
         }
         // clear spider cache
         WCF::getCache()->clear(WCF_DIR . 'cache', 'cache.spiders.php');
     }
     // delete tmp file
     @unlink($filename);
 }
 /**
  * Process configured dates with plaintext names, dashed ranges and slashed intervals.
  * 
  * @param	array		$cronjobsCache
  */
 protected function processConfiguredDates($cronjobsCache = array())
 {
     // get arrays containing the configured dates from our database (or, respectively, the cache).
     $this->cronjobsDataRaw['startMinute'] = explode(',', $cronjobsCache['startMinute']);
     $this->cronjobsDataRaw['startHour'] = explode(',', $cronjobsCache['startHour']);
     $this->cronjobsDataRaw['startDom'] = explode(',', $cronjobsCache['startDom']);
     $this->cronjobsDataRaw['startMonth'] = explode(',', $cronjobsCache['startMonth']);
     $this->cronjobsDataRaw['startDow'] = explode(',', $cronjobsCache['startDow']);
     // process plaintext month and day of week values.
     foreach ($this->cronjobsDataRaw as $element => $datesRaw) {
         foreach ($datesRaw as $position => $dateRaw) {
             switch ($element) {
                 // months.
                 case 'startMonth':
                     $datesPlain = array('jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec');
                     break;
                     // days of week.
                 // days of week.
                 case 'startDow':
                     // for us, the week begins on sunday because date() wants us to think that way.
                     $datesPlain = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
                     break;
                     // nothing to do for the others.
                 // nothing to do for the others.
                 default:
                     break;
             }
             // if $dateRaw is a time range expressed with a dash, a special handling is needed.
             if (StringUtil::indexOf($dateRaw, '-')) {
                 // dismantle the range into an array.
                 $range = explode('-', $dateRaw);
                 // investigate the new array.
                 foreach ($range as $key => $value) {
                     $slashPos = StringUtil::indexOf($value, '/');
                     if (StringUtil::length($value) == 3 && $slashPos === false) {
                         // this is a plaintext name, so convert this into a number.
                         $datePlain = StringUtil::toLowerCase($value);
                         $dateNum = array_search($datePlain, $datesPlain);
                         // put the converted value back to the array.
                         if ($dateNum !== false) {
                             $range[$key] = $dateNum;
                         }
                     } else {
                         if ($slashPos !== false) {
                             // this value additionally contains a slashed interval,
                             // so once again part this value.
                             $interval = explode('/', $value);
                             if (StringUtil::length($interval['0']) == 3) {
                                 // this is a plaintext name, so convert this into a number.
                                 $datePlain = StringUtil::toLowerCase($interval['0']);
                                 $dateNum = array_search($datePlain, $datesPlain);
                                 if ($dateNum !== false) {
                                     $range[$key] = $dateNum;
                                 }
                             } else {
                                 $range[$key] = $interval['0'];
                             }
                             $range[$key + 1] = $interval['1'];
                         }
                     }
                 }
                 // reassemble array.
                 foreach ($range as $key => $digit) {
                     $range[$key] = intval($digit);
                 }
                 $newPos = array_search($dateRaw, $this->cronjobsDataRaw[$element]);
                 $this->cronjobsDataRaw[$element][$newPos] = $range;
                 $this->getDashedRange($element, $newPos);
             } else {
                 // this is no range.
                 $slashPos = StringUtil::indexOf($dateRaw, '/');
                 if (StringUtil::length($dateRaw) == 3 && $slashPos === false) {
                     // this is a plaintext name, so convert this into a number.
                     $datePlain = StringUtil::toLowerCase($dateRaw);
                     $dateNum = array_search($datePlain, $datesPlain);
                     // put the converted value back to the original array.
                     if ($dateNum !== false) {
                         $this->cronjobsDataRaw[$element][$position] = $dateNum;
                     }
                 } else {
                     if ($slashPos !== false) {
                         // this value additionally contains a slashed interval,
                         // so once again part this value.
                         $interval = explode('/', $dateRaw);
                         // put parted value back to array.
                         unset($this->cronjobsDataRaw[$element][$position]);
                         $this->cronjobsDataRaw[$element][$position][] = $interval['0'];
                         $this->cronjobsDataRaw[$element][$position][] = $interval['1'];
                         // break down slashed interval.
                         $this->getSlashedInterval($element, $position);
                     }
                 }
             }
         }
     }
 }
 /**
  * Reads out PackageData
  *
  * @param	array<array>	$package	the package array generated in self::readPackages()
  * @param	mixed		$version	the version to check
  * @param	mixed		$field		should only one information be returned?
  * @return	mixed				either an array with data, or the data wanted in $field
  */
 public static function getPackageData(array $package, $version = null, $field = null)
 {
     $data = array();
     if ($version === null) {
         // read firest package for general information
         $key = array_keys($package);
         $xml = $package[$key[0]]['xml']->getElementTree('data');
     } else {
         $xml = $package[$version]['xml']->getElementTree('data');
     }
     $data['packageIdentifier'] = $xml['attrs']['name'];
     $data['isUpdate'] = false;
     $data['plugin'] = $data['packagename'] = $data['packagedescription'] = $data['standalone'] = null;
     foreach ($xml['children'] as $child) {
         switch (StringUtil::toLowerCase($child['name'])) {
             // read in package information
             case 'packageinformation':
                 foreach ($child['children'] as $packageInformation) {
                     switch (StringUtil::toLowerCase($packageInformation['name'])) {
                         case 'packagename':
                             if (!isset($data['packageName'])) {
                                 $data['packageName'] = $packageInformation['cdata'];
                             }
                             break;
                         case 'packagedescription':
                             if (!isset($data['packageDescription'])) {
                                 $data['packageDescription'] = $packageInformation['cdata'];
                             }
                             break;
                         case 'standalone':
                             $data['standalone'] = intval($packageInformation['cdata']);
                             break;
                         case 'promptparent':
                         case 'plugin':
                             if (!Package::isValidPackageName($packageInformation['cdata'])) {
                                 $data['plugin'] = null;
                             }
                             $data['plugin'] = $packageInformation['cdata'];
                             break;
                     }
                 }
                 break;
                 // read in author information
             // read in author information
             case 'authorinformation':
                 foreach ($child['children'] as $authorInformation) {
                     switch (StringUtil::toLowerCase($authorInformation['name'])) {
                         case 'author':
                             $data['author'] = $authorInformation['cdata'];
                             break;
                         case 'authorurl':
                             $data['authorURL'] = $authorInformation['cdata'];
                             break;
                     }
                 }
                 break;
                 // read in requirements
             // read in requirements
             case 'requiredpackages':
                 foreach ($child['children'] as $requiredPackage) {
                     if (Package::isValidPackageName($requiredPackage['cdata'])) {
                         $data['requirements'][$requiredPackage['cdata']] = array('name' => $requiredPackage['cdata']) + $requiredPackage['attrs'];
                     }
                 }
                 break;
                 // get installation and update instructions
             // get installation and update instructions
             case 'instructions':
                 if ($child['attrs']['type'] == 'update') {
                     $data['isUpdate'] = true;
                     $data['fromVersions'][] = $child['attrs']['fromversion'];
                 }
                 break;
         }
     }
     if ($field === null) {
         return $data;
     } else {
         return $data[$field];
     }
 }
Пример #15
0
 /**
  * @see DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     $tagIDArray = $this->getTagsIDArray();
     // get tags
     if (count($tagIDArray)) {
         $sql = "SELECT\t\tname, tagID\n\t\t\t\tFROM\t\twcf" . WCF_N . "_tag\n\t\t\t\tWHERE\t\ttagID IN (" . implode(',', array_keys($tagIDArray)) . ")\n\t\t\t\tORDER BY\tname";
         $result = WCF::getDB()->sendQuery($sql);
         while ($row = WCF::getDB()->fetchArray($result)) {
             $row['counter'] = $tagIDArray[$row['tagID']];
             $this->tags[StringUtil::toLowerCase($row['name'])] = new Tag(null, $row);
         }
         // assign sizes
         foreach ($this->tags as $tag) {
             $tag->setSize($this->calculateSize($tag->getCounter()));
         }
     }
 }
 /**
  * Handles a request on the attachment edit form.
  * Deletes old or uploads new attachments.
  */
 public function handleRequest()
 {
     // delete uploaded attachments
     if (isset($_POST['delete']) && is_array($_POST['delete']) && count($_POST['delete'])) {
         // delete selected attachments
         $keys = array_keys($_POST['delete']);
         $this->delete(intval(array_shift($keys)));
     }
     // move uploaded attachments
     if (isset($_POST['attachmentListPositions']) && is_array($_POST['attachmentListPositions'])) {
         $positionChanged = false;
         $positions = ArrayUtil::toIntegerArray($_POST['attachmentListPositions']);
         foreach ($positions as $attachmentID => $position) {
             $attachmentID = intval($attachmentID);
             if (isset($this->attachments[$this->messageID][$attachmentID]) && $this->attachments[$this->messageID][$attachmentID]['showOrder'] != $position) {
                 $this->attachments[$this->messageID][$attachmentID]['showOrder'] = $position;
                 $sql = "UPDATE\twcf" . WCF_N . "_attachment\n\t\t\t\t\t\tSET\tshowOrder = " . $position . "\n\t\t\t\t\t\tWHERE\tattachmentID = " . $attachmentID;
                 WCF::getDB()->registerShutdownUpdate($sql);
                 $positionChanged = true;
             }
         }
         if ($positionChanged) {
             uasort($this->attachments[$this->messageID], array('self', 'compareAttachments'));
         }
     }
     // upload new attachments
     if (isset($_FILES) && count($_FILES) && isset($_FILES['upload'])) {
         // upload new attachments
         for ($x = 0, $y = count($_FILES['upload']['name']); $x < $y; $x++) {
             $attachment = array();
             $attachment['attachmentName'] = $_FILES['upload']['name'][$x];
             if ($attachment['attachmentName']) {
                 $attachment['attachment'] = $_FILES['upload']['tmp_name'][$x];
                 $attachment['attachmentSize'] = $_FILES['upload']['size'][$x];
                 $attachment['sha1Hash'] = sha1_file($attachment['attachment']);
                 $attachment['attachmentExtension'] = StringUtil::toLowerCase(StringUtil::substring($attachment['attachmentName'], StringUtil::lastIndexOf($attachment['attachmentName'], '.') + 1));
                 $attachment['fileType'] = $_FILES['upload']['type'][$x];
                 $attachment['isImage'] = 0;
                 if (strchr($attachment['fileType'], 'image')) {
                     // check mime
                     $attachment['fileType'] = 'application/octet-stream';
                     if (($imageData = @getImageSize($attachment['attachment'])) !== false) {
                         if (strchr($imageData['mime'], 'image')) {
                             $attachment['fileType'] = $imageData['mime'];
                             if ($attachment['fileType'] == 'image/bmp') {
                                 $attachment['fileType'] = 'image/x-ms-bmp';
                             }
                             $attachment['isImage'] = 1;
                         }
                     }
                 }
                 $attachment['showOrder'] = (isset($this->attachments[$this->messageID]) ? count($this->attachments[$this->messageID]) : 0) + 1;
                 if ($this->checkAttachment($attachment['attachment'], $attachment['attachmentName'] . ':' . $attachment['sha1Hash'], $attachment['attachmentName'], $attachment['attachmentSize'], $attachment['attachmentExtension'], $attachment['isImage'])) {
                     $attachment['messageID'] = $this->messageID;
                     $attachment['idHash'] = $this->idHash;
                     $attachment['userID'] = WCF::getUser()->userID;
                     $attachment['uploadTime'] = TIME_NOW;
                     $attachment['thumbnailType'] = '';
                     if ($this->setAttachment($attachment)) {
                         $this->attachmentHashes[count($this->attachmentHashes)] = $attachment['attachmentName'] . ':' . $attachment['sha1Hash'];
                         $attachment['fileTypeIcon'] = $this->getFileTypeIcon($attachment);
                         $this->attachments[$this->messageID][$attachment['attachmentID']] = $attachment;
                     }
                 }
             }
         }
     }
     $this->assign();
     if (count($this->errors)) {
         // throw user exception
         throw new UserInputException('attachments', $this->errors);
     }
 }
 /**
  * Returns the right file type icon for the given attachment.
  * 
  * @param	array		$data
  * @return	string
  */
 protected static function getFileTypeIcon($data)
 {
     // get file extension
     $extension = StringUtil::firstCharToUpperCase(StringUtil::toLowerCase(StringUtil::substring($data['attachmentName'], StringUtil::lastIndexOf($data['attachmentName'], '.') + 1)));
     // get file type icon
     if (file_exists(WCF_DIR . 'icon/fileTypeIcon' . $extension . 'M.png')) {
         return StyleManager::getStyle()->getIconPath('fileTypeIcon' . $extension . 'M.png');
     } else {
         foreach (self::$fileTypeGroups as $key => $group) {
             if (in_array($extension, $group)) {
                 return StyleManager::getStyle()->getIconPath('fileTypeIcon' . $key . 'M.png');
             }
         }
         return StyleManager::getStyle()->getIconPath('fileTypeIconDefaultM.png');
     }
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // get user editor
     $editor = WCF::getUser()->getEditor();
     $success = array();
     // quit
     if (WCF::getUser()->getPermission('user.profile.canQuit')) {
         if (!WCF::getUser()->quitStarted && $this->quit == 1) {
             $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\t\tSET\tquitStarted = " . TIME_NOW . "\n\t\t\t\t\tWHERE\tuserID = " . WCF::getUser()->userID;
             WCF::getDB()->sendQuery($sql);
             $this->quitStarted = TIME_NOW;
             $success[] = 'wcf.user.quit.success';
         } else {
             if (WCF::getUser()->quitStarted && $this->cancelQuit == 1) {
                 $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\t\tSET\tquitStarted = 0\n\t\t\t\t\tWHERE\tuserID = " . WCF::getUser()->userID;
                 WCF::getDB()->sendQuery($sql);
                 $this->quitStarted = 0;
                 $success[] = 'wcf.user.quit.cancel.success';
             }
         }
     }
     // username
     if ($this->canChangeUsername && $this->username != WCF::getUser()->username) {
         $fields = array();
         if (StringUtil::toLowerCase($this->username) != StringUtil::toLowerCase(WCF::getUser()->username)) {
             if (!$this->canChangeUsername) {
                 $this->username = WCF::getUser()->username;
                 return;
             }
             $fields = array('lastUsernameChange' => TIME_NOW, 'oldUsername' => $editor->username);
         }
         $editor->update($this->username, '', '', null, null, $fields);
         $success[] = 'wcf.user.rename.success';
     }
     // email
     if (WCF::getUser()->getPermission('user.profile.canChangeEmail') && $this->email != WCF::getUser()->email && $this->email != WCF::getUser()->newEmail) {
         if (REGISTER_ACTIVATION_METHOD == 0 || REGISTER_ACTIVATION_METHOD == 2 || StringUtil::toLowerCase($this->email) == StringUtil::toLowerCase(WCF::getUser()->email)) {
             // update email
             $editor->update('', $this->email);
             $success[] = 'wcf.user.emailChange.success';
         } else {
             if (REGISTER_ACTIVATION_METHOD == 1) {
                 // get reactivation code
                 $activationCode = UserRegistrationUtil::getActivationCode();
                 // save as new email
                 $sql = "UPDATE\twcf" . WCF_N . "_user\n\t\t\t\t\tSET\treactivationCode = " . $activationCode . ",\n\t\t\t\t\t\tnewEmail = '" . escapeString($this->email) . "'\n\t\t\t\t\tWHERE\tuserID = " . WCF::getUser()->userID;
                 WCF::getDB()->registerShutdownUpdate($sql);
                 $subjectData = array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE));
                 $messageData = array('PAGE_TITLE' => WCF::getLanguage()->get(PAGE_TITLE), '$username' => WCF::getUser()->username, '$userID' => WCF::getUser()->userID, '$activationCode' => $activationCode, 'PAGE_URL' => PAGE_URL, 'MAIL_ADMIN_ADDRESS' => MAIL_ADMIN_ADDRESS);
                 require_once WCF_DIR . 'lib/data/mail/Mail.class.php';
                 $mail = new Mail(array(WCF::getUser()->username => $this->email), WCF::getLanguage()->get('wcf.user.emailChange.needReactivation.mail.subject', $subjectData), WCF::getLanguage()->get('wcf.user.emailChange.needReactivation.mail', $messageData));
                 $mail->send();
                 $success[] = 'wcf.user.emailChange.needReactivation';
             }
         }
     }
     // password
     if (!empty($this->newPassword) || !empty($this->confirmNewPassword)) {
         $editor->update('', '', $this->newPassword);
         // update cookie
         if (isset($_COOKIE[COOKIE_PREFIX . 'password'])) {
             HeaderUtil::setCookie('password', StringUtil::getSaltedHash($this->newPassword, $editor->salt), TIME_NOW + 365 * 24 * 3600);
         }
         $success[] = 'wcf.user.passwordChange.success';
     }
     // reset session
     WCF::getSession()->resetUserData();
     $this->saved();
     // show success message
     WCF::getTPL()->assign('success', $success);
     // reset password
     $this->password = '';
     $this->newPassword = $this->confirmNewPassword = '';
 }
 /**
  * @see WOTAPIPServerClient::handleRequest()
  */
 public function handleRequest($lines)
 {
     // get data
     $this->connection = 'Close';
     $this->data = array();
     $this->key = '';
     $this->salt = '';
     $this->sendTime = 0;
     $this->action = '';
     foreach ($lines as $no => $line) {
         if ($no == 0 && substr($line, 0, 8) == 'WOTAPIP/') {
             $this->protocolVersion = substr($line, 8, 3);
             continue;
         }
         $parts = ArrayUtil::trim(explode(':', $line, 2));
         switch ($parts[0]) {
             case 'KEY':
                 $this->key = StringUtil::trim($parts[1]);
                 break;
             case 'SALT':
                 $this->salt = StringUtil::trim($parts[1]);
                 break;
             case 'ACTION':
                 $this->action = StringUtil::trim($parts[1]);
                 break;
             case 'SENDTIME':
                 $this->sendTime = intval(StringUtil::trim($parts[1]));
                 break;
             case 'CONNECTION':
                 if ($parts[1] !== 'Close' && $parts[1] !== 'Keep-Alive') {
                     $this->send('unkwown connection value ' . $parts[1], 206);
                     return;
                 }
                 $this->connection = StringUtil::trim($parts[1]);
                 break;
             default:
                 if (substr($parts[0], 0, 5) == 'DATA_') {
                     $parts[0] = substr($parts[0], 5);
                 } else {
                     $this->send('unkwown line ' . $parts[0], 204);
                     return;
                 }
                 $this->data[StringUtil::toLowerCase($parts[0])] = $parts[1];
         }
     }
     // validate
     if (empty($this->key)) {
         $this->send('no key found', 200);
         return;
     }
     if (empty($this->salt)) {
         $this->send('no salt found', 201);
         return;
     }
     if (empty($this->action)) {
         $this->send('no key found', 202);
         return;
     }
     if (empty($this->sendTime)) {
         $this->send('sendTime not given', 203);
         return;
     }
     if ($this->sendTime < time() - 60 * 60 || $this->sendTime > time()) {
         $this->send('invalid sendTime given', 207);
         return;
     }
     /*if(count($this->data) > 5) {
     			$this->send('too many data given', 205);
     			return;
     		}*/
     if (!$this->validateKey($this->data)) {
         return;
     }
     // execute
     $className = 'WOTAPI' . StringUtil::firstCharToUpperCase(StringUtil::toLowerCase($this->action)) . 'Action';
     if (!file_exists(LW_DIR . 'lib/wotapi/' . $className . '.class.php')) {
         $this->send('classfile not found', 210);
         return;
     }
     require_once LW_DIR . 'lib/wotapi/' . $className . '.class.php';
     if (!class_exists($className)) {
         $this->send('class \'' . $className . '\' not found', 211);
         return;
     }
     try {
         $action = new $className($this);
     } catch (Exception $e) {
         ob_start();
         $e->show();
         $output = ob_get_contents();
         ob_end_clean();
         $this->send('exception thrown while execution: ' . addcslashes($output, ":\n\r\\"), 220);
     }
 }
 /**
  * Builds a bbcode tag.
  * 
  * @param	string		$string
  * @return	array		bbcode tag data
  */
 protected function buildTag($string)
 {
     $tag = array('name' => '', 'closing' => false, 'source' => $string);
     if (StringUtil::substring($string, 1, 1) == '/') {
         // closing tag
         $tag['name'] = StringUtil::toLowerCase(StringUtil::substring($string, 2, StringUtil::length($string) - 3));
         $tag['closing'] = true;
     } else {
         // opening tag
         // split tag and attributes
         preg_match("!^\\[([a-z0-9]+)=?(.*)]\$!si", $string, $match);
         $tag['name'] = StringUtil::toLowerCase($match[1]);
         // build attributes
         if (!empty($match[2])) {
             $tag['attributes'] = $this->buildTagAttributes($match[2]);
         }
     }
     return $tag;
 }
Пример #21
0
 /**
  * @see Template::getPluginFilename()
  */
 public function getPluginFilename($type, $tag)
 {
     return $this->pluginDir . TMP_FILE_PREFIX . 'TemplatePlugin' . StringUtil::firstCharToUpperCase(StringUtil::toLowerCase($type)) . StringUtil::firstCharToUpperCase(StringUtil::toLowerCase($tag)) . '.class.php';
 }
 /**
  * Search data within a node
  *
  * @param	object	$node
  */
 private function readNode(SimpleXMLElement $node)
 {
     $packageType = '';
     // read package version from xml
     if (StringUtil::toLowerCase($node->getName()) == 'packageinformation') {
         $children = $this->xml->getChildren($node);
         foreach ($children as $child) {
             $name = StringUtil::toLowerCase($child->getName());
             switch ($name) {
                 case 'plugin':
                     $this->package['packageType'] = 'plugin';
                     break;
                 case 'standalone':
                     if ($this->xml->getCDATA($child) == 1) {
                         $this->package['packageType'] = 'standalone';
                     }
                     break;
                 case 'version':
                     $this->package['version'] = $this->xml->getCDATA($child);
                     break;
             }
         }
         if (!isset($this->package['packageType'])) {
             $this->package['packageType'] = 'plugin';
         }
     }
     // skip required and optional packages when working with an archive
     if (!$this->skipPackages) {
         if (!array_key_exists('requiredpackages', $this->package) && StringUtil::toLowerCase($node->getName()) == 'requiredpackages') {
             // required packages found
             $packageType = 'requiredpackage';
         }
         if (!array_key_exists('optionalpackages', $this->package) && StringUtil::toLowerCase($node->getName()) == 'optionalpackages') {
             // optional packages found
             $packageType = 'optionalpackage';
         }
     }
     // read all requested packages
     if (!empty($packageType)) {
         $children = $this->xml->getChildren($node);
         foreach ($children as $child) {
             $attributes = $this->xml->getAttributes($child);
             $packageName = $this->xml->getCDATA($child);
             $this->package[$packageType][$packageName] = array('minversion' => isset($attributes['minversion']) ? $attributes['minversion'] : '', 'file' => isset($attributes['file']) ? $attributes['file'] : '');
         }
     }
 }
 /**
  * Applies the prefilters to the given string.
  * 
  * @param	string		$string
  * @return	string
  */
 public function applyPrefilters($string)
 {
     foreach ($this->template->getPrefilters() as $prefilter) {
         if (!is_object($prefilter)) {
             $filename = $this->template->getPluginFilename('prefilter', $prefilter);
             if (!file_exists($filename)) {
                 throw new SystemException('unable to find class file ' . $filename, 11000);
             }
             require_once $filename;
             $className = 'TemplatePluginPrefilter' . StringUtil::firstCharToUpperCase(StringUtil::toLowerCase($prefilter));
             if (!class_exists($className)) {
                 throw new SystemException($this->formatSyntaxError('unable to find prefilter class ' . $className, $this->currentIdentifier), 11001);
             }
             $prefilter = new $className();
         }
         if ($prefilter instanceof TemplatePluginPrefilter) {
             $string = $prefilter->execute($string, $this);
         } else {
             throw new SystemException($this->formatSyntaxError("Prefilter '" . $prefilter . "' does not implement the interface 'TemplatePluginPrefilter'", $this->currentIdentifier), 11010);
         }
     }
     return $string;
 }
 /**
  * Returns wether or not this invitation is valid.
  * 
  * @return	boolean
  */
 public static function isValid($email, $code)
 {
     $sql = "SELECT\tCOUNT(*) AS invitations\n\t\t\tFROM \twcf" . WCF_N . "_user_invitation\n\t\t\tWHERE\temail = '" . escapeString(StringUtil::toLowerCase($email)) . "'\n\t\t\t\tAND code = " . intval($code);
     $row = WCF::getDB()->getFirstRow($sql);
     return $row['invitations'] == 1;
 }
 /**
  * @see WOTAPIPServerClient::handleRequest()
  */
 public function handleRequest($lines)
 {
     // get data
     $this->connection = 'Close';
     $this->data = array();
     $this->action = '';
     $dataComing = false;
     $resumption = $this->started;
     foreach ($lines as $no => $line) {
         // not encrypted
         if (($no == 0 || $no == 1) && !$resumption) {
             // version
             if (substr($line, 0, 8) == 'WOTAPIP/') {
                 $this->started = true;
                 continue;
             }
             // initialization vector
             $iv = base64_decode($line);
             $this->crypter = new Mcrypt();
             $this->crypter->init(CRYPTER_KEY, $iv);
             continue;
         }
         // encrypted
         $line = $this->crypter->decryptFromText($line);
         $parts = ArrayUtil::trim(explode(':', $line, 2));
         if ($dataComing) {
             $this->data[StringUtil::toLowerCase($parts[0])] = $parts[1];
             continue;
         }
         switch ($parts[0]) {
             case 'ACTION':
                 $this->action = $parts[1];
                 break;
             case 'CONNECTION':
                 if ($parts[1] !== 'Close' && $parts[1] !== 'Keep-Alive') {
                     $this->send('unknown connection value ' . $parts[1], 206);
                     return;
                 }
                 $this->connection = StringUtil::trim($parts[1]);
                 break;
             case 'DATA':
                 $dataComing = true;
                 break;
             default:
                 if (substr($parts[0], 0, 5) == 'DATA_') {
                     $parts[0] = substr($parts[0], 5);
                 } else {
                     $this->send('unknown line ' . $parts[0], 204);
                     return;
                 }
         }
     }
     // validate
     if (empty($this->action)) {
         $this->send('no action specified', 202);
         return;
     }
     // execute
     $className = 'WOTAPI' . StringUtil::firstCharToUpperCase(StringUtil::toLowerCase($this->action)) . 'Action';
     if (!file_exists(LW_DIR . 'lib/wotapi/' . $className . '.class.php')) {
         $this->send('classfile not found', 210);
         return;
     }
     require_once LW_DIR . 'lib/wotapi/' . $className . '.class.php';
     if (!class_exists($className)) {
         $this->send('class \'' . $className . '\' not found', 211);
         return;
     }
     try {
         $action = new $className($this);
     } catch (Exception $e) {
         ob_start();
         $e->show();
         $output = ob_get_contents();
         ob_end_clean();
         $this->send('exception thrown while execution: ' . addcslashes($output, ":\n\r\\"), 220);
     }
 }
Пример #26
0
 /**
  * @see Page::readData()
  */
 public function readData()
 {
     parent::readData();
     if (!count($_POST)) {
         // default values
         // user
         if ($this->userID) {
             $user = new User($this->userID);
             $this->recipients = $user->username;
         }
         // existing message
         if ($this->pm) {
             if ($this->forwarding) {
                 $data = array('$author' => $this->pm->username ? $this->pm->username : WCF::getLanguage()->get('wcf.pm.author.system'), '$date' => DateUtil::formatTime(null, $this->pm->time), '$recipients' => implode(', ', $this->pm->getRecipients()), '$subject' => $this->pm->subject, '$text' => $this->pm->message);
                 $this->subject = WCF::getLanguage()->get('wcf.pm.forward.subject', array('$subject' => $this->pm->subject));
                 $this->text = WCF::getLanguage()->get('wcf.pm.forward.text', $data);
             } else {
                 if ($this->reply) {
                     $this->subject = WCF::getLanguage()->get('wcf.pm.reply.subject', array('$subject' => $this->pm->subject));
                     // replace RE: RE: RE: by RE[3]:
                     $this->subject = preg_replace('/(^RE: RE\\[)(\\d+)(?=\\]:)/ie', '"RE[".(\\2+1)', $this->subject);
                     $this->subject = preg_replace('/^(RE: RE:(?: RE:)+)/ie', '"RE[".substr_count("\\1", "RE:")."]:"', $this->subject);
                     if ($this->replyToAll == 1) {
                         $recipients = array();
                         foreach ($this->pm->getRecipients() as $recipient) {
                             $recipients[] = $recipient->recipient;
                         }
                         $recipients[] = $this->pm->username;
                         $recipients = array_unique($recipients);
                         foreach ($recipients as $key => $value) {
                             if (StringUtil::toLowerCase($value) == StringUtil::toLowerCase(WCF::getUser()->username)) {
                                 unset($recipients[$key]);
                                 break;
                             }
                         }
                         $this->recipients = implode(', ', $recipients);
                     } else {
                         $this->recipients = $this->pm->username;
                     }
                 } else {
                     // edit draft
                     $sql = "SELECT\t\trecipient, isBlindCopy\n\t\t\t\t\t\tFROM\t\twcf" . WCF_N . "_pm_to_user\n\t\t\t\t\t\tWHERE\t\tpmID = " . $this->pm->pmID . "\n\t\t\t\t\t\tORDER BY\trecipient";
                     $result = WCF::getDB()->sendQuery($sql);
                     while ($row = WCF::getDB()->fetchArray($result)) {
                         if ($row['isBlindCopy']) {
                             if (!empty($this->blindCopies)) {
                                 $this->blindCopies .= ', ';
                             }
                             $this->blindCopies .= $row['recipient'];
                         } else {
                             if (!empty($this->recipients)) {
                                 $this->recipients .= ', ';
                             }
                             $this->recipients .= $row['recipient'];
                         }
                     }
                     $this->subject = $this->pm->subject;
                     $this->text = $this->pm->message;
                     // options
                     $this->enableSmilies = $this->pm->enableSmilies;
                     $this->enableHtml = $this->pm->enableHtml;
                     $this->enableBBCodes = $this->pm->enableBBCodes;
                     $this->showSignature = $this->pm->showSignature;
                 }
             }
         }
     }
     if ($this->reply) {
         require_once WCF_DIR . 'lib/data/message/pm/PMList.class.php';
         $this->pmList = new PMList($this->pm);
         $this->pmList->sqlLimit = 10;
         $this->pmList->readObjects();
     }
 }
 /**
  * Returns the right file type icon for the given attachment.
  * 
  * @return	string
  */
 public function getFileTypeIcon()
 {
     if ($this->fileTypeIcon === null) {
         $this->fileTypeIcon = '';
         // get file extension
         $extension = StringUtil::firstCharToUpperCase(StringUtil::toLowerCase(StringUtil::substring($this->attachmentName, StringUtil::lastIndexOf($this->attachmentName, '.') + 1)));
         // get file type icon
         if (file_exists(WCF_DIR . 'icon/fileTypeIcon' . $extension . 'M.png')) {
             $this->fileTypeIcon = 'fileTypeIcon' . $extension . 'M.png';
         } else {
             foreach (self::$fileTypeGroups as $key => $group) {
                 if (in_array($extension, $group)) {
                     $this->fileTypeIcon = 'fileTypeIcon' . $key . 'M.png';
                     break;
                 }
             }
             if (empty($this->fileTypeIcon)) {
                 $this->fileTypeIcon = 'fileTypeIconDefaultM.png';
             }
         }
     }
     if (!class_exists('StyleManager')) {
         return RELATIVE_WCF_DIR . 'icon/' . $this->fileTypeIcon;
     } else {
         return StyleManager::getStyle()->getIconPath($this->fileTypeIcon);
     }
 }
 /**
  * @see TemplateAddForm::validateTemplateName()
  */
 protected function validateTemplateName()
 {
     if ($this->copy || StringUtil::toLowerCase($this->tplName) != StringUtil::toLowerCase($this->template->templateName)) {
         parent::validateTemplateName();
     }
 }
Пример #29
0
 /**
  * Validates the password hash for Simple Machines Forums 1.x (smf1).
  * 
  * @param	string		$username
  * @param	string		$password
  * @param	string		$salt
  * @param	string		$dbHash
  * @return	boolean
  */
 protected static function smf1($username, $password, $salt, $dbHash)
 {
     return self::secureCompare($dbHash, sha1(StringUtil::toLowerCase($username) . $password));
 }
Пример #30
0
 /**
  * Parses the xml stucture from a packages_update.xml.
  *
  * @param	array		$child
  * @param	string		$package
  * @return	array		$packageInfo
  */
 protected static function parsePackageUpdateXMLBlock($child = array(), $package = '')
 {
     // define default values
     $packageInfo = array('packageDescription' => '', 'standalone' => 0, 'plugin' => '', 'author' => '', 'authorURL' => '', 'versions' => array());
     // loop through tags inside the <package> tag.
     foreach ($child['children'] as $packageDefinition) {
         switch (StringUtil::toLowerCase($packageDefinition['name'])) {
             case 'packageinformation':
                 // loop through tags inside the <packageInformation> tag.
                 foreach ($packageDefinition['children'] as $packageInformation) {
                     switch (StringUtil::toLowerCase($packageInformation['name'])) {
                         case 'packagename':
                             $packageInfo['packageName'] = $packageInformation['cdata'];
                             break;
                         case 'packagedescription':
                             $packageInfo['packageDescription'] = $packageInformation['cdata'];
                             break;
                         case 'standalone':
                             $packageInfo['standalone'] = intval($packageInformation['cdata']);
                             break;
                         case 'plugin':
                             $packageInfo['plugin'] = $packageInformation['cdata'];
                             break;
                     }
                 }
                 break;
             case 'authorinformation':
                 // loop through tags inside the <authorInformation> tag.
                 foreach ($packageDefinition['children'] as $authorInformation) {
                     switch (StringUtil::toLowerCase($authorInformation['name'])) {
                         case 'author':
                             $packageInfo['author'] = $authorInformation['cdata'];
                             break;
                         case 'authorurl':
                             $packageInfo['authorURL'] = $authorInformation['cdata'];
                             break;
                     }
                 }
                 break;
             case 'versions':
                 // loop through <version> tags inside the <versions> tag.
                 foreach ($packageDefinition['children'] as $versions) {
                     $versionNo = $versions['attrs']['name'];
                     // loop through tags inside this <version> tag.
                     foreach ($versions['children'] as $version) {
                         switch (StringUtil::toLowerCase($version['name'])) {
                             case 'fromversions':
                                 // loop through <fromversion> tags inside the <fromversions> block.
                                 foreach ($version['children'] as $fromversion) {
                                     $packageInfo['versions'][$versionNo]['fromversions'][] = $fromversion['cdata'];
                                 }
                                 break;
                             case 'updatetype':
                                 $packageInfo['versions'][$versionNo]['updateType'] = $version['cdata'];
                                 break;
                             case 'timestamp':
                                 $packageInfo['versions'][$versionNo]['timestamp'] = $version['cdata'];
                                 break;
                             case 'file':
                                 $packageInfo['versions'][$versionNo]['file'] = $version['cdata'];
                                 break;
                             case 'requiredpackages':
                                 // loop through <requiredPackage> tags inside the <requiredPackages> block.
                                 foreach ($version['children'] as $requiredPackages) {
                                     $required = $requiredPackages['cdata'];
                                     $packageInfo['versions'][$versionNo]['requiredPackages'][$required] = array();
                                     if (isset($requiredPackages['attrs']['minversion'])) {
                                         $packageInfo['versions'][$versionNo]['requiredPackages'][$required]['minversion'] = $requiredPackages['attrs']['minversion'];
                                     }
                                 }
                                 break;
                             case 'excludedpackages':
                                 // loop through <excludedpackage> tags inside the <excludedpackages> block.
                                 foreach ($version['children'] as $excludedpackage) {
                                     $exclusion = $excludedpackage['cdata'];
                                     $packageInfo['versions'][$versionNo]['excludedPackages'][$exclusion] = array();
                                     if (isset($excludedpackage['attrs']['version'])) {
                                         $packageInfo['versions'][$versionNo]['excludedPackages'][$exclusion]['version'] = $excludedpackage['attrs']['version'];
                                     }
                                 }
                                 break;
                         }
                     }
                 }
                 break;
         }
     }
     // check required tags
     if (!isset($packageInfo['packageName'])) {
         throw new SystemException("required tag 'packageName' is missing for package '" . $package . "'", 13001);
     }
     if (!count($packageInfo['versions'])) {
         throw new SystemException("required tag 'versions' is missing for package '" . $package . "'", 13001);
     }
     return $packageInfo;
 }