News:

Wondering if this will always be free?  See why free is better.

Main Menu

Integration code problem

Started by CLICKBANKS.NET, May 02, 2006, 12:01:36 PM

Previous topic - Next topic

CLICKBANKS.NET

I need to integrates SMF 1.0.7 with this script, i think there are some minor error, can anyone please help me out with this, which part that is missing that i should add or edit.


<?php

function smf_register($values){

$host_details = parse_url($values["url"]);
$host = $host_details["host"];
$smf_path = $host_details["path"];
if(!ereg("/$",$smf_path))
$smf_path.= "http://xxx.com/forum/index.php?action=register";

$smf_values = array(
"username" => $values["username"],
"passwrd1" => $values["password"],
"passwrd2" => $values["password"],



);

while(list($key,$val) = each($smf_values)){
$post_string.= $key."=".urlencode($val)."&";
}//while
$post_string.= "&action=register2";
$fp = fsockopefputs($fp, "POST ".$smf_path."index.php HTTP/1.1\r\n");n ($host, 80, $errno, $errstr);
   
fputs($fp, "POST ".$smf_path."index.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);
   
   return
true;

}
//smf_register

function smf_login($values){

$host_details = parse_url($values["url"]);
$host = $host_details["host"];
$smf_path = $host_details["path"];
if(!ereg("/$",$smf_path))
$smf_path.= "http://xxx.com/forum/index.php?action=login";

$smf_values = array(
"username" => $values["username"],
"passwd" => $values["password"],



);

while(list($key,$val) = each($smf_values)){
$post_string.= $key."=".urlencode($val)."&";
}//while
$post_string.= "&action=register2";

$fp = fsockopen ($host, 80, $errno, $errstr);
   
fputs($fp, "POST ".$smf_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);
   

$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;

}
//smf_login

function smf_logout($values){

$host_details = parse_url($values["url"]);
$host = $host_details["host"];
$smf_path = $host_details["path"];
if(!ereg("/$",$smf_path))
$smf_path.= "http://xxx.com/forum/index.php?action=logout";

$smf_values = array(
"do" => "logout",
"u" => $GLOBALS["Get"]->cookie("bbuserid")
);

while(list($key,$val) = each($smf_values)){
$post_string.= $key."=".urlencode($val)."&";
}//while
$post_string.= "&action=register2";

$fp = fsockopen ($host, 80, $errno, $errstr);
   
fputs($fp, "POST ".$smf_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);
   

$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;

}
//smf_link

function smf_link($values){

return rtrim($values["url"],"/")."/index.php";

}
//smf_link

?>

Dean Williams

I'm sure that: $smf_path.= "http://xxx.com/forum/index.php?action=register"; should be: $smf_path.= "http://xxx.com/forum/";

Advertisement: