This source file includes following definitions.
- php_statpage
- php_getuid
- php_getgid
- PHP_FUNCTION
- PHP_FUNCTION
- PHP_FUNCTION
- PHP_FUNCTION
- php_getlastmod
- PHP_FUNCTION
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include "php.h"
22 #include "pageinfo.h"
23 #include "SAPI.h"
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #if HAVE_PWD_H
28 #ifdef PHP_WIN32
29 #include "win32/pwd.h"
30 #else
31 #include <pwd.h>
32 #endif
33 #endif
34 #if HAVE_GRP_H
35 # ifdef PHP_WIN32
36 # include "win32/grp.h"
37 # else
38 # include <grp.h>
39 # endif
40 #endif
41 #ifdef PHP_WIN32
42 #undef getgid
43 #define getgroups(a, b) 0
44 #define getgid() 1
45 #define getuid() 1
46 #endif
47 #if HAVE_UNISTD_H
48 #include <unistd.h>
49 #endif
50 #include <sys/stat.h>
51 #include <sys/types.h>
52 #ifdef PHP_WIN32
53 #include <process.h>
54 #endif
55
56 #include "ext/standard/basic_functions.h"
57
58
59
60 PHPAPI void php_statpage(void)
61 {
62 zend_stat_t *pstat;
63
64 pstat = sapi_get_stat();
65
66 if (BG(page_uid)==-1 || BG(page_gid)==-1) {
67 if(pstat) {
68 BG(page_uid) = pstat->st_uid;
69 BG(page_gid) = pstat->st_gid;
70 BG(page_inode) = pstat->st_ino;
71 BG(page_mtime) = pstat->st_mtime;
72 } else {
73 BG(page_uid) = getuid();
74 BG(page_gid) = getgid();
75 }
76 }
77 }
78
79
80
81
82 zend_long php_getuid(void)
83 {
84 php_statpage();
85 return (BG(page_uid));
86 }
87
88
89 zend_long php_getgid(void)
90 {
91 php_statpage();
92 return (BG(page_gid));
93 }
94
95
96
97 PHP_FUNCTION(getmyuid)
98 {
99 zend_long uid;
100
101 if (zend_parse_parameters_none() == FAILURE) {
102 return;
103 }
104
105 uid = php_getuid();
106 if (uid < 0) {
107 RETURN_FALSE;
108 } else {
109 RETURN_LONG(uid);
110 }
111 }
112
113
114
115
116 PHP_FUNCTION(getmygid)
117 {
118 zend_long gid;
119
120 if (zend_parse_parameters_none() == FAILURE) {
121 return;
122 }
123
124 gid = php_getgid();
125 if (gid < 0) {
126 RETURN_FALSE;
127 } else {
128 RETURN_LONG(gid);
129 }
130 }
131
132
133
134
135 PHP_FUNCTION(getmypid)
136 {
137 zend_long pid;
138
139 if (zend_parse_parameters_none() == FAILURE) {
140 return;
141 }
142
143 pid = getpid();
144 if (pid < 0) {
145 RETURN_FALSE;
146 } else {
147 RETURN_LONG(pid);
148 }
149 }
150
151
152
153
154 PHP_FUNCTION(getmyinode)
155 {
156 if (zend_parse_parameters_none() == FAILURE) {
157 return;
158 }
159
160 php_statpage();
161 if (BG(page_inode) < 0) {
162 RETURN_FALSE;
163 } else {
164 RETURN_LONG(BG(page_inode));
165 }
166 }
167
168
169 PHPAPI time_t php_getlastmod(void)
170 {
171 php_statpage();
172 return BG(page_mtime);
173 }
174
175
176
177 PHP_FUNCTION(getlastmod)
178 {
179 zend_long lm;
180
181 if (zend_parse_parameters_none() == FAILURE) {
182 return;
183 }
184
185 lm = php_getlastmod();
186 if (lm < 0) {
187 RETURN_FALSE;
188 } else {
189 RETURN_LONG(lm);
190 }
191 }
192
193
194
195
196
197
198
199
200
201