|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* You may not change or alter any portion of this comment or credits |
|
4
|
|
|
* of supporting developers from this source code or any supporting source code |
|
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
* This program is distributed in the hope that it will be useful, |
|
7
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
8
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
9
|
|
|
* |
|
10
|
|
|
* @copyright: The XOOPS Project http://sourceforge.net/projects/xoops/ |
|
11
|
|
|
* @license: http://www.fsf.org/copyleft/gpl.html GNU public license |
|
12
|
|
|
* @module: Smallworld |
|
13
|
|
|
* @Author: Michael Albertsen (http://culex.dk) <[email protected]> |
|
14
|
|
|
* @copyright: 2011 Culex |
|
15
|
|
|
* @Repository path: $HeadURL: https://svn.code.sf.net/p/xoops/svn/XoopsModules/smallworld/trunk/smallworld/include/functions.php $ |
|
16
|
|
|
* @Last committed: $Revision: 12175 $ |
|
17
|
|
|
* @Last changed by: $Author: djculex $ |
|
18
|
|
|
* @Last changed date: $Date: 2013-10-15 13:41:43 -0400 (Tue, 15 Oct 2013) $ |
|
19
|
|
|
* @ID: $Id: functions.php 12175 2013-10-15 17:41:43Z djculex $ |
|
20
|
|
|
**/ |
|
21
|
|
|
|
|
22
|
|
|
/* |
|
23
|
|
|
Get array of timestamps based on the timetype configured in preferences |
|
24
|
|
|
*/ |
|
25
|
|
|
function SmallworldGetTimestampsToForm() |
|
26
|
|
|
{ |
|
27
|
|
|
$timearray = array(); |
|
28
|
|
|
$start = 1900; |
|
29
|
|
|
$end = date('Y'); |
|
30
|
|
|
for ($i = $start; $i <= $end; $i++) { |
|
31
|
|
|
$key = $i; |
|
32
|
|
|
$timearray[$key] = $i; |
|
33
|
|
|
} |
|
34
|
|
|
ksort($timearray); |
|
35
|
|
|
|
|
36
|
|
|
return $timearray; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
// Clean vars or arrays |
|
40
|
|
|
// If array check for magicQuotes. |
|
41
|
|
|
// Pass string to Smallworld_cleanup_string |
|
42
|
|
|
function Smallworld_cleanup($text) |
|
|
|
|
|
|
43
|
|
|
{ |
|
44
|
|
View Code Duplication |
if (is_array($text)) { |
|
|
|
|
|
|
45
|
|
|
foreach ($text as $key => $value) { |
|
46
|
|
|
$text[$key] = Smallworld_cleanup_string($value); |
|
47
|
|
|
} |
|
48
|
|
|
} else { |
|
49
|
|
|
$text = Smallworld_cleanup_string($text); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
return $text; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
// Sanitize string |
|
56
|
|
|
function Smallworld_cleanup_string($text) |
|
|
|
|
|
|
57
|
|
|
{ |
|
58
|
|
|
$myts = MyTextSanitizer::getInstance(); |
|
59
|
|
|
$text = $myts->displayTarea($text, $html = 1, $smiley = 1, $xcode = 1, $image = 1, $br = 1); |
|
60
|
|
|
|
|
61
|
|
|
return $text; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
// clean Array for mysql insertion |
|
65
|
|
|
// or send string to Smallworld_sanitize_string |
|
66
|
|
|
function Smallworld_sanitize($text) |
|
|
|
|
|
|
67
|
|
|
{ |
|
68
|
|
View Code Duplication |
if (is_array($text)) { |
|
|
|
|
|
|
69
|
|
|
foreach ($text as $key => $value) { |
|
70
|
|
|
$text[$key] = Smallworld_sanitize_string($value); |
|
71
|
|
|
} |
|
72
|
|
|
} else { |
|
73
|
|
|
$text = Smallworld_sanitize_string($text); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
return $text; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
function Smallworld_sanitize_string($value) |
|
|
|
|
|
|
80
|
|
|
{ |
|
81
|
|
|
$myts = MyTextSanitizer::getInstance(); |
|
82
|
|
|
if(get_magic_quotes_gpc()){ |
|
83
|
|
|
$value = $myts->stripSlashesGPC($value); |
|
84
|
|
|
} else { |
|
85
|
|
|
$value = mysql_real_escape_string($value); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
return $value; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
function Smallworld_DateOfArray($array) |
|
92
|
|
|
{ |
|
93
|
|
|
$data = array(); |
|
94
|
|
|
foreach ($array as $k => $v) { |
|
95
|
|
|
$data[$k] = strtotime($v); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
return $data; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
function Smallworld_YearOfArray($array) |
|
102
|
|
|
{ |
|
103
|
|
|
$data = array(); |
|
104
|
|
|
foreach ($array as $k => $v) { |
|
105
|
|
|
$data[$k] = $v; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
return $data; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
function Smallworld_CreateIndexFiles($folderUrl) |
|
112
|
|
|
{ |
|
113
|
|
|
$myts =& MyTextSanitizer::getInstance(); |
|
114
|
|
|
file_put_contents($folderUrl . 'index.html', "<script>history.go(-1);</script>"); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
function smallworld_ImplodeArray($glue = ", ", $pieces) |
|
118
|
|
|
{ |
|
119
|
|
|
return implode($glue, $pieces); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
// recursively reduces deep arrays to single-dimensional arrays |
|
123
|
|
|
// $preserve_keys: (0=>never, 1=>strings, 2=>always) |
|
124
|
|
|
function Smallworld_array_flatten($array, $preserve_keys = 1, &$newArray = Array()) |
|
|
|
|
|
|
125
|
|
|
{ |
|
126
|
|
|
foreach ($array as $key => $child) { |
|
127
|
|
|
if (is_array($child)) { |
|
128
|
|
|
$newArray =& Smallworld_array_flatten($child, $preserve_keys, $newArray); |
|
129
|
|
|
} elseif ($preserve_keys + is_string($key) > 1) { |
|
130
|
|
|
$newArray[$key] = $child; |
|
131
|
|
|
} else { |
|
132
|
|
|
$newArray[] = $child; |
|
133
|
|
|
} |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
return $newArray; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/* |
|
140
|
|
|
* Calculate years from date format (YYYY-MM-DD) |
|
141
|
|
|
* @param date $birth |
|
142
|
|
|
* @returns integer |
|
143
|
|
|
*/ |
|
144
|
|
|
function Smallworld_Birthday($birth) |
|
145
|
|
|
{ |
|
146
|
|
|
list($year, $month, $day) = explode("-", $birth); |
|
147
|
|
|
$yearDiff = date("Y") - $year; |
|
148
|
|
|
$monthDiff = date("m") - $month; |
|
149
|
|
|
$dayDiff = date("d") - $day; |
|
150
|
|
|
if ($monthDiff == 0){ |
|
151
|
|
|
if($dayDiff < 0) { |
|
152
|
|
|
$yearDiff--; |
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
if ($monthDiff < 0){ |
|
156
|
|
|
$yearDiff--; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
return $yearDiff; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
function smallworld_isset_or($check) |
|
|
|
|
|
|
163
|
|
|
{ |
|
164
|
|
|
global $xoopsDB,$xoopsUser; |
|
|
|
|
|
|
165
|
|
|
$query = "SELECT * FROM ".$xoopsDB->prefix('smallworld_user')." WHERE username = '".$check."'"; |
|
166
|
|
|
$result=$xoopsDB->queryF($query); |
|
167
|
|
|
while ($row=$xoopsDB->fetchArray($result)) { |
|
168
|
|
|
if ($row['userid'] == '') { |
|
169
|
|
|
return false; |
|
170
|
|
|
} else { |
|
171
|
|
|
return $row['userid']; |
|
172
|
|
|
} |
|
173
|
|
|
} |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
//Srinivas Tamada http://9lessons.info |
|
177
|
|
|
//Loading Comments link with load_updates.php |
|
178
|
|
|
function smallworld_time_stamp($session_time) |
|
179
|
|
|
{ |
|
180
|
|
|
global $xoopsConfig; |
|
|
|
|
|
|
181
|
|
|
$time_difference = time() - $session_time; |
|
182
|
|
|
$seconds = $time_difference; |
|
183
|
|
|
$minutes = round($time_difference / 60); |
|
184
|
|
|
$hours = round($time_difference / 3600); |
|
185
|
|
|
$days = round($time_difference / 86400); |
|
186
|
|
|
$weeks = round($time_difference / 604800); |
|
187
|
|
|
$months = round($time_difference / 2419200); |
|
188
|
|
|
$years = round($time_difference / 29030400); |
|
189
|
|
|
if($seconds <= 60) { |
|
190
|
|
|
$t = "$seconds"._SMALLWORLD_SECONDSAGO; |
|
191
|
|
|
} else if($minutes <= 60) { |
|
192
|
|
|
if($minutes == 1) { |
|
193
|
|
|
$t = _SMALLWORLD_ONEMINUTEAGO; |
|
194
|
|
|
} else { |
|
195
|
|
|
$t = "$minutes"._SMALLWORLD_MINUTESAGO; |
|
196
|
|
|
} |
|
197
|
|
|
} else if($hours <= 24) { |
|
198
|
|
|
if($hours == 1) { |
|
199
|
|
|
$t = _SMALLWORLD_ONEHOURAGO; |
|
200
|
|
|
} else { |
|
201
|
|
|
$t = "$hours"._SMALLWORLD_HOURSAGO; |
|
202
|
|
|
} |
|
203
|
|
|
} else if($days <= 7 ) { |
|
204
|
|
|
if($days == 1){ |
|
205
|
|
|
$t = _SMALLWORLD_ONEDAYAGO; |
|
206
|
|
|
} else { |
|
207
|
|
|
$t = "$days"._SMALLWORLD_DAYSAGO; |
|
208
|
|
|
} |
|
209
|
|
|
} else if($weeks <=4) { |
|
210
|
|
|
if($weeks==1) { |
|
211
|
|
|
$t = _SMALLWORLD_ONEWEEKAGO; |
|
212
|
|
|
} else { |
|
213
|
|
|
$t = "$weeks"._SMALLWORLD_WEEKSAGO; |
|
214
|
|
|
} |
|
215
|
|
|
} else if($months <= 12) { |
|
216
|
|
|
if($months == 1) { |
|
217
|
|
|
$t = _SMALLWORLD_ONEMONTHAGO; |
|
218
|
|
|
} else { |
|
219
|
|
|
$t = "$months"._SMALLWORLD_MONTHSAGO; |
|
220
|
|
|
} |
|
221
|
|
|
} else { |
|
222
|
|
|
if($years == 1) { |
|
223
|
|
|
$t = _SMALLWORLD_ONEYEARAGO; |
|
224
|
|
|
} else { |
|
225
|
|
|
$t = "$years"._SMALLWORLD_YEARSAGO; |
|
226
|
|
|
} |
|
227
|
|
|
} |
|
228
|
|
|
|
|
229
|
|
|
return $t; |
|
230
|
|
|
} |
|
231
|
|
|
|
|
232
|
|
|
// Return only url/link |
|
233
|
|
|
// If url is image link return <img> |
|
234
|
|
|
function smallworld_tolink($text, $uid) |
|
235
|
|
|
{ |
|
236
|
|
|
global $xoopsUser; |
|
|
|
|
|
|
237
|
|
|
$ext = substr($text,-4,4); |
|
238
|
|
|
$ext2 = substr($text,-5,5); |
|
239
|
|
|
$xoopsUser = new XoopsUser($uid); |
|
240
|
|
|
$usr = new $xoopsUser($uid); |
|
241
|
|
|
|
|
242
|
|
|
$userID = $xoopsUser->getVar('uid'); |
|
243
|
|
|
$user = new XoopsUser($userID); |
|
244
|
|
|
$username = $user->getVar('uname'); |
|
245
|
|
|
$gallery = XOOPS_URL."/modules/smallworld/galleryshow.php?username=".$usr->getVar('uname'); |
|
246
|
|
|
|
|
247
|
|
|
if (in_array($ext,array('.jpg','.bmp','.gif','.png')) || in_array($ext,array('.JPG','.BMP','.GIF','.PNG')) || in_array($ext2,array('.jpeg'))){ |
|
248
|
|
|
if (strpos($text, 'UPLIMAGE') !== false ) { |
|
249
|
|
|
$text = str_replace('UPLIMAGE', '', $text); |
|
250
|
|
|
$text = preg_replace('/(((f|ht){1}tp:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i', |
|
251
|
|
|
'<span class="smallworldUplImgTxt"><br/><img class="smallworldAttImg" src="\\1"><br><br><a id="smallworldUplImgLnk" href="' |
|
252
|
|
|
. $gallery . '" target="_self">' |
|
253
|
|
|
. $usr->getVar('uname') . _SMALLWORLD_UPLOADEDSOMEIMAGES |
|
254
|
|
|
. '</a><br></span>', $text |
|
255
|
|
|
); |
|
256
|
|
|
$text = preg_replace('/(((f|ht){1}tps:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i', |
|
257
|
|
|
'<span class="smallworldUplImgTxt"><br/><img class="smallworldAttImg" src="\\1"><br><br><a id="smallworldUplImgLnk" href="' |
|
258
|
|
|
. $gallery . '" target="_self">' |
|
259
|
|
|
. $usr->getVar('uname') . _SMALLWORLD_UPLOADEDSOMEIMAGES |
|
260
|
|
|
. '</a><br></span>', $text |
|
261
|
|
|
); |
|
262
|
|
|
$text = preg_replace('/([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i', |
|
263
|
|
|
'\\1<span class="smallworldUplImgTxt"><br/><img class="smallworldAttImg" src="//\\2"><br><br><a id="smallworldUplImgLnk" href="' |
|
264
|
|
|
. $gallery . '" target="_self">' |
|
265
|
|
|
. $username . _SMALLWORLD_UPLOADEDSOMEIMAGES |
|
266
|
|
|
. '</a><br></span>', $text |
|
267
|
|
|
); |
|
268
|
|
|
$text = html_entity_decode($text,ENT_QUOTES,"UTF-8"); |
|
269
|
|
|
} else { |
|
270
|
|
|
$text = preg_replace('/(((f|ht){1}tp:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i', |
|
271
|
|
|
'<img class="smallworldAttImg" src="\\1"><a class="smallworldAttImgTxt" href="\\1">'._SMALLWORLD_CLICKIMAGETHUMB.' </a><br>', $text); |
|
272
|
|
|
$text = preg_replace('/(((f|ht){1}tps:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i', |
|
273
|
|
|
'<img class="smallworldAttImg" src="\\1"><a class="smallworldAttImgTxt" href="\\1">'._SMALLWORLD_CLICKIMAGETHUMB.' </a><br>', $text); |
|
274
|
|
|
$text = preg_replace('/([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i', |
|
275
|
|
|
'\\1<img class="smallworldAttImg" src="//\\2"><a class="smallworldAttImgTxt" href="//\\2">'._SMALLWORLD_CLICKIMAGETHUMB.'</a><br>', $text); |
|
276
|
|
|
$text = html_entity_decode($text,ENT_QUOTES,"UTF-8"); |
|
277
|
|
|
} |
|
278
|
|
|
} else { |
|
279
|
|
|
$text = html_entity_decode($text,ENT_QUOTES,"UTF-8"); |
|
280
|
|
|
$text = " " . $text; |
|
281
|
|
|
$text = str_replace('UPLIMAGE', '', $text); |
|
282
|
|
|
} |
|
283
|
|
|
|
|
284
|
|
|
return linkify_twitter_status($text); |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
function Smallworld_stripWordsKeepUrl($text) |
|
|
|
|
|
|
288
|
|
|
{ |
|
289
|
|
|
preg_replace('/(((f|ht){1}tps:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i', |
|
290
|
|
|
'<div class=".embed"><a href="\\1">\\1</a></div>', $text); |
|
291
|
|
|
|
|
292
|
|
|
return $text; |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
function Smallworld_sociallinks($num, $name) |
|
296
|
|
|
{ |
|
297
|
|
View Code Duplication |
if ($num == 0) { |
|
|
|
|
|
|
298
|
|
|
$image = '<img title="Msn" id="Smallworld_socialnetworkimg" src="'.XOOPS_URL.'/modules/smallworld/images/socialnetworkicons/msn.png"/>'; |
|
299
|
|
|
$link = '<a title="Msn" id="Smallworld_socialnetwork" target="_blank" href="http://members.msn.com/'.$name.'">'; |
|
300
|
|
|
} |
|
301
|
|
View Code Duplication |
if ($num == 1) { |
|
|
|
|
|
|
302
|
|
|
$image = '<img title="facebook" id="Smallworld_socialnetworkimg" src="'.XOOPS_URL.'/modules/smallworld/images/socialnetworkicons/facebook.png"/>'; |
|
303
|
|
|
$link = '<a title="facebook" id="Smallworld_socialnetwork" target="_blank" href="http://www.facebook.com/'.$name.'">'; |
|
304
|
|
|
} |
|
305
|
|
View Code Duplication |
if ($num == 2) { |
|
|
|
|
|
|
306
|
|
|
$image = '<img title="GooglePlus" id="Smallworld_socialnetworkimg" src="'.XOOPS_URL.'/modules/smallworld/images/socialnetworkicons/googleplus.png"/>'; |
|
307
|
|
|
$link = '<a title="GooglePlus" id="Smallworld_socialnetwork" target="_blank" href="https://plus.google.com/'.$name.'">'; |
|
308
|
|
|
} |
|
309
|
|
View Code Duplication |
if ($num == 3) { |
|
|
|
|
|
|
310
|
|
|
$image = '<img title="Icq" id="Smallworld_socialnetworkimg" src="'.XOOPS_URL.'/modules/smallworld/images/socialnetworkicons/icq.png"/>'; |
|
311
|
|
|
$link = '<a title="icq" id="Smallworld_socialnetwork" target="_blank" href="http://www.icq.com/people/'.$name.'/">'; |
|
312
|
|
|
} |
|
313
|
|
View Code Duplication |
if ($num == 4) { |
|
|
|
|
|
|
314
|
|
|
$image = '<img title="Skype" id="Smallworld_socialnetworkimg" src="'.XOOPS_URL.'/modules/smallworld/images/socialnetworkicons/skype.png"/>'; |
|
315
|
|
|
$link = '<a title="Skype" id="Smallworld_socialnetwork" target="_blank" href="skype:'.$name.'?userinfo">'; |
|
316
|
|
|
} |
|
317
|
|
View Code Duplication |
if ($num == 5) { |
|
|
|
|
|
|
318
|
|
|
$image = '<img title="Twitter" id="Smallworld_socialnetworkimg" src="'.XOOPS_URL.'/modules/smallworld/images/socialnetworkicons/twitter.png"/>'; |
|
319
|
|
|
$link = '<a title="Twitter" id="Smallworld_socialnetwork" target="_blank" href="http://twitter.com/#!/'.$name.'">'; |
|
320
|
|
|
} |
|
321
|
|
View Code Duplication |
if ($num == 6) { |
|
|
|
|
|
|
322
|
|
|
$image = '<img title="MySpace" id="Smallworld_socialnetworkimg" src="'.XOOPS_URL.'/modules/smallworld/images/socialnetworkicons/myspace.png"/>'; |
|
323
|
|
|
$link = '<a title="MySpace" id="Smallworld_socialnetwork" target="_blank" href="http://www.myspace.com/'.$name.'">'; |
|
324
|
|
|
} |
|
325
|
|
View Code Duplication |
if ($num == 7) { |
|
|
|
|
|
|
326
|
|
|
$image = '<img title="Xoops" id="Smallworld_socialnetworkimg" src="'.XOOPS_URL.'/modules/smallworld/images/socialnetworkicons/xoops.png"/>'; |
|
327
|
|
|
$link = '<a title="Xoops" id="Smallworld_socialnetwork" target="_blank" href="http://xoops.org/modules/profile/userinfo.php?uid='.$name.'">'; |
|
328
|
|
|
} |
|
329
|
|
View Code Duplication |
if ($num == 8) { |
|
|
|
|
|
|
330
|
|
|
$image = '<img title="Yahoo Messenger" id="Smallworld_socialnetworkimg" src="'.XOOPS_URL.'/modules/smallworld/images/socialnetworkicons/yahoo.png"/>'; |
|
331
|
|
|
$link = '<a title="Yahoo Messenger" id="Smallworld_socialnetwork" target="_blank" href="ymsgr:sendim?'.$name.'">'; |
|
332
|
|
|
} |
|
333
|
|
View Code Duplication |
if ($num == 9) { |
|
|
|
|
|
|
334
|
|
|
$image = '<img title="Youtube" id="Smallworld_socialnetworkimg" src="'.XOOPS_URL.'/modules/smallworld/images/socialnetworkicons/youtube.png"/>'; |
|
335
|
|
|
$link = '<a title="Youtube" id="Smallworld_socialnetwork" target="_blank" href="http://www.youtube.com/user/'.$name.'">'; |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
return $image.$link; |
|
|
|
|
|
|
339
|
|
|
} |
|
340
|
|
|
|
|
341
|
|
|
function smallworld_GetModuleOption($option, $repmodule='smallworld') |
|
|
|
|
|
|
342
|
|
|
{ |
|
343
|
|
|
global $xoopsModuleConfig, $xoopsModule; |
|
|
|
|
|
|
344
|
|
|
static $tbloptions = Array(); |
|
345
|
|
|
if(is_array($tbloptions) && array_key_exists($option,$tbloptions)) { |
|
346
|
|
|
return $tbloptions[$option]; |
|
347
|
|
|
} |
|
348
|
|
|
$retval = false; |
|
349
|
|
|
if (isset($xoopsModuleConfig) |
|
350
|
|
|
&& (is_object($xoopsModule) |
|
351
|
|
|
&& $xoopsModule->getVar('dirname') == $repmodule |
|
352
|
|
|
&& $xoopsModule->getVar('isactive')) |
|
353
|
|
|
) |
|
354
|
|
|
{ |
|
355
|
|
|
if(isset($xoopsModuleConfig[$option])) { |
|
356
|
|
|
$retval= $xoopsModuleConfig[$option]; |
|
357
|
|
|
} |
|
358
|
|
|
} else { |
|
359
|
|
|
$module_handler =& xoops_gethandler('module'); |
|
360
|
|
|
$module =& $module_handler->getByDirname($repmodule); |
|
361
|
|
|
$config_handler =& xoops_gethandler('config'); |
|
362
|
|
|
if ($module) { |
|
363
|
|
|
$moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); |
|
364
|
|
|
if(isset($moduleConfig[$option])) { |
|
365
|
|
|
$retval= $moduleConfig[$option]; |
|
366
|
|
|
} |
|
367
|
|
|
} |
|
368
|
|
|
} |
|
369
|
|
|
$tbloptions[$option]=$retval; |
|
370
|
|
|
|
|
371
|
|
|
return $retval; |
|
372
|
|
|
} |
|
373
|
|
|
|
|
374
|
|
|
/** |
|
375
|
|
|
* Check image extension and users gender. If image is legal image extension return avatar, |
|
376
|
|
|
else return default gender based image |
|
377
|
|
|
* @param int $userid |
|
378
|
|
|
* @param string $image |
|
379
|
|
|
* @returns string |
|
380
|
|
|
*/ |
|
381
|
|
|
function smallworld_getAvatarLink($userid, $image) |
|
382
|
|
|
{ |
|
383
|
|
|
global $xoopsUser, $xoopsDB; |
|
|
|
|
|
|
384
|
|
|
$ext = pathinfo(strtolower($image), PATHINFO_EXTENSION); |
|
385
|
|
|
$sql = "SELECT gender FROM ".$xoopsDB->prefix('smallworld_user')." WHERE userid = '".intval($userid)."'"; |
|
386
|
|
|
$result = $xoopsDB->queryf($sql); |
|
387
|
|
|
$counter = $xoopsDB->getRowsNum($result); |
|
388
|
|
|
if ($counter == 0) { |
|
389
|
|
|
$gender = ''; |
|
390
|
|
|
} else { |
|
391
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
|
392
|
|
|
$gender = $row['gender']; |
|
393
|
|
|
} |
|
394
|
|
|
} |
|
395
|
|
|
|
|
396
|
|
|
$image = ($image == 'blank.gif') ? '' : $image; |
|
397
|
|
|
|
|
398
|
|
|
if (preg_match("/avatars/i", $image)) { |
|
399
|
|
|
$link = XOOPS_UPLOAD_URL."/".$image; |
|
400
|
|
|
} else { |
|
401
|
|
|
$link = $image; |
|
402
|
|
|
} |
|
403
|
|
|
|
|
404
|
|
|
if (!in_array($ext,array('jpg','bmp','gif','png','jpeg')) || $image == '' || $image == "blank.gif"){ |
|
405
|
|
|
|
|
406
|
|
|
if ($ext == '' && $gender == '1') { |
|
|
|
|
|
|
407
|
|
|
$link = XOOPS_URL."/modules/smallworld/images/ano_woman.png"; |
|
408
|
|
|
} |
|
409
|
|
|
|
|
410
|
|
|
if ($ext == '' && $gender == '2') { |
|
411
|
|
|
$link = XOOPS_URL."/modules/smallworld/images/ano_man.png"; |
|
412
|
|
|
} |
|
413
|
|
|
|
|
414
|
|
|
if ($ext == '' AND $gender == '') { |
|
|
|
|
|
|
415
|
|
|
$link = XOOPS_URL."/modules/smallworld/images/genderless.png"; |
|
416
|
|
|
} |
|
417
|
|
|
} |
|
418
|
|
|
//echo $link."<br>"; |
|
|
|
|
|
|
419
|
|
|
return $link; |
|
420
|
|
|
} |
|
421
|
|
|
|
|
422
|
|
|
function smallworld_checkForXim() |
|
423
|
|
|
{ |
|
424
|
|
|
$filename = XOOPS_ROOT_PATH."/modules/xim/chat.php"; |
|
425
|
|
|
if (file_exists($filename)) { |
|
426
|
|
|
return true; |
|
427
|
|
|
} else { |
|
428
|
|
|
return false; |
|
429
|
|
|
} |
|
430
|
|
|
} |
|
431
|
|
|
|
|
432
|
|
|
/** |
|
433
|
|
|
* Get version number of xim if exists |
|
434
|
|
|
* @return int $version |
|
435
|
|
|
*/ |
|
436
|
|
|
function smallworld_XIMversion () { |
|
437
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
438
|
|
|
$sql = "SELECT version FROM ".$xoopsDB->prefix('modules')." WHERE dirname = 'xim'"; |
|
439
|
|
|
$result = $xoopsDB->queryF($sql); |
|
440
|
|
|
if ($result) { |
|
441
|
|
|
while ($r = $xoopsDB->fetchArray($result)) { |
|
442
|
|
|
$version = $r['version']; |
|
443
|
|
|
} |
|
444
|
|
|
} else { |
|
445
|
|
|
$version = 0; |
|
446
|
|
|
} |
|
447
|
|
|
|
|
448
|
|
|
return $version; |
|
|
|
|
|
|
449
|
|
|
} |
|
450
|
|
|
|
|
451
|
|
|
/* |
|
452
|
|
|
* Input: Message Id, |
|
453
|
|
|
* Return owner of thread (original poster) |
|
454
|
|
|
* Return Integer |
|
455
|
|
|
*/ |
|
456
|
|
View Code Duplication |
function Smallworld_getOwnerFromComment($msg_id_fk) |
|
|
|
|
|
|
457
|
|
|
{ |
|
458
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
459
|
|
|
$sql = "Select uid_fk from ".$xoopsDB->prefix('smallworld_messages')." where msg_id = '".$msg_id_fk."'"; |
|
460
|
|
|
$result = $xoopsDB->queryF($sql); |
|
461
|
|
|
while ($r = $xoopsDB->fetchArray($result)) { |
|
462
|
|
|
$owner = $r['uid_fk']; |
|
463
|
|
|
} |
|
464
|
|
|
|
|
465
|
|
|
return $owner; |
|
|
|
|
|
|
466
|
|
|
} |
|
467
|
|
|
|
|
468
|
|
|
// Get username from userID |
|
469
|
|
View Code Duplication |
function Smallworld_getName($userID) |
|
|
|
|
|
|
470
|
|
|
{ |
|
471
|
|
|
global $xoopsUser, $xoopsDB; |
|
|
|
|
|
|
472
|
|
|
$sql = "SELECT username FROM ".$xoopsDB->prefix('smallworld_user')." WHERE userid = '".intval($userID)."'"; |
|
473
|
|
|
$result = $xoopsDB->queryf($sql); |
|
474
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
|
475
|
|
|
$name = $row['username']; |
|
476
|
|
|
} |
|
477
|
|
|
|
|
478
|
|
|
return $name; |
|
|
|
|
|
|
479
|
|
|
} |
|
480
|
|
|
|
|
481
|
|
|
// Check if user has been taken down for inspection by admin |
|
482
|
|
|
// Userid = user id of user to check |
|
483
|
|
|
// return array |
|
484
|
|
|
function Smallworld_isInspected($userid) |
|
485
|
|
|
{ |
|
486
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
487
|
|
|
$data = array(); |
|
488
|
|
|
$sql = "SELECT inspect_start, inspect_stop FROM ".$xoopsDB->prefix('smallworld_admin')." WHERE userid = '".$userid."' AND (inspect_start+inspect_stop) > ".time().""; |
|
489
|
|
|
$result = $xoopsDB->queryF($sql); |
|
490
|
|
|
if ($xoopsDB->getRowsNum($result) > 0) { |
|
491
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
|
492
|
|
|
$data['inspect'] = 'yes'; |
|
493
|
|
|
$data['totaltime'] = ($row['inspect_start'] + $row['inspect_stop'])-time(); |
|
494
|
|
|
} |
|
495
|
|
|
} else { |
|
496
|
|
|
$data['inspect'] = 'no'; |
|
497
|
|
|
} |
|
498
|
|
|
|
|
499
|
|
|
return $data; |
|
500
|
|
|
} |
|
501
|
|
|
|
|
502
|
|
|
// Auto delete all inspects from DB where time has passed |
|
503
|
|
|
// inspect_start + inspect_stop - time() is deleted if negative intval |
|
504
|
|
|
function SmallworldDeleteOldInspects() |
|
505
|
|
|
{ |
|
506
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
507
|
|
|
$sql = "UPDATE ".$xoopsDB->prefix('smallworld_admin')." SET inspect_start = '', inspect_stop = '' WHERE (inspect_start+inspect_stop) <= ".time().""; |
|
508
|
|
|
$result = $xoopsDB->queryF($sql); |
|
|
|
|
|
|
509
|
|
|
} |
|
510
|
|
|
|
|
511
|
|
|
// Function to get sum of users in you following array |
|
512
|
|
|
// Used to calculate new message flash in jQuery intval fetch |
|
513
|
|
|
function smallworld_getCountFriendMessagesEtc() |
|
|
|
|
|
|
514
|
|
|
{ |
|
515
|
|
|
global $xoopsUser, $xoopsDB; |
|
|
|
|
|
|
516
|
|
|
$user = new xoopsUser; |
|
|
|
|
|
|
517
|
|
|
$Wall = new Wall_Updates(); |
|
518
|
|
|
$userid = $xoopsUser->getVar('uid'); |
|
519
|
|
|
$followers = Smallworld_array_flatten($Wall->getFollowers($userid),0); |
|
520
|
|
|
if (smallworld_GetModuleOption('usersownpostscount', $repmodule='smallworld') == 1) { |
|
521
|
|
|
array_push($followers, $userid); |
|
522
|
|
|
} |
|
523
|
|
|
$ids = join(',',$followers); |
|
524
|
|
|
$sql = "SELECT COUNT(*) AS total " |
|
525
|
|
|
." FROM ( " |
|
526
|
|
|
." SELECT com_id , count( * ) as comments FROM ".$xoopsDB->prefix('smallworld_comments')." WHERE uid_fk IN ($ids) Group by com_id " |
|
527
|
|
|
." UNION ALL " |
|
528
|
|
|
." Select msg_id , count( * ) as messages FROM ".$xoopsDB->prefix('smallworld_messages')." WHERE uid_fk IN ($ids) group by msg_id " |
|
529
|
|
|
." ) as d"; |
|
530
|
|
|
$result = $xoopsDB->queryF($sql); |
|
531
|
|
|
while ($r = $xoopsDB->fetchArray($result)) { |
|
532
|
|
|
$total = $r['total']; |
|
533
|
|
|
} |
|
534
|
|
|
|
|
535
|
|
|
return $total; |
|
|
|
|
|
|
536
|
|
|
} |
|
537
|
|
|
|
|
538
|
|
|
// Function to get sum of users in you following array |
|
539
|
|
|
// Used to calculate new message flash in jQuery intval fetch |
|
540
|
|
|
function smallworld_countUsersMessages($id) |
|
|
|
|
|
|
541
|
|
|
{ |
|
542
|
|
|
global $xoopsUser, $xoopsDB; |
|
|
|
|
|
|
543
|
|
|
$user = new xoopsUser; |
|
|
|
|
|
|
544
|
|
|
$Wall = new Wall_Updates(); |
|
|
|
|
|
|
545
|
|
|
$sql = "SELECT COUNT(*) AS total " |
|
546
|
|
|
." FROM ( " |
|
547
|
|
|
." SELECT com_id , count( * ) as comments FROM ".$xoopsDB->prefix('smallworld_comments')." WHERE uid_fk = ".intval($id)." Group by com_id " |
|
548
|
|
|
." UNION ALL " |
|
549
|
|
|
." Select msg_id , count( * ) as messages FROM ".$xoopsDB->prefix('smallworld_messages')." WHERE uid_fk = ".intval($id)."group by msg_id " |
|
550
|
|
|
." ) as d"; |
|
551
|
|
|
$result = $xoopsDB->queryF($sql); |
|
552
|
|
|
while ($r = $xoopsDB->fetchArray($result)) { |
|
553
|
|
|
$total = $r['total']; |
|
554
|
|
|
} |
|
555
|
|
|
|
|
556
|
|
|
return $total; |
|
|
|
|
|
|
557
|
|
|
} |
|
558
|
|
|
|
|
559
|
|
|
// Get the three newest members to array |
|
560
|
|
|
function smallworld_Stats_newest() |
|
561
|
|
|
{ |
|
562
|
|
|
global $xoopsDB, $xoopsUser; |
|
|
|
|
|
|
563
|
|
|
$nu = array(); |
|
564
|
|
|
$sql = "SELECT * FROM ".$xoopsDB->prefix('smallworld_user')." ORDER BY regdate DESC limit 3"; |
|
565
|
|
|
$result = $xoopsDB->queryF($sql); |
|
566
|
|
|
if ($xoopsDB->getRowsNum($result) > 0) { |
|
567
|
|
|
$i = 0; |
|
568
|
|
|
while ($r = $xoopsDB->fetchArray($result)) { |
|
569
|
|
|
$nu[$i]['userid'] = $r['userid']; |
|
570
|
|
|
$nu[$i]['username'] = $r['username']; |
|
571
|
|
|
$nu[$i]['regdate'] = date('d-m-Y',$r['regdate']); |
|
572
|
|
|
$nu[$i]['username_link'] = "<a href = '".XOOPS_URL."/modules/smallworld/userprofile.php?username=".$r['username']."'>"; |
|
573
|
|
|
$nu[$i]['username_link'] .= $r['username']." (".$r['realname'].") [".$nu[$i]['regdate']."] </a>"; |
|
574
|
|
|
$nu[$i]['userimage'] = $r['userimage']; |
|
575
|
|
|
$nu[$i]['userimage_link'] = smallworld_getAvatarLink ($r['userid'], Smallworld_Gravatar($r['userid'])); |
|
576
|
|
|
$i++; |
|
577
|
|
|
} |
|
578
|
|
|
} |
|
579
|
|
|
|
|
580
|
|
|
return $nu; |
|
581
|
|
|
} |
|
582
|
|
|
//Avatar Image |
|
583
|
|
View Code Duplication |
function Smallworld_Gravatar($uid) |
|
|
|
|
|
|
584
|
|
|
{ |
|
585
|
|
|
global $xoopsUser, $xoopsDB; |
|
|
|
|
|
|
586
|
|
|
$image=''; |
|
587
|
|
|
$sql = "SELECT userimage FROM ".$xoopsDB->prefix('smallworld_user')." WHERE userid = '".$uid."'"; |
|
588
|
|
|
$result = $xoopsDB->queryF($sql); |
|
589
|
|
|
while ($r = $xoopsDB->fetchArray($result)) { |
|
590
|
|
|
$image = $r['userimage']; |
|
591
|
|
|
} |
|
592
|
|
|
|
|
593
|
|
|
$image = ($image == '' || $image == 'blank.gif') ? smallworld_getAvatarLink($uid, $image) : $image; |
|
594
|
|
|
|
|
595
|
|
|
$type = Array( |
|
596
|
|
|
1 => 'jpg', |
|
597
|
|
|
2 => 'jpeg', |
|
598
|
|
|
3 => 'png', |
|
599
|
|
|
4 => 'gif' |
|
600
|
|
|
); |
|
601
|
|
|
|
|
602
|
|
|
$ext = explode(".",$image); |
|
603
|
|
|
|
|
604
|
|
|
if (@!in_array(strtolower ($ext[1]), $type) || $image == '') { |
|
605
|
|
|
$avatar = ''; |
|
606
|
|
|
} else { |
|
607
|
|
|
$avatar = $image; |
|
608
|
|
|
} |
|
609
|
|
|
|
|
610
|
|
|
return $avatar; |
|
611
|
|
|
} |
|
612
|
|
|
|
|
613
|
|
|
// find user with most posted messages |
|
614
|
|
|
function Smallworld_mostactiveusers_allround() |
|
615
|
|
|
{ |
|
616
|
|
|
global $xoopsDB,$xoopsUser; |
|
|
|
|
|
|
617
|
|
|
$sql = "SELECT uid_fk, COUNT( * ) as cnt "; |
|
618
|
|
|
$sql .= "FROM ( "; |
|
619
|
|
|
$sql .= "SELECT uid_fk "; |
|
620
|
|
|
$sql .= "FROM ".$xoopsDB->prefix('smallworld_messages')." "; |
|
621
|
|
|
$sql .= "UNION ALL SELECT uid_fk "; |
|
622
|
|
|
$sql .= "FROM ".$xoopsDB->prefix('smallworld_comments')." "; |
|
623
|
|
|
$sql .= ") AS u "; |
|
624
|
|
|
$sql .= "GROUP BY uid_fk "; |
|
625
|
|
|
$sql .= "ORDER BY count( * ) DESC limit 3"; |
|
626
|
|
|
$result = $xoopsDB->queryF($sql); |
|
627
|
|
|
$counter = $xoopsDB->getRowsNum($result); |
|
628
|
|
|
if ($counter < 1) { |
|
|
|
|
|
|
629
|
|
|
} else { |
|
630
|
|
|
$msg = array(); |
|
631
|
|
|
$counter = 1; |
|
632
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
|
633
|
|
|
$msg[$counter]["counter"] = $counter; |
|
634
|
|
|
$msg[$counter]["img"] = smallworld_getAvatarLink ($row['uid_fk'], Smallworld_Gravatar($row['uid_fk'])); |
|
635
|
|
|
$msg[$counter]["msgs"] = _SMALLWORLD_TOTALPOSTS." : ".$row["cnt"]; |
|
636
|
|
|
$msg[$counter]["cnt"] = $row["cnt"]; |
|
637
|
|
|
$msg[$counter]["username"] = $xoopsUser->getUnameFromId($row["uid_fk"]); |
|
638
|
|
|
$msg[$counter]["username_link"] = "<a href = '".XOOPS_URL."/modules/smallworld/userprofile.php?username=".$msg[$counter]["username"]."'>"; |
|
639
|
|
|
$msg[$counter]["username_link"] .= $msg[$counter]["username"]." (".$msg[$counter]["msgs"].")</a>"; |
|
640
|
|
|
$counter++; |
|
641
|
|
|
} |
|
642
|
|
|
} |
|
643
|
|
|
|
|
644
|
|
|
return $msg; |
|
|
|
|
|
|
645
|
|
|
} |
|
646
|
|
|
|
|
647
|
|
|
// Find worst rated users overall |
|
648
|
|
View Code Duplication |
function Smallworld_worstratedusers() |
|
|
|
|
|
|
649
|
|
|
{ |
|
650
|
|
|
global $xoopsUser, $xoopsDB; |
|
|
|
|
|
|
651
|
|
|
$array = array(); |
|
652
|
|
|
$counter = 1; |
|
653
|
|
|
$sql = "SELECT owner, ("; |
|
654
|
|
|
$sql .= "sum( up ) - sum( down )"; |
|
655
|
|
|
$sql .= ") AS total"; |
|
656
|
|
|
$sql .= " FROM ".$xoopsDB->prefix('smallworld_vote').""; |
|
657
|
|
|
$sql .= " GROUP BY owner ORDER by total ASC LIMIT 5"; |
|
658
|
|
|
$result = $xoopsDB->queryF($sql); |
|
659
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
|
660
|
|
|
$array[$counter]['counter'] = $counter; |
|
661
|
|
|
$array[$counter]['img'] = smallworld_getAvatarLink ($row["owner"], Smallworld_Gravatar($row["owner"])); |
|
662
|
|
|
$array[$counter]['user'] = $xoopsUser->getUnameFromId($row["owner"]); |
|
663
|
|
|
$array[$counter]['rating'] = $row["total"]; |
|
664
|
|
|
$array[$counter]['user_link'] = "<a href = '".XOOPS_URL."/modules/smallworld/userprofile.php?username=".$array[$counter]['user']."'>"; |
|
665
|
|
|
$array[$counter]['user_link'] .= $array[$counter]['user']." (".$array[$counter]['rating'].")</a>"; |
|
666
|
|
|
$counter++; |
|
667
|
|
|
} |
|
668
|
|
|
|
|
669
|
|
|
return $array; |
|
670
|
|
|
} |
|
671
|
|
|
|
|
672
|
|
|
// Find best rated users overall |
|
673
|
|
View Code Duplication |
function Smallworld_topratedusers() |
|
|
|
|
|
|
674
|
|
|
{ |
|
675
|
|
|
global $xoopsUser, $xoopsDB; |
|
|
|
|
|
|
676
|
|
|
$array = array(); |
|
677
|
|
|
$counter = 1; |
|
678
|
|
|
$sql = "SELECT owner, ("; |
|
679
|
|
|
$sql .= "sum( up ) - sum( down )"; |
|
680
|
|
|
$sql .= ") AS total"; |
|
681
|
|
|
$sql .= " FROM ".$xoopsDB->prefix('smallworld_vote').""; |
|
682
|
|
|
$sql .= " GROUP BY owner ORDER by total DESC LIMIT 5"; |
|
683
|
|
|
$result = $xoopsDB->queryF($sql); |
|
684
|
|
|
while ($row = $xoopsDB->fetchArray($result)) { |
|
685
|
|
|
$array[$counter]['counter'] = $counter; |
|
686
|
|
|
$array[$counter]['img'] = smallworld_getAvatarLink ($row["owner"], Smallworld_Gravatar($row["owner"])); |
|
687
|
|
|
$array[$counter]['user'] = $xoopsUser->getUnameFromId($row["owner"]); |
|
688
|
|
|
$array[$counter]['rating'] = $row["total"]; |
|
689
|
|
|
$array[$counter]['user_link'] = "<a href = '".XOOPS_URL."/modules/smallworld/userprofile.php?username=".$array[$counter]['user']."'>"; |
|
690
|
|
|
$array[$counter]['user_link'] .= $array[$counter]['user']." (".$array[$counter]['rating'].")</a>"; |
|
691
|
|
|
$counter++; |
|
692
|
|
|
} |
|
693
|
|
|
|
|
694
|
|
|
return $array; |
|
695
|
|
|
} |
|
696
|
|
|
|
|
697
|
|
|
function smallworld_nextBirthdays() |
|
698
|
|
|
{ |
|
699
|
|
|
global $xoopsDB,$xoopsUser; |
|
|
|
|
|
|
700
|
|
|
$now = date('d-m'); |
|
|
|
|
|
|
701
|
|
|
$res = array(); |
|
702
|
|
|
$sql = 'SELECT userid, username, userimage, realname, birthday, CURDATE(),' |
|
703
|
|
|
. ' DATE_FORMAT(birthday, "%d / %m") AS daymon , ' |
|
704
|
|
|
. ' (YEAR(CURDATE())-YEAR(birthday))' |
|
705
|
|
|
. ' - (RIGHT(CURDATE(),5)<RIGHT(birthday,5))' |
|
706
|
|
|
. ' AS age_now' |
|
707
|
|
|
. ' FROM xoops_smallworld_user WHERE right(birthday,5) = right(CURDATE(),5)' |
|
708
|
|
|
. ' ORDER BY MONTH( birthday ) , DAY( birthday ) ' |
|
709
|
|
|
. ' LIMIT 10 '; |
|
710
|
|
|
$result = $xoopsDB->queryF($sql); |
|
711
|
|
|
$counter = $xoopsDB->getRowsNum($result); |
|
712
|
|
|
$i = 0; |
|
713
|
|
|
while ($r = $xoopsDB->fetchArray($result)) { |
|
714
|
|
|
$res[$i]['amount'] = $counter; |
|
715
|
|
|
$res[$i]['userid'] = $r['userid']; |
|
716
|
|
|
$res[$i]['userimage'] = smallworld_getAvatarLink ($r['userid'], Smallworld_Gravatar($r["userid"])); |
|
717
|
|
|
$res[$i]['birthday'] = $r['daymon']; |
|
718
|
|
|
$res[$i]['agenow'] = $r['age_now']; |
|
719
|
|
|
$res[$i]['username'] = $xoopsUser->getUnameFromId($r['userid']); |
|
720
|
|
|
$res[$i]['username_link'] = "<a href = '".XOOPS_URL."/modules/smallworld/userprofile.php?username=".$res[$i]['username']."'>"; |
|
721
|
|
|
$res[$i]['username_link'] .= $res[$i]['username']." (".$r['daymon'].") ".$r['age_now']." "._SMALLWORLD_BDAY_YEARS; |
|
722
|
|
|
$res[$i]['username_link'] .="</a>"; |
|
723
|
|
|
$i++; |
|
724
|
|
|
} |
|
725
|
|
|
|
|
726
|
|
|
return $res; |
|
727
|
|
|
} |
|
728
|
|
|
|
|
729
|
|
|
/* |
|
730
|
|
|
* Return date format (YYYY-MM-DD) for MySql |
|
731
|
|
|
* @param date $stringDate |
|
732
|
|
|
* $returns date |
|
733
|
|
|
*/ |
|
734
|
|
View Code Duplication |
function Smallworld_euroToUsDate($stringDate) |
|
|
|
|
|
|
735
|
|
|
{ |
|
736
|
|
|
if ($stringDate != 0 || $stringDate != '') { |
|
737
|
|
|
$theData = explode("-", trim($stringDate)); |
|
738
|
|
|
$ret = $theData[2] . "-" . $theData[1] . "-" . $theData[0]; |
|
739
|
|
|
|
|
740
|
|
|
return $ret; |
|
741
|
|
|
} else { |
|
742
|
|
|
return "1900-01-01"; |
|
743
|
|
|
} |
|
744
|
|
|
} |
|
745
|
|
|
|
|
746
|
|
|
/* |
|
747
|
|
|
* Return date format (DD-MM-YYYY) for display |
|
748
|
|
|
* @param date $stringDate |
|
749
|
|
|
* $returns date |
|
750
|
|
|
*/ |
|
751
|
|
View Code Duplication |
function Smallworld_UsToEuroDate($stringDate) |
|
|
|
|
|
|
752
|
|
|
{ |
|
753
|
|
|
if ($stringDate != 0 || $stringDate != '') { |
|
754
|
|
|
$theData = explode("-", trim($stringDate)); |
|
755
|
|
|
$ret = $theData[2] . "-" . $theData[1] . "-" . $theData[0]; |
|
756
|
|
|
|
|
757
|
|
|
return $ret; |
|
758
|
|
|
} else { |
|
759
|
|
|
return "01-01-1900"; |
|
760
|
|
|
} |
|
761
|
|
|
} |
|
762
|
|
|
|
|
763
|
|
|
function smallworld_sp () |
|
764
|
|
|
{ |
|
765
|
|
|
$sp = array(); |
|
766
|
|
|
$sp[0]['spimage'] = "<img id = 'smallworld_img_sp' src = '" |
|
767
|
|
|
. XOOPS_URL . "/modules/smallworld/images/sp.png' height='30px' width='30px' />"; |
|
768
|
|
|
|
|
769
|
|
|
return $sp; |
|
770
|
|
|
} |
|
771
|
|
|
|
|
772
|
|
|
//Check privacy settings in permapage |
|
773
|
|
View Code Duplication |
function smallworldCheckPriv ($id) |
|
|
|
|
|
|
774
|
|
|
{ |
|
775
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
776
|
|
|
$public = "SELECT priv FROM ".$xoopsDB->prefix('smallworld_messages')." WHERE msg_id = ".$id.""; |
|
777
|
|
|
$result = $xoopsDB->queryF($public); |
|
778
|
|
|
while ($row = $xoopsDB->fetchArray($result)){ |
|
779
|
|
|
$priv = $row['priv']; |
|
780
|
|
|
} |
|
781
|
|
|
|
|
782
|
|
|
return $priv; |
|
|
|
|
|
|
783
|
|
|
} |
|
784
|
|
|
|
|
785
|
|
|
// Function to calculate remaining seconds until user's birthday |
|
786
|
|
|
// Input $d : date('Y-m-d') format |
|
787
|
|
|
// return seconds until date at midnight, or |
|
788
|
|
|
// return 0 if date ('Y-m-d') is equal to today |
|
789
|
|
|
function smallworldNextBDaySecs($d) |
|
790
|
|
|
{ |
|
791
|
|
|
$olddate = substr($d, 4); |
|
792
|
|
|
$exactdate = date('Y') . "" . $olddate; |
|
793
|
|
|
$newdate = date('Y') . "" . $olddate . " 00:00:00"; |
|
794
|
|
|
$nextyear = date('Y') + 1 . "" . $olddate . " 00:00:00"; |
|
795
|
|
|
if ($exactdate != date('Y-m-d')) { |
|
796
|
|
|
if($newdate > date("Y-m-d H:i:s")) { |
|
797
|
|
|
$start_ts = strtotime($newdate); |
|
798
|
|
|
$end_ts = strtotime(date("Y-m-d H:i:s")); |
|
799
|
|
|
$diff = $end_ts - $start_ts; |
|
800
|
|
|
$n = round($diff); |
|
801
|
|
|
$return = substr($n, 1); |
|
802
|
|
|
|
|
803
|
|
|
return $return; |
|
804
|
|
|
} else { |
|
805
|
|
|
$start_ts = strtotime($nextyear); |
|
806
|
|
|
$end_ts = strtotime(date("Y-m-d H:i:s")); |
|
807
|
|
|
$diff = $end_ts - $start_ts; |
|
808
|
|
|
$n = round($diff); |
|
809
|
|
|
$return = substr($n, 1); |
|
810
|
|
|
|
|
811
|
|
|
return $return; |
|
812
|
|
|
} |
|
813
|
|
|
} else { |
|
814
|
|
|
return 0; |
|
815
|
|
|
} |
|
816
|
|
|
} |
|
817
|
|
|
|
|
818
|
|
|
//Function to get value from xoopsConfig array |
|
819
|
|
|
function smallworldGetValfromArray($key, $array) |
|
820
|
|
|
{ |
|
821
|
|
|
$ar = smallworld_GetModuleOption($array, $repmodule='smallworld'); |
|
822
|
|
|
$ret = 0; |
|
|
|
|
|
|
823
|
|
|
if (in_array($key, $ar,true)) { |
|
824
|
|
|
$ret = 1; |
|
825
|
|
|
|
|
826
|
|
|
return $ret; |
|
827
|
|
|
} else { |
|
828
|
|
|
return 0; |
|
829
|
|
|
} |
|
830
|
|
|
|
|
831
|
|
|
} |
|
832
|
|
|
|
|
833
|
|
|
//Function to resize images proportionally |
|
834
|
|
|
// Using imagesize($imageurl) returns $img[0], $img[1] |
|
835
|
|
|
// Target = new max height or width in px |
|
836
|
|
|
function smallworld_imageResize($width, $height, $target) |
|
|
|
|
|
|
837
|
|
|
{ |
|
838
|
|
|
//takes the larger size of the width and height and applies the |
|
839
|
|
|
//formula accordingly...this is so this script will work |
|
840
|
|
|
//dynamically with any size image |
|
841
|
|
|
if ($width > $height) { |
|
842
|
|
|
$percentage = ($target / $width); |
|
843
|
|
|
} else { |
|
844
|
|
|
$percentage = ($target / $height); |
|
845
|
|
|
} |
|
846
|
|
|
//gets the new value and applies the percentage, then rounds the value |
|
847
|
|
|
$width = round($width * $percentage); |
|
848
|
|
|
$height = round($height * $percentage); |
|
849
|
|
|
//returns the new sizes in html image tag format...this is so you |
|
850
|
|
|
//can plug this function inside an image tag and just get the |
|
851
|
|
|
|
|
852
|
|
|
return "width=\"$width\" height=\"$height\""; |
|
853
|
|
|
} |
|
854
|
|
|
|
|
855
|
|
|
/** |
|
856
|
|
|
* Fetch image width and height |
|
857
|
|
|
* will attempt to use the getimagesiz method first, then curl |
|
858
|
|
|
* @param int $w |
|
859
|
|
|
* @param int $h |
|
860
|
|
|
* @param url $url |
|
861
|
|
|
* @returns array |
|
862
|
|
|
*/ |
|
863
|
|
|
function smallworld_getImageSize($w, $h, $url) |
|
864
|
|
|
{ |
|
865
|
|
|
$bn = basename($url); |
|
866
|
|
|
if ($bn != 'blank.gif' |
|
867
|
|
|
|| $bn != 'blank.png' |
|
868
|
|
|
|| $bn != 'blank.jpg' |
|
869
|
|
|
|| $bn != 'image_missing.png' |
|
870
|
|
|
) |
|
871
|
|
|
{ |
|
872
|
|
|
if (ini_get('allow_url_fopen')) { |
|
873
|
|
|
$imagesize = getimagesize($url); |
|
874
|
|
|
} else { |
|
875
|
|
|
$imagesize['0'] = $w; |
|
|
|
|
|
|
876
|
|
|
$imagesize['1'] = $h; |
|
877
|
|
|
} |
|
878
|
|
|
|
|
879
|
|
|
if (!ini_get('allow_url_fopen')) { |
|
880
|
|
|
if (function_exists('curl_init')) { |
|
881
|
|
|
$ch = curl_init(); |
|
882
|
|
|
curl_setopt($ch, CURLOPT_URL, $url); |
|
883
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
884
|
|
|
$result = curl_exec($ch); |
|
885
|
|
|
$img = ImageCreateFromString($result); |
|
886
|
|
|
$imagesize['0'] = imagesx($img); |
|
887
|
|
|
$imagesize['1'] = imagesy($img); |
|
888
|
|
|
} else { |
|
889
|
|
|
$imagesize['0'] = $w; |
|
890
|
|
|
$imagesize['1'] = $h; |
|
891
|
|
|
} |
|
892
|
|
|
} |
|
893
|
|
|
|
|
894
|
|
|
return $imagesize; |
|
895
|
|
|
} else { |
|
896
|
|
|
return array(0 => '0', 1 => '0'); |
|
897
|
|
|
} |
|
898
|
|
|
} |
|
899
|
|
|
|
|
900
|
|
|
/** |
|
901
|
|
|
* Check weather requests are set or not |
|
902
|
|
|
* If not return '' else return false |
|
903
|
|
|
* @param string $req |
|
904
|
|
|
* @returns string or void |
|
905
|
|
|
*/ |
|
906
|
|
|
|
|
907
|
|
|
function smallworld_isset($req) |
|
908
|
|
|
{ |
|
909
|
|
|
if(isset($req) || !empty($req)) { |
|
910
|
|
|
return $req; |
|
911
|
|
|
} else { |
|
912
|
|
|
return ''; |
|
913
|
|
|
} |
|
914
|
|
|
} |
|
915
|
|
|
|
|
916
|
|
|
/** |
|
917
|
|
|
* @do db query for images upload last 5 minutes by spec. userid and return random |
|
918
|
|
|
* @param int $userid |
|
919
|
|
|
* @returns string |
|
920
|
|
|
*/ |
|
921
|
|
View Code Duplication |
function smallworld_getRndImg($userid) |
|
|
|
|
|
|
922
|
|
|
{ |
|
923
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
924
|
|
|
$sql = "SELECT imgname FROM " . $xoopsDB->prefix('smallworld_images') . " WHERE userid = " . $userid |
|
925
|
|
|
. " AND time BETWEEN UNIX_TIMESTAMP( ) - 3000 AND UNIX_TIMESTAMP() ORDER BY rand() limit 1"; |
|
926
|
|
|
$result = $xoopsDB->queryF($sql); |
|
927
|
|
|
while ($r = $xoopsDB->fetchArray($result)) { |
|
928
|
|
|
$img = $r['imgname']; |
|
929
|
|
|
} |
|
930
|
|
|
if (!empty($img)) { |
|
931
|
|
|
return $img; |
|
932
|
|
|
} else { |
|
933
|
|
|
return false; |
|
934
|
|
|
} |
|
935
|
|
|
} |
|
936
|
|
|
|
|
937
|
|
|
/** |
|
938
|
|
|
* @Get url of smallworld |
|
939
|
|
|
* @returns string |
|
940
|
|
|
*/ |
|
941
|
|
|
function smallworld_getHostRequest() |
|
|
|
|
|
|
942
|
|
|
{ |
|
943
|
|
|
$protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https') === FALSE ? 'http' : 'https'; |
|
944
|
|
|
$host = $_SERVER['HTTP_HOST']; |
|
945
|
|
|
$script = $_SERVER['SCRIPT_NAME']; |
|
|
|
|
|
|
946
|
|
|
$params = $_SERVER['QUERY_STRING']; |
|
|
|
|
|
|
947
|
|
|
$currentUrl = $protocol . '://' . $host; |
|
948
|
|
|
|
|
949
|
|
|
return $currentUrl; |
|
950
|
|
|
} |
|
951
|
|
|
|
|
952
|
|
|
/** |
|
953
|
|
|
* @Get htmlentities |
|
954
|
|
|
* @return translated string to utf-8 |
|
|
|
|
|
|
955
|
|
|
*/ |
|
956
|
|
|
function smallworld_decodeEntities($text) |
|
957
|
|
|
{ |
|
958
|
|
|
$text= html_entity_decode($text,ENT_QUOTES,"ISO-8859-1"); #NOTE: UTF-8 does not work! |
|
959
|
|
|
$text= preg_replace('/&#(\d+);/me',"chr(\\1)",$text); #decimal notation |
|
960
|
|
|
$text= preg_replace('/&#x([a-f0-9]+);/mei',"chr(0x\\1)",$text); #hex notation |
|
961
|
|
|
return $text; |
|
962
|
|
|
} |
|
963
|
|
|
|
|
964
|
|
|
/** |
|
965
|
|
|
* @Get string and shorten so contains only ? chars |
|
966
|
|
|
* @Param $text |
|
967
|
|
|
* @Param $chars |
|
968
|
|
|
* return string first ? chars |
|
969
|
|
|
*/ |
|
970
|
|
|
function smallworld_shortenText($text, $chars) |
|
971
|
|
|
{ |
|
972
|
|
|
$text = $text." "; |
|
973
|
|
|
$text = substr($text,0,$chars); |
|
974
|
|
|
$text = substr($text,0,strrpos($text,' ')); |
|
975
|
|
|
$text = $text."..."; |
|
976
|
|
|
|
|
977
|
|
|
return $text; |
|
978
|
|
|
} |
|
979
|
|
|
|
|
980
|
|
|
/** |
|
981
|
|
|
* @Get languagefile if constants are not defined |
|
982
|
|
|
* @param $def |
|
983
|
|
|
* @file |
|
984
|
|
|
* return file include |
|
985
|
|
|
*/ |
|
986
|
|
|
function smallworld_isDefinedLanguage ($def, $file) |
|
987
|
|
|
{ |
|
988
|
|
|
global $xoopsConfig; |
|
|
|
|
|
|
989
|
|
|
if (!defined($def)){ |
|
990
|
|
|
// language files (main.php) |
|
991
|
|
|
if( file_exists(XOOPS_ROOT_PATH.'/modules/smallworld/language/'.$xoopsConfig['language'].'/'.$file ) ) { |
|
992
|
|
|
include_once XOOPS_ROOT_PATH.'/modules/smallworld/language/'.$xoopsConfig['language'].'/'.$file; |
|
993
|
|
|
} else { |
|
994
|
|
|
// fallback english |
|
995
|
|
|
include_once XOOPS_ROOT_PATH.'/modules/smallworld/language/english/'.'/'.$file; |
|
996
|
|
|
} |
|
997
|
|
|
} |
|
998
|
|
|
} |
|
999
|
|
|
|
|
1000
|
|
|
/** |
|
1001
|
|
|
* @Check if smallworld is for private or public access |
|
1002
|
|
|
* return value for config |
|
1003
|
|
|
*/ |
|
1004
|
|
|
function smallworld_checkPrivateOrPublic () |
|
1005
|
|
|
{ |
|
1006
|
|
|
global $xoopsUser; |
|
|
|
|
|
|
1007
|
|
|
$opt = array(); |
|
1008
|
|
|
$set = smallworld_GetModuleOption('smallworldprivorpub', $repmodule='smallworld'); |
|
1009
|
|
|
if ($set != 0) { |
|
1010
|
|
|
$opt['access'] = 1; |
|
1011
|
|
|
} else { |
|
1012
|
|
|
$opt['access'] = 0; |
|
1013
|
|
|
} |
|
1014
|
|
|
if ($xoopsUser) { |
|
1015
|
|
|
$id = $xoopsUser->getVar('uid'); |
|
1016
|
|
|
$user = new XoopsUser($id); |
|
|
|
|
|
|
1017
|
|
|
$check = new SmallWorldUser; |
|
1018
|
|
|
$profile = $check->checkIfProfile($id); |
|
1019
|
|
|
$opt['xoopsuser'] = 1; |
|
1020
|
|
|
if ($profile != 0) { |
|
1021
|
|
|
$opt['smallworlduser'] = 1; |
|
1022
|
|
|
} else { |
|
1023
|
|
|
$opt['smallworlduser'] = 0; |
|
1024
|
|
|
} |
|
1025
|
|
|
} else { |
|
1026
|
|
|
$opt['xoopsuser'] = 0; |
|
1027
|
|
|
$opt['smallworlduser'] = 0; |
|
1028
|
|
|
} |
|
1029
|
|
|
|
|
1030
|
|
|
return $opt; |
|
1031
|
|
|
} |
|
1032
|
|
|
|
|
1033
|
|
|
/** |
|
1034
|
|
|
* @return array of groups |
|
1035
|
|
|
* return array |
|
1036
|
|
|
* |
|
1037
|
|
|
*/ |
|
1038
|
|
|
function smallworld_xv_getGroupd () { |
|
1039
|
|
|
$db =& XoopsDatabaseFactory::getDatabaseConnection(); |
|
1040
|
|
|
$myts =& MyTextSanitizer::getInstance(); |
|
1041
|
|
|
$sql = "SELECT userid, username FROM ".$db->prefix('smallworld_user')." ORDER BY userid"; |
|
1042
|
|
|
$result = $db->queryF($sql); |
|
1043
|
|
|
$num = $db->getRowsNum($result); |
|
1044
|
|
|
if ($num == 0) { |
|
1045
|
|
|
$ndata = array(0 => _MI_SMALLWORLD_ALL); |
|
1046
|
|
|
} else { |
|
1047
|
|
|
while ($r = $db->fetchArray($result)) { |
|
1048
|
|
|
$data[$r['userid']] = $r['username']; |
|
|
|
|
|
|
1049
|
|
|
} |
|
1050
|
|
|
$ndata = array(0 => _MI_SMALLWORLD_ALL) + $data; |
|
|
|
|
|
|
1051
|
|
|
} |
|
1052
|
|
|
|
|
1053
|
|
|
return $ndata; |
|
1054
|
|
|
} |
|
1055
|
|
|
|
|
1056
|
|
|
/** |
|
1057
|
|
|
* Set javascript vars to theme using various values |
|
1058
|
|
|
* Return void |
|
1059
|
|
|
*/ |
|
1060
|
|
|
function smallworld_SetCoreScript () { |
|
1061
|
|
|
global $xoopsUser, $xoopsConfig, $xoTheme; |
|
|
|
|
|
|
1062
|
|
|
|
|
1063
|
|
|
$module_handler =& xoops_gethandler('module'); |
|
1064
|
|
|
$module = $module_handler->getByDirname('smallworld'); |
|
1065
|
|
|
$config_handler =& xoops_gethandler('config'); |
|
1066
|
|
|
if ($module) { |
|
1067
|
|
|
$moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); |
|
1068
|
|
|
} |
|
1069
|
|
|
|
|
1070
|
|
|
// IF logged in define xoops / smallworld user id |
|
1071
|
|
|
$myid = ($xoopsUser) ? $xoopsUser->getVar('uid'):0; |
|
1072
|
|
|
|
|
1073
|
|
|
// Check if option is et to allow public reading |
|
1074
|
|
|
$pub = smallworld_checkPrivateOrPublic(); |
|
1075
|
|
|
$access = $pub['access']; |
|
|
|
|
|
|
1076
|
|
|
|
|
1077
|
|
|
// GET various variables from language folder |
|
1078
|
|
View Code Duplication |
if (file_exists(XOOPS_ROOT_PATH.'/modules/smallworld/language/'.$xoopsConfig['language'].'/js/variables.js')) { |
|
|
|
|
|
|
1079
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/language/'.$xoopsConfig['language'].'/js/variables.js'); |
|
1080
|
|
|
} else { |
|
1081
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/language/english/js/variables.js'); |
|
1082
|
|
|
} |
|
1083
|
|
|
|
|
1084
|
|
|
// Check if USER is smallworld-registered user |
|
1085
|
|
|
$chkUser = new SmallWorldUser; |
|
1086
|
|
|
$ChkProf = ($xoopsUser) ? $chkUser->CheckIfProfile($myid):0; |
|
1087
|
|
|
|
|
1088
|
|
|
// Check if there are requests pending |
|
1089
|
|
|
$count_invit = ($xoopsUser) ? count($chkUser->getRequests($myid)):0; |
|
1090
|
|
|
|
|
1091
|
|
|
// Get module config for validation and place in javascript |
|
1092
|
|
|
$validate = $moduleConfig['validationstrenght']; |
|
|
|
|
|
|
1093
|
|
|
|
|
1094
|
|
|
// Check to see if smallworld should use username links to point to default xoops or smallworld |
|
1095
|
|
|
$takeoverlinks = $moduleConfig['takeoveruserlinks']; |
|
1096
|
|
|
$fieldstoshow = array_flip(smallworld_GetModuleOption('smallworldusethesefields', $repmodule='smallworld')); |
|
|
|
|
|
|
1097
|
|
|
$useverification = smallworld_GetModuleOption('smallworldmandatoryfields', $repmodule='smallworld'); |
|
1098
|
|
|
$smallworldUV = implode(',', $useverification); |
|
1099
|
|
|
|
|
1100
|
|
|
// Use googlemaps ? |
|
1101
|
|
|
$googlemaps = $moduleConfig['smallworldUseGoogleMaps']; |
|
1102
|
|
|
|
|
1103
|
|
|
// Get users messages count based on users followerArray |
|
1104
|
|
|
$getUserMsgNum = ($xoopsUser) ? smallworld_getCountFriendMessagesEtc():0; |
|
1105
|
|
|
|
|
1106
|
|
|
// Check if request url is with www or without |
|
1107
|
|
|
$urltest = smallworld_getHostRequest(); |
|
1108
|
|
|
$xoops_url = XOOPS_URL; |
|
1109
|
|
|
if (!strstr($urltest, 'www.')) { |
|
1110
|
|
|
$xoops_url = str_replace( 'www.', '', $xoops_url ); |
|
1111
|
|
|
} |
|
1112
|
|
|
|
|
1113
|
|
|
// Set javascript vars but only if not already defined. |
|
1114
|
|
|
// Check prevents multible loads |
|
1115
|
|
|
$script = "var Smallworld_myID;"."\n"; |
|
1116
|
|
|
$script .= "if (typeof Smallworld_myID === 'undefined') {"."\n"; |
|
1117
|
|
|
$script .= "var smallworld_url = '" . $xoops_url . "/modules/smallworld/" . "';\n"; |
|
1118
|
|
|
$script .= "var smallworld_uploaddir = '" . $xoops_url . "/uploads/avatars/" . "';\n"; |
|
1119
|
|
|
$script .= "var smallworld_urlReferer = document.referrer;"."\n"; |
|
1120
|
|
|
$script .= "var xoops_smallworld = jQuery.noConflict();\n"; |
|
1121
|
|
|
$script .= "var Smallworld_myID = " . $myid . ";\n"; |
|
1122
|
|
|
$script .= "var Smallworld_userHasProfile = " . $ChkProf . ";\n"; |
|
1123
|
|
|
$script .= "var smallworldTakeOverLinks = " . $takeoverlinks . ";\n"; |
|
1124
|
|
|
$script .= "var Smallworld_geocomplete = " . $googlemaps . ";\n"; |
|
1125
|
|
|
$script .= "var smallworldVerString = '" . $smallworldUV . "';\n"; |
|
1126
|
|
|
$script .= "var smallworlduseverification = new Array();\n"; |
|
1127
|
|
|
$script .= "smallworlduseverification = smallworldVerString.split(',');\n"; |
|
1128
|
|
|
$script .= "var Smallworld_hasmessages = " . $count_invit . ";\n"; |
|
1129
|
|
|
$script .= "var smallworldvalidationstrenght = " . $validate . ";\n"; |
|
1130
|
|
|
$script .= "var smallworld_getFriendsMsgComCount = " . $getUserMsgNum . ";\n"; |
|
1131
|
|
|
//$script .= "var $ = jQuery();\n"; |
|
|
|
|
|
|
1132
|
|
|
$script .= "}"."\n"; |
|
1133
|
|
|
$xoTheme->addScript('','',$script); |
|
1134
|
|
|
|
|
1135
|
|
|
// Include geolocate styling |
|
1136
|
|
|
if ($googlemaps == 1) { |
|
1137
|
|
|
$xoTheme->addScript("https://maps.googleapis.com/maps/api/js?sensor=false&language="._LANGCODE); |
|
1138
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/ui.geo_autocomplete.js'); |
|
1139
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/ui.geo_autocomplete_now.js'); |
|
1140
|
|
|
} |
|
1141
|
|
|
|
|
1142
|
|
|
smallworld_includeScripts (); |
|
1143
|
|
|
|
|
1144
|
|
|
} |
|
1145
|
|
|
|
|
1146
|
|
|
/** |
|
1147
|
|
|
* Include script files based on $page |
|
1148
|
|
|
* @return void |
|
1149
|
|
|
*/ |
|
1150
|
|
|
|
|
1151
|
|
|
function smallworld_includeScripts () { |
|
|
|
|
|
|
1152
|
|
|
global $xoopsUser, $xoopsConfig, $xoTheme; |
|
|
|
|
|
|
1153
|
|
|
$page = basename ($_SERVER['PHP_SELF'],".php"); |
|
1154
|
|
|
switch ($page) { |
|
1155
|
|
View Code Duplication |
case 'register': |
|
|
|
|
|
|
1156
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.colorbox.js'); |
|
1157
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.validate.js'); |
|
1158
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.validation.functions.js'); |
|
1159
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.stepy.js'); |
|
1160
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.elastic.source.js'); |
|
1161
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/smallworld.css'); |
|
1162
|
|
|
break; |
|
1163
|
|
|
|
|
1164
|
|
View Code Duplication |
case 'publicindex': |
|
|
|
|
|
|
1165
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.oembed.js'); |
|
1166
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.elastic.source.js'); |
|
1167
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/wall.js'); |
|
1168
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/ajaxupload.3.5.js'); |
|
1169
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.avatar_helper.js'); |
|
1170
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.bookmark.js'); |
|
1171
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/oembed.css'); |
|
1172
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.colorbox.js'); |
|
1173
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/smallworld.css'); |
|
1174
|
|
|
break; |
|
1175
|
|
|
|
|
1176
|
|
View Code Duplication |
case 'permalink': |
|
|
|
|
|
|
1177
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.oembed.js'); |
|
1178
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/wall.js'); |
|
1179
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/oembed.css'); |
|
1180
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/smallworld.css'); |
|
1181
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.innerfade.js'); |
|
1182
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.elastic.source.js'); |
|
1183
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.bookmark.js'); |
|
1184
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.colorbox.js'); |
|
1185
|
|
|
break; |
|
1186
|
|
|
|
|
1187
|
|
View Code Duplication |
case 'index': |
|
|
|
|
|
|
1188
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.oembed.js'); |
|
1189
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.elastic.source.js'); |
|
1190
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/wall.js'); |
|
1191
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/ajaxupload.3.5.js'); |
|
1192
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.avatar_helper.js'); |
|
1193
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.bookmark.js'); |
|
1194
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/oembed.css'); |
|
1195
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.colorbox.js'); |
|
1196
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/smallworld.css'); |
|
1197
|
|
|
break; |
|
1198
|
|
|
|
|
1199
|
|
|
case 'img_upload': |
|
1200
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/uploader/bootstrap.min.css'); |
|
1201
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/uploader/style.css'); |
|
1202
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/uploader/bootstrap-responsive.min.css'); |
|
1203
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/uploader/bootstrap-image-gallery.min.css'); |
|
1204
|
|
|
|
|
1205
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/vendor/jquery.ui.widget.js'); |
|
1206
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/uploader/tmpl.js'); |
|
1207
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/uploader/load-image.js'); |
|
1208
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/uploader/canvas-to-blob.js'); |
|
1209
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/uploader/bootstrap.js'); |
|
1210
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/uploader/bootstrap-image-gallery.js'); |
|
1211
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.iframe-transport.js'); |
|
1212
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.fileupload.js'); |
|
1213
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.fileupload-fp.js'); |
|
1214
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.fileupload-ui.js'); |
|
1215
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/main.js'); |
|
1216
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.colorbox.js'); |
|
1217
|
|
|
break; |
|
1218
|
|
|
|
|
1219
|
|
View Code Duplication |
case 'galleryshow': |
|
|
|
|
|
|
1220
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/galleriffic-5.css'); |
|
1221
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.galleriffic.js'); |
|
1222
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.history.js'); |
|
1223
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.opacityrollover.js'); |
|
1224
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/gallery_mod.js'); |
|
1225
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.innerfade.js'); |
|
1226
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.colorbox.js'); |
|
1227
|
|
|
break; |
|
1228
|
|
|
|
|
1229
|
|
View Code Duplication |
case 'friends': |
|
|
|
|
|
|
1230
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/apprise-1.5.full.js'); |
|
1231
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/jquery.fileupload-ui.css'); |
|
1232
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/oembed.css'); |
|
1233
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.oembed.js'); |
|
1234
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/wall.js'); |
|
1235
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/ajaxupload.3.5.js'); |
|
1236
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.avatar_helper.js'); |
|
1237
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.innerfade.js'); |
|
1238
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.colorbox.js'); |
|
1239
|
|
|
//$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/colorbox.css'); |
|
|
|
|
|
|
1240
|
|
|
break; |
|
1241
|
|
|
|
|
1242
|
|
View Code Duplication |
case 'editprofile': |
|
|
|
|
|
|
1243
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.colorbox.js'); |
|
1244
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.validate.js'); |
|
1245
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.validation.functions.js'); |
|
1246
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.stepy.js'); |
|
1247
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.elastic.source.js'); |
|
1248
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/smallworld.css'); |
|
1249
|
|
|
break; |
|
1250
|
|
|
|
|
1251
|
|
View Code Duplication |
case 'smallworldshare': |
|
|
|
|
|
|
1252
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.oembed.js'); |
|
1253
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/wall.js'); |
|
1254
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.innerfade.js'); |
|
1255
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.bookmark.js'); |
|
1256
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/oembed.css'); |
|
1257
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/smallworld.css'); |
|
1258
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.colorbox.js'); |
|
1259
|
|
|
break; |
|
1260
|
|
|
|
|
1261
|
|
|
case 'userprofile': |
|
1262
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/apprise-1.5.full.js'); |
|
1263
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/jquery.fileupload-ui.css'); |
|
1264
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/oembed.css'); |
|
1265
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.oembed.js'); |
|
1266
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/wall.js'); |
|
1267
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/ajaxupload.3.5.js'); |
|
1268
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.avatar_helper.js'); |
|
1269
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.bookmark.js'); |
|
1270
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.colorbox.js'); |
|
1271
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.elastic.source.js'); |
|
1272
|
|
|
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.countdown.js'); |
|
1273
|
|
|
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/smallworld.css'); |
|
1274
|
|
|
break; |
|
1275
|
|
|
} |
|
1276
|
|
|
} |
|
1277
|
|
|
|
|
1278
|
|
|
/** |
|
1279
|
|
|
* Check if permission is set for userid to post publicly |
|
1280
|
|
|
* @return array |
|
1281
|
|
|
*/ |
|
1282
|
|
|
|
|
1283
|
|
|
function smallworld_checkUserPubPostPerm () { |
|
1284
|
|
|
global $xoopsUser,$xoopsModule; |
|
|
|
|
|
|
1285
|
|
|
$check = new SmallWorldUser; |
|
1286
|
|
|
$UserPerPub = smallworld_GetModuleOption('smallworldshowPoPubPage'); |
|
1287
|
|
|
$allUsers = $check->allUsers(); |
|
|
|
|
|
|
1288
|
|
|
if ($UserPerPub[0] != 0) { |
|
1289
|
|
|
$pub = $UserPerPub; |
|
1290
|
|
|
} else { |
|
1291
|
|
|
$pub = $check->allUsers(); |
|
1292
|
|
|
} |
|
1293
|
|
|
|
|
1294
|
|
|
return $pub; |
|
1295
|
|
|
} |
|
1296
|
|
|
/** |
|
1297
|
|
|
* Change @username to urls |
|
1298
|
|
|
* @param string $status_text |
|
1299
|
|
|
* @return string $status_text |
|
1300
|
|
|
*/ |
|
1301
|
|
|
function linkify_twitter_status($status_text) { |
|
1302
|
|
|
// linkify twitter users |
|
1303
|
|
|
//$keywords = preg_split("/[\s,]+/", "hypertext language, programming"); |
|
|
|
|
|
|
1304
|
|
|
$status_text = preg_replace( |
|
1305
|
|
|
'/(^|\s)@(\w+)/', |
|
1306
|
|
|
'\1<a href="'.XOOPS_URL . '/modules/smallworld/userprofile.php?username=\2">' . '@\2</a> ', |
|
1307
|
|
|
$status_text |
|
1308
|
|
|
); |
|
1309
|
|
|
|
|
1310
|
|
|
return $status_text; |
|
1311
|
|
|
} |
|
1312
|
|
|
|
|
1313
|
|
|
/** |
|
1314
|
|
|
* Extract users from @tags |
|
1315
|
|
|
* @param $txt |
|
1316
|
|
|
* @return array @users |
|
1317
|
|
|
**/ |
|
1318
|
|
View Code Duplication |
function smallworld_getUidFromName ($name) |
|
|
|
|
|
|
1319
|
|
|
{ |
|
1320
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
1321
|
|
|
$sql = "Select userid from ".$xoopsDB->prefix('smallworld_user')." where username = '".$name."'"; |
|
1322
|
|
|
$result = $xoopsDB->queryF($sql); |
|
1323
|
|
|
while ($r = $xoopsDB->fetchArray($result)) { |
|
1324
|
|
|
$id = $r['userid']; |
|
1325
|
|
|
} |
|
1326
|
|
|
|
|
1327
|
|
|
return $id; |
|
|
|
|
|
|
1328
|
|
|
} |
|
1329
|
|
|
|
|
1330
|
|
|
/** |
|
1331
|
|
|
* Extract users from @tags |
|
1332
|
|
|
* @param $txt |
|
1333
|
|
|
* @return array @users |
|
|
|
|
|
|
1334
|
|
|
**/ |
|
1335
|
|
|
function smallworld_getTagUsers ($txt, $sender, $permalink='') |
|
1336
|
|
|
{ |
|
1337
|
|
|
$dBase = new SmallWorldDB; |
|
1338
|
|
|
$mail = new smallworld_mail; |
|
1339
|
|
|
preg_match_all("/@([a-zA-Z0-9]+|\\[[a-zA-Z0-9]+\\])/", $txt, $matches); |
|
1340
|
|
|
$users = array_unique($matches[1]); |
|
1341
|
|
|
foreach ($users as $users) { |
|
1342
|
|
|
$uid = smallworld_getUidFromName ($users); |
|
1343
|
|
|
$notify = json_decode($dBase->GetSettings($uid), true); |
|
1344
|
|
|
if (isset ($notify['notify'])) { |
|
1345
|
|
|
if ($notify['notify'] != 0) { |
|
1346
|
|
|
$mail->sendMails ($sender, $uid, 'tag', $link=$permalink, array($txt)); |
|
1347
|
|
|
} |
|
1348
|
|
|
} |
|
1349
|
|
|
|
|
1350
|
|
|
} |
|
1351
|
|
|
} |
|
1352
|
|
|
|
|
1353
|
|
|
/** |
|
1354
|
|
|
* Function to get count of messages in wall |
|
1355
|
|
|
* @param int $uid |
|
1356
|
|
|
* @return int $count |
|
1357
|
|
|
*/ |
|
1358
|
|
|
function smallworld_countUserWallMsges ($uid) |
|
1359
|
|
|
{ |
|
1360
|
|
|
$db =& XoopsDatabaseFactory::getDatabaseConnection(); |
|
1361
|
|
|
$sql = "SELECT message FROM ".$db->prefix('smallworld_messages')." where uid_fk='".$uid."'"; |
|
1362
|
|
|
$result = $db->queryF($sql); |
|
1363
|
|
|
$count = $db->getRowsNum($result); |
|
1364
|
|
|
|
|
1365
|
|
|
return $count; |
|
1366
|
|
|
} |
|
1367
|
|
|
|
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.