PHP-Nuke and other installers

Discussion in 'Developers' Forum' started by danf.1979, Dec 23, 2005.

  1. falko

    falko Super Moderator Howtoforge Staff Moderator HowtoForge Supporter ISPConfig Developer

    I'd recommend to put those values in a database table, or even better, create a new column in the isp_isp_web table, e.g. "phpnuke" where you put either 0 or 1, and then you can read all values from the database.
     
  2. danf.1979

    danf.1979 ISPConfig Developer ISPConfig Developer

    Uhm, I'm using this query for getting the "username" that would be the "owner" of the web directory:
    Code:
    $go_query = "SELECT * from isp_nodes, sys_user where isp_nodes.doc_id = '$web_id' and isp_nodes.doctype_id = 1013 and sys_user.doc_id = isp_nodes.userid";
    
    But I have realized now that this only gets the ispconfig "Login Data username" and not the "User & Email->new user->admin username" (owner of the web directory).
    I had not realized this earlier because I usually named both users the same, so ispconfig login username was the same as the owner of the directory. Now I know this query does not do what I want, and that is useful only when both usernames are the same.
    From the phpnuke installer *form*, only the web [ID] is passed as useful data to try to retrieve the real owner of the directory then in mysql. But I dont seem able to determine a sql query that retrieves the "user_username" in the table "isp_isp_user" with only the web [ID]. :(
    Any hints?
    I dont want to request the "username" to the user in the form, I want to retrieve it from mysql... Is this possible?
     
    Last edited: Dec 28, 2005
  3. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    You can use this SQL query:

    Code:
    select isp_isp_user.user_username from isp_dep, isp_isp_user WHERE isp_dep.parent_doc_id = $web_id AND isp_dep.parent_doctype_id = 1013 AND isp_dep.child_doctype_id = 1014 AND isp_isp_user.user_admin = 1
    I know its not easy to get started with ISPConfig development :)

    If you need need records that depend to oather records, e.g. Web ==> User or Web ==> Co-Domain you can retrieve them by the isp_dep table. This table includes the Parent (web) doc_id's and the doc_id's of the child records like co-domains and users.
     
  4. danf.1979

    danf.1979 ISPConfig Developer ISPConfig Developer

    Thank you...
    Yes, its not easy, but ispconfig is a great piece of software. That motivates me.
    Well, I had to modify a bit your query. Here is the query that works in the installer:
    Code:
    $go_query = "SELECT isp_isp_user.user_username from isp_isp_user, isp_dep WHERE isp_dep.parent_doc_id =$web_id AND isp_dep.parent_doctype_id = 1013 AND isp_dep.child_doctype_id = 1014 AND isp_dep.child_doc_id = isp_isp_user.doc_id AND isp_isp_user.user_admin = 1 ";
    
    Thanks for the isp_dep tip!
     
    Last edited: Dec 28, 2005
  5. danf.1979

    danf.1979 ISPConfig Developer ISPConfig Developer

    Are Mysql passwords stored some place in ispconfig tables? I would like to make an automated config.php with the name of the mysql database and the mysql password, so the user does nothing but a click to start using phpnuke...
     
  6. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    No, the passwords are only stored encrypted in the mysql "mysql" system database. The best way might be if you ask the user for the password in the installer and let him select the database because every web may have multiple databases.
     
  7. danf.1979

    danf.1979 ISPConfig Developer ISPConfig Developer

    Maybe they should be stored in the database, like in table isp_server field server_db_passwort. Then we could use them for any install script we could develop for configuring automagically all configuration files necessary for the installed CMS to run. I think it would be a nice feature, because we could install everything for a given customer, even without knowing his database password.
     
  8. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    If the passwords are stored in clear text in the isp_server table, it will be a massive security risk. So they are only stored in encrypted form that is irreversible.

    Believe me, its better to ask the user for the password. Thats why the webFTP asks for a password too even if the user is already logged in. Never store user passwords in the database in clear text.
     
  9. danf.1979

    danf.1979 ISPConfig Developer ISPConfig Developer

    Ok, I'll think on something else then. Anyway, I see table isp_server field server_db_passwort in clear text. Is this normal?
     
  10. danf.1979

    danf.1979 ISPConfig Developer ISPConfig Developer

    Is it impossible then for an admin or reseller to install phpnuke package for a client without asking him for his password? (to configure config.php)
    Suppose I get 10 or more phpnuke install request from some clients. Will I have to call all of them for asking the admin password? (suppose I'm not the admin and the actual admin does not know how to configure config.php)
    Thanks.
     
  11. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    In this case the admin has to set a new password. Or your installer creates automatically a new database for each installation incl. new user and pasword.
     
  12. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    Yes, because we need at least one password in clear text to access the database with the ISPConfig Interface. The special problem with userpasswords is, that most users use always the same password. So if you know their database password, you can guess e.g. their email and ftp passwords as well.
     
  13. danf.1979

    danf.1979 ISPConfig Developer ISPConfig Developer

    Yes, I think would be a good solution. Thanks, I'll try to implement it.
     
  14. danf.1979

    danf.1979 ISPConfig Developer ISPConfig Developer

    Could I (in some way) use the root mysql account that use ispconfig for creating new databases and *assign* those databases for a given customer?

    I mean, there is already a piece of code that generates a mysql database for a customer in "optionen"/"Datenbanken Neu". I had a look to the code and found function datenbank_insert, but i also did a string search for this function in /home/admispconfig and realize that it seems that it is not called from anywhere. It exists just as a definition in ispconfig_isp_datenbank.lib.php.

    How does optionen"/"Datenbanken Neu" use this function?
     
  15. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    Yes, thats how the "datenbank_insert function works.

    This function is called by the form for adding databases. The form definition is made with the form designer and so the function call is definied in the doctype definition and you can not find it in the code. Doctype definitions are stored in the doctype table in the database.

    The framework used for ispconfig is event driven and the datenbank_insert function is called after the database add form has been saved the first time.
     
  16. danf.1979

    danf.1979 ISPConfig Developer ISPConfig Developer

    Uhm, this seems even more difficult. It is obvious for me that doctype_def is not there for direct reading. I can't understand a word of it, but I guess its a template system? I think I'll have to learn the form editor to continue ahead?
     
  17. danf.1979

    danf.1979 ISPConfig Developer ISPConfig Developer

    Uhm, ok, I had a look to the form editor form name isp_datenbank. Impressive. I'll make a new one and see what i can achieve.
     
  18. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    You dont have to use the form editor. If you copy the sql queries from the datenbank_insert function that where used to create the database it will be sufficient.
     
  19. danf.1979

    danf.1979 ISPConfig Developer ISPConfig Developer

    Ok, now I ask the user for the database and his password. What I did is to insert temporarily the selected database and the user password in a table. Then writeconf.php erases the data.
    Once is finished I would like to send you the script so you can tell me what you think and comment the code so I can improve it. I would really appreciate it.
    I have work to do yet though. I'm searching for info on how to use the "mysqlimport" command so I can import the "nuke.sql" to populate the database.
     
  20. danf.1979

    danf.1979 ISPConfig Developer ISPConfig Developer

    Uhm, this does not work:
    Code:
    system("mysqlimport --user=$db_user --password=$pass_word $data_base /var/www/installers/php-nuke/sql/nuke.sql");
    
    :confused:
     

Share This Page