/** * update plugin_info with additional info from api */ function plugin_info_update() { global $plugin_info; foreach ($plugin_info as $key => $plugin) { $api_data = json_decode(get_api_details('plugin', $key . '.php', getDef('GSNOPLUGINCHECK', true))); // on api success if (is_object($api_data) && $api_data->status == 'successful') { $apiver = $api_data->version; $apipath = $api_data->path; $apiname = $api_data->name; $plugin_info[$key]['name'] = $apiname; // $plugin_info[$key]['apiname'] = $apiname; $plugin_info[$key]['apipath'] = $apipath; $plugin_info[$key]['apiver'] = $apiver; } } }
/** * retrieve the version check data obj * @since 3.4 * @return obj api json decoded obj on success */ function getVerCheck() { # check to see if there is a core update needed $data = get_api_details(); if ($data) { return json_decode($data); } else { return null; } }
<?php # Plugin hook to allow insertion of stuff into the header if (get_filename_id() != 'index') { exec_action('header'); } ?> <?php if (get_filename_id() != 'resetpassword' && get_filename_id() != 'index') { ?> <script> // check to see if core update is needed jQuery(document).ready(function() { <?php $data = get_api_details(); if ($data) { $apikey = json_decode($data); $verstatus = $apikey->status; ?> var verstatus = <?php echo $verstatus; ?> ; if(verstatus != 1) { $('a.support').parent('li').append('<span class="warning">!</span>'); $('a.support').attr('href', 'health-check.php'); } <?php } ?>
$plugin_info_sorted = subval_sort($plugin_info, 'name'); foreach ($plugin_info_sorted as $pluginid => $plugininfo) { $setNonce = '&nonce=' . get_nonce("set_" . $pluginid, "plugins.php"); // @todo disabled plugins have a version of (str) 'disabled', should be 0 or null $pluginver = $plugininfo['version'] == 'disabled' ? 0 : $plugininfo['version']; if (plugin_active($pluginid)) { $cls_Enabled = 'hidden'; $cls_Disabled = ''; $trclass = 'enabled'; } else { $cls_Enabled = ''; $cls_Disabled = 'hidden'; $trclass = 'disabled'; } // get extend api for this plugin filename $api_data = json_decode(get_api_details('plugin', $pluginid)); $updatelink = ''; // api success if (is_object($api_data) && $api_data->status == 'successful') { $apiver = $api_data->version; $apipath = $api_data->path; $apiname = $api_data->name; // show update available link if ($pluginver > 0 && version_compare($apiver, $pluginver, '>')) { $updatelink = '<br /><a class="updatelink" href="' . $apipath . '" target="_blank">' . i18n_r('UPDATE_AVAILABLE') . ' ' . $apiver . '</a>'; $needsupdate = true; } $plugin_title = '<a href="' . $apipath . '" target="_blank">' . $apiname . '</a>'; } else { // api fail , does not exist in extend $plugin_title = $plugininfo['name'];
function nm_update_extend_cache() { if (!is_frontend() && get_filename_id() == 'plugins') { include GSADMININCPATH . 'configuration.php'; $url = $site_link_back_url . 'api/extend/?id=541'; $tempfile = GSCACHEPATH . md5($url) . '.txt'; $cachefile = GSCACHEPATH . md5($site_link_back_url . 'api/extend/?file=news_manager.php') . '.txt'; get_api_details('custom', $url); if (file_exists($cachefile)) { unlink($cachefile); } @copy($tempfile, $cachefile); } }
} read_pluginsxml(); // get the live plugins into $live_plugins array if (!is_frontend()) { create_pluginsxml(); } // check that plugins have not been removed or added to the directory // load each of the plugins foreach ($live_plugins as $file => $en) { $pluginsLoaded = true; # debugLog("plugin: $file" . " exists: " . file_exists(GSPLUGINPATH . $file) ." enabled: " . $en); if ($en == 'true' && file_exists(GSPLUGINPATH . $file)) { require_once GSPLUGINPATH . $file; } else { if (!is_frontend() and get_filename_id() == 'plugins') { $apiback = get_api_details('plugin', $file, getDef('GSNOPLUGINCHECK', true)); $response = json_decode($apiback); if ($response and $response->status == 'successful') { register_plugin(pathinfo_filename($file), $file, 'disabled', $response->owner, '', i18n_r('PLUGIN_DISABLED'), '', ''); } else { register_plugin(pathinfo_filename($file), $file, 'disabled', 'Unknown', '', i18n_r('PLUGIN_DISABLED'), '', ''); } } else { register_plugin(pathinfo_filename($file), $file, 'disabled', 'Unknown', '', i18n_r('PLUGIN_DISABLED'), '', ''); } } } /** * change_plugin * * Enable/Disable a plugin
} read_pluginsxml(); // get the live plugins into $live_plugins array if (!is_frontend()) { create_pluginsxml(); } // check that plugins have not been removed or added to the directory // load each of the plugins foreach ($live_plugins as $file => $en) { $pluginsLoaded = true; # debugLog("plugin: $file" . " exists: " . file_exists(GSPLUGINPATH . $file) ." enabled: " . $en); if ($en == 'true' && file_exists(GSPLUGINPATH . $file)) { require_once GSPLUGINPATH . $file; } else { if (!is_frontend() and get_filename_id() == 'plugins') { $apiback = get_api_details('plugin', $file); $response = json_decode($apiback); if ($response and $response->status == 'successful') { register_plugin(pathinfo_filename($file), $file, 'disabled', $response->owner, '', i18n_r('PLUGIN_DISABLED'), '', ''); } else { register_plugin(pathinfo_filename($file), $file, 'disabled', 'Unknown', '', i18n_r('PLUGIN_DISABLED'), '', ''); } } else { register_plugin(pathinfo_filename($file), $file, 'disabled', 'Unknown', '', i18n_r('PLUGIN_DISABLED'), '', ''); } } } /** * change_plugin * * Enable/Disable a plugin
/** * register the plugins that are not enabled * api checks are only done on plugins page * * @todo disabled plugins have a version of (str) 'disabled', should be 0 or null, leaving alone for now for legacy support * * @since 3.4.0 * @uses $live_plugins; * @param bool $apilookup lookup filename in api to get name and desc */ function registerInactivePlugins($apilookup = false) { global $live_plugins; // load plugins into $plugins_info foreach ($live_plugins as $file => $en) { # debugLog("plugin: $file" . " exists: " . file_exists(GSPLUGINPATH . $file) ." enabled: " . $en); if ($en !== 'true' || !file_exists(GSPLUGINPATH . $file)) { if ($apilookup) { // check api to get names of inactive plugins etc. $apiback = get_api_details('plugin', $file); $response = json_decode($apiback); if ($response and $response->status == 'successful') { register_plugin(pathinfo_filename($file), $file, 'disabled', $response->owner, '', i18n_r('PLUGIN_DISABLED'), '', ''); } else { register_plugin(pathinfo_filename($file), $file, 'disabled', 'Unknown', '', i18n_r('PLUGIN_DISABLED'), '', ''); } } else { register_plugin(pathinfo_filename($file), $file, 'disabled', 'Unknown', '', i18n_r('PLUGIN_DISABLED'), '', ''); } } } }
$needsupdate = false; foreach ($pluginfiles as $fi) { $pathExt = pathinfo($fi, PATHINFO_EXTENSION); $pathName = pathinfo_filename($fi); $setNonce = '&nonce=' . get_nonce("set", "plugins.php"); if ($pathExt == "php") { if ($live_plugins[$fi] == 'true') { $cls_Enabled = 'hidden'; $cls_Disabled = ''; $trclass = 'enabled'; } else { $cls_Enabled = ''; $cls_Disabled = 'hidden'; $trclass = 'disabled'; } $api_data = json_decode(get_api_details('plugin', $fi, getDef('GSNOPLUGINCHECK', true))); $updatelink = null; if (is_object($api_data) && $api_data->status == 'successful') { if ($api_data->version > $plugin_info[$pathName]['version']) { $updatelink = '<br /><a class="updatelink" href="' . $api_data->path . '" target="_blank">' . i18n_r('UPDATE_AVAILABLE') . ' ' . $api_data->version . '</a>'; $needsupdate = true; } $plugin_title = '<a href="' . $api_data->path . '" target="_blank">' . $api_data->name . '</a>'; } else { $plugin_title = $plugin_info[$pathName]['name']; } $table .= '<tr id="tr-' . $counter . '" class="' . $trclass . '" >'; $table .= '<td style="width:150px" ><b>' . $plugin_title . '</b></td>'; $table .= '<td><span>' . $plugin_info[$pathName]['description']; if ($plugin_info[$pathName]['version'] != 'disabled') { $table .= '<br /><b>' . i18n_r('PLUGIN_VER') . ' ' . $plugin_info[$pathName]['version'] . '</b> — ' . i18n_r('AUTHOR') . ': <a href="' . $plugin_info[$pathName]['author_url'] . '" target="_blank">' . $plugin_info[$pathName]['author'] . '</a></span>';