
26th December 2005, 01:48
|
|
Senior Member
|
|
Join Date: Dec 2005
Location: Chile
Posts: 245
Thanks: 4
Thanked 3 Times in 2 Posts
|
|
Will I have to "include" it in my tool?
Code:
include("/root/ispconfig/scripts/lib/config.lib.php");
Or there is another way in the api to do this?
Last edited by danf.1979; 26th December 2005 at 04:04.
|

26th December 2005, 10:51
|
|
Senior Member
|
|
Join Date: Dec 2005
Location: Chile
Posts: 245
Thanks: 4
Thanked 3 Times in 2 Posts
|
|
Ok, OK. I have been progressing a lot in the php-nuke installer.
Here you have a screenshot:

What the script does till now, is:
Create directories and copy the all necessary files to run php-nuke in any given web. Admin, a reseller or a client can use it.
I have a problem though...
This is how my config.lib.php looks right now:
Code:
# php-nuke install function
function make_install_phpnuke($web_id, $username, $path_to_create) {
$web_id = intval($web_id);
exec("mkdir $path_to_create");
system("cp -R /var/www/installers/php-nuke/html/* $path_to_create");
system("chown -R $username:web$web_id $path_to_create");
}
class isp_web
{
var $FILE = "/root/ispconfig/scripts/lib/config.lib.php";
var $directory_mode = "0755";
var $web_doctype_id = 1013;
var $user_doctype_id = 1014;
.
.
.
etc
I have included config.lib.php in /home/admispconfig/.../tools/test2/install.php that process the form (the picture)
install.php runs fine, but I think that when included in install.php the function make_install_phpnuke() does not run with root priviledges, so the code
Code:
system("chown -R $username:web$web_id $path_to_create");
does not work. Am I right about this?
Then, I know that when you create an email user that will be the administrator, the directory permissions are changed, and you told me (falko) that only config.lib.php runned with root priviledges, so I guess the code is that changed permissions is in there. I cant find it though.
Can you help me with this?
I'm almost there... almost. And good news is that developing new installers will be very similar.
Thank you.
Last edited by danf.1979; 26th December 2005 at 10:53.
|

26th December 2005, 11:43
|
|
Senior Member
|
|
Join Date: Dec 2005
Location: Chile
Posts: 245
Thanks: 4
Thanked 3 Times in 2 Posts
|
|
Uhm, I was looking at write.conf. I think it's structure does what I want. I found a code that teached me I had to put my function inside the class isp_web() and then make a new instance of the class in tools/test2/install.php and then call my function as a method of that class (am I right?).
Now my make_install_phpnuke() function is inside class isp_web()
Code:
class isp_web
{
var $FILE = "/root/ispconfig/scripts/lib/config.lib.php";
var $directory_mode = "0755";
var $web_doctype_id = 1013;
var $user_doctype_id = 1014;
var $domain_doctype_id = 1015;
var $dns_doctype_id = 1016;
var $a_record_doctype_id = 1018;
var $cname_record_doctype_id = 1019;
var $mx_record_doctype_id = 1020;
var $dienste_doctype_id = 1023;
var $monitor_doctype_id = 1024;
var $firewall_doctype_id = 1025;
var $slave_doctype_id = 1028;
var $datenbank_doctype_id = 1029;
var $spf_record_doctype_id = 1031;
var $vhost_conf;
var $ftp_conf;
var $apache_user;
function make_install_phpnuke($web_id, $username, $path_to_create) {
$web_id = intval($web_id);
print_r(" $web_id ");
exec("mkdir $path_to_create");
system("cp -R /var/www/installers/php-nuke/html/* $path_to_create");
print_r("chown -R $username:web$web_id $path_to_create");
system("chown -R $username:web$web_id $path_to_create");
// chown($path_to_create, $username);
// chgrp ($path_to_create, $web_id);
}
//Constructor
function isp_web() {
global $mod;
.
.
etc
My install.php has (only important code to my problem is seen)
Code:
include_once("/root/ispconfig/scripts/lib/config.lib.php");
.
.
foreach($webs as $web_id => $val) {
$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";
$get_web = $go_api->db->queryOneRecord($query);
$username = $get_web["username"];
print_r(" $username ");
$path_to_create = $httpd_root ."/web".$web_id."/web/".$install_path;
print_r(" $path_to_create ");
// NEW, call instance an method of the class (my function)
$isp_web = new isp_web;
$isp_web->make_install_phpnuke($web_id, $username, $path_to_create);
// END NEW
// if ($val==1) make_install_phpnuke($web_id, $username, $path_to_create);
}
But I execute a test a I get this:
Code:
Fatal error: Call to a member function find_includes() on a non-object in /root/ispconfig/scripts/lib/config.lib.php on line 1772
This is line 1772 (last one):
Code:
function apache_user(){
global $mod;
$httpd_conf = $mod->system->server_conf["dist_httpd_conf"];
$includes = $mod->file->find_includes($httpd_conf);
.
.
etc
Why? How do I fix this? I think this is the solution, but dont know why this error occurs...
Thanks, and sorry for the several post, but I make progress from post to post, so new problems arise, and some get fixed.
Last edited by danf.1979; 26th December 2005 at 12:01.
|

26th December 2005, 13:30
|
|
Senior Member
|
|
Join Date: Dec 2005
Location: Chile
Posts: 245
Thanks: 4
Thanked 3 Times in 2 Posts
|
|
I commented the line
// $this->apache_user = $this->apache_user();
in function isp_web() in class isp_web, file config.lib.php, and now it gives me no error, but no permission changes either!
Code:
//Constructor
function isp_web() {
global $mod;
$this->vhost_conf = $mod->system->server_conf["server_path_httpd_conf"]."/".'vhosts'."/".'Vhosts_ispconfig.conf';
if($mod->system->server_conf["server_ftp_typ"] == "proftpd"){
$this->ftp_conf = "/etc/proftpd_ispconfig.conf";
} else {
$this->ftp_conf = "";
}
// $this->apache_user = $this->apache_user();
}
|

26th December 2005, 13:50
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,665
Thanks: 1,896
Thanked 2,594 Times in 2,445 Posts
|
|
You must not include /root/ispconfig/scripts/lib/config.lib.php in your install.php because then ti will not run with root privileges.
/root/ispconfig/scripts/lib/config.lib.php is called by /root/ispconfig/writeconf.php which itself is called by the /root/ispconfig/sv/ispconfig_wconf daemon which runs as root. This /root/ispconfig/sv/ispconfig_wconf daemon checks every 10 seconds if a file /home/admispconfig/ispconfig/.run exists; if it does, it calls the writeconf.php script.
So you have to modify /root/ispconfig/scripts/lib/config.lib.php and/or /root/ispconfig/scripts/writeconf.php, and whenever your install script is called, it should create /home/admispconfig/ispconfig/.run (add
PHP Code:
touch /home/admispconfig/ispconfig/.run;
to your PHP code) so that writeconf.php is called.
|

26th December 2005, 16:51
|
|
Senior Member
|
|
Join Date: Dec 2005
Location: Chile
Posts: 245
Thanks: 4
Thanked 3 Times in 2 Posts
|
|
uhm, I have a very big doubt. If I cant include config.lib.php, then how can I access my function in the class isp_web?
Is there some "api" way that I'm not aware of?
Thank you for your time.
|

27th December 2005, 05:50
|
|
Senior Member
|
|
Join Date: Dec 2005
Location: Chile
Posts: 245
Thanks: 4
Thanked 3 Times in 2 Posts
|
|
Do you mean I have to put my function inside config.lib.php isp_web class and then put de touch .run in that code so the deamon knows it has to run my function inside config.lib.php as root? Ok, this is what I understood from your explanation, but I dont know how to call my function from config.lib.php, since I cannot include it. I can't figure out the method to do it.
I'm really sorry if I'm being to newbie in this, but my experience is limited (I have only modified phpnuke scripts, but I know google and I dont want to give up). I think I need some guidance on this.
Thank you all.
|

27th December 2005, 13:49
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,665
Thanks: 1,896
Thanked 2,594 Times in 2,445 Posts
|
|
Quote:
|
Originally Posted by danf.1979
Do you mean I have to put my function inside config.lib.php isp_web class and then put de touch .run in that code so the deamon knows it has to run my function inside config.lib.php as root?
|
Yes.
Quote:
|
Originally Posted by danf.1979
Ok, this is what I understood from your explanation, but I dont know how to call my function from config.lib.php, since I cannot include it. I can't figure out the method to do it.
|
You can call your function from /root/ispconfig/scripts/writeconf.php or from any other function in the config.lib.php that you know of that it gets executed.
|

27th December 2005, 14:22
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,911
Thanks: 693
Thanked 4,197 Times in 3,212 Posts
|
|
Maybe some general informations on the structure of ISPConfig will help you to get things clearer. ISPConfig consistsn of 2 parts.
1) The web interface. All files for the webinterface are in the directories /home/admispconfig/ispconfig/ and above. The scripts in the webinterface run as user admispconfig. his user has limited rights and it is not allowed to change files etc.
2) The other part are the scripts in /root/ispconfig. These where executed as root user. They where executed when the run file is set "touch /home/admispconfig/ispconfig/.run".
|

27th December 2005, 18:06
|
|
Senior Member
|
|
Join Date: Dec 2005
Location: Chile
Posts: 245
Thanks: 4
Thanked 3 Times in 2 Posts
|
|
Ok! It worked! (but I have a new problem)
I did put my function on config.lib.php inside isp_web class
this is the function:
Code:
function make_install_phpnuke($web_id, $username, $path_to_create) {
$web_id = intval($web_id);
exec("mkdir $path_to_create");
system("cp -R /var/www/installers/php-nuke/html/* $path_to_create");
system("chown -R $username:web$web_id $path_to_create");
}
writeconf.php has now:
Code:
$isp_web = new isp_web;
$web_id = "8";
$username = "mundohosting";
$path_to_create = "/var/www/web8/web/phpnuke";
$isp_web->make_install_phpnuke($web_id, $username, $path_to_create);
And my install.php has the touch .run file.
Everything works as espected, BUT, as you have noticed, in writeconf.php I have defined all the functions variables...
Code:
$web_id = "8";
$username = "mundohosting";
$path_to_create = "/var/www/web8/web/phpnuke";
Because I dont know how to pass those values from install.php to writeconf.php... I cant think in a simple way to do this, but is there any? Maybe I should create a plain text file with the install data and read it from writeconf.php IF there is another touched file? like for example /home/admispconfig/.install
Is there any other way?
thank you!!
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +2. The time now is 00:05.
|
Recent comments
1 day 12 min ago
1 day 18 min ago
1 day 5 hours ago
1 day 11 hours ago
1 day 12 hours ago
1 day 14 hours ago
1 day 18 hours ago
2 days 58 min ago
2 days 4 hours ago
2 days 6 hours ago