Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

Hosted phpMyAdmin

Adrian Singer, 08-01-2007
Hosted phpMyAdmin is now available with all SoftwareProjects web hosting plans.

To access phpMyAdmin, point your browser to: https://softwareprojects.com/phpmyadmin and login with the MySQL username/password provided to you by customer support.

phpMyAdmin is shared by multiple customers on the same machine, but each user can only view and access their own database.

Oleg Golland, 08-01-2007
If anyone is interested in how we got phpMyAdmin to work well in a multiuser setup, here are some tips:

1. Switch to 'cookie' authentication method

2. update the getHtmlSelectedGrouped function under PMA_List_Database.class.php with the code below. This prevents users from being able to see all database names. They will only see databases that are available to them:


 
function getHtmlSelectGrouped($selected = '')
  {
    if (
true === $selected) {
     
$selected = $this->getDefault();       
    }     
 
   
$return = '<select name="db" id="lightm_db" xml:lang="en" dir="ltr"'
     
. ' onchange="if (this.value != \'\') window.parent.openDb(this.value);">' . "\n"
     
. '<option value="" dir="' . $GLOBALS['text_dir'] . '">'
     
. '(' . $GLOBALS['strDatabases'] . ') ...</option>' . "\n";
    foreach (
$this->getGroupedDetails() as $group => $dbs) {

       
$got_data = 0;
        foreach (
$dbs as $db) if ($db['num_tables']>0) { $got_data = 1; break; }
        if (empty(
$got_data)) continue;

      if (
count($dbs) > 1) {
       
$return .= '<optgroup label="' . htmlspecialchars($group)
          .
'">' . "\n";
       
// wether display db_name cuted by the group part
       
$cut = true;
      } else { 
       
// .. or full
       
$cut = false
      }
      foreach (
$dbs as $db) {

        if (
$db['num_tables']<1) continue;

       
$return .= '<option value="' . htmlspecialchars($db['name']) . '"'
         
.' title="' . htmlspecialchars($db['comment']) . '"';
        if (
$db['name'] == $selected) {
         
$return .= ' selected="selected"';
        }
       
$return .= '>' . htmlspecialchars($cut ? $db['disp_name_cut'] : $db['disp_name'])
          .
' (' . $db['num_tables'] . ')</option>' . "\n";
      }
      if (
count($dbs) > 1) {   
       
$return .= '</optgroup>' . "\n";
      }
    }
   
$return .= '</select>';
 
    return
$return;
  }

Dawn Rossi, 09-14-2009
In later versions of phpmyadmin, you have to update the function PMA_DBI_get_dblist() in database_interface.lib with:


function PMA_DBI_get_dblist($link = NULL) {
  if (empty(
$link)) {
    if (isset(
$GLOBALS['userlink'])) {
     
$link = $GLOBALS['userlink'];
    } else {
      return
FALSE;
    }
  }
 
$res = PMA_DBI_try_query('SHOW DATABASES;', $link);     
 
$dbs_array = array();
  while (
$row = PMA_DBI_fetch_row($res)) {

 
// Before MySQL 4.0.2, SHOW DATABASES could send the
  // whole list, so check if we really have access:
  //if (PMA_MYSQL_CLIENT_API < 40002) {
  // Better check the server version, in case the client API
  // is more recent than the server version

 
if (PMA_MYSQL_INT_VERSION < 40002 || 1) {
   
$dblink = @PMA_DBI_select_db($row[0], $link);
     
$res1 = PMA_DBI_try_query('SHOW TABLES;', $link);
      if (
mysql_num_rows($res1)<2) continue;
    if (!
$dblink) {
      continue;
    }
  }
 
$dbs_array[] = $row[0];
  }
 
PMA_DBI_free_result($res);
  unset(
$res);

  return
$dbs_array;
}
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions