Changeset 2497 for trunk/include/functions.inc.php
- Timestamp:
- Sep 4, 2008, 3:28:34 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions.inc.php
r2484 r2497 186 186 187 187 /** 188 * returns an array contening sub-directories, excluding " CVS"188 * returns an array contening sub-directories, excluding ".svn" 189 189 * 190 190 * @param string $dir … … 194 194 { 195 195 $sub_dirs = array(); 196 197 196 if ($opendir = opendir($directory)) 198 197 { … … 202 201 and $file != '..' 203 202 and is_dir($directory.'/'.$file) 204 and $file != 'CVS' 205 and $file != '.svn') 203 and $file != '.svn') 206 204 { 207 205 array_push($sub_dirs, $file); 208 206 } 209 207 } 208 closedir($opendir); 210 209 } 211 210 return $sub_dirs; 211 } 212 213 define('MKGETDIR_NONE', 0); 214 define('MKGETDIR_RECURSIVE', 1); 215 define('MKGETDIR_DIE_ON_ERROR', 2); 216 define('MKGETDIR_PROTECT_INDEX', 4); 217 define('MKGETDIR_PROTECT_HTACCESS', 8); 218 define('MKGETDIR_DEFAULT', 7); 219 /** 220 * creates directory if not exists; ensures that directory is writable 221 * @param: 222 * string $dir 223 * int $flags combination of MKGETDIR_xxx 224 * @return bool false on error else true 225 */ 226 function mkgetdir($dir, $flags=MKGETDIR_DEFAULT) 227 { 228 if ( !is_dir($dir) ) 229 { 230 $umask = umask(0); 231 $mkd = @mkdir($dir, 0755, ($flags&MKGETDIR_RECURSIVE) ? true:false ); 232 umask($umask); 233 if ($mkd==false) 234 { 235 !($flags&MKGETDIR_DIE_ON_ERROR) or trigger_error( "$dir ".l10n('no_write_access'), E_USER_ERROR); 236 return false; 237 } 238 if( $flags&MKGETDIR_PROTECT_HTACCESS ) 239 { 240 $file = $dir.'/.htaccess'; 241 file_exists($file) or @file_put_contents( $file, 'deny from all' ); 242 } 243 if( $flags&MKGETDIR_PROTECT_INDEX ) 244 { 245 $file = $dir.'/index.htm'; 246 file_exists($file) or @file_put_contents( $file, 'Not allowed!' ); 247 } 248 } 249 if ( !is_writable($dir) ) 250 { 251 if ( !is_writable($dir) ) 252 { 253 !($flags&MKGETDIR_DIE_ON_ERROR) or trigger_error( "$dir ".l10n('no_write_access'), E_USER_ERROR); 254 return false; 255 } 256 } 257 return true; 212 258 } 213 259 … … 225 271 { 226 272 $tndir = $dirname.'/thumbnail'; 227 if (!is_dir($tndir)) 228 { 229 if (!is_writable($dirname)) 230 { 231 array_push($errors, 232 '['.$dirname.'] : '.l10n('no_write_access')); 233 return false; 234 } 235 umask(0000); 236 mkdir($tndir, 0777); 237 } 238 273 if (! mkgetdir($tn_dir, MKGETDIR_NONE) ) 274 { 275 array_push($errors, 276 '['.$dirname.'] : '.l10n('no_write_access')); 277 return false; 278 } 239 279 return $tndir; 240 280 }
Note: See TracChangeset
for help on using the changeset viewer.