/** * Upgrade any enabled plugins * NOTE: Needs a fully working Geeklog, so can only be done late in the upgrade * process! * * @param boolean $migration whether the upgrade is part of a site migration * @param array $old_conf old $_CONF values before the migration * @return int number of failed plugin updates (0 = everything's fine) * @see PLG_upgrade * @see PLG_migrate */ private function upgradePlugins($migration = false, array $old_conf = array()) { global $_TABLES; $failed = 0; $result = DB_query("SELECT pi_name, pi_version FROM {$_TABLES['plugins']} WHERE pi_enabled = 1"); $numPlugins = DB_numRows($result); for ($i = 0; $i < $numPlugins; $i++) { list($pi_name, $pi_version) = DB_fetchArray($result); $success = true; if ($migration) { $success = PLG_migrate($pi_name, $old_conf); } if ($success === true) { $codeVersion = PLG_chkVersion($pi_name); if (!empty($codeVersion) && $codeVersion != $pi_version) { $success = PLG_upgrade($pi_name); } } if ($success !== true) { // migration or upgrade failed - disable plugin DB_change($_TABLES['plugins'], 'pi_enabled', 0, 'pi_name', $pi_name); COM_errorLog("Migration or upgrade for '{$pi_name}' plugin failed - plugin disabled"); $failed++; } } return $failed; }
/** * Handle uploaded plugin * * @return string HTML: redirect or main plugin screen + error message * */ function plugin_upload() { global $_CONF, $_TABLES; $retval = ''; $path_admin = $_CONF['path_html'] . substr($_CONF['site_admin_url'], strlen($_CONF['site_url']) + 1) . '/'; $upload_success = false; // If an error occured while uploading the file. $error_msg = plugin_getUploadError($_FILES['plugin']); if (!empty($error_msg)) { $retval .= plugin_main($error_msg); } else { require_once $_CONF['path_system'] . 'classes/unpacker.class.php'; $plugin_file = $_CONF['path_data'] . $_FILES['plugin']['name']; // Name the plugin file $archive = new unpacker($_FILES['plugin']['tmp_name'], $_FILES['plugin']['type']); $tmp = $archive->getlist(); // Grab the contents of the tarball to see what the plugin name is $dirname = preg_replace('/\\/.*$/', '', $tmp[0]['filename']); if (empty($dirname)) { // If $dirname is blank it's probably because the user uploaded a non Tarball file. $retval = COM_refresh($_CONF['site_admin_url'] . '/plugins.php?msg=100'); } else { $pi_did_exist = false; // plugin directory already existed $pi_had_entry = false; // plugin had an entry in the database $pi_was_enabled = false; // plugin was enabled if (file_exists($_CONF['path'] . 'plugins/' . $dirname)) { $pi_did_exist = true; // plugin directory already exists $pstatus = DB_query("SELECT pi_name, pi_enabled FROM {$_TABLES['plugins']} WHERE pi_name = '{$dirname}'"); $A = DB_fetchArray($pstatus); if (isset($A['pi_name'])) { $pi_had_entry = true; $pi_was_enabled = $A['pi_enabled'] == 1; } if ($pi_was_enabled) { // disable temporarily while we move the files around DB_change($_TABLES['plugins'], 'pi_enabled', 0, 'pi_name', $dirname); } require_once 'System.php'; $plugin_dir = $_CONF['path'] . 'plugins/' . $dirname; if (file_exists($plugin_dir . '.previous')) { @System::rm('-rf ' . $plugin_dir . '.previous'); } if (file_exists($plugin_dir)) { rename($plugin_dir, $plugin_dir . '.previous'); } $public_dir = $_CONF['path_html'] . $dirname; if (file_exists($public_dir . '.previous')) { @System::rm('-rf ' . $public_dir . '.previous'); } if (file_exists($public_dir)) { rename($public_dir, $public_dir . '.previous'); } $admin_dir = $path_admin . 'plugins/' . $dirname; if (file_exists($admin_dir . '.previous')) { @System::rm('-rf ' . $admin_dir . '.previous'); } if (file_exists($admin_dir)) { rename($admin_dir, $admin_dir . '.previous'); } } /** * Install the plugin * This doesn't work if the public_html & public_html/admin/plugins directories aren't 777 */ // Extract the tarball to data so we can get the $pi_name name from admin/install.php $archive->unpack($_CONF['path'] . 'data/', array($dirname . '/admin/install.php')); $plugin_inst = $_CONF['path'] . 'data/' . $dirname . '/admin/install.php'; $fdata = ''; $fhandle = @fopen($plugin_inst, 'r'); if ($fhandle) { $fdata = fread($fhandle, filesize($plugin_inst)); fclose($fhandle); } // Remove the plugin from data/ require_once 'System.php'; @System::rm('-rf ' . $_CONF['path'] . 'data/' . $dirname); /** * One time I wanted to install a muffler on my car and * needed to match up the outside diameter of the car's * exhaust pipe to the inside diameter of the muffler. * Unfortunately, when I went to the auto parts store they * didn't have a coupling adapter that would perfectly * match the two pipes, only a bunch of smaller adapters. * I ended up using about 4 small adapters to step down * one size at a time to the size of the muffler's input. * * It's kind of like this regular expression: * */ $fdata = preg_replace('/\\n/', '', $fdata); $fdata = preg_replace('/ /', '', $fdata); $pi_name = preg_replace('/^.*\\$pi\\_name=\'/', '', $fdata); $pi_name = preg_replace('/\'.*$/', '', $pi_name); // Some plugins don't have $pi_name set in their install.php file, // This means our regex won't work and we should just use $dirname if (preg_match('/\\<\\?php/', $pi_name) || preg_match('/--/', $pi_name)) { $pi_name = $dirname; } elseif (empty($pi_name)) { $pi_name = $dirname; } // Extract the uploaded archive to the plugins directory $upload_success = $archive->unpack($_CONF['path'] . 'plugins/'); $plg_path = $_CONF['path'] . 'plugins/' . $pi_name . '/'; if ($upload_success) { if (file_exists($plg_path . 'public_html')) { rename($plg_path . 'public_html', $_CONF['path_html'] . $pi_name); } if (file_exists($plg_path . 'admin')) { rename($plg_path . 'admin', $path_admin . 'plugins/' . $pi_name); } } unset($archive); // Collect some garbage // cleanup when uploading a new version if ($pi_did_exist) { $plugin_dir = $_CONF['path'] . 'plugins/' . $dirname; if (file_exists($plugin_dir . '.previous')) { @System::rm('-rf ' . $plugin_dir . '.previous'); } $public_dir = $_CONF['path_html'] . $dirname; if (file_exists($public_dir . '.previous')) { @System::rm('-rf ' . $public_dir . '.previous'); } $admin_dir = $path_admin . 'plugins/' . $dirname; if (file_exists($admin_dir . '.previous')) { @System::rm('-rf ' . $admin_dir . '.previous'); } if ($pi_was_enabled) { DB_change($_TABLES['plugins'], 'pi_enabled', 1, 'pi_name', $dirname); } } $msg_with_plugin_name = false; if ($pi_did_exist) { if ($pi_was_enabled) { // check if we have to perform an update $pi_version = DB_getItem($_TABLES['plugins'], 'pi_version', "pi_name = '{$dirname}'"); $code_version = PLG_chkVersion($dirname); if (!empty($code_version) && $code_version != $pi_version) { /** * At this point, we would have to call PLG_upgrade(). * However, we've loaded the plugin's old functions.inc * (in lib-common.php). We can't load the new one here * now since that would result in duplicate function * definitions. Solution: Trigger a reload (with the new * functions.inc) and continue there. */ $url = $_CONF['site_admin_url'] . '/plugins.php' . '?mode=continue_upgrade' . '&codeversion=' . urlencode($code_version) . '&piversion=' . urlencode($pi_version) . '&plugin=' . urlencode($dirname); echo COM_refresh($url); exit; } else { $msg = 98; // successfully uploaded } } else { $msg = 98; // successfully uploaded } } elseif (file_exists($plg_path . 'autoinstall.php')) { // if the plugin has an autoinstall.php, install it now if (plugin_autoinstall($pi_name)) { PLG_pluginStateChange($pi_name, 'installed'); $msg = 44; // successfully installed } else { $msg = 72; // an error occured while installing the plugin } } else { $msg = 98; // successfully uploaded } $url = $_CONF['site_admin_url'] . '/plugins.php?msg=' . $msg; if ($msg_with_plugin_name) { $url .= '&plugin=' . $dirname; } $retval = COM_refresh($url); } } return $retval; }
/** * Adds installed plugins to the list * */ function PLUGINS_loadPlugins(&$data_arr) { global $_CONF, $_TABLES, $glfPlugins; $result = DB_query("SELECT pi_name,pi_version,pi_gl_version,pi_enabled,pi_homepage FROM {$_TABLES['plugins']} WHERE 1=1"); $rows = DB_numRows($result); for ($i = 0; $i < $rows; $i++) { $P = DB_fetchArray($result); $pluginData = PLUGINS_getPluginXML($_CONF['path'] . 'plugins/' . $P['pi_name']); // ok the plugin is in the plugins table, so it's installed $P['installed'] = 1; // determine the plugin code version if ($P['pi_enabled'] == 1) { $P['pi_code_version'] = PLG_chkVersion($P['pi_name']); } else { $P['pi_code_version'] = is_array($pluginData) ? $pluginData['version'] : '0.0.0'; } $P['name'] = is_array($pluginData) ? $pluginData['name'] : ''; $P['description'] = is_array($pluginData) ? $pluginData['description'] : ''; $P['maintainer'] = is_array($pluginData) ? $pluginData['maintainer'] : ''; $P['phpversion'] = is_array($pluginData) ? $pluginData['phpversion'] : ''; $P['glfusionversion'] = is_array($pluginData) ? $pluginData['glfusionversion'] : ''; $P['update'] = ($P['pi_enabled'] == 1 and $P['pi_version'] != $P['pi_code_version']) ? 1 : 0; $P['bundled'] = in_array($P['pi_name'], $glfPlugins) ? 1 : 0; $data_arr[] = $P; } return; }
/** * used for the list of plugins in admin/plugins.php * * @param string $fieldName * @param string $fieldValue * @param array $A * @param array $icon_arr * @param string $token * @return string */ function ADMIN_getListField_plugins($fieldName, $fieldValue, $A, $icon_arr, $token) { global $_CONF, $LANG_ADMIN, $LANG32; $retval = ''; switch ($fieldName) { case 'info_installed': $retval = COM_createLink($icon_arr['info'], "{$_CONF['site_admin_url']}/plugins.php?mode=info_installed&pi_name={$A['pi_name']}", array('title' => $LANG32[13])); break; case 'pi_name': $retval = plugin_get_pluginname($A['pi_name']); break; case 'pi_version': $plugin_code_version = PLG_chkVersion($A['pi_name']); if (empty($plugin_code_version)) { $code_version = $LANG_ADMIN['na']; } else { $code_version = $plugin_code_version; } $pi_installed_version = $A['pi_version']; if (empty($plugin_code_version) || $pi_installed_version == $code_version) { $retval = $pi_installed_version; } else { $retval = "{$LANG32[37]}: {$pi_installed_version}, {$LANG32[36]}: {$plugin_code_version}"; if ($A['pi_enabled'] == 1) { $retval .= " <b>{$LANG32[38]}</b>"; $csrfToken = '&' . CSRF_TOKEN . '=' . $token; $style = 'style="vertical-align: middle;"'; $img = $_CONF['layout_url'] . '/images/update.png'; $img = "<img {$style} alt=\"[" . $LANG32[38] . "]\" src=\"{$img}\"" . XHTML . ">"; $url = $_CONF['site_admin_url'] . '/plugins.php?mode=updatethisplugin&pi_name=' . $A['pi_name'] . $csrfToken; $retval .= COM_createLink($img, $url, array('title' => $LANG32[42])); } } break; case 'pi_dependencies': if (PLG_checkDependencies($A['pi_name'])) { $retval = COM_getTooltip($LANG32[51], PLG_printDependencies($A['pi_name'], $A['pi_gl_version'])); } else { $style = "display: inline; color: #a00; border-bottom: 1px dotted #a00;"; $retval = COM_getTooltip("<b class='notbold' style='{$style}'>{$LANG32[52]}</b>", PLG_printDependencies($A['pi_name'], $A['pi_gl_version'])); } break; case 'pi_load': $csrfToken = '&' . CSRF_TOKEN . '=' . $token; $style = "style='vertical-align: middle;'"; $upimg = $_CONF['layout_url'] . '/images/admin/up.png'; $dnimg = $_CONF['layout_url'] . '/images/admin/down.png'; $url = $_CONF['site_admin_url'] . '/plugins.php?mode=change_load_order&pi_name=' . $A['pi_name'] . $csrfToken . '&where='; $retval .= COM_createLink("<img {$style} alt='+' src='{$upimg}'" . XHTML . ">", $url . 'up', array('title' => $LANG32[44])); $retval .= ' ' . $A['pi_load'] . ' '; $retval .= COM_createLink("<img {$style} alt='-' src='{$dnimg}'" . XHTML . ">", $url . 'dn', array('title' => $LANG32[45])); break; case 'pi_enabled': if (!PLG_checkDependencies($A['pi_name'])) { $retval = str_replace('<img ', '<img title="' . $LANG32[64] . '" ', $icon_arr['warning']); } else { $not_present = false; if ($A['pi_enabled'] == 1) { $switch = 'enabled'; $title = $LANG32[49]; } else { $switch = 'disabled'; $title = $LANG32[48]; if (!file_exists($_CONF['path'] . 'plugins/' . $A['pi_name'] . '/functions.inc')) { $not_present = true; } } if ($not_present) { $retval = str_replace('<img ', '<img title="' . $LANG32[64] . '" ', $icon_arr['unavailable']); } else { $sorting = ''; $csrfToken2 = '&' . CSRF_TOKEN . '=' . $token; if (!empty($_GET['order']) && !empty($_GET['direction'])) { // Remember how the list was sorted $ord = trim($_GET['order']); $dir = trim($_GET['direction']); $old = trim($_GET['prevorder']); $sorting = "&order={$ord}&direction={$dir}&prevorder={$old}"; } $retval = COM_createLink($icon_arr[$switch], $_CONF['site_admin_url'] . '/plugins.php?mode=toggle&pi_name=' . $A['pi_name'] . $csrfToken2 . $sorting, array('title' => $title)); } } break; case 'delete': $csrfToken2 = '&' . CSRF_TOKEN . '=' . $token; $id = 'uninstall_' . $A['pi_name']; // used by JavaScript $message = sprintf($LANG32[47], "\\'" . plugin_get_pluginname($A['pi_name']) . "\\'"); // used by JavaScript $url = $_CONF['site_admin_url'] . '/plugins.php?mode=delete&pi_name=' . $A['pi_name'] . $csrfToken2; $link_args = array('title' => $LANG32[46], 'onclick' => "confirm_action('{$message}', '{$url}&confirmed=1')", 'id' => $id); $retval .= COM_createLink($icon_arr['deleteitem'], $url, $link_args); // If javascript is available, we will be using it to get a confirmation from the user. So we need to hide the default link. $retval .= '<script type="text/javascript">document.getElementById("' . $id . '").href = "javascript:void(0);";</script>'; break; default: $retval = $fieldValue; break; } return $retval; }
/** * Handle uploaded plugin * * @return string HTML or error message * */ function MONITOR_plugin_upload($plugin = '') { global $_CONF, $_MONITOR_CONF, $_TABLES; $retval = ''; if ($plugin == '' || $_MONITOR_CONF['repository'] == '') { return; } $url = "https://api.github.com/repos/{$_MONITOR_CONF['repository']}/" . $plugin . '/releases'; //Get last release for this plugin $releases = MONITOR_curlRequestOnGitApi($url); $version = $releases[0]['tag_name']; $path_admin = $_CONF['path_html'] . substr($_CONF['site_admin_url'], strlen($_CONF['site_url']) + 1) . '/'; $upload_success = false; //Download the zip file from repository $source = "https://codeload.github.com/{$_MONITOR_CONF['repository']}/{$plugin}/zip/{$version}"; $destination = fopen($_CONF['path_data'] . $plugin . '.zip', 'w+'); set_time_limit(0); // unlimited max execution time $options = array(CURLOPT_FILE => $destination, CURLOPT_TIMEOUT => 28800, CURLOPT_URL => $source, CURLOPT_USERAGENT => $_MONITOR_CONF['repository'], CURLOPT_SSL_VERIFYPEER => false); $ch = curl_init(); curl_setopt_array($ch, $options); $result = curl_exec($ch); curl_close($ch); $plugin_file = $_CONF['path_data'] . $plugin . '.zip'; // Name the plugin file if (!file_exists($plugin_file)) { COM_errorLog('MONITOR - Download failed for Plugin: ' . $plugin); return 'Download failed for Plugin: ' . $plugin; } else { chmod($plugin_file, 0755); } require_once $_CONF['path_system'] . 'classes/unpacker.class.php'; $archive = new unpacker($plugin_file, 'application/x-zip'); if ($archive == false) { return 72; } COM_errorLog('MONITOR - Download ' . $plugin . ' plugin: ok'); $pi_did_exist = false; // plugin directory already existed $pi_had_entry = false; // plugin had an entry in the database $pi_was_enabled = false; // plugin was enabled $alternate = false; if (file_exists($_CONF['path'] . 'plugins/' . $plugin)) { $pi_did_exist = true; // plugin directory already exists $pstatus = DB_query("SELECT pi_name, pi_enabled FROM {$_TABLES['plugins']} WHERE pi_name = '{$plugin}'"); $A = DB_fetchArray($pstatus); if (isset($A['pi_name'])) { $pi_had_entry = true; $pi_was_enabled = $A['pi_enabled'] == 1; } if ($pi_was_enabled) { // disable temporarily while we move the files around DB_change($_TABLES['plugins'], 'pi_enabled', 0, 'pi_name', $plugin); COM_errorLog('MONITOR - Disable Plugin: ' . $plugin); } require_once 'System.php'; $plugin_dir = $_CONF['path'] . 'plugins/' . $plugin; if (file_exists($plugin_dir . '.previous')) { @System::rm('-rf ' . $plugin_dir . '.previous'); } if (file_exists($plugin_dir)) { rename($plugin_dir, $plugin_dir . '.previous'); COM_errorLog('MONITOR - Rename: ' . $plugin_dir . ' to ' . $plugin_dir . '.previous'); } $public_dir = $_CONF['path_html'] . $plugin; if (file_exists($public_dir . '.previous')) { @System::rm('-rf ' . $public_dir . '.previous'); } if (file_exists($public_dir)) { rename($public_dir, $public_dir . '.previous'); COM_errorLog('MONITOR - Rename: ' . $public_dir . ' to ' . $public_dir . '.previous'); } $admin_dir = $path_admin . 'plugins/' . $plugin; if (file_exists($admin_dir . '.previous')) { @System::rm('-rf ' . $admin_dir . '.previous'); } if (file_exists($admin_dir)) { rename($admin_dir, $admin_dir . '.previous'); COM_errorLog('MONITOR - Rename: ' . $admin_dir . ' to ' . $admin_dir . '.previous'); } } $upload_success = false; // Extract the uploaded archive to the data directory $upload_success = $archive->unpack($_CONF['path_data']); if (!$upload_success) { //Try alternative unzip unset($archive); require_once 'Archive/Zip.php'; $archive = new Archive_Zip($plugin_file); if ($archive == false) { return 72; } $params = array('add_path' => $_CONF['path_data']); $extract = $archive->extract($params); if (is_array($extract)) { $upload_success = true; } $alternate = true; } if (!$upload_success) { COM_errorLog("MONITOR - Can't unzip the archive. Update for {$plugin_dir} plugin failed! Please check the archive in your data folder. Could be an OS issue during unzip."); if (file_exists($plugin_dir . '.previous')) { rename($plugin_dir . '.previous', $plugin_dir); COM_errorLog('MONITOR - Rename: ' . $plugin_dir . '.previous' . ' to ' . $plugin_dir); } if (file_exists($public_dir . '.previous')) { rename($public_dir . '.previous', $public_dir); COM_errorLog('MONITOR - Rename: ' . $public_dir . '.previous' . ' to ' . $public_dir); } if (file_exists($admin_dir . '.previous')) { rename($admin_dir . '.previous', $admin_dir); COM_errorLog('MONITOR - Rename: ' . $admin_dir . '.previous' . ' to ' . $admin_dir); } if ($pi_was_enabled) { DB_change($_TABLES['plugins'], 'pi_enabled', 1, 'pi_name', $plugin); COM_errorLog('MONITOR - Enable Plugin: ' . $plugin); } return 72; exit; } else { //Move files to plugins directory COM_errorLog('MONITOR - Plugin update: ' . $plugin); if (!$alternate) { $folder_name = $archive->getdir(); } else { $listcontent = $archive->listContent(); $folder_name = $listcontent[0]['filename']; if (substr($folder_name, -1) == '/') { $folder_name = substr($folder_name, 0, -1); } } if ($folder_name == '') { exit; } $srcDir = $_CONF['path_data'] . $folder_name; $destDir = $_CONF['path'] . 'plugins/' . $plugin; //Move from data folder to plugins folder rename($srcDir, $destDir); $plg_path = $_CONF['path'] . 'plugins/' . $plugin . '/'; if (file_exists($plg_path . 'public_html')) { rename($plg_path . 'public_html', $_CONF['path_html'] . $plugin); COM_errorLog('MONITOR - Move ' . $plg_path . 'public_html to ' . $_CONF['path_html'] . $plugin); } else { COM_errorLog('MONITOR - ' . $plg_path . 'public_html does not exist'); } if (file_exists($plg_path . 'admin')) { rename($plg_path . 'admin', $path_admin . 'plugins/' . $plugin); COM_errorLog('MONITOR - Move ' . $plg_path . 'admin to ' . $path_admin . 'plugins/' . $plugin); } else { COM_errorLog('MONITOR - ' . $plg_path . 'admin does not exist'); } unset($archive); // Collect some garbage // cleanup when uploading a new version if ($pi_did_exist) { $plugin_dir = $_CONF['path'] . 'plugins/' . $plugin; if (file_exists($plugin_dir . '.previous')) { @System::rm('-rf ' . $plugin_dir . '.previous'); } $public_dir = $_CONF['path_html'] . $plugin; if (file_exists($public_dir . '.previous')) { @System::rm('-rf ' . $public_dir . '.previous'); } $admin_dir = $path_admin . 'plugins/' . $plugin; if (file_exists($admin_dir . '.previous')) { @System::rm('-rf ' . $admin_dir . '.previous'); } if ($pi_was_enabled) { DB_change($_TABLES['plugins'], 'pi_enabled', 1, 'pi_name', $plugin); COM_errorLog('MONITOR - Enable Plugin: ' . $plugin); } } $msg_with_plugin_name = false; if ($pi_did_exist) { if ($pi_was_enabled) { // check if we have to perform an update $pi_version = DB_getItem($_TABLES['plugins'], 'pi_version', "pi_name = '{$plugin}'"); $code_version = PLG_chkVersion($plugin); COM_errorLog('MONITOR - Reading' . $plugin . ' plugin installed version: ' . $pi_version . ' and code version: ' . $code_version); if (!empty($code_version) && $code_version != $pi_version) { /** * At this point, we would have to call PLG_upgrade(). * However, we've loaded the plugin's old functions.inc * (in lib-common.php). We can't load the new one here * now since that would result in duplicate function * definitions. Solution: Trigger a reload (with the new * functions.inc) and continue there. */ $url = $_CONF['site_admin_url'] . '/plugins/monitor/index.php' . '?action=continue_upgrade' . '&codeversion=' . urlencode($code_version) . '&piversion=' . urlencode($pi_version) . '&plugin_update=' . urlencode($plugin); COM_errorLog('MONITOR - Update Plugin ' . $plugin . ' from version: ' . $pi_version . ' to code version: ' . $code_version); echo COM_refresh($url); exit; } else { $msg = 98; // successfully uploaded } } else { $msg = 98; // successfully uploaded } } elseif (file_exists($plg_path . 'autoinstall.php')) { // if the plugin has an autoinstall.php, install it now if (plugin_autoinstall($plugin)) { PLG_pluginStateChange($plugin, 'installed'); $msg = 44; // successfully installed } else { $msg = 72; // an error occured while installing the plugin } } else { $msg = 98; // successfully uploaded } } return $msg; }
/** * used for the list of plugins in admin/plugins.php * */ function ADMIN_getListField_plugins($fieldname, $fieldvalue, $A, $icon_arr, $token) { global $_CONF, $LANG_ADMIN, $LANG32; static $added_token; $retval = ''; switch ($fieldname) { case 'edit': $retval = COM_createLink($icon_arr['edit'], "{$_CONF['site_admin_url']}/plugins.php?mode=edit&pi_name={$A['pi_name']}"); break; case 'pi_name': $retval = plugin_get_pluginname($A['pi_name']); break; case 'pi_version': $plugin_code_version = PLG_chkVersion($A['pi_name']); if (empty($plugin_code_version)) { $code_version = $LANG_ADMIN['na']; } else { $code_version = $plugin_code_version; } $pi_installed_version = $A['pi_version']; if (empty($plugin_code_version) || $pi_installed_version == $code_version) { $retval = $pi_installed_version; } else { $retval = "{$LANG32[37]}: {$pi_installed_version}, {$LANG32[36]}: {$plugin_code_version}"; if ($A['pi_enabled'] == 1) { $retval .= " <b>{$LANG32[38]}</b>" . ' <input type="image" src="' . $_CONF['layout_url'] . '/images/update.png" alt="[' . $LANG32[38] . ']" name="updatethisplugin" value="' . $A['pi_name'] . '" onclick="submit()" title="' . $LANG32[42] . '"' . XHTML . '>'; if (!isset($added_token)) { $retval .= '<input type="hidden" name="' . CSRF_TOKEN . '" ' . 'value="' . $token . '"' . XHTML . '>'; $added_token = true; } } } break; case 'enabled': $not_present = false; if ($A['pi_enabled'] == 1) { $switch = ' checked="checked"'; } else { $switch = ''; if (!file_exists($_CONF['path'] . 'plugins/' . $A['pi_name'] . '/functions.inc')) { $not_present = true; } } if ($not_present) { $retval = '<input type="checkbox" name="enabledplugins[' . $A['pi_name'] . ']" disabled="disabled"' . XHTML . '>'; } else { $retval = '<input type="checkbox" name="enabledplugins[' . $A['pi_name'] . ']" onclick="submit()" value="1"' . $switch . XHTML . '>'; if (!isset($added_token)) { $retval .= '<input type="hidden" name="' . CSRF_TOKEN . '" ' . 'value="' . $token . '"' . XHTML . '>'; $added_token = true; } } break; default: $retval = $fieldvalue; break; } return $retval; }