Filter:   InfoImg
download banners.php
Language: PHP
LOC: 252
Project Info
Free Market(freemarket)
Server: SourceForge
Type: cvs
...\freemarket\freemarket\www\
   .htaccess
   admin.php
   article.php
   auth.inc.php
   backend.php
   banners.php
   comments.php
   counter.php
   dhtmllib.js
   download.php
   ezhilit.php
   faq.php
   footer.php
   friend.php
   header.php
   index.php
   lang-croatian.php
   lang-danish.php
   lang-dutch.php
   lang-english.php
   lang-french.php
   lang-german.php
   lang-indonesia.php
   lang-indonesian.php
   lang-italian.php
   lang-japanese.php
   lang-korean.php
   lang-latvian.php
   lang-norwegian.php
   lang-polish.php
   lang-portuguese.php
   lang-quebec.php
   lang-russian.php
   lang-simplifiedchinese.php
   lang-slovak.php
   lang-spanish.php
   lang-swedish.php
   lang-TEMPLATE.php
   ...-traditionalchinese.php
   links.php
   mainfile.php
   memberlist.php
   memberslist.php
   pollBooth.php
   pollcomments.php
   postinfo.html
   print.php
   problems.php
   scroller.js
   search.php
   sections.php
   stats.php
   submit.php
   top.php
   topics.php
   user.php

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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<?php

######################################################################
# PHP-NUKE: Web Portal System
# ===========================
#
# Copyright (c) 2000 by Francisco Burzi (fburzi@ncc.org.ve)
# http://phpnuke.org
#
# This modules is to have a complete Banner Ad solution integrated
#
# This program is free software. You can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
######################################################################

if (!isset($config)) { include("config.php"); }
if (eregi("banners.php",$PHP_SELF)) include("mainfile.php");
dbconnect();

/********************************************/
/* Function to display banners in all pages */
/********************************************/

function viewbanner() {
    $bresult = mysql_query("select * from banner");
    $numrows = mysql_num_rows($bresult);

// Get a random banner if exist any.
// More efficient random stuff, thanks to Cristian Arroyo from http://www.planetalinux.com.ar

    if ($numrows>1) {
	$numrows = $numrows-1;
	mt_srand((double)microtime()*1000000);
	$bannum = mt_rand(0, $numrows);
    } else {
	$bannum = 0;
    }
    $bresult2 = mysql_query("select bid, imageurl from banner limit $bannum,1");
    list($bid, $imageurl) = mysql_fetch_row($bresult2);
    
    global $myIP;
    $myhost = getenv("REMOTE_ADDR");
    if($myIP==$myhost) {
    } else {
	mysql_query("update banner set impmade=impmade+1 where bid=$bid");
    }
    if($numrows>0) {
	$aborrar = mysql_query("select cid, imptotal, impmade, clicks, date from banner where bid=$bid");
	list($cid, $imptotal, $impmade, $clicks, $date) = mysql_fetch_row($aborrar);

// Check if this impression is the last one and print the banner

	if($imptotal==$impmade) {
	    mysql_query("insert into bannerfinish values (NULL, '$cid', '$impmade', '$clicks', '$date', now())");
	    mysql_query("delete from banner where bid=$bid");
	}
    echo"<center><a href=banners.php?op=click&bid=$bid target=_blank><img src=$imageurl border=1></a></center><br>";
    }
    mysql_free_result($bresult);
    mysql_free_result($bresult2);
    if($aborrar) {
	mysql_free_result($aborrar);
    }
    
}

/********************************************/
/* Function to redirect the clicks to the   */
/* correct url and add 1 click              */
/********************************************/

function clickbanner($bid) {
    $bresult = mysql_query("select clickurl from banner where bid=$bid");
    list($clickurl) = mysql_fetch_row($bresult);
    mysql_query("update banner set clicks=clicks+1 where bid=$bid");
    mysql_free_result($bresult);
    Header("Location: $clickurl");
}

/********************************************/
/* Function to let your client login to see */
/* the stats                                */
/********************************************/

function clientlogin() {
    echo"
    <html>
    <body bgcolor=AA9985 text=000000 link=006666 vlink=006666>
    <center><br><br><br><br>
    <table width=200 cellpadding=0 cellspacing=1 border=0 bgcolor=000000><tr><td>
    <table width=100% cellpadding=5 cellspacing=1 border=0 bgcolor=FFFFFF><tr><td colspan=1 bgcolor=eecfa1>
    <center><b>Advertising Statistics</b>
    </td></tr><tr><td bgcolor=fffacd>
    <form action=banners.php method=post>
    Login: <input class=textbox type=text name=login size=12 maxlength=10><br>
    Password: <input class=textbox type=password name=pass size=12 maxlength=10><br>
    <input class=textbox type=hidden name=op value=Ok>
    <input type=submit value=Login></td></tr><tr><td bgcolor=eecfa1>
    <font size=2>
    <center>Please type your client information</center>
    </td></tr></table></td></tr></table></form></font>
    </body></html>";
}

/*********************************************/
/* Function to display the banners stats for */
/* each client                               */
/*********************************************/

function bannerstats($login, $pass) {
    if (!isset($config)) { include("config.php"); }
    $result = mysql_query("select cid, name, passwd from bannerclient where login='$login'");
    list($cid, $name, $passwd) = mysql_fetch_row($result);
    
    if($login=="" AND $pass=="" OR $pass=="") {
	echo "<center><br>Login Incorrect!!!<br><br><a href=javascript:history.go(-1)>Back to Login Screen</a></center>";
    } else {
    
    if ($pass==$passwd) {
    
    echo"
    <html>
    <body bgcolor=AA9985 text=000000 link=006666 vlink=006666>
    <center>
    <table border=0 width=100% cellpadding=0 cellspacing=1 bgcolor=000000><tr><td>
    <table border=0 width=100% cellpadding=8 cellspacing=1 bgcolor=fffacd><tr><td>
    <font size=3>
    <center><b>Current Active Banners for $name</b></center><br>
    <font size=3>
    <table width=100% border=0><tr>
    <td bgcolor=887765><font color=Black><center><b>ID</b></td>
    <td bgcolor=887765><font color=Black><center><b>Imp. Made</b></td>
    <td bgcolor=887765><font color=Black><center><b>Imp. Total</b></td>
    <td bgcolor=887765><font color=Black><center><b>Imp. Left</b></td>
    <td bgcolor=887765><font color=Black><center><b>Clicks</b></td>
    <td bgcolor=887765><font color=Black><center><b>% Clicks</b></td>
    <td bgcolor=887765><font color=Black><center><b>Functions</b></td><tr>";
    $result = mysql_query("select bid, imptotal, impmade, clicks, date from banner where cid='$cid'");
    while(list($bid, $imptotal, $impmade, $clicks, $date) = mysql_fetch_row($result)) {
        if($impmade==0) {
    	    $percent = 0;
        } else {
    	    $percent = substr(100 * $clicks / $impmade, 0, 5);
        }

        if($imptotal==0) {
    	    $left = "Unlimited";
        } else {
    	    $left = $imptotal-$impmade;
        }
        echo "
        <td bgcolor=AA9985 align=center><font color=White>$bid</td>
        <td bgcolor=AA9985 align=center><font color=White>$impmade</td>
        <td bgcolor=AA9985 align=center><font color=White>$imptotal</td>
	<td bgcolor=AA9985 align=center><font color=White>$left</td>
        <td bgcolor=AA9985 align=center><font color=White>$clicks</td>
        <td bgcolor=AA9985 align=center><font color=White>$percent%</td>
        <td bgcolor=AA9985 align=center><font color=White><a href=banners.php?op=EmailStats&login=$login&cid=$cid&bid=$bid>E-mail Stats</a></td><tr>";
    }
    echo "
    </td></tr></table>
    <center><br><br>
    Following are your running Banners in $sitename<br><br>";

    $result = mysql_query("select bid, imageurl, clickurl from banner where cid='$cid'");
    while(list($bid, $imageurl, $clickurl) = mysql_fetch_row($result)) {

	$numrows = mysql_num_rows($result);
	if ($numrows>1) {
	    echo "<hr noshade width=80%><br>";
	}

	echo "<img src=$imageurl border=1><br>
	<font size=2>Banner ID: $bid<br>
	Send <a href=banners.php?op=EmailStats&login=$login&cid=$cid&bid=$bid>E-Mail Stats</a> for this Banner<br>
	This Banners points to <a href=$clickurl>this URL</a><br>
	<form action=banners.php method=submit>
	Change URL: <input class=textbox type=text name=url size=50 maxlength=200 value=$clickurl>
	<input class=textbox type=hidden name=login value=$login>
	<input class=textbox type=hidden name=bid value=$bid>
	<input class=textbox type=hidden name=pass value=$pass>
	<input class=textbox type=hidden name=cid value=$cid>
	<input type=submit name=op value=Change></form>";
    }
    echo "
    </td></tr></table></td></tr></table>
    </font>";


// Finnished Banners
    
    echo "
    <center><br>
    <table border=0 width=100% cellpadding=0 cellspacing=1 bgcolor=000000><tr><td>
    <table border=0 width=100% cellpadding=8 cellspacing=1 bgcolor=fffacd><tr><td>
    <font size=3>
    <center><b>Banners Finished for $name</b></center><br>
    <font size=3>
    <table width=100% border=0><tr>
    <td bgcolor=887765><font color=Black><center><b>ID</b></td>
    <td bgcolor=887765><font color=Black><center><b>Impressions</b></td>
    <td bgcolor=887765><font color=Black><center><b>Clicks</b></td>
    <td bgcolor=887765><font color=Black><center><b>% Clicks</b></td>
    <td bgcolor=887765><font color=Black><center><b>Start Date</b></td>
    <td bgcolor=887765><font color=Black><center><b>End Date</b></td><tr>";
    $result = mysql_query("select bid, impressions, clicks, datestart, dateend from bannerfinish where cid='$cid'");
    while(list($bid, $impressions, $clicks, $datestart, $dateend) = mysql_fetch_row($result)) {
        $percent = substr(100 * $clicks / $impressions, 0, 5);
	echo "
        <td bgcolor=AA9985 align=center><font color=White>$bid</td>
        <td bgcolor=AA9985 align=center><font color=White>$impressions</td>
        <td bgcolor=AA9985 align=center><font color=White>$clicks</td>
	<td bgcolor=AA9985 align=center><font color=White>$percent%</td>
        <td bgcolor=AA9985 align=center><font color=White>$datestart</td>
        <td bgcolor=AA9985 align=center><font color=White>$dateend</td><tr>";
    }
echo "
</td></tr></table></td></tr></table></td></tr></table>
<br><a href=http://linuxpreview.org><img src=images/powered/phpnuke.gif border=0 Alt=\"This site Powered by PHP-Nuke\"></a>
</body></html>";
    
    } else {
    echo "<center><br>Login Incorrect!!!<br><br><a href=javascript:history.go(-1)>Back to Login Screen</a></center>";    
    }
    }

}

/*********************************************/
/* Function to let the client E-mail his     */
/* banner Stats                              */
/*********************************************/

function EmailStats($login, $cid, $bid, $pass) {
    if (!isset($config)) { include("config.php"); }
    $result2 = mysql_query("select name, email from bannerclient where cid='$cid'");
    list($name, $email) = mysql_fetch_row($result2);
    if ($email=="") {
	echo "
	<html>
	<body bgcolor=AA9985 text=000000 link=006666 vlink=006666>
	<center><br><br><br>
	<b>Statistics for Banner No. $bid can't be send because<br>
	there isn't an email associated with client $name<br>
	Please contact the Administrator<br><br></b>
	<a href=javascript:history.go(-1)>Back to Banners Stats</a>
	";
    } else {
	$result = mysql_query("select bid, imptotal, impmade, clicks, imageurl, clickurl, date from banner where bid='$bid' and cid='$cid'");
	list($bid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date) = mysql_fetch_row($result);
        if($impmade==0) {
    	    $percent = 0;
        } else {
    	    $percent = substr(100 * $clicks / $impmade, 0, 5);
        }

        if($imptotal==0) {
    	    $left = "Unlimited";
	    $imptotal = "Unlimited";
        } else {
    	    $left = $imptotal-$impmade;
        }
	$fecha = date("F jS Y, h:iA.");
	$subject = "Your Banner Statistics at $sitename";
	$message = "Following are the complete stats for your advertising investment at $sitename:\n\n\nClient Name: $name\nBanner ID: $bid\nBanner Image: $imageurl\nBanner URL: $clickurl\n\nImpressions Purchased: $imptotal\nImpressions Made: $impmade\nImpressions Left: $left\nClicks Received: $clicks\nClicks Percent: $percent%\n\n\nReport Generated on: $fecha";
	$from = "$sitename";
	mail($email, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion());

	echo "
	<html>
	<body bgcolor=AA9985 text=000000 link=006666 vlink=006666>
	<center><br><br><br>
	<b>Statistics for Banner No. $bid has been send to<br>
	<i>$email</i> of $name<br><br></b>
	<a href=javascript:history.go(-1)>Back to Banners Stats</a>
	";
    }
}

/*********************************************/
/* Function to let the client to change the  */
/* url for his banner                        */
/*********************************************/

function change_banner_url_by_client($login, $pass, $cid, $bid, $url) {
    $result = mysql_query("select passwd from bannerclient where cid='$cid'");
    list($passwd) = mysql_fetch_row($result);
    if ($pass==$passwd) {
	mysql_query("update banner set clickurl='$url' where bid='$bid'");
    }
    echo "<center><br>You changed the URL<br><br><a href=javascript:history.go(-1)>Back to Stats Page</a></center>";
}

switch($op) {

    case "click":
	clickbanner($bid);
	break;

    case "login":
	clientlogin();
	break;

    case "Ok":
	bannerstats($login, $pass);
	break;

    case "Change":
	change_banner_url_by_client($login, $pass, $cid, $bid, $url);
	break;

    case "EmailStats":
	EmailStats($login, $cid, $bid, $pass);
	break;
	
    default:
	viewbanner();
	break;
}