3 * @file src/Core/System.php
5 namespace Friendica\Core;
7 use Friendica\BaseObject;
10 * @file include/Core/System.php
12 * @brief Contains the class with system relevant stuff
17 * @brief System methods
19 class System extends BaseObject
22 * @brief Retrieves the Friendica instance base URL
24 * @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN
25 * @return string Friendica server base URL
27 public static function baseUrl($ssl = false)
29 return self::getApp()->get_baseurl($ssl);
33 * @brief Removes the baseurl from an url. This avoids some mixed content problems.
35 * @param string $orig_url The url to be cleaned
37 * @return string The cleaned url
39 public static function removedBaseUrl($orig_url)
41 return self::getApp()->remove_baseurl($orig_url);
45 * @brief Returns a string with a callstack. Can be used for logging.
46 * @param integer $depth optional, default 4
49 public static function callstack($depth = 4)
51 $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
53 // We remove the first two items from the list since they contain data that we don't need.
59 $previous = ['class' => '', 'function' => ''];
61 // The ignore list contains all functions that are only wrapper functions
62 $ignore = ['get_config', 'get_pconfig', 'set_config', 'set_pconfig', 'fetch_url', 'probe_url'];
64 while ($func = array_pop($trace)) {
65 if (!empty($func['class'])) {
66 // Don't show multiple calls from the same function (mostly used for "dba" class)
67 if (($previous['class'] != $func['class']) && ($previous['function'] != 'q')) {
68 $classparts = explode("\\", $func['class']);
69 $callstack[] = array_pop($classparts).'::'.$func['function'];
72 } elseif (!in_array($func['function'], $ignore)) {
73 $callstack[] = $func['function'];
79 while ((count($callstack2) < $depth) && (count($callstack) > 0)) {
80 $callstack2[] = array_pop($callstack);
83 return implode(', ', $callstack2);
87 * @brief Called from db initialisation when db is dead.
89 static public function unavailable() {
92 <head><title>System Unavailable</title></head>
93 <body>Apologies but this site is unavailable at the moment. Please try again later.</body>
100 /// @todo Move the following functions from boot.php
102 function get_guid($size = 16, $prefix = "")
105 function local_user()
106 function public_contact()
107 function remote_user()
110 function is_site_admin()
111 function random_digits($digits)
112 function get_server()
113 function get_temppath()
114 function get_cachefile($file, $writemode = true)
115 function get_itemcachepath()
116 function get_spoolpath()
117 function current_load()