Events Scripts Error

Read 21877 times
Hi.

 Propably this is problem on my site but I can't findy information on google about it.

For testing I have added post-start-server.sh file in scripts folder.

In config property is 'EVENT_SCRIPTS=true'

When I'm trying to restart or start server I'm getting this error:

Code: [Select]
Fatal error: shell_exec(): PHP was not built with process execution support in /usr/local/centovacast/system/include.php on line 262

There is no matter what  post-start-server.sh containing, I'm always getting this error. It dissapera when file is empty.

shell_exec() is working.
I've done test:
Code: [Select]
<?php
$output 
shell_exec('ls -lart');
echo 
"<pre>$output</pre>";
?>


and there was normal output.

Any ideas ?
Thanks -- this needed to be ported to the new v3 systems architecture.  This has been done for the next build and the implementation details are available in the v3 documentation now.
Hi.

I found another issue in 'plugins'

I have created test code for pre-create account and when i'm trying to create one I'm getting following PHP error:
Code: [Select]
Warning: Missing argument 2 for PluginHooks_djp::handle_precreateaccount() in /usr/local/centovacast/system/plugins/djp/hooks.php on line 25

Warning: Missing argument 3 for PluginHooks_djp::handle_precreateaccount() in /usr/local/centovacast/system/plugins/djp/hooks.php on line 25

Warning: Missing argument 4 for PluginHooks_djp::handle_precreateaccount() in /usr/local/centovacast/system/plugins/djp/hooks.php on line 25

Warning: Missing argument 5 for PluginHooks_djp::handle_precreateaccount() in /usr/local/centovacast/system/plugins/djp/hooks.php on line 25

Warning: Missing argument 6 for PluginHooks_djp::handle_precreateaccount() in /usr/local/centovacast/system/plugins/djp/hooks.php on line 25

Warning: Missing argument 7 for PluginHooks_djp::handle_precreateaccount() in /usr/local/centovacast/system/plugins/djp/hooks.php on line 25

Warning: Missing argument 8 for PluginHooks_djp::handle_precreateaccount() in /usr/local/centovacast/system/plugins/djp/hooks.php on line 25

Warning: Missing argument 9 for PluginHooks_djp::handle_precreateaccount() in /usr/local/centovacast/system/plugins/djp/hooks.php on line 25

Warning: Missing argument 10 for PluginHooks_djp::handle_precreateaccount() in /usr/local/centovacast/system/plugins/djp/hooks.php on line 25

Warning: Missing argument 11 for PluginHooks_djp::handle_precreateaccount() in /usr/local/centovacast/system/plugins/djp/hooks.php on line 25

Warning: fopen(http://newairhost.com): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /usr/local/centovacast/system/plugins/djp/hooks.php on line 48

As You can see the fopen command doesn't work, i need that to call external php code. In config url fopen is allowed.


My code:

Code: [Select]
<?php
class PluginHooks_djp extends PluginHooks {

    public function 
install_hooks() {
        
PluginHooks::register('pre-create-account',array(&$this,'handle_precreateaccount'));
    }

    
/**
     * Handles the pre-create-account event
     *
     * @param string $username the username of the account
     * @param string $password the password for the account
     * @param string $email the email address for the account
     * @param string $ipaddress the IP address for the account
     * @param int $port the port number for the account
     * @param int $maxclients the listener limit for the account
     * @param int $maxbitrate the maximum bit rate for the account
     * @param int $transferlimit the data transfer limit for the account
     * @param int $diskquota the disk quota for the account
     * @param int $usesource 1 if the autoDJ is enabled, otherwise 0
     * @param int $mountlimit the mount point limit for the account
     *
     * @return int returns PluginHooks::OK on success, PluginHooks::ERROR on error
     */
     
public function handle_precreateaccount($username,$password,$email,$ipaddress,$port,$maxclients,$maxbitrate,$transferlimit,$diskquota,$usesource,$mountlimit) {

            
$data=array(
        'username' => $username,
        'password' => $password,
        'email' => $email,
    );
$result=$this->makeRequest('testpass',$data);
If($result)
return PluginHooks::OK;
else {
            
$this->set_error($result);
            return 
PluginHooks::ERROR;
}
        
    }

private function makeRequest$pass$data=array('state'=>true),$url='http://domain.com/ace/index/user/mariuszz')
{


mb_internal_encoding('UTF-8');
mb_regex_encoding('UTF-8');
$fp fopen('http://domain.com''r');
$username $data['username'];
if($fp){
$request "GET /ace/index/user/mariuszz HTTP/1.0\r\nUser-Agent:Mozilla/4.0\r\n\r\n";
echo $request;
fwrite($fp$request);
return $fp;
}
else
return FALSE;

}
}
Last Edit: December 13, 2012, 09:58:18 am by Headshaker
Thanks, this has been fixed for the next build! 

FYI, the parameters were incorrectly being passed in an array instead of individually, so if you want a temporary workaround in the meantime so you can continue development, you can temporarily use:

Code: [Select]
public function handle_precreateaccount($args) {
    list($username,$password,$email,$ipaddress,$port,$maxclients,
        $maxbitrate,$transferlimit,$diskquota,$usesource,$mountlimit) = $args;

    // ...
}

Again though, this will be fixed in the next build after which the above workaround will need to be removed.

On a side note, I don't think the code you quoted is doing quite what you want it to do... note that you're returning a file handle $fp from makeRequest() instead of closing it and returning true, and in handle_precreateaccount() you're calling set_error($result) if $result is non-true... which will always be equivalent to set_error(false) instead of a meaningful error message.
Is there any way to enable cUrl extension in CC panel ??

I can't get fopen work.

WIerd thing is that fopen to other domains on my server works but not to one (default one which is set in Plesk panel).

I'm still getting error like above:
Code: [Select]
Warning: fopen(http://domain.com): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /usr/local/centovacast/system/plugins/djp/hooks.php on line 48

When I'm trying do request with fsockopen I'm getting this:

Code: [Select]
HTTP/1.1 403 Forbidden
Date: Thu, 13 Dec 2012 22:09:32 GMT
Server: Apache
Accept-Ranges: bytes
X-Powered-By: PleskLin
Content-Length: 5039
Connection: close
Content-Type: text/html

Along with 'Apache 2 Test Page'

So something is wrong with my server but I have no idea what.

I found that when try open http://domain.com:8000 im getting empty response from server but http://123.456.789.123:8000 works

Any ideas ?
Last Edit: December 13, 2012, 02:22:09 pm by Headshaker
Is there any way to enable cUrl extension in CC panel ??
No, we only build what we need into our PHP binary.  CURL is redundant in PHP5 anyway -- you can use stream context options to do just about anything in native PHP that you could with CURL.

I can't get fopen work.
It looks like fopen is working fine, the remote server is just returning an error.

I'm still getting error like above:
Code: [Select]
Warning: fopen(http://domain.com): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /usr/local/centovacast/system/plugins/djp/hooks.php on line 48
That means your use of fopen() is working just fine -- the remote server is just returning a 403/Forbidden error.  That's a problem on the web server side (nothing to do with Centova cast nor Centova Cast's build of PHP) -- check your web server logs to find out why it's forbidden.

I found that when try open http://domain.com:8000 im getting empty response from server but http://123.456.789.123:8000 works
That port number looks like a stream port but if it's really a web server on that port, you probably just have name-based virtual hosting turned on, in whch case it's normal that an IP addy would return different content than a domain.
"pre-account-status" is giving array as argument, same situation as above

Code: [Select]
public function handle_precreateaccount($args) {
    list($username,$password,$email,$ipaddress,$port,$maxclients,
        $maxbitrate,$transferlimit,$diskquota,$usesource,$mountlimit) = $args;

    // ...
}
Interesting, it looks like there were actually still a substantial number of triggers that had this problem.  Fixed for the next build, thanks!