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
|
|
|
* |
7
|
|
|
* This program is distributed in the hope that it will be useful, |
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @copyright {@link http://xoops.org/ XOOPS Project} |
14
|
|
|
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
15
|
|
|
* @package |
16
|
|
|
* @since |
17
|
|
|
* @author XOOPS Development Team, |
18
|
|
|
* @author GIJ=CHECKMATE (PEAK Corp. http://www.peak.ne.jp/) |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
// a plugin for mylinks |
22
|
|
|
|
23
|
|
|
defined('XOOPS_ROOT_PATH') || exit('XOOPS Root Path not defined'); |
24
|
|
|
|
25
|
|
|
/* |
26
|
|
|
$db : db instance |
27
|
|
|
$myts : MyTextSanitizer instance |
28
|
|
|
$this->year : year |
29
|
|
|
$this->month : month |
30
|
|
|
$this->date : date |
31
|
|
|
$this->week_start : sunday:0 monday:1 |
32
|
|
|
$this->user_TZ : user's timezone (+1.5 etc) |
33
|
|
|
$this->server_TZ : server's timezone (-2.5 etc) |
34
|
|
|
$tzoffset_s2u : the offset from server to user |
35
|
|
|
$now : the result of time() |
36
|
|
|
$plugin = array('dirname'=>'dirname','name'=>'name','dotgif'=>'*.gif') |
37
|
|
|
|
38
|
|
|
$plugin_returns[ DATE ][] |
39
|
|
|
*/ |
40
|
|
|
|
41
|
|
|
// set range (added 86400 second margin "begin" & "end") |
42
|
|
|
$range_start_s = mktime(0, 0, 0, $this->month, $this->date - 1, $this->year); |
43
|
|
|
$range_end_s = mktime(0, 0, 0, $this->month, $this->date + 2, $this->year); |
44
|
|
|
|
45
|
|
|
// query (added 86400 second margin "begin" & "end") |
46
|
|
|
$result = $db->query('SELECT title,lid,`date`,cid FROM ' . $db->prefix('mylinks_links') . " WHERE `date` >= $range_start_s AND `date` < $range_end_s AND `status` > 0"); |
47
|
|
|
|
48
|
|
View Code Duplication |
while (list($title, $id, $server_time, $cid) = $db->fetchRow($result)) { |
|
|
|
|
49
|
|
|
$user_time = $server_time + $tzoffset_s2u; |
50
|
|
|
if (date('j', $user_time) != $this->date) { |
51
|
|
|
continue; |
52
|
|
|
} |
53
|
|
|
$target_date = date('j', $user_time); |
54
|
|
|
$tmp_array = array( |
55
|
|
|
'dotgif' => $plugin['dotgif'], |
56
|
|
|
'dirname' => $plugin['dirname'], |
57
|
|
|
'link' => XOOPS_URL . "/modules/{$plugin['dirname']}/singlelink.php?lid=$id&cid=$cid&caldate={$this->year}-{$this->month}-$target_date", |
58
|
|
|
'id' => $id, |
59
|
|
|
'server_time' => $server_time, |
60
|
|
|
'user_time' => $user_time, |
61
|
|
|
'name' => 'lid', |
62
|
|
|
'title' => $myts->htmlSpecialChars($title), |
63
|
|
|
'description' => '' |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
// multiple gifs allowed per a plugin & per a day |
67
|
|
|
$plugin_returns[$target_date][] = $tmp_array; |
68
|
|
|
} |
69
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.