|
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
|
|
|
* presenter module for xoops |
|
13
|
|
|
* |
|
14
|
|
|
* @copyright XOOPS Project (http://xoops.org) |
|
15
|
|
|
* @license GPL 2.0 or later |
|
16
|
|
|
* @package presenter |
|
17
|
|
|
* @since 2.5.5 |
|
18
|
|
|
* @author XOOPS Development Team <[email protected]> - <http://xoops.org> |
|
19
|
|
|
* @version $Id: 1.0 functions.php 11532 Wed 2013/08/28 4:00:28Z XOOPS Development Team $ |
|
20
|
|
|
*/ |
|
21
|
|
|
/***************Blocks************** |
|
22
|
|
|
* @param $cats |
|
23
|
|
|
* @return string |
|
24
|
|
|
*/ |
|
25
|
|
|
function presenter_block_addCatSelect($cats) |
|
26
|
|
|
{ |
|
27
|
|
|
if (is_array($cats)) { |
|
28
|
|
|
$cat_sql = '(' . current($cats); |
|
29
|
|
|
array_shift($cats); |
|
30
|
|
|
foreach ($cats as $cat) { |
|
31
|
|
|
$cat_sql .= ',' . $cat; |
|
32
|
|
|
} |
|
33
|
|
|
$cat_sql .= ')'; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
return $cat_sql; |
|
|
|
|
|
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param $global |
|
41
|
|
|
* @param $key |
|
42
|
|
|
* @param string $default |
|
43
|
|
|
* @param string $type |
|
44
|
|
|
* @return mixed|string |
|
45
|
|
|
*/ |
|
46
|
|
|
function presenter_CleanVars(&$global, $key, $default = '', $type = 'int') |
|
47
|
|
|
{ |
|
48
|
|
|
switch ($type) { |
|
49
|
|
|
case 'string': |
|
50
|
|
|
$ret = (isset($global[$key])) ? filter_var($global[$key], FILTER_SANITIZE_MAGIC_QUOTES) : $default; |
|
51
|
|
|
break; |
|
52
|
|
|
case 'int': |
|
53
|
|
|
default: |
|
54
|
|
|
$ret = (isset($global[$key])) ? filter_var($global[$key], FILTER_SANITIZE_NUMBER_INT) : $default; |
|
55
|
|
|
break; |
|
56
|
|
|
} |
|
57
|
|
|
if ($ret === false) { |
|
58
|
|
|
return $default; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
return $ret; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param $content |
|
66
|
|
|
*/ |
|
67
|
|
View Code Duplication |
function presenter_meta_keywords($content) |
|
|
|
|
|
|
68
|
|
|
{ |
|
69
|
|
|
global $xoopsTpl, $xoTheme; |
|
|
|
|
|
|
70
|
|
|
$myts =& MyTextSanitizer::getInstance(); |
|
71
|
|
|
$content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); |
|
72
|
|
|
if (isset($xoTheme) && is_object($xoTheme)) { |
|
73
|
|
|
$xoTheme->addMeta('meta', 'keywords', strip_tags($content)); |
|
74
|
|
|
} else { // Compatibility for old Xoops versions |
|
75
|
|
|
$xoopsTpl->assign('xoops_meta_keywords', strip_tags($content)); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param $content |
|
81
|
|
|
*/ |
|
82
|
|
View Code Duplication |
function presenter_meta_description($content) |
|
|
|
|
|
|
83
|
|
|
{ |
|
84
|
|
|
global $xoopsTpl, $xoTheme; |
|
|
|
|
|
|
85
|
|
|
$myts =& MyTextSanitizer::getInstance(); |
|
86
|
|
|
$content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); |
|
87
|
|
|
if (isset($xoTheme) && is_object($xoTheme)) { |
|
88
|
|
|
$xoTheme->addMeta('meta', 'description', strip_tags($content)); |
|
89
|
|
|
} else { // Compatibility for old Xoops versions |
|
90
|
|
|
$xoopsTpl->assign('xoops_meta_description', strip_tags($content)); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: