Beispiel #1
0
/**
* Ask user for a value, e.g. plugin name
*
* @param    filehandle  $fp             file handle, e.g. of 'php://stdin'
* @param    string      $desc1          first line of description
* @param    string      $desc2          second line of description
* @param    string      $defaultValue   default value, displayed in [...]
* @return   string                      value the user entered
*
*/
function getValue($fp, $desc1, $desc2, $defaultValue)
{
    echo "\n";
    echo $desc1 . "\n";
    echo "({$desc2}) [{$defaultValue}] ";
    $value = readln($fp);
    return $value;
}
Beispiel #2
0
#!/usr/bin/env php
<?php 
/**
 * This script should run after the pear install.
 *
 * It asks the user whether they want to setup a website now
 */
//if (readln("Would you like to add a website now? [y/n] ") != "y") {
//    die();
//}
echo "\nIntro text\n\n";
$name = readln("Website name:", "example.com");
$path = readln("Website path:", "/var/www");
$virtualHostPath = readln("Path to virtual hosts: ", "/etc/apache2/sites-available");
$hostsFilePath = readln("Path to hosts file:", "/etc/hosts");
if (is_dir($path . "/" . $name)) {
    echo "\nDirectory: " . $path . "/" . $name . " already exists, skipping intial directory creation...\n";
} else {
    echo "\nCreating " . $path . "/" . $name . "...";
    mkdir($path . "/" . $name);
    echo "\nCopying default application into directory...";
    $source = '@php_dir@' == '@' . 'php_dir@' ? dirname(__FILE__) . '/../app' : '@php_dir@' . '/xframe/app';
    smartCopy($source, $path . "/" . $name);
    unlink($path . "/" . $name . "/.ignore");
    //update the conf files
    updateConf($path . "/" . $name . "/config/dev.ini", $path . "/" . $name);
    updateConf($path . "/" . $name . "/config/test.ini", $path . "/" . $name);
    updateConf($path . "/" . $name . "/config/live.ini", $path . "/" . $name);
}
if (file_exists($virtualHostPath . "/" . $name)) {
    echo "\nVirtual host configuration already exists, skipping...";
Beispiel #3
0
    usort($subtitles, function ($a, $b) {
        if ($a->destaque and !$b->destaque) {
            return -1;
        }
        if ($b->destaque and !$a->destaque) {
            return 1;
        }
        return $a->downloads > $b->downloads ? -1 : 1;
    });
}
if (count($subtitles) > 1 and !(array_key_exists('f', $options) or array_key_exists('first', $options))) {
    echo "Qual das legendas abaixo desejas baixar?\n\n";
    foreach ($subtitles as $id => $subtitle) {
        echo sprintf('[%' . (count($subtitles) > 10 ? 2 : 1) . "d] %s %s (%d/dl %s)\n", $id, $subtitle->destaque ? '*' : ' ', $subtitle->arquivo, $subtitle->downloads, $subtitle->idioma);
    }
    $option = (int) readln();
    while (!isset($subtitles[$option])) {
        echo 'Opção inválida. Digite novamente: ';
        $option = readln();
    }
    $subtitle = $subtitles[$option];
} elseif ($subtitles) {
    $subtitle = $subtitles[0];
    // A única :)
} else {
    echo "Nenhuma legenda encontrada :(\n";
    exit(1);
}
echo "Baixando {$subtitle->arquivo}...\n";
$filename = $subtitle->download();
echo "Arquivo {$filename} baixado!\n";