HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Tips/Tricks/Mods (http://www.howtoforge.com/forums/forumdisplay.php?f=19)
-   -   Ability to Select Database Name / Username (http://www.howtoforge.com/forums/showthread.php?t=1052)

SleeperZ 30th October 2005 09:29

Ability to Select Database Name / Username
 
1 Attachment(s)
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. :)

domino 9th November 2005 03:14

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

SleeperZ 9th November 2005 09:29

Hi Domino,

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

hairydog2 12th November 2005 11:01

Quote:

Originally Posted by SleeperZ
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

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?

hairydog2 14th November 2005 21:11

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.

elangel_nocturno 15th November 2005 22:12

Quote:

Originally Posted by hairydog2
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.

Hi, i do the changhes manually.

Replace this:

PHP Code:

     // 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 Code:

     // 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

hairydog2 16th November 2005 20:28

Thank you. That worked perfectly.

SleeperZ 26th January 2006 02:23

1 Attachment(s)
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

hairydog2 26th January 2006 23:32

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?

falko 27th January 2006 07:30

Quote:

Originally Posted by hairydog2
I don't understand why it isn't in the standard ISPConfig build.

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.


All times are GMT +2. The time now is 02:31.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.