| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 #!/usr/bin/env php 2 <?php 3 /** 4 * @file 5 * Implement video rendering scheduling. 6 * If you are not using sites/default/settings.php as your settings file, 7 * add an optional parameter for the drupal site url: 8 * "php video_scheduler.php http://example.com/" or 9 * "php video_scheduler.php http://example.org/drupal/" 10 * 11 * @author Heshan Wanigasooriya <heshan at heidisoft dot com, heshanmw at gmail dot com> 12 * 13 */ 14 15 /** 16 * Drupal shell execution script 17 */ 18 19 $script = basename(array_shift($_SERVER['argv'])); 20 $script_name = realpath($script); 21 $php_exec = realpath($_SERVER['PHP_SELF']); 22 23 $shortopts = 'hr:s:v'; 24 $longopts = array('help', 'root:', 'site:', 'verbose'); 25 26 $args = @getopt($shortopts, $longopts); 27 28 if (isset($args['h']) || isset($args['help'])) { 29 echo <<<EOF 30 31 Video Scheduler. 32 33 Usage: {$script} [OPTIONS] 34 Example: {$script} 35 36 All arguments are long options. 37 38 -h, --help This page. 39 40 -r, --root Set the working directory for the script to the specified path. 41 To execute Drupal this has to be the root directory of your 42 Drupal installation, f.e. /home/www/foo/drupal (assuming Drupal 43 running on Unix). Current directory is not required. 44 Use surrounding quotation marks on Windows. 45 46 -s, --site Used to specify with site will be used for the upgrade. If no 47 site is selected then default will be used. 48 49 -v, --verbose This option displays the options as they are set, but will 50 produce errors from setting the session. 51 52 To run this script without --root argument invoke it from the root directory 53 of your Drupal installation with 54 55 ./{$script} 56 57 \n 58 EOF; 59 if (version_compare(phpversion(), '5.3.0', 'le')) { 60 echo "Warning: This version of PHP doesn't support long options\n"; 61 } 62 exit; 63 } 64 65 // define default settings 66 $_SERVER['HTTP_HOST'] = 'default'; 67 $_SERVER['PHP_SELF'] = '/index.php'; 68 $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; 69 $_SERVER['SERVER_SOFTWARE'] = 'PHP CLI'; 70 $_SERVER['REQUEST_METHOD'] = 'GET'; 71 $_SERVER['QUERY_STRING'] = ''; 72 $_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = '/index.php'; 73 $_SERVER['SCRIPT_NAME'] = '/' . basename($_SERVER['SCRIPT_NAME']); 74 $_SERVER['HTTP_USER_AGENT'] = 'console'; 75 76 // Starting directory 77 $cwd = realpath(getcwd()); 78 79 // toggle verbose mode 80 $_verbose_mode = isset($args['v']) || isset($args['verbose']) ? TRUE : FALSE; 81 82 // parse invocation arguments 83 if (isset($args['r']) || isset($args['root'])) { 84 // change working directory 85 $path = isset($args['r']) ? $args['r'] : $args['root']; 86 if (is_dir($path)) { 87 chdir($path); 88 } 89 else { 90 echo "\nERROR: {$path} not found.\n\n"; 91 exit(1); 92 } 93 } 94 else { 95 $path = $cwd; 96 while ($path && !(file_exists($path . '/index.php') && file_exists($path . '/includes/bootstrap.inc'))) { 97 $path = dirname($path); 98 } 99 100 if (!(file_exists($path . '/index.php') && file_exists($path . '/includes/bootstrap.inc'))) { 101 echo "Unable to locate Drupal root, user -r option to specify path to Drupal root\n"; 102 exit(1); 103 } 104 chdir($path); 105 } 106 107 if (isset($args['s']) || isset($args['site'])) { 108 $site = isset($args['s']) ? $args['s'] : $args['site']; 109 if (file_exists('./sites/' . $site)) { 110 $_SERVER['HTTP_HOST'] = $site; 111 } 112 else { 113 echo "ERROR: Unable to locate site {$site}\n"; 114 exit(1); 115 } 116 } 117 else if (preg_match('/' . preg_quote($path . '/sites/', '/') . '(.*?)\//i', $cwd, $matches)) { 118 if ($matches[1] != 'all' && file_exists('./sites/' . $matches[1])) { 119 $_SERVER['HTTP_HOST'] = $matches[1]; 120 } 121 } 122 123 define('DRUPAL_ROOT', realpath(getcwd())); 124 125 ini_set('display_errors', 0); 126 include_once DRUPAL_ROOT . '/includes/bootstrap.inc'; 127 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); 128 ini_set('display_errors', 1); 129 130 // turn off the output buffering that drupal is doing by default. 131 ob_end_flush(); 132 133 //include our conversion class (also contains our defines) 134 module_load_include('inc', 'video', 'includes/conversion'); 135 $video_conversion = new video_conversion; 136 $video_conversion->run_queue();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |