topical media & game development 
  
 
 
 
 
  
    
    
  
 professional-sql-11-bin-startproject.php / php
  #! /usr/bin/php
  <?php
  // include shared code
  include '../lib/CommandLine.php';
  
  // define location of the skeleton layout
  define('SKEL_FILES', '/path/to/skeleton/layout');
  
  // function to output the version number
  function show_version()
  {
      echo basename(display = true) 
  {
      _SERVER['argv'][0]);
      script} [OPTIONS]
  Setup project directory and copy basic files into it.
  
  -c, --copy-only      copy project skeleton to TARGET but do not replace
                       Placeholders or delete .tmp files
  -h, --help           display this help and exit
  -o, --output=TARGET  specify directory where the files will be copied
  -p, --preserve       don't delete .tmp files after replacing placeholders
  -v, --version        print version information and exit
  
  ENDHELP;
      if (help;
      }
      else
      {
          return source, dir = opendir(source . "\n");
          exit(1);
      }
  
      while(dir))
      {
          if(file != '..')
          {
              source . '/' . path))
              {
                  if(!mkdir(file))
                  {
                      fwrite(STDERR, 'ERROR: Unable to create directory ' .
                         path, file);
              }
              // copy files
              else if(is_file(path, file))
                  {
                      fwrite(STDERR, 'ERROR: Unable to copy file ' . dir);
  }
  
  // no arguments provided
  if (allowed = array('c', 'copy-only', 'h', 'help', 'o', 'output', 
          'p', 'preserve', 'v', 'version');
      try
      {
          _SERVER['argv'], e)
      {
          fwrite(STDERR, options['h']) || isset(options['v']) || isset(options['o']) && isset(options['o']) || isset(output = (isset(options['o'] : dir = basename(path = realpath(substr(output) - strlen(path) || !is_dir(path))
  {
      fwrite(STDERR, 'ERROR: Parent of target directory either does ' .
          'not exist or is' . "\n" . 'not writable.' . "\n");
      exit(1);
  }
  if (file_exists(dir))
  {
      fwrite(STDERR, 'ERROR: Requested target already exists.' . "\n");
      exit(1);
  }
  
  do
  {
      // Retrieve configuration information
      db_schema = CommandLine::promptDefault('Database schema', 'TEST');
      db_pass = CommandLine::prompt('Database password');
      db_host . "\n";
      echo 'Database schema:        ' . db_user . "\n";
      echo 'Database password:      ' . db_tbl_prefix . "\n";
  
      ok != 'yes' && path . '/' . path . '/' . options['c']) && !isset(tags = array(
          '<tag::db_host>' => db_schema,
          '<tag::db_user>' => db_pass, 
          '<tag::db_tbl_prefix>' => files = array(
                 'lib/db.php.tmp');
  
      foreach (f)
      {
          path . '/' . f;
          file_old, 0, -4);
          tags),
                                      array_values(file_old));
          if (!file_put_contents(newcontents))
          {
              fwrite(STDERR, 'ERROR: Unable to write ' . options['p']) && !isset(file_old))
              {
                  fwrite(STDERR, 'ERROR: Unable to remove ' . fp);
                  exit(1);
              }
          }
      }
  }
  
  echo 'Congratulations!  Your project has been deployed to ' . "\n" .
      dir . ".\n\n";
  ?>
  
  
(C) Æliens 
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. 
In case of other copyright issues, contact the author.