-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphotocanvas.php
More file actions
370 lines (341 loc) · 18.5 KB
/
photocanvas.php
File metadata and controls
370 lines (341 loc) · 18.5 KB
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
<?php
/*
* Property of Writale
* All rights reserved
* Writale © 2013
*/
if (!isset($_subject)) {
include realpath(dirname(__FILE__) . '/error/notfound.php');
exit();
}
try {
require_once realpath(dirname(__FILE__) . "/control/session/saved.php");
require_once realpath(dirname(__FILE__) . "/control/general/cache.php");
$_pid = $_subject;
$_self = false;
$pic = new Pictory(array(
'pid' => $_pid
));
$pic_detail = $pic->getDetail();
$_story_count = $pic_detail['storycount'];
$author_name = $pic_detail['firstname'] . ' ' . $pic_detail['lastname'];
$profile_link = $_protocol.$_SERVER['HTTP_HOST'].'/'.$pic_detail['un'];
$image_data = Util::getImageData($_pid);
$picture_amount = FebQuery::getPictoryCount ($pic_detail['uid']);
if($pic_detail['uid'] == $_SESSION['uid'])
$_self = true;
else {
$followState = (0 == FebQuery::getFollowingStatus($pic_detail['uid']))
? false
: true;
}
if ($image_data['ar'] == 1) {
if($image_data['height'] < 550)
$_height = $image_data['height'] - 60;
else
$_height = 550;
}
else if ($image_data['ar'] > 1)
$_height = 430;
else
$_height = 550;
$_self_link = $_protocol . $_SERVER['HTTP_HOST'] . '/' . $_subject;
if (isset($_GET['tps'])) {
$_tops = 1;
$_get_param = 'tops=1';
} else if (isset($_GET['rn'])) {
$_running = 1;
$_get_param = 'run=1';
} else if (isset($_GET['cmp'])) {
$_complete = 1;
$_get_param = 'comp=1';
} else
$_recent = 1;
} catch (Exception $ex) {
Util::__errorSummary(WRITALE_ERR_GEN, $ex);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title> Photo · <?php echo $author_name; ?> </title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Writale is a simple, powerful way to read and build social stories." />
<link rel="shortcut icon" type="image/x-icon" href="//<?php echo $_SERVER['HTTP_HOST'] ?>/resource/image/icon/favicon.ico" />
<link rel="stylesheet" type="text/css" href="//<?php echo $_SERVER['HTTP_HOST'] . '/style/universal.css'; ?>" />
<link rel="stylesheet" type="text/css" href="//<?php echo $_SERVER['HTTP_HOST'] . '/style/strydlg.css'; ?>" />
<link rel="stylesheet" type="text/css" href="//<?php echo $_SERVER['HTTP_HOST'] . '/style/photo-0958-25022014.css'; ?>" />
<link rel="stylesheet" type="text/css" href="//<?php echo $_SERVER['HTTP_HOST']; ?>/style/gnr-0349-20022014.css" />
<script src="//<?php echo $_SERVER['HTTP_HOST'] ?>/script/common.js"></script>
<script src="//<?php echo $_SERVER['HTTP_HOST'] ?>/script/feedact.js"></script>
</head>
<body class="photo-body">
<input type="hidden" value="<?php echo $_pid; ?>" id="photoid"/>
<?php if (isset($_get_param)): ?>
<input type="hidden" value="<?php echo $_get_param; ?>" id="get-param" />
<?php endif; ?>
<input id="pic-owner" type="hidden" value="<?php echo $pic_detail['uid']; ?>" />
<div id="feed-error" class="tiny-error"></div>
<div id="update-banner">This page has some updates which haven't been applied. Please refresh to see it. </div>
<?php
include realpath(dirname(__FILE__) . '/control/decorator/userpanel.php');
?>
<div id="general-outer-container">
<?php require realpath(dirname(__FILE__) . '/control/decorator/sidebar.php') ?>
<div id="general-middle-container">
<?php require realpath(dirname(__FILE__) . '/control/decorator/openstorypanel.php'); ?>
<div id="general-central-outline">
<div id="photo-place">
<div class="photo-utility inline">
<?php if ($_SESSION['uid'] != $pic_detail['uid']): ?>
<div class="button-std button-gen add-photo-butt inline-middle" id="add-story-butt" title="Add a story to this pic.">
Add Story
</div>
<div class="button-std button-colorless inline-middle" id="report-photo-butt">
Report
</div>
<?php else : ?>
<div class="button-std button-gen add-photo-butt inline-middle" id="invite-button-user" title="Invite people to add story to your picture">
Invite People
</div>
<div class="button-std button-colorless inline-middle" id="delete-pic" title="Double click to delete this photo.">
Delete
</div>
<?php endif; ?>
</div>
<div class="storycount bold inline" title="No. of stories written on this pic">
<div class="large-text">
<?php echo $_story_count; ?>
</div>
<?php echo ((1 == $_story_count) ? 'Story' : 'Stories'); ?>
</div>
<?php try { ?>
<img src="data:image/jpeg;base64,<?php echo Util::resizeImage(null, 950, $_height, true, $image_data['path']); ?>" alt="" />
<?php } catch (Exception $ex) {
Util::__errorSummary(WRITALE_ERR_GEN,$ex);
}
?>
</div>
<div id="footer">
</div>
<div id="p_d"></div>
<div class="bold" id="story-list-header">
<div class="inline-middle divide-middle-line">
</div>
<div class="inline-middle" id="header-text">
Stories based on this picture
</div>
<div class="inline-middle divide-middle-line">
</div>
</div>
<div class="photo-stories">
<div id="story-category-bar">
<div class="inline genre-top-link <?php if (isset($_recent)) echo 'bold'; ?>">
<a class="no-decorate" href="<?php echo $_self_link . '#p_d'; ?>"
title="See all recent stories based on this picture.">Recent Stories</a>
</div>
<div class="inline genre-top-link <?php if (isset($_tops)) echo 'bold'; ?>">
<a class="no-decorate" href="<?php echo $_self_link . '?tps=1#p_d'; ?>"
title="See all top stories based on this picture.">Top Stories</a>
</div>
<div class="inline genre-top-link <?php if (isset($_running)) echo 'bold'; ?>">
<a class="no-decorate" href="<?php echo $_self_link . '?rn=1#p_d'; ?>"
title="See all incomplete stories based on this picture.">Running Stories</a>
</div>
<div class="inline genre-top-link <?php if (isset($_complete)) echo 'bold'; ?>">
<a class="no-decorate" href="<?php echo $_self_link . '?cmp=1#p_d'; ?>"
title="See completed stories based on this picture.">Closed Stories</a>
</div>
</div>
<div id="story-content">
<?php include realpath(dirname(__FILE__) . '/control/process/storyfetch.php'); ?>
<div id="page-loader" class="dnone">
<img src="<?php echo $_protocol . $_SERVER['HTTP_HOST'] . '/resource/image/misc/ajax-loader.gif'; ?>"
alt="" />
</div>
</div>
</div>
<?php require realpath(dirname(__FILE__) . '/control/decorator/pagefooter.php'); ?>
</div>
</div>
<div class="sidebar-right">
<div class="sidebar-upper-section">
<div class="button-std button-gen sidebar-up-button" id="invite-button-side">
Invite
</div> people to add story.
<div class="divider"></div>
</div>
<div class="sidebar-lower-section">
<div id="photo-author">
<div class="title" id="author-title">
Photo Author
</div>
<div id="author-detail">
<div id="author-photo">
<a href="<?php echo $profile_link; ?>">
<img src="<?php echo $_protocol . $_SERVER['HTTP_HOST'] . '/' . $pic_detail['mad'] .
'/' . $pic_detail['bn'];
?>"
alt="" /></a>
</div>
<div id="author-data">
<div class="bold" id="author-name">
<a href="<?php echo $profile_link; ?>"> <?php echo $author_name; ?></a>
</div>
<div id="wfactor">
<a href="<?php echo $profile_link.'/picture'; ?>"><?php
echo $picture_amount.' Picture'.((1==$picture_amount) ? '':'s');
?></a></div>
</div>
</div>
<div id="photo-author-base">
<?php if(!$_self) : ?>
<div class="button-std<?php echo ((!$followState) ? ' button-gen' : ' button-colorless') ; ?>" id="follow-user">
<?php
echo ((!$followState) ? 'Follow' : 'Unfollow') ;
?>
</div>
<?php endif; ?>
</div>
</div>
<div id="trending-pic">
<div class="title" id="trending-pic-title">
Trending Pictures
</div>
<div id="trend-pic-contain">
<?php
try {
$res_tp = FebQuery::getTrendingPic($_pid);
if($res_tp->num_rows == 0) {
echo 'Nothing is trending now.';
}
else {
while($row = $res_tp->fetch_row()) {
$path = $row[0].$row[1].'/'.$row[2];
?>
<a href="<?php echo $_protocol.$_SERVER['HTTP_HOST'].'/'.$row[4]; ?>">
<img src="data:image/jpeg;base64,<?php
echo Util::resizeImage(null, 70, 70, true, $path); ?>" alt=""
title="<?php echo $row[3].' '.((1==$row[3]) ? 'Story' : 'Stories');?>" />
</a>
<?php
}
}
} catch (Exception $ex) {
Util::__errorSummary(WRITALE_ERR_GEN, $ex);
}
?>
</div>
<div id="border-bottom"></div>
</div>
</div>
</div>
<span class="stretch"></span>
</div>
<?php
try {
if(isset($_GET['ref']) && isset($_SESSION['invi_nonce']) &&
$_GET['ref'] == 'inv' && isset($_GET['iid']) && isset($_GET['iv_n']) && $_GET['iv_n'] == $_SESSION['invi_nonce']) {
$iid = Util::sanitize($_GET['iid'],WRITALE_INPT_GEN);
FebQuery::seeInvitation($iid);
}
} catch (Exception $ex) {
Util::__errorSummary(WRITALE_ERR_GEN, $ex);
}
include realpath(dirname(__FILE__) . '/control/decorator/openstory.php');
include realpath(dirname(__FILE__) . '/control/decorator/utilbottom.php');
include realpath(dirname(__FILE__) . '/control/decorator/savedutil.php');
?>
<script src="//<?php echo $_SERVER['HTTP_HOST'] ?>/script/storysieve.js"></script>
<script>
(function() {
var photo = (function() {
var
reportButt = _gAny('report-photo-butt'),
addStoryButt = _gAny('add-story-butt'),
inviteButtPublic = _gAny('invite-button-side'),
inviteButtPrivate = _gAny('invite-button-user'),
delButton = _gAny('delete-pic'),
pid = _gAny('photoid').value,
picOwner = _gAny('pic-owner').value,
nNotice = _gAny('notice-white'),
nFollow = _gAny('follow-user'),
nError = _gAny('feed-error'),
pictory = {
id: pid,
owner: picOwner
},
iDelTimeout,
showDeleteHelp = function(e) {
removeEvent.call(this, 'click', showDeleteHelp, false);
iDelTimeout = setTimeout(function() {
util.genError(nNotice, "Please double click on delete button, to remove this photo.");
addEvent.call(e.target, 'click', showDeleteHelp, false);
}, 200);
};
function init() {
var invite = function() {
common.invitation.init(pid, 'P');
};
wfeed.core.init(0);
storysieve.addPreview();
if (_gAny('feedlet-1'))
addEvent.call(window.self, 'scroll', storysieve.paginate.init, false);
if (reportButt) {
addEvent.call(reportButt, 'click', function() {
common.report('addp', pid);
}, false);
}
if (addStoryButt) {
addEvent.call(addStoryButt, 'click', function() {
story.showDialog(pictory);
}, false);
}
if (inviteButtPrivate) {
addEvent.call(inviteButtPrivate, 'click', invite, false);
}
addEvent.call(inviteButtPublic, 'click', invite, false);
if (delButton) {
addEvent.call(delButton, 'click', showDeleteHelp, false);
addEvent.call(delButton, 'dblclick', function() {
var sArg = '?dep=1&p=' + pid + '&u=' + picOwner;
clearTimeout(iDelTimeout);
removeEvent.call(this, 'click', showDeleteHelp, false);
util.dotLoader(this, 1);
wxhr.sendGenericRequest(sArg, afterDelete);
}, false);
}
if(nFollow) {
common.follow.init({
button : nFollow,
target : picOwner,
error : nError,
type : 1,
waitsize : '50px'
});
}
}
function afterDelete(r) {
var res = JSON.parse(r);
if (res.success) {
location.href = location.protocol + '//' + location.hostname;
}
else {
util.dotLoader(delButton, 0);
delButton.innerHTML = 'Delete';
if (res.error === 9)
util.genError(nNotice, "This picture has stories based on it. You can't delete it.");
else
util.genError(nError, "Something's wrong. Please try later.");
}
}
return {
init: init
};
})();
photo.init();
})();
</script>
</body>
</html>