// Construct an HTTP POST request
    $auth = array("accountType" => 'HOSTED_OR_GOOGLE', "Email" => '', "Passwd" => '', "service" => $type, "source" => 'Document Backup App');
    curl_setopt($curl, CURLOPT_URL, "https://www.google.com/accounts/ClientLogin");
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $auth);
    $response = curl_exec($curl);
    // Get the Auth string and save it
    if (preg_match("/Auth=([a-z0-9_\\-]+)/i", $response, $matches)) {
        return $matches[1];
    } else {
        exit("No token\n");
    }
}
$auth = get_auth_token($curl);
$headers_docs = array("Authorization: GoogleLogin auth=" . $auth, "GData-Version: 3.0");
$auth = get_auth_token($curl, "wise");
$headers_xls = array("Authorization: GoogleLogin auth=" . $auth, "GData-Version: 3.0");
curl_setopt($curl, CURLOPT_URL, "https://docs.google.com/feeds/default/private/full");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers_docs);
curl_setopt($curl, CURLOPT_POST, false);
$data = curl_exec($curl);
if (curl_getinfo($curl, CURLINFO_HTTP_CODE) == 200) {
    $response = simplexml_load_string($data);
} else {
    exit("ERROR: could not obtain document list\n");
}
$backup_date = date("Ymd");
$start_date = time() - 86400;
$first_run = file_exists(GDOCS_BACKUP_DIR . '.firstrun');
// Data itteration
foreach ($response->entry as $file) {
Exemple #2
0
</a></li>
							<?php 
        if (is_admin()) {
            ?>
							<li><a href="<?php 
            echo G\get_base_url("dashboard");
            ?>
"><?php 
            _se('Dashboard');
            ?>
</a></li>
							<?php 
        }
        ?>
                            <li><a href="<?php 
        echo G\get_base_url(sprintf("logout?auth_token=%s", get_auth_token()));
        ?>
"><?php 
        _se('Sign out');
        ?>
</a></li>
                        </ul>
                    </div>
                </div>
            </li>
			<?php 
    }
    ?>
			<?php 
    if (CHV\getSetting('website_mode') == 'public' or CHV\getSetting('website_mode') == 'private' and CHV\Login::getUser()) {
        ?>
$api_key = "<ACS API KEY HERE>";
function get_auth_token($apiKey, $username, $role)
{
    $content = "grant_type=client_credentials&scope=userid:" . $username . " role:" . $role;
    $request = curl_init("https://api.accusoft.com/v1/authTokens");
    curl_setopt($request, CURLOPT_POST, 1);
    curl_setopt($request, CURLOPT_POSTFIELDS, $content);
    curl_setopt($request, CURLOPT_HTTPHEADER, array('acs-api-key: ' . $apiKey, 'Content-Type: application/x-www-form-urlencoded'));
    curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($request);
    curl_close($request);
    $token = json_decode($response);
    return $token->access_token;
}
if (isset($_SESSION["access_token"]) == FALSE) {
    $auth_token = get_auth_token($api_key, $user_name, $role_name);
    $_SESSION["access_token"] = $auth_token;
} else {
    $auth_token = $_SESSION["access_token"];
}
?>
<!DOCTYPE html>
<html>
  <head>
    <title>Accusoft ACS File Manager</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
      html, body, .container{
        height: 100%;
        padding: 0;
        margin: 0;
Flight::route('/register/', function () use($link) {
    $secret_key = Flight::get('secret_key');
    if (isset($_GET['email']) and isset($_GET['password'])) {
        // prepare variables for request
        $password = get_crypt_password($_GET['password'], $secret_key);
        $email = $_GET['email'];
        $date = time();
        // save user's data
        $sql_user_data = "INSERT INTO USER (email, password, date) VALUES ('{$email}', '{$password}', CURRENT_TIMESTAMP)";
        $rq_user_data = mysqli_query($link, $sql_user_data);
        // If user's data successfully saved
        if ($rq_user_data == true) {
            // Get id of last insert
            $last_id = mysqli_insert_id($link);
            // Generate auth token for app
            $token = get_auth_token($date, $secret_key);
            // Save token to store with user id
            $sql_auth_token = "INSERT INTO SESSIONS (name, user_id) VALUES ('{$token}', '{$last_id}')";
            $rq_auth_token = mysqli_query($link, $sql_auth_token);
            //
            if ($rq_auth_token == true) {
                // Return token to app
                Flight::json(array("OK" => $token));
            }
        } else {
            // If email not unique
            Flight::json(array("error" => "Указанный email уже используется"));
        }
    } else {
        // if password or email not given
        Flight::json(array("error" => "Не указан один из обязательных параметров"));