Parker Clack
10-30-2005, 02:54 PM
I have a banner rotation system that I am using with vB version 2.xx and I want to port it over to 3.5
How would I write the following to work with 3.5?
<?php
error_reporting(7);
require('./global.php');
$timenow = time();
$boarduser = $bbuserinfo['userid'];
if(isset($bannerid))
{
$banner = $DB_site->query_first("SELECT * FROM banner WHERE id='$bannerid'");
$url = $banner['redirector_url'];
if (!empty($boarduser))
{
$DB_site->query("UPDATE banner SET userclicks=userclicks+1 WHERE id='$bannerid'");
// is there a user in the table who still has clicked?
$clickeduser = $DB_site->query_first("SELECT * FROM userclicks WHERE userid='$boarduser' AND bannerid='$bannerid'");
$clickeduser = $clickeduser['userid'];
if(!empty($clickeduser))
$DB_site->query("UPDATE userclicks SET clicks=clicks+1 WHERE userid='$boarduser' AND bannerid='$bannerid'");
else
$DB_site->query("INSERT INTO userclicks (userid, bannerid, clicks) VALUES ('$boarduser', '$bannerid', '1')");
}
else
$DB_site->query("UPDATE banner SET guestclicks=guestclicks+1 WHERE id='$bannerid'");
header("Location:$url");
}
else
echo ("Please Include an ID!");
?>
and
<?php
$noheader=1;
//require("./global.php");
set_magic_quotes_runtime(0);
@error_reporting(7);
// ###################### Start init #######################
unset($dbservertype);
//load config
require('./admin/config.php');
// init db **********************
// load db class
$dbservertype = strtolower($dbservertype);
$dbclassname="./admin/db_$dbservertype.php";
require($dbclassname);
$DB_site=new DB_Sql_vb;
$DB_site->appname='vBulletin';
$DB_site->appshortname='vBulletin (forum)';
$DB_site->database=$dbname;
$DB_site->server=$servername;
$DB_site->user=$dbusername;
$DB_site->password=$dbpassword;
$DB_site->connect();
$dbpassword="";
$DB_site->password="";
// end init db
if(isset($bannerid))
{
$banner = $DB_site->query_first("SELECT * FROM banner WHERE id='$bannerid'");
$url = $banner['url_to_banner'];
$update = $DB_site->query("UPDATE banner SET views=views+1 WHERE id='$bannerid'");
header("Location:$url");
}
else
echo ("Please Include an ID!");
?>
Thanks for any help you can give.
Parker
How would I write the following to work with 3.5?
<?php
error_reporting(7);
require('./global.php');
$timenow = time();
$boarduser = $bbuserinfo['userid'];
if(isset($bannerid))
{
$banner = $DB_site->query_first("SELECT * FROM banner WHERE id='$bannerid'");
$url = $banner['redirector_url'];
if (!empty($boarduser))
{
$DB_site->query("UPDATE banner SET userclicks=userclicks+1 WHERE id='$bannerid'");
// is there a user in the table who still has clicked?
$clickeduser = $DB_site->query_first("SELECT * FROM userclicks WHERE userid='$boarduser' AND bannerid='$bannerid'");
$clickeduser = $clickeduser['userid'];
if(!empty($clickeduser))
$DB_site->query("UPDATE userclicks SET clicks=clicks+1 WHERE userid='$boarduser' AND bannerid='$bannerid'");
else
$DB_site->query("INSERT INTO userclicks (userid, bannerid, clicks) VALUES ('$boarduser', '$bannerid', '1')");
}
else
$DB_site->query("UPDATE banner SET guestclicks=guestclicks+1 WHERE id='$bannerid'");
header("Location:$url");
}
else
echo ("Please Include an ID!");
?>
and
<?php
$noheader=1;
//require("./global.php");
set_magic_quotes_runtime(0);
@error_reporting(7);
// ###################### Start init #######################
unset($dbservertype);
//load config
require('./admin/config.php');
// init db **********************
// load db class
$dbservertype = strtolower($dbservertype);
$dbclassname="./admin/db_$dbservertype.php";
require($dbclassname);
$DB_site=new DB_Sql_vb;
$DB_site->appname='vBulletin';
$DB_site->appshortname='vBulletin (forum)';
$DB_site->database=$dbname;
$DB_site->server=$servername;
$DB_site->user=$dbusername;
$DB_site->password=$dbpassword;
$DB_site->connect();
$dbpassword="";
$DB_site->password="";
// end init db
if(isset($bannerid))
{
$banner = $DB_site->query_first("SELECT * FROM banner WHERE id='$bannerid'");
$url = $banner['url_to_banner'];
$update = $DB_site->query("UPDATE banner SET views=views+1 WHERE id='$bannerid'");
header("Location:$url");
}
else
echo ("Please Include an ID!");
?>
Thanks for any help you can give.
Parker