Ability to Select Database Name / Username

Discussion in 'Tips/Tricks/Mods' started by SleeperZ, Oct 30, 2005.

  1. SleeperZ

    SleeperZ ISPConfig Developer ISPConfig Developer

    Hi Guys,

    I have started working on making ISPConfig work for my current setup and one of the first things i've personally found not entirely userfriendly is the in-ability to select your own database names.

    For this reason I am posting this back in the hope that if someone else wants to add this ability they can. (Maybe it'll show up in a future release somehow)

    First make a backup of the database, and the files.

    You then need to edit the Database (Datenbank) form.

    Login as an administrator and click the Management Link (Top left corner)
    Under Form Designer click Edit Form.
    Edit 'isp - ISP Datenbank'

    You should see the following:

    datenbankname descField [Edit] [Delete] [^]
    datenbankuser descField [Edit] [Delete] [^]

    I could not work out a quick way to edit the field type, so I deleted the two, and created 2 new Short Textfield.

    Important: Keep the Fieldname the same as what it was before (datenbankname / datenbankuser), the Title is what will show on the form and to my knowledge can be set to anything I used Database Name, and Database User respectively.

    Now that you've done this, apply the patch that i've attached here to the file:
    /home/admispconfig/ispconfig/lib/classes/ispconfig_isp_datenbank.lib.php

    That should be it!

    I am reasonably new to all this so go easy on me :) Feel free to comment on how this goes, esspecially if there is a major problem. :)
     

    Attached Files:

    Last edited: Oct 30, 2005
  2. domino

    domino New Member

    I completely overlooked this post thinking it was only a tip. I didn't realize it was a hack for ISPConfig. Thank you! I hope to see posts like these in the future.

    Regards
     
  3. SleeperZ

    SleeperZ ISPConfig Developer ISPConfig Developer

    Hi Domino,

    Yeah planning on doing a few more before long. :) Watch this space.
     
  4. hairydog2

    hairydog2 New Member

    I'm happy that I understood all the steps up to here, but I'm not clear how to apply the patch to a php file. The patch looks like an sql query. Can you explain in "Dummies Guide" terms?
     
  5. hairydog2

    hairydog2 New Member

    Can anyone help here? When I run "patch -i select_db_name.patch"

    all I get is Hunk #1 FAILED at 119.
    1 out of 1 hunk FAILED -- saving rejects to file ispconfig_isp_datenbank.lib.php.rej

    And the patch makes no changes to the php file at all.
     
  6. elangel_nocturno

    elangel_nocturno New Member

    Hi, i do the changhes manually.

    Replace this:

    PHP:
         // sind fr dieses Web berhaupt Datenbanken zugelassen?
         
    if(!$web["web_mysql"]){
           
    $status "DELETE";
           
    $errorMessage $go_api->lng("error_db_nicht_erlaubt");
         }

        
    // Datenbankname und -user festlegen
        
    $db_ids $go_api->db->queryAllRecords("SELECT datenbankname FROM isp_isp_datenbank WHERE web_id = '$web_doc_id'");
              if(empty(
    $db_ids)){
                
    $new_db_id 1;
              } else {
                
    // kleinste freie ID finden
                
    foreach($db_ids as $db_id){
                  
    $db_nr[] = str_replace('web'.$web["doc_id"].'_db'''$db_id["datenbankname"]);
                }
                
    sort($db_nrSORT_NUMERIC);
                
    reset($db_nr);
                
    $i 0;
                while(!isset(
    $new_db_id)){
                  if(
    $db_nr[$i] != ($i 1)) $new_db_id $i 1;
                  
    $i++;
                }
              }
        
    $datenbankname 'web'.$web_doc_id.'_db'.$new_db_id;
        
    $datenbankuser 'web'.$web_doc_id.'_u'.$new_db_id;


        
    $go_api->db->query("UPDATE isp_isp_datenbank SET datenbankname = '$datenbankname', datenbankuser = '$datenbankuser', web_id = '$web_doc_id' WHERE doc_id = '$doc_id'");

        
    // Eintrag der Datenbank holen
        
    $datenbank $go_api->db->queryOneRecord("select * from isp_isp_datenbank where doc_id = '$doc_id'");
    with this:

    PHP:
         // sind fr dieses Web berhaupt Datenbanken zugelassen?
         
    if(!$web["web_mysql"]){
           
    $status "DELETE";
           
    $errorMessage $go_api->lng("error_db_nicht_erlaubt");
         }
    /*
        // Datenbankname und -user festlegen
        $db_ids = $go_api->db->queryAllRecords("SELECT datenbankname FROM isp_isp_datenbank WHERE web_id = '$web_doc_id'");
              if(empty($db_ids)){
                $new_db_id = 1;
              } else {
                // kleinste freie ID finden
                foreach($db_ids as $db_id){
                  $db_nr[] = str_replace('web'.$web["doc_id"].'_db', '', $db_id["datenbankname"]);
                }
                sort($db_nr, SORT_NUMERIC);
                reset($db_nr);
                $i = 0;
                while(!isset($new_db_id)){
                  if($db_nr[$i] != ($i + 1)) $new_db_id = $i + 1;
                  $i++;
                }
              }
    */
        
    $datenbankname 'web'.$web_doc_id.'_db'.$new_db_id;
        
    $datenbankuser 'web'.$web_doc_id.'_u'.$new_db_id;

        
    $go_api->db->query("UPDATE isp_isp_datenbank SET web_id = '$web_doc_id' WHERE doc_id = '$doc_id'");
       
    // $go_api->db->query("UPDATE isp_isp_datenbank SET datenbankname = '$datenbankname', datenbankuser = '$datenbankuser', web_id = '$web_doc_id' WHERE doc_id = '$doc_id'");

        // Eintrag der Datenbank holen
        
    $datenbank $go_api->db->queryOneRecord("select * from isp_isp_datenbank where doc_id = '$doc_id'");
    in the ispconfig_isp_datenbank.lib.php file.

    Thank to SleeperZ 4 the great job!.

    Bye.

    P.D.: sorry for my english
     
  7. hairydog2

    hairydog2 New Member

    Thank you. That worked perfectly.
     
  8. SleeperZ

    SleeperZ ISPConfig Developer ISPConfig Developer

    Hi,

    I recently upgraded to the latest version and found out this patch didnt work, so i've uploaded one that does now (And its tested!)

    Sorry about the confusion - see attached.

    The command I use is: patch -p0 < select_db_name.patch
     

    Attached Files:

  9. hairydog2

    hairydog2 New Member

    It would be great if each update of ISPConfig didn't overwrite this change.

    I don't understand why it isn't in the standard ISPConfig build.

    Is there a drawback that I have not noticed?
     
  10. falko

    falko Super Moderator ISPConfig Developer

    Because we're very, very busy (really busy) and don't have the time to test every patch... You must know that it takes several hours each day only to help the people in this forum, and besides that we still have to earn a living...

    If we integrate the patch into ISPConfig, we have to test it very thoroughly because otherwise we'd get a lot of posts here from people that are not so lucky... This is very time-consuming. Although this is open-source and free software, we want to maintain a certain level of quality.
     
  11. hairydog2

    hairydog2 New Member

    Fair enough. It's a great bit of software, and I'd not want to see that undermined.
     
  12. deezone

    deezone New Member

    Hi I've tried this patch and it has messed up my ISPConfig database creation. Under website > options... the list of database name no longer appear...it's BLANK. Does anybody know what had happened here? I'm unable to delete any database entry or change the database password because of this.
     
  13. falko

    falko Super Moderator ISPConfig Developer

    Can you try to remove the patch?
    I haven't tried it, so I don't know what happens there.
     
  14. meijerbrantm

    meijerbrantm New Member

    this post is quite old so i just wanted to ask does this work with the most recent version of ISPConfig?
     
  15. Jorem

    Jorem Member

    I also like to know if this is still working on the latest build.

    I like this patch a lot, because I like to give my databases the names of the projects.
     
  16. hans2512

    hans2512 New Member

    Maybe an easier solution is to add a descriptionfield to de database name.
     
    Last edited: Feb 25, 2007
  17. Jorem

    Jorem Member

    How can I do that in ISPConfig?
     
  18. Pasco

    Pasco Member

    I like this patch a lot, too.

    But I got one big unsolved problem. Everytime I do an update of ISPConfig the patch gets overwritten. OK, I can patch my new Version of ISPC again, but the big problem is, that I can't see the customized databases in ISPC webinterface's anymore. It looks like there is no database/s of the web, eventhough there is/are. The databases still exisists of course (accessing them with phpmyadmin is no prob) but I can't change their names, PWDs or erase them anymore via ISPC's webinterface, nor can all other users...

    Does anyone know a work around for that? Perhaps saving an ISPConfig Database before updating which I could reload after updating ISPConfig? Is it possible? Which database stores the (customized) databasenames /-users? Can I do that without troubling the update?

    Thx so much
    pasco
     
    Last edited: Apr 19, 2007

Share This Page