public static function fileinfo($fname) { list($dirname, $root, $protocol, $fname) = getRealPath($fname); if (!is_file($fname)) { throw new Exception("You are reading an invalid resource"); } if (!is_readable($fname)) { throw new Exception("Read permission denied"); } $mime = fileMime($fname); $data = array('path' => $protocol . $dirname, 'filename' => basename($fname), 'size' => filesize($fname), 'mime' => $mime, 'permissions' => filePermissions($fname), 'ctime' => null, 'mtime' => null); if (($mtime = filemtime($fname)) > 0) { $data["mtime"] = date(self::DATE_FORMAT, $mtime); } if (($ctime = filectime($fname)) > 0) { $data["ctime"] = date(self::DATE_FORMAT, $ctime); } if ($mime && preg_match("/^image/", $mime)) { if (function_exists('exif_read_data')) { if ($exif = exif_read_data($fname)) { if ($exif !== false) { if (is_array($exif)) { $tmp = array(); foreach ($exif as $key => $section) { if (is_array($section)) { foreach ($section as $name => $val) { $tmp[] = "{$key}.{$name}: {$val}"; } } } $data['exif'] = implode("\n", $tmp); } } } } else { $data['exif'] = "No EXIF data could be extracted. Missing 'exif_read_data'"; } if (!$data['exif']) { $data['exif'] = "No EXIF data found"; } } return $data; }
function changePermissionsViaPhp($configProblem, $filesProblem) { // ************************************************* // function changePermissionsViaPhp // Parameters: // $filesProblem: if or if problems with permissions on files occured // $configProblem: if or if not problems with permissions to create config occured // Return value: TRUE on success, otherwise FALSE // // Tries to use the builtin PHP-chmod to change the permissions // as needed by SiFiEx // Chmod is many time forbidden on hosters and even if not the PHP-user // maybe not allowed the permissions for files belogning to the FTP-user // ************************************************* if (!function_exists("chmod")) { return FALSE; } $filesDone = FALSE; $configDone = FALSE; if ($filesProblem) { if (@chmod("./files", 0777) && @chmod("./files/Standard", 0777)) { $filesDone = TRUE; } } else { $filesDone = TRUE; } if ($configProblem) { $oldPerm = filePermissions("./", TRUE); if (chmod("./", 0777)) { if ($this->writeNewConfig()) { chmod("./", $oldPerm); $configDone = TRUE; } } } else { $configDone = TRUE; } if ($filesDone && $configDone) { $this->filesProblem = FALSE; $this->configProblem = FALSE; return TRUE; } else { return FALSE; } }