コード例 #1
0
ファイル: cli.php プロジェクト: enigmatic-user/resellershop
function askColor($sQuestion)
{
    $sInput = ask($sQuestion);
    while (!preg_match('/^#[0-9a-f]{6}$/i', $sInput)) {
        $sInput = ask(array("Bitte geben Sie einen sechsstelligen Farbcode mit fuehrender Raute an: ", "(Beispiel fuer Farbe Petrol: #027a8b) "));
    }
    return $sInput;
}
コード例 #2
0
/**
 * Farbeinstellungen des Benutzers auslesen
 *
 * @return array        Farbwerte aus der global.ini als Array
 */
function getColors()
{
    // Einstellungen aus der global.ini auslesen
    $hColors = Settings::getValue('global', 'colors');
    if (!$hColors) {
        say("Farbeinstellungen konnten nicht ausgelesen werden");
        return false;
    }
    $hSettingsToChange = array();
    // Hauptfarbe nicht vorhanden -> Alles abbrechen
    if (!array_key_exists('main', $hColors) || $hColors['main'] === '{{hauptfarbe}}') {
        say('Es fehlt die Hauptfarbe in der global.ini! ');
        say('Bitte stellen Sie sicher, dass ein Bereich [colors] vorhanden ist. ');
        say('Setzen Sie darunter eine Zeile mit dem Inhalt main="#<ihrefarbe>". ');
        say('Beispiel: ');
        say('main="#027a8b"');
        // Nach Hauptfarbe fragen
        $sMainColor = null;
        do {
            if ($sMainColor !== null) {
                say('Ihre angegebene Farbe ist keine Hex-Farbe.');
            }
            $sMainColor = ask("Bitte geben Sie Ihre Hauptfarbe im Format #rrggbb an: ");
        } while (!preg_match('/^#[0-9a-z]{3}([0-9a-z]{3})?$/i', $sMainColor));
        $hColors['main'] = $sMainColor;
        $hSettingsToChange['main'] = '"' . $sMainColor . '"';
    }
    // Akzentfarbe nicht angegeben -> Hauptfarbe uebernehmen
    if (!array_key_exists('accent', $hColors) || $hColors['accent'] === '{{akzentfarbe}}') {
        say('Es wurde keine Akzentfarbe angegeben. Verwende Hauptfarbe als Akzentfarbe. ');
        say('Damit eine Akzentfarbe verwendet werden kann, muss in der global.ini ');
        say('eine Zeile mit dem Inhalt accent="#<ihrefarbe>" vorhanden sein. ');
        say('Beispiel: ');
        say('accent="#f59000"');
        // Nach Akzentfarbe fragen
        $sAccentColor = null;
        do {
            if ($sAccentColor !== null) {
                say('Ihre angegebene Farbe ist keine Hex-Farbe.');
            }
            $sAccentColor = ask("Bitte geben Sie Ihre Akzentfarbe im Format #rrggbb an: ");
        } while (!preg_match('/^#[0-9a-z]{3}([0-9a-z]{3})?$/i', $sAccentColor));
        $hColors['accent'] = $sAccentColor;
        $hSettingsToChange['accent'] = '"' . $sAccentColor . '"';
    }
    // Darkmode nicht angegeben -> nicht aktivieren
    if (!array_key_exists('darkmode', $hColors) || $hColors['darkmode'] === '{{farben-invertieren}}') {
        say('In den Einstellungen fehlt die Angabe der Invertierung. ');
        say('Soll der Text weiss auf schwarz dargestellt werden? (y/n): ');
        $hColors['darkmode'] = getCliBool();
        $hSettingsToChange['darkmode'] = $hColors['darkmode'] ? 'true' : 'false';
    }
    // Farbcode-Angaben auch in der global.ini uebernehmen
    if (count($hSettingsToChange) > 0) {
        updateGlobalConfig($hSettingsToChange);
    }
    return $hColors;
}
コード例 #3
0
function askAdditionalQuestions()
{
    $bShouldAskMoreQuestions = askBool(array("", "Herzlichen Glueckwunsch, Sie haben alle benoetigten Daten angegeben, damit ", "Ihr Shop seinen Dienst leisten kann. ", "Um Ihren Shop noch mehr Ihre Handschrift zu verleihen, empfehlen wir Ihnen, ", "in der global.ini weitere Angaben zu Ihrem Unternehmen und Shop, einzutragen. ", "Diese Angaben betreffen u.a. Kontaktdaten, weitere URLs und Ihre Firma. ", "Moechten Sie diese Daten nun direkt im Installationsvorgang angeben? (j/n): "));
    if ($bShouldAskMoreQuestions === 'false') {
        say(array("Sie koennen jederzeit die settings/global.ini oeffnen und saemtliche ", "Angaben anpassen. Sie erkennen einige auszufellende Werte z.B. an Stellen ", 'wie "{{unternehemensname}}" in Ihrem Shop. '));
        return false;
    }
    return array('vollstaendiger-unternehmensname' => ask(array("Bitte geben Sie fuer Seiten mit Gesetzestexten (wie z.B. AGB, Impressum) ", 'einen vollstaendigen Unternehmensnamen mit Rechtsform an ', '(Beispiel: ResellerShop GmbH & Co. KG): ')), 'unternehmensname' => ask(array("Bitte geben Sie den Unternehmensnamen an, der in Fliesstexten verwendet ", "werden soll (Beispiel: ResellerShop): ")), 'kurzer-unternehmensname' => ask(array("Bitte geben Sie einen abgekuerzten Unternehmensnamen an, der zur Variation ", "im Fliesstext verwendet wird (Beispiel: RP-Shop): ")), 'empfaenger-von-kontaktanfragen' => ask(array("", "Auf dem Shop befinden sich Kontaktformulare, mit denen Ihre Kunden und ", "Interessenten direkt mit Ihnen kommunizieren koennen. Sendet ein Benutzer ", "das Formular ab, so wird an eine hinterlegte E-Mail-Adresse eine ", "Nachricht gesendet. ", "Bitte geben Sie die E-Mail-Adresse des Empfaengers von ", "Kontaktnachrichten an: (Beispiel: info@reseller-shop.eu) ")), 'url-zu-ihrer-website' => askUrl(array("", "Fuer Verlinkungen auf Ihre regulaere Internetpraesenz (z.B. bei kritischen ", "Fehlern) koennen Sie die vollstaendige URL zu Ihrer Website angeben: ", "(Beispiel: https://www.reseller-shop.eu) ")), 'offizielle-url-zum-rp-system' => askDomain(array("Nutzen Sie eine eigene Subdomain fuer Ihr RP-System, so wird diese fuer ", "die Weiterleitung zu Ihrem RP beim Login verwendet. Wenn Sie nur die ", "URL mit Auftragsnummer verwenden, so verwenden Sie bitte diese hier. ", "Bitte geben Sie die offizielle URL an, unter der Ihr ResellerProfessional-", "System erreichbar ist: (Beispiel: https://demoshop.premium-admin.eu) ")));
}
コード例 #4
0
ファイル: wiki_base.php プロジェクト: apelon-ohie/ihris-site
function wikiLogin()
{
    global $login;
    global $wikilogin;
    global $snoopy;
    global $wikiapi_url;
    while (!$login) {
        $wikilogin['action'] = 'login';
        $wikilogin['lgname'] = trim(ask('wiki user name'));
        $wikilogin['lgpassword'] = getPassword('wikis');
        $wikilogin['format'] = 'php';
        if (!$snoopy instanceof Snoopy) {
            $snoopy = new Snoopy();
        }
        if (!$snoopy->submit($wikiapi_url, $wikilogin)) {
            I2CE::raiseError("Could not log in to {$wikiapi_url}");
            continue;
        }
        $res = unserialize($snoopy->results);
        if (array_key_exists('error', $res)) {
            I2CE::raiseError("Could not login:\n" . print_r($res['error'], true));
            continue;
        }
        if (!array_key_exists('login', $res) || !is_array($res['login']) || !array_key_exists('result', $res['login'])) {
            I2CE::raiseError("Error logging in:" . print_r($res, true));
            continue;
        }
        if ($res['login']['result'] == 'NeedToken' && array_key_exists('token', $res['login']) && $res['login']['token']) {
            $wikilogin['lgtoken'] = $res['login']['token'];
            $snoopy->setcookies();
            if (!$snoopy->submit($wikiapi_url, $wikilogin)) {
                I2CE::raiseError("Could not log in to {$wikiapi_url}");
                continue;
            }
            $res = unserialize($snoopy->results);
            if (array_key_exists('error', $res)) {
                I2CE::raiseError("Could not login:\n" . print_r($res['error'], true));
                continue;
            }
            if (!array_key_exists('login', $res) || !is_array($res['login']) || !array_key_exists('result', $res['login'])) {
                I2CE::raiseError("Error logging in");
                continue;
            }
        }
        if ($res['login']['result'] != 'Success') {
            I2CE::raiseError("No success logging in:" . print_r($res, true));
            continue;
        }
        I2CE::raiseError("Logged into {$wikiapi_url} as " . $wikilogin['lgname']);
        $snoopy->setcookies();
        $login = true;
    }
    return $login;
}
コード例 #5
0
function onzip($zipcode)
{
    global $zip;
    $zip = $zipcode;
    $categories = categories($channel);
    if ($channel == 'TEXT') {
        $sayZip = $zip;
    } else {
        $sayZip = "<say-as interpret-as='vxml:digits'>{$zip}</say-as>";
    }
    $event = ask("<speak>What are you looking for in {$sayZip}?</speak>", array("choices" => $categories, 'voice' => 'allison', "onChoice" => create_function('$event', 'onCategory($event->value);')));
}
コード例 #6
0
ファイル: functions.php プロジェクト: claudijd/phonebook
function get_ldap_connection()
{
    $ldapconn = ldap_connect(LDAP_HOST);
    $auth = new MozillaAuthAdapter();
    if (!isset($_SERVER["PHP_AUTH_USER"])) {
        ask();
        wail_and_bail();
    } else {
        // Check for validity of login
        if ($auth->check_valid_user($_SERVER["PHP_AUTH_USER"])) {
            $user_dn = $auth->user_to_dn($_SERVER["PHP_AUTH_USER"]);
            $password = $_SERVER["PHP_AUTH_PW"];
        } else {
            wail_and_bail();
        }
    }
    if (!ldap_bind($ldapconn, $user_dn, $_SERVER['PHP_AUTH_PW'])) {
        wail_and_bail();
        die(ldap_error($ldapconn));
    }
    return $ldapconn;
}
コード例 #7
0
ファイル: app.php プロジェクト: Kocal/LoLAPI
 /**
  * Initialise l'application
  */
 public static function init()
 {
     clear();
     while (self::$continue === true) {
         $input = null;
         self::showHelp();
         // L'utilisateur doit rentrer un numéro de commande
         while ($input === null || $input < 0 || $input >= count(self::$choices)) {
             $input = ask('Numéro de commande : ');
         }
         $command = self::$choices[$input];
         // Le numéro est valide, on execute la commande
         clear();
         echo 'Vous avez choisi la commande : "' . $command['text'] . '"' . PHP_EOL;
         self::exec($command);
         // Est-ce que l'utilisateur veut continuer ?
         $input = ask('Voulez-vous continuer ? (O/n) ');
         if ($input === 'n') {
             self::$continue = false;
         }
         clear();
     }
 }
コード例 #8
0
ファイル: dice_coin.php プロジェクト: rogervaas/tropo-samples
function the_ask()
{
    ask("Welcome to the chance facilitator.  Select 1 for six sided dice, 2 for twenty sided dice, 3 for a coin flip, 4 for rock paper scissors.", array("choices" => "1(one, 1), 2(two, 2), 3(three, 3), 4(four, 4)", "timeout" => 60.0, "attempts" => 3, "onChoice" => "choiceFCN", "onBadChoice" => "badChoiceFCN"));
}
コード例 #9
0
<?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "CLI.php";
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "base.php";
$base_vers = false;
if (simple_prompt("Is this a minor version bump (e.g. 4.0.5.X -> 4.0.6.0)?")) {
    $bump_type = 2;
    $base_vers = ask("What is the target minor version (e.g. 4.0.6)?");
} else {
    if (simple_prompt("Is this a major version bump (4.0.X -> 4.1.0)?")) {
        $bump_type = 1;
        $base_vers = ask("What is the target major version (e.g. 4.1)?");
    } else {
        if (simple_prompt("Is this a fanastic version bump (4.X -> 5.0)?")) {
            $bump_type = 0;
            $base_vers = ask("What is the target fantastic version (e.g. 5)?");
        } else {
            die("I don't know what you want to do\n");
        }
    }
}
$base_vers = trim($base_vers);
$base_vers_comps = explode('.', $base_vers);
if (count($base_vers_comps) != $bump_type + 1) {
    die("Invalid target version ({$base_vers})\n");
}
$check_vers_comps = $base_vers_comps;
$check_vers_comps[$bump_type]--;
$check_vers = implode('.', $check_vers_comps);
$check_short_vers = implode('.', array_slice($base_vers_comps, 0, $bump_type));
$new_vers_comps = $base_vers_comps;
コード例 #10
0
<?php

// -----------
// using speech input instead of touch-tone
// -----------
answer();
$result = ask("For sales, just say sales.  For support, say support.", array("choices" => "sales, support", "repeat" => 3));
if ($result->name == 'choice') {
    if ($result->value == "sales") {
        say("sales is not available right now.");
    }
    if ($result->value == "support") {
        say("support is currently on the other line.");
    }
}
hangup();
コード例 #11
0
ファイル: ggtracker.php プロジェクト: Ben749/racetrack
function kwd($ref)
{
    GT('k2');
    if (Preg_match("~utmctr=([^;|]+)~", $_COOKIE['__utmz'], $t)) {
        return tridecoder($t[1]);
    }
    #adwords failsafe on cookie
    #if($_ENV['yt']['mots']&&$_ENV['yt']['lw']&&$_ENV['yt']['lw']<(now-120)){$x=FGC(ipf,'mots');if(j9==1)Db("ipfmot:$x");Return $x;}
    if (preg_match("~&[q|p]=([^&]+)~i", $ref, $t)) {
        $mots = ask($t);
    } elseif (Preg_match("~cgi-bin.*x_query=([^&]+)~i", $ref, $t)) {
        $mots = $t[1];
    } elseif (Preg_match("~FORID%3A([^&]+)~i", $ref, $t)) {
        $mots = $t[1];
    } elseif (Preg_match("~fr/go.*/([^/]+)~i", $ref, $t)) {
        $mots = $t[1];
    } elseif (Preg_match("~fr/q/(.*).html~i", $ref, $t)) {
        $mots = $t[1];
    } elseif (Preg_match("~&text=([^&]+)~i", $ref, $t)) {
        $mots = $t[1];
    } elseif (Preg_match("~xeoo.*&k=([^&]+)~i", $ref, $t)) {
        $mots = $t[1];
    } elseif (Preg_match("~&(q|p|cx)=([^&]+)~i", $ref, $t)) {
        $mots = ask($t);
    } else {
        $ref = preg_replace('~&(searchfor|eingabe|l|key|text|itag|OVRAW|wd|recherche|rds|rch|data|uery|for|str|ing|qs|qt|req|k|q|p)=~is', 'MX=', $ref);
        preg_match_all("~MX=([^&]+)~is", $ref, $t);
        if ($t[1]) {
            $mots = str_replace('MX=', '', $t[0][0]);
        }
    }
    if (strlen($mots) > 3) {
        GT('k3');
        $mots = trim(Preg_replace("~[ ]{2,}~", ' ', str_replace(array('/', 'search&q=', 'http:', 'http', "\\\\'", "\\'", "\\'", '\\', "'", '"', '+', '-', '-', '&', '|', '{', '}', '(', ')', ',', '...', 'ggmain.jhtml ', 'searchfor=', ''), ' ', $mots)));
        $mots = Preg_replace("~'|\"|\\[|\\]~", '', $mots);
        if (is_numeric($mots)) {
            return '';
        }
        return strtolower(cleankeyword(Tridecoder($mots)));
        #"@'|\"|[\\]@"
    }
}
コード例 #12
0
ファイル: build.php プロジェクト: coldtrick/releases
}
// update manifest
file_put_contents($manifest_file, implode('', $manifest_contents));
// update CHANGES.txt
$date = date('Y-m-d');
$header = [];
$header[] = array_shift($changes_content);
//remove line 1
$header[] = array_shift($changes_content);
//remove line 2
$header[] = PHP_EOL;
$header[] = "{$new_version} ({$date}):" . PHP_EOL . PHP_EOL;
$new_array = array_merge($header, $release_notes, $changes_content);
file_put_contents($changes_file, implode('', $new_array));
lpr('Release notes and the manifest have been updated. You can manually check the output if needed.');
ask('Press ENTER to continue.');
// do all validation and ask for a confirm
lpr('Starting Release');
// commit new version
$commit_message = "chore: wrapping up v{$new_version}";
shell_exec("git commit -m \"{$commit_message}\" manifest.xml CHANGES.txt");
// create new tag for version
shell_exec("git tag -m \"Version {$new_version}\" v{$new_version}");
// push to github.com
shell_exec("git push origin HEAD --tags");
// update release text on github.com release
lpr('Creating release on GitHub');
// give github some time to have the new tag available
sleep(20);
$url = "https://api.github.com/repos/{$reponame}/releases";
$vars = ["tag_name" => "v{$new_version}", "name" => "v{$new_version}", "body" => implode('', $release_notes), "draft" => false, "prerelease" => false];
コード例 #13
0
<?php

// -----------
// handling wrong things the right way - introducing event handlers
// -----------
answer();
$result = ask("For sales, just say sales or press 1. For support, say support or press 2.", array("choices" => "sales( 1, sales), support( 2, support)", "repeat" => 3, "onBadChoice" => create_function('$event', 'say( "I am sorry I did not understand what you said." );')));
if ($result->name == "choice") {
    if ($result->value == "sales") {
        say("Ok, let me transfer you to sales.");
        transfer("tel:+14129272358");
    }
    if ($result->value == "support") {
        say("Sure, let me get support.  Please hold.");
        transfer("tel:+14129272341");
    }
}
コード例 #14
0
/*
 * A simple PHP script to allow speech recongition of color selections.
 * Publishes selections on a Tropo channel through a persistent socket connection.
 * 
 */
// Redis settings
define("REDIS_HOST", "bass.redistogo.com");
define("REDIS_PORT", 9219);
define("REDIS_PASS", "1604d5037f6fd79b71f158019a1eff04");
$redis = new Redis(REDIS_HOST, REDIS_PORT);
$redis->connect();
$redis->auth(REDIS_PASS);
say("Welcome to the Redis and socket I O test.");
do {
    $result = ask("Say the color you want to see. When done, say stop.", array("choices" => "white, blue, green, yellow, stop"));
    _log("*** User selected: " . $result->value . " ***");
    $response = $redis->publish("tropo.color", $result->value);
} while ($result->value != 'stop');
$redis->disconnect();
say("Goodbye.");
hangup();
class Redis
{
    // Private class members.
    private $server;
    private $port;
    private $sock;
    private $auth;
    function __construct($host = 'localhost', $port = 6379)
    {
コード例 #15
0
ファイル: release.php プロジェクト: apelon-ohie/ihris-site
            exec($cmd);
        }
    }
}
foreach ($top_mod_dirs as $mod => $dir) {
    if (is_dir("{$tmp_dir}/{$mod}")) {
        continue;
    }
    $cmd = "bzr branch {$dir} {$tmp_dir}/{$mod}";
    exec($cmd);
}
$create_release_minor_branch = null;
$push_release_branch = null;
if (simple_prompt("Create Release Branches?")) {
    if (!$launchpad_login) {
        $launchpad_login = trim(ask("What is the launchpad name/team to put packages under?"));
    }
    foreach ($top_mod_dirs as $mod => $dir) {
        if ($do_versioning) {
            $release = $last_release[$mod]['next_release'];
        } else {
            $release = $last_release[$mod]['release'];
        }
        $lp_release = "lp:~{$launchpad_login}/" . strtolower($mod) . "/{$release}-release";
        if (prompt("Create {$lp_release}?", $create_release_minor)) {
            $cmd = "cd {$tmp_dir}/{$mod} && bzr push {$lp_release}";
            exec($cmd);
        }
        $sub_major = implode(".", array_slice(explode(".", $next_release), 0, 2));
        $lp_release = "lp:~{$launchpad_login}/" . strtolower($mod) . "/{$sub_major}" . '-release';
        if (prompt("Push to {$lp_release}?", $push_release_branch)) {
コード例 #16
0
// turn the contacts into a comma seperated list of options for each contact (simple grammar)
function listOptions($theContacts)
{
    $s = '';
    foreach ($theContacts as $index => $contact) {
        if ($s != '') {
            $s .= ", ";
        }
        $s .= $index . " (" . $contact['nameChoices'] . ")";
    }
    return $s;
}
// -----------
// start
// -----------
// define the list of contacts
$contacts = array("nicole" => array("nameChoices" => "Nicole, Nicole Williams", "number" => "12067927251"), "april" => array("nameChoices" => "April, April Smith", "number" => "14129272367"), "gina" => array("nameChoices" => "Gina, Gina Anderson", "number" => "17135744782"));
// answer the phone and play the initial greeting
answer(30);
say("hello, and thank you for calling.");
// prompt the user for the name of the person they desire
$event = ask("Who would you like to call?  Just say " . listNames($contacts), array("repeat" => "3", "timeout" => "7", "choices" => listOptions($contacts), "onTimeout" => create_function('$event', 'say( "I\'m sorry, I didn\'t hear anything." );'), "onBadChoice" => create_function('$event', 'say( "I\'m sorry, I didn\'t understand what you said." );')));
// if they made a choice, transfer to that person
if ($event->name == 'choice') {
    say("ok, you said " . $event->value . ".  Please hold while I transfer you.");
    $ne = transfer("tel:+" . $contacts[$event->value]['number'], array("answerOnMedia" => false, "callerID" => "14074181800", "timeout" => 60.3456, "playrepeat" => 3, "playvalue" => "Ring... Ring... Ring...", "choices" => "1,2,3,4,5,6,7,8,9,0,*,#", "onSuccess" => create_function('$event', '_log("*********transfered to:  " . $event->value->calledId);'), "onError" => create_function('$event', '_log("*********transfer error");'), "onTimeout" => create_function('$event', '_log("*********transfer timeout");'), "onCallFailure" => create_function('$event', '_log("*********transfer failed");'), "onChoice" => create_function('$event', '_log("*********transfer canceled");')));
    _log("transfer event.name  = " . $ne->name);
    _log("transfer event.value = " . $ne->value);
    say("Goodbye");
}
hangup();
コード例 #17
0
<?php

// -----------
// asking for input
// -----------
answer();
$result = ask("Hi. For sales, press 1. For support, press 2.", array("choices" => "1, 2"));
if ($result->name == "choice") {
    if ($result->value == "1") {
        say("sales is not available right now.");
    }
    if ($result->value == "2") {
        say("support is currently on the other line.");
    }
}
hangup();
コード例 #18
0
<?php

// -----------
// handling the wrong choice
// -----------
answer();
$result = ask("For sales, just say sales or press 1. For support, say support or press 2.", array("choices" => "sales( 1, sales), support( 2, support)"));
if ($result->name == "choice") {
    if ($result->value == "sales") {
        say("Ok, let me transfer you to sales.");
        transfer("tel:+14129272358");
    }
    if ($result->value == "support") {
        say("Sure, let me get support.  Please hold.");
        transfer("tel:+14129272341");
    }
}
if ($result->name == "badChoice") {
    say("I'm not sure what you wanted.  Goodbye.");
    hangup();
}
コード例 #19
0
ファイル: simon.php プロジェクト: johntdyer/tropo-samples
$simon = array();
$win = true;
$inchar = "";
// keep going up to a pattern of 20 digits
while ($win == true && count($simon) <= 20) {
    // add another character to the pattern and read the pattern to the caller
    $simon[] = rand(0, 9);
    say("Simon says");
    foreach ($simon as $s) {
        say($s);
    }
    // now get the user input
    say("you say");
    $i = 0;
    while ($i < count($simon)) {
        $event = ask("", array("choices" => "1,2,3,4,5,6,7,8,9,0"));
        if ($event->name == 'choice') {
            $inchar = $event->value;
        }
        // read back each character of user input
        say($inchar);
        // if the user entered the incorrect character then we're done.
        if ($inchar != $simon[$i]) {
            $win = null;
            say("Sorry, that's not right.  goodbye.");
            hangup();
            break;
        }
        $i++;
    }
    // while
コード例 #20
0
<?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "CLI.php";
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "base.php";
$base_vers = false;
$bump_type = 1;
$base_vers = ask("What is the target major version (e.g. 4.2)?");
$base_vers = trim($base_vers);
$base_vers_comps = explode('.', $base_vers);
if (count($base_vers_comps) != $bump_type + 1) {
    die("Invalid target version ({$base_vers})\n");
}
$check_vers_comps = $base_vers_comps;
$check_vers_comps[$bump_type]--;
$check_vers = implode('.', $check_vers_comps);
$check_short_vers = implode('.', array_slice($base_vers_comps, 0, $bump_type));
$next_vers_comps = $base_vers_comps;
$next_vers_comps[1]++;
$next_vers = implode('.', $next_vers_comps);
$new_vers_comps = $base_vers_comps;
$new_vers_comps[] = '0';
$new_vers = implode('.', $new_vers_comps);
$found_modules = array_keys(getAvailableModules());
$always_update = array();
foreach ($found_modules as $module) {
    $mod_file = false;
    $storage->setIfIsSet($mod_file, "/config/data/{$module}/file");
    if (!$mod_file) {
        I2CE::raiseError("No file recored for {$module}");
        continue;
    }
コード例 #21
0
    if ($matches) {
        $db_janitor_user = $matches[1];
    }
    //	preg_match("/\"password\" \=\> \"([a-zA-Z0-9\.\-]+)\"/", $connection_info, $matches);
    preg_match("/\"password\" \\=\\> \"([^\"]+)\"/", $connection_info, $matches);
    if ($matches) {
        $db_janitor_pass = $matches[1];
    }
}
if (!$db_janitor_db || !$db_janitor_user || !$db_janitor_pass) {
    print "This script is supposed to be run in project root. It could not find grant information in src/config/connect_db.php";
    exit;
}
$host = "localhost";
$user = "******";
$pass = ask("Database root password", false, true);
// connect to DB
$mysqli = new mysqli("p:" . $host, $user, $pass);
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: " . $mysqli->connect_error;
}
$mysqli->set_charset("utf8");
// get all databases
$select_query = "GRANT ALL PRIVILEGES ON " . $db_janitor_db . ".* TO '" . $db_janitor_user . "'@'localhost' IDENTIFIED BY '" . $db_janitor_pass . "' WITH GRANT OPTION;";
$result = $mysqli->query($select_query);
$result_count = is_object($result) ? $result->num_rows : ($result ? $result : 0);
// print $select_query."<br>";
// print "Count: " . $result_count."<br>";
if ($result_count) {
    print "\nGrant added!\n\n";
} else {
コード例 #22
0
function promptPin()
{
    global $pinLength;
    // prompt the user for their pin number, followed by the pound key
    $result_pin = ask("Please enter your pin number, then press pound to continue.", array("choices" => "[" . $pinLength . " DIGITS]", "terminator" => "#", "timeout" => 15.0));
    // verify it
    verifyPin($result_pin->value);
}
コード例 #23
0
copyFile("_conf/httpd.conf", "/opt/local/apache2/conf/httpd.conf", "sudo");
copyFile("_conf/httpd-vhosts.conf", "/opt/local/apache2/conf/extra/httpd-vhosts.conf", "sudo");
// copy apache log rotation conf
copyFile("_conf/newsyslog-apache.conf", "/etc/newsyslog.d/apache.conf", "sudo");
// copy php.ini
copyFile("_conf/php.ini", "/opt/local/etc/php55/php.ini", "sudo");
// create accessible base conf
copyFile("_conf/apache.conf", "/srv/sites/apache/apache.conf");
// copy php.ini.default for native configuration
copyFile("_conf/php_ini_native.ini", "/etc/php.ini", "sudo");
// copy wkhtmltox static executables
copyFile("_conf/static_wkhtmltoimage", "/usr/local/bin/static_wkhtmltoimage", "sudo");
copyFile("_conf/static_wkhtmltopdf", "/usr/local/bin/static_wkhtmltopdf", "sudo");
output("\nConfiguration copied");
// Add alias' to .bash_profile
checkFileContent("~/.bash_profile", "_conf/bash_profile.default");
// Add local domains to /etc/hosts
command("sudo chmod 777 /etc/hosts");
checkFileContent("/etc/hosts", "_conf/hosts.default");
command("sudo chmod 644 /etc/hosts");
// Set root password
command("sudo /opt/local/share/mysql56/support-files/mysql.server start");
$answer = ask("MySQL root password");
command("sudo /opt/local/lib/mysql56/bin/mysqladmin -u root password '" . $answer . "'");
// restart apache
command("sudo /opt/local/apache2/bin/apachectl restart");
// DONE
output("\n\nSetup is completed - please restart your terminal");
// TODO: Cannot set root password until computer has been restarted - Maybe there is another way to make it possible?
// output("\n\nSetup is almost completed - please restart your computer now and run the below command manually in terminal: ");
// output("\n\nsudo /opt/local/lib/mysql56/bin/mysqladmin -u root password '#DB ROOT PASSWORD#'\n\n");
コード例 #24
0
ファイル: debian.php プロジェクト: apelon-ohie/ihris-site
        die;
    }
    if (count($gpg_keys) > 1) {
        $keyid = '-k' . chooseMenuValue("Choose a GPG Key", $gpg_keys);
    } else {
        $keyid = false;
    }
}
if ($rc) {
    $tmp_dir_base = "/home/" . trim($whoami) . "/ihris-{$rc}-ppa/{$launchpad_login}/{$ppa}";
} else {
    $tmp_dir_base = "/home/" . trim($whoami) . "/ihris-ppa/{$launchpad_login}/{$ppa}";
}
if ($booleans['prompt'] && !simple_prompt("use {$tmp_dir_base} to store release branches and debian packaging?")) {
    while (true) {
        $tmp_dir_base = ask("What directory should I use");
        if (is_dir($tmp_dir_base)) {
            break;
        } else {
            if (simple_prompt("Create {$tmp_dir_base}?")) {
                exec("mkdir -p {$tmp_dir_base}");
                break;
            }
        }
    }
}
$deb_src_dir = $tmp_dir_base . '/debs';
if (!is_dir($deb_src_dir)) {
    if (!$booleans['prompt'] || simple_prompt("Create {$deb_src_dir}?")) {
        exec("mkdir -p {$deb_src_dir}");
    } else {
コード例 #25
0
<?php

answer();
// Have to ask an initial question and wait for a response
// Otherwise it will run through to the hangup();
ask("Hello there! What would you like to know about? Say cats, dogs, or fish.", array("choices" => "cats(cat, cats, feline), dogs(dog, dogs, big dogs), fish(fish)", "repeat" => 3, "timeout" => 30, "onEvent" => create_function('$event', 'if ($event->name == "badChoice") say( "I\'m sorry, I didn\'t quite understand. Say cats, dogs, or fish."); 
                  if ($event->name == "timeout") say( "Are you sure that you don\'t want to know about cats, dogs OR fish?!"); 
                  if ($event->name == "choice") 
                  { 
                      if ($event->value == "cats") 
                      { 
                        say( "Cats like to eat, sleep, lather, rinse, repeat." ); 
                      } 
                      if ($event->value == "dogs") 
                      { 
                        say( "Dogs like tearing up your most prized possessions." ); 
                      } 
                      if ($event->value == "fish") 
                      { 
                        say( "Fish like to swim in circles - it keeps the water circulating." ); 
                      } 

                      // make their choice available outside of the array 
                      define(choice, $event->value); 

                  }')));
wait(3000);
say("You probably already knew that about " . choice . " though, right?");
wait(8000);
say("Sure buddy, sure. Adios.");
hangup();
コード例 #26
0
 $pot_file = $template_dir . $lp_module . '.pot';
 if (!is_readable($pot_file)) {
     I2CE::raiseError($pot_file . " is not readable for {$module}");
     continue;
 }
 $old_translations = loadPOT($pot_file);
 $sources = array_keys($old_translations);
 foreach ($sources as $i => $source) {
     if (strlen(trim($source)) == 0) {
         unset($sources[$i]);
         continue;
     }
 }
 $old_src = chooseMenuValue("Which string would you like to change?", $sources);
 do {
     $new_src = trim(ask("What is the new source?"));
 } while (!simple_prompt("Replace:\n\t{$old_src}\nto:\n\t{$new_src}"));
 if (simple_prompt("Would you like to preserve the existing translations in the .po files for the locales " . implode(",", array_keys($avail_locales)) . "?")) {
     foreach ($avail_locales as $avail_locale => $avail_locale_file) {
         I2CE::raiseError("Updateing {$lp_module}'s {$avail_locale}.po");
         $loc_translations = loadPot($avail_locale_file);
         $top_module = $found_modules[$module];
         $new_loc_translations = array();
         foreach ($loc_translations as $key => $vals) {
             if ($key == $old_src) {
                 $key = $new_src;
             }
             $new_loc_translations[$key] = $vals;
         }
         writeOutPOT($avail_locale_file, $top_module, $module, $module_vers, $new_loc_translations);
     }
コード例 #27
0
 */
require '../vendor/autoload.php';
use waylaidwanderer\SteamCommunity\Enum\LoginResult;
use waylaidwanderer\SteamCommunity\SteamCommunity;
date_default_timezone_set('America/Los_Angeles');
$settings = json_decode(file_get_contents('settings.json'));
$steam = new SteamCommunity($settings->username, $settings->password, dirname(__FILE__) . $settings->cookieFilesDir);
$loginResult = $steam->doLogin();
while ($loginResult != LoginResult::LoginOkay) {
    if ($loginResult == LoginResult::Need2FA) {
        $authCode = ask('Enter 2FA code: ');
        $steam->setTwoFactorCode($authCode);
        $loginResult = $steam->doLogin();
    } else {
        if ($loginResult == LoginResult::NeedEmail) {
            $authCode = ask('Enter Steam Guard code from email: ');
            $steam->setEmailCode($authCode);
            $loginResult = $steam->doLogin();
        } else {
            break;
        }
    }
}
if ($loginResult == LoginResult::LoginOkay) {
    writeLine('Logged in successfully.');
    $tradeOffers = $steam->getTradeOffers();
    /*
    $trade = $tradeOffers->createTrade(12345);
    $trade->addOtherItem(730, 2, "12345678");
    var_dump($trade->send());
    */
コード例 #28
0
ファイル: convert_pds.php プロジェクト: ahastudio/moniwiki
    if (is_dir($argv[4])) {
        echo 'Dest dir already exists!', "\n";
        exit;
    }
    $dest_dir = $argv[4];
} else {
    $dest_dir = $src_dir . '.new';
}
//
set_time_limit(0);
if (!file_exists($dest_dir)) {
    _mkdir_p($dest_dir);
}
echo "\t* src dir  = ", $src_dir, "\n";
echo "\t* dest dir = ", $dest_dir, "\n";
$ans = ask('Are you sure ? [y/N]', 'n');
if ($ans == 'n') {
    exit;
}
require_once $topdir . "/lib/pagekey.{$fromenc}.php";
require_once $topdir . "/lib/pagekey.{$toenc}.php";
$from_class = 'PageKey_' . $fromenc;
$to_class = 'PageKey_' . $toenc;
$from = new $from_class($DBInfo);
$to = new $to_class($DBInfo);
function get_sub_dir($dir)
{
    $dh = opendir($dir);
    if (!is_resource($dh)) {
        return array();
    }
コード例 #29
0
// See http://bit.ly/confTutorial for a tutorial with this code.
// An array of conference IDs and phone numbers to alert.
// If a conference ID is used that has a phone number attached,
// when someone joins or leaves that conference, the attached phone
// number will get an SMS alerting them.
$pins = array();
$pins['1337'] = '14075551212';
$pins['2600'] = '19255556789';
$pins['1234'] = '';
// won't alert
// If set to true, only known Conference IDs will be accepted
$require_pin = false;
$voice = 'kate';
while ($currentCall->isActive) {
    $response = ask('Enter your conference ID, followed by the pound key.', array('terminator' => '#', 'choices' => '[1-10 DIGITS]', 'timeout' => '3', 'mode' => 'keypad', 'voice' => $voice));
    switch ($response->name) {
        case 'choice':
            if ($require_pin && !array_key_exists($response->value, $pins)) {
                // This conference only allows specific conference IDs, and the one
                // entered isn't on the list.
                say('Sorry, that is not a valid conference ID.', array('voice' => $voice));
                break;
            }
            if (array_key_exists($response->value, $pins) && !empty($pins[$response->value])) {
                // Send an alert that someone has entered the conference
                message($currentCall->callerID . ' has entered conference ' . $response->value, array('to' => $pins[$response->value], 'network' => 'SMS'));
            }
            say('<speak>Conference ID <say-as interpret-as="vxml:digits">' . $response->value . '</say-as> accepted.</speak>', array('voice' => $voice));
            say('You will now be placed into the conference. Please announce yourself. To exit the conference without disconnecting, press pound.', array('voice' => $voice));
            conference($response->value, array('terminator' => '#'));
コード例 #30
0
// using HTTP Auth on your URL?
$password = '';
// using HTTP Auth on your URL?
// Defaults
$network = isset($network) ? $network : 'SMS';
if ($action == 'create') {
    // this is an outgoing message
    $opts = array('to' => $to, 'network' => $network);
    if (!empty($from)) {
        $opts['callerID'] = $from;
    }
    message($msg, $opts);
} else {
    // this is an incoming message, capture output.
    answer();
    $response = ask('', array('choices' => '[ANY]'));
    hangup();
    // Set up the post to your web server
    $data['msg'] = $response->value;
    $data['to'] = $currentCall->calledID;
    $data['from'] = $currentCall->callerID;
    $param['data'] = $data;
    if (!empty($username)) {
        $param['username'] = $username;
    }
    if (!empty($password)) {
        $param['password'] = $password;
    }
    $result = post($url, $param);
    _log($result);
}