-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathdetect_cms.php
More file actions
105 lines (91 loc) · 3.86 KB
/
Copy pathdetect_cms.php
File metadata and controls
105 lines (91 loc) · 3.86 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* Detect the host CMS
*
* @author Vince Wooll <sales@jomres.net>
*
* @version Jomres 10.7.2
*
* @copyright 2005-2023 Vince Wooll
* Jomres (tm) PHP, CSS & Javascript files are released under both MIT and GPL2 licenses. This means that you can choose the license that best suits your project, and use it accordingly
**/
// ################################################################
defined('_JOMRES_INITCHECK') or die('');
// ################################################################
/**
* Detects which CMS Jomres is installed on.
*
* In theory Jomres can (with the appropriate supporting CMS specific functionality) be run on any PHP CMS, although in practice only Joomla and Wordpress are supported, there simply isn't enough demand for any other CMSs. First looks to see if we are installed on a recognised CMS, if _JOMRES_DETECTED_CMS isn't found then we'll scan JOMRES_REMOTEPLUGINS_ABSPATH (typically /jomres/remote_plugins/) to find another file that will set the Detected CMS.
*
**/
if (file_exists(JOMRESCONFIG_ABSOLUTE_PATH.JRDS.'wp-config.php')) {
define('_JOMRES_DETECTED_CMS', 'wordpress');
define('_JOMRES_DETECTED_CMS_SPECIFIC_FILES', JOMRES_CMSSPECIFIC_ABSPATH._JOMRES_DETECTED_CMS.JRDS);
} elseif (file_exists(JOMRESCONFIG_ABSOLUTE_PATH.JRDS.'libraries'.JRDS.'cms'.JRDS.'version'.JRDS.'version.php')) {
if (!defined('JPATH_PLATFORM')) {
define('JPATH_PLATFORM', 1);
} // Joomla 3.3.1 uses this instead of JEXEC.
require_once JOMRESCONFIG_ABSOLUTE_PATH.JRDS.'libraries'.JRDS.'cms'.JRDS.'version'.JRDS.'version.php';
$jversion = new JVersion();
$bang = explode('.', $jversion->getShortVersion());
$vshort_version = $bang[0];
if ($vshort_version == '3') {
define('_JOMRES_DETECTED_CMS', 'joomla3');
define('_JOMRES_DETECTED_CMS_SPECIFIC_FILES', JOMRES_CMSSPECIFIC_ABSPATH._JOMRES_DETECTED_CMS.JRDS);
}
} elseif (file_exists(JOMRESCONFIG_ABSOLUTE_PATH.JRDS.'libraries'.JRDS.'src'.JRDS.'Version.php')) {
if (!defined('JPATH_PLATFORM')) {
define('JPATH_PLATFORM', 1);
}
require_once JOMRESCONFIG_ABSOLUTE_PATH.JRDS.'libraries'.JRDS.'src'.JRDS.'Version.php';
$jversion = new Joomla\CMS\Version();
if ($jversion::MAJOR_VERSION == '3') {
define('_JOMRES_DETECTED_CMS', 'joomla3');
define('_JOMRES_DETECTED_CMS_SPECIFIC_FILES', JOMRES_CMSSPECIFIC_ABSPATH._JOMRES_DETECTED_CMS.JRDS);
}
if ($jversion::MAJOR_VERSION == '4') {
define('_JOMRES_DETECTED_CMS', 'joomla4');
define('_JOMRES_DETECTED_CMS_SPECIFIC_FILES', JOMRES_CMSSPECIFIC_ABSPATH._JOMRES_DETECTED_CMS.JRDS);
}
if ($jversion::MAJOR_VERSION == '5') {
define('_JOMRES_DETECTED_CMS', 'joomla5');
define('_JOMRES_DETECTED_CMS_SPECIFIC_FILES', JOMRES_CMSSPECIFIC_ABSPATH._JOMRES_DETECTED_CMS.JRDS);
}
}
if (!defined('_JOMRES_DETECTED_CMS')) {
$jrePath = JOMRES_REMOTEPLUGINS_ABSPATH;
$d = @dir($jrePath);
$docs = array();
if ($d) {
while (false !== ($entry = $d->read())) {
$filename = $entry;
if (substr($entry, 0, 1) != '.') {
$docs[ ] = $entry;
}
}
$d->close();
if (!empty($docs)) {
sort($docs);
foreach ($docs as $doc) {
$listdir = $jrePath.$doc.JRDS;
$dr = @dir($listdir);
if ($dr) {
while (false !== ($entry = $dr->read())) {
$filename = $entry;
if ($filename == 'detect_cms.php') {
require_once $jrePath.'detect_cms.php';
}
}
$dr->close();
}
}
}
}
}
if (!defined('_JOMRES_DETECTED_CMS')) {
define('_JOMRES_DETECTED_CMS', 'unknown');
}
if (_JOMRES_DETECTED_CMS == 'unknown') {
$message = "Error, cannot detect the current CMS.<br/> It is possible that you have upgraded your CMS's version and the version of Jomres you're running isn't aware of the new version of the CMS. If that's the case then you will need to upgrade Jomres too, however before you do please <a href='http://www.jomres.net/manual/installation-and-upgrading/11-upgrading'>see this page.</a>";
throw new Exception($message);
}