Changeset 79
- Timestamp:
- Apr 5, 2006 7:16:48 PM (18 years ago)
- Location:
- branches/1.1dev
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.1dev/bin/module_maker/form_template.cli.php
r78 r79 1 #!/usr/local/bin/php -q1 #!/usr/local/bin/php 2 2 <?php 3 3 /** … … 6 6 */ 7 7 8 $CFG->enable_session = false; 9 $CFG->log_screen_priority = LOG_DEBUG; 10 error_reporting(E_ALL); 11 require_once dirname(__FILE__) . '/../../config/boot.inc.php'; 8 // Get module maker configuration. 9 require_once dirname(__FILE__) . '/_config.inc.php'; 12 10 13 11 // Test arguments. 14 if ($_SERVER['argc'] == 2) {15 $db_tbl = $_SERVER['argv'][ 1];12 if ($_SERVER['argc'] == 3) { 13 $db_tbl = $_SERVER['argv'][2]; 16 14 } else { 17 die(basename($_SERVER['argv'][0]) . " Warning: You must specify a DB table as the firstargument.\n");15 die(basename($_SERVER['argv'][0]) . " Warning: You must specify a DB table as the second argument.\n"); 18 16 } 19 17 -
branches/1.1dev/bin/module_maker/list_template.cli.php
r78 r79 1 #!/usr/local/bin/php -q1 #!/usr/local/bin/php 2 2 <?php 3 3 /** … … 7 7 8 8 9 $CFG->enable_session = false; 10 $CFG->log_screen_priority = LOG_DEBUG; 11 error_reporting(E_ALL); 12 require_once dirname(__FILE__) . '/../../config/boot.inc.php'; 9 // Get module maker configuration. 10 require_once dirname(__FILE__) . '/_config.inc.php'; 13 11 14 12 $op = null; … … 16 14 17 15 // Test arguments. 18 if ($_SERVER['argc'] == 2) {19 $db_tbl = $_SERVER['argv'][ 1];20 } else if ($_SERVER['argc'] == 3) {21 $db_tbl = $_SERVER['argv'][ 1];22 $op = $_SERVER['argv'][ 2];16 if ($_SERVER['argc'] == 3) { 17 $db_tbl = $_SERVER['argv'][2]; 18 } else if ($_SERVER['argc'] == 4) { 19 $db_tbl = $_SERVER['argv'][2]; 20 $op = $_SERVER['argv'][3]; 23 21 } else { 24 die(basename($_SERVER['argv'][0]) . " Warning: You must specify a DB table as the firstargument.\n");22 die(basename($_SERVER['argv'][0]) . " Warning: You must specify a DB table as the second argument.\n"); 25 23 } 26 24 -
branches/1.1dev/bin/module_maker/module.cli.php
r78 r79 1 #!/usr/local/bin/php -q1 #!/usr/local/bin/php 2 2 <?php 3 3 /** … … 7 7 8 8 9 $CFG->enable_session = false; 10 $CFG->log_screen_priority = LOG_DEBUG; 11 error_reporting(E_ALL); 12 require_once dirname(__FILE__) . '/../../config/boot.inc.php'; 9 // Get module maker configuration. 10 require_once dirname(__FILE__) . '/_config.inc.php'; 13 11 14 12 … … 18 16 19 17 // Test for a single argument. 20 if ($_SERVER['argc'] == 4 && $_SERVER['argv'][3] == 'clean') {21 $module_name_singular = $_SERVER['argv'][ 1];22 $module_name_plural = $_SERVER['argv'][ 2];23 } else if ($_SERVER['argc'] == 3) {18 if ($_SERVER['argc'] == 5 && $_SERVER['argv'][4] == 'clean') { 19 $module_name_singular = $_SERVER['argv'][2]; 20 $module_name_plural = $_SERVER['argv'][3]; 21 } else if ($_SERVER['argc'] == 4) { 24 22 // Normal operation. 25 $module_name_singular = $_SERVER['argv'][ 1];26 $module_name_plural = $_SERVER['argv'][ 2];27 } else if ($_SERVER['argc'] == 2 && $_SERVER['argv'][1] == '_default_') {23 $module_name_singular = $_SERVER['argv'][2]; 24 $module_name_plural = $_SERVER['argv'][3]; 25 } else if ($_SERVER['argc'] == 3 && $_SERVER['argv'][2] == '_default_') { 28 26 // Hacked mode: use these module names: 29 27 $module_name_singular = 'event'; … … 33 31 die(basename($_SERVER['argv'][0]) . " Error: invalid arguments. Try like this: 34 32 35 " . basename($_SERVER['argv'][0]) . " <namesingular> <nameplural> 33 " . basename($_SERVER['argv'][0]) . " <sitedirectory> <namesingular> <nameplural> 34 35 E.g.: " . basename($_SERVER['argv'][0]) . " ~/Sites/www.asdf.com category categories 36 36 37 37 There is also a secret _default_ option that uses options hard-coded into the script. Hack the script for more info. … … 48 48 49 49 // Where deleted files go: 50 $user_trash_folder = "/Users/" . get_current_user() . "/.Trash";50 $user_trash_folder = $_SERVER['HOME'] . '/.Trash'; 51 51 52 52 // Directories … … 77 77 78 78 79 if ($_SERVER['argc'] == 4 && $_SERVER['argv'][3] == 'clean') { 80 cleanFiles(); 79 // Only after we've defined essential files can we clean. 80 if ($_SERVER['argc'] == 5 && $_SERVER['argv'][4] == 'clean') { 81 echo "Beginning file cleanup\n"; 82 trashFile("$admin_dir/$admin_script"); 83 trashFile("$admin_tpl_dir/$admin_list_template"); 84 trashFile("$admin_tpl_dir/$admin_form_template"); 85 trashFile("$public_dir/$public_script"); 86 trashFile("$public_tpl_dir/$public_list_template"); 87 trashFile("$public_tpl_dir/$public_detail_template"); 88 echo "End file cleanup\n"; 81 89 die; 82 90 } 91 92 // Go! 93 echo 'Running Module Maker. Using database: ' . $CFG->database . "\n"; 94 83 95 84 96 /****************************************************************************** … … 395 407 *****************************************************************************/ 396 408 397 /** 398 * Removes existing modules files. Danger! 399 */ 400 function cleanFiles() 409 function trashFile($file_path_name) 401 410 { 402 411 global $user_trash_folder; 403 global $admin_dir; 404 global $admin_script; 405 global $admin_tpl_dir; 406 global $admin_list_template; 407 global $admin_form_template; 408 global $public_dir; 409 global $public_script; 410 global $public_tpl_dir; 411 global $public_detail_template; 412 global $public_list_template; 413 414 echo "Beginning file cleanup\n"; 415 416 if (!dir($user_trash_folder)) { 417 mkdir($user_trash_folder); 418 chmod($user_trash_folder, 0777); 419 echo "Attempting to create user trash folder: $user_trash_folder/\n"; 412 static $file_prefix; 413 414 if (!isset($file_prefix)) { 415 $file_prefix = time(); 416 } else { 417 $file_prefix++; 420 418 } 421 if (!dir("$user_trash_folder/") || !is_writable("$user_trash_folder/")) { 419 420 // Make user trash folder. 421 if (!is_dir($user_trash_folder)) { 422 echo "Attempting to create user trash folder: $user_trash_folder/\n"; 423 mkdir($user_trash_folder); 424 chmod($user_trash_folder, 0777); 425 } 426 if (!is_dir("$user_trash_folder") || !is_writable("$user_trash_folder")) { 422 427 die("User trash directory not available: $user_trash_folder/\n"); 423 428 } 424 429 425 if (file_exists("$admin_dir/$admin_script")) { 426 rename("$admin_dir/$admin_script", "$user_trash_folder/$admin_script" . '_' . md5(microtime())); 427 printf("Moved to trash: %s\n", "$admin_dir/$admin_script"); 430 // Move file to trash. 431 if (file_exists($file_path_name)) { 432 rename($file_path_name, sprintf('%s/%s_%s', $user_trash_folder, $file_prefix, basename($file_path_name))); 433 printf("Moved: %s -> %s\n", $file_path_name, sprintf('%s/%s_%s', $user_trash_folder, $file_prefix, basename($file_path_name))); 428 434 } else { 429 printf("File not found: %s\n", "$admin_dir/$admin_script");435 printf("File not found: %s\n", $file_path_name); 430 436 } 431 432 if (file_exists("$admin_tpl_dir/$admin_list_template")) {433 rename("$admin_tpl_dir/$admin_list_template", "$user_trash_folder/$admin_list_template" . '_' . md5(microtime()));434 printf("Moved to trash: %s\n", "$admin_tpl_dir/$admin_list_template");435 } else {436 printf("File not found: %s\n", "$admin_tpl_dir/$admin_list_template");437 }438 439 if (file_exists("$admin_tpl_dir/$admin_form_template")) {440 rename("$admin_tpl_dir/$admin_form_template", "$user_trash_folder/$admin_form_template" . '_' . md5(microtime()));441 printf("Moved to trash: %s\n", "$admin_tpl_dir/$admin_form_template");442 } else {443 printf("File not found: %s\n", "$admin_tpl_dir/$admin_form_template");444 }445 446 if (file_exists("$public_dir/$public_script")) {447 rename("$public_dir/$public_script", "$user_trash_folder/$public_script" . '_' . md5(microtime()));448 printf("Moved to trash: %s\n", "$public_dir/$public_script");449 } else {450 printf("File not found: %s\n", "$public_dir/$public_script");451 }452 453 if (file_exists("$public_tpl_dir/$public_list_template")) {454 rename("$public_tpl_dir/$public_list_template", "$user_trash_folder/$public_list_template" . '_' . md5(microtime()));455 printf("Moved to trash: %s\n", "$public_tpl_dir/$public_list_template");456 } else {457 printf("File not found: %s\n", "$public_tpl_dir/$public_list_template");458 }459 460 if (file_exists("$public_tpl_dir/$public_detail_template")) {461 rename("$public_tpl_dir/$public_detail_template", "$user_trash_folder/$public_detail_template" . '_' . md5(microtime()));462 printf("Moved to trash: %s\n", "$public_tpl_dir/$public_detail_template");463 } else {464 printf("File not found: %s\n", "$public_tpl_dir/$public_detail_template");465 }466 467 echo "End file cleanup\n";468 437 } 469 438 -
branches/1.1dev/bin/module_maker/sql.cli.php
r78 r79 6 6 */ 7 7 8 $CFG->enable_session = false; 9 $CFG->log_screen_priority = LOG_DEBUG; 10 error_reporting(E_ALL); 11 require_once dirname(__FILE__) . '/../../config/boot.inc.php'; 8 // Get module maker configuration. 9 require_once dirname(__FILE__) . '/_config.inc.php'; 12 10 13 11 $op = null; … … 15 13 16 14 // Test arguments. 17 if ($_SERVER['argc'] == 2) {18 $db_tbl = $_SERVER['argv'][ 1];19 } else if ($_SERVER['argc'] == 3) {20 $db_tbl = $_SERVER['argv'][ 1];21 $op = $_SERVER['argv'][ 2];15 if ($_SERVER['argc'] == 3) { 16 $db_tbl = $_SERVER['argv'][2]; 17 } else if ($_SERVER['argc'] == 4) { 18 $db_tbl = $_SERVER['argv'][2]; 19 $op = $_SERVER['argv'][3]; 22 20 } else { 23 die(basename($_SERVER['argv'][0]) . " Warning: You must specify a DB table as the firstargument.\n");21 die(basename($_SERVER['argv'][0]) . " Warning: You must specify a DB table as the second argument.\n"); 24 22 } 25 23 -
branches/1.1dev/bin/module_maker/validation.cli.php
r78 r79 7 7 8 8 9 $CFG->enable_session = false; 10 $CFG->log_screen_priority = LOG_DEBUG; 11 error_reporting(E_ALL); 12 require_once dirname(__FILE__) . '/../../config/boot.inc.php'; 9 // Get module maker configuration. 10 require_once dirname(__FILE__) . '/_config.inc.php'; 13 11 14 12 // Test arguments. 15 if ($_SERVER['argc'] == 2) {16 $db_tbl = $_SERVER['argv'][ 1];13 if ($_SERVER['argc'] == 3) { 14 $db_tbl = $_SERVER['argv'][2]; 17 15 } else { 18 die(basename($_SERVER['argv'][0]) . " Warning: You must specify a DB table as the firstargument.\n");16 die(basename($_SERVER['argv'][0]) . " Warning: You must specify a DB table as the second argument.\n"); 19 17 } 20 18 -
branches/1.1dev/lib/App.inc.php
r78 r79 104 104 if (!is_dir($CFG->log_directory) || !is_writable($CFG->log_directory)) { 105 105 // We must use trigger_error rather than calling logMsg, which might lead to an infinite loop. 106 trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $CFG->log_directory), E_USER_ERROR); 106 trigger_error(sprintf('Codebase error: log directory not found or writable: %s', $CFG->log_directory), E_USER_NOTICE); 107 $CFG->log_directory = '/tmp'; 108 $CFG->log_filename = sprintf('%s_%s.log', getenv('USER'), getenv('HTTP_HOST')); 107 109 } 108 110 … … 121 123 122 124 // FILE ACTION 123 if ($ priority <= $CFG->log_file_priority &&$CFG->log_file_priority) {125 if ($CFG->log_file_priority && $priority <= $CFG->log_file_priority) { 124 126 error_log($event_str . "\n", 3, $CFG->log_directory . '/' . $CFG->log_filename); 125 127 } 126 128 127 129 // EMAIL ACTION 128 if ($ priority <= $CFG->log_email_priority &&$CFG->log_email_priority) {130 if ($CFG->log_email_priority && $priority <= $CFG->log_email_priority) { 129 131 if (empty($CFG->log_to_email)) { 130 132 $CFG->log_to_email = 'bug@strangecode.com'; … … 140 142 141 143 // SMS ACTION 142 if ($ priority <= $CFG->log_sms_priority &&$CFG->log_sms_priority) {144 if ($CFG->log_sms_priority && $priority <= $CFG->log_sms_priority) { 143 145 if (empty($CFG->log_to_email)) { 144 146 $CFG->log_to_sms = 'bug@strangecode.com'; … … 150 152 151 153 // SCREEN ACTION 152 if ($ priority <= $CFG->log_screen_priority &&$CFG->log_screen_priority) {154 if ($CFG->log_screen_priority && $priority <= $CFG->log_screen_priority) { 153 155 echo "[{$event['date']}] [{$event['type']}] [{$event['file:line']}] [{$event['message']}]\n"; 154 156 } … … 292 294 } 293 295 294 /** 295 * Redirects a user by calling the dieURL(). It will use: 296 * 1. the stored boomerang URL, it it exists 297 * 2. the referring URL, it it exists. 298 * 3. an empty string, which will force dieURL to use the default URL. 299 */ 300 function dieBoomerangURL($id=null, $carry_args=null) 296 /* 297 * Redirects a user by calling App::dieURL(). It will use: 298 * 1. the stored boomerang URL, it it exists 299 * 2. a specified $default_url, it it exists 300 * 3. the referring URL, it it exists. 301 * 4. redirect_home_url configuration variable. 302 * 303 * @access public 304 * @param string $id Identifier for this script. 305 * @param mixed $carry_args Additional arguments to carry in the URL automatically (see App::oHREF()). 306 * @param string $default_url A default URL if there is not a valid specified boomerang URL. 307 * @return bool False if the session is not running. No return otherwise. 308 * @author Quinn Comendant <quinn@strangecode.com> 309 * @since 31 Mar 2006 19:17:00 310 */ 311 function dieBoomerangURL($id=null, $carry_args=null, $default_url=null) 301 312 { 302 313 // Get URL from stored boomerang. Allow non specific URL if ID not valid. … … 307 318 $url = end($_SESSION['_boomerang']['url']); 308 319 } 309 } else if (!refererIsMe() && !preg_match('/admin_common/', getenv('SCRIPT_NAME'))) { 320 } else if (isset($default_url)) { 321 $url = $default_url; 322 } else if (!refererIsMe()) { 310 323 // Ensure that the redirecting page is not also the referrer. 311 // admin_common is an alias of 'admin', which confuses this function. Just here for local testing.312 324 $url = getenv('HTTP_REFERER'); 313 325 } else {
Note: See TracChangeset
for help on using the changeset viewer.