Better location handling (remix by Datenanalyst David)

This commit is contained in:
markseu 2013-07-30 11:31:40 +02:00
parent a17580f2d1
commit 61fe77ac41
2 changed files with 6 additions and 7 deletions

View file

@ -878,10 +878,9 @@ class Yellow_Toolbox
// Check if location is valid
static function isValidLocation($location)
{
$string = "/";
$string = "";
$tokens = explode('/', $location);
for($i=1; $i<count($tokens)-1; ++$i) $string .= self::normaliseName($tokens[$i]).'/';
$string .= self::normaliseName($tokens[$i]);
for($i=1; $i<count($tokens); ++$i) $string .= '/'.self::normaliseName($tokens[$i]);
return $location == $string;
}

View file

@ -54,12 +54,9 @@ class Yellow_Commandline
{
if($this->yellow->config->isExisting("serverName") && $this->yellow->config->isExisting("serverBase"))
{
$this->yellow->toolbox->timerStart($time);
$serverName = $this->yellow->config->get("serverName");
$serverBase = $this->yellow->config->get("serverBase");
list($statusCode, $contentCount, $mediaCount, $errorCount) = $this->buildStatic($serverName, $serverBase, $location, $path);
$this->yellow->toolbox->timerStop($time);
if(defined("DEBUG") && DEBUG>=1) echo "Yellow_Commandline::build time:$time ms\n";
} else {
list($statusCode, $contentCount, $mediaCount, $errorCount) = array(500, 0, 0, 1);
$fileName = $this->yellow->config->get("configDir").$this->yellow->config->get("configFile");
@ -77,6 +74,7 @@ class Yellow_Commandline
// Build static files
function buildStatic($serverName, $serverBase, $location, $path)
{
$this->yellow->toolbox->timerStart($time);
$statusCodeMax = $errorCount = 0;
if(empty($location))
{
@ -109,6 +107,8 @@ class Yellow_Commandline
}
if(defined("DEBUG") && DEBUG>=1) echo "Yellow_Commandline::buildStatic status:$statusCode file:$fileName\n";
}
$this->yellow->toolbox->timerStop($time);
if(defined("DEBUG") && DEBUG>=1) echo "Yellow_Commandline::buildStatic time:$time ms\n";
return array($statusCodeMax, count($pages), count($fileNames), $errorCount);
}
@ -123,7 +123,7 @@ class Yellow_Commandline
$statusCode = $this->yellow->request();
if($statusCode != 404)
{
$ok = true;
$ok = false;
$modified = strtotime($this->yellow->page->getHeader("Last-Modified"));
if(preg_match("/^(\w+)\/(\w+)/", $this->yellow->page->getHeader("Content-Type"), $matches))
{