Beispiel #1
0
function uploadPhoto($ip, $image, $nick, $email, $path, $albumName)
{
    $existsAlbum = isAlbum($nick, $albumName);
    if (!$existsAlbum) {
        if (!newAlbum($ip, $nick, $email, $albumName, "private", "DEFAULT")) {
            return '1';
        }
    }
    if (uploadImage($image, $path)) {
        $newPhoto = addPhoto($nick, $path, $albumName);
        if (!newPhoto and !$existsAlbum) {
            deleteAlbum($nick, $albumName);
            // Remove Photo
            return '2';
        }
        addAction($nick, $email, $ip, 'new_photo');
        return '0';
    }
    return '3';
}
Beispiel #2
0
/**
 * Processes loading of this sample code through a web browser.  Uses AuthSub
 * authentication and outputs a list of a user's albums if succesfully
 * authenticated.
 *
 * @return void
 */
function processPageLoad()
{
    global $_SESSION, $_GET;
    if (!isset($_SESSION['sessionToken']) && !isset($_GET['token'])) {
        requestUserLogin('Please login to your Google Account.');
    } else {
        $client = getAuthSubHttpClient();
        if (!empty($_REQUEST['command'])) {
            switch ($_REQUEST['command']) {
                case 'retrieveSelf':
                    outputUserFeed($client, "default");
                    break;
                case 'retrieveUser':
                    outputUserFeed($client, $_REQUEST['user']);
                    break;
                case 'retrieveAlbumFeed':
                    outputAlbumFeed($client, $_REQUEST['user'], $_REQUEST['album']);
                    break;
                case 'retrievePhotoFeed':
                    outputPhotoFeed($client, $_REQUEST['user'], $_REQUEST['album'], $_REQUEST['photo']);
                    break;
            }
        }
        // Now we handle the potentially destructive commands, which have to
        // be submitted by POST only.
        if (!empty($_POST['command'])) {
            switch ($_POST['command']) {
                case 'addPhoto':
                    addPhoto($client, $_POST['user'], $_POST['album'], $_FILES['photo']);
                    break;
                case 'deletePhoto':
                    deletePhoto($client, $_POST['user'], $_POST['album'], $_POST['photo']);
                    break;
                case 'addAlbum':
                    addAlbum($client, $_POST['user'], $_POST['name']);
                    break;
                case 'deleteAlbum':
                    deleteAlbum($client, $_POST['user'], $_POST['album']);
                    break;
                case 'addComment':
                    addComment($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['comment']);
                    break;
                case 'addTag':
                    addTag($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['tag']);
                    break;
                case 'deleteComment':
                    deleteComment($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['comment']);
                    break;
                case 'deleteTag':
                    deleteTag($client, $_POST['user'], $_POST['album'], $_POST['photo'], $_POST['tag']);
                    break;
                default:
                    break;
            }
        }
        // If a menu parameter is available, display a submenu.
        if (!empty($_REQUEST['menu'])) {
            switch ($_REQUEST['menu']) {
                case 'user':
                    displayUserMenu();
                    break;
                case 'photo':
                    displayPhotoMenu();
                    break;
                case 'album':
                    displayAlbumMenu();
                    break;
                case 'logout':
                    logout();
                    break;
                default:
                    header('HTTP/1.1 400 Bad Request');
                    echo "<h2>Invalid menu selection.</h2>\n";
                    echo "<p>Please check your request and try again.</p>";
            }
        }
        if (empty($_REQUEST['menu']) && empty($_REQUEST['command'])) {
            displayMenu();
        }
    }
}
Beispiel #3
0
/* * **********************************************
  If we're signed in we can go ahead and retrieve
  data
 * ********************************************** */
set_time_limit('10000');
if (isset($_SESSION['google_token'])) {
    $client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['google_token']);
    $userInfo = $_SESSION['google_userInfo'];
    $album_ids = explode(',', $_GET['album_ids']);
    foreach ($album_ids as $album_id) {
        $singleAlbum = fetchSingleAlbums($album_id);
        if (!file_exists(ABSOLUTE_PATH . "/assets/images/archive")) {
            mkdir(ABSOLUTE_PATH . "/assets/images/archive");
        }
        $filepath = $album_id;
        if (!file_exists(ABSOLUTE_PATH . "/assets/images/albums/{$filepath}")) {
            mkdir(ABSOLUTE_PATH . "/assets/images/albums/{$filepath}");
        }
        $result = addAlbum($client, 'Test Album');
        $albumId = $result->getGphotoId()->getText();
        foreach ($singleAlbum as $photo) {
            $url = $photo->source;
            $destination_path = ABSOLUTE_PATH . '/assets/images/albums/' . $filepath . '/' . $photo->id . '.jpg';
            downloadImage($url, $destination_path);
            addPhoto($client, $userInfo->user_id, $albumId, $photo->id, $destination_path);
        }
    }
    echo '<p class="bg-success"> Your album has been move to your picasa account successfully.</p>';
} else {
    echo 'first login via google inorder to move your album to picasa account';
}
Beispiel #4
0
    }
    $src_W = $imgage[0];
    //获取大图片宽度
    $src_H = $imgage[1];
    //获取大图片高度
    $rW = floatval($src_W) / floatval($width);
    $rH = floatval($src_H) / floatval($height);
    $ratio = max($rW, $rH);
    $width = intval($src_W / $ratio);
    $height = intval($src_H / $ratio);
    $tn = imagecreatetruecolor($width, $height);
    //创建缩略图
    imagecopyresampled($tn, $im, 0, 0, 0, 0, $width, $height, $src_W, $src_H);
    //复制图像并改变大小
    imagejpeg($tn, $small_img);
    //输出图像
}
$filenames = scandir("/var/www/html/data/FP_V0_PHOTO_1");
foreach ($filenames as $name) {
    if ($name != '.' and $name != "..") {
        $longitude = rand(11620000, 11640000) / 100000.0;
        $latitude = rand(3980000, 4010000) / 100000.0;
        $path = "data/FP_V0_PHOTO_1/" . $name;
        $absPath = "/var/www/html/data/FP_V0_PHOTO_1/" . $name;
        $absSnapPath = "/var/www/html/data/FP_V0_PHOTO_1/" . $name . "_snap.jpg";
        $cmd = "convert -resize 100x100 " . $absPath . " " . $absSnapPath;
        system($cmd);
        $md5 = md5_file($absPath);
        addPhoto("1", 1, 1, $name, $path, $longitude, $latitude, time(), "Beijing", $md5, "for test");
    }
}
Beispiel #5
0
        $username = $_SESSION['name'];
        $filename = $_FILES["file"]["name"];
        $tmpfile = $_FILES["file"]["tmp_name"];
        $userid = getUserID($username);
        $path = "data/FP_V0_PHOTO_" . $userid . "/" . $filename;
        move_uploaded_file($tmpfile, $path);
        $absPath = "/var/www/html/" . $path;
        $absSnapPath = $absPath . "_snap.jpg";
        $cmd = "convert -resize 100x100 " . $absPath . " " . $absSnapPath;
        system($cmd);
        $md5 = md5_file($absPath);
        $picTag = $_POST['picTag'];
        $picPos = $_POST['picPos'];
        $longitude = split(",", $picPos)[0];
        $latitude = split(",", $picPos)[1];
        addPhoto($userid, 1, 1, $filename, $path, $longitude, $latitude, time(), "address", $md5, $picTag);
        header("Location: upload.php");
    }
}
?>

<html  xmlns="http://www.w3.org/1999/xhtml" lang="en">
  <head>

   <script type="text/javascript" src="js/jquery.min.js"></script>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">

    <link href="css/upload.css" rel='stylesheet' type='text/css' />
Beispiel #6
0
<html>
<head>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/main.css" rel="stylesheet">
    <script src="js/bootstrap.min.js" type="text/javascript"></script>
    <script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
    <meta charset="UTF-8">
    <title>Добавить кота</title>
</head>
<?

if (!empty($_FILES)) {
    // Тут надо будет ввести проверку на админа.
    addPhoto();
}

?>

<body>

<?var_dump($_POST)?>
<?var_dump($_FILES)?>
<h1>Добавим нового кота.</h1>
<h2><a href="../index.php">Назад</a></h2>
<form name="new_cat" action="" enctype="multipart/form-data" method="post">
    <inpute type="hidden" name="addCat" value="yes">
    <input name="name" type="text">
    <input class="input-large"  name="file" type="file">
    <input class="input-large" type="submit">
</form>
</body>
function savePhoto($uuid, $toilet_id, $photo)
{
    if (empty($uuid)) {
        return ERROR_UUID;
    }
    $tid = (int) $toilet_id;
    if ($tid == 0) {
        return ERROR_TOILET_ID;
    }
    if (empty($photo)) {
        return ERROR_FILE;
    }
    if ($photo->getError() === UPLOAD_ERR_OK) {
        $photoDir = 'images/photos/' . $toilet_id . '/';
        if (!file_exists($photoDir)) {
            mkdir($photoDir, 0777, true);
        }
        $filename = 'JPEG_' . date('Ymd_His') . '.jpg';
        $photo->moveTo($photoDir . $filename);
        if (!addPhoto($toilet_id, $uuid, $filename)) {
            unlink($photoDir . $filename);
            return ERROR_SQL;
        } else {
            removeOldestPhoto($toilet_id);
        }
    } else {
        return ERROR_FILE;
    }
    return ERROR_OK;
}