|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Mylinks install functions.php |
|
4
|
|
|
* |
|
5
|
|
|
* LICENSE |
|
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
|
|
|
* |
|
11
|
|
|
* @copyright:: {@link http://xoops.org/ XOOPS Project} |
|
12
|
|
|
* @license :: {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License} |
|
13
|
|
|
* @package :: mylinks |
|
14
|
|
|
* @author :: zyspec ([email protected]) |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @param $xoopsModule |
|
21
|
|
|
* @return bool |
|
22
|
|
|
*/ |
|
23
|
|
|
function xoops_module_pre_install_mylinks_base(&$xoopsModule) |
|
24
|
|
|
{ |
|
25
|
|
|
global $xoopsDB; |
|
26
|
|
|
$retVal = true; |
|
27
|
|
|
|
|
28
|
|
|
$minPHPVersion = $xoopsModule->getInfo('min_php'); |
|
29
|
|
|
$minSQLVersion = $xoopsModule->getInfo('min_sql'); |
|
30
|
|
|
$minXoopsVersion = $xoopsModule->getInfo('min_xoops'); |
|
31
|
|
|
|
|
32
|
|
|
/* |
|
33
|
|
|
* Error Messages |
|
34
|
|
|
*/ |
|
35
|
|
|
$phpErrMsg = "<span style='color: red; font-weight: bold;'>YOUR PHP VERSION MUST BE UPGRADED TO AT LEAST VERSION {$minPHPVersion} TO USE THIS MODULE</span>"; |
|
36
|
|
|
$mysqlErrMsg = "<span style='color: red; font-weight: bold;'>YOUR MYSQL DATABASE VERSION MUST BE UPGRADED TO AT LEAST VERSION {$minSQLVersion} TO USE THIS MODULE</span>"; |
|
37
|
|
|
$xoopsErrMsg = "<span style='color: red; font-weight: bold;'>YOUR XOOPS VERSION MUST BE UPGRADED TO AT LEAST VERSION {$minXoopsVersion} TO USE THIS MODULE</span>"; |
|
38
|
|
|
|
|
39
|
|
|
// Check if PHP version is supported |
|
40
|
|
|
if (version_compare(PHP_VERSION, $minPHPVersion) < 0) { |
|
41
|
|
|
$retVal = false; |
|
42
|
|
|
$xoopsModule->setErrors($phpErrMsg); |
|
43
|
|
|
} else { |
|
44
|
|
|
// Check if MySQL version is supported |
|
45
|
|
|
$minSQLSupported = explode('.', $minSQLVersion); |
|
46
|
|
|
$sql = $xoopsDB->query('SELECT version() AS sqlver'); |
|
47
|
|
|
$result = $xoopsDB->fetchObject($sql); |
|
48
|
|
|
$currSQLVer = $result->sqlver; |
|
49
|
|
|
$sqlVerArray = explode('.', $currSQLVer); |
|
50
|
|
|
$sqlVerArray = array_map('intval', $sqlVerArray); //strip off non-integer revision chars |
|
51
|
|
|
|
|
52
|
|
|
if ($sqlVerArray[0] < $minSQLSupported[0]) { |
|
53
|
|
|
$retVal = false; |
|
54
|
|
|
$xoopsModule->setErrors($mysqlErrMsg); |
|
55
|
|
|
} elseif ($sqlVerArray[0] == $minSQLSupported[0]) { |
|
56
|
|
|
if ($sqlVerArray[1] < $minSQLSupported[1]) { |
|
57
|
|
|
$retVal = false; |
|
58
|
|
|
$xoopsModule->setErrors($mysqlErrMsg); |
|
59
|
|
|
} elseif (($sqlVerArray[1] == $minSQLSupported[1]) && ($sqlVerArray[2] < $minSQLSupported[2])) { |
|
60
|
|
|
$retVal = false; |
|
61
|
|
|
$xoopsModule->setErrors($mysqlErrMsg); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
if ($retVal) { |
|
66
|
|
|
// Check if this XOOPS version is supported |
|
67
|
|
|
$curXoopsVersion = substr(XOOPS_VERSION, 6); |
|
68
|
|
|
if (version_compare($curXoopsVersion, $minXoopsVersion, '<')) { |
|
69
|
|
|
$retVal = false; |
|
70
|
|
|
$xoopsModule->setErrors(sprintf($xoopsErrMsg, $minXoopsVersion, $curXoopsVersion)); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
return $retVal; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @param $xoopsModule |
|
80
|
|
|
* @return bool |
|
81
|
|
|
*/ |
|
82
|
|
|
function xoops_module_install_mylinks_base(&$xoopsModule) |
|
|
|
|
|
|
83
|
|
|
{ |
|
84
|
|
|
return true; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* eval functions to support module relocation (directory renaming) |
|
89
|
|
|
*/ |
|
90
|
|
|
eval('function xoops_module_install_' . $moduleDirName . '(&$module=NULL) |
|
91
|
|
|
{ |
|
92
|
|
|
return xoops_module_install_mylinks_base($module); |
|
93
|
|
|
} |
|
94
|
|
|
'); |
|
95
|
|
|
eval('function xoops_module_pre_install_' . $moduleDirName . '(&$module=NULL) |
|
96
|
|
|
{ |
|
97
|
|
|
return xoops_module_pre_install_mylinks_base($module); |
|
98
|
|
|
} |
|
99
|
|
|
'); |
|
100
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.