コード例 #1
0
ファイル: NodeFunction.php プロジェクト: pjiahao/phpmyadmin
 /**
  * Initialises the class
  *
  * @param string $name     An identifier for the new node
  * @param int    $type     Type of node, may be one of CONTAINER or OBJECT
  * @param bool   $is_group Whether this object has been created
  *                         while grouping nodes
  */
 public function __construct($name, $type = Node::OBJECT, $is_group = false)
 {
     parent::__construct($name, $type, $is_group);
     $this->icon = PMA\libraries\Util::getImage('b_routines.png', __('Function'));
     $this->links = array('text' => 'db_routines.php?server=' . $GLOBALS['server'] . '&db=%2$s&item_name=%1$s&item_type=FUNCTION' . '&edit_item=1&token=' . $_SESSION[' PMA_token '], 'icon' => 'db_routines.php?server=' . $GLOBALS['server'] . '&db=%2$s&item_name=%1$s&item_type=FUNCTION' . '&execute_dialog=1&token=' . $_SESSION[' PMA_token ']);
     $this->classes = 'function';
 }
コード例 #2
0
 /**
  * Initialises the class
  *
  * @param string $name     An identifier for the new node
  * @param int    $type     Type of node, may be one of CONTAINER or OBJECT
  * @param bool   $is_group Whether this object has been created
  *                         while grouping nodes
  */
 public function __construct($name, $type = Node::OBJECT, $is_group = false)
 {
     parent::__construct($name, $type, $is_group);
     $this->icon = PMA\libraries\Util::getImage('b_triggers.png');
     $this->links = array('text' => 'db_triggers.php?server=' . $GLOBALS['server'] . '&db=%3$s&item_name=%1$s&edit_item=1' . '&token=' . $_SESSION[' PMA_token '], 'icon' => 'db_triggers.php?server=' . $GLOBALS['server'] . '&db=%3$s&item_name=%1$s&export_item=1' . '&token=' . $_SESSION[' PMA_token ']);
     $this->classes = 'trigger';
 }
コード例 #3
0
 /**
  * Prepares environment for the test.
  *
  * @return void
  */
 public function setUp()
 {
     //$_REQUEST
     $_REQUEST['log'] = "index1";
     $_REQUEST['pos'] = 3;
     //$GLOBALS
     $GLOBALS['cfg']['MaxRows'] = 10;
     $GLOBALS['server'] = 1;
     $GLOBALS['cfg']['ServerDefault'] = "server";
     $GLOBALS['cfg']['RememberSorting'] = true;
     $GLOBALS['cfg']['SQP'] = array();
     $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] = 1000;
     $GLOBALS['cfg']['ShowSQL'] = true;
     $GLOBALS['cfg']['TableNavigationLinksMode'] = 'icons';
     $GLOBALS['cfg']['LimitChars'] = 100;
     $GLOBALS['table'] = "table";
     $GLOBALS['pmaThemeImage'] = 'image';
     //$_SESSION
     $_SESSION['PMA_Theme'] = Theme::load('./themes/pmahomme');
     $_SESSION['PMA_Theme'] = new Theme();
     Util::cacheSet('profiling_supported', true);
     $binary_log_file_names = array();
     $binary_log_file_names[] = array("Log_name" => "index1", "File_size" => 100);
     $binary_log_file_names[] = array("Log_name" => "index2", "File_size" => 200);
     //Mock DBI
     $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock();
     $dbi->expects($this->once())->method('fetchResult')->will($this->returnValue($binary_log_file_names));
     $container = Container::getDefaultContainer();
     $container->set('dbi', $dbi);
 }
コード例 #4
0
ファイル: NodeIndex.php プロジェクト: pjiahao/phpmyadmin
 /**
  * Initialises the class
  *
  * @param string $name     An identifier for the new node
  * @param int    $type     Type of node, may be one of CONTAINER or OBJECT
  * @param bool   $is_group Whether this object has been created
  *                         while grouping nodes
  */
 public function __construct($name, $type = Node::OBJECT, $is_group = false)
 {
     parent::__construct($name, $type, $is_group);
     $this->icon = PMA\libraries\Util::getImage('b_index.png', __('Index'));
     $this->links = array('text' => 'tbl_indexes.php?server=' . $GLOBALS['server'] . '&db=%3$s&table=%2$s&index=%1$s' . '&token=' . $_SESSION[' PMA_token '], 'icon' => 'tbl_indexes.php?server=' . $GLOBALS['server'] . '&db=%3$s&table=%2$s&index=%1$s' . '&token=' . $_SESSION[' PMA_token ']);
     $this->classes = 'index';
 }
コード例 #5
0
ファイル: NodeEvent.php プロジェクト: phpmyadmin/phpmyadmin
 /**
  * Initialises the class
  *
  * @param string $name     An identifier for the new node
  * @param int    $type     Type of node, may be one of CONTAINER or OBJECT
  * @param bool   $is_group Whether this object has been created
  *                         while grouping nodes
  */
 public function __construct($name, $type = Node::OBJECT, $is_group = false)
 {
     parent::__construct($name, $type, $is_group);
     $this->icon = PMA\libraries\Util::getImage('b_events.png');
     $this->links = array('text' => 'db_events.php?server=' . $GLOBALS['server'] . '&db=%2$s&item_name=%1$s&edit_item=1', 'icon' => 'db_events.php?server=' . $GLOBALS['server'] . '&db=%2$s&item_name=%1$s&export_item=1');
     $this->classes = 'event';
 }
コード例 #6
0
ファイル: GISFactory.php プロジェクト: ryanfmurphy/phpmyadmin
 /**
  * Returns the singleton instance of geometric class of the given type.
  *
  * @param string $type type of the geometric object
  *
  * @return GISGeometry the singleton instance of geometric class
  *                          of the given type
  *
  * @access public
  * @static
  */
 public static function factory($type)
 {
     $type_lower = strtolower($type);
     $file = './libraries/gis/GIS' . ucfirst($type_lower) . '.php';
     if (!PMA_isValid($type_lower, PMA\libraries\Util::getGISDatatypes()) || !file_exists($file)) {
         return false;
     }
     if (include_once $file) {
         switch (strtoupper($type)) {
             case 'MULTIPOLYGON':
                 return GISMultipolygon::singleton();
             case 'POLYGON':
                 return GISPolygon::singleton();
             case 'MULTIPOINT':
                 return GISMultipoint::singleton();
             case 'POINT':
                 return GISPoint::singleton();
             case 'MULTILINESTRING':
                 return GISMultilinestring::singleton();
             case 'LINESTRING':
                 return GISLinestring::singleton();
             case 'GEOMETRYCOLLECTION':
                 return GISGeometrycollection::singleton();
             default:
                 return false;
         }
     } else {
         return false;
     }
 }
コード例 #7
0
 /**
  * Initialises the class
  *
  * @param string $name     An identifier for the new node
  * @param int    $type     Type of node, may be one of CONTAINER or OBJECT
  * @param bool   $is_group Whether this object has been created
  *                         while grouping nodes
  */
 public function __construct($name, $type = Node::OBJECT, $is_group = false)
 {
     parent::__construct($name, $type, $is_group);
     $this->icon = PMA\libraries\Util::getImage('b_routines.png', __('Procedure'));
     $this->links = array('text' => 'db_routines.php?server=' . $GLOBALS['server'] . '&db=%2$s&item_name=%1$s&item_type=PROCEDURE' . '&edit_item=1', 'icon' => 'db_routines.php?server=' . $GLOBALS['server'] . '&db=%2$s&item_name=%1$s&item_type=PROCEDURE' . '&execute_dialog=1');
     $this->classes = 'procedure';
 }
コード例 #8
0
 /**
  * Returns information with latest version from phpmyadmin.net
  *
  * @return object JSON decoded object with the data
  */
 public function getLatestVersion()
 {
     if (!$GLOBALS['cfg']['VersionCheck']) {
         return null;
     }
     // Get response text from phpmyadmin.net or from the session
     // Update cache every 6 hours
     if (isset($_SESSION['cache']['version_check']) && time() < $_SESSION['cache']['version_check']['timestamp'] + 3600 * 6) {
         $save = false;
         $response = $_SESSION['cache']['version_check']['response'];
     } else {
         $save = true;
         $file = 'https://www.phpmyadmin.net/home_page/version.json';
         $response = Util::httpRequest($file, "GET");
     }
     $response = $response ? $response : '{}';
     /* Parse response */
     $data = json_decode($response);
     /* Basic sanity checking */
     if (!is_object($data) || empty($data->version) || empty($data->releases) || empty($data->date)) {
         return null;
     }
     if ($save) {
         $_SESSION['cache']['version_check'] = array('response' => $response, 'timestamp' => time());
     }
     return $data;
 }
コード例 #9
0
ファイル: NodeView.php プロジェクト: phpmyadmin/phpmyadmin
 /**
  * Initialises the class
  *
  * @param string $name     An identifier for the new node
  * @param int    $type     Type of node, may be one of CONTAINER or OBJECT
  * @param bool   $is_group Whether this object has been created
  *                         while grouping nodes
  */
 public function __construct($name, $type = Node::OBJECT, $is_group = false)
 {
     parent::__construct($name, $type, $is_group);
     $this->icon = PMA\libraries\Util::getImage('b_props.png', __('View'));
     $this->links = array('text' => 'sql.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s&amp;pos=0', 'icon' => 'tbl_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s');
     $this->classes = 'view';
 }
コード例 #10
0
 /**
  * Returns information with latest version from phpmyadmin.net
  *
  * @return object JSON decoded object with the data
  */
 public function getLatestVersion()
 {
     if (!$GLOBALS['cfg']['VersionCheck']) {
         return null;
     }
     // wait 3s at most for server response, it's enough to get information
     // from a working server
     $connection_timeout = 3;
     $response = '{}';
     // Get response text from phpmyadmin.net or from the session
     // Update cache every 6 hours
     if (isset($_SESSION['cache']['version_check']) && time() < $_SESSION['cache']['version_check']['timestamp'] + 3600 * 6) {
         $save = false;
         $response = $_SESSION['cache']['version_check']['response'];
     } else {
         $save = true;
         $file = 'https://www.phpmyadmin.net/home_page/version.json';
         if (ini_get('allow_url_fopen')) {
             $context = array('http' => array('request_fulluri' => true, 'timeout' => $connection_timeout));
             $context = Util::handleContext($context);
             if (!defined('TESTSUITE')) {
                 session_write_close();
             }
             $response = file_get_contents($file, false, stream_context_create($context));
         } else {
             if (function_exists('curl_init')) {
                 $curl_handle = curl_init($file);
                 if ($curl_handle === false) {
                     return null;
                 }
                 $curl_handle = Util::configureCurl($curl_handle);
                 curl_setopt($curl_handle, CURLOPT_HEADER, false);
                 curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
                 curl_setopt($curl_handle, CURLOPT_TIMEOUT, $connection_timeout);
                 if (!defined('TESTSUITE')) {
                     session_write_close();
                 }
                 $response = curl_exec($curl_handle);
             }
         }
     }
     /* Parse response */
     $data = json_decode($response);
     /* Basic sanity checking */
     if (!is_object($data) || empty($data->version) || empty($data->releases) || empty($data->date)) {
         return null;
     }
     if ($save) {
         if (!isset($_SESSION) && !defined('TESTSUITE')) {
             ini_set('session.use_only_cookies', 'false');
             ini_set('session.use_cookies', 'false');
             ini_set('session.use_trans_sid', 'false');
             ini_set('session.cache_limiter', 'nocache');
             session_start();
         }
         $_SESSION['cache']['version_check'] = array('response' => $response, 'timestamp' => time());
     }
     return $data;
 }
コード例 #11
0
 /**
  * returns the pbxt engine specific handling for
  * PMA_ENGINE_DETAILS_TYPE_SIZE variables.
  *
  * @param string $formatted_size the size expression (for example 8MB)
  *
  * @return string the formatted value and its unit
  */
 public function resolveTypeSize($formatted_size)
 {
     if (preg_match('/^[0-9]+[a-zA-Z]+$/', $formatted_size)) {
         $value = PMA\libraries\Util::extractValueFromFormattedSize($formatted_size);
     } else {
         $value = $formatted_size;
     }
     return PMA\libraries\Util::formatByteDown($value);
 }
コード例 #12
0
 /**
  * Returns HTML for control buttons displayed infront of a node
  *
  * @return String HTML for control buttons
  */
 public function getHtmlForControlButtons()
 {
     $ret = '';
     $cfgRelation = PMA_getRelationsParam();
     if ($cfgRelation['navwork']) {
         $db = $this->realParent()->real_name;
         $item = $this->real_name;
         $ret = '<span class="navItemControls">' . '<a href="navigation.php' . PMA_URL_getCommon() . '&hideNavItem=true' . '&itemType=' . urlencode($this->getItemType()) . '&itemName=' . urlencode($item) . '&dbName=' . urlencode($db) . '"' . ' class="hideNavItem ajax">' . PMA\libraries\Util::getImage('lightbulb_off.png', __('Hide')) . '</a></span>';
     }
     return $ret;
 }
コード例 #13
0
 /**
  * Returns HTML for control buttons displayed infront of a node
  *
  * @return String HTML for control buttons
  */
 public function getHtmlForControlButtons()
 {
     $ret = '';
     $cfgRelation = PMA_getRelationsParam();
     if ($cfgRelation['navwork']) {
         $db = $this->realParent()->real_name;
         $item = $this->real_name;
         $params = array('hideNavItem' => true, 'itemType' => $this->getItemType(), 'itemName' => $item, 'dbName' => $db);
         $ret = '<span class="navItemControls">' . '<a href="navigation.php' . URL::getCommon($params) . '"' . ' class="hideNavItem ajax">' . PMA\libraries\Util::getImage('hide.png', __('Hide')) . '</a></span>';
     }
     return $ret;
 }
コード例 #14
0
 /**
  * Initialises the class
  *
  * @param string $name An identifier for the new node
  */
 public function __construct($name)
 {
     parent::__construct($name, Node::CONTAINER);
     if ($GLOBALS['is_create_db_priv'] && $GLOBALS['cfg']['ShowCreateDb'] !== false) {
         $new = NodeFactory::getInstance('Node', _pgettext('Create new database', 'New'));
         $new->isNew = true;
         $new->icon = PMA\libraries\Util::getImage('b_newdb.png', '');
         $new->links = array('text' => 'server_databases.php?server=' . $GLOBALS['server'], 'icon' => 'server_databases.php?server=' . $GLOBALS['server']);
         $new->classes = 'new_database italics';
         $this->addChild($new);
     }
 }
コード例 #15
0
ファイル: PDF.php プロジェクト: iShareLife/phpmyadmin
 /**
  * This function must be named "Footer" to work with the TCPDF library
  *
  * @return void
  */
 public function Footer()
 {
     // Check if footer for this page already exists
     if (!isset($this->footerset[$this->page])) {
         $this->SetY(-15);
         $this->SetFont(PMA_PDF_FONT, '', 14);
         $this->Cell(0, 6, __('Page number:') . ' ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 'T', 0, 'C');
         $this->Cell(0, 6, Util::localisedDate(), 0, 1, 'R');
         $this->SetY(20);
         // set footerset
         $this->footerset[$this->page] = 1;
     }
 }
コード例 #16
0
 /**
  * Initialises the class
  */
 public function __construct()
 {
     parent::__construct(__('Triggers'), Node::CONTAINER);
     $this->icon = PMA\libraries\Util::getImage('b_triggers.png');
     $this->links = array('text' => 'db_triggers.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'db_triggers.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s&amp;token=' . $_SESSION[' PMA_token ']);
     $this->real_name = 'triggers';
     $new = NodeFactory::getInstance('Node', _pgettext('Create new trigger', 'New'));
     $new->isNew = true;
     $new->icon = PMA\libraries\Util::getImage('b_trigger_add.png', '');
     $new->links = array('text' => 'db_triggers.php?server=' . $GLOBALS['server'] . '&amp;db=%3$s&amp;token=' . $_SESSION[' PMA_token '] . '&amp;add_item=1', 'icon' => 'db_triggers.php?server=' . $GLOBALS['server'] . '&amp;db=%3$s&amp;token=' . $_SESSION[' PMA_token '] . '&amp;add_item=1');
     $new->classes = 'new_trigger italics';
     $this->addChild($new);
 }
コード例 #17
0
 /**
  * Initialises the class
  */
 public function __construct()
 {
     parent::__construct(__('Events'), Node::CONTAINER);
     $this->icon = PMA\libraries\Util::getImage('b_events.png', '');
     $this->links = array('text' => 'db_events.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s', 'icon' => 'db_events.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s');
     $this->real_name = 'events';
     $new = NodeFactory::getInstance('Node', _pgettext('Create new event', 'New'));
     $new->isNew = true;
     $new->icon = PMA\libraries\Util::getImage('b_event_add.png', '');
     $new->links = array('text' => 'db_events.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&add_item=1', 'icon' => 'db_events.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&add_item=1');
     $new->classes = 'new_event italics';
     $this->addChild($new);
 }
コード例 #18
0
 /**
  * Initialises the class
  */
 public function __construct()
 {
     parent::__construct(__('Procedures'), Node::CONTAINER);
     $this->icon = PMA\libraries\Util::getImage('b_routines.png', __('Procedures'));
     $this->links = array('text' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;type=PROCEDURE', 'icon' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;type=PROCEDURE');
     $this->real_name = 'procedures';
     $new_label = _pgettext('Create new procedure', 'New');
     $new = NodeFactory::getInstance('Node', $new_label);
     $new->isNew = true;
     $new->icon = PMA\libraries\Util::getImage('b_routine_add.png', $new_label);
     $new->links = array('text' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&add_item=1', 'icon' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&add_item=1');
     $new->classes = 'new_procedure italics';
     $this->addChild($new);
 }
コード例 #19
0
 /**
  * Initialises the class
  */
 public function __construct()
 {
     parent::__construct(__('Columns'), Node::CONTAINER);
     $this->icon = Util::getImage('pause.png', __('Columns'));
     $this->links = array('text' => 'tbl_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s' . '&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'tbl_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s' . '&amp;token=' . $_SESSION[' PMA_token ']);
     $this->real_name = 'columns';
     $new_label = _pgettext('Create new column', 'New');
     $new = NodeFactory::getInstance('Node', $new_label);
     $new->isNew = true;
     $new->icon = Util::getImage('b_column_add.png', $new_label);
     $new->links = array('text' => 'tbl_addfield.php?server=' . $GLOBALS['server'] . '&amp;db=%3$s&amp;table=%2$s' . '&amp;field_where=last&after_field=' . '&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'tbl_addfield.php?server=' . $GLOBALS['server'] . '&amp;db=%3$s&amp;table=%2$s' . '&amp;field_where=last&after_field=' . '&amp;token=' . $_SESSION[' PMA_token ']);
     $new->classes = 'new_column italics';
     $this->addChild($new);
 }
コード例 #20
0
 /**
  * Initialises the class
  */
 public function __construct()
 {
     parent::__construct(__('Functions'), Node::CONTAINER);
     $this->icon = PMA\libraries\Util::getImage('b_routines.png', __('Functions'));
     $this->links = array('text' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '] . '&amp;type=FUNCTION', 'icon' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '] . '&amp;type=FUNCTION');
     $this->real_name = 'functions';
     $new_label = _pgettext('Create new function', 'New');
     $new = NodeFactory::getInstance('Node', $new_label);
     $new->isNew = true;
     $new->icon = PMA\libraries\Util::getImage('b_routine_add.png', $new_label);
     $new->links = array('text' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '] . '&add_item=1&amp;item_type=FUNCTION', 'icon' => 'db_routines.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '] . '&add_item=1&amp;item_type=FUNCTION');
     $new->classes = 'new_function italics';
     $this->addChild($new);
 }
コード例 #21
0
 /**
  * Initialises the class
  */
 public function __construct()
 {
     parent::__construct(__('Indexes'), Node::CONTAINER);
     $this->icon = PMA\libraries\Util::getImage('b_index.png', __('Indexes'));
     $this->links = array('text' => 'tbl_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s' . '&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'tbl_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s' . '&amp;token=' . $_SESSION[' PMA_token ']);
     $this->real_name = 'indexes';
     $new_label = _pgettext('Create new index', 'New');
     $new = NodeFactory::getInstance('Node', $new_label);
     $new->isNew = true;
     $new->icon = PMA\libraries\Util::getImage('b_index_add.png', $new_label);
     $new->links = array('text' => 'tbl_indexes.php?server=' . $GLOBALS['server'] . '&amp;create_index=1&amp;added_fields=2' . '&amp;db=%3$s&amp;table=%2$s&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'tbl_indexes.php?server=' . $GLOBALS['server'] . '&amp;create_index=1&amp;added_fields=2' . '&amp;db=%3$s&amp;table=%2$s&amp;token=' . $_SESSION[' PMA_token ']);
     $new->classes = 'new_index italics';
     $this->addChild($new);
 }
コード例 #22
0
 /**
  * Initialises the class
  */
 public function __construct()
 {
     parent::__construct(__('Views'), Node::CONTAINER);
     $this->icon = PMA\libraries\Util::getImage('b_views.png', __('Views'));
     $this->links = array('text' => 'db_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;tbl_type=view', 'icon' => 'db_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;tbl_type=view');
     $this->classes = 'viewContainer subContainer';
     $this->real_name = 'views';
     $new_label = _pgettext('Create new view', 'New');
     $new = NodeFactory::getInstance('Node', $new_label);
     $new->isNew = true;
     $new->icon = PMA\libraries\Util::getImage('b_view_add.png', $new_label);
     $new->links = array('text' => 'view_create.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s', 'icon' => 'view_create.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s');
     $new->classes = 'new_view italics';
     $this->addChild($new);
 }
コード例 #23
0
 /**
  * Initialises the class
  */
 public function __construct()
 {
     parent::__construct(__('Tables'), Node::CONTAINER);
     $this->icon = PMA\libraries\Util::getImage('b_browse.png', __('Tables'));
     $this->links = array('text' => 'db_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;tbl_type=table' . '&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'db_structure.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;tbl_type=table' . '&amp;token=' . $_SESSION[' PMA_token ']);
     $this->real_name = 'tables';
     $this->classes = 'tableContainer subContainer';
     $new_label = _pgettext('Create new table', 'New');
     $new = NodeFactory::getInstance('Node', $new_label);
     $new->isNew = true;
     $new->icon = PMA\libraries\Util::getImage('b_table_add.png', $new_label);
     $new->links = array('text' => 'tbl_create.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'tbl_create.php?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;token=' . $_SESSION[' PMA_token ']);
     $new->classes = 'new_table italics';
     $this->addChild($new);
 }
コード例 #24
0
 /**
  * returns html tables with stats over inno db buffer pool
  *
  * @return string  html table with stats
  */
 public function getPageBufferpool()
 {
     // The following query is only possible because we know
     // that we are on MySQL 5 here (checked above)!
     // side note: I love MySQL 5 for this. :-)
     $sql = '
          SHOW STATUS
         WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\'
            OR Variable_name = \'Innodb_page_size\';';
     $status = $GLOBALS['dbi']->fetchResult($sql, 0, 1);
     $output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n" . '    <caption class="tblHeaders">' . "\n" . '        ' . __('Buffer Pool Usage') . "\n" . '    </caption>' . "\n" . '    <tfoot>' . "\n" . '        <tr>' . "\n" . '            <th colspan="2">' . "\n" . '                ' . __('Total') . "\n" . '                : ' . Util::formatNumber($status['Innodb_buffer_pool_pages_total'], 0) . '&nbsp;' . __('pages') . ' / ' . join('&nbsp;', Util::formatByteDown($status['Innodb_buffer_pool_pages_total'] * $status['Innodb_page_size'])) . "\n" . '            </th>' . "\n" . '        </tr>' . "\n" . '    </tfoot>' . "\n" . '    <tbody>' . "\n" . '        <tr class="odd">' . "\n" . '            <th>' . __('Free pages') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_pages_free'], 0) . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="even">' . "\n" . '            <th>' . __('Dirty pages') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_pages_dirty'], 0) . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="odd">' . "\n" . '            <th>' . __('Pages containing data') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_pages_data'], 0) . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="even">' . "\n" . '            <th>' . __('Pages to be flushed') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_pages_flushed'], 0) . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="odd">' . "\n" . '            <th>' . __('Busy pages') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_pages_misc'], 0) . "\n" . '</td>' . "\n" . '        </tr>';
     // not present at least since MySQL 5.1.40
     if (isset($status['Innodb_buffer_pool_pages_latched'])) {
         $output .= '        <tr class="even">' . '            <th>' . __('Latched pages') . '</th>' . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_pages_latched'], 0) . '</td>' . '        </tr>';
     }
     $output .= '    </tbody>' . "\n" . '</table>' . "\n\n" . '<table class="data" id="table_innodb_bufferpool_activity">' . "\n" . '    <caption class="tblHeaders">' . "\n" . '        ' . __('Buffer Pool Activity') . "\n" . '    </caption>' . "\n" . '    <tbody>' . "\n" . '        <tr class="odd">' . "\n" . '            <th>' . __('Read requests') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_read_requests'], 0) . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="even">' . "\n" . '            <th>' . __('Write requests') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_write_requests'], 0) . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="odd">' . "\n" . '            <th>' . __('Read misses') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_reads'], 0) . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="even">' . "\n" . '            <th>' . __('Write waits') . '</th>' . "\n" . '            <td class="value">' . Util::formatNumber($status['Innodb_buffer_pool_wait_free'], 0) . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="odd">' . "\n" . '            <th>' . __('Read misses in %') . '</th>' . "\n" . '            <td class="value">' . ($status['Innodb_buffer_pool_read_requests'] == 0 ? '---' : htmlspecialchars(Util::formatNumber($status['Innodb_buffer_pool_reads'] * 100 / $status['Innodb_buffer_pool_read_requests'], 3, 2)) . ' %') . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '        <tr class="even">' . "\n" . '            <th>' . __('Write waits in %') . '</th>' . "\n" . '            <td class="value">' . ($status['Innodb_buffer_pool_write_requests'] == 0 ? '---' : htmlspecialchars(Util::formatNumber($status['Innodb_buffer_pool_wait_free'] * 100 / $status['Innodb_buffer_pool_write_requests'], 3, 2)) . ' %') . "\n" . '</td>' . "\n" . '        </tr>' . "\n" . '    </tbody>' . "\n" . '</table>' . "\n";
     return $output;
 }
コード例 #25
0
/**
 * returns collation of given db
 *
 * @param string $db name of db
 *
 * @return string  collation of $db
 */
function PMA_getDbCollation($db)
{
    if ($GLOBALS['dbi']->isSystemSchema($db)) {
        // We don't have to check the collation of the virtual
        // information_schema database: We know it!
        return 'utf8_general_ci';
    }
    if (!$GLOBALS['cfg']['Server']['DisableIS']) {
        // this is slow with thousands of databases
        $sql = 'SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA' . ' WHERE SCHEMA_NAME = \'' . Util::sqlAddSlashes($db) . '\' LIMIT 1';
        return $GLOBALS['dbi']->fetchValue($sql);
    } else {
        $GLOBALS['dbi']->selectDb($db);
        $return = $GLOBALS['dbi']->fetchValue('SELECT @@collation_database');
        if ($db !== $GLOBALS['db']) {
            $GLOBALS['dbi']->selectDb($GLOBALS['db']);
        }
        return $return;
    }
}
コード例 #26
0
/**
 * Create the routine
 *
 * @param string $routine_query    Query to create routine
 * @param string $create_routine   Query to restore routine
 * @param array  $privilegesBackup Privileges backup
 *
 * @return array
 */
function PMA_RTN_createRoutine($routine_query, $create_routine, $privilegesBackup)
{
    $result = $GLOBALS['dbi']->tryQuery($routine_query);
    if (!$result) {
        $errors = array();
        $errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($routine_query)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
        // We dropped the old routine,
        // but were unable to create the new one
        // Try to restore the backup query
        $result = $GLOBALS['dbi']->tryQuery($create_routine);
        $errors = checkResult($result, __('Sorry, we failed to restore' . ' the dropped routine.'), $create_routine, $errors);
        return array($errors, null);
    }
    // Default value
    $resultAdjust = false;
    if ($GLOBALS['proc_priv'] && $GLOBALS['is_reload_priv']) {
        // Insert all the previous privileges
        // but with the new name and the new type
        foreach ($privilegesBackup as $priv) {
            $adjustProcPrivilege = 'INSERT INTO ' . Util::backquote('mysql') . '.' . Util::backquote('procs_priv') . ' VALUES("' . $priv[0] . '", "' . $priv[1] . '", "' . $priv[2] . '", "' . $_REQUEST['item_name'] . '", "' . $_REQUEST['item_type'] . '", "' . $priv[5] . '", "' . $priv[6] . '", "' . $priv[7] . '");';
            $resultAdjust = $GLOBALS['dbi']->query($adjustProcPrivilege);
        }
    }
    $message = PMA_RTN_flushPrivileges($resultAdjust);
    return array(array(), $message);
}
コード例 #27
0
/**
 * Creates the HTML code that shows the routine execution dialog.
 *
 * @param array $routine Data for the routine returned by
 *                       PMA_RTN_getDataFromName()
 *
 * @return string   HTML code for the routine execution dialog.
 */
function PMA_RTN_getExecuteForm($routine)
{
    global $db, $cfg;
    // Escape special characters
    $routine['item_name'] = htmlentities($routine['item_name'], ENT_QUOTES);
    for ($i = 0; $i < $routine['item_num_params']; $i++) {
        $routine['item_param_name'][$i] = htmlentities($routine['item_param_name'][$i], ENT_QUOTES);
    }
    // Create the output
    $retval = "";
    $retval .= "<!-- START ROUTINE EXECUTE FORM -->\n\n";
    $retval .= "<form action='db_routines.php' method='post'\n";
    $retval .= "       class='rte_form ajax' onsubmit='return false'>\n";
    $retval .= "<input type='hidden' name='item_name'\n";
    $retval .= "       value='{$routine['item_name']}' />\n";
    $retval .= "<input type='hidden' name='item_type'\n";
    $retval .= "       value='{$routine['item_type']}' />\n";
    $retval .= PMA_URL_getHiddenInputs($db) . "\n";
    $retval .= "<fieldset>\n";
    if ($GLOBALS['is_ajax_request'] != true) {
        $retval .= "<legend>{$routine['item_name']}</legend>\n";
        $retval .= "<table class='rte_table'>\n";
        $retval .= "<caption class='tblHeaders'>\n";
        $retval .= __('Routine parameters');
        $retval .= "</caption>\n";
    } else {
        $retval .= "<legend>" . __('Routine parameters') . "</legend>\n";
        $retval .= "<table class='rte_table' style='width: 100%;'>\n";
    }
    $retval .= "<tr>\n";
    $retval .= "<th>" . __('Name') . "</th>\n";
    $retval .= "<th>" . __('Type') . "</th>\n";
    if ($cfg['ShowFunctionFields']) {
        $retval .= "<th>" . __('Function') . "</th>\n";
    }
    $retval .= "<th>" . __('Value') . "</th>\n";
    $retval .= "</tr>\n";
    // Get a list of data types that are not yet supported.
    $no_support_types = PMA\libraries\Util::unsupportedDatatypes();
    for ($i = 0; $i < $routine['item_num_params']; $i++) {
        // Each parameter
        if ($routine['item_type'] == 'PROCEDURE' && $routine['item_param_dir'][$i] == 'OUT') {
            continue;
        }
        $rowclass = $i % 2 == 0 ? 'even' : 'odd';
        $retval .= "\n<tr class='{$rowclass}'>\n";
        $retval .= "<td>{$routine['item_param_name'][$i]}</td>\n";
        $retval .= "<td>{$routine['item_param_type'][$i]}</td>\n";
        if ($cfg['ShowFunctionFields']) {
            $retval .= "<td>\n";
            if (stristr($routine['item_param_type'][$i], 'enum') || stristr($routine['item_param_type'][$i], 'set') || in_array(mb_strtolower($routine['item_param_type'][$i]), $no_support_types)) {
                $retval .= "--\n";
            } else {
                $field = array('True_Type' => mb_strtolower($routine['item_param_type'][$i]), 'Type' => '', 'Key' => '', 'Field' => '', 'Default' => '', 'first_timestamp' => false);
                $retval .= "<select name='funcs[" . $routine['item_param_name'][$i] . "]'>";
                $retval .= PMA\libraries\Util::getFunctionsForField($field, false, array());
                $retval .= "</select>";
            }
            $retval .= "</td>\n";
        }
        // Append a class to date/time fields so that
        // jQuery can attach a datepicker to them
        $class = '';
        if ($routine['item_param_type'][$i] == 'DATETIME' || $routine['item_param_type'][$i] == 'TIMESTAMP') {
            $class = 'datetimefield';
        } else {
            if ($routine['item_param_type'][$i] == 'DATE') {
                $class = 'datefield';
            }
        }
        $retval .= "<td class='nowrap'>\n";
        if (in_array($routine['item_param_type'][$i], array('ENUM', 'SET'))) {
            if ($routine['item_param_type'][$i] == 'ENUM') {
                $input_type = 'radio';
            } else {
                $input_type = 'checkbox';
            }
            foreach ($routine['item_param_length_arr'][$i] as $value) {
                $value = htmlentities(PMA\libraries\Util::unquote($value), ENT_QUOTES);
                $retval .= "<input name='params[" . $routine['item_param_name'][$i] . "][]' " . "value='" . $value . "' type='" . $input_type . "' />" . $value . "<br />\n";
            }
        } else {
            if (in_array(mb_strtolower($routine['item_param_type'][$i]), $no_support_types)) {
                $retval .= "\n";
            } else {
                $retval .= "<input class='{$class}' type='text' name='params[" . $routine['item_param_name'][$i] . "]' />\n";
            }
        }
        $retval .= "</td>\n";
        $retval .= "</tr>\n";
    }
    $retval .= "\n</table>\n";
    if ($GLOBALS['is_ajax_request'] != true) {
        $retval .= "</fieldset>\n\n";
        $retval .= "<fieldset class='tblFooters'>\n";
        $retval .= "    <input type='submit' name='execute_routine'\n";
        $retval .= "           value='" . __('Go') . "' />\n";
        $retval .= "</fieldset>\n";
    } else {
        $retval .= "<input type='hidden' name='execute_routine' value='true' />";
        $retval .= "<input type='hidden' name='ajax_request' value='true' />";
    }
    $retval .= "</form>\n\n";
    $retval .= "<!-- END ROUTINE EXECUTE FORM -->\n\n";
    return $retval;
}
コード例 #28
0
 /**
  * Outputs the content of a table in MediaWiki format
  *
  * @param string $db        database name
  * @param string $table     table name
  * @param string $crlf      the end of line sequence
  * @param string $error_url the url to go back in case of error
  * @param string $sql_query SQL query for obtaining data
  * @param array  $aliases   Aliases of db/table/columns
  *
  * @return bool             Whether it succeeded
  */
 public function exportData($db, $table, $crlf, $error_url, $sql_query, $aliases = array())
 {
     $db_alias = $db;
     $table_alias = $table;
     $this->initAlias($aliases, $db_alias, $table_alias);
     // Print data comment
     $output = $this->_exportComment("Table data for " . PMA\libraries\Util::backquote($table_alias));
     // Begin the table construction
     // Use the "wikitable" class for style
     // Use the "sortable"  class for allowing tables to be sorted by column
     $output .= "{| class=\"wikitable sortable\" style=\"text-align:center;\"" . $this->_exportCRLF();
     // Add the table name
     if (isset($GLOBALS['mediawiki_caption'])) {
         $output .= "|+'''" . $table_alias . "'''" . $this->_exportCRLF();
     }
     // Add the table headers
     if (isset($GLOBALS['mediawiki_headers'])) {
         // Get column names
         $column_names = $GLOBALS['dbi']->getColumnNames($db, $table);
         // Add column names as table headers
         if (!is_null($column_names)) {
             // Use '|-' for separating rows
             $output .= "|-" . $this->_exportCRLF();
             // Use '!' for separating table headers
             foreach ($column_names as $column) {
                 if (!empty($aliases[$db]['tables'][$table]['columns'][$column])) {
                     $column = $aliases[$db]['tables'][$table]['columns'][$column];
                 }
                 $output .= " ! " . $column . "" . $this->_exportCRLF();
             }
         }
     }
     // Get the table data from the database
     $result = $GLOBALS['dbi']->query($sql_query, null, PMA\libraries\DatabaseInterface::QUERY_UNBUFFERED);
     $fields_cnt = $GLOBALS['dbi']->numFields($result);
     while ($row = $GLOBALS['dbi']->fetchRow($result)) {
         $output .= "|-" . $this->_exportCRLF();
         // Use '|' for separating table columns
         for ($i = 0; $i < $fields_cnt; ++$i) {
             $output .= " | " . $row[$i] . "" . $this->_exportCRLF();
         }
     }
     // End table construction
     $output .= "|}" . str_repeat($this->_exportCRLF(), 2);
     return PMA_exportOutputHandler($output);
 }
コード例 #29
0
/**
 * Move or copy a table
 *
 * @param string $db    current database name
 * @param string $table current table name
 *
 * @return void
 */
function PMA_moveOrCopyTable($db, $table)
{
    /**
     * Selects the database to work with
     */
    $GLOBALS['dbi']->selectDb($db);
    /**
     * $_REQUEST['target_db'] could be empty in case we came from an input field
     * (when there are many databases, no drop-down)
     */
    if (empty($_REQUEST['target_db'])) {
        $_REQUEST['target_db'] = $db;
    }
    /**
     * A target table name has been sent to this script -> do the work
     */
    if (PMA_isValid($_REQUEST['new_name'])) {
        if ($db == $_REQUEST['target_db'] && $table == $_REQUEST['new_name']) {
            if (isset($_REQUEST['submit_move'])) {
                $message = Message::error(__('Can\'t move table to same one!'));
            } else {
                $message = Message::error(__('Can\'t copy table to same one!'));
            }
        } else {
            Table::moveCopy($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name'], $_REQUEST['what'], isset($_REQUEST['submit_move']), 'one_table');
            if (isset($_REQUEST['adjust_privileges']) && !empty($_REQUEST['adjust_privileges'])) {
                if (isset($_REQUEST['submit_move'])) {
                    PMA_AdjustPrivileges_renameOrMoveTable($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name']);
                } else {
                    PMA_AdjustPrivileges_copyTable($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name']);
                }
                if (isset($_REQUEST['submit_move'])) {
                    $message = Message::success(__('Table %s has been moved to %s. Privileges have been ' . 'adjusted.'));
                } else {
                    $message = Message::success(__('Table %s has been copied to %s. Privileges have been ' . 'adjusted.'));
                }
            } else {
                if (isset($_REQUEST['submit_move'])) {
                    $message = Message::success(__('Table %s has been moved to %s.'));
                } else {
                    $message = Message::success(__('Table %s has been copied to %s.'));
                }
            }
            $old = PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote($table);
            $message->addParam($old);
            $new = PMA\libraries\Util::backquote($_REQUEST['target_db']) . '.' . PMA\libraries\Util::backquote($_REQUEST['new_name']);
            $message->addParam($new);
            /* Check: Work on new table or on old table? */
            if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) {
            }
        }
    } else {
        /**
         * No new name for the table!
         */
        $message = Message::error(__('The table name is empty!'));
    }
    if ($GLOBALS['is_ajax_request'] == true) {
        $response = PMA\libraries\Response::getInstance();
        $response->addJSON('message', $message);
        if ($message->isSuccess()) {
            $response->addJSON('db', $GLOBALS['db']);
        } else {
            $response->setRequestStatus(false);
        }
        exit;
    }
}
コード例 #30
0
/**
 * Adjust the privileges after copying a table
 *
 * @param string $oldDb    Database name before table copying
 * @param string $oldTable Table name before table copying
 * @param string $newDb    Database name after table copying
 * @param string $newTable Table name after table copying
 *
 * @return void
 */
function PMA_AdjustPrivileges_copyTable($oldDb, $oldTable, $newDb, $newTable)
{
    if (isset($GLOBALS['table_priv']) && $GLOBALS['table_priv'] && isset($GLOBALS['col_priv']) && $GLOBALS['col_priv'] && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']) {
        $GLOBALS['dbi']->selectDb('mysql');
        // For Table Specific privileges
        $query_table_specific_old = 'SELECT * FROM ' . Util::backquote('tables_priv') . ' where ' . 'Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";';
        $old_privs_table = $GLOBALS['dbi']->fetchResult($query_table_specific_old, 0);
        foreach ($old_privs_table as $old_priv) {
            $newDb_table_privs_query = 'INSERT INTO ' . Util::backquote('tables_priv') . ' VALUES("' . $old_priv[0] . '", "' . $newDb . '", "' . $old_priv[2] . '", "' . $newTable . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "' . $old_priv[6] . '", "' . $old_priv[7] . '");';
            $GLOBALS['dbi']->query($newDb_table_privs_query);
        }
        // For Column Specific privileges
        $query_col_specific_old = 'SELECT * FROM ' . Util::backquote('columns_priv') . ' WHERE ' . 'Db = "' . $oldDb . '" AND Table_name = "' . $oldTable . '";';
        $old_privs_col = $GLOBALS['dbi']->fetchResult($query_col_specific_old, 0);
        foreach ($old_privs_col as $old_priv) {
            $newDb_col_privs_query = 'INSERT INTO ' . Util::backquote('columns_priv') . ' VALUES("' . $old_priv[0] . '", "' . $newDb . '", "' . $old_priv[2] . '", "' . $newTable . '", "' . $old_priv[4] . '", "' . $old_priv[5] . '", "' . $old_priv[6] . '");';
            $GLOBALS['dbi']->query($newDb_col_privs_query);
        }
        // Finally FLUSH the new privileges
        $flush_query = "FLUSH PRIVILEGES;";
        $GLOBALS['dbi']->query($flush_query);
    }
}