apcal_locale   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
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       Antiques Promotion (http://www.antiquespromotion.ca)
19
 */
20
21
require_once __DIR__ . '/../../mainfile.php';
22
23
$xoopsErrorHandler->activated = false;
24
error_reporting(E_NONE);
25
26
header('Access-Control-Allow-Origin: *');
27
28
$locales = new apcal_locale();
29
30
$array   = array();
31
$catcrit = $_GET['c'] > 0 ? 'categories LIKE \'%' . str_pad($_GET['c'], 5, '0', STR_PAD_LEFT) . '%\' AND' : '';
32
$result  = $GLOBALS['xoopsDB']->queryF("SELECT id, start, end, summary, shortsummary FROM {$GLOBALS['xoopsDB']->prefix('apcal_event')} WHERE {$catcrit} end>UNIX_TIMESTAMP() ORDER BY start ASC LIMIT 0,{$_GET['n']}");
33
while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) {
34
    $start  = $row['start'];
35
    $startD = $locales->date_long_names[(int)gmstrftime('%d', $row['start'] + (date('I', $row['start']) * 3600))];
36
    $startM = $locales->month_long_names[(int)gmstrftime('%m', $row['start'] + (date('I', $row['start']) * 3600))];
37
38
    $endD = $locales->date_long_names[(int)gmstrftime('%d', $row['end'] + (date('I', $row['end']) * 3600))];
39
    $endM = $locales->month_long_names[(int)gmstrftime('%m', $row['end'] + (date('I', $row['end']) * 3600))];
40
41
    $row['start']   = $startD . ' ' . htmlentities($startM, ENT_QUOTES, 'UTF-8');
42
    $row['end']     = $endD . ' ' . htmlentities($endM, ENT_QUOTES, 'UTF-8');
43
    $row['summary'] = htmlentities($row['summary'], ENT_QUOTES, 'UTF-8');
44
    $row['link']    = $xoopsModuleConfig['apcal_useurlrewrite'] ? XOOPS_URL . '/modules/apcal/' . $row['shortsummary'] . '-' . date('j-n-Y', $start) : XOOPS_URL
45
                                                                                                                                                       . '/modules/apcal/?event_id='
46
                                                                                                                                                       . $row['id'];
47
    $array[]        = $row;
48
}
49
$c = $_GET['c']
50
     > 0 ? htmlentities($GLOBALS['xoopsDB']->fetchObject($GLOBALS['xoopsDB']->queryF("SELECT cat_title FROM {$GLOBALS['xoopsDB']->prefix('apcal_cat')} WHERE cid={$_GET['c']} LIMIT 0,1"))->cat_title,
51
                        ENT_QUOTES, 'UTF-8') : '';
52
$l = '</dl><div class="APfooter">'
53
     . _APCAL_PROVIDEDBY
54
     . ' <a href="'
55
     . XOOPS_URL
56
     . '" title="'
57
     . htmlentities($xoopsConfig['sitename'], ENT_QUOTES, 'UTF-8')
58
     . '" target="_blank">'
59
     . htmlentities($xoopsConfig['sitename'], ENT_QUOTES, 'UTF-8')
60
     . '</a><br><a href="'
61
     . _APCAL_APURL
62
     . '" title="'
63
     . _APCAL_AP
64
     . '" target="_blank">APCal</a> '
65
     . _APCAL_X
66
     . ' <a href="'
67
     . _APCAL_APURL2
68
     . '" title="'
69
     . _APCAL_AP
70
     . '" target="_blank">AP</a></div>';
71
echo check() ? json_encode(array($array, $l, '<div class="APtitle">' . $c . '</div>')) : '';
72
73
/**
74
 * Class apcal_locale
75
 */
76
class apcal_locale
77
{
78
    public $hour_names_24;
79
    public $hour_names_12;
80
    public $holidays;
81
    public $date_short_names;
82
    public $date_long_names;
83
    public $week_numbers;
84
    public $week_short_names;
85
    public $week_middle_names;
86
    public $week_long_names;
87
    public $month_short_names;
88
    public $month_middle_names;
89
    public $month_long_names;
90
    public $byday2langday_w;
91
    public $byday2langday_m;
92
93
    /**
94
     * apcal_locale constructor.
95
     */
96
    public function __construct()
97
    {
98
        include XOOPS_ROOT_PATH . '/modules/apcal/language/' . $GLOBALS['xoopsConfig']['language'] . '/apcal_vars.phtml';
99
    }
100
}
101
102
/**
103
 * @return int
104
 */
105
function check()
106
{
107
    global $l;
108
109
    return preg_match('/<a href="http:\/\/xoops.antique(s?)promotion.(com|ca)/', $l);
110
}
111