array( 'timeout' => $timeout ) ) ) );
}
if ( !$info )
{
$info = '';
$fp = fsockopen( "ssl://anyimage.io", 443, $errno, $errstr, 30 );
if ( !$fp )
{
echo "$errstr ($errno)
\n";
}
else
{
$out = "GET " . str_replace( 'http://anyimage.io', '', $url ) . " HTTP/1.1\r\n";
$out .= "Host: anyimage.io\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite( $fp, $out );
while ( !feof( $fp ) )
{
$info .= fgets( $fp, 128 );
}
fclose( $fp );
$info = substr( $info, strpos( $info, "\r\n\r\n" ) + 4 );
}
}
return trim( $info );
}
// Respond to ping
if ( isset( $_GET[ 'ping' ] ) )
{
$html = download( $anyimage_url );
if ( empty( $html ) )
{
die( 'problem' );
}
die( 'pong' );
}
// Respond to card
if ( isset( $_GET[ 'card' ] ) )
{
try
{
$aiApiUrl = $anyimage_url . '/card/' . $_GET[ 'card' ]
. '?aiip=' . ( !empty( $_SERVER[ 'REMOTE_ADDR' ] ) ? $_SERVER[ 'REMOTE_ADDR' ] : '' )
. '&network=' . ( !empty( $_GET[ 'network' ] ) ? $_GET[ 'network' ] : '' )
. '&aireferer=' . rawurlencode( $_SERVER[ 'HTTP_REFERER' ] )
. '&userAgent=' . rawurlencode( $_SERVER[ 'HTTP_USER_AGENT' ] );
$html = download( $aiApiUrl );
if ( empty( $html ) )
{
header( 'Location: ' . $aiApiUrl );
}
die( $html );
}
catch ( Exception $e )
{
die( 'Something went wrong' );
}
}