예제 #1
0
 /**
  * @return array
  */
 public static function configure()
 {
     $io = PicCLI::getIO();
     $io->outln("Please specify the full path to where the SQLite database file should be created.");
     $path = PicCLI::prompt("Path");
     if (!$path) {
         $io->errln("No path specified.");
         exit(PicCLI::EXIT_INPUT);
     }
     if ($path[0] !== "/") {
         $io->errln("Must provide absolute path.");
         exit(PicCLI::EXIT_INPUT);
     }
     if (file_exists($path)) {
         $io->errln("Path to database file already exists.");
         exit(PicCLI::EXIT_INPUT);
     }
     if (!is_writeable(dirname($path))) {
         $io->errln("The current user does not have permission to write to that directory.");
         exit(PicCLI::EXIT_INPUT);
     }
     return array("path" => $path);
 }
예제 #2
0
<?php

PicCLI::initGetopt(array("add", "remove", "user", "group"));
$io = PicCLI::getIO();
if (PicCLI::getGetopt("--add")) {
    $mode = "add";
} elseif (PicCLI::getGetopt("--remove")) {
    $mode = "remove";
} else {
    $io->errln("No mode specified.");
    exit(PicCLI::EXIT_USAGE);
}
if (!($pathID = PicCLI::getGetopt(1))) {
    $io->errln("No path ID specified.");
    exit(PicCLI::EXIT_USAGE);
}
if (!is_numeric($pathID)) {
    $io->errln("Invalid path ID supplied.");
    exit(PicCLI::EXIT_INPUT);
}
$pathID = (int) $pathID;
loadPicFile("classes/db.php");
PicDB::initDB();
if (!loadPicFile("helpers/id/path.php", array("id" => $pathID))) {
    $io->errln(sprintf("Path %d does not exist.", $pathID));
    exit(PicCLI::EXIT_INPUT);
}
if (PicCLI::getGetopt("--user")) {
    if (!($username = PicCLI::getGetopt(2))) {
        $username = PicCLI::prompt("Username");
        if (!$username) {
예제 #3
0
<?php

define("BASE_PATH", dirname(__DIR__) . "/");
if (!file_exists(BASE_PATH . "conf/app.json")) {
    fwrite(STDERR, "Pictorials is not installed.\n");
    exit(1);
}
if (empty($argv[1])) {
    fwrite(STDERR, "No sub-command specified.\n");
    exit(1);
}
require BASE_PATH . "main/bootstrap.php";
loadPicFile("classes/cli.php");
try {
    $command = PicCLI::initCommandCLI(array("create", "update", "delete", "view", "list", "allow", "deny", "permission"));
} catch (Exception $e) {
    PicCLI::getIO()->errln($e->getMessage());
    exit(PicCLI::EXIT_USAGE);
}
loadPicFile("entry/_path/{$command}.php");