Changeset 185 for trunk/trax/trax.php
- Timestamp:
- 03/23/06 09:45:48 (6 years ago)
- Files:
-
- 1 modified
-
trunk/trax/trax.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/trax/trax.php
r183 r185 1 1 <?php 2 2 /** 3 * C opy Pear directory data_dir/PHPonTrax/data/ to user'swork area3 * Create Trax application work area 4 4 * 5 5 * (PHP 5) … … 12 12 */ 13 13 14 /** 15 * Define where to find files to copy to the work area 16 * 17 * Set automatically by the Pear installer when you install Trax with 18 * the <b>pear install</b> command. If you are prevented from using 19 * <b>pear install</b>, change "@DATA-DIR@/PHPonTrax" by hand to the 20 * full filesystem path of the location where you installed the Trax 21 * distribution 22 */ 23 define("SOURCE_DIR", "@DATA-DIR@/PHPonTrax/data/"); 24 14 25 function trax() { 15 // Set default destination directory16 $dstdir = "./";17 26 18 27 // Get command line argument, if any 19 if (array_key_exists('argc',$GLOBALS) && ($GLOBALS['argc'] > 1)) { 20 21 // Check for excess arguments 22 if ($GLOBALS['argc'] > 2) { 23 echo "unrecognized command argument ".$GLOBALS['argv'][2]."\n"; 24 return; 25 } 26 27 // Destination directory on command line 28 $dstdir = $GLOBALS['argv'][1]; 29 30 // Guarantee it ends with '/' 31 if (substr($dstdir,-1,1) != '/') { 32 $dstdir .= '/'; 33 } 34 if (!create_dir($dstdir)) { 35 return; 36 } 37 } 38 $srcdir = "@DATA-DIR@/PHPonTrax/data/"; 28 if (!array_key_exists('argc',$GLOBALS) 29 || ($GLOBALS['argc'] < 2)) { 30 usage(); // print Usage message and exit 31 } 32 33 // Check for excess arguments 34 if ($GLOBALS['argc'] > 2) { 35 echo "unrecognized command argument ".$GLOBALS['argv'][2]."\n"; 36 usage(); 37 } 38 39 // Destination directory on command line 40 $dstdir = $GLOBALS['argv'][1]; 41 42 // Guarantee it ends with '/' 43 if (substr($dstdir,-1,1) != '/') { 44 $dstdir .= '/'; 45 } 46 if (!create_dir($dstdir)) { 47 return; 48 } 49 50 $srcdir = SOURCE_DIR; 39 51 // copy source directory to destination directory 40 52 copy_dir($srcdir,$dstdir); … … 43 55 /** 44 56 * Copy a directory with all its contents 57 * 58 * When a file whose filename ends '.log' is created, its permissions 59 * are set to be world writable. 45 60 * @param string $src_path Path to source directory 46 61 * @param string $dst_path Path to destination directory … … 108 123 return false; 109 124 } 125 126 // Log files need to be world writeable 127 if (substr($src_file,-4,4) == '.log') { 128 chmod($dst_path . $src_file, 0666); 129 } 110 130 echo "$dst_path$src_file created\n"; 111 131 } else { … … 170 190 171 191 /** 192 * Output a Usage message and exit 193 */ 194 function usage() { 195 echo <<<END 196 Usage: @BIN-DIR@/trax /path/to/your/app 197 198 Description: 199 The 'trax' command creates a new Trax application with a default 200 directory structure and configuration at the path you specify. 201 202 Example: 203 trax /var/www/html 204 205 This generates a skeletal Trax installation in /var/www/html. 206 See the README in the newly created application to get going. 207 208 END; 209 exit; 210 } 211 212 /** 172 213 * Main program 173 214 */
