"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/Server.php" between
canopy-3.0.4.tar.gz and canopy-3.0.5.tar.gz

About: Canopy provides a complete web site content management system (successor of "phpwebsite").

Server.php  (canopy-3.0.4):Server.php  (canopy-3.0.5)
<?php <?php
namespace Canopy; namespace Canopy;
/** /**
* Class to assist with _SERVER super globals. * Class to assist with _SERVER super globals.
* @author Matthew McNaney <mcnaneym@appstate.edu> * @author Matthew McNaney <mcnaneym@appstate.edu>
* @license http://opensource.org/licenses/lgpl-3.0.html * @license http://opensource.org/licenses/lgpl-3.0.html
*/ */
class Server class Server
{ {
skipping to change at line 32 skipping to change at line 33
if (strpos($_SERVER['REQUEST_URI'], $_SERVER['PHP_SELF']) === FALSE) { if (strpos($_SERVER['REQUEST_URI'], $_SERVER['PHP_SELF']) === FALSE) {
self::forwardInfo(); self::forwardInfo();
} }
$url = self::getCurrentUrl(); $url = self::getCurrentUrl();
$method = $_SERVER['REQUEST_METHOD']; $method = $_SERVER['REQUEST_METHOD'];
$vars = $_REQUEST; $vars = $_REQUEST;
$data = file_get_contents('php://input'); $data = file_get_contents('php://input');
// The 'Accept' header might not always be set. If not, // The 'Accept' header might not always be set. If not,
// we'll assume the client wants 'text/html' // we'll assume the client wants 'text/html'
if(isset($_SERVER['HTTP_ACCEPT'])){ if (isset($_SERVER['HTTP_ACCEPT'])) {
$accept = new \phpws2\Http\Accept($_SERVER['HTTP_ACCEPT']); $accept = new \phpws2\Http\Accept($_SERVER['HTTP_ACCEPT']);
} else { } else {
$accept = new \phpws2\Http\Accept('text/html'); $accept = new \phpws2\Http\Accept('text/html');
} }
self::$REQUEST_SINGLETON = new \Canopy\Request($url, $method, $vars, self::$REQUEST_SINGLETON = new \Canopy\Request($url, $method, $vars,
$data, $accept); $data, $accept);
$dataValues = array(); $dataValues = array();
parse_str($data, $dataValues); parse_str($data, $dataValues);
$content_type = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_ TYPE'] : null; $content_type = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_ TYPE'] : null;
switch ($method) { switch ($method) {
case 'PATCH': case 'PATCH':
self::$REQUEST_SINGLETON->setPatchVars($dataValues); self::$REQUEST_SINGLETON->setPatchVars($dataValues);
break; break;
skipping to change at line 180 skipping to change at line 182
/** /**
* Returns the url of the current page * Returns the url of the current page
* If redirect is true and a redirect occurs at the root level, * If redirect is true and a redirect occurs at the root level,
* index.php is returned. * index.php is returned.
* @param boolean $relative Returned site url does not contain web root. * @param boolean $relative Returned site url does not contain web root.
* @param boolean $use_redirect Returns the address as mod_rewrite format. * @param boolean $use_redirect Returns the address as mod_rewrite format.
* @return string * @return string
*/ */
public static function getCurrentUrl($relative = true, $use_redirect = true) public static function getCurrentUrl($relative = true, $use_redirect = true)
{ {
static $saveUrl = [];
if (isset($saveUrl[(int) $relative][(int) $use_redirect])) {
return $saveUrl[(int) $relative][(int) $use_redirect];
}
$address = array(); $address = array();
if (!$relative) { if (!$relative) {
$address[] = self::getSiteUrl(); $address[] = self::getSiteUrl();
} }
$self = & $_SERVER['PHP_SELF']; $self = $_SERVER['PHP_SELF'];
if ($use_redirect && isset($_SERVER['REQUEST_URI'])) { if ($use_redirect && isset($_SERVER['REQUEST_URI'])) {
// some users reported problems using redirect_url so parsing uri in stead // some users reported problems using redirect_url so parsing uri in stead
if ($_SERVER['REQUEST_URI'] != '/') { if ($_SERVER['REQUEST_URI'] != '/') {
$root_url = substr($self, 0, strrpos($self, '/')); $root_url = substr($self, 0, strrpos($self, '/'));
$address[] = preg_replace("@^$root_url/@", '', $address[] = preg_replace("@^$root_url/@", '',
$_SERVER['REQUEST_URI']); $_SERVER['REQUEST_URI']);
} else { } else {
$address[] = 'index.php'; $address[] = 'index.php';
} }
return implode('', $address); $saveUrl[(int) $relative][(int) $use_redirect] = implode('',
} $address);
} else {
$stack = explode('/', $self); $stack = explode('/', $self);
$url = array_pop($stack); $url = array_pop($stack);
if (!empty($url)) { if (!empty($url)) {
$address[] = $url; $address[] = $url;
} }
if (!empty($_SERVER['QUERY_STRING'])) { if (!empty($_SERVER['QUERY_STRING'])) {
$address[] = '?'; $address[] = '?';
$address[] = $_SERVER['QUERY_STRING']; $address[] = $_SERVER['QUERY_STRING'];
}
$address = implode('', $address);
$address = preg_replace('@^/?@', '', $address);
$saveUrl[(int) $relative][(int) $use_redirect] = $address;
} }
$address = implode('', $address); return $saveUrl[(int) $relative][(int) $use_redirect];
return preg_replace('@^/?@', '', $address);
} }
/** /**
* *
* @param boolean $with_http * @param boolean $with_http
* @param boolean $with_directory * @param boolean $with_directory
* @return string * @return string
*/ */
public static function getSiteUrl($with_http = true, $with_directory = true, public static function getSiteUrl($with_http = true, $with_directory = true,
$end_slash = true) $end_slash = true)
 End of changes. 8 change blocks. 
17 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)