Skip to content

Commit 31e1e65

Browse files
committed
Move source code the OutdatedExtrasCheck plugin into file
1 parent 2caf4b0 commit 31e1e65

2 files changed

Lines changed: 286 additions & 280 deletions

File tree

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
<?php
2+
if (!defined('MODX_BASE_PATH')) {
3+
die('What are you doing? Get out of here!');
4+
}
5+
6+
// get manager role check
7+
$internalKey = $modx->getLoginUserID();
8+
$sid = $modx->sid;
9+
$role = $_SESSION['mgrRole'];
10+
$user = $_SESSION['mgrShortname'];
11+
// show widget only to Admin role 1
12+
if(($role!=1) AND ($wdgVisibility == 'AdminOnly')) {}
13+
// show widget to all manager users excluded Admin role 1
14+
else if(($role==1) AND ($wdgVisibility == 'AdminExcluded')) {}
15+
// show widget only to "this" role id
16+
else if(($role!=$ThisRole) AND ($wdgVisibility == 'ThisRoleOnly')) {}
17+
// show widget only to "this" username
18+
else if(($user!=$ThisUser) AND ($wdgVisibility == 'ThisUserOnly')) {}
19+
else {
20+
// get plugin id and setting button
21+
$result = $modx->db->select('id', $this->getFullTableName("site_plugins"), "name='{$modx->event->activePlugin}' AND disabled=0");
22+
$pluginid = $modx->db->getValue($result);
23+
if($modx->hasPermission('edit_plugin')) {
24+
$button_pl_config = '<a data-toggle="tooltip" href="javascript:;" title="' . $_lang["settings_config"] . '" class="text-muted pull-right" onclick="parent.modx.popup({url:\''. MODX_MANAGER_URL.'?a=102&id='.$pluginid.'&tab=1\',title1:\'' . $_lang["settings_config"] . '\',icon:\'fa-cog\',iframe:\'iframe\',selector2:\'#tabConfig\',position:\'center center\',width:\'80%\',height:\'80%\',hide:0,hover:0,overlay:1,overlayclose:1})" ><i class="fa fa-cog fa-spin-hover" style="color:#FFFFFF;"></i> </a>';
25+
}
26+
$modx->setPlaceholder('button_pl_config', $button_pl_config);
27+
//plugin lang
28+
$_oec_lang = array();
29+
$plugin_path = $modx->config['base_path'] . "assets/plugins/extrascheck/";
30+
include($plugin_path . 'lang/english.php');
31+
if (file_exists($plugin_path . 'lang/' . $modx->config['manager_language'] . '.php')) {
32+
include($plugin_path . 'lang/' . $modx->config['manager_language'] . '.php');
33+
}
34+
//run the plugin
35+
// get globals
36+
global $modx,$_lang;
37+
//function to extract snippet version from description <strong></strong> tags
38+
if (!function_exists('getver')) {
39+
function getver($string, $tag)
40+
{
41+
$content ="/<$tag>(.*?)<\/$tag>/";
42+
preg_match($content, $string, $text);
43+
return $text[1];
44+
}
45+
}
46+
$e = &$modx->Event;
47+
$EVOversion = $modx->config['settings_version'];
48+
$output = '';
49+
//get extras module id for the link
50+
$modtable = $modx->getFullTableName('site_modules');
51+
$getExtra = $modx->db->select( "id, name", $modtable, "name='Extras'" );
52+
while( $row = $modx->db->getRow( $getExtra ) ) {
53+
$ExtrasID = $row['id'];
54+
}
55+
//check outdated files
56+
//ajax index
57+
$indexajax = "../index-ajax.php";
58+
if (file_exists($indexajax)){
59+
$output .= '<div class="widget-wrapper alert alert-danger"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>index-ajax.php</b> '.$_oec_lang['not_used'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['if_dont_use'].', '.$_oec_lang['please_delete'].'.</div>';
60+
}
61+
//check outdated default manager themes
62+
$oldthemes = explode(",","$badthemes");
63+
foreach ($oldthemes as $oldtheme){
64+
if (file_exists('media/style/'.$oldtheme)){
65+
$output .= '<div class="widget-wrapper alert alert-danger"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>'.$oldtheme.'</b> '.$_lang["manager_theme"].', '.$_oec_lang['isoutdated'].' '.$_oec_lang['isoutdated'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['please_delete'].' '.$_oec_lang['from_folder'].' ' . MODX_MANAGER_PATH . 'media/style/.</div>';
66+
}
67+
}
68+
//check outdated modx rss news feed
69+
$url_security = $modx->config['rss_url_security'];
70+
if($url_security == 'http://feeds.feedburner.com/modxsecurity'){
71+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>'.$_lang["settings_config"].' > '.$_lang["rss_url_security_title"].'</b> (http://feeds.feedburner.com/modxsecurity) '.$_oec_lang['outdated'].'. '.$_oec_lang['please_download_and_install'].' <b>UpdateEvoRss</b> '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a> </div>';
72+
}
73+
$url_news = $modx->config['rss_url_news'];
74+
if($url_news == 'http://feeds.feedburner.com/modx-announce'){
75+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>'.$_lang["settings_config"].' > '.$_lang["rss_url_news_title"].' </b>(http://feeds.feedburner.com/modx-announce) '.$_oec_lang['outdated'].'. '.$_oec_lang['please_download_and_install'].' <b>UpdateEvoRss</b> '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a> </div>';
76+
}
77+
//get site snippets table
78+
$table = $modx->getFullTableName('site_snippets');
79+
//check ditto
80+
//get min version from config
81+
$minDittoVersion = $DittoVersion;
82+
//search the snippet by name
83+
$CheckDitto = $modx->db->select( "id, name, description", $table, "name='Ditto'" );
84+
if($CheckDitto != ''){
85+
while( $row = $modx->db->getRow( $CheckDitto ) ) {
86+
//extract snippet version from description <strong></strong> tags
87+
$curr_ditto_version = getver($row['description'],"strong");
88+
//check snippet version and return an alert if outdated
89+
if (version_compare($curr_ditto_version,$minDittoVersion,'lt')){
90+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>' . $row['name'] . '</b> '.$_lang["snippet"].' (version ' . $curr_ditto_version . ') '.$_oec_lang['isoutdated'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['please_update'].' <b>' . $row['name'] . '</b> '.$_oec_lang["to_latest"].' ('.$_oec_lang['min _required'].' '.$minDittoVersion.') '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a> '.$_oec_lang['or_move_to'].' <b>DocLister</b></div>';
91+
}
92+
}
93+
}
94+
//end check ditto
95+
96+
//check eform
97+
//get min version from config
98+
$minEformVersion = $EformVersion;
99+
//search the snippet by name
100+
$CheckEform = $modx->db->select( "id, name, description", $table, "name='eForm'" );
101+
if($CheckEform != ''){
102+
while( $row = $modx->db->getRow( $CheckEform ) ) {
103+
//extract snippet version from description <strong></strong> tags
104+
$curr_Eform_version = getver($row['description'],"strong");
105+
//check snippet version and return an alert if outdated
106+
if (version_compare($curr_Eform_version,$minEformVersion,'lt')){
107+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>' . $row['name'] . '</b> '.$_lang["snippet"].' (version ' . $curr_Eform_version . ') '.$_oec_lang['isoutdated'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['please_update'].' <b>' . $row['name'] . '</b> '.$_oec_lang["to_latest"].' ('.$_oec_lang['min _required'].' '.$minEformVersion.') '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a> '.$_oec_lang['or_move_to'].' <b>FormLister</b></div>';
108+
}
109+
}
110+
}
111+
//end check eform
112+
113+
//check AjaxSearch
114+
//get min version from config
115+
$minAjaxSearchVersion = $AjaxSearchVersion;
116+
//search the snippet by name
117+
$CheckAjaxSearch = $modx->db->select( "id, name, description", $table, "name='AjaxSearch'" );
118+
if($CheckAjaxSearch != ''){
119+
while( $row = $modx->db->getRow( $CheckAjaxSearch ) ) {
120+
//extract snippet version from description <strong></strong> tags
121+
$curr_AjaxSearch_version = getver($row['description'],"strong");
122+
//check snippet version and return an alert if outdated
123+
if (version_compare($curr_AjaxSearch_version,$minAjaxSearchVersion,'lt')){
124+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>' . $row['name'] . '</b> '.$_lang["snippet"].' (version ' . $curr_AjaxSearch_version . ') '.$_oec_lang['isoutdated'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['please_update'].' <b>' . $row['name'] . '</b> '.$_oec_lang["to_latest"].' ('.$_oec_lang['min _required'].' '.$minAjaxSearchVersion.') '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a>.</div>';
125+
}
126+
}
127+
}
128+
//end check AjaxSearch
129+
130+
//check Wayfinder
131+
//get min version from config
132+
$minWayfinderVersion = $WayfinderVersion;
133+
//search the snippet by name
134+
$CheckWayfinder = $modx->db->select( "id, name, description", $table, "name='Wayfinder'" );
135+
if($CheckWayfinder != ''){
136+
while( $row = $modx->db->getRow( $CheckWayfinder ) ) {
137+
//extract snippet version from description <strong></strong> tags
138+
$curr_Wayfinder_version = getver($row['description'],"strong");
139+
//check snippet version and return an alert if outdated
140+
if (version_compare($curr_Wayfinder_version,$minWayfinderVersion,'lt')){
141+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>' . $row['name'] . '</b> '.$_lang["snippet"].' (version ' . $curr_Wayfinder_version . ') '.$_oec_lang['isoutdated'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['please_update'].' <b>' . $row['name'] . '</b> '.$_oec_lang["to_latest"].' ('.$_oec_lang['min _required'].' '.$minWayfinderVersion.') '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a>.</div>';
142+
}
143+
}
144+
}
145+
//end check Wayfinder
146+
147+
//check WebLogin
148+
//get min version from config
149+
$minWebLoginVersion = $WebLoginVersion;
150+
//search the snippet by name
151+
$CheckWebLogin = $modx->db->select( "id, name, description", $table, "name='WebLogin'" );
152+
if($CheckWebLogin != ''){
153+
while( $row = $modx->db->getRow( $CheckWebLogin ) ) {
154+
//extract snippet version from description <strong></strong> tags
155+
$curr_WebLogin_version = getver($row['description'],"strong");
156+
//check snippet version and return an alert if outdated
157+
if (version_compare($curr_WebLogin_version,$minWebLoginVersion,'lt')){
158+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>' . $row['name'] . '</b> '.$_lang["snippet"].' (version ' . $curr_WebLogin_version . ') '.$_oec_lang['isoutdated'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['please_update'].' <b>' . $row['name'] . '</b> '.$_oec_lang["to_latest"].' ('.$_oec_lang['min _required'].' '.$minWebLoginVersion.') '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a> '.$_oec_lang['or_move_to'].' <b>FormLister</b></div>';
159+
}
160+
}
161+
}
162+
//end check WebLogin
163+
164+
//check WebChangePwd
165+
//get min version from config
166+
$minWebChangePwdVersion = $WebChangePwdVersion;
167+
//search the snippet by name
168+
$CheckWebChangePwd = $modx->db->select( "id, name, description", $table, "name='WebChangePwd'" );
169+
if($CheckWebLogin != ''){
170+
while( $row = $modx->db->getRow( $CheckWebChangePwd ) ) {
171+
//extract snippet version from description <strong></strong> tags
172+
$curr_WebChangePwd_version = getver($row['description'],"strong");
173+
//check snippet version and return an alert if outdated
174+
if (version_compare($curr_WebChangePwd_version,$minWebChangePwdVersion,'lt')){
175+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>' . $row['name'] . '</b> '.$_lang["snippet"].' (version ' . $curr_WebChangePwd_version . ') '.$_oec_lang['isoutdated'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['please_update'].' <b>' . $row['name'] . '</b> '.$_oec_lang["to_latest"].' ('.$_oec_lang['min _required'].' '.$minWebChangePwdVersion.') '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a> '.$_oec_lang['or_move_to'].' <b>FormLister</b></div>';
176+
}
177+
}
178+
}
179+
//end check WebChangePwd
180+
181+
//check WebSignup
182+
//get min version from config
183+
$minWebSignupVersion = $WebSignupVersion;
184+
//search the snippet by name
185+
$CheckWebSignup = $modx->db->select( "id, name, description", $table, "name='WebSignup'" );
186+
if($CheckWebSignup != ''){
187+
while( $row = $modx->db->getRow( $CheckWebSignup ) ) {
188+
//extract snippet version from description <strong></strong> tags
189+
$curr_WebSignup_version = getver($row['description'],"strong");
190+
//check snippet version and return an alert if outdated
191+
if (version_compare($curr_WebSignup_version,$minWebSignupVersion,'lt')){
192+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>' . $row['name'] . '</b> '.$_lang["snippet"].' (version ' . $curr_WebSignup_version . ') '.$_oec_lang['isoutdated'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['please_update'].' <b>' . $row['name'] . '</b> '.$_oec_lang["to_latest"].' ('.$_oec_lang['min _required'].' '.$minWebSignupVersion.') '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a> '.$_oec_lang['or_move_to'].' <b>FormLister</b></div>';
193+
}
194+
}
195+
}
196+
//end check WebSignup
197+
198+
//check Breadcrumbs
199+
//get min version from config
200+
$minBreadcrumbsVersion = $BreadcrumbsVersion;
201+
//search the snippet by name
202+
$CheckBreadcrumbs = $modx->db->select( "id, name, description", $table, "name='Breadcrumbs'" );
203+
if($CheckBreadcrumbs != ''){
204+
while( $row = $modx->db->getRow( $CheckBreadcrumbs ) ) {
205+
//extract snippet version from description <strong></strong> tags
206+
$curr_Breadcrumbs_version = getver($row['description'],"strong");
207+
//check snippet version and return an alert if outdated
208+
if (version_compare($curr_Breadcrumbs_version,$minBreadcrumbsVersion,'lt')){
209+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>' . $row['name'] . '</b> '.$_lang["snippet"].' (version ' . $curr_Breadcrumbs_version . ') '.$_oec_lang['isoutdated'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['please_update'].' <b>' . $row['name'] . '</b> '.$_oec_lang["to_latest"].' ('.$_oec_lang['min _required'].' '.$minBreadcrumbsVersion.') '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a>.</div>';
210+
}
211+
}
212+
}
213+
//end check Breadcrumbs
214+
215+
//check Reflect
216+
//get min version from config
217+
$minReflectVersion = $ReflectVersion;
218+
//search the snippet by name
219+
$CheckReflect = $modx->db->select( "id, name, description", $table, "name='Reflect'" );
220+
if($CheckReflect != ''){
221+
while( $row = $modx->db->getRow( $CheckReflect ) ) {
222+
//extract snippet version from description <strong></strong> tags
223+
$curr_Reflect_version = getver($row['description'],"strong");
224+
//check snippet version and return an alert if outdated
225+
if (version_compare($curr_Reflect_version,$minReflectVersion,'lt')){
226+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>' . $row['name'] . '</b> '.$_lang["snippet"].' (version ' . $curr_Reflect_version . ') '.$_oec_lang['isoutdated'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['please_update'].' <b>' . $row['name'] . '</b> '.$_oec_lang["to_latest"].' ('.$_oec_lang['min _required'].' '.$minReflectVersion.') '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a>.</div>';
227+
}
228+
}
229+
}
230+
//end check Reflect
231+
232+
//check Jot
233+
//get min version from config
234+
$minJotVersion = $JotVersion;
235+
//search the snippet by name
236+
$CheckJot = $modx->db->select( "id, name, description", $table, "name='Jot'" );
237+
if($CheckJot != ''){
238+
while( $row = $modx->db->getRow( $CheckJot ) ) {
239+
//extract snippet version from description <strong></strong> tags
240+
$curr_Jot_version = getver($row['description'],"strong");
241+
//check snippet version and return an alert if outdated
242+
if (version_compare($curr_Jot_version,$minJotVersion,'lt')){
243+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>' . $row['name'] . '</b> '.$_lang["snippet"].' (version ' . $curr_Jot_version . ') '.$_oec_lang['isoutdated'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['please_update'].' <b>' . $row['name'] . '</b> '.$_oec_lang["to_latest"].' ('.$_oec_lang['min _required'].' '.$minJotVersion.') '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a>.</div>';
244+
}
245+
}
246+
}
247+
//end check Jot
248+
249+
//check Multitv
250+
//get min version from config
251+
$minMtvVersion = $MtvVersion;
252+
//search the snippet by name
253+
$CheckMtv = $modx->db->select( "id, name, description", $table, "name='multiTV'" );
254+
if($CheckMtv != ''){
255+
while( $row = $modx->db->getRow( $CheckMtv ) ) {
256+
//extract snippet version from description <strong></strong> tags
257+
$curr_mtv_version = getver($row['description'],"strong");
258+
//check snippet version and return an alert if outdated
259+
if (version_compare($curr_mtv_version,$minMtvVersion,'lt')){
260+
$output .= '<div class="widget-wrapper alert alert-warning"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <b>' . $row['name'] . '</b> '.$_lang["snippet"].' (version ' . $curr_mtv_version . ') '.$_oec_lang['isoutdated'].' <b>Evolution '.$EVOversion.'</b>. '.$_oec_lang['please_update'].' <b>' . $row['name'] . '</b> '.$_oec_lang["to_latest"].' ('.$_oec_lang['min _required'].' '.$minMtvVersion.') '.$_oec_lang['from'].' <a target="main" href="index.php?a=112&id='.$ExtrasID.'">'.$_oec_lang['extras_module'].'</a></div>';
261+
}
262+
}
263+
}
264+
//end check Multitv
265+
266+
if($output != ''){
267+
if($e->name == 'OnManagerWelcomeHome') {
268+
$out = $output;
269+
$wdgTitle = 'EVO '.$EVOversion.' - '.$_oec_lang['title'].'';
270+
$widgets['xtraCheck'] = array(
271+
'menuindex' =>'0',
272+
'id' => 'xtraCheck'.$pluginid.'',
273+
'cols' => 'col-12',
274+
'headAttr' => 'style="color:#E84B39;"',
275+
'bodyAttr' => '',
276+
'icon' => 'fa-warning',
277+
'title' => ''.$wdgTitle.' '.$button_pl_config.'',
278+
'body' => '<div class="card-body">'.$out.'</div>',
279+
'hide' => '0'
280+
);
281+
$e->output(serialize($widgets));
282+
return;
283+
}
284+
}
285+
}

0 commit comments

Comments
 (0)