*/
namespace Friendica\Core;
-use Friendica\BaseObject;
+use Friendica\DI;
use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Util\XML;
/**
* @brief System methods
*/
-class System extends BaseObject
+class System
{
- /**
- * @brief Retrieves the Friendica instance base URL
- *
- * @param bool $ssl Whether to append http or https under BaseURL::SSL_POLICY_SELFSIGN
- * @return string Friendica server base URL
- * @throws InternalServerErrorException
- */
- public static function baseUrl($ssl = false)
- {
- return self::getApp()->getBaseURL($ssl);
- }
-
- /**
- * @brief Removes the baseurl from an url. This avoids some mixed content problems.
- *
- * @param string $orig_url The url to be cleaned
- *
- * @return string The cleaned url
- * @throws \Exception
- */
- public static function removedBaseUrl($orig_url)
- {
- return self::getApp()->removeBaseURL($orig_url);
- }
-
/**
* @brief Returns a string with a callstack. Can be used for logging.
* @param integer $depth optional, default 4
* and adds an application/json HTTP header to the output.
* After finishing the process is getting killed.
*
- * @param array $x The input content.
+ * @param mixed $x The input content.
* @param string $content_type Type of the input (Default: 'application/json').
*/
public static function jsonExit($x, $content_type = 'application/json') {
if (is_bool($prefix) && !$prefix) {
$prefix = '';
} elseif (empty($prefix)) {
- $prefix = hash('crc32', self::getApp()->getHostName());
+ $prefix = hash('crc32', DI::baseUrl()->getHostname());
}
while (strlen($prefix) < ($size - 13)) {
* Redirects to an external URL (fully qualified URL)
* If you want to route relative to the current Friendica base, use App->internalRedirect()
*
- * @param string $url The new Location to redirect
+ * @param string $url The new Location to redirect
+ * @param int $code The redirection code, which is used (Default is 302)
+ *
* @throws InternalServerErrorException If the URL is not fully qualified
*/
- public static function externalRedirect($url)
+ public static function externalRedirect($url, $code = 302)
{
if (empty(parse_url($url, PHP_URL_SCHEME))) {
throw new InternalServerErrorException("'$url' is not a fully qualified URL, please use App->internalRedirect() instead");
}
+ switch ($code) {
+ case 302:
+ // this is the default code for a REDIRECT
+ // We don't need a extra header here
+ break;
+ case 301:
+ header('HTTP/1.1 301 Moved Permanently');
+ break;
+ case 307:
+ header('HTTP/1.1 307 Temporary Redirect');
+ break;
+ }
+
header("Location: $url");
exit();
}
/// @todo Move the following functions from boot.php
/*
- function killme()
function local_user()
function public_contact()
function remote_user()
function notice($s)
function info($s)
function is_site_admin()
- function get_server()
function get_temppath()
function get_cachefile($file, $writemode = true)
function get_itemcachepath()