Subversion Repositories svnkaklik

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?php
2
/*************************
3
  Coppermine Photo Gallery
4
  ************************
5
  Copyright (c) 2003-2005 Coppermine Dev Team
6
  v1.1 originaly written by Gregory DEMAR
7
 
8
  This program is free software; you can redistribute it and/or modify
9
  it under the terms of the GNU General Public License as published by
10
  the Free Software Foundation; either version 2 of the License, or
11
  (at your option) any later version.
12
  ********************************************
13
  Coppermine version: 1.3.3
14
  $Source: /cvsroot/coppermine/stable/db_ecard.php,v $
15
  $Revision: 1.5 $
16
  $Author: gaugau $
17
  $Date: 2005/04/19 03:17:10 $
18
**********************************************/
19
 
20
define('IN_COPPERMINE', true);
21
define('DB_ECARD_PHP', true);
22
global $CONFIG;
23
 
24
require('include/init.inc.php');
25
if (!GALLERY_ADMIN_MODE) cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__, 'false');
26
 
27
$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : '';
28
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : '';
29
$count = isset($_REQUEST['count']) ? $_REQUEST['count'] : '';
30
//set default values
31
$selectOptions = array(25,50,75,100);
32
$sortBy = 'date';
33
$sortDirection = 'DESC';
34
$sortText = $lang_db_ecard_php['ecard_by_date'];
35
$sortDirectionText = $lang_db_ecard_php['ecard_descending'];
36
if (!$start) {$startFrom = '0';}else{$startFrom=$start;}
37
if (!$count) {$countTo = $selectOptions[0];}else{$countTo=$count;}
38
$tabOutput = '';
39
 
40
//delete selected ecards
41
if (isset($_REQUEST['eid'])) {
42
  foreach ($_REQUEST['eid'] as $key) {
43
    //print $key;
44
    //print "<br>";
45
    $query = "DELETE FROM {$CONFIG['TABLE_ECARDS']} WHERE eid='$key'";
46
    $result = db_query($query);
47
    }
48
}
49
 
50
switch ($sort) {
51
  case 'snd' :
52
    $sortBy = 'sender_name';
53
    $sortDirection = 'DESC';
54
    $sortText = $lang_db_ecard_php['ecard_by_sender_name'];
55
    break;
56
  case 'sna' :
57
    $sortBy = 'sender_name';
58
    $sortDirection = 'ASC';
59
    $sortText = $lang_db_ecard_php['ecard_by_sender_name'];
60
    break;
61
  case 'sed' :
62
    $sortBy = 'sender_email';
63
    $sortDirection = 'DESC';
64
    $sortText = $lang_db_ecard_php['ecard_by_sender_email'];
65
    break;
66
  case 'sea' :
67
    $sortBy = 'sender_email';
68
    $sortDirection = 'ASC';
69
    $sortText = $lang_db_ecard_php['ecard_by_sender_email'];
70
    break;
71
  case 'id' :
72
    $sortBy = 'sender_ip';
73
    $sortDirection = 'DESC';
74
    $sortText = $lang_db_ecard_php['ecard_by_sender_ip'];
75
    break;
76
  case 'ia' :
77
    $sortBy = 'sender_ip';
78
    $sortDirection = 'ASC';
79
    $sortText = $lang_db_ecard_php['ecard_by_sender_ip'];
80
    break;
81
  case 'rnd' :
82
    $sortBy = 'recipient_name';
83
    $sortDirection = 'DESC';
84
    $sortText = $lang_db_ecard_php['ecard_by_recipient_name'];
85
    break;
86
  case 'rna' :
87
    $sortBy = 'recipient_name';
88
    $sortDirection = 'ASC';
89
    $sortText = $lang_db_ecard_php['ecard_by_recipient_name'];
90
    break;
91
  case 'red' :
92
    $sortBy = 'recipient_email';
93
    $sortDirection = 'DESC';
94
    $sortText = $lang_db_ecard_php['ecard_by_recipient_email'];
95
    break;
96
  case 'rea' :
97
    $sortBy = 'recipient_email';
98
    $sortDirection = 'ASC';
99
    $sortText = $lang_db_ecard_php['ecard_by_recipient_email'];
100
    break;
101
  case 'da' :
102
    $sortBy = 'date';
103
    $sortDirection = 'ASC';
104
    break;
105
}
106
 
107
if ($sortDirection == 'ASC'){$sortDirectionText = $lang_db_ecard_php['ecard_ascending'];}
108
 
109
// determine the total number of entries
110
$result = db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_ECARDS']}");
111
if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['ecards_empty'], __FILE__, __LINE__, false);
112
$totalEcards = mysql_fetch_array($result);
113
$totalEcards = $totalEcards[0];
114
$result = db_query("SELECT eid, sender_name, sender_email, recipient_name, recipient_email, link, date, sender_ip FROM {$CONFIG['TABLE_ECARDS']} ORDER BY $sortBy $sortDirection LIMIT $startFrom,$countTo");
115
if (!mysql_num_rows($result)) cpg_die(ERROR, $lang_errors['ecards_empty'], __FILE__, __LINE__, false);
116
 
117
pageheader($lang_db_ecard_php['title']);
118
 
119
$formTarget = cpgGetUrlVars('count');
120
print '<form method="post" name="ecardselect" action="'.$formTarget.'" onSubmit="return defaultagree(this)">';
121
?>
122
<script language="javascript" type="text/javascript">
123
<!--
124
function checkAll(field)
125
{
126
for (i = 0; i < field.length; i++)
127
  field[i].checked = true ;
128
}
129
 
130
function uncheckAll(field)
131
{
132
for (i = 0; i < field.length; i++)
133
  field[i].checked = false ;
134
}
135
 
136
var checkobj
137
 
138
function agreesubmit(el){
139
checkobj=el
140
if (document.all||document.getElementById){
141
for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
142
var tempobj=checkobj.form.elements[i]
143
if(tempobj.type.toLowerCase()=="submit")
144
tempobj.disabled=!checkobj.checked
145
}
146
}
147
}
148
 
149
function defaultagree(el){
150
if (!document.all&&!document.getElementById){
151
if (window.checkobj&&checkobj.checked)
152
return true
153
else{
154
alert("<?php print $lang_db_ecard_php['ecards_delete_confirm']; ?>")
155
return false
156
}
157
}
158
}
159
 
160
-->
161
</script>
162
<?php
163
// create tabbed display (non-coppermine standard); maybe this could be changed later using the coppermine standard method
164
// step 1: calculate the number of pages
165
$pageTotal = ceil($totalEcards/$countTo);
166
// step 2: get the current url without 'start' and 'count'
167
$urlWithoutStart = $_SERVER["SCRIPT_NAME"]."?";
168
foreach ($_GET as $key => $value) {
169
  if ($key!='start' && $key!='count'){$urlWithoutStart.= $key . "=" . $value . "&";}
170
}
171
//print $pageTotal;
172
//step 3: loop through the pages & create the links
173
for ($page = 1 ; $page <= $pageTotal; $page++) {
174
if ($page != $startFrom/$countTo+1) {
175
  $tabOutput .= '<a href="'.$urlWithoutStart.'start='.($page-1)*$countTo.'&count='.$countTo.'">';
176
  }
177
else {
178
  $currentPage = $page;
179
  $currentStart = ($page-1)*$countTo+1;
180
  $currentEnd = $currentStart+$countTo-1;
181
  if ($currentEnd > $totalEcards) {$currentEnd =$totalEcards;}
182
  }
183
$tabOutput .= $page;
184
//$tabOutput .= '('.$page.'/'.$startFrom/$countTo.') ';
185
if ($page != $startFrom/$countTo+1) {
186
  $tabOutput .= '</a>';
187
  }
188
$tabOutput .= '&nbsp;';
189
}
190
$maxPage =  $page-1;
191
 
192
 
193
$tableHeader1 = $lang_db_ecard_php['title']." (".$lang_db_ecard_php['ecard_sorted']." ".$sortText.", ".$sortDirectionText.")";
194
starttable('100%',$tableHeader1,3);
195
print '<tr><td class="tableb_compact">';
196
printf($lang_db_ecard_php['ecard_number'], $currentStart, $currentEnd, $totalEcards);
197
print '</td><td class="tableb_compact">';
198
if ($maxPage > 1) {
199
  print $lang_db_ecard_php['ecard_goto_page'].' ';
200
  print $tabOutput;
201
}
202
print '</td><td align="right" class="tableb_compact">';
203
print $lang_db_ecard_php['ecard_records_per_page'];
204
print '  <select onChange="if(this.options[this.selectedIndex].value) window.location.href=\''.$formTarget.'count=\'+this.options[this.selectedIndex].value;"  name="count" class="listbox">';
205
foreach ($selectOptions as $key ) {
206
  print '   <option value="'.$key.'" ';
207
  if ($key == $countTo) {print 'selected="selected"';}
208
  print '>'.$key.'</option>';
209
}
210
print '  </select>';
211
print '</td></tr>';
212
endtable();
213
 
214
print '<br />';
215
 
216
 
217
$urlWithoutSort = cpgGetUrlVars('sort');
218
starttable('100%');
219
//print '<table border="1">';
220
print "<tr>
221
<th class=\"tableh1_compact\" align=\"left\" valign=\"bottom\" rowspan=\"2\"></th>
222
<th class=\"tableh1_compact\" colspan=\"3\" align=\"left\" valign=\"bottom\">".$lang_db_ecard_php['ecard_sender']."</th>
223
<th class=\"tableh1_compact\" colspan=\"2\" align=\"left\" valign=\"bottom\">".$lang_db_ecard_php['ecard_recipient']."</th>
224
<th class=\"tableh1_compact\" rowspan=\"2\" align=\"left\" valign=\"bottom\">".$lang_db_ecard_php['ecard_date']." <a href=\"".$urlWithoutSort."sort=da\"><img src=\"images/ascending.gif\" width=\"9\" height=\"9\" border=\"0\" alt=\"\" title=\"".$lang_db_ecard_php['ecard_ascending']."\" /></a>&nbsp;<a href=\"".$urlWithoutSort."sort=dd\"><img src=\"images/descending.gif\" width=\"9\" height=\"9\" border=\"0\" alt=\"\" title=\"".$lang_db_ecard_php['ecard_descending']."\" /></a></th>
225
<th class=\"tableh1_compact\" rowspan=\"2\" align=\"left\" valign=\"bottom\"></th>
226
</tr>";
227
print "<tr>
228
<th class=\"tableh1_compact\" align=\"left\" valign=\"bottom\">".$lang_db_ecard_php['ecard_name']." <a href=\"".$urlWithoutSort."sort=sna\"><img src=\"images/ascending.gif\" width=\"9\" height=\"9\" border=\"0\" alt=\"\" title=\"".$lang_db_ecard_php['ecard_ascending']."\" /></a>&nbsp;<a href=\"".$urlWithoutSort."sort=snd\"><img src=\"images/descending.gif\" width=\"9\" height=\"9\" border=\"0\" alt=\"\" title=\"".$lang_db_ecard_php['ecard_descending']."\" /></a></th>
229
<th class=\"tableh1_compact\" align=\"left\" valign=\"bottom\">".$lang_db_ecard_php['ecard_email']." <a href=\"".$urlWithoutSort."sort=sea\"><img src=\"images/ascending.gif\" width=\"9\" height=\"9\" border=\"0\" alt=\"\" title=\"".$lang_db_ecard_php['ecard_ascending']."\" /></a>&nbsp;<a href=\"".$urlWithoutSort."sort=sed\"><img src=\"images/descending.gif\" width=\"9\" height=\"9\" border=\"0\" alt=\"\" title=\"".$lang_db_ecard_php['ecard_descending']."\" /></a></th>
230
<th class=\"tableh1_compact\" align=\"left\" valign=\"bottom\">".$lang_db_ecard_php['ecard_ip']." <a href=\"".$urlWithoutSort."sort=ia\"><img src=\"images/ascending.gif\" width=\"9\" height=\"9\" border=\"0\" alt=\"\" title=\"".$lang_db_ecard_php['ecard_ascending']."\" /></a>&nbsp;<a href=\"".$urlWithoutSort."sort=id\"><img src=\"images/descending.gif\" width=\"9\" height=\"9\" border=\"0\" alt=\"\" title=\"".$lang_db_ecard_php['ecard_descending']."\" /></a></th>
231
<th class=\"tableh1_compact\" align=\"left\" valign=\"bottom\">".$lang_db_ecard_php['ecard_name']." <a href=\"".$urlWithoutSort."sort=rna\"><img src=\"images/ascending.gif\" width=\"9\" height=\"9\" border=\"0\" alt=\"\" title=\"".$lang_db_ecard_php['ecard_ascending']."\" /></a>&nbsp;<a href=\"".$urlWithoutSort."sort=rnd\"><img src=\"images/descending.gif\" width=\"9\" height=\"9\" border=\"0\" alt=\"\" title=\"".$lang_db_ecard_php['ecard_descending']."\" /></a></th>
232
<th class=\"tableh1_compact\" align=\"left\" valign=\"bottom\">".$lang_db_ecard_php['ecard_email']." <a href=\"".$urlWithoutSort."sort=rea\"><img src=\"images/ascending.gif\" width=\"9\" height=\"9\" border=\"0\" alt=\"\" title=\"".$lang_db_ecard_php['ecard_ascending']."\" /></a>&nbsp;<a href=\"".$urlWithoutSort."sort=red\"><img src=\"images/descending.gif\" width=\"9\" height=\"9\" border=\"0\" alt=\"\" title=\"".$lang_db_ecard_php['ecard_descending']."\" /></a></th>
233
</tr>";
234
$tempClass = ' class="tableb"';
235
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
236
   print "\t<tr>\n";
237
   print "<td".$tempClass." align=\"center\"><input type=\"Checkbox\" name=\"eid[]\" value=\"".$line['eid']."\" id=\"eidselector\" class=\"checkbox\"></td>\n";
238
   print "<td".$tempClass."><b class=\"thumb_caption\">".$line['sender_name']."</b></td>\n";
239
   print "<td".$tempClass."><span class=\"thumb_caption\"><a href=\"mailto:".$line['sender_email']."\">".$line['sender_email']."</a></span></td>\n";
240
   print "<td".$tempClass."><span class=\"thumb_caption\"><a href=\"http://ws.arin.net/cgi-bin/whois.pl?queryinput=".$line['sender_ip']."\">".$line['sender_ip']."</a></span></td>\n";
241
   print "<td".$tempClass."><b class=\"thumb_caption\">".$line['recipient_name']."</b></td>\n";
242
   print "<td".$tempClass."><span class=\"thumb_caption\"><a href=\"mailto:".$line['recipient_email']."\">".$line['recipient_email']."</a></span></td>\n";
243
   print "<td".$tempClass."><span class=\"thumb_caption\">".strftime($lastcom_date_fmt,$line['date'])."</span></td>\n";
244
   print "<td align=\"center\"".$tempClass."><span class=\"thumb_caption\"><a href=\"displayecard.php?data=".$line['link']."\"><img src=\"images/ecard.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\" title=\"".$lang_db_ecard_php['ecard_display']."\" /></a></span></td>\n";
245
   print "\t</tr>\n";
246
   if ($tempClass == ' class="tableb"'){$tempClass = ' class="tableh2"';}else{$tempClass = ' class="tableb"';}
247
}
248
 
249
print '<tr><td class="tableh1_compact" align="center"><img src="images/arrow_upleft.gif" width="31" height="22" border="0" alt="" /></td>';
250
print '<td colspan="3" class="tableh1_compact">';
251
print '<input type="button" name="CheckAll" class="button" value="'.$lang_db_ecard_php['check_all'].'" onClick="checkAll(document.ecardselect.eidselector)">&nbsp;';
252
print '<input type="button" name="UnCheckAll" class="button" value="'.$lang_db_ecard_php['uncheck_all'].'" onClick="uncheckAll(document.ecardselect.eidselector)">';
253
print '</td>';
254
print '<td colspan="4" class="tableh1_compact" align="left">';
255
print '<input type="submit" class="button" name="delete" value="'.$lang_db_ecard_php['ecards_delete_selected'].'" disabled="disabled">&nbsp;';
256
print '<input name="agreecheck" type="checkbox" onClick="agreesubmit(this)">'.$lang_db_ecard_php['ecards_delete_sure'];
257
print '</td>';
258
print '</tr>';
259
endtable();
260
 
261
print "</form>\n";
262
 
263
pagefooter();
264
 
265
 
266
 
267
function cpgGetUrlVars($exception)
268
// get the url vars
269
{
270
 $cpgGetUrl = $_SERVER["SCRIPT_NAME"]."?";
271
 foreach ($_GET as $key => $value) {
272
    if ($key!=$exception){$cpgGetUrl.= $key . "=" . $value . "&";}
273
 }
274
return $cpgGetUrl;
275
}
276
 
277
?>