$source = 'Ads PHP Client Library Examples';
    try {
        print 'Requesting AuthTokens ';
        while (TRUE) {
            // Repeatedly request new authTokens, to trigger a CAPTCHA challenge.
            $authToken = new AuthToken($email, $password, $service, $source);
            $value = $authToken->GetAuthToken();
            print '.';
        }
    } catch (AuthTokenException $e) {
        print "\n";
        if ($e->GetError() == 'CaptchaRequired') {
            print "A CAPTCHA is required.\n";
            printf("View CAPTCHA challenge image: %s/accounts/%s\n", $authToken->GetServer(), $e->GetCaptchaUrl());
            $captchaToken = $e->GetCaptchaToken();
            $captchaResponse = readInput('Enter CAPTCHA response: ');
            // Request new AuthToken using CAPTCHA token and response.
            try {
                $authToken = new AuthToken($email, $password, $service, $source, NULL, NULL, $captchaToken, $captchaResponse);
                $value = $authToken->GetAuthToken();
                print "CAPTCHA challenge passed.\n";
            } catch (AuthTokenException $e) {
                print "CAPTCHA challenge failed.\n";
            }
        } else {
            printf("AuthTokenException: %s\n", $e->GetError());
        }
    }
} catch (Exception $e) {
    print $e->getMessage();
}
Exemplo n.º 2
0
 /**
  * Sets-up the field values of the super globals used by AdminController
  * when changing a profile or managing passwords. These particular
  * values don't change with respect to what this tool does.
  *
  * @param array $data current profile state
  */
 function prepareGlobals($data)
 {
     $_SESSION = array();
     $_REQUEST = $this->copyProfileFields($data);
     $_REQUEST["arg"] = "profile";
     $_REQUEST['YIOOP_TOKEN'] = "";
     if (!isset($_SERVER['REQUEST_URI'])) {
         if (isset($data['WEB_URI']) && $data['WEB_URI'] != "") {
             $_SERVER['REQUEST_URI'] = $data['WEB_URI'];
         } else {
             e("Enter web path for Yioop instance:\n");
             $_SERVER['REQUEST_URI'] = readInput();
         }
     }
 }
Exemplo n.º 3
0
/**
 * Callback function applied to each file in the directory being traversed
 * by @see replace(). Searches $filename matching $pattern. Depending
 *     on $mode ($arg[2] as described in replace()), it outputs and
 *     replaces with $replace
 *
 * @param string $filename name of file to search and replace in
 * @param mixed $set_pattern if not false, then sets $set_pattern in $pattern to
 *     initialize the callback on subsequent calls. $pattern here is the
 *     search pattern
 * @param mixed $set_replace if not false, then sets $set_replace in $replace to
 *     initialize the callback on subsequent calls.
 * @param mixed $set_mode if not false, then sets $set_mode in $mode to
 *     initialize the callback on subsequent calls.
 */
function replaceFile($filename, $set_pattern = false, $set_replace = false, $set_mode = false)
{
    global $change_extensions;
    static $pattern = "/";
    static $replace = "";
    static $mode = "effect";
    $pattern = $set_pattern ? $set_pattern : $pattern;
    $replace = $set_replace ? $set_replace : $replace;
    $mode = $set_mode ? $set_mode : $mode;
    $path_parts = pathinfo($filename);
    if (!isset($path_parts['extension'])) {
        return;
    }
    $extension = $path_parts['extension'];
    if (!excludedPath($filename) && in_array($extension, $change_extensions)) {
        $lines = file($filename);
        $out_lines = "";
        $no_output = true;
        $silent = false;
        if ($mode == "change") {
            $silent = true;
        }
        $num = 0;
        $change = false;
        foreach ($lines as $line) {
            $num++;
            $new_line = $line;
            if (preg_match($pattern, $line)) {
                if ($no_output && !$silent) {
                    $no_output = false;
                    echo "\nIn {$filename}:\n";
                }
                $new_line = preg_replace($pattern, $replace, $line);
                if (!$silent) {
                    echo "  Line {$num}: {$line}";
                    echo "  Changes to: {$new_line}";
                }
                if ($mode == "interactive") {
                    echo "Do replacement? (Yy - yes, anything else no): ";
                    $confirm = strtolower(readInput());
                    if ($confirm != "y") {
                        $new_line = $line;
                    }
                }
                if (strcmp($new_line, $line) != 0) {
                    $change = true;
                }
            }
            $out_lines .= $new_line;
        }
        if (in_array($mode, array("change", "interactive"))) {
            if ($change) {
                file_put_contents($filename, $out_lines);
            }
        }
    }
}
Exemplo n.º 4
0
            end1($splitLine);
        }
    }
}
$rootMade = 0;
//flag for if root account was created
$loggedon = 0;
//0=logged off, 1=root, 2=users
$user = "******";
//user name
$numUsers = 0;
//number of users
$numGroups = 0;
//number of groups
$numFiles = 0;
//Number of Files
$users[0] = "";
$files[0] = "";
//files array
$groups[0][0] = "";
//groups array
$inName = "commands";
$logMessage = "";
$inLines = count(file($inName));
$inVar = fopen($inName, 'r') or die("File DNE");
readInput();
$audit = fopen("audit.txt", 'w');
fwrite($audit, $logMessage);
fclose($audit);
fclose($inVar);
//end
Exemplo n.º 5
0
function selectScreen()
{
    println();
    Cli::output("1. Set up environment variables");
    Cli::output("2. Install certificate for Arcanist (requires 1.)");
    Cli::output("3. Install TortoiseSVN");
    Cli::output("4. Install TortoiseGit and Git for Windows");
    Cli::output("5. Install Notepad++ 6.3");
    Cli::output("6. Configure Arcanist to use Notepad++");
    Cli::output("0. Exit");
    println();
    Cli::notice("You can press Ctrl+C anytime to exit");
    println();
    Cli::output("How do you feel today?");
    $selection = readInput();
    switch ($selection) {
        case 0:
            exit(0);
            break;
        case 1:
            Cli::notice("If plenty of error messages pop up, don't worry. That's just me testing whether it works or not. The error messages penetrate my error blocking barreers...");
            Cli::output("Press a button to continue");
            println();
            Cli::notice("Admin rights may be necessary - Idk");
            dontMove();
            ob_start();
            $checkEnv = checkEnvVars();
            ob_end_clean();
            if ($checkEnv) {
                println();
                Cli::success("Environment already set up - can't be bothered to change");
            } else {
                addToPathEnv("PHP");
                addToPathEnv("arc\\arcanist\\bin");
                Cli::notice("Please restart the install script (that is, close this window completely) and re-run this step to see if it worked.");
                Cli::output("You know that it failed when the same errors happen.");
            }
            break;
        case 2:
            installCertificate();
            break;
        case 3:
            Cli::notice("Please remember to install with the command line tools feature");
            println();
            Cli::notice("Installing TortoiseSVN");
            exec("start " . ROOT . "Installers\\TortoiseSVN\\TortoiseSVN-1.7.11.23600-" . (OS_ARCH == 32 ? "win32" : "x64") . "-svn-1.7.8.msi");
            break;
        case 4:
            Cli::notice("Installing TortoiseGit");
            exec("start " . ROOT . "Installers\\TortoiseGit\\TortoiseGit-1.8.1.0-" . OS_ARCH . "bit.msi");
            Cli::notice("Please wait until TortoiseGit has finished installing.");
            dontMove();
            Cli::notice("Installing Git for Windows");
            exec("start " . ROOT . "Installers\\GitForWindows\\Git-1.8.1.2-preview20130201.exe");
            break;
        case 5:
            Cli::notice("I recommend installing into the default directory.");
            println();
            Cli::notice("Installing Notepad++ 6.3");
            exec("start " . ROOT . "Installers\\Notepad++\npp.6.3.Installer.exe");
            break;
        case 6:
            installArcEditor();
            break;
        default:
            Cli::output("Invalid input!");
            break;
    }
    selectScreen();
}