forked from XoopsModules25x/xoopspartners
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvpartner.php
More file actions
60 lines (57 loc) · 2.38 KB
/
vpartner.php
File metadata and controls
60 lines (57 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/*
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
*--------------------------------------
* Author: Raul Recio (AKA UNFOR)
* Project: The XOOPS Project
*--------------------------------------
*/
/**
* XoopsPartners - a partner affiliation links module
*
* @package module\xoopspartners\frontside
* @author Raul Recio (aka UNFOR)
* @author XOOPS Module Development Team
* @copyright http://xoops.org 2001-2016 © XOOPS Project
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License
*/
use Xmf\Request;
require __DIR__ . '/header.php';
$xpPartnersHandler = $xpHelper->getHandler('partners');
$id = Request::getInt('id', XoopspartnersConstants::DEFAULT_PID, 'GET');
if (XoopspartnersConstants::DEFAULT_PID === $id) {
$xpHelper->redirect('index.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _MD_XPARTNERS_NOPART);
}
$partnerObj = $xpPartnersHandler->get($id);
if (($partnerObj instanceof XoopspartnersPartners)
&& $partnerObj->getVar('url')
&& (XoopspartnersConstants::STATUS_ACTIVE == $partnerObj->getVar('status')))
{
if (!isset($GLOBALS['xoopsUser']) // not a registered user
|| !$xpHelper->isUserAdmin() // registered but not an admin
|| $xpHelper->getConfig('incadmin')) // admin but want to include admin hits
{
if (!isset($_COOKIE['partners'][$id])) {
setcookie("partners[{$id}]", $id, time() + $xpHelper->getConfig('cookietime'));
$hitCount = $partnerObj->getVar('hits');
++$hitCount;
$partnerObj->setVar('hits', $hitCount);
$xpPartnersHandler->insert($partnerObj);
}
}
echo "<html>\n"
. " <head>\n"
. " <meta http-equiv='Refresh' content='0; URL=" . htmlentities($partnerObj->getVar('url')) . "'>\n"
. " </head>\n"
. " <body></body>\n"
. "</html>\n";
} else {
unset($xpPartnersHandler);
$xpHelper->redirect('index.php', XoopspartnersConstants::REDIRECT_DELAY_MEDIUM, _MD_XPARTNERS_NOPART);
}