Toon posts:

[PHP]The PHP CGI cannot be accessed directly

Pagina: 1
Acties:

Verwijderd

Topicstarter
hoi,

Ik probeer een scriptje en ik krijg dit als melding :
HTTP/1.1 400
Date: Thu, 05 May 2005 09:48:42 GMT
Server: Apache/2.0.44 (Win32) mod_perl/1.99_08 Perl/v5.8.6
Content-Length: 643
Connection: close
Content-Type: text/html; charset=ISO-8859-1

<b>Security Alert!</b> The PHP CGI cannot be accessed directly.

<p>This PHP CGI binary was compiled with force-cgi-redirect enabled. This
means that a page will only be served up if the REDIRECT_STATUS CGI variable is
set, e.g. via an Apache Action directive.</p>
<p>For more information as to <i>why</i> this behaviour exists, see the <a href="http://php.net/security.cgi-bin">manual page for CGI security</a>.</p>
<p>For more information about changing this behaviour or re-enabling this webserver,
consult the installation file that came with this distribution, or visit
<a href="http://php.net/install.windows">the manual page</a>.</p>
Dus ik google wat rond en zie bijvoorbeeld op http://codewalkers.com/archives/phpcoding/7365.html
First thing you need to do is change the line in php.ini so it is cgi.force_redirect = Off

Then - and this is where I tore my hair out for a while - if you have your php.ini in the /windows directory, ensure there there isn't also a default php.ini in the PHP directory as it seems to read that one first.
Dus eerste wat ik deed was de php.ini in mijn php path hernoemen als .bak, zodat de php.ini in mijn windows path gebruikt word. In die php.ini (c:\windows\) heb ik de line :
cgi.force_redirect = 1
veranderd naar
cgi.force_redirect = 0
en heb me toen me script opnieuw gerunt. En toen kreeg ik dit als repsonse :
HTTP/1.1 200 OK
Date: Thu, 05 May 2005 09:54:08 GMT
Server: Apache/2.0.44 (Win32) mod_perl/1.99_08 Perl/v5.8.6
X-Powered-By: PHP/4.3.11
Connection: close
Content-Type: text/html; charset=ISO-8859-1

MZÿÿ¸@𺴠Í!¸LÍ!This program cannot be run in DOS mode.

$…˜SvÁù=%Áù=%Áù=%ºå1%Æù=%Bå3%Àù=%®æ7%Êù=%®æ9%Ãù=%£æ.%Çù=%Áù<%où=%÷ß7%Åù=%ÿ;%Àù=%>Ù9%Åù=%RichÁù=%PELõÆJBà``@jp@ÐP‚ä`txÀpÄ.text€[` `.rdata4p p@@.data(&@À.rsrcÀ @@SU‹l$VW‹|$…í‹õv‹\$SVWè2ƒÄ…Àt
ø+ðuë_‹Å^][Ãÿ´r@‹Å_+Æ^][Ãÿ8t@…Àu5¡°r@‹T$‹‹‹Lˆü‹‹L$‹P‹D$RPQÿ4t@ƒÄ3Ò…ÀžÂJ#ÂËD$=@r¸@‹
Ìp@‹T$ƒÁ QPjRÿÐp@ƒÄÃÿ8t@…Àu ‹D$…Àt‹@Pÿ<t@ƒÄƒøÿu$ÿ%´r@‹
Ìp@ƒÁ QÿÈp@ƒÄƒøÿuÿ%´r@Ãì¡°r@SV‹´$3Û‹‰\$‰\$‹‹DŜü€x1u^¸[ÄÃUL$W‹=r@Qh¸‘@ÿ׃ăøÿu‰\$T$Rh°‘@ÿ׋-”r@ƒÄƒøÿ¡°r@u‰\$ë9\$u‹‹‹LŜüytÈto9\$t9‹‹‹T‘ü‹Ŝ€;Ët'Qh¨‘@D$$hPÿ˜r@ƒÄ=~&¸ë‹‹‹DŜüT$‹HtQh˜‘@Rÿœr@ƒÄ
en dit gaat nog een tijdje door ;-)

Mijn specs:

- windows xp home
- precompiled Apache (http://www.indigostar.com...htm#About%20Indigo%20Perl) : Apache 2.0.48
- PHP 4.3.4

help?

Verwijderd

bij alle PHP scripts...? En post eens wat code

Verwijderd

Topicstarter
nee niet bij alle ... gaat specifiek over de NuSoap toolkit.

Dit is mijn code

server.php:

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

$NAMESPACE='urn:hellowsdl';

// Pull in the NuSOAP code
require_once('lib/nusoap.php');

// Create the server instance
$server = new soap_server();

// Initialize WSDL support
$server->configureWSDL('hellowsdl', $NAMESPACE);
$server->wsdl->schemaTargetNamespace = $NAMESPACE;

// Register the method to expose

$server->register('hello',              // method name
    array('name' => 'xsd:string'),      // input parameters
    array('return' => 'xsd:string'),    // output parameters
    'urn:hellowsdl',                    // namespace
    'urn:hellowsdl#hello',              // soapaction
    'rpc',                              // style
    'encoded',                          // use
    'Says hello to the caller'          // documentation
);



// Define the method as a PHP function
function hello($name) {
        return 'Hello, ' . $name;
}

// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

?>



client.php (dat is de script die ik aanroep) :
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the client instance

$client = new soapclient('http://localhost/server.php?wsdl', true);

// Check for an error
$err = $client->getError();
if ($err) {
    // Display the error
    echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
    // At this point, you know the call that follows will fail
}
// Call the SOAP method
//$person = array('firstname' => 'Willi', 'age' => 22, 'gender' => 'male');
$name="My name";

$result = $client->call('hello', array('name' => $name));
// Check for a fault
if ($client->fault) {
    echo '<h2>Fault</h2><pre>';
    print_r($result);
    echo '</pre>';
} else {
    // Check for errors
    $err = $client->getError();
    if ($err) {
        // Display the error
        echo '<h2>Error</h2><pre>' . $err . '</pre>';
    } else {
        // Display the result
        echo '<h2>Result</h2><pre>';
        print_r($result);
    echo '</pre>';
    }
}
// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
// Display the debug messages
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
?>


Als je de wsdl betand wilt zien : http://www.leihitu.nl/soap/server.php.
Als ik de wsdl oproep (vanaf client.php) die op www.leihitu.nl staat dan gaat het gewoon goed. Maar op mijn localhost niet.

[ Voor 21% gewijzigd door Verwijderd op 05-05-2005 12:09 ]


  • Radiant
  • Registratie: Juli 2003
  • Niet online

Radiant

Certified MS Bob Administrator

Je krijgt bij die foutmelding een link naar de installatie manual van PHP voor windows, waarschijnlijk heb je die niet goed opgevolgt, dus misschien moet je die nog maar eens doornemen en kijken wat je precies fout hebt gedaan bij de installatie.

  • gorgi_19
  • Registratie: Mei 2002
  • Laatst online: 20-08 11:40

gorgi_19

Kruimeltjes zijn weer op :9

Ik zie hier eerder een configuratie of een installatieprobleem in dan een programmeerprobleem :)

>> Software Algemeen

Digitaal onderwijsmateriaal, leermateriaal voor hbo