GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Banner rotator... (https://gfy.com/showthread.php?t=997813)

djroof 11-16-2010 03:43 PM

Banner rotator...
 
any fast solution pls?

sarettah 11-16-2010 04:07 PM

I have a fairly simple one I use across a bunch of my sites. Uses a 3 table database (banners, links, sites).

Pretty easy to modify out.

Database structure

--
-- Table structure for table `banners`
--

CREATE TABLE IF NOT EXISTS `banners` (
`id` int(10) NOT NULL auto_increment,
`site` int(10) NOT NULL default '0',
`name` varchar(254) NOT NULL,
`type` char(2) NOT NULL,
`width` int(10) NOT NULL default '0',
`height` int(10) NOT NULL default '0',
`last_used` datetime NOT NULL,
`active` tinyint(4) NOT NULL default '1',
PRIMARY KEY (`id`),
KEY `last_used` (`last_used`),
KEY `width` (`width`),
KEY `height` (`height`),
KEY `site` (`site`)
) ENGINE=INNODB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1406 ;


-- --------------------------------------------------------

--
-- Table structure for table `links`
--

CREATE TABLE IF NOT EXISTS `links` (
`id` int(10) NOT NULL auto_increment,
`site` int(10) NOT NULL default '0',
`link` varchar(254) NOT NULL,
`active` tinyint(4) NOT NULL default '1',
PRIMARY KEY (`id`),
KEY `site` (`site`)
) ENGINE=INNODB DEFAULT CHARSET=latin1 AUTO_INCREMENT=83 ;

-- --------------------------------------------------------

--
-- Table structure for table `sites`
--

CREATE TABLE IF NOT EXISTS `sites` (
`id` int(10) NOT NULL auto_increment,
`sponsor` int(10) NOT NULL default '0',
`name` varchar(35) NOT NULL,
`active` tinyint(1) NOT NULL default '1',
PRIMARY KEY (`id`),
KEY `sponsor` (`sponsor`)
) ENGINE=INNODB DEFAULT CHARSET=latin1 AUTO_INCREMENT=75 ;


Actual banner rotation code

// pass ins

// Type sc=softcore, hc=hardcore
// mxw maximum width in pixels
// mxh maximum height in pixels
// mnw minimum width in pixels
// mnh minimum height in pixels

function getad($type, $mxw, $mxh, $mnw, $mnh)
{
$adbhost = "localhost";
$adbuser = "dbusername";
$adbpass = "dbpassword";
$adb = mysql_connect($adbhost, $adbuser, $adbpass);


$sql_str="select a.id, a.name, c.name as sitename, a.height, a.width, b.link ";
$sql_str .="from banners a ";
$sql_str .="inner join links b on a.site=b.site ";
$sql_str .="inner join sites c on a.site=c.id ";
$sql_str .="where a.type='" . $type . "' ";
$sql_str .="and a.width<=" . $mxw . " and a.height<=" . $mxh . " and ";
$sql_str .="a.width>=" . $mnw . " and a.height>=" . $mnh . " ";
$sql_str .="order by a.last_used limit 1";
$result=mysql_query($sql_str,$adb);
if(!$result)
{
//echo "sql prob sql=" . $sql_str . "<br>\n";
}
else
{
$banner=mysql_fetch_array($result);
echo "<a href=" . $banner['link'] . " target=_blank>";
echo "<img src=http://www.yourdomainname.com/images/" . $banner['name'] . " border=0" . ' alt="' . $banner['sitename'] . '">';
echo "</a>";
}
$sql_str="update banners set last_used=now() where id=" . $banner['id'];
$result=mysql_query($sql_str,$adb);
}


How to call it in the page.


getad('sc',480,80,350,50);

borked 11-16-2010 04:07 PM

stick a load of banners in a directory and pull 1 at random?

Fabien 11-16-2010 04:08 PM

Cool thread, keep 'hem coming cause i wanna try a new one too.

djroof 11-16-2010 04:12 PM

thanks!!!!!

Adraco 11-16-2010 04:13 PM

Smart Spots from Smart-Scripts.com?

atom 11-16-2010 04:14 PM

http://www.openx.org/

Jdoughs 11-16-2010 04:16 PM

PHP Code:

<?php
$ad
[] = "<a href=''><img src='' alt='' width='' height='' /></a>";
$ad[] = "<a href=''><img src='' alt='' width='' height='' /></a>";
$ad[] = "<a href=''><img src='' alt='' width='' height='' /></a>";
$ad[] = "<a href=''><img src='' alt='' width='' height='' /></a>";
shuffle($ad);
echo 
$ad[0]; 
?>


Vendzilla 11-16-2010 04:43 PM

http://dynamicdrive.com

wehateporn 11-16-2010 04:46 PM

This is one of the most basic and user friendly HTML rotators ever, it's free as well

http://www.focalmedia.net/htmlrotate.html

sarettah 11-16-2010 05:26 PM

Fuck. When I was sanitizing the code I some how killed a couple of things.

Need a select to the database, or in the sql the database could be specified.

Also there are a couple of other things that should be in there to protect it a touch.

Sorry about that.

a better version of the actual script portion:

Code:

// pass ins
// Type  sc=softcore, hc=hardcore
// mxw maximum width in pixels
// mxh maximum height in pixels
// mnw minimum width in pixels
// mnh minimum height in pixels
function getad($type, $mxw, $mxh, $mnw, $mnh)
{
  // default to softcore if not provided or if invalid
  if($type<>'sc' && $type<>'hc')
  {
    $type='sc';
  }
 
  // check for numeric values in banner dimensions
  // protects against sql injection too
  if(is_numeric($mxw) && is_numeric($mxh) && is_numeric($mnw) && is_numeric($mnh))
  {
    // connection could be a pass in
    // doing it here is for stand alone
    // usually would be in an included function
   
    $adbhost = "localhost";
    $adbuser = "dbusername";
    $adbpass = "dbpassword";
    $adbname = "dbname";
    $adb = mysql_connect($adbhost, $adbuser, $adbpass);
    if($adb)
    {
      // select to the database
      mysql_select_db($adbname,$adb);
     
      // sql to pull the banner
      $sql_str="select a.id, a.name, c.name as sitename, a.height, a.width, b.link ";
      $sql_str .="from banners a ";
      $sql_str .="inner join links b on a.site=b.site ";
      $sql_str .="inner join sites c on a.site=c.id ";
      $sql_str .="where a.type='" . $type . "' ";
      $sql_str .="and a.width<=" . $mxw . " and a.height<=" . $mxh . " and ";
      $sql_str .="a.width>=" . $mnw . " and a.height>=" . $mnh . " ";
      $sql_str .="order by a.last_used limit 1";
      $result=mysql_query($sql_str,$adb);
      if(!$result)
      {
        //echo "sql prob sql=" . $sql_str . "<br>\n";
      }
      else
      {
        //only attempt to present the banner if evrything went ok
        if(mysql_num_rows($result)>0)
        {
          $banner=mysql_fetch_array($result);
          echo "<a href=" . $banner['link'] . " target=_blank>";
          echo "<img src=http://www.yourdomainname.com/images/" . $banner['name'] . " border=0" . ' alt="' . $banner['sitename'] . '">';
          echo "</a>";   
          $sql_str="update banners set last_used=now() where id=" . $banner['id'];
          $result=mysql_query($sql_str,$adb);
        }
        else
        {
          // could do a default banner here
        }
      }
    }
  }
}


ruff 11-16-2010 05:57 PM

Someone posted this Simple Banner Rotator on another thread and I've using it. It's pretty easy to set up and works real well.

http://www.spyka.net/scripts/javascr...banner-rotator

SmokeyTheBear 11-17-2010 08:53 AM

i made/posted this not long ago

fucking-around-and-business-discussion/992905-simple-smart-banner-rotation-tutorial-ghetto-openx.html

Twoface31 11-17-2010 09:05 AM

this is cool ;)

SuzzyQ 11-17-2010 09:17 AM

Quote:

Originally Posted by wehateporn (Post 17704451)
This is one of the most basic and user friendly HTML rotators ever, it's free as well

http://www.focalmedia.net/htmlrotate.html

I use this one on a mainstream site and it works well.

Emil 11-17-2010 09:31 AM

PHP Code:

<?php
srand 
((double)microtime()*1000000);
$f_contents file ("banners.txt");
$line $f_contents[array_rand ($f_contents)];
print 
$line;
?>

Make banners.txt. One line of HTML for the banner on each line.

HomerSimpson 11-17-2010 09:46 AM

small - javascript

big - php (+mysql) custom

huge - openx


if you need any extra help
http://www.awmzone.com/services

IllTestYourGirls 11-17-2010 11:04 AM

Funny I was just looking for one yesterday as well!

Quote:

Originally Posted by Jdoughs (Post 17704375)
PHP Code:

<?php
$ad
[] = "<a href=''><img src='' alt='' width='' height='' /></a>";
$ad[] = "<a href=''><img src='' alt='' width='' height='' /></a>";
$ad[] = "<a href=''><img src='' alt='' width='' height='' /></a>";
$ad[] = "<a href=''><img src='' alt='' width='' height='' /></a>";
shuffle($ad);
echo 
$ad[0]; 
?>


Will this pull them at random? I want them to be different each surfer that comes.


All times are GMT -7. The time now is 07:45 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123