1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* **************************************************************************** |
4
|
|
|
* marquee - MODULE FOR XOOPS |
5
|
|
|
* Copyright (c) Hervé Thouzard (http://www.herve-thouzard.com) |
6
|
|
|
* |
7
|
|
|
* You may not change or alter any portion of this comment or credits |
8
|
|
|
* of supporting developers from this source code or any supporting source code |
9
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
* |
14
|
|
|
* @copyright Hervé Thouzard (http://www.herve-thouzard.com) |
15
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
16
|
|
|
* @package marquee |
17
|
|
|
* @author Hervé Thouzard (http://www.herve-thouzard.com) |
18
|
|
|
* |
19
|
|
|
* Version : |
20
|
|
|
* **************************************************************************** |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
// defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
|
|
|
|
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Returns a module's option |
27
|
|
|
* |
28
|
|
|
* Return's a module's option (for the news module) |
29
|
|
|
* |
30
|
|
|
* @package Marquee |
31
|
|
|
* @author Hervé Thouzard (http://www.herve-thouzard.com) |
32
|
|
|
* @copyright (c) Hervé Thouzard |
33
|
|
|
* |
34
|
|
|
* @param string $option module option's name |
35
|
|
|
* |
36
|
|
|
* @param string $repmodule |
37
|
|
|
* |
38
|
|
|
* @return bool |
39
|
|
|
*/ |
40
|
|
|
function marquee_getmoduleoption($option, $repmodule = 'marquee') |
41
|
|
|
{ |
42
|
|
|
global $xoopsModuleConfig, $xoopsModule; |
|
|
|
|
43
|
|
|
static $tbloptions = []; |
44
|
|
|
if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) { |
45
|
|
|
return $tbloptions[$option]; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
$retval = false; |
49
|
|
|
if (null !== $xoopsModuleConfig |
50
|
|
|
&& (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $repmodule |
51
|
|
|
&& $xoopsModule->getVar('isactive'))) { |
52
|
|
|
if (isset($xoopsModuleConfig[$option])) { |
53
|
|
|
$retval = $xoopsModuleConfig[$option]; |
54
|
|
|
} |
55
|
|
|
} else { |
56
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
57
|
|
|
$moduleHandler = xoops_getHandler('module'); |
|
|
|
|
58
|
|
|
$module = $moduleHandler->getByDirname($repmodule); |
59
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
60
|
|
|
$configHandler = xoops_getHandler('config'); |
61
|
|
|
if ($module) { |
62
|
|
|
$moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
63
|
|
|
if (isset($moduleConfig[$option])) { |
64
|
|
|
$retval = $moduleConfig[$option]; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
$tbloptions[$option] = $retval; |
69
|
|
|
|
70
|
|
|
return $retval; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Verify if the current "user" is a bot or not |
75
|
|
|
* |
76
|
|
|
* If you have a problem with this function, insert the folowing code just before the line if (isset($_SESSION['news_cache_bot'])) { : |
77
|
|
|
* return false; |
78
|
|
|
* |
79
|
|
|
* @package Marquee |
80
|
|
|
* @author Hervé Thouzard (http://www.herve-thouzard.com) |
81
|
|
|
* @copyright (c) Hervé Thouzard |
82
|
|
|
*/ |
83
|
|
|
function marquee_isbot() |
84
|
|
|
{ |
85
|
|
|
if (isset($_SESSION['marquee_cache_bot'])) { |
86
|
|
|
return $_SESSION['marquee_cache_bot']; |
87
|
|
|
} else { |
88
|
|
|
// Add here every bot you know separated by a pipe | (not matter with the upper or lower cases) |
89
|
|
|
// If you want to see the result for yourself, add your navigator's user agent at the end (mozilla for example) |
90
|
|
|
$botlist = 'AbachoBOT|Arachnoidea|ASPSeek|Atomz|cosmos|crawl25-public.alexa.com|CrawlerBoy Pinpoint.com|Crawler|DeepIndex|EchO!|exabot|Excalibur Internet Spider|FAST-WebCrawler|Fluffy the spider|GAIS Robot/1.0B2|GaisLab data gatherer|Google|Googlebot-Image|googlebot|Gulliver|ia_archiver|Infoseek|Links2Go|Lycos_Spider_(modspider)|Lycos_Spider_(T-Rex)|MantraAgent|Mata Hari|Mercator|MicrosoftPrototypeCrawler|[email protected]|MSNBOT|NEC Research Agent|NetMechanic|Nokia-WAPToolkit|nttdirectory_robot|Openfind|Oracle Ultra Search|PicoSearch|Pompos|Scooter|Slider_Search_v1-de|Slurp|Slurp.so|SlySearch|Spider|Spinne|SurferF3|Surfnomore Spider|suzuran|teomaagent1|TurnitinBot|Ultraseek|VoilaBot|vspider|W3C_Validator|Web Link Validator|WebTrends|WebZIP|whatUseek_winona|WISEbot|Xenu Link Sleuth|ZyBorg'; |
91
|
|
|
$botlist = strtoupper($botlist); |
92
|
|
|
$currentagent = strtoupper(xoops_getenv('HTTP_USER_AGENT')); |
|
|
|
|
93
|
|
|
$retval = false; |
94
|
|
|
$botarray = explode('|', $botlist); |
95
|
|
|
foreach ($botarray as $onebot) { |
96
|
|
|
if (false !== strpos($currentagent, $onebot)) { |
97
|
|
|
$retval = true; |
98
|
|
|
break; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
$_SESSION['marquee_cache_bot'] = $retval; |
103
|
|
|
|
104
|
|
|
return $retval; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Escape a string so that it can be included in a javascript string |
109
|
|
|
* |
110
|
|
|
* @param $string |
111
|
|
|
* |
112
|
|
|
* @return mixed |
113
|
|
|
*/ |
114
|
|
|
function marquee_javascript_escape($string) |
115
|
|
|
{ |
116
|
|
|
return str_replace("'", "\\'", $string); |
117
|
|
|
} |
118
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.