<?php /*!*********************************************************************** ************************************************************************* * \file httpsocket-sample.php * * \author Kai Klenovsek * * \date First Step: 2004-12-22 * * \note <br> * \b THE \bBEER-WARE \bLICENSE <br> * As long as you retain this notice you can do whatever you want with <br> * this stuff. If we meet some day, and you think this stuff is worth it, <br> * you can buy me a beer in return. <br> * * \b NOTES: <br> * *************************************************************************** ***************************************************************************/ // Import PHPLib-Extreme require("../../phplibex.inc.php"); // Create object from class $httpsocket = new httpsocket( "localhost" ); echo "<a href=\"".$SCRIPT_NAME."?action=http_get\">Test http_get()</a><br>"; echo "<a href=\"".$SCRIPT_NAME."?action=http_gethead\">Test http_gethead()</a><br>"; echo "<a href=\"".$SCRIPT_NAME."?action=http_post\">Test http_post()</a><br><br>"; switch ($action) { case "http_get": echo "<b>HTTP_GET() Result:</b><br>"; $http_get = $httpsocket->httpsocket_http_get( "index.html" ); for ( $loop=0; $loop <= sizeof($http_get); $loop++ ) echo htmlentities( $http_get[$loop] ); break; case "http_gethead": echo "<b>HTTP_GETHEAD() Result:</b><br>"; $http_gethead = $httpsocket->httpsocket_http_gethead( "index.html" ); for ( $loop=0; $loop <= sizeof($http_gethead); $loop++ ) echo htmlentities( $http_gethead[$loop] ); break; case "http_post": echo "<b>HTTP_POST() Result:</b><br>"; if ( !$httpsocket->httpsocket_http_post( "index.html", "Hello World") ) echo "Cant post data to server."; else echo "Data posting well done."; break; default: break; } $errors = $httpsocket->httpsocket_get_errorlist(); echo "<br><br><b>Error messages:</b><br>"; for ( $loop=0; $loop <= sizeof($errors); $loop++ ) echo "<b>".$errors[$loop]."</b><br>"; ?>