17 if (!defined(
"PSF_ENTRY_POINT"))
18 die(
"Not a valid psf entry point");
20 require_once(dirname(__FILE__) .
"/default_config.php");
21 require_once(dirname(__FILE__) .
"/definitions.php");
22 require_once(dirname(__FILE__) .
"/variables.php");
28 function psf_php_enable_debug()
30 ini_set(
'display_errors', 1);
31 ini_set(
'display_startup_errors', 1);
32 error_reporting(E_ALL);
38 function psf_string_auto_trim($string, $max, $suffix =
"")
40 if (strlen($string) <= $max)
42 return substr($string, 0, $max) . $suffix;
46 function psf_string_startsWith($string, $text)
48 return (strpos($string, $text) === 0);
52 function psf_string_endsWith($string, $text)
54 $length = strlen($text);
58 return (substr($string, -$length) === $text);
62 function psf_string_contains($string, $text)
64 return strpos($string, $text) !==
false;
67 function psf_version()
72 function psf_path($file =
'')
75 return $psf_home . $file;
80 function psf_generate_friendly_name($text)
82 $text = str_replace(
";",
"", $text);
83 $text = str_replace(
"&",
"", $text);
84 $text = str_replace(
"\"",
"", $text);
85 $text = str_replace(
">",
"", $text);
86 $text = str_replace(
"<",
"", $text);
87 $text = str_replace(
" ",
"_", $text);
88 $text = str_replace(
"(",
"", $text);
89 $text = str_replace(
")",
"", $text);
90 $text = str_replace(
"/",
"", $text);
91 $text = strtolower($text);
95 function psf_indent_text($text, $in)
97 global $psf_indent_system_enabled;
98 if (!$psf_indent_system_enabled)
104 $lines = explode(
"\n", $text);
105 foreach ($lines as $line)
106 $result .= $prefix . $line .
"\n";
112 return Localization::Get($key);
115 function psf_string2bool($str)
117 $str = strtolower($str);
125 function psf_curl($link, $timeout=5)
128 curl_setopt($ch, CURLOPT_URL, $link);
129 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
130 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
131 $data = curl_exec($ch);
136 function psf_debug_log($text)
138 global $psf_global_debug_ring;
139 $psf_global_debug_ring[] = $text;
142 function psf_print_debug_as_html()
144 global $psf_global_debug_ring;
146 foreach ($psf_global_debug_ring as $log)
147 $html .=
"<!-- PSF Debug: " . htmlspecialchars($log) .
" -->\n";
152 function psf_get_execution_time()
154 global $psf_global_startup_time;
155 return (microtime(
true) - $psf_global_startup_time);