31 if (stristr(PHP_OS,
'LINUX')) {
34 if (stristr(PHP_OS,
'DARWIN')) {
37 if (stristr(PHP_OS,
'WIN')) {
40 if (stristr(PHP_OS,
'BSD')) {
43 if (stristr(PHP_OS,
'UNIX')) {
46 if (stristr(PHP_OS,
'HP-UX')) {
49 if (stristr(PHP_OS,
'IRIX')) {
52 if (stristr(PHP_OS,
'SUNOS')) {
77 sys_get_temp_dir().DIRECTORY_SEPARATOR.
'simplesaml' 82 if (!is_dir($tempDir)) {
83 if (!mkdir($tempDir, 0700,
true)) {
85 throw new \SimpleSAML_Error_Exception(
86 'Error creating temporary directory "'.$tempDir.
'": '.
87 (is_array(
$error) ?
$error[
'message'] :
'no error available')
90 } elseif (function_exists(
'posix_getuid')) {
92 $stat = lstat($tempDir);
93 if ($stat[
'uid'] !== posix_getuid()) {
94 throw new \SimpleSAML_Error_Exception(
95 'Temporary directory "'.$tempDir.
'" does not belong to the current user.' 120 if (
$base === null) {
129 if (substr(
$path, 0, 1) ===
'/') {
141 } elseif ($d ===
'..') {
144 if (substr(
$ret, -1) !==
'/') {
178 if (!is_string(
$filename) || !is_string(
$data) || !is_numeric($mode)) {
179 throw new \InvalidArgumentException(
'Invalid input parameters');
182 $tmpFile = self::getTempDir().DIRECTORY_SEPARATOR.rand();
184 $res = @file_put_contents($tmpFile,
$data);
185 if (
$res ===
false) {
186 $error = error_get_last();
187 throw new \SimpleSAML_Error_Exception(
188 'Error saving file "'.$tmpFile.
'": '.
189 (is_array(
$error) ?
$error[
'message'] :
'no error available')
193 if (self::getOS() !== self::WINDOWS) {
194 if (!chmod($tmpFile, $mode)) {
196 $error = error_get_last();
198 throw new \SimpleSAML_Error_Exception(
199 'Error changing file mode of "'.$tmpFile.
'": '.
200 (is_array(
$error) ?
$error[
'message'] :
'no error available')
207 $error = error_get_last();
208 throw new \SimpleSAML_Error_Exception(
209 'Error moving "'.$tmpFile.
'" to "'.
$filename.
'": '.
210 (is_array(
$error) ?
$error[
'message'] :
'no error available')
214 if (function_exists(
'opcache_invalidate')) {
static writeFile($filename, $data, $mode=0600)
Atomically write a file.
static getTempDir()
This function retrieves the path to a directory where temporary files can be saved.
static getOS()
This function returns the Operating System we are running on.
foreach($_POST as $key=> $value) $res
static resolvePath($path, $base=null)
Resolve a (possibly) relative path from the given base path.
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d