<?php
function vbulletin_register($values){
$host_details = parse_url($values["url"]);
$host = $host_details["host"];
$vbulletin_path = $host_details["path"];
if(!ereg("/$",$vbulletin_path))
$vbulletin_path.= "/";
$vbulletin_values = array(
"s" => "",
"do" => "addmember",
"url" => urlencode($values["url"]),
"agree" => "1",
"password_md5" => "",
"passwordconfirm_md5" => "",
"username" => $values["username"],
"password" => $values["password"],
"passwordconfirm" => $values["password"],
"email" => $values["email"],
"emailconfirm" => $values["email"],
"referrername" => "",
"timezoneoffset" => "0",
"dst" => "2",
"options[adminemail]" => "1"
);
while(list($key,$val) = each($vbulletin_values)){
$post_string.= $key."=".urlencode($val)."&";
}//while
$post_string = rtrim($post_string,"&");
$fp = fsockopen ($host, 80, $errno, $errstr);
if($fp){
fputs($fp, "POST ".$vbulletin_path."register.php HTTP/1.1\r\n");
fputs($fp, "Host: ".$host."\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($post_string)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $post_string . "\r\n\r\n");
$line = "";
while (!feof($fp)) {
$line.= fgets ($fp,1024);
}//while
fclose ($fp);
}//if
return true;
}//vbulletin_register
function vbulletin_login($values){
$host_details = parse_url($values["url"]);
$host = $host_details["host"];
$vbulletin_path = $host_details["path"];
if(!ereg("/$",$vbulletin_path))
$vbulletin_path.= "/";
$vbulletin_values = array(
"s" => "",
"do" => "login",
"forceredirect" => "1",
"vb_login_md5password" => "",
"vb_login_md5password_utf" => "",
"vb_login_username" => $values["username"],
"vb_login_password" => $values["password"],
"cookieuser" => "1"
);
while(list($key,$val) = each($vbulletin_values)){
$post_string.= $key."=".urlencode($val)."&";
}//while
$post_string = rtrim($post_string,"&");
$fp = fsockopen ($host, 80, $errno, $errstr);
if($fp){
fputs($fp, "POST ".$vbulletin_path."login.php HTTP/1.1\r\n");
fputs($fp, "Host: ".$host."\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($post_string)."\r\n");
fputs($fp, "User-Agent: ".$_SERVER["HTTP_USER_AGENT"]."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $post_string."\r\n\r\n");
$line = "";
while (!feof($fp)) {
$line.= fgets ($fp,1024);
}//while
fclose ($fp);
}//if
$line = ereg_replace("\r","",$line);
$lines = explode("\n",$line);
foreach($lines as $header){
if(eregi("^Set-Cookie",$header)){
preg_match_all("/^Set-Cookie: ([^=]+)=([^;]+);/",$header,$matches);
$name = $matches[1][0];
$value = urldecode($matches[2][0]);
preg_match_all("/expires=([^;]+);/",$header,$matches);
$expire_string = $matches[1][0];
if($expire_string)
$expire = strtotime($expire_string);
else
$expire = 0;
load_cookie($name,$value,$expire);
}//if
}//foreach
return true;
}//vbulletin_login
function vbulletin_logout($values){
$host_details = parse_url($values["url"]);
$host = $host_details["host"];
$vbulletin_path = $host_details["path"];
if(!ereg("/$",$vbulletin_path))
$vbulletin_path.= "/";
$vbulletin_values = array(
"do" => "logout",
"u" => $GLOBALS["Get"]->cookie("bbuserid")
);
while(list($key,$val) = each($vbulletin_values)){
$post_string.= $key."=".urlencode($val)."&";
}//while
$post_string = rtrim($post_string,"&");
$fp = fsockopen ($host, 80, $errno, $errstr);
if($fp){
fputs($fp, "POST ".$vbulletin_path."login.php HTTP/1.1\r\n");
fputs($fp, "Host: ".$host."\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($post_string)."\r\n");
$cookies = "";
while(list($key,$val) = each($_COOKIE)){
$cookies.= $key."=".urlencode($val)."; ";
}//while
$cookies = rtrim($cookies,'; ');
fputs($fp, "Cookie: ".$cookies."\n");
fputs($fp, "User-Agent: ".$_SERVER["HTTP_USER_AGENT"]."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $post_string."\r\n\r\n");
$line = "";
while (!feof($fp)) {
$line.= fgets ($fp,1024);
}//while
fclose ($fp);
}//if
$line = ereg_replace("\r","",$line);
$lines = explode("\n",$line);
foreach($lines as $header){
if(eregi("^Set-Cookie",$header)){
preg_match_all("/^Set-Cookie: ([^=]+)=([^;]+);/",$header,$matches);
$name = $matches[1][0];
$value = urldecode($matches[2][0]);
preg_match_all("/expires=([^;]+);/",$header,$matches);
$expire_string = $matches[1][0];
if($expire_string)
$expire = strtotime($expire_string);
else
$expire = 0;
load_cookie($name,$value,$expire);
}//if
}//foreach
return true;
}//vbulletin_logout
function vbulletin_link($values){
return rtrim($values["url"],"/")."/index.php";
}//vbulletin_link
?> |