HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Developers' Forum (http://www.howtoforge.com/forums/forumdisplay.php?f=18)
-   -   PHP-Nuke and other installers (http://www.howtoforge.com/forums/showthread.php?t=1810)

danf.1979 23rd December 2005 23:33

PHP-Nuke and other installers
 
I'm developing a PHP-nuke installer in the "Tools" section. I think most installers would be very similar.
If I have a client that owns more than one web, I need a way to "know" in which site he wants to install php-nuke. From what variable can I get this info?
Also I need the user and pass to write in the database. How can I get this values? What scripts should I read?
Thanks

danf.1979 24th December 2005 03:54

What I really need right now is to save the username of the user who executes the tool in $username. How can I accomplish this?

till 24th December 2005 11:10

Quote:

Originally Posted by danf.1979
I'm developing a PHP-nuke installer in the "Tools" section. I think most installers would be very similar.
If I have a client that owns more than one web, I need a way to "know" in which site he wants to install php-nuke. From what variable can I get this info?

I dont that it will work this way, because if you know the username you cannot know in which website phpnuke should be installed. Every user can have an unlimited number of websites in ISPConfig.

You will have to let the user select in which website phpnuke shall be installed. Have a look at the backup tool, this tool shows a list of all sites the user is allowd to backup and the list to delect the phpnuke destination may be similar. Dont forget that you have also an admin and resellers and they might have to install packages for their clients too, but how to get the available sites for a user / admin / reseller this is all handled in the code for the site backups and you can copy it from there.

Quote:

Also I need the user and pass to write in the database. How can I get this values? What scripts should I read?
No, dont write your own database functions. ISPCOnfig uses an database wrapper, if you use native mysql functions your extension might be incompatible to future ISPConfig releases. The database wrapper is in the class /home/admispconfig/ispconfig/lib/classes/ispconfig_mysql.lib.php (or similar name in this directory, dont have the sources here currently).

The database wrapper is already initialized if you have included the two main includes as shown in the other tools. You can call the query function e.g. by: $go_api->db->query("Here comes your SQL");

I recommend having a look at the other tools, they show you how to use the db wrapper for querys and inserts.

till 24th December 2005 11:12

Quote:

Originally Posted by danf.1979
What I really need right now is to save the username of the user who executes the tool in $username. How can I accomplish this?

You can get the username from the $go_info array. Just insert print_r($go_info); in your code and you get a list of all variables available in the session.

danf.1979 24th December 2005 18:23

OK, I love you. I'm making progress, and getting more used to the api.

danf.1979 25th December 2005 00:31

I'm having problems creating the folders with the right permissions. The owner and group is admispconfig, I need it to be user:web[id].
This doesnt seem to work:
Code:

exec("chown $username:web1 $php_nuke_path");
Dont know why. From a console it works OK, but from the php script dont. Does this have something to do with a php feature? (i.e. security?)
How can I get to create the folder with the right permissions? I dont seem able to find the piece of code that generates de /var/www/web[ID] folder when creating a new customer. I think this code could help me. Not sure though.
I'm creating the phpnuke install folder with:
Code:

exec("mkdir $php_nuke_path");
Is this aproach the correct one?
Maybe thereis another way with the ispconfig api. Dont know for sure. I'm just starting to get used to the api.

danf.1979 25th December 2005 01:02

Ok, progress, but still no gold.
I'm using now:
Code:

chown($php_nuke_path, $username);
But, i get this:
Code:

Warning: chown() [function.chown]: Operation not permitted in /home/admispconfig/ispconfig/web/tools/tools/test/install.php on line 66
Command was:
Code:

chown user:web1 /var/www/web1/web/bbb
Change "user" with my real user (it exists).
When I created the web directory "bbb" with mkdir, the owner and group was admispconfig. I dont seem capable o changing that, at least no from a php script.
May be I could do so with a Python script.

danf.1979 25th December 2005 01:42

Ok, I had posted something in here, but I'll just wait for help on the last matter because I' learned already about the "->" thingy.

falko 25th December 2005 13:42

Quote:

Originally Posted by danf.1979
How can I get to create the folder with the right permissions? I dont seem able to find the piece of code that generates de /var/www/web[ID] folder when creating a new customer. I think this code could help me. Not sure though.

This code is in /root/ispconfig/scripts/lib/config.lib.php. This script is run as root so you shouldn't have permission problems if you put your code in there.

danf.1979 25th December 2005 22:17

Ok, so i put my function in /root/ispconfig/scripts/lib/config.lib.php, inside class isp_web right? but then how do I call the function from my tool?
Thank you.


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

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