2 namespace Friendica\Core;
7 * @file include/Core/System.php
9 * @brief Contains the class with system relevant stuff
14 * @brief System methods
21 * @brief Initializes the static class variable
23 private static function init() {
26 if (!is_object(self::$a)) {
32 * @brief Retrieves the Friendica instance base URL
34 * @param bool $ssl Whether to append http or https under SSL_POLICY_SELFSIGN
35 * @return string Friendica server base URL
37 public static function baseUrl($ssl = false) {
39 return self::$a->get_baseurl($ssl);
43 * @brief Removes the baseurl from an url. This avoids some mixed content problems.
45 * @param string $orig_url
47 * @return string The cleaned url
49 public static function removedBaseUrl($orig_url) {
51 return self::$a->remove_baseurl($orig_url);
55 * @brief Returns a string with a callstack. Can be used for logging.
59 public static function callstack($depth = 4) {
60 $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
62 // We remove the first two items from the list since they contain data that we don't need.
68 $previous = array('class' => '', 'function' => '');
70 // The ignore list contains all functions that are only wrapper functions
71 $ignore = array('get_config', 'get_pconfig', 'set_config', 'set_pconfig', 'fetch_url', 'probe_url');
73 while ($func = array_pop($trace)) {
74 if (!empty($func['class'])) {
75 // Don't show multiple calls from the same function (mostly used for "dba" class)
76 if (($previous['class'] != $func['class']) && ($previous['function'] != 'q')) {
77 $classparts = explode("\\", $func['class']);
78 $callstack[] = array_pop($classparts).'::'.$func['function'];
81 } elseif (!in_array($func['function'], $ignore)) {
82 $callstack[] = $func['function'];
87 $callstack2 = array();
88 while ((count($callstack2) < $depth) && (count($callstack) > 0)) {
89 $callstack2[] = array_pop($callstack);
92 return implode(', ', $callstack2);
95 /// @todo Move the following functions from boot.php
97 function get_guid($size = 16, $prefix = "")
100 function local_user()
101 function public_contact()
102 function remote_user()
105 function is_site_admin()
106 function random_digits($digits)
107 function get_server()
108 function get_temppath()
109 function get_cachefile($file, $writemode = true)
110 function get_itemcachepath()
111 function get_spoolpath()
112 function current_load()