1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* $Id: functions.php v 1.00 21 June 2005 John N Exp $ |
4
|
|
|
* Module: WF-Links |
5
|
|
|
* Version: v1.0.3 |
6
|
|
|
* Release Date: 21 June 2005 |
7
|
|
|
* Developer: John N |
8
|
|
|
* Team: WF-Projects |
9
|
|
|
* Licence: GNU |
10
|
|
|
*/ |
11
|
|
|
defined('XOOPS_ROOT_PATH') || die('XOOPS root path not defined'); |
12
|
|
|
/** |
13
|
|
|
* wfs_gethandler() |
14
|
|
|
* |
15
|
|
|
* @param $name |
16
|
|
|
* @param boolean $optional |
17
|
|
|
* @return |
18
|
|
|
*/ |
19
|
|
|
function &wfl_gethandler( $name, $optional = false ) { |
|
|
|
|
20
|
|
|
global $handlers, $xoopsModule; |
|
|
|
|
21
|
|
|
|
22
|
|
|
$name = strtolower( trim( $name ) ); |
23
|
|
|
if ( !isset( $handlers[$name] ) ) { |
24
|
|
|
if ( file_exists( $hnd_file = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule -> getVar( 'dirname' ) . '/class/class_' . $name . '.php' ) ) { |
25
|
|
|
require_once $hnd_file; |
26
|
|
|
} |
27
|
|
|
$class = 'wfl' . ucfirst( $name ) . 'Handler'; |
28
|
|
|
if ( class_exists( $class ) ) { |
29
|
|
|
$handlers[$name] = new $class( $GLOBALS['xoopsDB'] ); |
30
|
|
|
} |
31
|
|
|
} |
32
|
|
|
if ( !isset( $handlers[$name] ) && !$optional ) { |
33
|
|
|
trigger_error( '<div>Class <b>' . $class . '</b> does not exist.</div> |
|
|
|
|
34
|
|
|
<div>Handler Name: ' . $name, E_USER_ERROR ) . '</div>'; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
return isset( $handlers[$name] ) ? $handlers[$name] : false; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
function wfl_checkgroups( $cid = 0, $permType = 'WFLinkCatPerm', $redirect = false ) |
41
|
|
|
{ |
42
|
|
|
global $xoopsUser, $xoopsModule; |
|
|
|
|
43
|
|
|
|
44
|
|
|
$groups = is_object( $xoopsUser ) ? $xoopsUser -> getGroups() : XOOPS_GROUP_ANONYMOUS; |
45
|
|
|
$gperm_handler = &xoops_gethandler( 'groupperm' ); |
46
|
|
|
if ( !$gperm_handler -> checkRight( $permType, $cid, $groups, $xoopsModule -> getVar( 'mid' ) ) ) { |
47
|
|
|
if ($redirect == false) { |
|
|
|
|
48
|
|
|
return false; |
49
|
|
|
} else { |
50
|
|
|
redirect_header( 'index.php', 3, _NOPERM ); |
51
|
|
|
exit(); |
|
|
|
|
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return true; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
function wfl_getVoteDetails( $lid = 0 ) |
|
|
|
|
59
|
|
|
{ |
60
|
|
|
global $xoopsDB; |
|
|
|
|
61
|
|
|
|
62
|
|
|
$sql = "SELECT |
63
|
|
|
COUNT(rating) AS rate, |
64
|
|
|
MIN(rating) AS min_rate, |
65
|
|
|
MAX(rating) AS max_rate, |
66
|
|
|
AVG(rating) AS avg_rate, |
67
|
|
|
COUNT(ratinguser) AS rating_user, |
68
|
|
|
MAX(ratinguser) AS max_user, |
69
|
|
|
MAX(title) AS max_title, |
70
|
|
|
MIN(title) AS min_title, |
71
|
|
|
sum(ratinguser = 0) AS null_ratinguser |
72
|
|
|
FROM " . $xoopsDB -> prefix( 'wflinks_votedata' ); |
73
|
|
|
if ($lid > 0) { |
74
|
|
|
$sql .= " WHERE lid = $lid"; |
75
|
|
|
} |
76
|
|
|
if ( !$result = $xoopsDB -> query( $sql ) ) { |
77
|
|
|
return false; |
78
|
|
|
} |
79
|
|
|
$ret = $xoopsDB -> fetchArray( $result ); |
80
|
|
|
|
81
|
|
|
return $ret; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
function wfl_calcVoteData( $sel_id = 0 ) |
85
|
|
|
{ |
86
|
|
|
$ret = array(); |
87
|
|
|
$ret['useravgrating'] = 0; |
88
|
|
|
|
89
|
|
|
$sql = "SELECT rating FROM " . $xoopsDB -> prefix( 'wflinks_votedata' ); |
|
|
|
|
90
|
|
|
if ($sel_id != 0) { |
91
|
|
|
" WHERE lid = " . $sel_id; |
92
|
|
|
} |
93
|
|
|
if ( !$result = $xoopsDB -> query( $sql ) ) { |
94
|
|
|
return false; |
95
|
|
|
} |
96
|
|
|
$ret['uservotes'] = $xoopsDB -> getRowsNum( $result ); |
97
|
|
|
while ( list( $rating ) = $xoopsDB -> fetchRow( $result ) ) { |
98
|
|
|
$ret['useravgrating'] += intval( $rating ); |
99
|
|
|
} |
100
|
|
|
if ($ret['useravgrating'] > 0) { |
101
|
|
|
$ret['useravgrating'] = number_format( ( $ret['useravgrating'] / $ret['uservotes'] ), 2 ); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
return $ret; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
function wfl_cleanRequestVars( &$array, $name = null, $def = null, $strict = false, $lengthcheck = 15 ) |
|
|
|
|
108
|
|
|
{ |
109
|
|
|
// Sanitise $_request for further use. This method gives more control and security. |
110
|
|
|
// Method is more for functionality rather than beauty at the moment, will correct later. |
111
|
|
|
unset( $array['usercookie'] ); |
112
|
|
|
unset( $array['PHPSESSID'] ); |
113
|
|
|
|
114
|
|
|
if ( is_array( $array ) && $name == null ) { |
115
|
|
|
$globals = array(); |
116
|
|
|
foreach ( array_keys( $array ) as $k ) { |
117
|
|
|
$value = strip_tags( trim( $array[$k] ) ); |
118
|
|
|
if ( strlen( $value >= $lengthcheck ) ) { |
119
|
|
|
return null; |
120
|
|
|
} |
121
|
|
View Code Duplication |
if ( ctype_digit( $value ) ) { |
|
|
|
|
122
|
|
|
$value = intval( $value ); |
123
|
|
|
} else { |
124
|
|
|
if ($strict == true) { |
|
|
|
|
125
|
|
|
$value = preg_replace( '/\W/', '', trim( $value ) ); |
126
|
|
|
} |
127
|
|
|
$value = strtolower( strval( $value ) ); |
128
|
|
|
} |
129
|
|
|
$globals[$k] = $value; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
return $globals; |
133
|
|
|
} |
134
|
|
|
if ( !isset( $array[$name] ) || !array_key_exists( $name, $array ) ) { |
135
|
|
|
return $def; |
136
|
|
|
} else { |
137
|
|
|
$value = strip_tags( trim( $array[$name] ) ); |
138
|
|
|
} |
139
|
|
View Code Duplication |
if ( ctype_digit( $value ) ) { |
|
|
|
|
140
|
|
|
$value = intval( $value ); |
141
|
|
|
} else { |
142
|
|
|
if ($strict == true) { |
|
|
|
|
143
|
|
|
$value = preg_replace( '/\W/', '', trim( $value ) ); |
144
|
|
|
} |
145
|
|
|
$value = strtolower( strval( $value ) ); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
return $value; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
// toolbar() |
|
|
|
|
152
|
|
|
// @return |
153
|
|
|
function wfl_toolbar( $cid = 0 ) |
154
|
|
|
{ |
155
|
|
|
$toolbar = "[ "; |
156
|
|
|
if ( true == wfl_checkgroups( $cid, 'WFLinkSubPerm' ) ) { |
157
|
|
|
$toolbar .= "<a href='submit.php?cid=" . $cid . "'>" . _MD_WFL_SUBMITLINK . "</a> | "; |
158
|
|
|
} |
159
|
|
|
$toolbar .= "<a href='newlist.php?newlinkshowdays=7'>" . _MD_WFL_LATESTLIST . "</a> | <a href='topten.php?list=hit'>" . _MD_WFL_POPULARITY . "</a> ]"; |
160
|
|
|
|
161
|
|
|
return $toolbar; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
// wfl_serverstats() |
|
|
|
|
165
|
|
|
// @return |
166
|
|
|
function wfl_serverstats() |
167
|
|
|
{ |
168
|
|
|
echo " |
169
|
|
|
<fieldset><legend style='font-weight: bold; color: #0A3760;'>" . _AM_WFL_LINK_IMAGEINFO . "</legend>\n |
170
|
|
|
<div style='padding: 8px;'>\n |
171
|
|
|
<div>" . _AM_WFL_LINK_SPHPINI . "</div>\n"; |
172
|
|
|
|
173
|
|
|
$safemode = ( ini_get( 'safe_mode' ) ) ? _AM_WFL_LINK_ON . _AM_WFL_LINK_SAFEMODEPROBLEMS : _AM_WFL_LINK_OFF; |
174
|
|
|
$registerglobals = ( ini_get( 'register_globals' ) == '' ) ? _AM_WFL_LINK_OFF : _AM_WFL_LINK_ON; |
175
|
|
|
$links = ( ini_get( 'file_uploads' ) ) ? _AM_WFL_LINK_ON : _AM_WFL_LINK_OFF; |
176
|
|
|
|
177
|
|
|
$gdlib = ( function_exists( 'gd_info' ) ) ? _AM_WFL_LINK_GDON : _AM_WFL_LINK_GDOFF; |
178
|
|
|
echo "<li>" . _AM_WFL_LINK_GDLIBSTATUS . $gdlib; |
179
|
|
|
if ( function_exists( 'gd_info' ) ) { |
180
|
|
|
if ( true == $gdlib = gd_info() ) { |
181
|
|
|
echo "<li>" . _AM_WFL_LINK_GDLIBVERSION . "<b>" . $gdlib['GD Version'] . "</b>"; |
182
|
|
|
} |
183
|
|
|
} |
184
|
|
|
echo "<br /><br />\n\n"; |
185
|
|
|
echo "<li>" . _AM_WFL_LINK_SAFEMODESTATUS . $safemode; |
186
|
|
|
echo "<li>" . _AM_WFL_LINK_REGISTERGLOBALS . $registerglobals; |
187
|
|
|
echo "<li>" . _AM_WFL_LINK_SERVERUPLOADSTATUS . $links; |
188
|
|
|
echo "</div>"; |
189
|
|
|
echo "</fieldset><br />"; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
// displayicons() |
193
|
|
|
// @param $time |
194
|
|
|
// @param integer $status |
195
|
|
|
// @param integer $counter |
196
|
|
|
// @return |
197
|
|
|
function wfl_displayicons( $time, $status = 0, $counter = 0 ) |
198
|
|
|
{ |
199
|
|
|
global $xoopsModuleConfig, $xoopsModule; |
|
|
|
|
200
|
|
|
|
201
|
|
|
$new = ''; |
202
|
|
|
$pop = ''; |
203
|
|
|
|
204
|
|
|
$newdate = ( time() - ( 86400 * intval( $xoopsModuleConfig['daysnew'] ) ) ); |
205
|
|
|
$popdate = ( time() - ( 86400 * intval( $xoopsModuleConfig['daysupdated'] ) ) ) ; |
206
|
|
|
|
207
|
|
|
if ($xoopsModuleConfig['displayicons'] != 3) { |
208
|
|
|
if ($newdate < $time) { |
209
|
|
|
if ( intval( $status ) > 1 ) { |
210
|
|
|
if ( $xoopsModuleConfig['displayicons'] == 1 ) |
211
|
|
|
$new = ' <img src="' . XOOPS_URL . '/modules/' . $xoopsModule -> getVar( 'dirname' ) . '/assets/images/icon/update.png" alt="" align="top" />'; |
212
|
|
|
if ( $xoopsModuleConfig['displayicons'] == 2 ) |
213
|
|
|
$new = "<i>Updated!</i>"; |
214
|
|
View Code Duplication |
} else { |
|
|
|
|
215
|
|
|
if ( $xoopsModuleConfig['displayicons'] == 1 ) |
216
|
|
|
$new = ' <img src="' . XOOPS_URL . '/modules/' . $xoopsModule -> getVar( 'dirname' ) . '/assets/images/icon/new.png" alt="" align="top" />'; |
217
|
|
|
if ( $xoopsModuleConfig['displayicons'] == 2 ) |
218
|
|
|
$new = "<i>New!</i>"; |
219
|
|
|
} |
220
|
|
|
} |
221
|
|
|
if ($popdate > $time) { |
222
|
|
View Code Duplication |
if ($counter >= $xoopsModuleConfig['popular']) { |
|
|
|
|
223
|
|
|
if ( $xoopsModuleConfig['displayicons'] == 1 ) |
224
|
|
|
$pop = ' <img src ="' . XOOPS_URL . '/modules/' . $xoopsModule -> getVar( 'dirname' ) . '/assets/images/icon/popular.png" alt="" align="top" />'; |
225
|
|
|
if ( $xoopsModuleConfig['displayicons'] == 2 ) |
226
|
|
|
$pop = "<i>Popular!</i>"; |
227
|
|
|
} |
228
|
|
|
} |
229
|
|
|
} |
230
|
|
|
$icons = $new . " " . $pop; |
231
|
|
|
|
232
|
|
|
return $icons; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
if ( !function_exists( 'wfl_convertorderbyin' ) ) { |
236
|
|
|
// Reusable Link Sorting Functions |
237
|
|
|
// wfl_convertorderbyin() |
238
|
|
|
// @param $orderby |
239
|
|
|
// @return |
240
|
|
|
function wfl_convertorderbyin( $orderby ) |
|
|
|
|
241
|
|
|
{ |
242
|
|
|
switch ( trim( $orderby ) ) { |
243
|
|
|
case "titleA": |
244
|
|
|
$orderby = "title ASC"; |
245
|
|
|
break; |
246
|
|
|
case "dateA": |
247
|
|
|
$orderby = "published ASC"; |
248
|
|
|
break; |
249
|
|
|
case "hitsA": |
250
|
|
|
$orderby = "hits ASC"; |
251
|
|
|
break; |
252
|
|
|
case "ratingA": |
253
|
|
|
$orderby = "rating ASC"; |
254
|
|
|
break; |
255
|
|
|
case "countryA": |
256
|
|
|
$orderby = "country ASC"; |
257
|
|
|
break; |
258
|
|
|
case "titleD": |
259
|
|
|
$orderby = "title DESC"; |
260
|
|
|
break; |
261
|
|
|
case "hitsD": |
262
|
|
|
$orderby = "hits DESC"; |
263
|
|
|
break; |
264
|
|
|
case "ratingD": |
265
|
|
|
$orderby = "rating DESC"; |
266
|
|
|
break; |
267
|
|
|
case"dateD": |
|
|
|
|
268
|
|
|
$orderby = "published DESC"; |
269
|
|
|
break; |
270
|
|
|
case "countryD": |
271
|
|
|
$orderby = "country DESC"; |
272
|
|
|
break; |
273
|
|
|
} |
274
|
|
|
|
275
|
|
|
return $orderby; |
276
|
|
|
} |
277
|
|
|
} |
278
|
|
|
if ( !function_exists( 'wfl_convertorderbytrans' ) ) { |
279
|
|
|
function wfl_convertorderbytrans( $orderby ) |
280
|
|
|
{ |
281
|
|
|
if ( $orderby == "hits ASC" ) $orderbyTrans = _MD_WFL_POPULARITYLTOM; |
282
|
|
|
if ( $orderby == "hits DESC" ) $orderbyTrans = _MD_WFL_POPULARITYMTOL; |
283
|
|
|
if ( $orderby == "title ASC" ) $orderbyTrans = _MD_WFL_TITLEATOZ; |
284
|
|
|
if ( $orderby == "title DESC" ) $orderbyTrans = _MD_WFL_TITLEZTOA; |
285
|
|
|
if ( $orderby == "published ASC" ) $orderbyTrans = _MD_WFL_DATEOLD; |
286
|
|
|
if ( $orderby == "published DESC" ) $orderbyTrans = _MD_WFL_DATENEW; |
287
|
|
|
if ( $orderby == "rating ASC" ) $orderbyTrans = _MD_WFL_RATINGLTOH; |
288
|
|
|
if ( $orderby == "rating DESC" ) $orderbyTrans = _MD_WFL_RATINGHTOL; |
289
|
|
|
if ( $orderby == "country ASC" ) $orderbyTrans = _MD_WFL_COUNTRYLTOH; |
290
|
|
|
if ( $orderby == "country DESC" ) $orderbyTrans = _MD_WFL_COUNTRYHTOL; |
291
|
|
|
|
292
|
|
|
return $orderbyTrans; |
|
|
|
|
293
|
|
|
} |
294
|
|
|
} |
295
|
|
|
if ( !function_exists( 'wfl_convertorderbyout' ) ) { |
296
|
|
|
function wfl_convertorderbyout( $orderby ) |
|
|
|
|
297
|
|
|
{ |
298
|
|
|
if ( $orderby == "title ASC" ) $orderby = "titleA"; |
299
|
|
|
if ( $orderby == "published ASC" ) $orderby = "dateA"; |
300
|
|
|
if ( $orderby == "hits ASC" ) $orderby = "hitsA"; |
301
|
|
|
if ( $orderby == "rating ASC" ) $orderby = "ratingA"; |
302
|
|
|
if ( $orderby == "country ASC" ) $orderby = "countryA"; |
303
|
|
|
if ( $orderby == "weight ASC" ) $orderby = "weightA"; |
304
|
|
|
if ( $orderby == "title DESC" ) $orderby = "titleD"; |
305
|
|
|
if ( $orderby == "published DESC" ) $orderby = "dateD"; |
306
|
|
|
if ( $orderby == "hits DESC" ) $orderby = "hitsD"; |
307
|
|
|
if ( $orderby == "rating DESC" ) $orderby = "ratingD"; |
308
|
|
|
if ( $orderby == "country DESC" ) $orderby = "countryD"; |
309
|
|
|
|
310
|
|
|
return $orderby; |
311
|
|
|
} |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
// updaterating() |
315
|
|
|
// @param $sel_id |
316
|
|
|
// @return updates rating data in itemtable for a given item |
317
|
|
|
function wfl_updaterating( $sel_id ) |
318
|
|
|
{ |
319
|
|
|
global $xoopsDB; |
|
|
|
|
320
|
|
|
$query = "SELECT rating FROM " . $xoopsDB -> prefix( 'wflinks_votedata' ) . " WHERE lid=" . $sel_id; |
321
|
|
|
$voteresult = $xoopsDB -> query( $query ); |
322
|
|
|
$votesDB = $xoopsDB -> getRowsNum( $voteresult ); |
323
|
|
|
$totalrating = 0; |
324
|
|
|
while ( list( $rating ) = $xoopsDB -> fetchRow( $voteresult ) ) { |
325
|
|
|
$totalrating += $rating; |
326
|
|
|
} |
327
|
|
|
$finalrating = $totalrating / $votesDB; |
328
|
|
|
$finalrating = number_format( $finalrating, 4 ); |
329
|
|
|
$sql = sprintf( "UPDATE %s SET rating = %u, votes = %u WHERE lid = %u", $xoopsDB -> prefix( 'wflinks_links' ), $finalrating, $votesDB, $sel_id ); |
330
|
|
|
$xoopsDB -> query( $sql ); |
331
|
|
|
} |
332
|
|
|
|
333
|
|
|
// totalcategory() |
334
|
|
|
// @param integer $pid |
335
|
|
|
// @return |
336
|
|
|
function wfl_totalcategory( $pid = 0 ) |
337
|
|
|
{ |
338
|
|
|
global $xoopsDB; |
|
|
|
|
339
|
|
|
|
340
|
|
|
$sql = "SELECT cid FROM " . $xoopsDB -> prefix( 'wflinks_cat' ); |
341
|
|
|
if ($pid > 0) { |
342
|
|
|
$sql .= " WHERE pid=0"; |
343
|
|
|
} |
344
|
|
|
$result = $xoopsDB -> query( $sql ); |
345
|
|
|
$catlisting = 0; |
346
|
|
|
while ( list( $cid ) = $xoopsDB -> fetchRow( $result ) ) { |
347
|
|
|
if ( wfl_checkgroups( $cid ) ) { |
348
|
|
|
$catlisting++; |
349
|
|
|
} |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
return $catlisting; |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
// wfl_getTotalItems() |
356
|
|
|
// @param integer $sel_id |
357
|
|
|
// @param integer $get_child |
358
|
|
|
// @param integer $return_sql |
359
|
|
|
// @return |
360
|
|
|
function wfl_getTotalItems( $sel_id = 0, $get_child = 0, $return_sql = 0 ) |
361
|
|
|
{ |
362
|
|
|
global $xoopsDB, $mytree, $_check_array; |
|
|
|
|
363
|
|
|
|
364
|
|
|
if ($sel_id > 0) { |
365
|
|
|
$sql = "SELECT DISTINCT a.lid, a.cid, published FROM " . $xoopsDB -> prefix( 'wflinks_links' ) . " a LEFT JOIN " |
366
|
|
|
. $xoopsDB -> prefix( 'wflinks_altcat' ) . " b " |
367
|
|
|
. "ON b.lid=a.lid " |
368
|
|
|
. "WHERE published > 0 AND published <= " . time() |
369
|
|
|
. " AND (expired = 0 OR expired > " . time() . ") AND offline = 0 " |
370
|
|
|
. " AND (b.cid=a.cid OR (a.cid=" . $sel_id . " OR b.cid=" . $sel_id . ")) "; |
371
|
|
|
} else { |
372
|
|
|
$sql = "SELECT lid, cid, published from " . $xoopsDB -> prefix( 'wflinks_links' ) . " WHERE offline = 0 AND published > 0 AND published <= " . time() . " AND (expired = 0 OR expired > " . time() . ")"; |
373
|
|
|
} |
374
|
|
|
if ($return_sql == 1) { |
375
|
|
|
return $sql; |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
$count = 0; |
379
|
|
|
$published_date = 0; |
380
|
|
|
|
381
|
|
|
$arr = array(); |
|
|
|
|
382
|
|
|
$result = $xoopsDB -> query( $sql ); |
383
|
|
View Code Duplication |
while ( list( $lid, $cid, $published ) = $xoopsDB -> fetchRow( $result ) ) { |
|
|
|
|
384
|
|
|
if ( true == wfl_checkgroups() ) { |
385
|
|
|
$count++; |
386
|
|
|
$published_date = ( $published > $published_date ) ? $published : $published_date; |
387
|
|
|
} |
388
|
|
|
} |
389
|
|
|
|
390
|
|
|
$child_count = 0; |
391
|
|
|
if ($get_child == 1) { |
392
|
|
|
$arr = $mytree -> getAllChildId( $sel_id ); |
393
|
|
|
$size = count( $arr ); |
|
|
|
|
394
|
|
|
for ( $i = 0; $i < count( $arr ); ++$i ) { |
|
|
|
|
395
|
|
|
$query2 = "SELECT DISTINCT a.lid, a.cid, published FROM " . $xoopsDB -> prefix( 'wflinks_links' ) . " a LEFT JOIN " |
396
|
|
|
. $xoopsDB -> prefix( 'wflinks_altcat' ) . " b " |
397
|
|
|
. "ON b.lid=a.lid " |
398
|
|
|
. "WHERE published > 0 AND published <= " . time() |
399
|
|
|
. " AND (expired = 0 OR expired > " . time() . ") AND offline = 0 " |
400
|
|
|
. " AND (b.cid=a.cid OR (a.cid=" . $arr[$i] . " OR b.cid=" . $arr[$i] . ")) "; |
401
|
|
|
|
402
|
|
|
$result2 = $xoopsDB -> query( $query2 ); |
403
|
|
View Code Duplication |
while ( list( $lid, $published ) = $xoopsDB -> fetchRow( $result2 ) ) { |
|
|
|
|
404
|
|
|
if ($published == 0) { |
405
|
|
|
continue; |
406
|
|
|
} |
407
|
|
|
$published_date = ( $published > $published_date ) ? $published : $published_date; |
408
|
|
|
$child_count++; |
409
|
|
|
} |
410
|
|
|
} |
411
|
|
|
} |
412
|
|
|
$info['count'] = $count + $child_count; |
|
|
|
|
413
|
|
|
$info['published'] = $published_date; |
414
|
|
|
|
415
|
|
|
return $info; |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
function wfl_imageheader( $indeximage = '', $indexheading = '' ) |
419
|
|
|
{ |
420
|
|
|
global $xoopsDB, $xoopsModuleConfig; |
|
|
|
|
421
|
|
|
|
422
|
|
|
if ($indeximage == '') { |
423
|
|
|
$result = $xoopsDB -> query( "SELECT indeximage, indexheading FROM " . $xoopsDB -> prefix( 'wflinks_indexpage' ) ); |
424
|
|
|
list( $indeximage, $indexheading ) = $xoopsDB -> fetchrow( $result ); |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
$image = ''; |
428
|
|
|
if ( !empty( $indeximage ) ) { |
429
|
|
|
$image = wfl_displayimage( $indeximage, "'index.php'", $xoopsModuleConfig['mainimagedir'], $indexheading ); |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
return $image; |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
function wfl_displayimage( $image = '', $path = '', $imgsource = '', $alttext = '' ) |
436
|
|
|
{ |
437
|
|
|
global $xoopsConfig, $xoopsUser, $xoopsModule; |
|
|
|
|
438
|
|
|
|
439
|
|
|
$showimage = ''; |
440
|
|
|
// Check to see if link is given |
441
|
|
|
if ($path) { |
442
|
|
|
$showimage = "<a href=" . $path . ">"; |
443
|
|
|
} |
444
|
|
|
|
445
|
|
|
// checks to see if the file is valid else displays default blank image |
446
|
|
|
if ( !is_dir( XOOPS_ROOT_PATH . "/{$imgsource}/{$image}" ) && file_exists( XOOPS_ROOT_PATH . "/{$imgsource}/{$image}" ) ) { |
447
|
|
|
$showimage .= "<img src='" . XOOPS_URL . "/{$imgsource}/{$image}' border='0' alt='" . $alttext . "' /></a>"; |
448
|
|
|
} else { |
449
|
|
|
if ( $xoopsUser && $xoopsUser -> isAdmin( $xoopsModule -> getVar( 'mid' ) ) ) { |
450
|
|
|
$showimage .= "<img src='" . XOOPS_URL . "/modules/" . $xoopsModule -> getVar( 'dirname' ) . "/assets/images/brokenimg.gif' alt='" . _MD_WFL_ISADMINNOTICE . "' /></a>"; |
451
|
|
|
} else { |
452
|
|
|
$showimage .= "<img src='" . XOOPS_URL . "/modules/" . $xoopsModule -> getVar( 'dirname' ) . "/assets/images/blank.gif' alt='" . $alttext . "' /></a>"; |
453
|
|
|
} |
454
|
|
|
} |
455
|
|
|
clearstatcache(); |
456
|
|
|
|
457
|
|
|
return $showimage; |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
function wfl_letters() |
461
|
|
|
{ |
462
|
|
|
global $xoopsModule; |
|
|
|
|
463
|
|
|
|
464
|
|
|
$letterchoice = "<div>" . _MD_WFL_BROWSETOTOPIC . "</div>"; |
465
|
|
|
$letterchoice .= "[ "; |
466
|
|
|
$alphabet = array ( "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" ); |
467
|
|
|
$num = count( $alphabet ) - 1; |
468
|
|
|
$counter = 0; |
469
|
|
|
while ( list( , $ltr ) = each( $alphabet ) ) { |
470
|
|
|
$letterchoice .= "<a href='" . XOOPS_URL . "/modules/" . $xoopsModule -> getVar( 'dirname' ) . "/viewcat.php?list=$ltr'>$ltr</a>"; |
471
|
|
|
if ( $counter == round( $num / 2 ) ) |
472
|
|
|
$letterchoice .= " ]<br />[ "; |
473
|
|
|
elseif ( $counter != $num ) |
474
|
|
|
$letterchoice .= " | "; |
475
|
|
|
$counter++; |
476
|
|
|
} |
477
|
|
|
$letterchoice .= " ]"; |
478
|
|
|
|
479
|
|
|
return $letterchoice; |
480
|
|
|
} |
481
|
|
|
|
482
|
|
|
function wfl_isnewimage( $published ) |
483
|
|
|
{ |
484
|
|
|
global $xoopsModule, $xoopsDB; |
|
|
|
|
485
|
|
|
|
486
|
|
|
$oneday = ( time() - ( 86400 * 1 ) ); |
487
|
|
|
$threedays = ( time() - ( 86400 * 3 ) ); |
488
|
|
|
$week = ( time() - ( 86400 * 7 ) ); |
489
|
|
|
|
490
|
|
|
$path = "modules/" . $xoopsModule -> getVar( 'dirname' ) . "/assets/images/icon"; |
491
|
|
|
|
492
|
|
|
if ($published > 0 && $published < $week) { |
493
|
|
|
$indicator['image'] = "$path/linkload4.gif"; |
|
|
|
|
494
|
|
|
$indicator['alttext'] = _MD_WFL_NEWLAST; |
495
|
|
|
} elseif ($published >= $week && $published < $threedays) { |
496
|
|
|
$indicator['image'] = "$path/linkload3.gif"; |
|
|
|
|
497
|
|
|
$indicator['alttext'] = _MD_WFL_NEWTHIS; |
498
|
|
|
} elseif ($published >= $threedays && $published < $oneday) { |
499
|
|
|
$indicator['image'] = "$path/linkload2.gif"; |
|
|
|
|
500
|
|
|
$indicator['alttext'] = _MD_WFL_THREE; |
501
|
|
|
} elseif ($published >= $oneday) { |
502
|
|
|
$indicator['image'] = "$path/linkload1.gif"; |
|
|
|
|
503
|
|
|
$indicator['alttext'] = _MD_WFL_TODAY; |
504
|
|
|
} else { |
505
|
|
|
$indicator['image'] = "$path/linkload.gif"; |
|
|
|
|
506
|
|
|
$indicator['alttext'] = _MD_WFL_NO_FILES; |
507
|
|
|
} |
508
|
|
|
|
509
|
|
|
return $indicator; |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
function wfl_strrrchr( $haystack, $needle ) |
513
|
|
|
{ |
514
|
|
|
return substr( $haystack, 0, strpos( $haystack, $needle ) + 1 ); |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
function wfl_adminmenu( $header = '', $menu = '', $extra = '', $scount = 4 ) |
|
|
|
|
518
|
|
|
{ |
519
|
|
|
global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
|
|
|
520
|
|
|
|
521
|
|
|
$_named_url = xoops_getenv( 'PHP_SELF' ); |
522
|
|
|
if ( $_named_url ) |
523
|
|
|
$thispage = basename( $_named_url ); |
524
|
|
|
|
525
|
|
|
if ( file_exists( "../docs/" . $xoopsConfig['language'] . "/readme.html") ) { |
526
|
|
|
$docs = '<a href="../docs/' . $xoopsConfig['language'] . '/readme.html" target="_blank">' . _AM_WFL_DOCUMENTATION . '</a> |'; |
527
|
|
|
} elseif ( file_exists( "../docs/english/readme.html") ) { |
528
|
|
|
$docs = '<a href="../docs/english/readme.html" target="_blank">' . _AM_WFL_DOCUMENTATION . '</a> |'; |
529
|
|
|
} else { |
530
|
|
|
$docs = ''; |
531
|
|
|
} |
532
|
|
|
|
533
|
|
|
$op = ( isset( $_GET['op'] ) ) ? $op = "?op=" . $_GET['op'] : ''; |
534
|
|
|
|
535
|
|
|
echo "<h4 style='color: #2F5376;'>" . _AM_WFL_MODULE_NAME . "</h4>"; |
536
|
|
|
echo " |
537
|
|
|
<table width='100%' cellspacing='0' cellpadding='0' border='0' class='outer'>\n |
538
|
|
|
<tr>\n |
539
|
|
|
<td style='font-size: 10px; text-align: left; color: #2F5376; padding: 2px 6px; line-height: 18px;'>\n |
540
|
|
|
<a href='../admin/index.php'>" . _AM_WFL_BINDEX . "</a> | \n |
541
|
|
|
<a href='../index.php'>" . _AM_WFL_GOMODULE . "</a> | \n |
542
|
|
|
<a href='../../system/admin.php?fct=preferences&op=showmod&mod=" . $xoopsModule -> getVar( 'mid' ) . "'>" . _AM_WFL_PREFS . "</a> | \n |
543
|
|
|
<a href='../../system/admin.php?fct=modulesadmin&op=update&module=" . $xoopsModule -> getVar( 'dirname' ) . "'>" . _AM_WFL_BUPDATE . "</a> | \n |
544
|
|
|
<a href='../admin/permissions.php'>" . _AM_WFL_BPERMISSIONS . "</a> | \n |
545
|
|
|
<a href='../admin/myblocksadmin.php'>" . _AM_WFL_BLOCKADMIN . "</a> | \n |
546
|
|
|
".$docs." |
547
|
|
|
<a href='../admin/about.php'>" . _AM_WFL_ABOUT . "</a> \n |
548
|
|
|
</td>\n |
549
|
|
|
</tr>\n |
550
|
|
|
</table><br />\n |
551
|
|
|
"; |
552
|
|
|
|
553
|
|
|
if ( empty( $menu ) ) { |
554
|
|
|
// You can change this part to suit your own module. Defining this here will save you form having to do this each time. |
555
|
|
|
$menu = array( |
556
|
|
|
_AM_WFL_INDEXPAGE => "indexpage.php", |
557
|
|
|
_AM_WFL_MCATEGORY => "category.php", |
558
|
|
|
_AM_WFL_MLINKS => "main.php?op=edit", |
559
|
|
|
_AM_WFL_MUPLOADS => "upload.php", |
560
|
|
|
_AM_WFL_MVOTEDATA => "votedata.php", |
561
|
|
|
_AM_WFL_MLISTPINGTIMES => "main.php?op=pingtime", |
562
|
|
|
_AM_WFL_MCOMMENTS => "../../system/admin.php?module=" . $xoopsModule -> getVar( 'mid' ) . "&status=0&limit=100&fct=comments&selsubmit=Go", |
563
|
|
|
); |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
if ( !is_array( $menu ) ) { |
567
|
|
|
echo "<table width='100%' cellpadding= '2' cellspacing= '1' class='outer'>\n"; |
568
|
|
|
echo "<tr><td class ='even' align ='center'><b>" . _AM_WFL_NOMENUITEMS . "</b></td></tr></table><br />\n"; |
569
|
|
|
|
570
|
|
|
return false; |
571
|
|
|
} |
572
|
|
|
|
573
|
|
|
$oddnum = array( 1 => "1", 3 => "3", 5 => "5", 7 => "7", 9 => "9", 11 => "11", 13 => "13" ); |
574
|
|
|
// number of rows per menu |
575
|
|
|
$menurows = count( $menu ) / $scount; |
576
|
|
|
// total amount of rows to complete menu |
577
|
|
|
$menurow = ceil( $menurows ) * $scount; |
578
|
|
|
// actual number of menuitems per row |
579
|
|
|
$rowcount = $menurow / ceil( $menurows ); |
|
|
|
|
580
|
|
|
$count = 0; |
581
|
|
|
for ( $i = count( $menu ); $i < $menurow; ++$i ) { |
582
|
|
|
$tempArray = array( 1 => null ); |
583
|
|
|
$menu = array_merge( $menu, $tempArray ); |
584
|
|
|
$count++; |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
// Sets up the width of each menu cell |
588
|
|
|
$width = 100 / $scount; |
589
|
|
|
$width = ceil( $width ); |
590
|
|
|
|
591
|
|
|
$menucount = 0; |
592
|
|
|
$count = 0; |
593
|
|
|
|
594
|
|
|
// Menu table output |
595
|
|
|
echo "<table width='100%' cellpadding= '2' cellspacing= '1' class='outer'><tr>"; |
596
|
|
|
|
597
|
|
|
// Check to see if $menu is and array |
598
|
|
|
if ( is_array( $menu ) ) { |
599
|
|
|
$classcounts = 0; |
600
|
|
|
$classcol[0] = "even"; |
|
|
|
|
601
|
|
|
|
602
|
|
|
for ($i = 1; $i < $menurow; ++$i) { |
603
|
|
|
$classcounts++; |
604
|
|
|
if ($classcounts >= $scount) { |
605
|
|
|
if ($classcol[$i-1] == 'odd') { |
606
|
|
|
$classcol[$i] = ( $classcol[$i-1] == 'odd' && in_array( $classcounts, $oddnum ) ) ? "even" : "odd"; |
607
|
|
|
} else { |
608
|
|
|
$classcol[$i] = ( $classcol[$i-1] == 'even' && in_array( $classcounts, $oddnum ) ) ? "odd" : "even"; |
609
|
|
|
} |
610
|
|
|
$classcounts = 0; |
611
|
|
|
} else { |
612
|
|
|
$classcol[$i] = ( $classcol[$i-1] == 'even' ) ? "odd" : "even"; |
613
|
|
|
} |
614
|
|
|
} |
615
|
|
|
unset( $classcounts ); |
616
|
|
|
|
617
|
|
|
foreach ($menu as $menutitle => $menulink) { |
618
|
|
|
if ($thispage . $op == $menulink) { |
|
|
|
|
619
|
|
|
$classcol[$count] = "outer"; |
620
|
|
|
} |
621
|
|
|
echo "<td class='" . $classcol[$count] . "' style='text-align: center;' valign='middle' width='$width%'>"; |
622
|
|
|
if ( is_string( $menulink ) ) { |
623
|
|
|
echo "<a href='" . $menulink . "'><small>" . $menutitle . "</small></a></td>"; |
624
|
|
|
} else { |
625
|
|
|
echo " </td>"; |
626
|
|
|
} |
627
|
|
|
$menucount++; |
628
|
|
|
$count++; |
629
|
|
|
|
630
|
|
|
// Break menu cells to start a new row if $count > $scount |
631
|
|
|
if ($menucount >= $scount) { |
632
|
|
|
echo "</tr>"; |
633
|
|
|
$menucount = 0; |
634
|
|
|
} |
635
|
|
|
} |
636
|
|
|
echo "</table><br />"; |
637
|
|
|
unset( $count ); |
638
|
|
|
unset( $menucount ); |
639
|
|
|
} |
640
|
|
|
// ###### Output warn messages for security ###### |
641
|
|
|
if ( is_dir( XOOPS_ROOT_PATH . "/modules/" . $xoopsModule -> getVar( 'dirname' ) . "/update/" ) ) { |
642
|
|
|
xoops_error( sprintf( _AM_WFL_WARNINSTALL1, XOOPS_ROOT_PATH . '/modules/' . $xoopsModule -> getVar( 'dirname' ) . '/update/' ) ); |
643
|
|
|
echo '<br />'; |
644
|
|
|
} |
645
|
|
|
|
646
|
|
|
$_file = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule -> getVar( 'dirname' ) . "/update.php"; |
647
|
|
|
if ( file_exists( $_file ) ) { |
648
|
|
|
xoops_error( sprintf( _AM_WFL_WARNINSTALL2, XOOPS_ROOT_PATH . '/modules/' . $xoopsModule -> getVar( 'dirname' ) . '/update.php' ) ); |
649
|
|
|
echo '<br />'; |
650
|
|
|
} |
651
|
|
|
|
652
|
|
|
$path1 = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['mainimagedir']; |
653
|
|
|
if ( !is_dir( $path1 ) ) { |
654
|
|
|
xoops_error( sprintf( _AM_WFL_WARNINSTALL3, $path1 ) ); |
655
|
|
|
echo '<br />'; |
656
|
|
|
} |
657
|
|
|
if ( !is_writable( $path1 ) ) { |
658
|
|
|
xoops_error( sprintf( _AM_WFL_WARNINSTALL4, $path1 ) ); |
659
|
|
|
echo '<br />'; |
660
|
|
|
} |
661
|
|
|
|
662
|
|
|
$path1_t = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['mainimagedir'] . '/thumbs'; |
663
|
|
|
if ( !is_dir( $path1_t ) ) { |
664
|
|
|
xoops_error( sprintf( _AM_WFL_WARNINSTALL3, $path1_t ) ); |
665
|
|
|
echo '<br />'; |
666
|
|
|
} |
667
|
|
|
if ( !is_writable( $path1_t ) ) { |
668
|
|
|
xoops_error( sprintf( _AM_WFL_WARNINSTALL4, $path1_t ) ); |
669
|
|
|
echo '<br />'; |
670
|
|
|
} |
671
|
|
|
|
672
|
|
|
$path2 = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['screenshots']; |
673
|
|
|
if ( !is_dir( $path2 ) ) { |
674
|
|
|
xoops_error( sprintf( _AM_WFL_WARNINSTALL3, $path2 ) ); |
675
|
|
|
echo '<br />'; |
676
|
|
|
} |
677
|
|
|
if ( !is_writable( $path2 ) ) { |
678
|
|
|
xoops_error( sprintf( _AM_WFL_WARNINSTALL4, $path2 ) ); |
679
|
|
|
echo '<br />'; |
680
|
|
|
} |
681
|
|
|
|
682
|
|
|
$path2_t = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['screenshots'] . '/thumbs'; |
683
|
|
|
if ( !is_dir( $path2_t ) ) { |
684
|
|
|
xoops_error( sprintf( _AM_WFL_WARNINSTALL3, $path2_t ) ); |
685
|
|
|
echo '<br />'; |
686
|
|
|
} |
687
|
|
|
if ( !is_writable( $path2_t ) ) { |
688
|
|
|
xoops_error( sprintf( _AM_WFL_WARNINSTALL4, $path2_t ) ); |
689
|
|
|
echo '<br />'; |
690
|
|
|
} |
691
|
|
|
|
692
|
|
|
$path3 = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['catimage']; |
693
|
|
|
if ( !is_dir( $path3 ) ) { |
694
|
|
|
xoops_error( sprintf( _AM_WFL_WARNINSTALL3, $path3 ) ); |
695
|
|
|
echo '<br />'; |
696
|
|
|
} |
697
|
|
|
if ( !is_writable( $path3 ) ) { |
698
|
|
|
xoops_error( sprintf( _AM_WFL_WARNINSTALL4, $path3 ) ); |
699
|
|
|
echo '<br />'; |
700
|
|
|
} |
701
|
|
|
|
702
|
|
|
$path3_t = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['catimage'] . '/thumbs'; |
703
|
|
|
if ( !is_dir( $path3_t ) ) { |
704
|
|
|
xoops_error( sprintf( _AM_WFL_WARNINSTALL3, $path3_t ) ); |
705
|
|
|
echo '<br />'; |
706
|
|
|
} |
707
|
|
|
if ( !is_writable( $path3_t ) ) { |
708
|
|
|
xoops_error( sprintf( _AM_WFL_WARNINSTALL4, $path3_t ) ); |
709
|
|
|
echo '<br />'; |
710
|
|
|
} |
711
|
|
|
|
712
|
|
|
echo "<h3 style='color: #2F5376;'>" . $header . "</h3>"; |
713
|
|
|
if ($extra) { |
714
|
|
|
echo "<div>$extra</div>"; |
715
|
|
|
} |
716
|
|
|
} |
717
|
|
|
|
718
|
|
|
function wfl_getDirSelectOption( $selected, $dirarray, $namearray ) |
|
|
|
|
719
|
|
|
{ |
720
|
|
|
echo "<select size='1' name='workd' onchange='location.href=\"upload.php?rootpath=\"+this.options[this.selectedIndex].value'>"; |
721
|
|
|
echo "<option value=''>--------------------------------------</option>"; |
722
|
|
|
foreach ($namearray as $namearray => $workd) { |
723
|
|
|
if ($workd === $selected) { |
724
|
|
|
$opt_selected = "selected"; |
725
|
|
|
} else { |
726
|
|
|
$opt_selected = ""; |
727
|
|
|
} |
728
|
|
|
echo "<option value='" . htmlspecialchars( $namearray, ENT_QUOTES ) . "' $opt_selected>" . $workd . "</option>"; |
729
|
|
|
} |
730
|
|
|
echo "</select>"; |
731
|
|
|
} |
732
|
|
|
|
733
|
|
|
function wfl_uploading( $FILES, $uploaddir = "uploads", $allowed_mimetypes = '', $redirecturl = "index.php", $num = 0, $redirect = 0, $usertype = 1 ) |
|
|
|
|
734
|
|
|
{ |
735
|
|
|
global $FILES, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; |
|
|
|
|
736
|
|
|
|
737
|
|
|
$down = array(); |
738
|
|
|
include_once XOOPS_ROOT_PATH . "/modules/" . $xoopsModule -> getVar( 'dirname' ) . "/class/uploader.php"; |
739
|
|
|
if ( empty( $allowed_mimetypes ) ) { |
740
|
|
|
$allowed_mimetypes = wfl_retmime( $FILES['userfile']['name'], $usertype ); |
741
|
|
|
} |
742
|
|
|
$upload_dir = XOOPS_ROOT_PATH . "/" . $uploaddir . "/"; |
743
|
|
|
|
744
|
|
|
$maxfilesize = $xoopsModuleConfig['maxfilesize']; |
745
|
|
|
$maxfilewidth = $xoopsModuleConfig['maximgwidth']; |
746
|
|
|
$maxfileheight = $xoopsModuleConfig['maximgheight']; |
747
|
|
|
|
748
|
|
|
$uploader = new XoopsMediaUploader( $upload_dir, $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight ); |
749
|
|
|
$uploader -> noAdminSizeCheck( 1 ); |
750
|
|
|
if ( $uploader -> fetchMedia( $_POST['xoops_upload_file'][0] ) ) { |
751
|
|
|
if ( !$uploader -> upload() ) { |
752
|
|
|
$errors = $uploader -> getErrors(); |
753
|
|
|
redirect_header( $redirecturl, 2, $errors ); |
754
|
|
|
} else { |
755
|
|
|
if ($redirect) { |
756
|
|
|
redirect_header( $redirecturl, 1 , _AM_PDD_UPLOADFILE ); |
757
|
|
|
} else { |
758
|
|
|
if ( is_file( $uploader -> savedDestination ) ) { |
759
|
|
|
$down['url'] = XOOPS_URL . "/" . $uploaddir . "/" . strtolower( $uploader -> savedFileName ); |
760
|
|
|
$down['size'] = filesize( XOOPS_ROOT_PATH . "/" . $uploaddir . "/" . strtolower( $uploader -> savedFileName ) ); |
761
|
|
|
} |
762
|
|
|
|
763
|
|
|
return $down; |
764
|
|
|
} |
765
|
|
|
} |
766
|
|
|
} else { |
767
|
|
|
$errors = $uploader -> getErrors(); |
768
|
|
|
redirect_header( $redirecturl, 1, $errors ); |
769
|
|
|
} |
770
|
|
|
} |
771
|
|
|
|
772
|
|
|
function wfl_getforum( $forumid ) |
|
|
|
|
773
|
|
|
{ |
774
|
|
|
global $xoopsDB, $xoopsConfig; |
|
|
|
|
775
|
|
|
|
776
|
|
|
echo "<select name='forumid'>"; |
777
|
|
|
echo "<option value='0'>----------------------</option>"; |
778
|
|
|
if ($forumid < 4) { |
779
|
|
|
$result = $xoopsDB -> query( "SELECT forum_name, forum_id FROM " . $xoopsDB -> prefix( "bb_forums" ) . " ORDER BY forum_id" ); |
780
|
|
|
} else { |
781
|
|
|
$result = $xoopsDB -> query( "SELECT forum_name, forum_id FROM " . $xoopsDB -> prefix( "bbex_forums" ) . " ORDER BY forum_id" ); |
782
|
|
|
} |
783
|
|
View Code Duplication |
while ( list( $forum_name, $forum_id ) = $xoopsDB -> fetchRow( $result ) ) { |
|
|
|
|
784
|
|
|
if ($forum_id == $forumid) { |
785
|
|
|
$opt_selected = "selected='selected'"; |
786
|
|
|
} else { |
787
|
|
|
$opt_selected = ""; |
788
|
|
|
} |
789
|
|
|
echo "<option value='" . $forum_id . "' $opt_selected>" . $forum_name . "</option>"; |
790
|
|
|
} |
791
|
|
|
echo "</select></div>"; |
792
|
|
|
|
793
|
|
|
return $forumid; |
794
|
|
|
} |
795
|
|
|
|
796
|
|
|
function wfl_linklistheader( $heading ) |
797
|
|
|
{ |
798
|
|
|
echo " |
799
|
|
|
<!-- <h4 style='font-weight: bold; color: #0A3760;'>" . $heading . "</h4>\n --> |
800
|
|
|
<table width='100%' cellspacing='1' class='outer' style='font-size: smaller;' summary>\n |
801
|
|
|
<tr>\n |
802
|
|
|
<th style='text-align: center;'>" . _AM_WFL_MINDEX_ID . "</th>\n |
803
|
|
|
<th style='text-align: left;'><b>" . _AM_WFL_MINDEX_TITLE . "</th>\n |
804
|
|
|
<th style='text-align: left;'><b>" . _AM_WFL_CATTITLE . "</th>\n |
805
|
|
|
<th style='text-align: center;'>" . _AM_WFL_MINDEX_POSTER . "</th>\n |
806
|
|
|
<th style='text-align: center;'>" . _AM_WFL_MINDEX_PUBLISH . "</th>\n |
807
|
|
|
<th style='text-align: center;'>" . _AM_WFL_MINDEX_EXPIRE . "</th>\n |
808
|
|
|
<th style='text-align: center;'>" . _AM_WFL_MINDEX_ONLINE . "</th>\n |
809
|
|
|
<th style='text-align: center;'>" . _AM_WFL_MINDEX_ACTION . "</th>\n |
810
|
|
|
</tr>\n |
811
|
|
|
"; |
812
|
|
|
} |
813
|
|
|
|
814
|
|
|
function wfl_linklistbody( $published ) |
815
|
|
|
{ |
816
|
|
|
global $wfmyts, $imagearray, $xoopsModuleConfig, $xoopsModule; |
|
|
|
|
817
|
|
|
xoops_load('XoopsUserUtility'); |
818
|
|
|
$lid = $published['lid']; |
819
|
|
|
$cid = $published['cid']; |
820
|
|
|
|
821
|
|
|
$title = "<a href='../singlelink.php?cid=" . $published['cid'] . "&lid=" . $published['lid'] . "'>" . $wfmyts -> htmlSpecialCharsStrip( trim( $published['title'] ) ) . "</a>";; |
822
|
|
|
$maintitle = urlencode( $wfmyts -> htmlSpecialChars( trim( $published['title'] ) ) ); |
|
|
|
|
823
|
|
|
$cattitle = wfl_cattitle($published['cid']); |
824
|
|
|
$submitter = XoopsUserUtility::getUnameFromId( $published['submitter'] ); |
825
|
|
|
$hwhoisurl = str_replace( 'http://', '', $published['url']); |
826
|
|
|
$submitted = formatTimestamp( $published['date'], $xoopsModuleConfig['dateformat'] ); |
|
|
|
|
827
|
|
|
$publish = ( $published['published'] > 0 ) ? formatTimestamp( $published['published'], $xoopsModuleConfig['dateformatadmin'] ): 'Not Published'; |
828
|
|
|
$expires = $published['expired'] ? formatTimestamp( $published['expired'], $xoopsModuleConfig['dateformatadmin'] ): _AM_WFL_MINDEX_NOTSET; |
829
|
|
|
// if ( ( $published['published'] && $published['published'] < time() ) && $published['offline'] == 0 ) { |
|
|
|
|
830
|
|
|
// $published_status = $imagearray['online']; |
831
|
|
|
// } else { |
832
|
|
|
// $published_status = ( $published['published'] == 0 ) ? "<a href='newlinks.php'>" . $imagearray['offline'] . "</a>" : $imagearray['offline']; |
833
|
|
|
// } |
834
|
|
|
if ( (( $published['expired'] && $published['expired'] > time() ) OR $published['expired']==0)&& ( $published['published'] && $published['published'] < time() ) && $published['offline'] == 0 ) { |
|
|
|
|
835
|
|
|
$published_status = $imagearray['online']; |
836
|
|
|
} elseif (( $published['expired'] && $published['expired'] < time() ) && $published['offline'] == 0) { |
837
|
|
|
$published_status = $imagearray['expired']; |
838
|
|
|
} else { |
839
|
|
|
$published_status = ( $published['published'] == 0 ) ? "<a href='newlinks.php'>" . $imagearray['offline'] . "</a>" : $imagearray['offline']; |
840
|
|
|
} |
841
|
|
|
$icon = "<a href='main.php?op=edit&lid=" . $lid . "' title='" . _AM_WFL_ICO_EDIT . "'>" . $imagearray['editimg'] . "</a> "; |
842
|
|
|
$icon .= "<a href='main.php?op=delete&lid=" . $lid . "' title='" . _AM_WFL_ICO_DELETE . "'>" . $imagearray['deleteimg'] . "</a> "; |
843
|
|
|
$icon .= "<a href='altcat.php?op=main&cid=" . $cid . "&lid=" . $lid . "&title=" . $wfmyts -> htmlSpecialCharsStrip( trim( $published['title'] ) ) . "' title='" . _AM_WFL_ALTCAT_CREATEF . "'>" . $imagearray['altcat'] . "</a> "; |
844
|
|
|
$icon .= '<a href="http://whois.domaintools.com/' . $hwhoisurl . '" target="_blank"><img src="' . XOOPS_URL . '/modules/' . $xoopsModule -> getVar( 'dirname' ) . '/assets/images/icon/domaintools.png" alt="WHOIS" title="WHOIS" align="absmiddle"/></a>'; |
845
|
|
|
|
846
|
|
|
echo " |
847
|
|
|
<tr style='text-align: center;'>\n |
848
|
|
|
<td class='head'><small>" . $lid . "</small></td>\n |
849
|
|
|
<td class='even' style='text-align: left;'><small>" . $title . "</small></td>\n |
850
|
|
|
<td class='even' style='text-align: left;'><small>" . $cattitle . "</small></td>\n |
851
|
|
|
<td class='even'><small>" . $submitter . "</small></td>\n |
852
|
|
|
<td class='even'><small>" . $publish . "</small></td>\n |
853
|
|
|
<td class='even'><small>" . $expires . "</small></td>\n |
854
|
|
|
<td class='even' width='4%'>" . $published_status . "</td>\n |
855
|
|
|
<td class='even' style='text-align: center; width: 6%; white-space: nowrap;'>$icon</td>\n |
856
|
|
|
</tr>\n |
857
|
|
|
"; |
858
|
|
|
unset( $published ); |
859
|
|
|
} |
860
|
|
|
|
861
|
|
|
function wfl_cattitle($catt) |
|
|
|
|
862
|
|
|
{ |
863
|
|
|
global $xoopsDB; |
|
|
|
|
864
|
|
|
$sql = "SELECT title FROM " . $xoopsDB -> prefix( 'wflinks_cat' ) . " WHERE cid=" . $catt; |
865
|
|
|
$result = $xoopsDB -> query( $sql ); |
866
|
|
|
$result = $xoopsDB -> fetchArray( $result ); |
867
|
|
|
|
868
|
|
|
return $result['title']; |
869
|
|
|
} |
870
|
|
|
|
871
|
|
|
function wfl_linklistfooter() |
872
|
|
|
{ |
873
|
|
|
echo "<tr style='text-align: center;'>\n<td class='head' colspan='7'>" . _AM_WFL_MINDEX_NOLINKSFOUND . "</td>\n</tr>\n"; |
874
|
|
|
} |
875
|
|
|
|
876
|
|
View Code Duplication |
function wfl_linklistpagenav( $pubrowamount, $start, $art = "art", $_this = '' ) |
|
|
|
|
877
|
|
|
{ |
878
|
|
|
global $xoopsModuleConfig; |
|
|
|
|
879
|
|
|
echo "</table>\n"; |
880
|
|
|
if ( ( $pubrowamount < $xoopsModuleConfig['admin_perpage'] ) ) { |
881
|
|
|
return false; |
882
|
|
|
} |
883
|
|
|
// Display Page Nav if published is > total display pages amount. |
884
|
|
|
include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
885
|
|
|
// $page = ( $pubrowamount > $xoopsModuleConfig['admin_perpage'] ) ? _AM_WFL_MINDEX_PAGE : ''; |
|
|
|
|
886
|
|
|
$pagenav = new XoopsPageNav( $pubrowamount, $xoopsModuleConfig['admin_perpage'], $start, 'st' . $art, $_this ); |
887
|
|
|
echo '<div align="right" style="padding: 8px;">' . $pagenav -> renderNav() . '</div>'; |
888
|
|
|
} |
889
|
|
|
|
890
|
|
View Code Duplication |
function wfl_linklistpagenavleft( $pubrowamount, $start, $art = "art", $_this = '' ) |
|
|
|
|
891
|
|
|
{ |
892
|
|
|
global $xoopsModuleConfig; |
|
|
|
|
893
|
|
|
// echo "</table>\n"; |
894
|
|
|
if ( ( $pubrowamount < $xoopsModuleConfig['admin_perpage'] ) ) { |
895
|
|
|
return false; |
896
|
|
|
} |
897
|
|
|
// Display Page Nav if published is > total display pages amount. |
898
|
|
|
include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
899
|
|
|
// $page = ( $pubrowamount > $xoopsModuleConfig['admin_perpage'] ) ? _AM_WFL_MINDEX_PAGE : ''; |
|
|
|
|
900
|
|
|
$pagenav = new XoopsPageNav( $pubrowamount, $xoopsModuleConfig['admin_perpage'], $start, 'st' . $art, $_this ); |
901
|
|
|
echo '<div align="left" style="padding: 8px;">' . $pagenav -> renderNav() . '</div>'; |
902
|
|
|
} |
903
|
|
|
|
904
|
|
|
// Retreive an editor according to the module's option "form_options" |
905
|
|
|
function wfl_getWysiwygForm( $caption, $name, $value ) |
906
|
|
|
{ |
907
|
|
|
global $xoopsModuleConfig, $xoopsUser, $xoopsModule; |
|
|
|
|
908
|
|
|
|
909
|
|
|
$editor = false; |
910
|
|
|
$x22 = false; |
911
|
|
|
$xv = str_replace( 'XOOPS ', '', XOOPS_VERSION ); |
912
|
|
|
if ( substr( $xv, 2, 1 ) == '2') { |
913
|
|
|
$x22 = true; |
914
|
|
|
} |
915
|
|
|
$editor_configs = array(); |
916
|
|
|
$editor_configs["name"] = $name; |
917
|
|
|
$editor_configs["value"] = $value; |
918
|
|
|
$editor_configs["rows"] = 35; |
919
|
|
|
$editor_configs["cols"] = 60; |
920
|
|
|
$editor_configs["width"] = "100%"; |
921
|
|
|
$editor_configs["height"] = "400px"; |
922
|
|
|
|
923
|
|
|
$isadmin = ( ( is_object( $xoopsUser ) && !empty( $xoopsUser ) ) && $xoopsUser -> isAdmin( $xoopsModule -> mid() ) ) ? true : false; |
924
|
|
|
if ($isadmin == true) { |
|
|
|
|
925
|
|
|
$formuser = $xoopsModuleConfig['form_options']; |
926
|
|
|
} else { |
927
|
|
|
$formuser = $xoopsModuleConfig['form_optionsuser']; |
928
|
|
|
} |
929
|
|
|
|
930
|
|
|
switch ($formuser) { |
931
|
|
|
case "fck": |
932
|
|
|
if (!$x22) { |
933
|
|
|
if ( is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/fckeditor/formfckeditor.php")) { |
934
|
|
|
include_once(XOOPS_ROOT_PATH . "/class/xoopseditor/fckeditor/formfckeditor.php"); |
935
|
|
|
$editor = new XoopsFormFckeditor($editor_configs,true); |
936
|
|
|
} else { |
937
|
|
|
if ($dhtml) { |
|
|
|
|
938
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
939
|
|
|
} else { |
940
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
941
|
|
|
} |
942
|
|
|
} |
943
|
|
|
} else { |
944
|
|
|
$editor = new XoopsFormEditor($caption, "fckeditor", $editor_configs); |
945
|
|
|
} |
946
|
|
|
break; |
947
|
|
|
|
948
|
|
|
case "htmlarea": |
949
|
|
|
if (!$x22) { |
950
|
|
|
if ( is_readable(XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php")) { |
951
|
|
|
include_once(XOOPS_ROOT_PATH . "/class/htmlarea/formhtmlarea.php"); |
952
|
|
|
$editor = new XoopsFormHtmlarea($caption, $name, $value); |
953
|
|
|
} |
954
|
|
|
} else { |
955
|
|
|
$editor = new XoopsFormEditor($caption, "htmlarea", $editor_configs); |
956
|
|
|
} |
957
|
|
|
break; |
958
|
|
|
|
959
|
|
|
case "dhtml": |
960
|
|
|
if (!$x22) { |
961
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
962
|
|
|
} else { |
963
|
|
|
$editor = new XoopsFormEditor($caption, "dhtmltextarea", $editor_configs); |
964
|
|
|
} |
965
|
|
|
break; |
966
|
|
|
|
967
|
|
|
case "textarea": |
968
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value); |
969
|
|
|
break; |
970
|
|
|
|
971
|
|
View Code Duplication |
case "koivi": |
|
|
|
|
972
|
|
|
if (!$x22) { |
973
|
|
|
if ( is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/koivi/formwysiwygtextarea.php")) { |
974
|
|
|
include_once(XOOPS_ROOT_PATH . "/class/xoopseditor/koivi/formwysiwygtextarea.php"); |
975
|
|
|
$editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '400px'); |
976
|
|
|
} else { |
977
|
|
|
if ($dhtml) { |
978
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
979
|
|
|
} else { |
980
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
981
|
|
|
} |
982
|
|
|
} |
983
|
|
|
} else { |
984
|
|
|
$editor = new XoopsFormEditor($caption, "koivi", $editor_configs); |
985
|
|
|
} |
986
|
|
|
break; |
987
|
|
|
|
988
|
|
|
case "tinyeditor": |
989
|
|
|
if (!$x22) { |
990
|
|
|
if ( is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/tinyeditor/formtinyeditortextarea.php")) { |
991
|
|
|
include_once(XOOPS_ROOT_PATH . "/class/xoopseditor/tinyeditor/formtinyeditortextarea.php"); |
992
|
|
|
$editor = new XoopsFormTinyeditorTextArea(array('caption'=>$caption, 'name'=>$name, 'value'=>$value, 'width'=>'100%', 'height'=>'400px')); |
993
|
|
|
} else { |
994
|
|
|
if ($dhtml) { |
995
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 50, 60); |
996
|
|
|
} else { |
997
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
998
|
|
|
} |
999
|
|
|
} |
1000
|
|
|
} else { |
1001
|
|
|
$editor = new XoopsFormEditor($caption, "tinyeditor", $editor_configs); |
1002
|
|
|
} |
1003
|
|
|
break; |
1004
|
|
|
|
1005
|
|
View Code Duplication |
case "dhtmlext": |
|
|
|
|
1006
|
|
|
if (!$x22) { |
1007
|
|
|
if ( is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/dhtmlext/dhtmlext.php")) { |
1008
|
|
|
include_once(XOOPS_ROOT_PATH . "/class/xoopseditor/dhtmlext/dhtmlext.php"); |
1009
|
|
|
$editor = new XoopsFormDhtmlTextAreaExtended($caption, $name, $value, 10, 50); |
1010
|
|
|
} else { |
1011
|
|
|
if ($dhtml) { |
1012
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 50, 60); |
1013
|
|
|
} else { |
1014
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
1015
|
|
|
} |
1016
|
|
|
} |
1017
|
|
|
} else { |
1018
|
|
|
$editor = new XoopsFormEditor($caption, "dhtmlext", $editor_configs); |
1019
|
|
|
} |
1020
|
|
|
break; |
1021
|
|
|
|
1022
|
|
|
case 'tinymce' : |
|
|
|
|
1023
|
|
|
if (!$x22) { |
1024
|
|
|
if ( is_readable(XOOPS_ROOT_PATH . "/class/xoopseditor/tinymce/formtinymce.php")) { |
1025
|
|
|
include_once(XOOPS_ROOT_PATH . "/class/xoopseditor/tinymce/formtinymce.php"); |
1026
|
|
|
$editor = new XoopsFormTinymce(array('caption'=>$caption, 'name'=>$name, 'value'=>$value, 'width'=>'100%', 'height'=>'400px')); |
1027
|
|
|
} elseif ( is_readable(XOOPS_ROOT_PATH . "/editors/tinymce/formtinymce.php")) { |
1028
|
|
|
include_once(XOOPS_ROOT_PATH . "/editors/tinymce/formtinymce.php"); |
1029
|
|
|
$editor = new XoopsFormTinymce(array('caption'=>$caption, 'name'=>$name, 'value'=>$value, 'width'=>'100%', 'height'=>'400px')); |
1030
|
|
|
} else { |
1031
|
|
|
if ($dhtml) { |
1032
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
1033
|
|
|
} else { |
1034
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
1035
|
|
|
} |
1036
|
|
|
} |
1037
|
|
|
} else { |
1038
|
|
|
$editor = new XoopsFormEditor($caption, "tinymce", $editor_configs); |
1039
|
|
|
} |
1040
|
|
|
break; |
1041
|
|
|
} |
1042
|
|
|
|
1043
|
|
|
return $editor; |
1044
|
|
|
} |
1045
|
|
|
|
1046
|
|
|
function wfl_countryname($countryn) |
1047
|
|
|
{ |
1048
|
|
|
$country_array = array ( |
1049
|
|
|
"" => "Unknown", |
1050
|
|
|
"-" => "Unknown", |
1051
|
|
|
"AD" => "Andorra", |
1052
|
|
|
"AE" => "United Arab Emirates", |
1053
|
|
|
"AF" => "Afghanistan", |
1054
|
|
|
"AG" => "Antigua and Barbuda", |
1055
|
|
|
"AI" => "Anguilla", |
1056
|
|
|
"AL" => "Albania", |
1057
|
|
|
"AM" => "Armenia", |
1058
|
|
|
"AN" => "Netherlands Antilles", |
1059
|
|
|
"AO" => "Angola", |
1060
|
|
|
"AQ" => "Antarctica", |
1061
|
|
|
"AR" => "Argentina", |
1062
|
|
|
"AS" => "American Samoa", |
1063
|
|
|
"AT" => "Austria", |
1064
|
|
|
"AU" => "Australia", |
1065
|
|
|
"AW" => "Aruba", |
1066
|
|
|
"AX" => "Åland Islands", // Added |
1067
|
|
|
"AZ" => "Azerbaijan", |
1068
|
|
|
"BA" => "Bosnia and Herzegovina", |
1069
|
|
|
"BB" => "Barbados", |
1070
|
|
|
"BD" => "Bangladesh", |
1071
|
|
|
"BE" => "Belgium", |
1072
|
|
|
"BF" => "Burkina Faso", |
1073
|
|
|
"BG" => "Bulgaria", |
1074
|
|
|
"BH" => "Bahrain", |
1075
|
|
|
"BI" => "Burundi", |
1076
|
|
|
"BJ" => "Benin", |
1077
|
|
|
"BL" => "Saint Barthélemy", // Added |
1078
|
|
|
"BM" => "Bermuda", |
1079
|
|
|
"BN" => "Brunei Darussalam", |
1080
|
|
|
"BO" => "Bolivia", |
1081
|
|
|
"BR" => "Brazil", |
1082
|
|
|
"BS" => "Bahamas", |
1083
|
|
|
"BT" => "Bhutan", |
1084
|
|
|
"BV" => "Bouvet Island", |
1085
|
|
|
"BW" => "Botswana", |
1086
|
|
|
"BY" => "Belarus", |
1087
|
|
|
"BZ" => "Belize", |
1088
|
|
|
"CA" => "Canada", |
1089
|
|
|
"CC" => "Cocos (Keeling) Islands", |
1090
|
|
|
"CD" => "Congo (Dem. Rep.)", // Added |
1091
|
|
|
"CF" => "Central African Republic", |
1092
|
|
|
"CG" => "Congo", |
1093
|
|
|
"CH" => "Switzerland", |
1094
|
|
|
"CI" => "Cote D'Ivoire", // Removed: (Ivory Coast) |
1095
|
|
|
"CK" => "Cook Islands", |
1096
|
|
|
"CL" => "Chile", |
1097
|
|
|
"CM" => "Cameroon", |
1098
|
|
|
"CN" => "China", |
1099
|
|
|
"CO" => "Colombia", |
1100
|
|
|
"CR" => "Costa Rica", |
1101
|
|
|
"CS" => "Czechoslovakia (former)", // Not listed anymore |
1102
|
|
|
"CU" => "Cuba", |
1103
|
|
|
"CV" => "Cape Verde", |
1104
|
|
|
"CX" => "Christmas Island", |
1105
|
|
|
"CY" => "Cyprus", |
1106
|
|
|
"CZ" => "Czech Republic", |
1107
|
|
|
"DE" => "Germany", |
1108
|
|
|
"DJ" => "Djibouti", |
1109
|
|
|
"DK" => "Denmark", |
1110
|
|
|
"DM" => "Dominica", |
1111
|
|
|
"DO" => "Dominican Republic", |
1112
|
|
|
"DZ" => "Algeria", |
1113
|
|
|
"EC" => "Ecuador", |
1114
|
|
|
"EE" => "Estonia", |
1115
|
|
|
"EG" => "Egypt", |
1116
|
|
|
"EH" => "Western Sahara", |
1117
|
|
|
"ER" => "Eritrea", |
1118
|
|
|
"ES" => "Spain", |
1119
|
|
|
"EU" => "Europe", |
1120
|
|
|
"ET" => "Ethiopia", |
1121
|
|
|
"FI" => "Finland", |
1122
|
|
|
"FJ" => "Fiji", |
1123
|
|
|
"FK" => "Falkland Islands (Malvinas)", |
1124
|
|
|
"FM" => "Micronesia", |
1125
|
|
|
"FO" => "Faroe Islands", |
1126
|
|
|
"FR" => "France", |
1127
|
|
|
"FX" => "France, Metropolitan", // Not listed anymore |
1128
|
|
|
"GA" => "Gabon", |
1129
|
|
|
"GB" => "Great Britain", // Name was: Great Britain (UK) |
1130
|
|
|
"GD" => "Grenada", |
1131
|
|
|
"GE" => "Georgia", |
1132
|
|
|
"GF" => "French Guiana", |
1133
|
|
|
"GG" => "Guernsey", // Added |
1134
|
|
|
"GH" => "Ghana", |
1135
|
|
|
"GI" => "Gibraltar", |
1136
|
|
|
"GL" => "Greenland", |
1137
|
|
|
"GM" => "Gambia", |
1138
|
|
|
"GN" => "Guinea", |
1139
|
|
|
"GP" => "Guadeloupe", |
1140
|
|
|
"GQ" => "Equatorial Guinea", |
1141
|
|
|
"GR" => "Greece", |
1142
|
|
|
"GS" => "S. Georgia and S. Sandwich Isls.", |
1143
|
|
|
"GT" => "Guatemala", |
1144
|
|
|
"GU" => "Guam", |
1145
|
|
|
"GW" => "Guinea-Bissau", |
1146
|
|
|
"GY" => "Guyana", |
1147
|
|
|
"HK" => "Hong Kong", |
1148
|
|
|
"HM" => "Heard and McDonald Islands", |
1149
|
|
|
"HN" => "Honduras", |
1150
|
|
|
"HR" => "Croatia", |
1151
|
|
|
"HT" => "Haiti", |
1152
|
|
|
"HU" => "Hungary", |
1153
|
|
|
"ID" => "Indonesia", |
1154
|
|
|
"IE" => "Ireland", |
1155
|
|
|
"IL" => "Israel", |
1156
|
|
|
"IM" => "Isle of Man", // Added |
1157
|
|
|
"IN" => "India", |
1158
|
|
|
"IO" => "British Indian Ocean Territory", |
1159
|
|
|
"IQ" => "Iraq", |
1160
|
|
|
"IR" => "Iran", // Changed name |
1161
|
|
|
"IS" => "Iceland", |
1162
|
|
|
"IT" => "Italy", |
1163
|
|
|
"JE" => "Jersey", |
1164
|
|
|
"JM" => "Jamaica", |
1165
|
|
|
"JO" => "Jordan", |
1166
|
|
|
"JP" => "Japan", |
1167
|
|
|
"KE" => "Kenya", |
1168
|
|
|
"KG" => "Kyrgyzstan", |
1169
|
|
|
"KH" => "Cambodia", |
1170
|
|
|
"KI" => "Kiribati", |
1171
|
|
|
"KM" => "Comoros", |
1172
|
|
|
"KN" => "Saint Kitts and Nevis", |
1173
|
|
|
"KP" => "Korea (North)", // Official name: Korea, Democratic People's Republic of |
1174
|
|
|
"KR" => "Korea (South)", // Official name: Korea, Republic of |
1175
|
|
|
"KW" => "Kuwait", |
1176
|
|
|
"KY" => "Cayman Islands", |
1177
|
|
|
"KZ" => "Kazakhstan", |
1178
|
|
|
"LA" => "Laos", // Official name: Lao People's Democratic Republic |
1179
|
|
|
"LB" => "Lebanon", |
1180
|
|
|
"LC" => "Saint Lucia", |
1181
|
|
|
"LI" => "Liechtenstein", |
1182
|
|
|
"LK" => "Sri Lanka", |
1183
|
|
|
"LR" => "Liberia", |
1184
|
|
|
"LS" => "Lesotho", |
1185
|
|
|
"LT" => "Lithuania", |
1186
|
|
|
"LU" => "Luxembourg", |
1187
|
|
|
"LV" => "Latvia", |
1188
|
|
|
"LY" => "Libya", // Official name: Libyan Arab Jamahiriya |
1189
|
|
|
"MA" => "Morocco", |
1190
|
|
|
"MC" => "Monaco", |
1191
|
|
|
"MD" => "Moldova", // Official name: Moldova, Republic of |
1192
|
|
|
"ME" => "Montenegro", // Added |
1193
|
|
|
"MF" => "Saint Martin", // Added |
1194
|
|
|
"MG" => "Madagascar", |
1195
|
|
|
"MH" => "Marshall Islands", |
1196
|
|
|
"MK" => "Macedonia", // Official name: Macedonia, The Former Yugoslav Republic of |
1197
|
|
|
"ML" => "Mali", |
1198
|
|
|
"MM" => "Myanmar", |
1199
|
|
|
"MN" => "Mongolia", |
1200
|
|
|
"MO" => "Macao", // Corrected name |
1201
|
|
|
"MP" => "Northern Mariana Islands", |
1202
|
|
|
"MQ" => "Martinique", |
1203
|
|
|
"MR" => "Mauritania", |
1204
|
|
|
"MS" => "Montserrat", |
1205
|
|
|
"MT" => "Malta", |
1206
|
|
|
"MU" => "Mauritius", |
1207
|
|
|
"MV" => "Maldives", |
1208
|
|
|
"MW" => "Malawi", |
1209
|
|
|
"MX" => "Mexico", |
1210
|
|
|
"MY" => "Malaysia", |
1211
|
|
|
"MZ" => "Mozambique", |
1212
|
|
|
"NA" => "Namibia", |
1213
|
|
|
"NC" => "New Caledonia", |
1214
|
|
|
"NE" => "Niger", |
1215
|
|
|
"NF" => "Norfolk Island", |
1216
|
|
|
"NG" => "Nigeria", |
1217
|
|
|
"NI" => "Nicaragua", |
1218
|
|
|
"NL" => "Netherlands", |
1219
|
|
|
"NO" => "Norway", |
1220
|
|
|
"NP" => "Nepal", |
1221
|
|
|
"NR" => "Nauru", |
1222
|
|
|
"NT" => "Neutral Zone", |
1223
|
|
|
"NU" => "Niue", |
1224
|
|
|
"NZ" => "New Zealand", |
1225
|
|
|
"OM" => "Oman", |
1226
|
|
|
"PA" => "Panama", |
1227
|
|
|
"PE" => "Peru", |
1228
|
|
|
"PF" => "French Polynesia", |
1229
|
|
|
"PG" => "Papua New Guinea", |
1230
|
|
|
"PH" => "Philippines", |
1231
|
|
|
"PK" => "Pakistan", |
1232
|
|
|
"PL" => "Poland", |
1233
|
|
|
"PM" => "St. Pierre and Miquelon", |
1234
|
|
|
"PN" => "Pitcairn", |
1235
|
|
|
"PR" => "Puerto Rico", |
1236
|
|
|
"PS" => "Palestinian Territory, Occupied", // Added |
1237
|
|
|
"PT" => "Portugal", |
1238
|
|
|
"PW" => "Palau", |
1239
|
|
|
"PY" => "Paraguay", |
1240
|
|
|
"QA" => "Qatar", |
1241
|
|
|
"RE" => "Reunion", |
1242
|
|
|
"RO" => "Romania", |
1243
|
|
|
"RS" => "Serbia", // Added |
1244
|
|
|
"RU" => "Russian Federation", |
1245
|
|
|
"RW" => "Rwanda", |
1246
|
|
|
"SA" => "Saudi Arabia", |
1247
|
|
|
"SB" => "Solomon Islands", |
1248
|
|
|
"SC" => "Seychelles", |
1249
|
|
|
"SD" => "Sudan", |
1250
|
|
|
"SE" => "Sweden", |
1251
|
|
|
"SG" => "Singapore", |
1252
|
|
|
"SH" => "St. Helena", |
1253
|
|
|
"SI" => "Slovenia", |
1254
|
|
|
"SJ" => "Svalbard and Jan Mayen Islands", |
1255
|
|
|
"SK" => "Slovakia", // Changed name, was: Slovak Republic |
1256
|
|
|
"SL" => "Sierra Leone", |
1257
|
|
|
"SM" => "San Marino", |
1258
|
|
|
"SN" => "Senegal", |
1259
|
|
|
"SO" => "Somalia", |
1260
|
|
|
"SR" => "Suriname", |
1261
|
|
|
"ST" => "Sao Tome and Principe", |
1262
|
|
|
"SU" => "USSR (former)", // Removed from ISO list, doesn' exsist anymore |
1263
|
|
|
"SV" => "El Salvador", |
1264
|
|
|
"SY" => "Syrian Arab Republic", // Changed name, was: Syria |
1265
|
|
|
"SZ" => "Swaziland", |
1266
|
|
|
"TC" => "Turks and Caicos Islands", |
1267
|
|
|
"TD" => "Chad", |
1268
|
|
|
"TF" => "French Southern Territories", |
1269
|
|
|
"TG" => "Togo", |
1270
|
|
|
"TH" => "Thailand", |
1271
|
|
|
"TJ" => "Tajikistan", |
1272
|
|
|
"TK" => "Tokelau", |
1273
|
|
|
"TL" => "Timor-Leste", // Added |
1274
|
|
|
"TM" => "Turkmenistan", |
1275
|
|
|
"TN" => "Tunisia", |
1276
|
|
|
"TO" => "Tonga", |
1277
|
|
|
"TP" => "East Timor", // Removed from ISO list, doesn' exsist anymore |
1278
|
|
|
"TR" => "Turkey", |
1279
|
|
|
"TT" => "Trinidad and Tobago", |
1280
|
|
|
"TV" => "Tuvalu", |
1281
|
|
|
"TW" => "Taiwan", // Official name acc. to iso-list: Taiwan, Province of China |
1282
|
|
|
"TZ" => "Tanzania", |
1283
|
|
|
"UA" => "Ukraine", |
1284
|
|
|
"UG" => "Uganda", |
1285
|
|
|
"UK" => "United Kingdom", // Doesn't exsist in iso-list ? |
1286
|
|
|
"UM" => "US Minor Outlying Islands", |
1287
|
|
|
"US" => "United States", |
1288
|
|
|
"UY" => "Uruguay", |
1289
|
|
|
"UZ" => "Uzbekistan", |
1290
|
|
|
"VA" => "Vatican City State", |
1291
|
|
|
"VC" => "Saint Vincent and the Grenadines", |
1292
|
|
|
"VE" => "Venezuela", |
1293
|
|
|
"VG" => "Virgin Islands, British", |
1294
|
|
|
"VI" => "Virgin Islands, U.S.", |
1295
|
|
|
"VN" => "Viet Nam", |
1296
|
|
|
"VU" => "Vanuatu", |
1297
|
|
|
"WF" => "Wallis and Futuna Islands", |
1298
|
|
|
"WS" => "Samoa", |
1299
|
|
|
"YE" => "Yemen", |
1300
|
|
|
"YT" => "Mayotte", |
1301
|
|
|
"YU" => "Yugoslavia", // Removed from iso list |
1302
|
|
|
"ZA" => "South Africa", |
1303
|
|
|
"ZM" => "Zambia", |
1304
|
|
|
"ZR" => "Zaire", // Removed from iso list |
1305
|
|
|
"ZW" => "Zimbabwe" |
1306
|
|
|
); |
1307
|
|
|
|
1308
|
|
|
return $country_array[$countryn]; |
1309
|
|
|
} |
1310
|
|
|
|
1311
|
|
|
function wfl_html2text($document) |
|
|
|
|
1312
|
|
|
{ |
1313
|
|
|
$search = array ( |
1314
|
|
|
"'<script[^>]*?>.*?</script>'si", // Strip out javascript |
1315
|
|
|
"'<img.*?/>'si", // Strip out img tags |
1316
|
|
|
"'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
1317
|
|
|
"'([\r\n])[\s]+'", // Strip out white space |
1318
|
|
|
"'&(quot|#34);'i", // Replace HTML entities |
1319
|
|
|
"'&(amp|#38);'i", |
1320
|
|
|
"'&(lt|#60);'i", |
1321
|
|
|
"'&(gt|#62);'i", |
1322
|
|
|
"'&(nbsp|#160);'i", |
1323
|
|
|
"'&(iexcl|#161);'i", |
1324
|
|
|
"'&(cent|#162);'i", |
1325
|
|
|
"'&(pound|#163);'i", |
1326
|
|
|
"'&(copy|#169);'i", |
1327
|
|
|
//"'&#(\d+);'e" // evaluate as php |
1328
|
|
|
); |
1329
|
|
|
|
1330
|
|
|
$replace = array ( |
1331
|
|
|
"", |
1332
|
|
|
"", |
1333
|
|
|
"", |
1334
|
|
|
"\\1", |
1335
|
|
|
"\"", |
1336
|
|
|
"&", |
1337
|
|
|
"<", |
1338
|
|
|
">", |
1339
|
|
|
" ", |
1340
|
|
|
chr(161), |
1341
|
|
|
chr(162), |
1342
|
|
|
chr(163), |
1343
|
|
|
chr(169), |
1344
|
|
|
//"chr(\\1)" |
1345
|
|
|
); |
1346
|
|
|
|
1347
|
|
|
$text = preg_replace($search, $replace, $document); |
1348
|
|
|
|
1349
|
|
|
return $text; |
1350
|
|
|
} |
1351
|
|
|
|
1352
|
|
|
// Start functions for Google PageRank |
1353
|
|
|
// Source: http://www.sws-tech.com/scripts/googlepagerank.php |
1354
|
|
|
// This code is released under the public domain |
1355
|
|
|
function zeroFill($a, $b) |
1356
|
|
|
{ |
1357
|
|
|
$z = hexdec(80000000); |
1358
|
|
|
//echo $z; |
1359
|
|
|
if ($z & $a) { |
1360
|
|
|
$a = ($a>>1); |
1361
|
|
|
$a &= (~$z); |
1362
|
|
|
$a |= 0x40000000; |
1363
|
|
|
$a = ($a>>($b-1)); |
1364
|
|
|
} else { |
1365
|
|
|
$a = ($a>>$b); |
1366
|
|
|
} |
1367
|
|
|
|
1368
|
|
|
return $a; |
1369
|
|
|
} |
1370
|
|
|
|
1371
|
|
|
function mix($a,$b,$c) |
1372
|
|
|
{ |
1373
|
|
|
$a -= $b; $a -= $c; $a ^= (zeroFill($c,13)); |
1374
|
|
|
$b -= $c; $b -= $a; $b ^= ($a<<8); |
1375
|
|
|
$c -= $a; $c -= $b; $c ^= (zeroFill($b,13)); |
1376
|
|
|
$a -= $b; $a -= $c; $a ^= (zeroFill($c,12)); |
1377
|
|
|
$b -= $c; $b -= $a; $b ^= ($a<<16); |
1378
|
|
|
$c -= $a; $c -= $b; $c ^= (zeroFill($b,5)); |
1379
|
|
|
$a -= $b; $a -= $c; $a ^= (zeroFill($c,3)); |
1380
|
|
|
$b -= $c; $b -= $a; $b ^= ($a<<10); |
1381
|
|
|
$c -= $a; $c -= $b; $c ^= (zeroFill($b,15)); |
1382
|
|
|
|
1383
|
|
|
return array($a,$b,$c); |
1384
|
|
|
} |
1385
|
|
|
|
1386
|
|
|
function GoogleCH($url, $length=null, $init=0xE6359A60) |
1387
|
|
|
{ |
1388
|
|
|
if (is_null($length)) { |
1389
|
|
|
$length = sizeof($url); |
1390
|
|
|
} |
1391
|
|
|
$a = $b = 0x9E3779B9; |
1392
|
|
|
$c = $init; |
1393
|
|
|
$k = 0; |
1394
|
|
|
$len = $length; |
1395
|
|
|
while ($len >= 12) { |
1396
|
|
|
$a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24)); |
1397
|
|
|
$b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24)); |
1398
|
|
|
$c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24)); |
1399
|
|
|
$mix = mix($a,$b,$c); |
1400
|
|
|
$a = $mix[0]; $b = $mix[1]; $c = $mix[2]; |
1401
|
|
|
$k += 12; |
1402
|
|
|
$len -= 12; |
1403
|
|
|
} |
1404
|
|
|
$c += $length; |
1405
|
|
|
switch ($len) { /* all the case statements fall through */ |
1406
|
|
|
case 11: $c+=($url[$k+10]<<24); |
|
|
|
|
1407
|
|
|
case 10: $c+=($url[$k+9]<<16); |
|
|
|
|
1408
|
|
|
case 9 : $c+=($url[$k+8]<<8); |
|
|
|
|
1409
|
|
|
/* the first byte of c is reserved for the length */ |
1410
|
|
|
case 8 : $b+=($url[$k+7]<<24); |
|
|
|
|
1411
|
|
|
case 7 : $b+=($url[$k+6]<<16); |
|
|
|
|
1412
|
|
|
case 6 : $b+=($url[$k+5]<<8); |
|
|
|
|
1413
|
|
|
case 5 : $b+=($url[$k+4]); |
|
|
|
|
1414
|
|
|
case 4 : $a+=($url[$k+3]<<24); |
|
|
|
|
1415
|
|
|
case 3 : $a+=($url[$k+2]<<16); |
|
|
|
|
1416
|
|
|
case 2 : $a+=($url[$k+1]<<8); |
|
|
|
|
1417
|
|
|
case 1 : $a+=($url[$k+0]); |
|
|
|
|
1418
|
|
|
/* case 0: nothing left to add */ |
1419
|
|
|
} |
1420
|
|
|
$mix = mix($a,$b,$c); |
1421
|
|
|
//echo $mix[0]; |
|
|
|
|
1422
|
|
|
/*-------------------------------------------- report the result */ |
1423
|
|
|
|
1424
|
|
|
return $mix[2]; |
1425
|
|
|
} |
1426
|
|
|
//converts a string into an array of integers containing the numeric value of the char |
1427
|
|
|
function strord($string) |
1428
|
|
|
{ |
1429
|
|
|
for ($i=0; $i<strlen($string); ++$i) { |
1430
|
|
|
$result[$i] = ord($string{$i}); |
|
|
|
|
1431
|
|
|
} |
1432
|
|
|
|
1433
|
|
|
return $result; |
|
|
|
|
1434
|
|
|
} |
1435
|
|
|
|
1436
|
|
|
function pagerank($url) |
1437
|
|
|
{ |
1438
|
|
|
$pagerank = ''; |
1439
|
|
|
$ch = "6" . GoogleCH(strord("info:" . $url)); |
1440
|
|
|
$fp = fsockopen("www.google.com", 80, $errno, $errstr, 30); |
1441
|
|
|
if (!$fp) { |
1442
|
|
|
echo "$errstr ($errno)<br />\n"; |
1443
|
|
|
} else { |
1444
|
|
|
$out = "GET /search?client=navclient-auto&ch=". $ch . "&features=Rank&q=info:" . $url . " HTTP/1.1\r\n"; |
1445
|
|
|
$out .= "Host: www.google.com\r\n"; |
1446
|
|
|
$out .= "Connection: Close\r\n\r\n"; |
1447
|
|
|
|
1448
|
|
|
fwrite($fp, $out); |
1449
|
|
|
|
1450
|
|
|
while (!feof($fp)) { |
1451
|
|
|
$data = fgets($fp, 128); |
1452
|
|
|
$pos = strpos($data, "Rank_"); |
1453
|
|
|
if ($pos === false) {} else { |
|
|
|
|
1454
|
|
|
$pagerank = substr($data, $pos + 9); |
1455
|
|
|
} |
1456
|
|
|
} |
1457
|
|
|
fclose($fp); |
1458
|
|
|
} |
1459
|
|
|
|
1460
|
|
|
return $pagerank; |
1461
|
|
|
} |
1462
|
|
|
// End functions for Google PageRank |
1463
|
|
|
|
1464
|
|
|
// Check if Tag module is installed |
1465
|
|
View Code Duplication |
function wfl_tag_module_included() |
|
|
|
|
1466
|
|
|
{ |
1467
|
|
|
static $wfl_tag_module_included; |
1468
|
|
|
if (!isset($wfl_tag_module_included)) { |
1469
|
|
|
$modules_handler = xoops_gethandler('module'); |
1470
|
|
|
$tag_mod = $modules_handler -> getByDirName('tag'); |
1471
|
|
|
if (!$tag_mod) { |
1472
|
|
|
$tag_mod = false; |
|
|
|
|
1473
|
|
|
} else { |
1474
|
|
|
$wfl_tag_module_included = $tag_mod -> getVar('isactive') == 1; |
1475
|
|
|
} |
1476
|
|
|
} |
1477
|
|
|
|
1478
|
|
|
return $wfl_tag_module_included; |
1479
|
|
|
} |
1480
|
|
|
|
1481
|
|
|
// Add item_tag to Tag-module |
1482
|
|
|
function wfl_tagupdate($lid, $item_tag) |
1483
|
|
|
{ |
1484
|
|
|
global $xoopsModule; |
|
|
|
|
1485
|
|
|
if (wfl_tag_module_included()) { |
1486
|
|
|
include_once XOOPS_ROOT_PATH . "/modules/tag/include/formtag.php"; |
1487
|
|
|
$tag_handler = xoops_getmodulehandler('tag', 'tag'); |
1488
|
|
|
$tag_handler -> updateByItem($item_tag, $lid, $xoopsModule -> getVar( 'dirname' ), 0); |
1489
|
|
|
} |
1490
|
|
|
} |
1491
|
|
|
|
1492
|
|
|
// Check if News module is installed |
1493
|
|
View Code Duplication |
function wfl_news_module_included() |
|
|
|
|
1494
|
|
|
{ |
1495
|
|
|
static $wfl_news_module_included; |
1496
|
|
|
if (!isset($wfl_news_module_included)) { |
1497
|
|
|
$modules_handler = xoops_gethandler('module'); |
1498
|
|
|
$news_mod = $modules_handler -> getByDirName('news'); |
1499
|
|
|
if (!$news_mod) { |
1500
|
|
|
$news_mod = false; |
|
|
|
|
1501
|
|
|
} else { |
1502
|
|
|
$wfl_news_module_included = $news_mod -> getVar('isactive') == 1; |
1503
|
|
|
} |
1504
|
|
|
} |
1505
|
|
|
|
1506
|
|
|
return $wfl_news_module_included; |
1507
|
|
|
} |
1508
|
|
|
|
1509
|
|
View Code Duplication |
function wfl_getbanner_from_id_banner($banner_id) |
|
|
|
|
1510
|
|
|
{ |
1511
|
|
|
###### Hack by www.stefanosilvestrini.com ###### |
1512
|
|
|
global $xoopsConfig; |
|
|
|
|
1513
|
|
|
$db =& XoopsDatabaseFactory::getDatabaseConnection(); |
1514
|
|
|
$bresult = $db -> query("SELECT COUNT(*) FROM " . $db -> prefix('banner') . " WHERE bid=" . $banner_id); |
1515
|
|
|
list ($numrows) = $db -> fetchRow($bresult); |
1516
|
|
|
if ($numrows > 1) { |
1517
|
|
|
$numrows = $numrows - 1; |
1518
|
|
|
mt_srand((double) microtime() * 1000000); |
1519
|
|
|
$bannum = mt_rand(0, $numrows); |
1520
|
|
|
} else { |
1521
|
|
|
$bannum = 0; |
1522
|
|
|
} |
1523
|
|
|
if ($numrows > 0) { |
1524
|
|
|
$bresult = $db -> query("SELECT * FROM " . $db -> prefix('banner'). " WHERE bid=" . $banner_id, 1, $bannum); |
1525
|
|
|
list ($bid, $cid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date, $htmlbanner, $htmlcode) = $db -> fetchRow($bresult); |
|
|
|
|
1526
|
|
|
if ($xoopsConfig['my_ip'] == xoops_getenv('REMOTE_ADDR')) { |
|
|
|
|
1527
|
|
|
// EMPTY |
1528
|
|
|
} else { |
1529
|
|
|
$db -> queryF(sprintf("UPDATE %s SET impmade = impmade+1 WHERE bid = %u", $db -> prefix('banner'), $bid)); |
1530
|
|
|
} |
1531
|
|
|
/* Check if this impression is the last one and print the banner */ |
1532
|
|
|
if ($imptotal == $impmade) { |
1533
|
|
|
$newid = $db -> genId($db -> prefix("bannerfinish") . "_bid_seq"); |
1534
|
|
|
$sql = sprintf("INSERT INTO %s (bid, cid, impressions, clicks, datestart, dateend) VALUES (%u, %u, %u, %u, %u, %u)", $db -> prefix('bannerfinish'), $newid, $cid, $impmade, $clicks, $date, time()); |
1535
|
|
|
$db -> queryF($sql); |
1536
|
|
|
$db -> queryF(sprintf("DELETE FROM %s WHERE bid = %u", $db -> prefix('banner'), $bid)); |
1537
|
|
|
} |
1538
|
|
|
if ($htmlbanner) { |
1539
|
|
|
$bannerobject = $htmlcode; |
1540
|
|
|
} else { |
1541
|
|
|
$bannerobject = '<div align="center"><a href="' . XOOPS_URL . '/banners.php?op=click&bid=' . $bid . '" target="_blank">'; |
1542
|
|
|
if (stristr($imageurl, '.swf')) { |
1543
|
|
|
$bannerobject = $bannerobject |
1544
|
|
|
.'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="468" height="60">' |
1545
|
|
|
.'<param name="movie" value="' . $imageurl . '"></param>' |
1546
|
|
|
.'<param name="quality" value="high"></param>' |
1547
|
|
|
.'<embed src="' . $imageurl . '" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="468" height="60">' |
1548
|
|
|
.'</embed>' |
1549
|
|
|
.'</object>'; |
1550
|
|
|
} else { |
1551
|
|
|
$bannerobject = $bannerobject . '<img src="' . $imageurl . '" alt="" />'; |
1552
|
|
|
} |
1553
|
|
|
$bannerobject = $bannerobject . '</a></div>'; |
1554
|
|
|
} |
1555
|
|
|
|
1556
|
|
|
return $bannerobject; |
1557
|
|
|
} |
1558
|
|
|
} |
1559
|
|
|
|
1560
|
|
View Code Duplication |
function wfl_getbanner_from_id_client($client_id) |
|
|
|
|
1561
|
|
|
{ |
1562
|
|
|
###### Hack by www.stefanosilvestrini.com ###### |
1563
|
|
|
global $xoopsConfig; |
|
|
|
|
1564
|
|
|
$db =& XoopsDatabaseFactory::getDatabaseConnection(); |
1565
|
|
|
$bresult = $db -> query("SELECT COUNT(*) FROM " . $db -> prefix('banner') . " WHERE cid=" . $client_id); |
1566
|
|
|
list ($numrows) = $db -> fetchRow($bresult); |
1567
|
|
|
if ($numrows > 1) { |
1568
|
|
|
$numrows = $numrows - 1; |
1569
|
|
|
mt_srand((double) microtime() * 1000000); |
1570
|
|
|
$bannum = mt_rand(0, $numrows); |
1571
|
|
|
} else { |
1572
|
|
|
$bannum = 0; |
1573
|
|
|
} |
1574
|
|
|
if ($numrows > 0) { |
1575
|
|
|
$bresult = $db -> query("SELECT * FROM " . $db -> prefix('banner') . " WHERE cid=" . $client_id . " ORDER BY rand()", 1, $bannum); |
1576
|
|
|
list ($bid, $cid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date, $htmlbanner, $htmlcode) = $db -> fetchRow($bresult); |
|
|
|
|
1577
|
|
|
if ($xoopsConfig['my_ip'] == xoops_getenv('REMOTE_ADDR')) { |
|
|
|
|
1578
|
|
|
// EMPTY |
1579
|
|
|
} else { |
1580
|
|
|
$db -> queryF(sprintf("UPDATE %s SET impmade = impmade+1 WHERE bid = %u", $db -> prefix('banner'), $bid)); |
1581
|
|
|
} |
1582
|
|
|
/* Check if this impression is the last one and print the banner */ |
1583
|
|
|
if ($imptotal == $impmade) { |
1584
|
|
|
$newid = $db -> genId($db -> prefix('bannerfinish') . "_bid_seq"); |
1585
|
|
|
$sql = sprintf("INSERT INTO %s (bid, cid, impressions, clicks, datestart, dateend) VALUES (%u, %u, %u, %u, %u, %u)", $db -> prefix('bannerfinish'), $newid, $cid, $impmade, $clicks, $date, time()); |
1586
|
|
|
$db -> queryF($sql); |
1587
|
|
|
$db -> queryF(sprintf("DELETE FROM %s WHERE bid = %u", $db -> prefix('banner'), $bid)); |
1588
|
|
|
} |
1589
|
|
|
if ($htmlbanner) { |
1590
|
|
|
$bannerobject = $htmlcode; |
1591
|
|
|
} else { |
1592
|
|
|
$bannerobject = '<div align="center"><a href="' . XOOPS_URL . '/banners.php?op=click&bid=' . $bid . '" target="_blank">'; |
1593
|
|
|
if (stristr($imageurl, '.swf')) { |
1594
|
|
|
$bannerobject = $bannerobject |
1595
|
|
|
.'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="468" height="60">' |
1596
|
|
|
.'<param name="movie" value="' . $imageurl . '"></param>' |
1597
|
|
|
.'<param name="quality" value="high"></param>' |
1598
|
|
|
.'<embed src="' . $imageurl . '" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="468" height="60">' |
1599
|
|
|
.'</embed>' |
1600
|
|
|
.'</object>'; |
1601
|
|
|
} else { |
1602
|
|
|
$bannerobject = $bannerobject . '<img src="' . $imageurl . '" alt="" />'; |
1603
|
|
|
} |
1604
|
|
|
$bannerobject = $bannerobject . '</a></div>'; |
1605
|
|
|
} |
1606
|
|
|
|
1607
|
|
|
return $bannerobject; |
1608
|
|
|
} |
1609
|
|
|
} |
1610
|
|
|
|
1611
|
|
View Code Duplication |
function emailcnvrt($email) |
|
|
|
|
1612
|
|
|
{ |
1613
|
|
|
$search = array( |
1614
|
|
|
"/\@/", |
1615
|
|
|
"/\./", |
1616
|
|
|
"/\mailto:/", |
1617
|
|
|
); |
1618
|
|
|
|
1619
|
|
|
$replace = array( |
1620
|
|
|
" AT ", |
1621
|
|
|
" DOT ", |
1622
|
|
|
"", |
1623
|
|
|
); |
1624
|
|
|
|
1625
|
|
|
$text = preg_replace($search, $replace, $email); |
1626
|
|
|
|
1627
|
|
|
return $text; |
1628
|
|
|
} |
1629
|
|
|
|
1630
|
|
View Code Duplication |
function printemailcnvrt($email) |
|
|
|
|
1631
|
|
|
{ |
1632
|
|
|
$search = array ( |
1633
|
|
|
"/\ AT /", |
1634
|
|
|
"/\ DOT /", |
1635
|
|
|
); |
1636
|
|
|
|
1637
|
|
|
$replace = array ( |
1638
|
|
|
"@", |
1639
|
|
|
".", |
1640
|
|
|
); |
1641
|
|
|
|
1642
|
|
|
$text = preg_replace($search, $replace, $email); |
1643
|
|
|
|
1644
|
|
|
return $text; |
1645
|
|
|
} |
1646
|
|
|
|
1647
|
|
|
function wfl_substr($str, $start, $length, $trimmarker = '...') |
1648
|
|
|
{ |
1649
|
|
|
$config_handler =& xoops_gethandler('config'); |
1650
|
|
|
$im_multilanguageConfig =& $config_handler->getConfigsByCat(IM_CONF_MULILANGUAGE); |
1651
|
|
|
|
1652
|
|
|
if ($im_multilanguageConfig['ml_enable']) { |
1653
|
|
|
$tags = explode(',',$im_multilanguageConfig['ml_tags']); |
1654
|
|
|
$strs = array(); |
1655
|
|
|
$hasML = false; |
1656
|
|
|
foreach ($tags as $tag) { |
1657
|
|
|
if (preg_match("/\[".$tag."](.*)\[\/".$tag."\]/sU",$str,$matches)) { |
1658
|
|
|
if (count($matches) > 0) { |
1659
|
|
|
$hasML = true; |
1660
|
|
|
$strs[] = $matches[1]; |
1661
|
|
|
} |
1662
|
|
|
} |
1663
|
|
|
} |
1664
|
|
|
} else { |
1665
|
|
|
$hasML = false; |
1666
|
|
|
} |
1667
|
|
|
|
1668
|
|
|
if (!$hasML) { |
1669
|
|
|
$strs = array($str); |
1670
|
|
|
} |
1671
|
|
|
|
1672
|
|
|
for ($i = 0; $i <= count($strs)-1; ++$i) { |
|
|
|
|
1673
|
|
|
if (!XOOPS_USE_MULTIBYTES) { |
1674
|
|
|
$strs[$i] = ( strlen($strs[$i]) - $start <= $length ) ? substr( $strs[$i], $start, $length ) : substr( $strs[$i], $start, $length - strlen($trimmarker) ) . $trimmarker; |
1675
|
|
|
} |
1676
|
|
|
|
1677
|
|
|
if (function_exists('mb_internal_encoding') && @mb_internal_encoding(_CHARSET)) { |
1678
|
|
|
$str2 = mb_strcut( $strs[$i] , $start , $length - strlen( $trimmarker ) ); |
1679
|
|
|
$strs[$i] = $str2 . ( mb_strlen($strs[$i])!=mb_strlen($str2) ? $trimmarker : '' ); |
1680
|
|
|
} |
1681
|
|
|
|
1682
|
|
|
// phppp patch |
1683
|
|
|
$DEP_CHAR=127; |
|
|
|
|
1684
|
|
|
$pos_st=0; |
1685
|
|
|
$action = false; |
1686
|
|
|
for ( $pos_i = 0; $pos_i < strlen($strs[$i]); $pos_i++ ) { |
1687
|
|
|
if ( ord( substr( $strs[$i], $pos_i, 1) ) > 127 ) { |
1688
|
|
|
$pos_i++; |
1689
|
|
|
} |
1690
|
|
|
if ($pos_i<=$start) { |
1691
|
|
|
$pos_st=$pos_i; |
1692
|
|
|
} |
1693
|
|
|
if ($pos_i>=$pos_st+$length) { |
1694
|
|
|
$action = true; |
1695
|
|
|
break; |
1696
|
|
|
} |
1697
|
|
|
} |
1698
|
|
|
$strs[$i] = ($action) ? substr( $strs[$i], $pos_st, $pos_i - $pos_st - strlen($trimmarker) ) . $trimmarker : $strs[$i]; |
1699
|
|
|
|
1700
|
|
|
$strs[$i] = ($hasML)?'['.$tags[$i].']'.$strs[$i].'[/'.$tags[$i].']':$strs[$i]; |
|
|
|
|
1701
|
|
|
} |
1702
|
|
|
$str = implode('',$strs); |
1703
|
|
|
|
1704
|
|
|
return $str; |
1705
|
|
|
} |
1706
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.