*/
class Tools {
+ /* octal constants (sys/stat.h) */
+ const S_IFMT = 0170000;
+ const S_IFGITLINK = 0160000; /* GIT defined */
+ const S_IFLNK = 0120000;
+ const S_IFREG = 0100000;
+ const S_IFDIR = 0040000;
+ const S_IPERMS = 0000777;
+ const S_IXUSR = 0000100;
+
+ public static function get_filetype($mode, $exec = false) {
+ if(!preg_match('/^[0-7]+$/', $mode))
+ return $mode;
+
+ $mode = octdec($mode);
+
+ if(($mode & self::S_IFMT) == self::S_IFGITLINK)
+ return 'submodule';
+ else if(($mode & self::S_IFMT) == self::S_IFDIR)
+ return 'directory';
+ else if(($mode & self::S_IFMT) == self::S_IFLNK)
+ return 'symlink';
+ else if(($mode & self::S_IFMT) == self::S_IFREG) {
+ if($exec && ($mode & self::S_IXUSR))
+ return 'executable';
+ return 'file';
+ } else
+ return 'unknown';
+ }
+
+ public static function is_regular_file($mode) {
+ $mode = octdec($mode);
+ return (($mode & self::S_IFMT) == self::S_IFREG);
+ }
+
+ public static function get_file_permissions($mode) {
+ $mode = octdec($mode);
+ return sprintf("%04o",($mode & self::S_IPERMS));
+ }
public static function age_calculate($last_change) {
$result = array();
return $ctext;
}
+ public static function parseTimeZone($timezone) {
+ if(!preg_match("/^([+-])([0-9]{2})([0-9]{2})$/i", $timezone, $treffer))
+ return 0;
+ $offset = ($treffer[1] == '-' ? -1 : 1) * (($treffer[2] * 3600) + ($treffer[3] * 60));
+ return $offset;
+ }
+
}
?>
\ No newline at end of file