1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
<?php
/*
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2005 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id: fs_unix.php,v 1.22.2.2 2005/04/14 01:48:30 cryptographite Exp $
*/
?>
<?php
function fs_copy($source, $dest) {
$umask = umask(0113);
$results = copy($source, $dest);
umask($umask);
}
function fs_exec($cmd, &$results, &$status, $debugfile="") {
if (!empty($debugfile)) {
$cmd = "($cmd) 2>$debugfile";
}
return exec($cmd, $results, $status);
}
function fs_tempdir() {
return export_filename(getenv("TEMP"));
}
function fs_file_exists($filename) {
return @file_exists($filename);
}
function fs_is_link($filename) {
/* if the link is broken it will spew a warning, so ignore it */
return @is_link($filename);
}
function fs_filesize($filename) {
return filesize($filename);
}
function fs_fopen($filename, $mode, $use_include_path=0) {
return fopen($filename, $mode, $use_include_path);
}
function fs_file_get_contents($filename) {
if (function_exists("file_get_contents")) {
$tmp = @file_get_contents($filename);
} else {
if ($fd = fs_fopen($fname, "rb")) {
while (!feof($fd)) {
$tmp .= fread($fd, 65536);
}
fclose($fd);
}
}
return $tmp;
}
function fs_is_dir($filename) {
return @is_dir($filename);
}
function fs_is_file($filename) {
return @is_file($filename);
}
function fs_is_readable($filename) {
return @is_readable($filename);
}
function fs_opendir($path) {
return opendir($path);
}
function fs_rename($oldname, $newname) {
return rename($oldname, $newname);
}
function fs_stat($filename) {
return stat($filename);
}
/* This function deletes a file.
** The errormessage is surpressed !
*/
function fs_unlink($filename) {
return @unlink($filename);
}
function fs_is_executable($filename) {
return is_executable($filename);
}
function fs_import_filename($filename, $for_exec=1) {
if ($for_exec) {
$filename = escapeshellarg ($filename); // Might as well use the function PHP provides!
}
return $filename;
}
function fs_export_filename($filename) {
return $filename;
}
function fs_executable($filename) {
return $filename;
}
function fs_mkdir($filename, $perms) {
$umask = umask(0);
/*
* PHP 4.2.0 on Unix (specifically FreeBSD) has a bug where mkdir
* causes a seg fault if you specify modes.
*
* See: http://bugs.php.net/bug.php?id=16905
*
* We can't reliably determine the OS, so let's just turn off the
* permissions for any Unix implementation.
*/
if (!strcmp(phpversion(), "4.2.0")) {
$results = mkdir(fs_import_filename($filename, 0));
} else {
$results = mkdir(fs_import_filename($filename, 0), $perms);
}
umask($umask);
return $results;
}
?>
|