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=29)
-   -   [DOMAINID] Prefix (http://www.howtoforge.com/forums/showthread.php?t=42229)

oilyflutesalad 28th December 2009 20:21

[DOMAINID] Prefix
 
I wanted to include the ID of the parent domain in FTP accounts, so after a bit of firebug magic and a quick look through relevant files, I've modified the source to add the keyword DOMAINID.

Example Usage:
Code:

c[CLIENTID]d[DOMAINID]_
Will result in something like "c3d12_default" if an FTP account with name "default" was added. Without the domain ID prefix, a client would get a duplicate error if they tried to create a "default" FTP account for each domain, even though it would make sense to be able to create them. Now they can have default accounts for every domain in their account.

Open tools.inc.php for editing. I'm using Ubuntu Server 9.10. The path to your ISPConfig directory may be different on your distro.
Code:

vi /var/www/ispconfig/sites/tools.inc.php
Go down to the replacePrefix function. Add ,'DOMAINID' to the $keywordlist array, then add a new case under the two existing ones:
Code:

[...]
        // Array containing keys to search
        $keywordlist=array('CLIENTNAME','CLIENTID','DOMAINID');
[...]
                                case 'CLIENTID':
                                        $name=str_replace('['.$keyword.']', getClientID($dataRecord),$name);
                                break;
                                case 'DOMAINID':
                                        $name=str_replace('['.$keyword.']', $dataRecord['parent_domain_id'],$name);
                                break;
[...]

And that's it! Save the file and you're done. To change your prefixes, go into ISPConfig then on the System tab, click "Interface Config" in the system menu.

moglia 16th January 2010 13:57

I will try test and implement.
 
Thanks 4 contrib.

BorderAmigos 22nd February 2010 22:38

FEATURE REQUEST !!! Can this be included in the next release of ISPConfig 3. It's useful and it would be nice not to have to re-do the edit after updating. Thanks.

till 23rd February 2010 09:13

If you like to request a feature, plaese post it as feature request in the bugtracker and vote for it there.

xxfog 18th April 2010 12:47

Hi oily..

did you already set this into bugtracker.ispconfig.org?

I would like to vote for it ther!

If so, please send the direkt link in this post.
If not - will you? ;-)

moglia 18th April 2010 13:22

Complement
 
[DOMAINNAME] is interessant too.

Prefix and Sufix implementation to create ftp account for example.

USERNAME_[DOMAINNAME] or USERNAME@[DOMAINNAME]

Examples:
user@domain.com
user_domain.com

radim_h 17th May 2010 02:05

Quote:

Originally Posted by moglia (Post 225718)
[DOMAINNAME] is interessant too.

Prefix and Sufix implementation to create ftp account for example.

USERNAME_[DOMAINNAME] or USERNAME@[DOMAINNAME]

Examples:
user@domain.com
user_domain.com

yes [DOMAINNAME] will be great

ppnl.com 19th October 2010 15:45

To adapt ispconfig and use DOMAINNAME, DOMAINID, DOMAINNAMESHORT as prefix for database in order to allow moving databases between clients!

My prefix for database name and database user is:
[DOMAINNAMESHORT][DOMAINID]_

Here DOMAINNAMESHORT will be the first 5 characters of the domain name, and the DOMAINID will be added to make it unique, however not a full list of databases with ONLY numbers!

e.g. for domain.com the database prefix will be domai12_

And because it's based on DOMAIN it allows to move to another client.

INSTRUCTIONS (on own risk)

To support DOMAINID, DOMAINNAME and DOMAINNAMESHORT as prefix modfiy the file /usr/local/ispconfig/interface/web/sites/tools.inc.php and modify replacePrefix and add also a new function getDomainName :

Code:

function replacePrefix($name, $dataRecord) {
  // No input -> no possible output -> go out!
  if ($name=="") return "";
 
  // Array containing keys to search
  $keywordlist=array('CLIENTNAME','CLIENTID','DOMAINID','DOMAINNAME','DOMAINNAMESHORT');
 
  // Try to match the key within the string
  foreach ($keywordlist as $keyword) {
    if (substr_count($name, '['.$keyword.']') > 0) {
      switch ($keyword) {
        case 'CLIENTNAME':
          $name=str_replace('['.$keyword.']', getClientName($dataRecord),$name);
        break;
        case 'CLIENTID':
          $name=str_replace('['.$keyword.']', getClientID($dataRecord),$name);
        break;
        case 'DOMAINID':
          $name=str_replace('['.$keyword.']', $dataRecord['parent_domain_id'],$name);
        break;
        case 'DOMAINNAME':
          $name=str_replace('['.$keyword.']', getDomainName($dataRecord['parent_domain_id']),$name);
        break;
        case 'DOMAINNAMESHORT':
          $name=str_replace('['.$keyword.']', substr(getDomainName($dataRecord['parent_domain_id']),0,5),$name);
        break;
      }
    }
  }
  return $name;
}

function getDomainName($domain_id) {
  global $app;
  $tmp = $app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id = " . $domain_id);

  return $tmp['domain'];
}


To show the dropdown with domains in the database edit form, modify web/sites/templates/database_edit.htm and add between client_group_id and type around line 39:
(copied from ftp_user_edit.htm)

Code:

<div class="ctrlHolder">
    <label for="parent_domain_id">{tmpl_var name='parent_domain_id_txt'}</label>
    <select name="parent_domain_id" id="parent_domain_id" class="selectInput">
                                      {tmpl_var name='parent_domain_id'}
    </select>
  </div>

To define the domain dropdown in the form modify /usr/local/ispconfig/interface/web/sites/form/database.tform.php and add between server_id and type around line 72:
(copied from ftp_user.tform.php)
Code:

'parent_domain_id' => array (
                        'datatype'      => 'INTEGER',
                        'formtype'      => 'SELECT',
                        'default'      => '',
                        'datasource'    => array (      'type'  => 'SQL', 'querystring' => "SELECT domain_id,domain FROM web_domain WHERE type = 'vhost' AND {AUTHSQL} ORDER BY domain",'keyfield'=> 'domain_id','valuefield'=> 'domain'
                                                ),
                        'value'        => ''
),

Add to the table web_database the field parent_domain_id after server_id with INT unsigned default 0.


All times are GMT +2. The time now is 01:56.

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