Jump to content

Archived

This topic is now archived and is closed to further replies.

mikelmao

[SOLVED] PHP Returning problem

Recommended Posts

It wont put the Return of GUID in a string. I echo the array, and it shows nothing in the array.

Code:

guid_send.php:

 

<?php
$addr = $_SERVER['SERVER_NAME'];
$sock = fsockopen('return_guid.php', 80);
$request = "POST /***.php HTTP/1.1\r\n".
           "Host: ******.info\r\n".
           "Connection: Close\r\n".
           "User-Agent: *********\r\n".
           "Content-Type: application/x-www-form-urlencoded\r\n".
           "Content-Length: ". strlen('webaddr='.urlencode($addr)) ."\r\n\r\n".
           "webaddr=".urlencode($addr);
fwrite($sock, $request);
while($buf = fgets($sock))
{
  if(preg_match('/^result=(0|1)$/', $buf, $matches))
  {
    $result = (int)$matches[1];
  }
  elseif(preg_match('/^guid=([A-Z0-9\-]+)$/', $buf, $matches))
  {
    $guid = $matches[1];
  }
    echo $matches ."<br />";
}

echo "This is the current GUID: ". $guid;

fclose($sock);
?>

 

return_guid.php:

 

<?php
include 'connect.php';

function rand_string($c, $l, $u = FALSE) {
if (!$u) for ($s = '', $i = 0, $z = strlen($c)-1; $i < $l; $x = rand(0,$z), $s .= $c{$x}, $i++);
else for ($i = 0, $z = strlen($c)-1, $s = $c{rand(0,$z)}, $i = 1; $i != $l; $x = rand(0,$z), $s .= $c{$x}, $s = ($s{$i} == $s{$i-1} ? substr($s,0,-1) : $s), $i=strlen($s));
return $s;
}

if($_SERVER['HTTP_USER_AGENT'] == '*******' && !empty($_POST['webaddr']))
{
  echo 'result=1';
  do {
    $gui = rand_string('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',4).'-'.rand_string('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',4).'-'.rand_string('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',4).'-'.rand_string('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',4);
  } while(mysql_num_rows(mysql_query('SELECT guid FROM guids WHERE guid = \''.$gui.'\'')));
  if(mysql_query('INSERT INTO guids (guid, address, ip, working) VALUES("'.$gui.'", "'.realEscape($_POST['webaddr']).'",
     "'.$_SERVER['REMOTE_ADDR'].'", 1)')){
      echo 'guid='.$gui;
  }
  else
      echo 0;
}
?>

 

 

What could be the problem? thanks

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.