/**
* Loads the required classes automatically.
*/
-function __autoload($className) {
+spl_autoload_register(function($className) {
$namespaces = explode('\\', $className);
if (count($namespaces) > 1) {
// remove 'wcf' component
require_once($classPath);
}
}
-}
+});
/**
* Escapes strings for execution in sql queries.
$i = 0;
// Read the 512 bytes header
+ $longFilename = null;
while (strlen($binaryData = $this->file->read(512)) != 0) {
// read header
$header = $this->readHeader($binaryData);
if ($header === false) {
continue;
}
- $this->contentList[$i] = $header;
- $this->contentList[$i]['index'] = $i;
- $i++;
+
+ // fixes a bug that files with long names aren't correctly
+ // extracted
+ if ($longFilename !== null) {
+ $header['filename'] = $longFilename;
+ $longFilename = null;
+ }
+ if ($header['typeflag'] == 'L') {
+ $format = 'Z'.$header['size'].'filename';
+
+ $fileData = unpack($format, $this->file->read(512));
+ $longFilename = $fileData['filename'];
+ $header['size'] = 0;
+ }
+ // don't include the @LongLink file in the content list
+ else {
+ $this->contentList[$i] = $header;
+ $this->contentList[$i]['index'] = $i;
+ $i++;
+ }
$this->file->seek($this->file->tell() + (512 * ceil(($header['size'] / 512))));
}
/**
* Unpacks file header for one file entry.
- *
+ *
* @param string $binaryData
* @return array $fileheader
*/
$checksum += ord(substr($binaryData, $i, 1));
}
- // Extract the values
- //$data = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor", $binaryData);
- if (version_compare(PHP_VERSION, '5.5.0-dev', '>=')) {
- $format = 'Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/Z8checksum/Z1typeflag/Z100link/Z6magic/Z2version/Z32uname/Z32gname/Z8devmajor/Z8devminor/Z155prefix';
- }
- else {
- $format = 'a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1typeflag/a100link/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155prefix';
- }
+ // extract values
+ $format = 'Z100filename/Z8mode/Z8uid/Z8gid/Z12size/Z12mtime/Z8checksum/Z1typeflag/Z100link/Z6magic/Z2version/Z32uname/Z32gname/Z8devmajor/Z8devminor/Z155prefix';
$data = unpack($format, $binaryData);
* @return array
*/
protected static function getAvailableLanguages() {
- $languages = $match = array();
- $tar = new Tar(SETUP_FILE);
- foreach ($tar->getContentList() as $file) {
- if (strpos($file['filename'], 'setup/lang/') === 0 && substr($file['filename'], -4) == '.xml') {
- $xml = new XML();
- $xml->load(TMP_DIR.$file['filename']);
- $languageCode = LanguageEditor::readLanguageCodeFromXML($xml);
- $languageName = LanguageEditor::readLanguageNameFromXML($xml);
-
- $languages[$languageCode] = $languageName;
- }
+ $languages = $match = [];
+ foreach (glob(TMP_DIR.'setup/lang/*.xml') as $file) {
+ $xml = new XML();
+ $xml->load($file);
+ $languageCode = LanguageEditor::readLanguageCodeFromXML($xml);
+ $languageName = LanguageEditor::readLanguageNameFromXML($xml);
+
+ $languages[$languageCode] = $languageName;
}
- $tar->close();
// sort languages by language name
asort($languages);
}
// login as admin
- $factory = new ACPSessionFactory();
+ $factory = WCF::getDIContainer()->make(ACPSessionFactory::class);
$factory->load();
SessionHandler::getInstance()->changeUser($admin);
*/
protected $applicationHandler;
- /**
- * @var PageMenu
- */
- protected $pageMenu;
-
/**
* @var RequestHandler
*/
* @param RequestHandler $requestHandler
* @param RouteHandler $routeHandler
*/
- public function __construct(ApplicationHandler $applicationHandler, PageMenu $pageMenu, RequestHandler $requestHandler, RouteHandler $routeHandler) {
+ public function __construct(ApplicationHandler $applicationHandler, RequestHandler $requestHandler, RouteHandler $routeHandler) {
$this->applicationHandler = $applicationHandler;
- $this->pageMenu = $pageMenu;
$this->requestHandler = $requestHandler;
$this->routeHandler = $routeHandler;
$controller = 'Index';
}
else {
- return $this->pageMenu->getLandingPage()->getProcessor()->getLink();
+ // loading the PageMenu object as a dependency in ACP requests breaks everything
+ return WCF::getDIContainer()->get(PageMenu::class)->getLandingPage()->getProcessor()->getLink();
}
}
*/
protected $isACPRequest = false;
- /**
- * @var PageMenu
- */
- protected $pageMenu;
-
/**
* @var RouteHandler
*/
* @param ControllerMap $controllerMap
* @param RouteHandler $routeHandler
*/
- public function __construct(ApplicationHandler $applicationHandler, ControllerMap $controllerMap, PageMenu $pageMenu, RouteHandler $routeHandler) {
+ public function __construct(ApplicationHandler $applicationHandler, ControllerMap $controllerMap, RouteHandler $routeHandler) {
$this->applicationHandler = $applicationHandler;
$this->controllerMap = $controllerMap;
- $this->pageMenu = $pageMenu;
$this->routeHandler = $routeHandler;
parent::__construct();
return;
}
- $landingPage = $this->pageMenu->getLandingPage();
+ // loading the PageMenu object as a dependency in ACP requests breaks everything
+ $landingPage = WCF::getDIContainer()->get(PageMenu::class)->getLandingPage();
if ($landingPage === null) {
return;
}
use wcf\system\request\ControllerMap;
use wcf\system\request\RequestHandler;
use wcf\system\request\RouteHandler;
+use wcf\system\WCF;
/**
* Dynamic route implementation to resolve HTTP requests, handling controllers using a distinct pattern.
*/
protected $isACP = false;
- /**
- * @var PageMenu;
- */
- protected $pageMenu;
-
/**
* pattern for incoming requests
* @var string
*
* @param ApplicationHandler $applicationHandler
* @param ControllerMap $controllerMap
- * @param PageMenu $pageMenu
* @param RequestHandler $requestHandler
* @param RouteHandler $routeHandler
*/
- public function __construct(ApplicationHandler $applicationHandler, ControllerMap $controllerMap, PageMenu $pageMenu, RequestHandler $requestHandler, RouteHandler $routeHandler) {
+ public function __construct(ApplicationHandler $applicationHandler, ControllerMap $controllerMap, RequestHandler $requestHandler, RouteHandler $routeHandler) {
$this->applicationHandler = $applicationHandler;
$this->controllerMap = $controllerMap;
- $this->pageMenu = $pageMenu;
$this->requestHandler = $requestHandler;
$this->routeHandler = $routeHandler;
if (count($components) == 1 && isset($components['controller'])) {
$ignoreController = false;
- if (!RequestHandler::getInstance()->isACPRequest()) {
- $landingPage = PageMenu::getInstance()->getLandingPage();
+ if (!$this->requestHandler->isACPRequest()) {
+ // loading the PageMenu object as a dependency in ACP requests breaks everything
+ $landingPage = WCF::getDIContainer()->get(PageMenu::class)->getLandingPage();
if ($this->primaryApplication === '') {
- $primaryApplication = ApplicationHandler::getInstance()->getPrimaryApplication();
- $this->primaryApplication = ApplicationHandler::getInstance()->getAbbreviation($primaryApplication->packageID);
+ $primaryApplication = $this->applicationHandler->getPrimaryApplication();
+ $this->primaryApplication = $this->applicationHandler->getAbbreviation($primaryApplication->packageID);
}
// check if this is the default controller
- if (strcasecmp(RouteHandler::getInstance()->getDefaultController($application), $components['controller']) === 0) {
+ if (strcasecmp($this->routeHandler->getDefaultController($application), $components['controller']) === 0) {
// check if this matches the primary application
if ($this->primaryApplication === $application) {
if (strcasecmp($landingPage->getController(), $components['controller']) === 0) {