Location: PHPKode > projects > phpSC > external/proxy_listen.php
<?php
require_once('../config.php');
error_reporting(0);
ini_set('display_errors', 0); // CHANGE VALUE TO 1 FOR RELEASES //
$conn = _MYSQL_CONNECT;
mysql_select_db(_MYSQL_DB,$conn);
$result = mysql_query("SELECT * FROM servers WHERE id = '".$_GET['server']."' LIMIT 1",$conn) or die (mysql_error());
$data = mysql_fetch_array($result);
echo $tenPercentOfFileInBytes;
$streamToOpen = $data['ip'];
$port = $data['port'];
$path = "/";

header("Content-type: audio/mpeg");
$socket = fsockopen($streamToOpen,$port);

fputs($socket, "GET $path HTTP/1.0\r\n");
fputs($socket, "Host: $streamToOpen\r\n");
fputs($socket, "User-Agent: phpSC\r\n");
fputs($socket, "Accept: */*\r\n");
fputs($socket, "Connection: close\r\n\r\n");

while (!feof($socket)) {
$buffer = fgets($socket, 4096);
echo $buffer;
}

$totalSize = 0;
for ($i=0; $i < $tenPercentOfFileInBytes; ) {
$buffer = fgets($socket);
$strSize = strlen($buffer);
$totalSize = $totalSize + $strSize;
echo "$strSize \n";
$i = $i + $strSize;
echo $buffer;
}

fclose($socket);
?>
Return current item: phpSC