1999-04-17 00:37:12 +00:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
1999-07-16 13:13:16 +00:00
|
|
|
| PHP version 4.0 |
|
1999-04-17 00:37:12 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2001-02-26 06:11:02 +00:00
|
|
|
| Copyright (c) 1997-2001 The PHP Group |
|
1999-04-17 00:37:12 +00:00
|
|
|
+----------------------------------------------------------------------+
|
2000-05-18 15:34:45 +00:00
|
|
|
| This source file is subject to version 2.02 of the PHP license, |
|
1999-07-16 13:13:16 +00:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available at through the world-wide-web at |
|
2000-05-18 15:34:45 +00:00
|
|
|
| http://www.php.net/license/2_02.txt. |
|
1999-07-16 13:13:16 +00:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
1999-04-17 00:37:12 +00:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Author: Jim Winstead <jimw@php.net> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
1999-04-23 20:06:01 +00:00
|
|
|
|
1999-04-17 00:37:12 +00:00
|
|
|
#include "php.h"
|
|
|
|
#include "safe_mode.h"
|
2001-02-23 22:07:16 +00:00
|
|
|
#include "fopen_wrappers.h"
|
1999-04-17 00:37:12 +00:00
|
|
|
#include "php_globals.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#if HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
1999-08-17 12:32:23 +00:00
|
|
|
#ifdef OS2
|
|
|
|
# define INCL_DOS
|
|
|
|
# include <os2.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS)
|
|
|
|
# include <sys/statvfs.h>
|
|
|
|
#elif defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)
|
|
|
|
# include <sys/statfs.h>
|
|
|
|
#endif
|
|
|
|
|
1999-04-17 00:37:12 +00:00
|
|
|
#if HAVE_PWD_H
|
2000-02-11 15:59:30 +00:00
|
|
|
# ifdef PHP_WIN32
|
1999-04-17 00:37:12 +00:00
|
|
|
# include "win32/pwd.h"
|
|
|
|
# else
|
|
|
|
# include <pwd.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_GRP_H
|
2000-02-11 15:59:30 +00:00
|
|
|
# ifdef PHP_WIN32
|
1999-04-17 00:37:12 +00:00
|
|
|
# include "win32/grp.h"
|
|
|
|
# else
|
|
|
|
# include <grp.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_UTIME
|
2000-02-11 15:59:30 +00:00
|
|
|
# ifdef PHP_WIN32
|
1999-04-17 00:37:12 +00:00
|
|
|
# include <sys/utime.h>
|
|
|
|
# else
|
|
|
|
# include <utime.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2000-03-06 20:37:11 +00:00
|
|
|
#include "basic_functions.h"
|
1999-04-17 00:37:12 +00:00
|
|
|
|
1999-12-12 16:48:54 +00:00
|
|
|
#include "php_filestat.h"
|
1999-04-17 00:37:12 +00:00
|
|
|
|
|
|
|
#ifndef S_ISDIR
|
|
|
|
#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
|
|
|
|
#endif
|
|
|
|
#ifndef S_ISREG
|
|
|
|
#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
|
|
|
|
#endif
|
|
|
|
#ifndef S_ISLNK
|
|
|
|
#define S_ISLNK(mode) (((mode)&S_IFMT) == S_IFLNK)
|
|
|
|
#endif
|
|
|
|
|
2000-03-15 11:52:07 +00:00
|
|
|
#ifdef PHP_WIN32
|
|
|
|
#define S_IRUSR S_IREAD
|
|
|
|
#define S_IWUSR S_IWRITE
|
|
|
|
#define S_IXUSR S_IEXEC
|
|
|
|
|
|
|
|
#define S_IRGRP S_IREAD
|
|
|
|
#define S_IWGRP S_IWRITE
|
|
|
|
#define S_IXGRP S_IEXEC
|
|
|
|
|
|
|
|
#define S_IROTH S_IREAD
|
|
|
|
#define S_IWOTH S_IWRITE
|
|
|
|
#define S_IXOTH S_IEXEC
|
|
|
|
|
|
|
|
#undef getgid
|
|
|
|
#define getgroups(a,b) 0
|
|
|
|
#define getgid() 1
|
|
|
|
#define getuid() 1
|
|
|
|
#endif
|
1999-04-17 00:37:12 +00:00
|
|
|
|
2000-03-17 12:41:55 +00:00
|
|
|
#define S_IXROOT ( S_IXUSR | S_IXGRP | S_IXOTH )
|
|
|
|
|
1999-07-26 20:09:08 +00:00
|
|
|
PHP_RINIT_FUNCTION(filestat)
|
1999-04-17 00:37:12 +00:00
|
|
|
{
|
1999-12-12 16:48:54 +00:00
|
|
|
BLS_FETCH();
|
|
|
|
|
|
|
|
BG(CurrentStatFile)=NULL;
|
|
|
|
BG(CurrentStatLength)=0;
|
1999-04-17 00:37:12 +00:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-26 20:09:08 +00:00
|
|
|
PHP_RSHUTDOWN_FUNCTION(filestat)
|
1999-04-17 00:37:12 +00:00
|
|
|
{
|
1999-12-12 16:48:54 +00:00
|
|
|
BLS_FETCH();
|
|
|
|
|
|
|
|
if (BG(CurrentStatFile)) {
|
|
|
|
efree (BG(CurrentStatFile));
|
1999-04-21 04:02:11 +00:00
|
|
|
}
|
1999-04-17 00:37:12 +00:00
|
|
|
return SUCCESS;
|
2000-09-16 05:02:06 +00:00
|
|
|
}
|
1999-04-17 00:37:12 +00:00
|
|
|
|
2000-05-23 23:13:02 +00:00
|
|
|
/* {{{ proto double diskfreespace(string path)
|
|
|
|
Get free diskspace for filesystem that path is on */
|
1999-08-17 12:32:23 +00:00
|
|
|
PHP_FUNCTION(diskfreespace)
|
|
|
|
{
|
1999-12-20 15:38:44 +00:00
|
|
|
pval **path;
|
1999-08-17 12:32:23 +00:00
|
|
|
#ifdef WINDOWS
|
|
|
|
double bytesfree;
|
|
|
|
|
|
|
|
HINSTANCE kernel32;
|
|
|
|
FARPROC gdfse;
|
|
|
|
typedef BOOL (WINAPI *gdfse_func)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
|
|
|
|
gdfse_func func;
|
|
|
|
|
|
|
|
/* These are used by GetDiskFreeSpaceEx, if available. */
|
|
|
|
ULARGE_INTEGER FreeBytesAvailableToCaller;
|
|
|
|
ULARGE_INTEGER TotalNumberOfBytes;
|
|
|
|
ULARGE_INTEGER TotalNumberOfFreeBytes;
|
|
|
|
|
|
|
|
/* These are used by GetDiskFreeSpace otherwise. */
|
|
|
|
DWORD SectorsPerCluster;
|
|
|
|
DWORD BytesPerSector;
|
|
|
|
DWORD NumberOfFreeClusters;
|
|
|
|
DWORD TotalNumberOfClusters;
|
|
|
|
|
|
|
|
#else /* not - WINDOWS */
|
|
|
|
#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS)
|
|
|
|
struct statvfs buf;
|
|
|
|
#elif defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)
|
|
|
|
struct statfs buf;
|
|
|
|
#endif
|
|
|
|
double bytesfree = 0;
|
|
|
|
#endif /* WINDOWS */
|
|
|
|
|
2000-06-05 19:47:54 +00:00
|
|
|
if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1,&path)==FAILURE) {
|
1999-08-17 12:32:23 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
|
|
|
|
1999-12-20 02:09:58 +00:00
|
|
|
convert_to_string_ex(path);
|
1999-08-17 12:32:23 +00:00
|
|
|
|
1999-12-20 02:09:58 +00:00
|
|
|
if (php_check_open_basedir((*path)->value.str.val)) RETURN_FALSE;
|
1999-08-17 12:32:23 +00:00
|
|
|
|
|
|
|
#ifdef WINDOWS
|
|
|
|
/* GetDiskFreeSpaceEx is only available in NT and Win95 post-OSR2,
|
|
|
|
so we have to jump through some hoops to see if the function
|
|
|
|
exists. */
|
|
|
|
kernel32 = LoadLibrary("kernel32.dll");
|
|
|
|
if (kernel32) {
|
|
|
|
gdfse = GetProcAddress(kernel32, "GetDiskFreeSpaceExA");
|
|
|
|
/* It's available, so we can call it. */
|
|
|
|
if (gdfse) {
|
|
|
|
func = (gdfse_func)gdfse;
|
1999-12-20 15:38:44 +00:00
|
|
|
if (func((*path)->value.str.val,
|
1999-08-17 12:32:23 +00:00
|
|
|
&FreeBytesAvailableToCaller,
|
|
|
|
&TotalNumberOfBytes,
|
|
|
|
&TotalNumberOfFreeBytes) == 0) RETURN_FALSE;
|
|
|
|
|
2000-10-29 09:14:55 +00:00
|
|
|
/* i know - this is ugly, but i works (thies@thieso.net) */
|
2000-09-16 05:02:06 +00:00
|
|
|
bytesfree = FreeBytesAvailableToCaller.HighPart *
|
1999-08-17 12:32:23 +00:00
|
|
|
(double) (((unsigned long)1) << 31) * 2.0 +
|
|
|
|
FreeBytesAvailableToCaller.LowPart;
|
|
|
|
}
|
|
|
|
/* If it's not available, we just use GetDiskFreeSpace */
|
|
|
|
else {
|
1999-12-20 15:38:44 +00:00
|
|
|
if (GetDiskFreeSpace((*path)->value.str.val,
|
1999-08-17 12:32:23 +00:00
|
|
|
&SectorsPerCluster, &BytesPerSector,
|
|
|
|
&NumberOfFreeClusters, &TotalNumberOfClusters) == 0) RETURN_FALSE;
|
|
|
|
bytesfree = (double)NumberOfFreeClusters * (double)SectorsPerCluster * (double)BytesPerSector;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
1999-12-17 20:55:31 +00:00
|
|
|
php_error(E_WARNING, "Unable to load kernel32.dll");
|
1999-08-17 12:32:23 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined(OS2)
|
|
|
|
{
|
|
|
|
FSALLOCATE fsinfo;
|
1999-12-20 15:38:44 +00:00
|
|
|
char drive = (*path)->value.str.val[0] & 95;
|
2000-09-16 05:02:06 +00:00
|
|
|
|
1999-08-17 12:32:23 +00:00
|
|
|
if (DosQueryFSInfo( drive ? drive - 64 : 0, FSIL_ALLOC, &fsinfo, sizeof( fsinfo ) ) == 0)
|
|
|
|
bytesfree = (double)fsinfo.cbSector * fsinfo.cSectorUnit * fsinfo.cUnitAvail;
|
|
|
|
}
|
|
|
|
#else /* WINDOWS, OS/2 */
|
|
|
|
#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS)
|
1999-12-20 02:09:58 +00:00
|
|
|
if (statvfs((*path)->value.str.val,&buf)) RETURN_FALSE;
|
1999-08-17 12:32:23 +00:00
|
|
|
if (buf.f_frsize) {
|
|
|
|
bytesfree = (((double)buf.f_bavail) * ((double)buf.f_frsize));
|
|
|
|
} else {
|
|
|
|
bytesfree = (((double)buf.f_bavail) * ((double)buf.f_bsize));
|
|
|
|
}
|
|
|
|
#elif defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)
|
1999-12-20 02:09:58 +00:00
|
|
|
if (statfs((*path)->value.str.val,&buf)) RETURN_FALSE;
|
1999-08-17 12:32:23 +00:00
|
|
|
bytesfree = (((double)buf.f_bsize) * ((double)buf.f_bavail));
|
|
|
|
#endif
|
|
|
|
#endif /* WINDOWS */
|
|
|
|
|
|
|
|
RETURN_DOUBLE(bytesfree);
|
|
|
|
}
|
2000-05-23 23:13:02 +00:00
|
|
|
/* }}} */
|
1999-08-17 12:32:23 +00:00
|
|
|
|
2000-09-16 05:10:03 +00:00
|
|
|
/* {{{ proto bool chgrp(string filename, mixed group)
|
|
|
|
Change file group */
|
1999-05-16 11:19:26 +00:00
|
|
|
PHP_FUNCTION(chgrp)
|
1999-04-17 00:37:12 +00:00
|
|
|
{
|
|
|
|
#ifndef WINDOWS
|
1999-12-20 02:09:58 +00:00
|
|
|
pval **filename, **group;
|
1999-04-17 00:37:12 +00:00
|
|
|
gid_t gid;
|
|
|
|
struct group *gr=NULL;
|
|
|
|
int ret;
|
1999-08-15 18:52:10 +00:00
|
|
|
PLS_FETCH();
|
1999-04-17 00:37:12 +00:00
|
|
|
|
2000-06-05 19:47:54 +00:00
|
|
|
if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2,&filename,&group)==FAILURE) {
|
1999-04-17 00:37:12 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
1999-12-20 02:09:58 +00:00
|
|
|
convert_to_string_ex(filename);
|
|
|
|
if ((*group)->type == IS_STRING) {
|
|
|
|
gr = getgrnam((*group)->value.str.val);
|
1999-04-17 00:37:12 +00:00
|
|
|
if (!gr) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING, "unable to find gid for %s",
|
1999-12-20 02:09:58 +00:00
|
|
|
(*group)->value.str.val);
|
1999-04-17 00:37:12 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
gid = gr->gr_gid;
|
|
|
|
} else {
|
1999-12-20 02:09:58 +00:00
|
|
|
convert_to_long_ex(group);
|
|
|
|
gid = (*group)->value.lval;
|
1999-04-17 00:37:12 +00:00
|
|
|
}
|
|
|
|
|
2000-11-02 23:08:07 +00:00
|
|
|
if (PG(safe_mode) &&(!php_checkuid((*filename)->value.str.val, NULL, CHECKUID_ALLOW_FILE_NOT_EXISTS))) {
|
1999-04-17 00:37:12 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the basedir */
|
1999-12-20 02:09:58 +00:00
|
|
|
if (php_check_open_basedir((*filename)->value.str.val))
|
|
|
|
RETURN_FALSE;
|
1999-04-17 00:37:12 +00:00
|
|
|
|
2000-08-06 16:22:07 +00:00
|
|
|
ret = V_CHOWN((*filename)->value.str.val, -1, gid);
|
1999-04-17 00:37:12 +00:00
|
|
|
if (ret == -1) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING, "chgrp failed: %s", strerror(errno));
|
1999-04-17 00:37:12 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
RETURN_TRUE;
|
1999-04-21 04:02:11 +00:00
|
|
|
#else
|
|
|
|
RETURN_FALSE;
|
|
|
|
#endif
|
1999-04-17 00:37:12 +00:00
|
|
|
}
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
1999-04-17 00:37:12 +00:00
|
|
|
|
2000-09-16 05:02:06 +00:00
|
|
|
/* {{{ proto bool chown (string filename, mixed user)
|
|
|
|
Change file owner */
|
1999-05-16 11:19:26 +00:00
|
|
|
PHP_FUNCTION(chown)
|
1999-04-17 00:37:12 +00:00
|
|
|
{
|
|
|
|
#ifndef WINDOWS
|
1999-12-20 02:09:58 +00:00
|
|
|
pval **filename, **user;
|
1999-04-17 00:37:12 +00:00
|
|
|
int ret;
|
|
|
|
uid_t uid;
|
|
|
|
struct passwd *pw = NULL;
|
1999-08-15 18:52:10 +00:00
|
|
|
PLS_FETCH();
|
1999-04-17 00:37:12 +00:00
|
|
|
|
2000-06-05 19:47:54 +00:00
|
|
|
if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2,&filename,&user)==FAILURE) {
|
1999-04-17 00:37:12 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
1999-12-20 02:09:58 +00:00
|
|
|
convert_to_string_ex(filename);
|
|
|
|
if ((*user)->type == IS_STRING) {
|
|
|
|
pw = getpwnam((*user)->value.str.val);
|
1999-04-17 00:37:12 +00:00
|
|
|
if (!pw) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING, "unable to find uid for %s",
|
1999-12-20 02:09:58 +00:00
|
|
|
(*user)->value.str.val);
|
1999-04-17 00:37:12 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
uid = pw->pw_uid;
|
|
|
|
} else {
|
1999-12-20 02:09:58 +00:00
|
|
|
convert_to_long_ex(user);
|
|
|
|
uid = (*user)->value.lval;
|
1999-04-17 00:37:12 +00:00
|
|
|
}
|
|
|
|
|
2000-11-02 23:08:07 +00:00
|
|
|
if (PG(safe_mode) &&(!php_checkuid((*filename)->value.str.val, NULL, CHECKUID_ALLOW_FILE_NOT_EXISTS))) {
|
1999-04-17 00:37:12 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the basedir */
|
1999-12-20 02:09:58 +00:00
|
|
|
if (php_check_open_basedir((*filename)->value.str.val))
|
|
|
|
RETURN_FALSE;
|
1999-04-17 00:37:12 +00:00
|
|
|
|
2000-08-06 16:22:07 +00:00
|
|
|
ret = V_CHOWN((*filename)->value.str.val, uid, -1);
|
1999-04-17 00:37:12 +00:00
|
|
|
if (ret == -1) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING, "chown failed: %s", strerror(errno));
|
1999-04-17 00:37:12 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
RETURN_TRUE;
|
|
|
|
}
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
1999-04-17 00:37:12 +00:00
|
|
|
|
1999-04-21 04:02:11 +00:00
|
|
|
|
2000-05-17 18:14:05 +00:00
|
|
|
/* {{{ proto bool chmod(string filename, int mode)
|
|
|
|
Change file mode */
|
1999-05-16 11:19:26 +00:00
|
|
|
PHP_FUNCTION(chmod)
|
1999-04-21 04:02:11 +00:00
|
|
|
{
|
1999-12-20 02:09:58 +00:00
|
|
|
pval **filename, **mode;
|
2000-10-31 18:05:19 +00:00
|
|
|
int ret;
|
|
|
|
mode_t imode;
|
1999-04-21 04:02:11 +00:00
|
|
|
PLS_FETCH();
|
2000-09-16 05:02:06 +00:00
|
|
|
|
2000-06-05 19:47:54 +00:00
|
|
|
if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2,&filename,&mode)==FAILURE) {
|
1999-04-17 00:37:12 +00:00
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
1999-12-20 02:09:58 +00:00
|
|
|
convert_to_string_ex(filename);
|
|
|
|
convert_to_long_ex(mode);
|
1999-04-17 00:37:12 +00:00
|
|
|
|
2000-11-02 23:08:07 +00:00
|
|
|
if (PG(safe_mode) &&(!php_checkuid((*filename)->value.str.val, NULL, CHECKUID_ALLOW_FILE_NOT_EXISTS))) {
|
1999-04-17 00:37:12 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the basedir */
|
1999-12-20 02:09:58 +00:00
|
|
|
if (php_check_open_basedir((*filename)->value.str.val))
|
|
|
|
RETURN_FALSE;
|
1999-04-17 00:37:12 +00:00
|
|
|
|
2000-10-31 18:05:19 +00:00
|
|
|
imode = (mode_t) (*mode)->value.lval;
|
2000-06-09 10:34:53 +00:00
|
|
|
/* in safe mode, do not allow to setuid files.
|
2000-09-16 05:02:06 +00:00
|
|
|
Setuiding files could allow users to gain privileges
|
2000-06-09 10:34:53 +00:00
|
|
|
that safe mode doesn't give them.
|
|
|
|
*/
|
2000-09-16 05:02:06 +00:00
|
|
|
if(PG(safe_mode))
|
2000-06-09 10:34:53 +00:00
|
|
|
imode &= 0777;
|
|
|
|
|
2000-08-06 16:22:07 +00:00
|
|
|
ret = V_CHMOD((*filename)->value.str.val, imode);
|
1999-04-17 00:37:12 +00:00
|
|
|
if (ret == -1) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING, "chmod failed: %s", strerror(errno));
|
1999-04-17 00:37:12 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
RETURN_TRUE;
|
|
|
|
}
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
1999-04-17 00:37:12 +00:00
|
|
|
|
1999-04-21 04:02:11 +00:00
|
|
|
|
2000-06-12 14:44:16 +00:00
|
|
|
/* {{{ proto bool touch(string filename [, int time])
|
2000-05-17 18:14:05 +00:00
|
|
|
Set modification time of file */
|
2000-09-16 05:02:06 +00:00
|
|
|
PHP_FUNCTION(touch)
|
1999-04-21 04:02:11 +00:00
|
|
|
{
|
1999-04-17 00:37:12 +00:00
|
|
|
#if HAVE_UTIME
|
1999-12-20 02:09:58 +00:00
|
|
|
pval **filename, **filetime;
|
1999-04-17 00:37:12 +00:00
|
|
|
int ret;
|
|
|
|
struct stat sb;
|
|
|
|
FILE *file;
|
|
|
|
struct utimbuf *newtime = NULL;
|
2000-06-05 19:47:54 +00:00
|
|
|
int ac = ZEND_NUM_ARGS();
|
1999-04-21 04:02:11 +00:00
|
|
|
PLS_FETCH();
|
2000-09-16 05:02:06 +00:00
|
|
|
|
1999-12-20 02:09:58 +00:00
|
|
|
if (ac == 1 && zend_get_parameters_ex(1,&filename) != FAILURE) {
|
1999-04-17 00:37:12 +00:00
|
|
|
#ifndef HAVE_UTIME_NULL
|
|
|
|
newtime = (struct utimbuf *)emalloc(sizeof(struct utimbuf));
|
|
|
|
if (!newtime) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING, "unable to emalloc memory for changing time");
|
1999-04-17 00:37:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
newtime->actime = time(NULL);
|
|
|
|
newtime->modtime = newtime->actime;
|
|
|
|
#endif
|
1999-12-20 02:09:58 +00:00
|
|
|
} else if (ac == 2 && zend_get_parameters_ex(2,&filename,&filetime) != FAILURE) {
|
1999-04-17 00:37:12 +00:00
|
|
|
newtime = (struct utimbuf *)emalloc(sizeof(struct utimbuf));
|
|
|
|
if (!newtime) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING, "unable to emalloc memory for changing time");
|
1999-04-17 00:37:12 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-12-20 02:09:58 +00:00
|
|
|
convert_to_long_ex(filetime);
|
|
|
|
newtime->actime = (*filetime)->value.lval;
|
|
|
|
newtime->modtime = (*filetime)->value.lval;
|
1999-04-17 00:37:12 +00:00
|
|
|
} else {
|
|
|
|
WRONG_PARAM_COUNT;
|
|
|
|
}
|
1999-12-20 02:09:58 +00:00
|
|
|
convert_to_string_ex(filename);
|
1999-04-17 00:37:12 +00:00
|
|
|
|
2000-11-02 23:08:07 +00:00
|
|
|
if (PG(safe_mode) &&(!php_checkuid((*filename)->value.str.val, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
|
1999-04-17 00:37:12 +00:00
|
|
|
if (newtime) efree(newtime);
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check the basedir */
|
2000-07-27 13:28:21 +00:00
|
|
|
if (php_check_open_basedir((*filename)->value.str.val)) {
|
|
|
|
if (newtime) efree(newtime);
|
1999-12-20 02:09:58 +00:00
|
|
|
RETURN_FALSE;
|
2000-07-27 13:28:21 +00:00
|
|
|
}
|
1999-04-17 00:37:12 +00:00
|
|
|
|
|
|
|
/* create the file if it doesn't exist already */
|
2000-04-20 17:24:01 +00:00
|
|
|
ret = V_STAT((*filename)->value.str.val, &sb);
|
1999-04-17 00:37:12 +00:00
|
|
|
if (ret == -1) {
|
2000-04-15 14:28:48 +00:00
|
|
|
file = V_FOPEN((*filename)->value.str.val, "w");
|
1999-04-17 00:37:12 +00:00
|
|
|
if (file == NULL) {
|
1999-12-20 02:09:58 +00:00
|
|
|
php_error(E_WARNING, "unable to create file %s because %s", (*filename)->value.str.val, strerror(errno));
|
1999-04-17 00:37:12 +00:00
|
|
|
if (newtime) efree(newtime);
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
fclose(file);
|
|
|
|
}
|
|
|
|
|
2000-08-06 16:22:07 +00:00
|
|
|
ret = V_UTIME((*filename)->value.str.val, newtime);
|
1999-04-17 00:37:12 +00:00
|
|
|
if (newtime) efree(newtime);
|
|
|
|
if (ret == -1) {
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING, "utime failed: %s", strerror(errno));
|
1999-04-17 00:37:12 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
} else {
|
|
|
|
RETURN_TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
1999-04-17 00:37:12 +00:00
|
|
|
|
1999-04-21 04:02:11 +00:00
|
|
|
|
2000-05-17 18:14:05 +00:00
|
|
|
/* {{{ proto void clearstatcache(void)
|
|
|
|
Clear file stat cache */
|
1999-05-16 11:19:26 +00:00
|
|
|
PHP_FUNCTION(clearstatcache)
|
1999-04-21 04:02:11 +00:00
|
|
|
{
|
1999-12-12 16:48:54 +00:00
|
|
|
BLS_FETCH();
|
|
|
|
|
|
|
|
if (BG(CurrentStatFile)) {
|
|
|
|
efree(BG(CurrentStatFile));
|
|
|
|
BG(CurrentStatFile) = NULL;
|
1999-04-17 00:37:12 +00:00
|
|
|
}
|
|
|
|
}
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
1999-04-17 00:37:12 +00:00
|
|
|
|
1999-04-21 04:02:11 +00:00
|
|
|
|
1999-12-18 04:01:20 +00:00
|
|
|
static void php_stat(const char *filename, int type, pval *return_value)
|
1999-04-17 00:37:12 +00:00
|
|
|
{
|
1999-12-12 16:48:54 +00:00
|
|
|
struct stat *stat_sb;
|
2000-03-14 20:20:43 +00:00
|
|
|
int rmask=S_IROTH,wmask=S_IWOTH,xmask=S_IXOTH; /* access rights defaults to other */
|
1999-12-12 16:48:54 +00:00
|
|
|
BLS_FETCH();
|
|
|
|
|
|
|
|
stat_sb = &BG(sb);
|
|
|
|
|
|
|
|
if (!BG(CurrentStatFile) || strcmp(filename,BG(CurrentStatFile))) {
|
|
|
|
if (!BG(CurrentStatFile)
|
|
|
|
|| strlen(filename) > BG(CurrentStatLength)) {
|
|
|
|
if (BG(CurrentStatFile)) efree(BG(CurrentStatFile));
|
|
|
|
BG(CurrentStatLength) = strlen(filename);
|
|
|
|
BG(CurrentStatFile) = estrndup(filename,BG(CurrentStatLength));
|
1999-04-17 00:37:12 +00:00
|
|
|
} else {
|
1999-12-12 16:48:54 +00:00
|
|
|
strcpy(BG(CurrentStatFile),filename);
|
1999-04-17 00:37:12 +00:00
|
|
|
}
|
|
|
|
#if HAVE_SYMLINK
|
1999-12-12 16:48:54 +00:00
|
|
|
BG(lsb).st_mode = 0; /* mark lstat buf invalid */
|
1999-04-17 00:37:12 +00:00
|
|
|
#endif
|
2000-04-20 17:24:01 +00:00
|
|
|
if (V_STAT(BG(CurrentStatFile),&BG(sb))==-1) {
|
1999-04-17 00:37:12 +00:00
|
|
|
if (type != 15 || errno != ENOENT) { /* fileexists() test must print no error */
|
1999-12-12 16:48:54 +00:00
|
|
|
php_error(E_NOTICE,"stat failed for %s (errno=%d - %s)",BG(CurrentStatFile),errno,strerror(errno));
|
1999-04-17 00:37:12 +00:00
|
|
|
}
|
1999-12-12 16:48:54 +00:00
|
|
|
efree(BG(CurrentStatFile));
|
|
|
|
BG(CurrentStatFile)=NULL;
|
1999-04-17 00:37:12 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if HAVE_SYMLINK
|
|
|
|
if (8 == type /* filetype */
|
|
|
|
|| 14 == type /* is link */
|
|
|
|
|| 16 == type) { /* lstat */
|
|
|
|
|
|
|
|
/* do lstat if the buffer is empty */
|
|
|
|
|
1999-12-12 16:48:54 +00:00
|
|
|
if (!BG(lsb).st_mode) {
|
2000-04-20 17:24:01 +00:00
|
|
|
if (V_LSTAT(BG(CurrentStatFile),&BG(lsb)) == -1) {
|
1999-12-12 16:48:54 +00:00
|
|
|
php_error(E_NOTICE,"lstat failed for %s (errno=%d - %s)",BG(CurrentStatFile),errno,strerror(errno));
|
1999-04-17 00:37:12 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-03-14 20:20:43 +00:00
|
|
|
|
|
|
|
if(BG(sb).st_uid==getuid()) {
|
|
|
|
rmask=S_IRUSR;
|
|
|
|
wmask=S_IWUSR;
|
|
|
|
xmask=S_IXUSR;
|
|
|
|
} else if(BG(sb).st_gid==getgid()) {
|
|
|
|
rmask=S_IRGRP;
|
|
|
|
wmask=S_IWGRP;
|
|
|
|
xmask=S_IXGRP;
|
|
|
|
} else {
|
|
|
|
int groups,n,i;
|
|
|
|
gid_t *gids;
|
2000-09-16 05:02:06 +00:00
|
|
|
|
2000-03-14 20:20:43 +00:00
|
|
|
groups = getgroups(0,NULL);
|
|
|
|
if(groups) {
|
|
|
|
gids=(gid_t *)emalloc(groups*sizeof(gid_t));
|
|
|
|
n=getgroups(groups,gids);
|
|
|
|
for(i=0;i<n;i++){
|
|
|
|
if(BG(sb).st_gid==gids[i]) {
|
|
|
|
rmask=S_IRGRP;
|
|
|
|
wmask=S_IWGRP;
|
|
|
|
xmask=S_IXGRP;
|
|
|
|
break;
|
2000-09-16 05:02:06 +00:00
|
|
|
}
|
2000-03-14 20:20:43 +00:00
|
|
|
}
|
|
|
|
efree(gids);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-17 00:37:12 +00:00
|
|
|
switch(type) {
|
|
|
|
case 0: /* fileperms */
|
1999-12-12 16:48:54 +00:00
|
|
|
RETURN_LONG((long)BG(sb).st_mode);
|
1999-04-17 00:37:12 +00:00
|
|
|
case 1: /* fileinode */
|
1999-12-12 16:48:54 +00:00
|
|
|
RETURN_LONG((long)BG(sb).st_ino);
|
1999-04-17 00:37:12 +00:00
|
|
|
case 2: /* filesize */
|
1999-12-12 16:48:54 +00:00
|
|
|
RETURN_LONG((long)BG(sb).st_size);
|
1999-04-17 00:37:12 +00:00
|
|
|
case 3: /* fileowner */
|
1999-12-12 16:48:54 +00:00
|
|
|
RETURN_LONG((long)BG(sb).st_uid);
|
1999-04-17 00:37:12 +00:00
|
|
|
case 4: /* filegroup */
|
1999-12-12 16:48:54 +00:00
|
|
|
RETURN_LONG((long)BG(sb).st_gid);
|
1999-04-17 00:37:12 +00:00
|
|
|
case 5: /* fileatime */
|
1999-12-12 16:48:54 +00:00
|
|
|
RETURN_LONG((long)BG(sb).st_atime);
|
1999-04-17 00:37:12 +00:00
|
|
|
case 6: /* filemtime */
|
1999-12-12 16:48:54 +00:00
|
|
|
RETURN_LONG((long)BG(sb).st_mtime);
|
1999-04-17 00:37:12 +00:00
|
|
|
case 7: /* filectime */
|
1999-12-12 16:48:54 +00:00
|
|
|
RETURN_LONG((long)BG(sb).st_ctime);
|
1999-04-17 00:37:12 +00:00
|
|
|
case 8: /* filetype */
|
|
|
|
#if HAVE_SYMLINK
|
1999-12-12 16:48:54 +00:00
|
|
|
if (S_ISLNK(BG(lsb).st_mode)) {
|
1999-04-17 00:37:12 +00:00
|
|
|
RETURN_STRING("link",1);
|
|
|
|
}
|
|
|
|
#endif
|
1999-12-12 16:48:54 +00:00
|
|
|
switch(BG(sb).st_mode&S_IFMT) {
|
1999-04-17 00:37:12 +00:00
|
|
|
case S_IFIFO: RETURN_STRING("fifo",1);
|
|
|
|
case S_IFCHR: RETURN_STRING("char",1);
|
|
|
|
case S_IFDIR: RETURN_STRING("dir",1);
|
|
|
|
case S_IFBLK: RETURN_STRING("block",1);
|
|
|
|
case S_IFREG: RETURN_STRING("file",1);
|
2001-04-03 10:51:16 +00:00
|
|
|
#if defined(S_IFSOCK) && !defined(ZEND_WIN32)&&!defined(__BEOS__)
|
2000-12-03 13:42:54 +00:00
|
|
|
case S_IFSOCK: RETURN_STRING("socket",1);
|
|
|
|
#endif
|
1999-04-17 00:37:12 +00:00
|
|
|
}
|
1999-12-12 16:48:54 +00:00
|
|
|
php_error(E_WARNING,"Unknown file type (%d)",BG(sb).st_mode&S_IFMT);
|
1999-04-17 00:37:12 +00:00
|
|
|
RETURN_STRING("unknown",1);
|
|
|
|
case 9: /*is writable*/
|
2000-03-14 20:20:43 +00:00
|
|
|
if(getuid()==0) RETURN_LONG(1); /* root */
|
|
|
|
RETURN_LONG((BG(sb).st_mode&wmask)!=0);
|
1999-04-17 00:37:12 +00:00
|
|
|
case 10: /*is readable*/
|
2000-03-14 20:20:43 +00:00
|
|
|
if(getuid()==0) RETURN_LONG(1); /* root */
|
|
|
|
RETURN_LONG((BG(sb).st_mode&rmask)!=0);
|
1999-04-17 00:37:12 +00:00
|
|
|
case 11: /*is executable*/
|
2000-03-17 12:41:55 +00:00
|
|
|
if(getuid()==0) xmask = S_IXROOT; /* root */
|
2000-03-14 20:20:43 +00:00
|
|
|
RETURN_LONG((BG(sb).st_mode&xmask)!=0 && !S_ISDIR(BG(sb).st_mode));
|
1999-04-17 00:37:12 +00:00
|
|
|
case 12: /*is file*/
|
1999-12-12 16:48:54 +00:00
|
|
|
RETURN_LONG(S_ISREG(BG(sb).st_mode));
|
1999-04-17 00:37:12 +00:00
|
|
|
case 13: /*is dir*/
|
1999-12-12 16:48:54 +00:00
|
|
|
RETURN_LONG(S_ISDIR(BG(sb).st_mode));
|
1999-04-17 00:37:12 +00:00
|
|
|
case 14: /*is link*/
|
|
|
|
#if HAVE_SYMLINK
|
1999-12-12 16:48:54 +00:00
|
|
|
RETURN_LONG(S_ISLNK(BG(lsb).st_mode));
|
1999-04-17 00:37:12 +00:00
|
|
|
#else
|
|
|
|
RETURN_FALSE;
|
|
|
|
#endif
|
|
|
|
case 15: /*file exists*/
|
|
|
|
RETURN_TRUE; /* the false case was done earlier */
|
|
|
|
case 16: /* lstat */
|
|
|
|
#if HAVE_SYMLINK
|
1999-12-12 16:48:54 +00:00
|
|
|
stat_sb = &BG(lsb);
|
1999-04-17 00:37:12 +00:00
|
|
|
#endif
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case 17: /* stat */
|
|
|
|
if (array_init(return_value) == FAILURE) {
|
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
add_next_index_long(return_value, stat_sb->st_dev);
|
|
|
|
add_next_index_long(return_value, stat_sb->st_ino);
|
|
|
|
add_next_index_long(return_value, stat_sb->st_mode);
|
|
|
|
add_next_index_long(return_value, stat_sb->st_nlink);
|
|
|
|
add_next_index_long(return_value, stat_sb->st_uid);
|
|
|
|
add_next_index_long(return_value, stat_sb->st_gid);
|
2001-02-21 07:18:28 +00:00
|
|
|
#ifdef HAVE_ST_RDEV
|
1999-04-17 00:37:12 +00:00
|
|
|
add_next_index_long(return_value, stat_sb->st_rdev);
|
|
|
|
#else
|
|
|
|
add_next_index_long(return_value, -1);
|
|
|
|
#endif
|
|
|
|
add_next_index_long(return_value, stat_sb->st_size);
|
|
|
|
add_next_index_long(return_value, stat_sb->st_atime);
|
|
|
|
add_next_index_long(return_value, stat_sb->st_mtime);
|
|
|
|
add_next_index_long(return_value, stat_sb->st_ctime);
|
* fixed some #if/#ifdef issues
* hand-patched in php3 changes from 3.0.6 to HEAD in these files:
fopen-wrappers.[ch] ext/standard/file.[ch] ext/standard/fsock.[ch]
ext/standard/php3_string.h ext/standard/string.c
* added some new file/socket macros for more readable code:
FP_FGETS(buf,len,sock,fp,issock)
FP_FREAD(buf,len,sock,fp,issock)
FP_FEOF(sock,fp,issock)
FP_FGETC(sock,fp,issock)
1999-06-16 17:06:53 +00:00
|
|
|
#ifdef HAVE_ST_BLKSIZE
|
1999-04-17 00:37:12 +00:00
|
|
|
add_next_index_long(return_value, stat_sb->st_blksize);
|
|
|
|
#else
|
|
|
|
add_next_index_long(return_value, -1);
|
|
|
|
#endif
|
* fixed some #if/#ifdef issues
* hand-patched in php3 changes from 3.0.6 to HEAD in these files:
fopen-wrappers.[ch] ext/standard/file.[ch] ext/standard/fsock.[ch]
ext/standard/php3_string.h ext/standard/string.c
* added some new file/socket macros for more readable code:
FP_FGETS(buf,len,sock,fp,issock)
FP_FREAD(buf,len,sock,fp,issock)
FP_FEOF(sock,fp,issock)
FP_FGETC(sock,fp,issock)
1999-06-16 17:06:53 +00:00
|
|
|
#ifdef HAVE_ST_BLOCKS
|
1999-04-17 00:37:12 +00:00
|
|
|
add_next_index_long(return_value, stat_sb->st_blocks);
|
|
|
|
#else
|
|
|
|
add_next_index_long(return_value, -1);
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
1999-08-02 19:17:14 +00:00
|
|
|
php_error(E_WARNING, "didn't understand stat call");
|
1999-04-17 00:37:12 +00:00
|
|
|
RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* another quickie macro to make defining similar functions easier */
|
|
|
|
#define FileFunction(name, funcnum) \
|
|
|
|
void name(INTERNAL_FUNCTION_PARAMETERS) { \
|
1999-12-20 02:09:58 +00:00
|
|
|
pval **filename; \
|
2000-06-05 19:47:54 +00:00
|
|
|
if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1,&filename) == FAILURE) { \
|
1999-04-17 00:37:12 +00:00
|
|
|
WRONG_PARAM_COUNT; \
|
|
|
|
} \
|
1999-12-20 02:09:58 +00:00
|
|
|
convert_to_string_ex(filename); \
|
2000-02-14 14:18:17 +00:00
|
|
|
if ((*filename)->value.str.len) \
|
|
|
|
php_stat((*filename)->value.str.val, funcnum, return_value); \
|
1999-04-17 00:37:12 +00:00
|
|
|
}
|
|
|
|
|
2000-05-17 18:14:05 +00:00
|
|
|
/* {{{ proto int fileperms(string filename)
|
|
|
|
Get file permissions */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(fileperms),0)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto int fileinode(string filename)
|
|
|
|
Get file inode */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(fileinode),1)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto int filesize(string filename)
|
|
|
|
Get file size */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(filesize), 2)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto int fileowner(string filename)
|
|
|
|
Get file owner */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(fileowner),3)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
2001-02-15 20:33:09 +00:00
|
|
|
/* {{{ proto int filegroup(string filename)
|
2000-05-17 18:14:05 +00:00
|
|
|
Get file group */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(filegroup),4)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto int fileatime(string filename)
|
|
|
|
Get last access time of file */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(fileatime),5)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto int filemtime(string filename)
|
|
|
|
Get last modification time of file */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(filemtime),6)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto int filectime(string filename)
|
|
|
|
Get inode modification time of file */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(filectime),7)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto string filetype(string filename)
|
|
|
|
Get file type */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(filetype), 8)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto int is_writable(string filename)
|
|
|
|
Returns true if file can be written */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(is_writable), 9)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto int is_readable(string filename)
|
|
|
|
Returns true if file can be read */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(is_readable),10)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto int is_executable(string filename)
|
|
|
|
Returns true if file is executable */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(is_executable),11)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto int is_file(string filename)
|
|
|
|
Returns true if file is a regular file */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(is_file),12)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto int is_dir(string filename)
|
|
|
|
Returns true if file is directory */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(is_dir),13)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto int is_link(string filename)
|
|
|
|
Returns true if file is symbolic link */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(is_link),14)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto bool file_exists(string filename)
|
|
|
|
Returns true if filename exists */
|
1999-07-26 20:09:08 +00:00
|
|
|
FileFunction(PHP_FN(file_exists),15)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto array lstat(string filename)
|
|
|
|
Give information about a file or symbolic link */
|
2000-12-07 12:09:38 +00:00
|
|
|
FileFunction(php_if_lstat,16)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
|
|
|
|
|
|
|
/* {{{ proto array stat(string filename)
|
|
|
|
Give information about a file */
|
2000-12-07 12:09:38 +00:00
|
|
|
FileFunction(php_if_stat,17)
|
2000-05-17 18:14:05 +00:00
|
|
|
/* }}} */
|
1999-04-17 00:37:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* End:
|
|
|
|
*/
|