-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
186 lines (159 loc) · 5.01 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<?php
require_once 'picasa/Picasa_Wrapper.php';
$media = new Picasa_Fetcher_Wrapper();
if (!$media->log_in(DOMAIN))
{
echo "You are being redirected to google...";
}
$user_albums = $media->get_user_albums();
$album = NULL;
$photo = NULL;
if (isset($_GET['album']) && isset($user_albums[$_GET['album']]))
{
$album = $user_albums[$_GET['album']];
$photos = $album->get_photos();
if (isset($_GET['photo']) && isset($photos[$_GET['photo']]))
{
$photo = $photos[$_GET['photo']];
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>M Sync</title>
<link rel="stylesheet" href="theme/style.css">
</head>
<body>
<ul class="sandbar">
<li id="logo"><a href="http://www.hyves.nl" target="_blank">
<img src="theme/logo.png" height="27" width="72" border="0" />
</a>
</li>
<li><a href="index.php">Home</a></li>
<? if ($album != NULL) { ?>
<li><a href='?album=<?= $_GET['album'] ?>'><?= $album->get_title() ?></a></li>
<? } ?>
<? if ($photo != NULL) { ?>
<li><a>Photo <?= $_GET['photo'] ?></a></li>
<? } ?>
</ul>
<div id="content">
<?
if ($photo != NULL) {
if (isset($_GET['upload'])) {
uploadPhoto($user_albums, $album, $photo, $_GET['upload']);
}
showPhotoDetails($user_albums, $album, $photo);
} else if ($album != NULL) {
if (isset($_GET['upload'])) {
uploadAlbum($user_albums, $album, $_GET['upload']);
}
showAlbumDetails($user_albums, $album);
} else {
showAlbums($user_albums);
}
?>
</div>
</body>
</html>
<?
function showAlbums($user_albums)
{
echo "<ul>";
foreach ($user_albums as $id=>$album)
{
echo "<li><a href='?album=$id'>
<img src='theme/picasa_logo.jpg' height='10px'>".$album->get_title()."
</a></li>";
}
echo "</ul>";
}
function showAlbumDetails($user_albums, $album)
{
?>
<div align='right'>
<table>
<tr><td colspan="1">Share this album</td></tr>
<tr>
<td>
<a href='?album=<?=$_GET['album']?>&upload=hyves'>
<img src='theme/hyves_logo.jpg' height='50px'>
</a>
</td>
</tr>
</table>
</div>
<h1>Viewing album <?= $album->get_title() ?></h1><br/>
<?
foreach ($album->get_photos() as $id=>$photo)
{
echo "<hr/>";
echo "<a href='?album=".$_GET['album']."&photo=$id'><img src='".$photo->get_default_thumb_url()."'/></a><br/>";
}
}
function showPhotoDetails($user_albums, $album, $photo)
{
?>
<div align='right'>
<table>
<tr><td colspan="1">Share this picture</td></tr>
<tr>
<td>
<a href='?album=<?=$_GET['album']?>&photo=<?=$_GET['photo']?>&upload=hyves'>
<img src='theme/hyves_logo.jpg' height='50px'>
</a>
</td>
</tr>
</table>
</div>
<div class="alert"><center>
<img src='<?= $photo->get_full_size_url() ?>'/><br/>
<?= $photo->get_title() ?>
</center></div>
<hr/>
<ul>
<li><a href="<?= $photo->get_default_link() ?>">Goto source</a></li>
<li>The picture has <?= $photo->get_comment_count() ?> comments
(comments are <?= $photo->get_commenting_enabled()? 'enabled' : 'disabled' ?>)</li>
<li>The original picture is <?= $photo->get_original_width() ?>x<?= $photo->get_original_height() ?>
and has a size of <?= $photo->get_original_size_bytes() ?> bytes.</li>
<li>It was taken at geolocation <?= $photo->get_geo_location() ?>.</li>
</ul>
<?
if ($photo->get_comment_count() > 0) {
foreach($photo->get_comments() as $comment) {
?>
<hr/>
<?= $comment ?>
<?
}
}
}
function uploadPhoto($user_albums, $album, $photo, $service)
{
require_once 'hyves/Hyves_Uploader_Wrapper.php';
$consumerKey = 'MTAyMThf39vqLmyf-t2LVswBCYWfhg==';
$consumerSecret = 'MTAyMThfV_7flEzhupNx8JDGX1ZpWQ==';
$next_url = DOMAIN.'http://localhost/?album='.$_GET['album']."&photo=".$_GET['photo'].'&upload=hyves&confirm';
$media = new Hyves_Media_Uploader_Wrapper($consumerKey, $consumerSecret);
$media->log_in($next_url);
$id = $media->upload($photo);
echo "Uploaded photo $id";
}
function uploadAlbum($user_albums, $album)
{
require_once 'hyves/Hyves_Uploader_Wrapper.php';
$consumerKey = 'MTAyMThf39vqLmyf-t2LVswBCYWfhg==';
$consumerSecret = 'MTAyMThfV_7flEzhupNx8JDGX1ZpWQ==';
$next_url = DOMAIN.'?album='.$_GET['album'].'&upload=hyves&confirm';
$media = new Hyves_Media_Uploader_Wrapper($consumerKey, $consumerSecret);
$media->log_in($next_url);
echo "<h1>Uploading album...</h1>";
echo "<ul>";
$url = $media->upload_album($album);
echo "</ul>";
echo "<a href='$url' target='blank'>Done! See it on Hyves</a>";
}
?>