-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbanners.php
More file actions
132 lines (114 loc) · 3.95 KB
/
Copy pathbanners.php
File metadata and controls
132 lines (114 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/***
* INTEGRATED FLEET MANAGEMENT SYSTEM
* OBSIDIAN FLEET
* http://www.obsidianfleet.net/ifs/
*
* Developer: Frank Anon
* fanon@obsidianfleet.net
*
* Version: 1.11
* Release Date: June 3, 2004
*
* Copyright (C) 2003-2004 Frank Anon for Obsidian Fleet RPG
* Distributed under the terms of the GNU General Public License
* See doc/LICENSE for details
*
* This file based on code from Mambo Site Server 4.0.12
* Copyright (C) 2000 - 2002 Miro International Pty Ltd
*
* Date: 12/9/03
* Comments: Views banners; redirects to proper URL
***/
include ("configuration.php");
switch($op)
{
case "click":
clickbanner($bid, $database, $mpre);
break;
default:
viewbanner($database, $mpre);
}
function viewbanner($database, $mpre)
{
$qry="SELECT * FROM {$mpre}banner WHERE showBanner=1";
$result=$database->openConnectionWithReturn($qry);
$numrows = mysql_num_rows($result);
// Get a random banner (if any exist)
if ($numrows>1)
{
$numrows = $numrows-1;
mt_srand((double)microtime()*1000000);
$bannum = mt_rand(0, $numrows);
}
else
$bannum = 0;
$qry="SELECT bid, imageurl FROM {$mpre}banner WHERE showBanner=1 LIMIT $bannum,1";
$result=$database->openConnectionWithReturn($qry);
if (mysql_num_rows($result)!=0)
{
list($bid, $imageurl) = mysql_fetch_row($result);
$qry="UPDATE {$mpre}banner SET impmade=impmade+1 WHERE bid=$bid";
$database->openConnectionNoReturn($qry);
if($numrows>0)
{
$qry="SELECT cid, imptotal, impmade, clicks, date, name, imageurl
FROM {$mpre}banner WHERE bid=$bid";
$result=$database->openConnectionWithReturn($qry);
list($cid, $imptotal, $impmade, $clicks, $date, $name, $imageurl)
= mysql_fetch_row($result);
// Check if this impression is the last one and print the banner
if($imptotal==$impmade)
{
$qry="INSERT INTO {$mpre}bannerfinish
(cid, name, impressions, clicks, imageurl, datestart, dateend)
VALUES ('$cid', '$name', '$impmade', '$clicks', '$imageurl', '$date', now())";
$database->openConnectionNoReturn($qry);
$qry="DELETE FROM {$mpre}banner WHERE bid=$bid";
$database->openConnectionNoReturn($qry);
}
if ((eregi(".gif", $imageurl)) || (eregi(".jpg", $imageurl)))
{
$imageurl="images/banners/$imageurl";
echo"<a href=\"banners.php?op=click&bid=$bid\">" .
"<img src=\"$imageurl\" border=\"0\" vspace=\"5\" alt=\"Partner Site Banner\" /></a>\n";
}
elseif (eregi(".swf", $imageurl))
{
$imageurl="images/banners/$imageurl";
echo "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" " .
"codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\" " .
"height=\"50\" border=\"5\" VSPACE=\"5\">\n" .
"<param name=\"SRC\" value=\"$imageurl\" />\n" .
"<embed src=\"$imageurl\" loop=\"false\" " .
"pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" " .
"type=\"application/x-shockwave-flash\" height=\"50\" />\n" .
"</object></a>\n";
}
}
}
else
echo " ";
}
/********************************************/
/* Function to redirect the clicks to the */
/* correct url and add 1 click */
/********************************************/
function clickbanner($bid, $database, $mpre)
{
if ($database=="")
{
require("classes/database.php");
$database = new database();
}
$qry="SELECT clickurl FROM {$mpre}banner WHERE bid=$bid";
$result=$database->openConnectionWithReturn($qry);
list($clickurl) = mysql_fetch_row($result);
$qry="UPDATE {$mpre}banner SET clicks=clicks+1 WHERE bid=$bid";
$database->openConnectionNoReturn($qry);
$pat="http://";
if (!eregi($pat, $clickurl))
$clickurl="http://".$clickurl;
header("Location: {$clickurl}");
}
?>