Archive for January, 2008
Pass $_post Variables Without Forms
by GizzmoAsus on Jan.11, 2008, under PHP Code
Intro
Ever wanted to send variables to another script without clogging up the URI? Well the following is a function which allows you to do just that:
Usage
To use this function just call it
$something = sendPost($URL_of_the_file_you_want_to_pass_the_variables_to, $an_array_containing_the_variables_you_wish_to_send)
Note: The array needs to be made up in the following way:
$context = array( 'post_variable1' => 'post_value1', 'post_variable2' => 'post_value2', 'post_variable3' => 'post_value3' );
Code
function sendPost($url, $context)
{
$context = array_change_key_case($context, CASE_LOWER);
$contextSize = sizeof($context);
$contextKeys = array_keys($context);
$data = "";
foreach ($contextKeys as $key)
{
$amp = "&";
if (next($contextKeys) === FALSE) { $amp = ""; }
$data .= urlencode($key)."=".urlencode($context[$key]).$amp;
}
list($host,$url) = explode('/',$url,2);
$sock = fsockopen($host,80,$errno,$errstr,1);
if (!$sock) { die("$errstr ($errno) in ".__FILE__." (".__LINE__.")\n"); }
$http_request = "POST /".$url." HTTP/1.1\r\n";
$http_request .= "Host: ".$host."\r\n";
$http_request .= "Content-type: application/x-www-form-urlencoded\r\n";
$http_request .= "Content-length: " . strlen($data) . "\r\n";
$http_request .= "Accept: */*\r\n";
$http_request .= "\r\n";
$http_request .= "$data\r\n";
$http_request .= "\r\n";
fwrite($sock,$http_request);
$response_headers = array();
while ($str = trim(fgets($sock)))
array_push($response_headers,$str);
fclose($sock);
$errors = true;
$errorMsg = "";
foreach($response_headers as $response_header){
if($response_header == 'HTTP/1.1 200 OK'){
$errors = false;
}elseif($response_header == 'X-UFU: OK'){
$errors = false;
}
}
if (!$errors)
return true;
else
return false;
}
Enjoy and please free to leave a comment if you use this code
Online Directories – Customer Street
by GizzmoAsus on Jan.10, 2008, under Web
Well as some of you may have read I recently started working for a company based in Lancaster, Customer Street who deal with online directories and portals. Since starting there my main responsibility has been carrying out upgrades to the online directories in order to improve both functionality and usability. These can be found at:
Feel free to leave comments about what you think about them.
According to a few online ranking systems, UFindUs is the second largest online directory behind Yell.com and is constantly on the rise.