/system/cp/cp.utilities.php
PHP | 5636 lines | 3811 code | 1272 blank | 553 comment | 490 complexity | 26e0bc0fa448a1550a0a0c14d0e6633d MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php
- /*
- =====================================================
- ExpressionEngine - by EllisLab
- -----------------------------------------------------
- http://expressionengine.com/
- -----------------------------------------------------
- Copyright (c) 2003 - 2010 EllisLab, Inc.
- =====================================================
- THIS IS COPYRIGHTED SOFTWARE
- PLEASE READ THE LICENSE AGREEMENT
- http://expressionengine.com/docs/license.html
- =====================================================
- File: cp.utilities.php
- -----------------------------------------------------
- Purpose: Utilities
- =====================================================
- */
- if ( ! defined('EXT'))
- {
- exit('Invalid file request');
- }
- class Utilities {
- /** -------------------------------------------
- /** Extensions Manager
- /** -------------------------------------------*/
- function extensions_manager($message = '')
- {
- global $DSP, $IN, $PREFS, $LANG, $DB, $FNS, $EXT;
-
- $debug = TRUE;
- $extension_files = array();
- $extensions_installed = array();
-
- /** ---------------------------------------
- /** Extensions Available
- /** ---------------------------------------*/
-
- $i = 0;
- if ($fp = @opendir(PATH_EXT))
- {
- while (false !== ($file = readdir($fp)))
- {
- if (substr($file, -strlen(EXT)) == EXT && substr($file, 0, 4) == 'ext.')
- {
- $extension_files[$i] = substr($file, 4, -strlen(EXT));
-
- $i++;
- }
- }
-
- closedir($fp);
- }
-
- /** ---------------------------------------
- /** Extensions Enabled
- /** ---------------------------------------*/
-
- $query = $DB->query("SELECT class, version FROM exp_extensions WHERE enabled = 'y'");
-
- if ($query->num_rows > 0)
- {
- foreach($query->result as $row) $extensions_installed[strtolower($row['class'])] = $row['version'];
- }
-
- /** ---------------------------------------
- /** Create Output
- /** ---------------------------------------*/
-
- $DSP->crumbline = FALSE;
-
- if ($PREFS->ini('allow_extensions') == 'y')
- {
- $DSP->right_crumb($LANG->line('disable_extensions'), BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=toggle_extension_confirm'.AMP.'which=disable');
- }
- else
- {
- $DSP->right_crumb($LANG->line('enable_extensions'), BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=toggle_extension_confirm'.AMP.'which=enable');
- }
-
- $r = $DSP->qdiv('tableHeading', $LANG->line('extensions_manager'));
-
- if ($message != '')
- {
- $r .= $DSP->qdiv('success', $message);
- }
-
- // List of Extensions Table
-
- $r .= $DSP->table('tableBorder', '0', '0', '100%');
-
- if (count($extension_files) == 0)
- {
- $r .= $DSP->tr().
- $DSP->td('tableCellTwo', '', '2').
- '<b>'.$LANG->line('no_extensions_exist').'</b>'.
- $DSP->td_c().
- $DSP->tr_c();
- }
- else
- {
- $r .= $DSP->tr().
- $DSP->td('tableHeadingAlt', '55%').
- $LANG->line('extension_name').
- $DSP->td_c().
- $DSP->td('tableHeadingAlt', '15%').
- $LANG->line('documentation').
- $DSP->td_c().
- $DSP->td('tableHeadingAlt', '15%').
- $LANG->line('settings').
- $DSP->td_c().
- $DSP->td('tableHeadingAlt', '15%').
- $LANG->line('status').
- $DSP->td_c().
- $DSP->tr_c();
- }
- $i = 0;
-
- if (count($extension_files) > 0)
- {
- $extension_meta = array('description', 'settings_exist', 'docs_url', 'name', 'version');
- $qm = ($PREFS->ini('force_query_string') == 'y') ? '' : '?';
-
- foreach ($extension_files as $extension_name)
- {
- $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo';
-
- /** ------------------------------------
- /** Load Extension and Fetch Metadata
- /** ------------------------------------*/
-
- $meta = array();
- $class_name = ucfirst($extension_name);
-
- if ( ! class_exists($class_name))
- {
- if ($debug === TRUE)
- {
- include(PATH_EXT.'ext.'.$extension_name.EXT);
- }
- else
- {
- @include(PATH_EXT.'ext.'.$extension_name.EXT);
- }
-
- if ( ! class_exists($class_name)) continue;
- }
-
- $OBJ = new $class_name();
-
- foreach($extension_meta as $meta_item)
- {
- ${$meta_item} = ( ! isset($OBJ->{$meta_item})) ? '' : $OBJ->{$meta_item};
- }
-
- if ($name == '')
- {
- $name = ucwords(str_replace('_',' ',$extension_name));
- }
-
- /** ------------------------------------
- /** Different Output depending on current status
- /** ------------------------------------*/
-
- if ($PREFS->ini('allow_extensions') == 'y' && isset($extensions_installed[$extension_name]))
- {
- // Double check that the extension is up to date
- // If not, then quickly run the update script to make
- // sure that we are up to date before changing any settings
-
- if ($OBJ->version > $EXT->version_numbers[$class_name] && method_exists($OBJ, 'update_extension') === TRUE)
- {
- $update = $OBJ->update_extension($EXT->version_numbers[$class_name]);
-
- $EXT->version_numbers[$class_name] = $OBJ->version;
- }
-
- $installed = $LANG->line('extension_enabled') . ' ('.$DSP->anchor(BASE.AMP.'C=admin'.
- AMP.'M=utilities'.
- AMP.'P=toggle_extension'.
- AMP.'which=disable'.
- AMP.'name='.$extension_name,
- $LANG->line('disable_extension'),
- "onclick='if(!confirm(\"".
- $LANG->line('toggle_extension_confirmation').
- "\")) return false;'").')';
-
- $link = $DSP->qspan('defaultBold', $name).' (v.'.$version.')';
-
- if ($description != '' && $description != '')
- {
- $link .= NL.$DSP->br().NL.$description;
- }
-
- $settings_link = $DSP->anchor(BASE.AMP.'C=admin'.
- AMP.'M=utilities'.
- AMP.'P=extension_settings'.
- AMP.'name='.$extension_name,
- $LANG->line('settings'));
- }
- else
- {
-
- $link = $DSP->qspan('defaultLight', $name.' (v.'.$version.')');
-
- if ($PREFS->ini('allow_extensions') == 'y')
- {
- $installed = $LANG->line('extension_disabled') . ' ('.$DSP->anchor(BASE.AMP.'C=admin'.
- AMP.'M=utilities'.
- AMP.'P=toggle_extension'.
- AMP.'which=enable'.
- AMP.'name='.$extension_name,
- $LANG->line('enable_extension'),
- "onclick='if(!confirm(\"".
- $LANG->line('toggle_extension_confirmation').
- "\")) return false;'").')';
- }
- else
- {
- $installed = $LANG->line('extension_disabled');
- }
-
- $settings_link = $DSP->qspan('defaultLight', $LANG->line('settings'));
- }
-
- if ($docs_url != '')
- {
- $docs_url = $DSP->anchor($FNS->fetch_site_index().$qm.'URL='.urlencode($docs_url), $LANG->line('documentation'), '', TRUE);
- }
-
- $r .= $DSP->tr()
- . $DSP->table_qcell($style, $link, '55%')
- . $DSP->table_qcell($style, ($docs_url == '') ? '--' : $docs_url, '15%')
- . $DSP->table_qcell($style, ($settings_exist != 'y') ? '--' : $settings_link, '15%')
- . $DSP->table_qcell($style, $installed, '15%')
- .$DSP->tr_c();
-
- unset($OBJ);
- }
- }
-
- $r .= $DSP->table_c();
-
- $DSP->title = $LANG->line('extensions_manager');
- $DSP->crumb = $DSP->anchor(BASE.AMP.'C=admin'.AMP.'area=utilities', $LANG->line('utilities')).
- $DSP->crumb_item($LANG->line('extensions_manager'));
- $DSP->body = $r;
- }
- /* END */
-
-
- /** -------------------------------------------
- /** Extension Settings Form
- /** -------------------------------------------*/
- function extension_settings($message = '')
- {
- global $DSP, $IN, $PREFS, $LANG, $DB, $FNS, $REGX;
-
- if ($PREFS->ini('allow_extensions') != 'y')
- {
- return $DSP->no_access_message();
- }
-
- if ($IN->GBL('name') === FALSE OR ! preg_match("/^[a-z0-9][\w.-]*$/i",$IN->GBL('name'))) return false;
-
- $class_name = ucfirst($IN->GBL('name'));
- $current = array();
-
- /** ---------------------------------------
- /** Extensions Enabled
- /** ---------------------------------------*/
-
- $query = $DB->query("SELECT settings FROM exp_extensions
- WHERE enabled = 'y' AND class = '".$DB->escape_str($class_name)."'
- LIMIT 1");
-
- if ($query->num_rows > 0 && $query->row['settings'] != '')
- {
- $current = $REGX->array_stripslashes(unserialize($query->row['settings']));
- }
-
- /** -----------------------------
- /** Call Extension File
- /** -----------------------------*/
-
- if ( ! class_exists($class_name))
- {
- @include(PATH_EXT.'ext.'.$IN->GBL('name').EXT);
-
- if ( ! class_exists($class_name)) return false;
- }
-
- $OBJ = new $class_name();
-
- foreach(array('description', 'settings_exist', 'docs_url', 'name', 'version') as $meta_item)
- {
- ${$meta_item} = ( ! isset($OBJ->{$meta_item})) ? '' : $OBJ->{$meta_item};
- }
-
- if ($name == '')
- {
- $name = ucwords(str_replace('_',' ',$extension_name));
- }
-
- // -----------------------------------
- // Fetch Extension Language file
- //
- // If there are settings, then there is a language file
- // because we need to know all the various variable names in the settings
- // form. I was tempted to give these language files a prefix but I
- // decided against it for the sake of simplicity and the fact that
- // a module might have extension's bundled with them and it would make
- // sense to have the same language file for both.
- // -----------------------------------
- $LANG->fetch_language_file($IN->GBL('name'));
-
- /** ---------------------------------------
- /** Creating Their Own Settings Form?
- /** ---------------------------------------*/
-
- if (method_exists($OBJ, 'settings_form') === TRUE)
- {
- return $OBJ->settings_form($current);
- }
-
- /** ---------------------------------------
- /** Right Crumb Tab
- /** ---------------------------------------*/
-
- $DSP->crumbline = TRUE;
-
- $DSP->right_crumb($LANG->line('disable_extension'), BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=toggle_extension_confirm'.AMP.'which=disable'.AMP.'name='.$IN->GBL('name'));
-
- /** -----------------------------
- /** Create Page's Content
- /** -----------------------------*/
-
- $r = $DSP->table('', '', '', '100%')
- .$DSP->tr()
- .$DSP->td('default', '', '', '', 'top')
- .$DSP->heading($LANG->line('extension_settings'));
-
- $qm = ($PREFS->ini('force_query_string') == 'y') ? '' : '?';
- $docs = ($docs_url == '') ? '' : ' ['.$DSP->anchor($FNS->fetch_site_index().$qm.'URL='.urlencode($docs_url), $LANG->line('documentation'), '', TRUE).']';
- $r .= $DSP->td_c()
- .$DSP->td('default', '', '', '', 'middle')
- .$DSP->qdiv('defaultRight', '<strong>'.$docs.'</strong>'.NBS.NBS)
- .$DSP->td_c()
- .$DSP->tr_c()
- .$DSP->tr()
- .$DSP->td('default', '100%', '2', '', 'top');
-
- $r .= Utilities::extension_settings_form($name, $IN->GBL('name'), $OBJ->settings(), $current);
-
- $r .= $DSP->td_c()
- .$DSP->tr_c()
- .$DSP->table_c()
- .$DSP->td_c()
- .$DSP->tr_c()
- .$DSP->table_c();
-
- $DSP->title = $LANG->line('extension_settings');
- $DSP->crumb = $DSP->anchor(BASE.AMP.'C=admin'.AMP.'area=utilities', $LANG->line('utilities')).
- $DSP->crumb_item($DSP->anchor(BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=extensions_manager', $LANG->line('extensions_manager')));
- $DSP->crumb .= $DSP->crumb_item($name);
- $DSP->body = $r;
- }
- /* END */
-
-
- /** -----------------------------
- /** Store Extension Settings
- /** -----------------------------*/
-
- function save_extension_settings()
- {
- global $IN, $DB, $FNS;
-
- // Basic security check
- if ( ! preg_match("/^[a-z0-9][\w.-]*$/i",$IN->GBL('name'))) return false;
-
- if ( ! class_exists(ucfirst($IN->GBL('name'))))
- {
- include(PATH_EXT.'ext.'.strtolower($IN->GBL('name')).EXT);
- }
-
- // Ok, I admit that we should be able to simply unset the 'name' value
- // from the $_POST array and simply insert that into the database.
- // I, Paul Burdick of the Sinister House geeks, am slowly becoming
- // anal retentive in my young age and decided to make sure only those
- // settings specified by the extension are inserted AND that there is
- // always an empty string in the really rare chance that one is not
- // specified.
-
- if (class_exists(ucfirst($IN->GBL('name'))))
- {
- $class_name = ucfirst($IN->GBL('name'));
-
- $OBJ = new $class_name();
-
- /** ---------------------------------------
- /** Processing Their Own Settings Form?
- /** ---------------------------------------*/
-
- if (method_exists($OBJ, 'settings_form') === TRUE)
- {
- $OBJ->save_settings();
-
- $FNS->redirect(BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=extensions_manager');
- exit;
- }
-
- if (method_exists($OBJ, 'settings') === TRUE)
- {
- $settings = $OBJ->settings();
- }
-
- $insert = array();
-
- foreach($settings as $key => $value)
- {
- if ( ! is_array($value))
- {
- $insert[$key] = ($IN->GBL($key, 'POST') !== FALSE) ? $IN->GBL($key, 'POST') : $value;
- }
- elseif (is_array($value) && isset($value['1']) && is_array($value['1']))
- {
- if(is_array($IN->GBL($key, 'POST')) OR $value[0] == 'ms')
- {
- $data = (is_array($IN->GBL($key, 'POST'))) ? $IN->GBL($key, 'POST') : array();
-
- $data = array_intersect($data, array_keys($value['1']));
- }
- else
- {
- if ($IN->GBL($key, 'POST') === FALSE)
- {
- $data = ( ! isset($value['2'])) ? '' : $value['2'];
- }
- else
- {
- $data = $IN->GBL($key, 'POST');
- }
- }
-
- $insert[$key] = $data;
- }
- else
- {
- $insert[$key] = ($IN->GBL($key, 'POST') !== FALSE) ? $IN->GBL($key, 'POST') : '';
- }
- }
-
- $DB->query("UPDATE exp_extensions SET settings = '".addslashes(serialize($insert))."' WHERE class = '".$DB->escape_str($IN->GBL('name'))."'");
- }
-
- $FNS->redirect(BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=extensions_manager');
- exit;
- }
- /* END */
-
-
-
- /** -----------------------------
- /** Create Form Automagically
- /** -----------------------------*/
-
- function extension_settings_form($extension_name, $name, $fdata, $data)
- {
- global $DSP, $LANG;
- $r = $DSP->form_open(
- array(
- 'action' => 'C=admin'.AMP.'M=utilities'.AMP.'P=save_extension_settings',
- 'name' => 'settings_'.$name,
- 'id' => 'settings_'.$name
- ),
-
- array('name' => $name)
- );
-
-
- $r .= $DSP->table('tableBorder', '0', '', '100%');
- $r .= $DSP->tr();
- $r .= $DSP->td('tableHeadingAlt', '', '2');
- $r .= $extension_name;
- $r .= $DSP->td_c();
- $r .= $DSP->tr_c();
-
- $i = 0;
-
- /** -----------------------------
- /** Blast through the array
- /** -----------------------------*/
-
- foreach ($fdata as $key => $val)
- {
- $style = ($i % 2) ? 'tableCellOne' : 'tableCellTwo'; $i++;
-
- $default_data = (is_array($val)) ? '' : $val;
-
- $data[$key] = ( ! isset($data[$key])) ? $default_data : $data[$key];
-
- if (!is_array($val) || $val['0'] != 'sf')
- {
- $r .= $DSP->tr();
-
- // If the form type is a textarea, we'll align the text at the top, otherwise, we'll center it
-
- if (is_array($val) && ($val['0'] == 't' OR $val['0'] == 'ms' OR ($val['0'] == 'c' && sizeof($val['1']) > 1)))
- {
- $r .= $DSP->td($style, '50%', '', '', 'top');
- }
- else
- {
- $r .= $DSP->td($style, '50%', '');
- }
-
- /** -----------------------------
- /** Preference heading
- /** -----------------------------*/
-
- $r .= $DSP->div('defaultBold');
-
- $label = ( ! is_array($val)) ? $key : '';
-
- // Fix for array form variables like cat_id[]
- // Such names to do no work well with the
- // translation utility sadly.
-
- if (($LANG->line($key) === false || $LANG->line($key) == '') && strpos($key, '[]') !== false)
- {
- if ($LANG->line(str_replace('[]','',$key)) === FALSE)
- {
- $r .= '<label for="'.$key.'">'.ucwords(str_replace('_', ' ', $key))."</label>";
- }
- else
- {
- $r .= $LANG->line(str_replace('[]','',$key), $label);
- }
- }
- else
- {
- $r .= $LANG->line($key, $label);
- }
-
- $r .= $DSP->div_c();
-
-
- /** -----------------------------
- /** Preference sub-heading
- /** -----------------------------*/
-
- $r .= $DSP->td_c();
-
- /** -----------------------------
- /** Preference value
- /** -----------------------------*/
-
- $r .= $DSP->td($style, '50%', '');
- }
-
- if (is_array($val))
- {
- /** -----------------------------
- /** Drop-down menus
- /** -----------------------------*/
-
- if ($val['0'] == 's' || $val['0'] == 'ms')
- {
- $multi = ($val['0'] == 'ms') ? "class='multiselect' size='8' multiple='multiple'" : "class='select'";
- $nkey = ($val['0'] == 'ms') ? $key.'[]' : $key;
-
- if (isset($val['2']))
- {
- $r .= "<select name='{$nkey}' $multi ".$val['2'].">\n";
- }
- else
- {
- $r .= "<select name='{$nkey}' $multi >\n";
- }
-
- $data[$key] = ($data[$key] == '') ? $val['2'] : $data[$key];
-
- foreach ($val['1'] as $k => $v)
- {
- if ($val['0'] == 's' || ! is_array($data[$key]))
- {
- $selected = ($k == $data[$key]) ? 1 : '';
- }
- elseif(is_array($data[$key]))
- {
- $selected = (in_array($k,$data[$key])) ? 1 : '';
- }
-
- $name = ($LANG->line($v) == false OR $key == 'weblog_id') ? $v : $LANG->line($v);
-
- $r .= $DSP->input_select_option($k, $name, $selected);
- }
-
- $r .= $DSP->input_select_footer();
-
- }
- elseif ($val['0'] == 'r')
- {
- /** -----------------------------
- /** Radio buttons
- /** -----------------------------*/
-
- if ( ! isset($val['2']))
- {
- $val['2'] = '';
- }
-
- $data[$key] = ($data[$key] == '') ? $val['2'] : $data[$key];
-
- foreach ($val['1'] as $k => $v)
- {
- $selected = ($k == $data[$key]) ? 1 : '';
-
- $r .= $LANG->line($v).$DSP->nbs();
- $r .= $DSP->input_radio($key, $k, $selected, ( ! isset($val['3'])) ? '' : $val['3']).$DSP->nbs(3);
- }
- }
- elseif ($val['0'] == 'c')
- {
- /** -----------------------------
- /** Checkboxes
- /** -----------------------------*/
-
- if ( ! isset($val['2']))
- {
- $val['2'] = '';
- }
-
- $data[$key] = ($data[$key] == '') ? $val['2'] : $data[$key];
-
- foreach ($val['1'] as $k => $v)
- {
- $selected = ($k == $data[$key]) ? 1 : '';
-
- if (sizeof($val['1']) == 1)
- {
- $r .= $DSP->input_checkbox($key, $k, $selected);
- }
- else
- {
- $r .= $DSP->qdiv('publishPad', $DSP->input_checkbox($key, $k, $selected).' '.$LANG->line($v));
- }
- }
- }
- elseif ($val['0'] == 't')
- {
- /** -----------------------------
- /** Textarea fields
- /** -----------------------------*/
-
- // The "kill_pipes" index instructs us to
- // turn pipes into newlines
-
- $data[$key] = ($data[$key] == '') ? $val['1'] : $data[$key];
-
- if (isset($val['2']['kill_pipes']) AND $val['2']['kill_pipes'] === TRUE)
- {
- $text = '';
-
- foreach (explode('|', $data[$key]) as $exp)
- {
- $text .= $exp.NL;
- }
- }
- else
- {
- $text = $data[$key];
- }
-
- $rows = (isset($val['2']['rows'])) ? $val['2']['rows'] : '15';
-
- $r .= $DSP->input_textarea($key, $text, $rows);
-
- }
- elseif ($val['0'] == 'f' || $val['0'] == 'sf')
- {
- switch($val['1'])
- {
- case 'new_table' :
-
- $i = 0;
- // Close current tables
- $r .= $DSP->table_c();
-
- $r .= $DSP->div_c();
-
- // Open new table
- $r .= $DSP->div('', '', $key);
-
- $r .= $DSP->table('tableBorder', '0', '', '100%');
- $r .= $DSP->tr();
- $r .= $DSP->td('tableHeadingAlt', '', '2');
- $r .= $LANG->line($val['2']);
- $r .= $DSP->td_c();
- $r .= $DSP->tr_c();
-
- break;
- }
- }
- }
- else
- {
- /** -----------------------------
- /** Text input fields
- /** -----------------------------*/
-
- $r .= $DSP->input_text($key, $data[$key], '20', '120', 'input', '100%');
- }
-
- $r .= $DSP->td_c();
- $r .= $DSP->tr_c();
- }
-
- $r .= $DSP->table_c();
- $r .= $DSP->div_c();
- $r .= $DSP->qdiv('itemWrapperTop', $DSP->input_submit($LANG->line('submit'), 'submit'));
-
- return $r;
- }
- /* END */
-
-
- /** -------------------------------------------
- /** Plugin Manager
- /** -------------------------------------------*/
- // Helper function used to sort plugins
- function _plugin_title_sorter($a, $b)
- {
- return strnatcasecmp($a['title'], $b['title']);
- }
- function plugin_manager($message = '')
- {
- global $DSP, $IN, $PREFS, $LANG, $FNS;
-
- if ( ! @include_once(PATH_LIB.'pclzip.lib.php'))
- {
- return $DSP->no_access_message('PclZip Library does not appear to be installed. It is required.');
- }
-
- $is_writable = (is_writable(PATH_PI) && $PREFS->ini('demo_date') == FALSE) ? TRUE : FALSE;
-
- $plugins = array();
- $info = array();
-
- if ($fp = @opendir(PATH_PI))
- {
- while (false !== ($file = readdir($fp)))
- {
- if ( preg_match("/^pi\.[a-z\_0-9]+?".preg_quote(EXT, '/')."$/", $file))
- {
- if ( ! @include_once(PATH_PI.$file))
- {
- continue;
- }
-
- $name = str_replace('pi.', '', $file);
- $name = str_replace(EXT, '', $name);
-
- $plugins[] = $name;
-
- $info[$name] = $plugin_info;
- }
- }
-
- closedir($fp);
- }
- if ( in_array('magpie', $plugins) && $PREFS->ini('demo_date') == FALSE)
- $r = '<div style="float: left; width: 69%; margin-right: 2%;">';
- else
- $r = '<div style="float: left; width: 100%;">';
-
- if ($is_writable)
- {
- $r .= $DSP->form_open(
- array(
- 'action' => 'C=admin'.AMP.'M=utilities'.AMP.'P=plugin_remove_conf',
- 'name' => 'target',
- 'id' => 'target'
- )
- );
- $r .= $DSP->toggle();
- }
-
- if ($message != '')
- {
- $r .= $DSP->qdiv('itemWrapper', $DSP->qdiv('highlight', $message));
- }
-
- $r .= $DSP->table('tableBorder', '0', '10', '100%').
- $DSP->tr().
- $DSP->td('tableHeading', ($is_writable) ? '97%' : '100%', '').
- count($plugins).' '.$LANG->line('plugin_installed').
- $DSP->td_c();
-
- if ($is_writable)
- {
- $r .= $DSP->td('tableHeading', '3%', '').
- $DSP->input_checkbox('toggleflag', '', '', "onclick=\"toggle(this);\"").
- $DSP->td_c();
- }
-
- $r .= $DSP->tr_c();
-
- if (count($plugins) == 0)
- {
- $r .= $DSP->tr().
- $DSP->td('tableCellTwo', '', '2').
- '<b>'.$LANG->line('no_plugins_exist').'</b>'.
- $DSP->td_c().
- $DSP->tr_c();
- }
- $i = 0;
-
- if (count($plugins) > 0)
- {
- foreach ($plugins as $plugin)
- {
- $version = '(v.'.trim($info[$plugin]['pi_version']).')';
- $update = '';
-
- $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo';
-
- $name = $DSP->qspan('defaultBold', $DSP->anchor(BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=plugin_info'.AMP.'name='.$plugin, $info[$plugin]['pi_name']));
- $description = $info[$plugin]['pi_description'];
-
- $r .= $DSP->tr();
-
- $r .= $DSP->table_qcell($style, $name.' '.$version.' '.$update.$DSP->br().$description, ($is_writable) ? '85%' : '100%');
-
- if ($is_writable)
- {
- $r .= $DSP->table_qcell($style, $DSP->input_checkbox('toggle[]', $plugin), '15%');
- }
-
- $r .= $DSP->tr_c();
- }
- }
-
- $r .= $DSP->table_c();
-
- if ($is_writable)
- {
- $r .= $DSP->div('itemWrapper', 'right')
- .$DSP->input_submit($LANG->line('plugin_remove'))
- .$DSP->div_c()
- .$DSP->form_close();
- }
-
- $r .= $DSP->div_c();
-
- /** -------------------------------------------
- /** Latest Plugin Table
- /** -------------------------------------------*/
-
- // Do we have the Magpie plugin so we can parse the EE plugin RSS feed?
- if (in_array('magpie', $plugins) && $PREFS->ini('demo_date') == FALSE)
- {
- $request = 'http://expressionengine.com/feeds/pluginlist/';
-
- $target = parse_url($request);
-
- $fp = @fsockopen($target['host'], 80, $errno, $errstr, 15);
-
- $code = '';
-
- if (is_resource($fp))
- {
- fputs ($fp,"GET " . $request . " HTTP/1.0\r\n" );
- fputs ($fp,"Host: " . $target['host'] . "\r\n" );
- fputs ($fp,"User-Agent: EE/EllisLab PHP/" . phpversion() . "\r\n\r\n");
-
- $getting_headers = true;
-
- while ( ! feof($fp))
- {
- $line = fgets($fp, 4096);
-
- if ($getting_headers == false)
- {
- $code .= $line;
- }
- elseif (trim($line) == '')
- {
- $getting_headers = false;
- }
- }
-
- @fclose($fp);
- }
-
- $plugins = new MagpieRSS($code);
-
- $i = 0;
-
- if (count($plugins->items) > 0)
- {
- // Example pagination: &perpage=10&page=10&sortby=alpha
- $paginate = '';
- $extra = ''; // Will hold sort method
- $total_rows = count($plugins->items);
- $perpage = ( ! $IN->GBL('perpage')) ? 10 : $IN->GBL('perpage');
- $page = ( ! $IN->GBL('page')) ? 0 : $IN->GBL('page');
- $sortby = ( ! $IN->GBL('sortby')) ? '' : $IN->GBL('sortby');
- $base = BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=plugin_manager';
-
- if ($sortby == 'alpha')
- {
- usort($plugins->items, array('Utilities', '_plugin_title_sorter'));
- $extra = AMP.'sortby=alpha';
- $link = $DSP->anchor($base, $LANG->line('plugin_by_date'));
- $title = $LANG->line('plugins').$DSP->qspan('defaultSmall', $LANG->line('plugin_by_letter').' : '.$link);
- }
- else
- {
- $link = $DSP->anchor($base.AMP.'sortby=alpha', $LANG->line('plugin_by_letter'));
- $title = $LANG->line('plugins').$DSP->qspan('defaultSmall', $LANG->line('plugin_by_date').' : '.$link);
- }
- $ten_plugins = array_slice($plugins->items, $page, $perpage-1);
-
- // Latest Plugins Table
- $r .= '<div style="float: left; width: 29%; clear: right;">';
-
- $r .= $DSP->table('tableBorder', '0', '10', '100%').
- $DSP->tr().
- $DSP->td('tableHeadingAlt', '', '').
- $title.
- $DSP->td_c().
- $DSP->tr_c();
-
- $curl_installed = ( ! extension_loaded('curl') || ! function_exists('curl_init')) ? FALSE : TRUE;
-
- $qm = ($PREFS->ini('force_query_string') == 'y') ? '' : '?';
-
- foreach ($ten_plugins as $item)
- {
- $attr = explode('|', $item['dc']['subject']);
- $dl = $attr[0];
- $version = '(v.'.$attr[1].')';
- $require = ( ! $attr[2] ) ? '' : $DSP->br().$DSP->qspan('highlight', $LANG->line('plugin_requires').': '.$attr[2]);
-
- $name = $DSP->qspan('defaultBold', $DSP->anchor($FNS->fetch_site_index().$qm.'URL='.$item['link'], $item['title']));
- $description = $FNS->word_limiter($item['description'], '20');
-
- $install = ( ! class_exists('PclZip') || ! $is_writable || ! $curl_installed) ? '' : $DSP->anchor(BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=plugin_install'.AMP.'file='.$dl, '<span style=\'color:#009933;\'>'.$LANG->line('plugin_install').'</span>');
-
- $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo';
-
- $r .= $DSP->tr();
-
- $r .= $DSP->table_qcell($style, $name.' '.$version.$DSP->nbs().$require.$DSP->qdiv('itemWrapper', $description).$install, '60%');
- $r .= $DSP->tr_c();
- }
-
- $r .= $DSP->table_c();
-
- if ($total_rows > $perpage)
- {
- $paginate = $DSP->pager( BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=plugin_manager'.$extra.AMP.'perpage='.$perpage,
- $total_rows,
- $perpage,
- $page,
- 'page'
- );
- }
-
- $r .= $DSP->qdiv('itemWrapper', $paginate.BR.BR);
- $r .= $DSP->div_c();
- }
-
- }
-
- $DSP->title = $LANG->line('plugin_manager');
- $DSP->crumb = $DSP->anchor(BASE.AMP.'C=admin'.AMP.'area=utilities', $LANG->line('utilities')).
- $DSP->crumb_item($LANG->line('plugin_manager'));
- $DSP->body = $r;
- }
- /* END */
- /** -------------------------------------------
- /** Plugin Info
- /** -------------------------------------------*/
- function plugin_info()
- {
- global $IN, $DSP, $LANG, $FNS, $PREFS;
-
- // Basic security check
- if ( ! preg_match("/^[a-z0-9][\w.-]*$/i",$IN->GBL('name'))) return false;
-
- $name = $IN->GBL('name');
-
- if ( ! @include(PATH_PI.'pi.'.$name.EXT))
- {
- return $DSP->error_message('Unable to load the following plugin: '.$name.EXT);
- }
-
- $qm = ($PREFS->ini('force_query_string') == 'y') ? '' : '?';
-
- $DSP->title = ucwords(str_replace("_", " ", $name));
- $DSP->crumb = $DSP->anchor(BASE.AMP.'C=admin'.AMP.'area=utilities', $LANG->line('utilities')).
- $DSP->crumb_item($DSP->anchor(BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=plugin_manager', $LANG->line('plugin_manager'))).
- $DSP->crumb_item(ucwords(str_replace("_", " ", $name)));
- $i = 0;
-
- $r = $DSP->table('tableBorder', '0', '10', '100%').
- $DSP->tr().
- $DSP->td('tableHeading', '', '2').
- $LANG->line('plugin_information').
- $DSP->td_c().
- $DSP->tr_c();
-
- if ( ! isset($plugin_info) OR ! is_array($plugin_info))
- {
- $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo';
-
- $name = ucwords(str_replace("_", " ", $name));
- $r .= $DSP->tr();
- $r .= $DSP->table_qcell($style, $DSP->qspan('defaultBold', $LANG->line('pi_name')), '30%');
- $r .= $DSP->table_qcell($style, $DSP->qspan('defaultBold', $name), '70%');
- $r .= $DSP->tr_c();
-
- $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo';
- $r .= $DSP->tr();
- $r .= $DSP->td($style, '', '2').$DSP->qspan('default', $LANG->line('no_additional_info'));
- $r .= $DSP->td_c();
- $r .= $DSP->tr_c();
-
- }
- else
- {
- foreach ($plugin_info as $key => $val)
- {
- $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo';
-
- $item = ($LANG->line($key) != FALSE) ? $LANG->line($key) : ucwords(str_replace("_", " ", $key));
-
- if ($key == 'pi_author_url')
- {
- if (substr($val, 0, 4) != "http")
- $val = "http://".$val;
-
- $val = $DSP->anchor($FNS->fetch_site_index().$qm.'URL='.$val, $val, '', 1);
- }
-
- if ($key == 'pi_usage')
- $val = nl2br(htmlspecialchars($val));
-
- $r .= $DSP->tr();
- $r .= $DSP->table_qcell($style, $DSP->qspan('defaultBold', $item), '30%', 'top');
- $r .= $DSP->table_qcell($style, $DSP->qspan('default', $val), '70%');
- $r .= $DSP->tr_c();
- }
- }
- $r .= $DSP->table_c();
-
- $DSP->body = $r;
- }
- /* END */
-
- /** -------------------------------------------
- /** Plugin Extraction from ZIP file
- /** -------------------------------------------*/
-
- function plugin_install()
- {
- global $IN, $DSP, $LANG, $PREFS;
-
- if ($PREFS->ini('demo_date') != FALSE)
- {
- return $DSP->no_access_message();
- }
-
- if ( ! @include_once(PATH_LIB.'pclzip.lib.php'))
- {
- return $DSP->error_message($LANG->line('plugin_zlib_missing'));
- }
-
- if ( ! is_writable(PATH_PI))
- {
- return $DSP->error_message($LANG->line('plugin_folder_not_writable'));
- }
-
- if ( ! extension_loaded('curl') || ! function_exists('curl_init'))
- {
- return $DSP->error_message($LANG->line('plugin_no_curl_support'));
- }
-
- $file = $IN->GBL('file');
-
- $local_name = basename($file);
- $local_file = PATH_PI.$local_name;
-
- // Get the remote file
- $c = curl_init($file);
- curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
-
- // prevent a PHP warning on certain servers
- if (! ini_get('safe_mode') && ! ini_get('open_basedir'))
- {
- curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
- }
-
- $code = curl_exec($c);
- curl_close($c);
-
- $file_info = pathinfo($local_file);
-
- if ($file_info['extension'] == 'txt' ) // Get rid of any notes/headers in the TXT file
- {
- $code = strstr($code, '<?php');
- }
-
- if ( ! $fp = fopen($local_file, 'wb'))
- {
- return $DSP->error_message($LANG->line('plugin_problem_creating_file'));
- }
-
- flock($fp, LOCK_EX);
- fwrite($fp, $code);
- flock($fp, LOCK_UN);
- fclose($fp);
- @chmod($local_file, 0777);
-
- // Check file information so we know what to do with it
-
- if ($file_info['extension'] == 'txt' ) // We've got a TXT file!
- {
- $new_file = basename($local_file, '.txt');
- if ( ! rename($local_file, PATH_PI.$new_file))
- {
- $message = $LANG->line('plugin_install_other');
- }
- else
- {
- @chmod($new_file, 0777);
- $message = $LANG->line('plugin_install_success');
- }
- }
- else if ($file_info['extension'] == 'zip' ) // We've got a ZIP file!
- {
- // Unzip and install plugin
- if (class_exists('PclZip'))
- {
- $zip = new PclZip($local_file);
- chdir(PATH_PI);
- $ok = @$zip->extract('');
-
- if ($ok)
- {
- $message = $LANG->line('plugin_install_success');
- unlink($local_file);
- }
- else
- {
- $message = $LANG->line('plugin_error_uncompress');
- }
-
- chdir(PATH);
- }
- else
- {
- $message = $LANG->line('plugin_error_no_zlib');
- }
- }
- else
- {
- $message = $LANG->line('plugin_install_other');
- }
-
- return Utilities::plugin_manager($message);
- }
- /* END */
-
-
- /** -------------------------------------------
- /** Plugin Removal Confirmation
- /** -------------------------------------------*/
-
- function plugin_remove_confirm()
- {
- global $IN, $DSP, $LANG, $PREFS;
- if ($PREFS->ini('demo_date') != FALSE)
- {
- return $DSP->no_access_message();
- }
-
- $r = $DSP->form_open(array('action' => 'C=admin'.AMP.'M=utilities'.AMP.'P=plugin_remove'));
-
- $i = 0;
-
- foreach ($_POST as $key => $val)
- {
- if (strstr($key, 'toggle') AND ! is_array($val))
- {
- $r .= $DSP->input_hidden('deleted[]', $val);
-
- $i++;
- }
- }
-
- $message = ($i == 1) ? 'plugin_single_confirm' : 'plugin_multiple_confirm';
-
- $r .= $DSP->qdiv('alertHeading', $LANG->line('plugin_delete_confirm'))
- .$DSP->div('box')
- .$DSP->qdiv('itemWrapper', '<b>'.$LANG->line($message).'</b>');
-
- $r .= $DSP->qdiv('itemWrapper', $DSP->qdiv('alert', $LANG->line('action_can_not_be_undone')))
- .$DSP->qdiv('itemWrapper', BR.$DSP->input_submit($LANG->line('deinstall')).BR)
- .$DSP->div_c()
- .$DSP->form_close();
-
-
-
- $DSP->title = $LANG->line('plugin_delete_confirm');
- $DSP->crumb = $DSP->anchor(BASE.AMP.'C=admin'.AMP.'area=utilities', $LANG->line('utilities')).
- $DSP->crumb_item($DSP->anchor(BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=plugin_manager', $LANG->line('plugin_manager'))).
- $DSP->crumb_item($LANG->line('plugin_delete_confirm'));
- $DSP->body = $r;
- }
-
- /** -------------------------------------------
- /** Plugin Removal
- /** -------------------------------------------*/
-
- function plugin_remove()
- {
- global $IN, $DSP, $LANG, $PREFS;
-
- if ($PREFS->ini('demo_date') != FALSE)
- {
- return $DSP->no_access_message();
- }
-
- $deleted = $IN->GBL('deleted');
- $message = '';
- $style = '';
- $i = 0;
-
- $DSP->title = $LANG->line('plugin_removal');
- $DSP->crumb = $DSP->anchor(BASE.AMP.'C=admin'.AMP.'area=utilities', $LANG->line('utilities')).
- $DSP->crumb_item($DSP->anchor(BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=plugin_manager', $LANG->line('plugin_manager'))).
- $DSP->crumb_item($LANG->line('plugin_removal'));
-
- $r = $DSP->table('tableBorder', '0', '10', '100%').
- $DSP->tr().
- $DSP->td('tableHeading', '', '').
- $LANG->line('plugin_removal_status').
- $DSP->td_c().
- $DSP->tr_c();
-
- foreach ( $deleted as $name )
- {
- $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo';
-
- if (unlink(PATH_PI.'pi.'.$name.'.php'))
- $message = $LANG->line('plugin_removal_success').' '.ucwords(str_replace("_", " ", $name));
- else
- $message = $LANG->line('plugin_removal_error').' '.ucwords(str_replace("_", " ", $name)).'.';
-
- $r .= $DSP->tr();
- $r .= $DSP->table_qcell($style, $DSP->qdiv('itemWrapper', $DSP->qdiv('highlight', $message)), '100%');
- $r .= $DSP->tr_c();
- }
-
- $r .= $DSP->table_c();
-
- $DSP->body = $r;
- }
- /* END */
-
-
- /** -------------------------------------------
- /** Disable Extensions Confirmation
- /** -------------------------------------------*/
-
- function toggle_extension_confirm()
- {
- global $IN, $DSP, $LANG;
-
- // Basic security check
- if ($IN->GBL('name') !== FALSE && ! preg_match("/^[a-z0-9][\w.-]*$/i",$IN->GBL('name'))) return false;
- $r = $DSP->form_open(array('action' => 'C=admin'.AMP.'M=utilities'.AMP.'P=toggle_extension'));
-
- if ($IN->GBL('which') == 'enable')
- {
- $message = ($IN->GBL('name') !== FALSE) ? 'enable_extension_conf' : 'enable_extensions_conf';
-
- $r .= $DSP->input_hidden('which', 'enable');
- }
- else
- {
- $message = ($IN->GBL('name') !== FALSE) ? 'disable_extension_conf' : 'disable_extensions_conf';
-
- $r .= $DSP->input_hidden('which', 'disable');
- }
-
- $r .= $DSP->input_hidden('name', ($IN->GBL('name') !== FALSE) ? $IN->GBL('name') : '');
-
- $r .= $DSP->qdiv('alertHeading', $LANG->line($message))
- .$DSP->div('box')
- .$DSP->qdiv('itemWrapper', '<b>'.$LANG->line('toggle_extension_confirmation').'</b>');
-
- $r .= $DSP->qdiv('itemWrapper', BR.$DSP->input_submit($LANG->line('submit')).BR)
- .$DSP->div_c()
- .$DSP->form_close();
-
-
-
- $DSP->title = $LANG->line('extensions_manager');
- $DSP->crumb = $DSP->anchor(BASE.AMP.'C=admin'.AMP.'area=utilities', $LANG->line('utilities')).
- $DSP->crumb_item($DSP->anchor(BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=extensions_manager', $LANG->line('extensions_manager'))).
- $DSP->crumb_item($LANG->line($message));
- $DSP->body = $r;
- }
-
- /** -------------------------------------------
- /** Toggle Extension/s
- /** -------------------------------------------*/
-
- function toggle_extension()
- {
- global $IN, $FNS, $DB, $PREFS;
- $message = '';
-
- if ($IN->GBL('name') !== FALSE && $IN->GBL('name') != '')
- {
- // Basic security check
- if ( ! preg_match("/^[a-z0-9][\w.-]*$/i",$IN->GBL('name'))) return false;
-
- // Disable/Enable Single Extension
-
- if ($IN->GBL('which') == 'enable')
- {
- // Check if the Extension is already installed and just disabled
- // If so we just turn it back on. If not, we have to activate
- // the extension. We have the enabled field so that if someone
- // disables a parameter we can still have the extension's settings
- // in the database and not lost to the ether.
-
- $query = $DB->query("SELECT COUNT(*) AS count FROM exp_extensions WHERE class = '".$DB->escape_str(ucfirst($IN->GBL('name')))."'");
-
- if ($query->row['count'] == 0)
- {
- if ( ! class_exists(ucfirst($IN->GBL('name'))))
- {
- include(PATH_EXT.'ext.'.$IN->GBL('name').EXT);
- }
-
- if (class_exists(ucfirst($IN->GBL('name'))))
- {
- $class_name = ucfirst($IN->GBL('name'));
-
- $OBJ = new $class_name();
-
- if (method_exists($OBJ, 'activate_extension') === TRUE)
- {
- $activate = $OBJ->activate_extension();
- }
- }
- }
- else
- {
- $DB->query("UPDATE exp_extensions SET enabled = 'y' WHERE class = '".$DB->escape_str(ucfirst($IN->GBL('name')))."'");
- }
- }
- else
- {
- $DB->query("UPDATE exp_extensions SET enabled = 'n' WHERE class = '".$DB->escape_str(ucfirst($IN->GBL('name')))."'");
-
- if ( ! class_exists(ucfirst($IN->GBL('name'))))
- {
- include(PATH_EXT.'ext.'.$IN->GBL('name').EXT);
- }
-
- if (class_exists(ucfirst($IN->GBL('name'))))
- {
- $class_name = ucfirst($IN->GBL('name'));
-
- $OBJ = new $class_name();
-
- if (method_exists($OBJ, 'disable_extension') === TRUE)
- {
- $disable = $OBJ->disable_extension();
- }
- }
- }
- }
- else
- {
- // Disable/Enable All Extensions
-
- if ($IN->GBL('which') == 'enable')
- {
- Admin::update_config_file(array('allow_extensions' => "y"));
- }
- else
- {
- Admin::update_config_file(array('allow_extensions' => "n"));
- }
- }
-
- $FNS->redirect(BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=extensions_manager');
- exit;
- }
- /* END */
-
- /** -------------------------------------------
- /** SQL Manager
- /** -------------------------------------------*/
- function sql_info()
- {
- global $DB, $DSP, $PREFS, $LOC, $LANG;
-
- $i = 0;
- $style_one = 'tableCellOne';
- $style_two = 'tableCellTwo';
-
-
- $query = $DB->query("SELECT version() AS ver");
-
- $DSP->title = $LANG->line('utilities');
- $DSP->crumb = $DSP->anchor(BASE.AMP.'C=admin'.AMP.'area=utilities', $LANG->line('utilities')).
- $DSP->crumb_item($LANG->line('sql_manager'));
-
- $DSP->body = $DSP->qdiv('tableHeading', $LANG->line('sql_manager'));
-
- /** -----------------------------
- /** Table Header
- /** -----------------------------*/
- $DSP->body .= $DSP->table('tableBorder', '0', '0', '100%').
- $DSP->tr().
- $DSP->table_qcell('tableHeadingAlt',
- array(
- $LANG->line('sql_info'),
- $LANG->line('value')
- )
- ).
- $DSP->tr_c();
-
-
- /** -------------------------------------------
- /** Database Type
- /** -------------------------------------------*/
-
- $DSP->body .= $DSP->table_qrow( ($i++ % 2) ? $style_one : $style_two,
- array(
- $DSP->qspan('defaultBold', $LANG->line('database_type')),
- $PREFS->ini('db_type')
- )
- );
-
-
-
- /** -------------------------------------------
- /** SQL Version
- /** -------------------------------------------*/
-
- $query = $DB->query("SELECT version() AS ver");
-
- $DSP->body .= $DSP->table_qrow( ($i++ % 2) ? $style_one : $style_two,
- array(
- $DSP->qspan('defaultBold', $LANG->line('sql_version')),
- $query->row['ver']
- )
- );
-
-
- $DB->fetch_fields = TRUE;
- $query = $DB->query("SHOW TABLE STATUS FROM `".$PREFS->ini('db_name')."`");
- $totsize = 0;
- $records = 0;
-
- $prelen = strlen($DB->prefix);
-
- foreach ($query->result as $val)
- {
- if (strncmp($val['Name'], $DB->prefix, $prelen) != 0)
- {
- continue;
- }
-
- $totsize += ($val['Data_length'] + $val['Index_length']);
- $records += $val['Rows'];
- }
-
- /** -------------------------------------------
- /** Database Records
- /** -------------------------------------------*/
-
- $DSP->body .= $DSP->table_qrow( ($i++ % 2) ? $style_one : $style_two,
- array(
- $DSP->qspan('defaultBold', $LANG->line('records')),
- $records
- )
- );
-
- /** -------------------------------------------
- /** Database Size
- /** -------------------------------------------*/
- $size = Utilities::byte_format($totsize);
-
- $DSP->body .= $DSP->table_qrow( ($i++ % 2) ? $style_one : $style_two,
- array(
- $DSP->qspan('defaultBold', $LANG->line('database_size')),
- $size['0'].' '.$size['1']
- )
- );
-
- /** -------------------------------------------
- /** Database Uptime
- /** -------------------------------------------*/
-
- $query = $DB->query("SHOW STATUS");
-
- $uptime = '';
- $queries = '';
-
- foreach ($query->result as $key => $val)
- {
- foreach ($val as $v)
- {
- if (preg_match("#^uptime#i", $v))
- {
- $uptime = $key;
- }
-
- if (preg_match("#^questions#i", $v))
- {
- $queries = $key;
- }
- }
- }
-
-
- $DSP->body .= $DSP->table_qrow( ($i++ % 2) ? $style_one : $style_two,
- array(
- $DSP->qspan('defaultBold', $LANG->line('database_uptime')),
- $LOC->format_timespan($query->result[$uptime]['Value'])
- )
- );
-
- /** -------------------------------------------
- /** Total Server Queries
- /** -------------------------------------------*/
-
- /*
- $DSP->body .= $DSP->table_qrow( ($i++ % 2) ? $style_one : $style_two,
- array(
- $DSP->qspan('defaultBold', $LANG->line('total_queries')),
- number_format($query->result[$queries]['Value'])
- )
- );
- */
-
-
- $DSP->body .= $DSP->table_c();
-
- /** -------------------------------------------
- /** SQL Utilities
- /** -------------------------------------------*/
-
- $DSP->body .= $DSP->table('tableBorder', '0', '0', '100%').
- $DSP->tr().
- $DSP->table_qcell('tableHeading',
- array(
- $LANG->line('sql_utilities'),
- )
- ).
- $DSP->tr_c();
-
- $DSP->body .= $DSP->table_qrow( ($i++ % 2) ? $style_one : $style_two,
- array(
- $DSP->qspan('defaultBold', $DSP->anchor(BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=view_database', $LANG->line('view_database')))
- )
- );
-
- /*
- $DSP->body .= $DSP->table_qrow( ($i++ % 2) ? $style_one : $style_two,
- array(
- $DSP->qspan('defaultBold', $DSP->anchor(BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=sql_backup', $LANG->line('sql_backup')))
- )
- );
- */
- $DSP->body .= $DSP->table_qrow( ($i++ % 2) ? $style_one : $style_two,
- array(
- $DSP->qspan('defaultBold', $DSP->anchor(BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=sql_query', $LANG->line('sql_query')))
- )
- );
- $DSP->body .= $DSP->table_qrow( ($i++ % 2) ? $style_one : $style_two,
- array(
- $DSP->qspan('defaultBold', $DSP->anchor(BASE.AMP.'C=admin'.AMP.'M=utilities'.AMP.'P=sql_status', $LANG->line('sql_status')))
- )
- );
- $DSP->body .= $DSP->table_qrow( ($…
Large files files are truncated, but you can click here to view the full file