Sistemini kullanarak içinde PHP bir CGI gömme Sorunu

2 Cevap

Merhaba ben böyle bir cgi-script gömmek için php sistemi kullanıyorum

<?php echo system('./cgi-bin/rebol-include.cgi'); ?>

Sorun benim cgi betiği şunları yazıyor

print "content-type: text/html^/"

PHP göstermek böylece

"content-type: text/html"

html sayfa üzerinde. Bu istenmeyen bir eserdir, bu php gömülü olarak cgi döndürülen bir bütün html sayfası bilerek kaldırmak için en iyi yolu nedir?

2 Cevap

Sistem arka keneler "'" ile ikame edilmiş olabilir ve arka kene sonucu bir alt dize içine sokulabilir.

Bu yüzden

<?= substr(`./cgi-bin/rebol-include.cgi`, strlen('content-type: text/html^/')) ?>

Bu size "içerik-tipi" sonra her şeyi vermelidir.

Siz) (sistem yerine sanal () kullanarak denediniz mi?

virtual() is an Apache-specific function which is similar to in mod_include. It performs an Apache sub-request. It is useful for including CGI scripts or .shtml files, or anything else that you would parse through Apache. Note that for a CGI script, the script must generate valid CGI headers. At the minimum that means it must generate a Content-Type header.

bkz http://php.net/manual/en/function.virtual.php