View Single Post
  #26  
Old 29th October 2008, 14:45
dayjahone dayjahone is offline
Senior Member
 
Join Date: Jan 2007
Posts: 419
Thanks: 31
Thanked 0 Times in 0 Posts
Default

Here is that index.php file:

Code:
<?php

include("../../lib/config.inc.php");
include("../../lib/app.inc.php");

// Lade Soap Klasse
$go_api->uses_obj("soap");


$s = new nusoap_server;


$s->register('service');
$s->register('login');
$s->register('logout');


function login($user, $pass) {

        global $go_api, $go_info;

        // alte Sessions löschen
        $go_api->db->query("DELETE FROM remote_session WHERE tstamp < '".(time() - 1800)."'");

        if(empty($user) or empty($pass)) {
                return new soap_fault('Client','','username or password empty.');
        } else {

                $user = addslashes($user);
                $pass = addslashes($pass);

                $user = $go_api->db->queryOneRecord("SELECT * FROM remote_user WHERE username = '$user' and passwort = md5('$pass')");

                // Checke IP
                if($user["ip"] != '') {
                        if($_SERVER['REMOTE_ADDR'] != $user["ip"]) return new soap_fault('Client','','IP-Address not allowed.');
                }

                if($user["ruserid"] > 0) {

                        $session["user"] = $user;
                        $session_data = addslashes(serialize($session));
                        $session_id = md5 (uniqid (rand()));
                        $go_api->db->query("INSERT INTO remote_session (sid,ruserid,data,tstamp) VALUES ('$session_id','".$user["ruserid"]."','$session_data','".time()."')");
                        return $session_id;

                } else {
                        return new soap_fault('Client','','username or password incorrect.');
                }
        }
}

function logout($sid) {
        global $go_api, $go_info;
        if(empty($sid)) {
                return new soap_fault('Client','','sid empty.');
        } else {
                $sid = addslashes($sid);
                $sql = "DELETE FROM remote_session WHERE sid = '$sid'";
                $go_api->db->query($sql);
                return true;
        }
}


function service($sid, $module, $function, $params) {
        global $go_api, $go_info;

        // prüfe ob session aktiv
        $session = addslashes($session);

        // lösche abgelaufene session records ( älter als 30 minuten)
        $go_api->db->query("DELETE FROM remote_session WHERE tstamp < ".time() + 1800);

        // hole Session
        $session_record = $go_api->db->queryOneRecord("SELECT * FROM remote_session WHERE sid = '$sid'");
        if(empty($session_record["data"])) {
                return new soap_fault('Server','','session not available.');
        } else {
                $session = unserialize(stripslashes($session_record["data"]));
                $ruserid = $session_record["ruserid"];
                unset($session_record);
        }

        // allowed Modules
        $allowed_modules[] = 'dns';
        $allowed_modules[] = 'slave';
        $allowed_modules[] = 'reseller';
        $allowed_modules[] = 'kunde';
        $allowed_modules[] = 'web';

        // überprüfen ob modul und funktion übergeben wurden


        // Checke IP
        if($session["ip"] != '') {
                if($_SERVER['REMOTE_ADDR'] != $session["ip"]) return new soap_fault('Client','','IP-Address not allowed.');
        }


        if(in_array($module,$allowed_modules)) {
                $go_api->uses($module);
                if(class_exists($module)) {
                        if(method_exists($go_api->$module,$function)) {
                                $retval = $go_api->$module->$function($session,$params);
                                if($go_api->$module->errorMessage == '') {
                                        return $retval;
                                } else {
                                        return new soap_fault('Client','',$go_api->$module->errorMessage);
                                }
                        } else {
                                return new soap_fault('Client','','function does not exist.');
                        }
                } else {
                        return new soap_fault('Client','','moduleclass not available.');
                }
        } else {
                return new soap_fault('Client','','module not allowed.');
        }

}





$s->service($HTTP_RAW_POST_DATA);

?>
and here is the error I'm still getting:

Code:
Request

POST /remote/index.php HTTP/1.0
Host: server1.mydomain.com:81
User-Agent: NuSOAP/0.7.3 (1.51)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: ""
Content-Length: 538

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns2885:login xmlns:ns2885="http://tempuri.org"><user xsi:type="xsd:string">roach</user><pass xsi:type="xsd:string">two</pass></ns2885:login></SOAP-ENV:Body></SOAP-ENV:Envelope>
Response

HTTP/1.1 200 OK
Date: Wed, 29 Oct 2008 13:44:42 GMT
Server: Apache
X-Powered-By: PHP/5.2.6
Set-Cookie: PHPSESSID=08d4043c1357535830f5f22b779bc9c6; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Transfer-Encoding: chunked
Content-Type: text/html

<br />
<b>Fatal error</b>:  Call to undefined function xml_parser_create() in <b>/home/admispconfig/ispconfig/lib/classes/ispconfig_soap.obj.php</b> on line <b>6409</b><br />
Error: Response not of type text/xml: text/html
Reply With Quote