Annotation of /trunk/lib/UnixPlatform.class.php
Parent Directory
|
Revision Log
Revision 2 - (view) (download)
| 1 : | andphe | 2 | <?php |
| 2 : | /* | ||
| 3 : | * $RCSfile: UnixPlatform.class.php,v $ | ||
| 4 : | * | ||
| 5 : | * Gallery - a web based photo album viewer and editor | ||
| 6 : | * Copyright (C) 2000-2004 Bharat Mediratta | ||
| 7 : | * | ||
| 8 : | * This program is free software; you can redistribute it and/or modify | ||
| 9 : | * it under the terms of the GNU General Public License as published by | ||
| 10 : | * the Free Software Foundation; either version 2 of the License, or (at | ||
| 11 : | * your option) any later version. | ||
| 12 : | * | ||
| 13 : | * This program is distributed in the hope that it will be useful, but | ||
| 14 : | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 : | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 16 : | * General Public License for more details. | ||
| 17 : | * | ||
| 18 : | * You should have received a copy of the GNU General Public License | ||
| 19 : | * along with this program; if not, write to the Free Software | ||
| 20 : | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
| 21 : | */ | ||
| 22 : | /** | ||
| 23 : | * @version $Id:UnixPlatform.class.php 106 2007-02-10 22:30:30Z kevinuru $ | ||
| 24 : | * @package zOOmGallery | ||
| 25 : | * @author Mike de Boer <mailme@mikedeboer.nl> | ||
| 26 : | */ | ||
| 27 : | |||
| 28 : | /** | ||
| 29 : | * An Unix version of the platform class | ||
| 30 : | * | ||
| 31 : | * @access public | ||
| 32 : | */ | ||
| 33 : | class UnixPlatform extends zoom { | ||
| 34 : | |||
| 35 : | function UnixPlatform() { | ||
| 36 : | //empty constructor | ||
| 37 : | } | ||
| 38 : | |||
| 39 : | function copy($source, $dest) { | ||
| 40 : | $umask = umask(0113); | ||
| 41 : | $results = copy($source, $dest); | ||
| 42 : | umask($umask); | ||
| 43 : | return true; | ||
| 44 : | } | ||
| 45 : | |||
| 46 : | function exec($cmd, &$results, &$status, $debugfile="") { | ||
| 47 : | if (!empty($debugfile)) { | ||
| 48 : | $cmd = "($cmd) 2>$debugfile"; | ||
| 49 : | } | ||
| 50 : | return exec($cmd, $results, $status); | ||
| 51 : | } | ||
| 52 : | |||
| 53 : | function tempdir() { | ||
| 54 : | return export_filename(getenv("TEMP")); | ||
| 55 : | } | ||
| 56 : | |||
| 57 : | function file_exists($filename) { | ||
| 58 : | return @file_exists($filename); | ||
| 59 : | } | ||
| 60 : | |||
| 61 : | function is_link($filename) { | ||
| 62 : | /* if the link is broken it will spew a warning, so ignore it */ | ||
| 63 : | return @is_link($filename); | ||
| 64 : | } | ||
| 65 : | |||
| 66 : | function filesize($filename) { | ||
| 67 : | return filesize($filename); | ||
| 68 : | } | ||
| 69 : | |||
| 70 : | function getimagesize($filename) { | ||
| 71 : | return getimagesize($filename); | ||
| 72 : | } | ||
| 73 : | |||
| 74 : | function fopen($filename, $mode, $use_include_path=0) { | ||
| 75 : | return fopen($filename, $mode, $use_include_path); | ||
| 76 : | } | ||
| 77 : | |||
| 78 : | function fclose($fp) { | ||
| 79 : | return @fclose($fp); | ||
| 80 : | } | ||
| 81 : | |||
| 82 : | function is_dir($filename) { | ||
| 83 : | return @is_dir($filename); | ||
| 84 : | } | ||
| 85 : | |||
| 86 : | function is_file($filename) { | ||
| 87 : | return @is_file($filename); | ||
| 88 : | } | ||
| 89 : | |||
| 90 : | function opendir($path) { | ||
| 91 : | return opendir($path); | ||
| 92 : | } | ||
| 93 : | |||
| 94 : | function closedir($dir_handle) { | ||
| 95 : | return closedir($dir_handle); | ||
| 96 : | } | ||
| 97 : | |||
| 98 : | function chdir($path) { | ||
| 99 : | return chdir($path); | ||
| 100 : | } | ||
| 101 : | |||
| 102 : | function readdir($dir_handle) { | ||
| 103 : | return readdir($dir_handle); | ||
| 104 : | } | ||
| 105 : | |||
| 106 : | function rename($oldname, $newname) { | ||
| 107 : | return rename($oldname, $newname); | ||
| 108 : | } | ||
| 109 : | |||
| 110 : | function stat($filename) { | ||
| 111 : | return stat($filename); | ||
| 112 : | } | ||
| 113 : | |||
| 114 : | function unlink($filename) { | ||
| 115 : | return unlink($filename); | ||
| 116 : | } | ||
| 117 : | |||
| 118 : | function is_executable($filename) { | ||
| 119 : | return is_executable($filename); | ||
| 120 : | } | ||
| 121 : | |||
| 122 : | function import_filename($filename) { | ||
| 123 : | return $filename; | ||
| 124 : | } | ||
| 125 : | |||
| 126 : | function export_filename($filename) { | ||
| 127 : | return $filename; | ||
| 128 : | } | ||
| 129 : | |||
| 130 : | function executable($filename) { | ||
| 131 : | return $filename; | ||
| 132 : | } | ||
| 133 : | |||
| 134 : | function mkdir($filename, $perms = '0666') { | ||
| 135 : | $perms = octdec($perms); | ||
| 136 : | $umask = umask(0); | ||
| 137 : | /* | ||
| 138 : | * PHP 4.2.0 on Unix (specifically FreeBSD) has a bug where mkdir | ||
| 139 : | * causes a seg fault if you specify modes. | ||
| 140 : | * | ||
| 141 : | * See: http://bugs.php.net/bug.php?id=16905 | ||
| 142 : | * | ||
| 143 : | * We can't reliably determine the OS, so let's just turn off the | ||
| 144 : | * permissions for any Unix implementation. | ||
| 145 : | */ | ||
| 146 : | if (!strcmp(phpversion(), "4.2.0")) { | ||
| 147 : | $results = mkdir($this->import_filename($filename, 0)); | ||
| 148 : | } else { | ||
| 149 : | $results = mkdir($this->import_filename($filename, 0), $perms); | ||
| 150 : | } | ||
| 151 : | |||
| 152 : | umask($umask); | ||
| 153 : | return $results; | ||
| 154 : | } | ||
| 155 : | |||
| 156 : | function rmdir($path) { | ||
| 157 : | return rmdir($path); | ||
| 158 : | } | ||
| 159 : | |||
| 160 : | /** | ||
| 161 : | * Chmods files and directories recursively to given permissions. Available from 1.0.0 up. | ||
| 162 : | * @param $path The starting file or directory (no trailing slash) | ||
| 163 : | * @param $perms Integer value to chmod files. NULL = dont chmod files. | ||
| 164 : | * @return TRUE=all succeeded FALSE=one or more chmods failed | ||
| 165 : | */ | ||
| 166 : | function chmod($path, $perms = '644') { | ||
| 167 : | $ret = TRUE; | ||
| 168 : | $perms = octdec($perms); | ||
| 169 : | if (is_dir($path)) { | ||
| 170 : | $dh = opendir($path); | ||
| 171 : | while ($file = readdir($dh)) { | ||
| 172 : | if ($file != '.' && $file != '..') { | ||
| 173 : | $fullpath = $path.'/'.$file; | ||
| 174 : | if (is_dir($fullpath)) { | ||
| 175 : | if (!$this->chmod($fullpath, $perms)) | ||
| 176 : | $ret = FALSE; | ||
| 177 : | } else { | ||
| 178 : | if (isset($perms)) | ||
| 179 : | if (!@chmod($fullpath, $perms)) | ||
| 180 : | $ret = FALSE; | ||
| 181 : | } // if | ||
| 182 : | } // if | ||
| 183 : | } // while | ||
| 184 : | closedir($dh); | ||
| 185 : | if (!@chmod($path, $perms)) | ||
| 186 : | $ret = FALSE; | ||
| 187 : | } else { | ||
| 188 : | if (isset($perms)) | ||
| 189 : | $ret = @chmod($path, $perms); | ||
| 190 : | } // if | ||
| 191 : | return $ret; | ||
| 192 : | } | ||
| 193 : | |||
| 194 : | /** | ||
| 195 : | * @see platform::splitPath | ||
| 196 : | */ | ||
| 197 : | function splitPath($path) { | ||
| 198 : | $slash = $this->getDirectorySeparator(); | ||
| 199 : | $list = array(); | ||
| 200 : | foreach (explode($slash, $path) as $element) { | ||
| 201 : | if (!empty($element)) { | ||
| 202 : | $list[] = $element; | ||
| 203 : | } else if (empty($list)) { | ||
| 204 : | $list[] = $slash; | ||
| 205 : | } | ||
| 206 : | } | ||
| 207 : | return $list; | ||
| 208 : | } | ||
| 209 : | |||
| 210 : | /** | ||
| 211 : | * @see platform::isSymlinkSupported | ||
| 212 : | */ | ||
| 213 : | function isSymlinkSupported() { | ||
| 214 : | return true; | ||
| 215 : | } | ||
| 216 : | } | ||
| 217 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

