__('Install'), 'enable' => __('Enable'), 'disable' => __('Disable'), 'uninstall' => __('Uninstall'), // 'check' => 'Check' ); $status_names = array( -1 => __('Not Compatible'), 0 => __('Not Installed'), 1 => __('Active'), 2 => __('Awaiting Configuration'), 3 => __('Awaiting Upgrade'), 4 => __('Installed') ); /* get the comprehensive list of plugins */ $pluginslist = retrieve_plugin_list(); /* Check to see if we are installing, etc... */ $modes = array('installold', 'uninstallold', 'install', 'uninstall', 'disable', 'enable', 'check', 'moveup', 'movedown'); if (isset_request_var('mode') && in_array(get_nfilter_request_var('mode'), $modes) && isset_request_var('id')) { get_filter_request_var('id', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^([a-zA-Z0-9]+)$/'))); $mode = get_nfilter_request_var('mode'); $id = sanitize_search_string(get_request_var('id')); if (isset_request_var('header')) { $option = 'header=false'; } else { $option = ''; } switch ($mode) { case 'install': if (!in_array($id, $plugins_integrated)) { api_plugin_install($id); } if ($_SESSION['sess_plugins_state'] != '-3') { header('Location: plugins.php?state=5' . ($option != '' ? '&' . $option:'')); } else { header('Location: plugins.php' . ($option != '' ? '?' . $option:'')); } exit; break; case 'uninstall': if (!in_array($id, $pluginslist)) break; api_plugin_uninstall($id); header('Location: plugins.php' . ($option != '' ? '?' . $option:'')); exit; break; case 'disable': if (!in_array($id, $pluginslist)) break; api_plugin_disable($id); header('Location: plugins.php' . ($option != '' ? '?' . $option:'')); exit; break; case 'enable': if (!in_array($id, $pluginslist)) break; if (!in_array($id, $plugins_integrated)) { api_plugin_enable($id); } header('Location: plugins.php' . ($option != '' ? '?' . $option:'')); exit; break; case 'check': if (!in_array($id, $pluginslist)) break; break; case 'moveup': if (!in_array($id, $pluginslist)) break; if (in_array($id, $plugins_integrated)) break; api_plugin_moveup($id); header('Location: plugins.php' . ($option != '' ? '?' . $option:'')); exit; break; case 'movedown': if (!in_array($id, $pluginslist)) break; if (in_array($id, $plugins_integrated)) break; api_plugin_movedown($id); header('Location: plugins.php' . ($option != '' ? '&' . $option:'')); exit; break; } } function retrieve_plugin_list () { $pluginslist = array(); $temp = db_fetch_assoc('SELECT directory FROM plugin_config ORDER BY name'); foreach ($temp as $t) { $pluginslist[] = $t['directory']; } return $pluginslist; } top_header(); update_show_current(); bottom_footer(); function plugins_temp_table_exists($table) { return sizeof(db_fetch_row("SHOW TABLES LIKE '$table'")); } function plugins_load_temp_table() { global $config, $plugins, $plugins_integrated; $pluginslist = retrieve_plugin_list(); if (isset($_SESSION['plugin_temp_table'])) { $table = $_SESSION['plugin_temp_table']; } else { $table = 'plugin_temp_table_' . rand(); } $x = 0; while ($x < 30) { if (!plugins_temp_table_exists($table)) { $_SESSION['plugin_temp_table'] = $table; db_execute("CREATE TEMPORARY TABLE IF NOT EXISTS $table LIKE plugin_config"); db_execute("TRUNCATE $table"); db_execute("INSERT INTO $table SELECT * FROM plugin_config"); break; } else { $table = 'plugin_temp_table_' . rand(); } $x++; } $path = $config['base_path'] . '/plugins/'; $dh = opendir($path); if ($dh !== false) { while (($file = readdir($dh)) !== false) { if (is_dir("$path/$file") && file_exists("$path/$file/setup.php") && !in_array($file, $pluginslist) && !in_array($file, $plugins_integrated)) { if (file_exists("$path/$file/INFO")) { $info = parse_ini_file("$path/$file/INFO", true); $cinfo[$file] = $info['info']; if (!isset($cinfo[$file]['author'])) $cinfo[$file]['author'] = __('Unknown'); if (!isset($cinfo[$file]['homepage'])) $cinfo[$file]['homepage'] = __('Not Stated'); if (isset($cinfo[$file]['webpage'])) $cinfo[$file]['homepage'] = $cinfo[$file]['webpage']; if (!isset($cinfo[$file]['longname'])) $cinfo[$file]['longname'] = ucfirst($file); $cinfo[$file]['status'] = 0; $pluginslist[] = $file; if (!isset($info['info']['compat']) || version_compare(CACTI_VERSION, $info['info']['compat']) < 0) { $cinfo[$file]['status'] = -1; } } else { $cinfo[$file] = array('name' => ucfirst($file), 'longname' => '', 'author' => '', 'homepage' => '', 'version' => '', 'compat' => '0.8'); $cinfo[$file]['status'] = -1; } $pluginslist[] = $file; db_execute("REPLACE INTO $table (directory, name, status, author, webpage, version) VALUES ('" . $file . "', '" . $cinfo[$file]['longname'] . "', '" . $cinfo[$file]['status'] . "', '" . $cinfo[$file]['author'] . "', '" . $cinfo[$file]['homepage'] . "', '" . $cinfo[$file]['version'] . "')"); } } closedir($dh); } return $table; } function update_show_current () { global $plugins, $pluginslist, $config, $status_names, $actions, $item_rows; /* ================= input validation and session storage ================= */ $filters = array( 'rows' => array( 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-1' ), 'page' => array( 'filter' => FILTER_VALIDATE_INT, 'default' => '1' ), 'filter' => array( 'filter' => FILTER_CALLBACK, 'pageset' => true, 'default' => '', 'options' => array('options' => 'sanitize_search_string') ), 'sort_column' => array( 'filter' => FILTER_CALLBACK, 'default' => 'name', 'options' => array('options' => 'sanitize_search_string') ), 'sort_direction' => array( 'filter' => FILTER_CALLBACK, 'default' => 'ASC', 'options' => array('options' => 'sanitize_search_string') ), 'state' => array( 'filter' => FILTER_VALIDATE_INT, 'pageset' => true, 'default' => '-3' ) ); validate_store_request_vars($filters, 'sess_plugins'); /* ================= input validation ================= */ $table = plugins_load_temp_table(); ?>
-3) { if (get_request_var('state') == 5) { $sql_where .= (strlen($sql_where) ? ' AND ':'WHERE ') . ' status IN(1,4)'; } else { $sql_where .= (strlen($sql_where) ? ' AND ':'WHERE ') . ' status=' . get_request_var('state'); } } if (get_request_var('rows') == '-1') { $rows = read_config_option('num_rows_table'); } else { $rows = get_request_var('rows'); } $total_rows = db_fetch_cell("SELECT count(*) FROM $table $sql_where"); $sql_order = get_order_string(); $sql_limit = ' LIMIT ' . ($rows*(get_request_var('page')-1)) . ',' . $rows; $sql_order = str_replace('version ', 'version+0 ', $sql_order); $sql_order = str_replace('id DESC', 'id ASC', $sql_order); $plugins = db_fetch_assoc("SELECT * FROM $table $sql_where $sql_order $sql_limit"); db_execute("DROP TABLE $table"); $nav = html_nav_bar('plugins.php?filter=' . get_request_var('filter'), MAX_DISPLAY_PAGES, get_request_var('page'), $rows, $total_rows, 8, __('Plugins'), 'page', 'main'); form_start('plugins.php', 'chk'); print $nav; html_start_box('', '100%', '', '3', 'center', ''); $display_text = array( 'nosort' => array('display' => __('Actions'), 'align' => 'left', 'sort' => '', 'tip' => __('Actions available include \'Install\', \'Activate\', \'Disable\', \'Enable\', \'Uninstall\'.')), 'directory' => array('display' => __('Plugin Name'), 'align' => 'left', 'sort' => 'ASC', 'tip' => __('The name for this Plugin. The name is controlled by the directory it resides in.')), 'name' => array('display' => __('Plugin Description'), 'align' => 'left', 'sort' => 'ASC', 'tip' => __('A description that the Plugins author has given to the Plugin.')), 'status' => array('display' => __('Status'), 'align' => 'left', 'sort' => 'ASC', 'tip' => __('The status of this Plugin.')), 'author' => array('display' => __('Author'), 'align' => 'left', 'sort' => 'ASC', 'tip' => __('The author of this Plugin.')), 'version' => array('display' => __('Version'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('The version of this Plugin.')), 'id' => array('display' => __('Load Order'), 'align' => 'right', 'sort' => 'ASC', 'tip' => __('The load order of the Plugin. You can change the load order by first sorting by it, then moving a Plugin either up or down.'))); html_header_sort($display_text, get_request_var('sort_column'), get_request_var('sort_direction'), 1); $i = 0; if (sizeof($plugins)) { $j = 0; foreach ($plugins as $plugin) { if ((isset($plugins[$j+1]) && $plugins[$j+1]['status'] < 0) || (!isset($plugins[$j+1]))) { $last_plugin = true; } else { $last_plugin = false; } if ($plugin['status'] <= 0 || (get_request_var('sort_column') != 'id')) { $load_ordering = false; } else { $load_ordering = true; } form_alternate_row('', true); print format_plugin_row($plugin, $last_plugin, $load_ordering); $i++; $j++; } } else { print '
";
break;
}
$link .= '