Rev 229 Rev 240
1 <?php 1 <?php
2   2  
3 /** 3 /**
4 * This file attempts to recursively make all files in the parent directory 4 * This file attempts to recursively make all files in the parent directory
5 * (i.e. the singapore root directory) writable. This will, in general, only 5 * (i.e. the singapore root directory) writable. This will, in general, only
6 * succeed on server-owned content hence making it deletable by FTP users. 6 * succeed on server-owned content hence making it deletable by FTP users.
7 * 7 *
8 * @author Tamlyn Rhodes <tam at zenology dot co dot uk> 8 * @author Tamlyn Rhodes <tam at zenology dot co dot uk>
9 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License 9 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License
10 * @copyright (c)2004 Tamlyn Rhodes 10 * @copyright (c)2004 Tamlyn Rhodes
11 * @version $Id: cleanup.php,v 1.4 2006/03/02 16:14:03 tamlyn Exp $ 11 * @version $Id: cleanup.php,v 1.4 2006/03/02 16:14:03 tamlyn Exp $
12 */ 12 */
13   13  
14 /** 14 /**
15 * Recursively attempts to make all files and directories in $dir writable 15 * Recursively attempts to make all files and directories in $dir writable
16 * 16 *
17 * @param string full directory name (must end with /) 17 * @param string full directory name (must end with /)
18 */ 18 */
19 function makeWritable($dir) 19 function makeWritable($dir)
20 { 20 {
21 if (is_dir($dir)) { 21 if (is_dir($dir)) {
22 $d = dir($dir); 22 $d = dir($dir);
23 while (($file = $d->read()) !== false) { 23 while (($file = $d->read()) !== false) {
24 //ignore current and parent dirs and php files 24 //ignore current and parent dirs and php files
25 if ($file == '.' || $file == '..' || substr($file, strlen($file)-4)=='.php') continue; 25 if ($file == '.' || $file == '..' || substr($file, strlen($file)-4)=='.php') continue;
26 $fullfile = $d->path . $file; 26 $fullfile = $d->path . $file;
27 if(@chmod($fullfile,0777)) 27 if(@chmod($fullfile,0777))
28 echo "Made $fullfile writable.<br />"; 28 echo "Made $fullfile writable.<br />";
29 if (is_dir($fullfile)) 29 if (is_dir($fullfile))
30 makeWritable($fullfile."/"); 30 makeWritable($fullfile."/");
31 } 31 }
32 } 32 }
33 } 33 }
34   34  
35   35  
36   36  
37 ?> 37 ?>
38 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 38 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
39 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 39 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
40   40  
41 <html xmlns="http://www.w3.org/1999/xhtml"> 41 <html xmlns="http://www.w3.org/1999/xhtml">
42 <head> 42 <head>
43 <title>cleanup script</title> 43 <title>cleanup script</title>
44 <link rel="stylesheet" type="text/css" href="tools.css" /> 44 <link rel="stylesheet" type="text/css" href="tools.css" />
45 </head> 45 </head>
46   46  
47 <body> 47 <body>
48   48  
49 <h1>Fixing file permissions</h1> 49 <h1>Fixing file permissions</h1>
50   50  
51 <p><?php 51 <p><?php
52 //start with parent directory (singapore root) 52 //start with parent directory (singapore root)
53 makeWritable("../"); 53 makeWritable("../");
54 ?></p> 54 ?></p>
55   55  
56 <p>All done! <a href="index.html">Return</a> to tools.</p> 56 <p>All done! <a href="index.html">Return</a> to tools.</p>
57   57  
58 </body> 58 </body>
59 </html> 59 </html>