Page 1 of 1

Enable HTTP for in fsockopen, php.ini not working!

Posted: Fri Oct 17, 2008 11:10 am
by JAB Creations
I'm running XAMPP and I've found and replaced five php.ini files of...

allow_url_include = Off

...with...

allow_url_include = On

...restarted Apache and nill. Rebooted XP and nill. Uploaded the bloody file to my server and NILL!

Here is my code and the error message included that I'm getting. It's sorta kinda completely time sensitive that I test this to work correctly if I want to score this job so a quick response would be greatly appreciated (I hate asking for one though!) Here is what I have, maybe it's a syntax issue? :|

Code: Select all

<div style="height: 200px;">
<?php
function url_remote($url)
{
 $separator = '&';
 //$separator = '&';//Uncomment this instead separator if you plan to use as part of client XHTML output.
 if (isset($url))
 {$remote_url .= $url.'?';
  foreach ($_POST as $key => $value)
  {
   $remote_url .= urlencode($key).'='.urlencode($value);
   $remote_url .=  $separator;
  }
  return $remote_url;
 }
 else
 {
  return false;
 }
}
$url = $_POST['url'];
//echo url_remote($url);
//include(url_remote($url));
 
 
 
$fp = fsockopen(url_remote($url), 80, $errno, $errstr, <!-- s8) --><img src=\"{SMILIES_PATH}/icon_cool.gif\" alt=\"8)\" title=\"Cool\" /><!-- s8) -->;
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
}
//else {echo 'success';}
 else {
    $out = "GET / HTTP/1.1\r\n";
    $out .= "Host: http://www.example.com\r\n";
    $out .= "Connection: Close\r\n\r\n";
 
    fwrite($fp, $out);
    while (!feof($fp)) {
        echo fgets($fp, 128);
    }
    fclose($fp);
}
 
 
 
?>
</div>
<form action="" method="post">
<fieldset>
<legend>Add Game</legend>
<div><label for="name_first">First Name</label><input id="name_first" name="name_first" type="text" value="John" /></div>
<div><label for="name_last">Last Name</label><input id="name_last" name="name_last" type="text" value="Smith" /></div>
<div><label for="url">URL</label><input id="url" name="url" type="text" value="http://localhost/" /></div>
</fieldset>
 
<fieldset>
<legend>Game Tags</legend>
<div><label for="cat_1"><input checked="checked" class="checkbox" id="cat_1" name="cat_1" type="checkbox" value="1" />Action</label></div>
<div><label for="cat_2"><input checked="checked" class="checkbox" id="cat_2" name="cat_2" type="checkbox" value="2" />Adventure</label></div>
<div><label for="cat_3"><input checked="checked" class="checkbox" id="cat_3" name="cat_3" type="checkbox" value="3" />Arcade</label></div>
<div><label for="cat_4"><input checked="checked" class="checkbox" id="cat_4" name="cat_4" type="checkbox" value="4" />Family</label></div>
<div><label for="cat_5"><input checked="checked" class="checkbox" id="cat_5" name="cat_5" type="checkbox" value="5" />Puzzle</label></div>
<div><label for="cat_6"><input checked="checked" class="checkbox" id="cat_6" name="cat_6" type="checkbox" value="6" />Role Player</label></div>
<div><label for="cat_7"><input checked="checked" class="checkbox" id="cat_7" name="cat_7" type="checkbox" value="7" />Sports</label></div>
</fieldset>
 
<fieldset>
<legend>Options</legend>
<div><input class="button" type="submit" value="Add this game now!" /></div>
</fieldset>
</form>

Re: Enable HTTP for in fsockopen, php.ini not working!

Posted: Fri Oct 17, 2008 11:17 am
by JAB Creations
basically, you cant feed a full uri as the target parameter.
...trying this now then...

Re: Enable HTTP for in fsockopen, php.ini not working!

Posted: Fri Oct 17, 2008 11:26 am
by JAB Creations
I need to work on following directions!

This works!

Code: Select all

<div style="height: 200px;">
<?php
function url_remote($url)
{
 $separator = '&';
 //$separator = '&';//Uncomment this instead separator if you plan to use as part of client XHTML output.
 if (isset($url))
 {
  $remote_url .= $url.'?';
  foreach ($_POST as $key => $value)
  {
   $remote_url .= urlencode($key).'='.urlencode($value);
   $remote_url .=  $separator;
  }
 file_get_contents($remote_url);
 }
}
 
// Working example from the form below...
$url = $_POST['url'];
 
file_get_contents(url_remote($url));
 
 
?>
</div>
<form action="" method="post">
<fieldset>
<legend>Add Game</legend>
<div><label for="name_first">First Name</label><input id="name_first" name="name_first" type="text" value="John" /></div>
<div><label for="name_last">Last Name</label><input id="name_last" name="name_last" type="text" value="Smith" /></div>
<div><label for="url">URL</label><input id="url" name="url" type="text" value="http://localhost/" /></div>
</fieldset>
 
<fieldset>
<legend>Game Tags</legend>
<div><label for="cat_1"><input checked="checked" class="checkbox" id="cat_1" name="cat_1" type="checkbox" value="1" />Action</label></div>
<div><label for="cat_2"><input checked="checked" class="checkbox" id="cat_2" name="cat_2" type="checkbox" value="2" />Adventure</label></div>
<div><label for="cat_3"><input checked="checked" class="checkbox" id="cat_3" name="cat_3" type="checkbox" value="3" />Arcade</label></div>
<div><label for="cat_4"><input checked="checked" class="checkbox" id="cat_4" name="cat_4" type="checkbox" value="4" />Family</label></div>
<div><label for="cat_5"><input checked="checked" class="checkbox" id="cat_5" name="cat_5" type="checkbox" value="5" />Puzzle</label></div>
<div><label for="cat_6"><input checked="checked" class="checkbox" id="cat_6" name="cat_6" type="checkbox" value="6" />Role Player</label></div>
<div><label for="cat_7"><input checked="checked" class="checkbox" id="cat_7" name="cat_7" type="checkbox" value="7" />Sports</label></div>
</fieldset>
 
<fieldset>
<legend>Options</legend>
<div><input class="button" type="submit" value="Add this game now!" /></div>
</fieldset>
</form>

...and I'm sending this to him in an email now! *breathes*