Changeset 2497 for trunk/include
- Timestamp:
- Sep 4, 2008, 3:28:34 AM (16 years ago)
- Location:
- trunk/include
- Files:
-
- 3 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 } -
trunk/include/functions_mail.inc.php
r2479 r2497 796 796 global $conf, $user, $lang_info; 797 797 $dir = $conf['local_data_dir'].'/tmp'; 798 @mkdir( $dir ); 799 $filename = $dir.'/mail.'.$user['username'].'.'.$lang_info['code'].'.'.$args['template'].'.'.$args['theme']; 800 if ($args['content_format'] == 'text/plain') 801 { 802 $filename .= '.txt'; 803 } 804 else 805 { 806 $filename .= '.html'; 807 } 808 $file = fopen($filename, 'w+'); 809 fwrite($file, $to ."\n"); 810 fwrite($file, $subject ."\n"); 811 fwrite($file, $headers); 812 fwrite($file, $content); 813 fclose($file); 798 if ( mkgetdir( $dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR) ) 799 { 800 $filename = $dir.'/mail.'.$user['username'].'.'.$lang_info['code'].'.'.$args['template'].'.'.$args['theme']; 801 if ($args['content_format'] == 'text/plain') 802 { 803 $filename .= '.txt'; 804 } 805 else 806 { 807 $filename .= '.html'; 808 } 809 $file = fopen($filename, 'w+'); 810 fwrite($file, $to ."\n"); 811 fwrite($file, $subject ."\n"); 812 fwrite($file, $headers); 813 fwrite($file, $content); 814 fclose($file); 815 } 814 816 return $result; 815 817 } -
trunk/include/template.class.php
r2489 r2497 54 54 $this->smarty->debugging = $conf['debug_template']; 55 55 56 if ( isset($conf['compiled_template_dir'] ) ) 57 { 58 $compile_dir = $conf['compiled_template_dir']; 59 } 60 else 61 { 62 $compile_dir = $conf['local_data_dir']; 63 if ( !is_dir($compile_dir) ) 64 { 65 mkdir( $compile_dir, 0777); 66 file_put_contents($compile_dir.'/index.htm', ''); 67 } 68 $compile_dir .= '/templates_c'; 69 } 70 if ( !is_dir($compile_dir) ) 71 { 72 mkdir( $compile_dir, 0777 ); 73 file_put_contents($compile_dir.'/index.htm', ''); 74 } 56 $compile_dir = $conf['local_data_dir'].'/templates_c'; 57 mkgetdir( $compile_dir ); 75 58 76 59 $this->smarty->compile_dir = $compile_dir; … … 124 107 $this->smarty->clear_compiled_tpl(); 125 108 $this->smarty->compile_id = $save_compile_id; 126 file_put_contents($this->smarty->compile_dir.'/index.htm', ' ');109 file_put_contents($this->smarty->compile_dir.'/index.htm', 'Not allowed!'); 127 110 } 128 111
Note: See TracChangeset
for help on using the changeset viewer.