コード例 #1
0
function main()
{
    global $argv;
    if (count($argv) != 3) {
        die("{$argv['0']}: usage {$argv['0']} [user] [pass]\n");
    }
    $opts = array();
    $opts['username'] = $argv[1];
    $opts['password'] = $argv[2];
    // $opts['debug'] = 1; uncomment if having trouble
    $s = new Snaphax($opts);
    $result = $s->login();
    var_dump($result);
    if (empty($result) || empty($result['snaps'])) {
        echo "no snaps";
        exit;
    }
    foreach ($result['snaps'] as $snap) {
        if ($snap['st'] == SnapHax::STATUS_NEW) {
            echo "fetching {$snap['id']}\n";
            $blob_data = $s->fetch($snap['id']);
            if ($blob_data) {
                if ($snap['m'] == SnapHax::MEDIA_IMAGE) {
                    $ext = '.jpg';
                } else {
                    $ext = '.mp4';
                }
                file_put_contents($snap['sn'] . $snap['id'] . $ext, $blob_data);
            }
        }
    }
}
コード例 #2
0
ファイル: req_token.php プロジェクト: 382309009/snaphax
function main()
{
    global $argv;
    if (count($argv) != 5) {
        die("{$argv['0']}: usage {$argv['0']} [user] [pass] [param1] [param2]\n");
    }
    $opts = array();
    $opts['username'] = $argv[1];
    $opts['password'] = $argv[2];
    $opts['debug'] = 1;
    $s = new Snaphax($opts);
    $req_token = $s->reqToken($argv[3], $argv[4]);
    echo "req_token for {$argv['3']} {$argv['4']}:\n";
    var_dump($req_token);
    $req_token = $s->reqToken($argv[4], $argv[3]);
    echo "req_token for {$argv['4']} {$argv['3']}:\n";
    var_dump($req_token);
}
コード例 #3
0
ファイル: upload.php プロジェクト: 382309009/snaphax
function main()
{
    global $argv;
    if (count($argv) != 5) {
        die("{$argv['0']}: usage {$argv['0']} [user] [pass] [fname] [recipients]\n");
    }
    $fdata = file_get_contents($argv[3]);
    if (!$fdata) {
        die("could not read {$argv['3']}");
    }
    $opts = array();
    $opts['username'] = $argv[1];
    $opts['password'] = $argv[2];
    $opts['debug'] = 1;
    $s = new Snaphax($opts);
    $result = $s->login();
    var_dump($result);
    $result = $s->upload($fdata, SnapHax::MEDIA_IMAGE, array($argv[4]));
    var_dump($result);
}
コード例 #4
0
<?php

require_once './snaphax.php';
$key = 'somekey';
if (!isset($_GET['d'])) {
    die('no data');
}
$data = unserialize(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($_GET['d']), MCRYPT_MODE_ECB));
$opts = array();
$opts['username'] = $data['u'];
$s = new Snaphax($opts);
$s->auth_token = $data['at'];
header("Content-Type: image/png");
$blob_data = $s->fetch($data['id']);
echo $blob_data;
コード例 #5
0
    $useCookieInfo = isset($userInfo['u']) && isset($userInfo['p']);
    setcookie('nl', '', time() - 3600);
}
$logged = false;
$loginAttempted = false;
if (isset($_POST['username']) && isset($_POST['password']) || $useCookieInfo) {
    $loginAttempted = true;
    $opts = array();
    if ($useCookieInfo) {
        $opts['username'] = $userInfo['u'];
        $opts['password'] = $userInfo['p'];
    } else {
        $opts['username'] = $_POST['username'];
        $opts['password'] = $_POST['password'];
    }
    $s = new Snaphax($opts);
    $result = $s->login();
    if (!empty($result)) {
        $logged = $result['logged'];
    }
    if ($logged) {
        $data = array();
        $data['u'] = $result['username'];
        $data['p'] = $opts['password'];
        setcookie('nl', base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, serialize($data), MCRYPT_MODE_ECB)), time() + 604800);
    }
}
?>

<!doctype html>
<html>