コード例 #1
0
ファイル: help.php プロジェクト: parkerj/eduTrac-SIS
    private function general_help()
    {
        ETSIS_CLI::line(<<<EOB

NAME

  etsis
      
DESCRIPTION
            
  Manage eduTrac SIS through command line.
            
SYNOPSIS
            
  etsis <command>

COMMANDS

  cli       Get information about ETSIS-CLI itself.
  core      Install, update and manage eduTrac SIS.
  help      Get help on ETSIS-CLI.
  db        Perform basic database operations.

OPTIONAL PARAMETERS    

  --require=<path>      Load a PHP file before running a command.
  --path=<path>         Path to eduTrac SIS files.
  --dir=<path>          Set path to locate file or where file should be saved.

FLAGS
  --verbose, -v         Turn on verbose output.
  --quiet, -q           Disable all output.
EOB
);
    }
コード例 #2
0
ファイル: cli.php プロジェクト: parkerj/eduTrac-SIS
 /**
  * Print various data about the CLI environment.
  *
  * ## EXAMPLES
  *
  *     # Display CLI environment.
  *     $ ./etsis cli info 
  */
 function info()
 {
     $php_bin = defined('PHP_BINARY') ? PHP_BINARY : getenv('ETSIS_CLI_PHP_USED');
     ETSIS_CLI::line("PHP binary:\t" . $php_bin);
     ETSIS_CLI::line("PHP version:\t" . PHP_VERSION);
     ETSIS_CLI::line("php.ini used:\t" . get_cfg_var('cfg_file_path'));
     ETSIS_CLI::line("PHP Modules:\t" . shell_exec('php -m'));
     ETSIS_CLI::line("MySQL Version:\t" . exec('mysql -V'));
     ETSIS_CLI::line("ETSIS-CLI root dir:\t" . ETSIS_CLI_ROOT);
     ETSIS_CLI::line("ETSIS-CLI version:\t" . ETSIS_CLI_VERSION);
 }
コード例 #3
0
 public static function describe_command($class, $command)
 {
     if (method_exists($class, 'help')) {
         $class::help();
         return;
     }
     $methods = self::get_subcommands($class);
     $out = "Usage: etsis {$command}";
     if (empty($methods)) {
         ETSIS_CLI::line($out);
     } else {
         $out .= ' [' . implode('|', $methods) . ']';
         ETSIS_CLI::line($out);
     }
 }
コード例 #4
0
ファイル: core.php プロジェクト: parkerj/eduTrac-SIS
 /**
  * Use this command to update installation.
  * 
  * ## EXAMPLES  
  * 
  *      #Updates a current installation.
  *      $ ./etsis core update
  */
 public function update()
 {
     $zip = new ZipArchive();
     $current_release = ETSIS_CLI::getCurrentRelease();
     $file = 'http://etsis.s3.amazonaws.com/core/1.1/release/' . $current_release . '.zip';
     if (version_compare(trim(file_get_contents('RELEASE')), $current_release, '<')) {
         if (ETSIS_CLI::checkExternalFile($file) == 200) {
             //Download file to the server
             opt_notify(new \cli\progress\Bar('Downloading ', 1000000));
             ETSIS_CLI::getDownload($current_release . '.zip', $file);
             //Unzip the file to update
             opt_notify(new \cli\progress\Bar('Unzipping ', 1000000));
             $x = $zip->open($current_release . '.zip');
             if ($x === true) {
                 //Extract file in root.
                 $zip->extractTo(realpath(__DIR__ . '/../../../../../../'));
                 $zip->close();
                 //Remove download after completion.
                 unlink($current_release . '.zip');
             }
             ETSIS_CLI::line('Core upgrade complete.');
             ETSIS_CLI::line('Run the command %G./etsis db migrate%n to check for database updates.');
         } else {
             ETSIS_CLI::line('Update server cannot be reached. Please try again later.');
         }
     } else {
         ETSIS_CLI::line('No Update');
     }
 }
コード例 #5
0
ファイル: db.php プロジェクト: parkerj/eduTrac-SIS
 /**
  * List all the tables in eduTrac SIS database.
  * 
  * ## EXAMPLES
  *  
  *     $ ./etsis db tables
  *     Success: Database table list complete. 
  */
 public function tables()
 {
     try {
         $this->pdo = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS, [PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"]);
         $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $this->pdo->query('SET CHARACTER SET utf8');
     } catch (PDOException $e) {
         ETSIS_CLI::error(sprintf('"%s"', $e->getMessage()));
     }
     $opt = $this->pdo->query("SHOW TABLES");
     foreach ($opt as $r) {
         ETSIS_CLI::line(' %GTable:%n ' . $r['Tables_in_' . DB_NAME]);
     }
     $this->pdo = null;
     ETSIS_CLI::success('Database table list complete.');
 }