-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_photos.php
107 lines (99 loc) · 3.98 KB
/
my_photos.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
<?php
/******************************************************************************
Etano
===============================================================================
File: my_photos.php
$Revision$
Software by: DateMill (http://www.datemill.com)
Copyright by: DateMill (http://www.datemill.com)
Support at: http://www.datemill.com/forum
*******************************************************************************
* See the "docs/licenses/etano.txt" file for license. *
******************************************************************************/
require 'includes/common.inc.php';
require _BASEPATH_.'/includes/user_functions.inc.php';
require _BASEPATH_.'/skins_site/'.get_my_skin().'/lang/photos.inc.php';
check_login_member('upload_photos');
$tpl=new phemplate(_BASEPATH_.'/skins_site/'.get_my_skin().'/','remove_nonjs');
define('COLUMNS',3);
$accepted_results_per_page=array(6=>6,12=>12,24=>24,48=>48);
$output=array();
$o=isset($_GET['o']) ? (int)$_GET['o'] : 0;
$r=!empty($_GET['r']) ? (int)$_GET['r'] : current($accepted_results_per_page);
$where="`fk_user_id`='".$_SESSION[_LICENSE_KEY_]['user']['user_id']."' AND `del`=0";
$from="`{$dbtable_prefix}user_photos`";
$query="SELECT count(*) FROM $from WHERE $where";
if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
$totalrows=mysql_result($res,0,0);
$loop_rows=array();
if (!empty($totalrows)) {
if ($o>=$totalrows) {
$o=$totalrows-$r;
$o=$o>=0 ? $o : 0;
}
$query="SELECT `photo_id`,`photo`,`is_main`,`is_private`,`caption`,`status`,`reject_reason`,`stat_views`,`stat_comments`,UNIX_TIMESTAMP(`date_posted`) as `date_posted` FROM $from WHERE $where ORDER BY `date_posted` DESC LIMIT $o,$r";
if (!($res=@mysql_query($query))) {trigger_error(mysql_error(),E_USER_ERROR);}
$loop_items=array();
$i=1;
$rows=0;
while ($rsrow=mysql_fetch_assoc($res)) {
$rsrow['date_posted']=strftime($_SESSION[_LICENSE_KEY_]['user']['prefs']['date_format'],$rsrow['date_posted']+$_SESSION[_LICENSE_KEY_]['user']['prefs']['time_offset']);
$rsrow['is_private']=empty($rsrow['is_private']) ? $GLOBALS['_lang'][139] : $GLOBALS['_lang'][138];
$rsrow['caption']=sanitize_and_format($rsrow['caption'],TYPE_STRING,$__field2format[TEXT_DB2DISPLAY]);
$rsrow['class']='';
if ($rsrow['status']==STAT_EDIT) {
$rsrow['status']='stat_edit';
$rsrow['reject_reason']=rawurlencode($rsrow['reject_reason']);
} else {
unset($rsrow['reject_reason']);
if ($rsrow['status']==STAT_PENDING) {
$rsrow['status']='stat_pending';
$rsrow['stat_pending']=true;
}
}
if ($i%COLUMNS==1) {
$rsrow['class'].=' first';
}
$loop_items[]=$rsrow;
if ($i%COLUMNS==0) {
$loop_items[count($loop_items)-1]['class'].=' last';
$loop_rows[$rows]['loop_items']=$loop_items;
$loop_items=array();
++$rows;
}
++$i;
}
// one more time for $i%COLUMNS
if (!empty($loop_items)) {
$loop_items[count($loop_items)-1]['class'].=' last';
$loop_rows[$rows]['loop_items']=$loop_items;
}
$loop_rows[0]['class']='first';
if (empty($rows)) {
$loop_rows[0]['class'].=' last';
} else {
$loop_rows[count($loop_rows)-1]['class']='last';
}
$output['pager2']=pager($totalrows,$o,$r);
}
$output['return2me']='my_photos.php';
if (!empty($_SERVER['QUERY_STRING'])) {
$output['return2me'].='?'.$_SERVER['QUERY_STRING'];
}
$output['return2me']=rawurlencode($output['return2me']);
$tpl->set_file('content','my_photos.html');
$tpl->set_loop('loop_rows',$loop_rows);
$tpl->set_var('output',$output);
$tpl->process('content','content',TPL_MULTILOOP | TPL_OPTLOOP | TPL_OPTIONAL | TPL_NOLOOP);
$tpl->drop_loop('loop_rows');
unset($loop_rows);
$tpl->drop_var('output.pager2');
$tplvars['title']=$GLOBALS['_lang'][140];
$tplvars['page_title']=$GLOBALS['_lang'][140];
$tplvars['page']='my_photos';
$tplvars['css']='my_photos.css';
if (is_file('my_photos_left.php')) {
include 'my_photos_left.php';
}
unset($page_last_modified_time); // we want everything fresh on this page.
include 'frame.php';