Файл: obiead/admin.php
Строк: 733
<link rel="stylesheet" href="inc/css.css">
<script src="inc/modules.js"></script>
<?
//////////////////////////////////////////////////////////////////
// --obieAD-- //
// //
// -The AD banner management- //
// -Version 1.2 created on Dec/02- //
// //
// Writen by Minh Nguyen Duong @ obie. //
// All right reserved - http://obiewebsite.sourceforge.net //
// //
// obiePAD included //
// //
// This Software is FREE and can be modified //
// and redistributed under the condition that //
// the copyright and information above stays //
// intact and with the script. //
// //
// If you redistribute obieAD, please link back //
// to http://obiewebsite.sourceforge.net //
//////////////////////////////////////////////////////////////////
include "config.php";
$tongsosubmit = sizeof (file($submitfile)) - 1;
$tongsodata = sizeof (file($adsfile)) - 1;
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
function checkexits(){
global $submitfile;
global $adsfile;
global $noexits;
$noexits=0;
$file=file($submitfile);
while(list(,$value)=each($file)){
list($fname,$femail,$furl,$fbanner,$fuser,$fpass,$fcounter,$ferror,$blank)=split( "|", $value);
if($username==$fuser){
$noexits=1;
}
}
$file=file($adsfile);
while(list(,$value)=each($file)){
list($fname,$femail,$furl,$fbanner,$fuser,$fpass,$fcounter,$ferror,$blank)=split( "|", $value);
if($username==$fuser){
$noexits=1;
}
}
}
function cchmod($x){
if (is_writable($x)==1) {}
else print("<p>File: <b>$x</b> is <font color=red>not writeable</font> (click <a href="javascript:setchmod('$x');" title="Require PHP4. If files can not be CHMOD, you must CHMOD files manually">here</a> to CHMOD it)");
}
function setjsfile($jscontent,$style){
$fp = fopen ("obiead.js", "w+");
fwrite ($fp, "//obieAD.js file for the STYLE " .$style ."nn");
fwrite ($fp, $jscontent);
fwrite ($fp, "nn//obieAD coden//Generated by obieAD http://obiewebsite.sourceforge.netn");
fclose ($fp);
}
Function output($thisFile) {
$fd = fopen( $thisFile, "r" );
$contents = fread( $fd, filesize( $thisFile ) );
fclose($fd);
$myContents1 = str_replace("<","<",$contents);
$myContents = str_replace(">",">",$myContents1);
print $myContents;
}
if($a_u==$admin_username && $a_p==$admin_password){
//HEADER
print("<table border=0 cellpadding=1 cellspacing=1 width=100% bgcolor=#F0F0F0>
<tr><td width=150 align=center valign=top>");
include "inc/admin_cp.php";
print("</td><td width=99% bgcolor=#FFFFFF align=right valign=top>");
if ($action == 'gencode'){
$p1 = $PATH_INFO;
list($sp,$vutdi) = explode("/admin.php", $p1);
print("<h3>Code generated successfully</h3>
<p>Your changes in config.php file has been saved.
<p>FAQ : <a href="javascript:" onClick="return openclosediv('xem')">How do I add banner to my webpages</a> (Click to open/close)<BR><BR>
<div id=xem style="display:none;">
<p><font size=2>To showing the AD banner in your webpages, choose one of two ways below:</font>
<p align="center"><font size=2><b>Typical (recommended) : </b></font>Add this code into HTML webpages<hr size=1 color=black>
<br><table border=0 bgcolor=#F0F0F0><TR><TD align=left valign=top>Works with all types. Eg: *.html, *.htm, *.shtml, *.php, *.phtml, *.php3, *.asp, *.cgi ....
<br>It's very simple and easy, I 'm using this way for my AD banners<p>
<font color=brown face=courrier><script src="$script_path/obiead.js"></script></font>
<p><u>Note:</u> The "include" function at header of the file : <b>ad.php</b> must be : <font color=brown face=courrier>include "config.php";</font></td></tr></table>
<p align="center"><font size=2><b>Advanced : </b></font>Include obieAD to PHP webpages<br><hr size=1 color=black>
<br><table border=0 bgcolor=#F0F0F0><TR><TD align=left valign=top><u>Step one :</u> open the file <b>ad.php</b> (as a text editor, Notepad is example) and replace the line<br>
<font color=brown face=courrier>include "config.php";</font><br>as the line<br><font color=brown face=courrier>include "$sp/config.php";</font>
<p><u>Step two :</u> add this line to PHP pages : <font color=brown face=courrier><? include "$sp/ad.php"; ?></font>
<p><u>Note:</u> You may choose only ONE of two ways.<br>If you choose this way, you do not need to generate code after changes<br>
<br><u><font color=red>Note 2:</font></u> If you use this way but the AD not shows correctly, you must open two files :<b>ad.php</b> and <b>obiead.js</b> to change your own SERVER PATH. (some servers run under safe mode and the SERVER PATH not be generated automatically)</p>
</td></tr></table>");
if ($style==1) {
$jscontent = 'document.write("<iframe width=' .$w .' height=' .$h .' marginheight=0 marginwidth=0 scrolling=no frameborder=0 src=' .$script_path .'/ad.php></iframe>");';
setjsfile($jscontent,$style);
}
else if ($style==2){
$chieudai=($w + 15)*$numicons;
$jscontent = 'document.write("<iframe width=' .$chieudai .' height=' .$h .' marginheight=0 marginwidth=0 scrolling=no frameborder=0 src=' .$script_path .'/ad.php></iframe>");';
setjsfile($jscontent,$style);
}
else if ($style==3){
$chieurong=($h + 15)*$numicons;
$jscontent = 'document.write("<iframe width=' .$w .' height=' .$chieurong .' marginheight=0 marginwidth=0 scrolling=no frameborder=0 src=' .$script_path .'/ad.php></iframe>");';
setjsfile($jscontent,$style);
}
else print("Administrators must set the style of obieAD in the config.php file");
}
if($action=='del' && $ad){
$file=file($adsfile);
while(list(,$value)=each($file)){
list($fname,$femail,$furl,$fbanner,$fuser,$fpass,$fcounter,$ferror,$blank)=split( "|", $value);
if($ad==$fuser && $ad!='root'){
$xaucu="$fname|$femail|$furl|$fbanner|$fuser|$fpass|$fcounter|$ferror|n";
$xaumoi="";
$fp = fopen($adsfile, "r");
$data = fread($fp, filesize($adsfile));
fclose($fp);
$newdata = str_replace($xaucu, $xaumoi, $data);
$fp = fopen($adsfile,"w");
fwrite($fp,$newdata) or die ("error writing");
fclose($fp);
$succ = "1";
/////////////////NEW in obieAD 1.2/////////////////////////////
$pos = strpos($fbanner, "^");
if($pos===false){}
else if($pos == 0 && $add!=1) {
$adpath = str_replace('^/','',$fbanner);
unlink($adpath);
}
//END
if($move==1) echo "<p align=left><font size=2>Banner <b>$ad</b> moved to SUBMITER database</font><br><br><i>Please wait, I will transfer you to where you came....</i></p><script>run('admin.php?a_u=$a_u&a_p=$a_p&action=viewall');</script>";
else echo "<p align=left><font size=2>Deleted banner <b>$ad</b> from database</font><br><br><i>Please wait, I will transfer you to where you came....</i><script>run('admin.php?a_u=$a_u&a_p=$a_p&action=viewall');</script>";
}
}
}
if($action=='delsubmit' && $ad){
$file=file($submitfile);
while(list(,$value)=each($file)){
list($fname,$femail,$furl,$fbanner,$fuser,$fpass,$fcounter,$ferror,$blank)=split( "|", $value);
if($ad==$fuser && $ad!='root'){
$xaucu="$fname|$femail|$furl|$fbanner|$fuser|$fpass|$fcounter|$ferror|n";
$xaumoi="";
$fp = fopen($submitfile, "r");
$data = fread($fp, filesize($submitfile));
fclose($fp);
$newdata = str_replace($xaucu, $xaumoi, $data);
$fp = fopen($submitfile,"w");
fwrite($fp,$newdata) or die ("error writing");
fclose($fp);
$succ = "1";
/////////////////NEW in obieAD 1.2/////////////////////////////
$pos = strpos($fbanner, "^");
if($pos===false){}
else if($pos == 0 && $add!=1) {
$adpath = str_replace('^/','',$fbanner);
unlink($adpath);
}
//END
if($add==1) echo "<p align=left><font size=2>Banner <b>$ad</b> added to database</font><br><br><i>Please wait, I will transfer you to where you came....</i></p><script>run('admin.php?a_u=$a_u&a_p=$a_p&action=submit');</script>";
else echo "<p align=left><font size=2>Deleted submiter <b>$ad</b> from submiter database</font><br><br><i>Please wait, I will transfer you to where you came....</i><script>run('admin.php?a_u=$a_u&a_p=$a_p&action=submit');</script>";
}
}
}
if($action=='add' && $ad){
checkexits();
$file=file($submitfile);
while(list(,$value)=each($file)){
list($fname,$femail,$furl,$fbanner,$fuser,$fpass,$fcounter,$ferror,$blank)=split( "|", $value);
if($ad==$fuser){
$ferror = 0;
$xaucu="$fname|$femail|$furl|$fbanner|$fuser|$fpass|$fcounter|$ferror|n";
$adadd = $xaucu;
$xaumoi="";
}
}
if($noexits==0){
$fp2=fopen($adsfile,"a");
fwrite($fp2,$adadd);
fclose($fp2);
//Mail content
if ($yesmail==1){
$fbanner = str_replace("^",$script_path,$fbanner);
$mailmessage="Hi,
We added your banner AD to our system.
Your AD info :
--------------
Username: $fuser
Password: $fpass
Banner URL: $fbanner
You can show all banners at : $script_path/func.php?action=showall
and edit your account at : $script_path/login.php
Thanks for using our services
$admin_email
$admin_website";
mail($femail, "Your banner added", $mailmessage, "From: $admin_emailrn" ."Reply-To: $admin_emailrn" ."X-Mailer: PHP/" . phpversion());
}
print("<script>location.href='admin.php?a_u=$a_u&a_p=$a_p&action=delsubmit&ad=$ad&add=1';</script>");
}
else print("<p>ERROR: Username <b>$ad</b> has been used</p>");
}
if($action=='move' && $ad){
checkexits();
$file=file($adsfile);
while(list(,$value)=each($file)){
list($fname,$femail,$furl,$fbanner,$fuser,$fpass,$fcounter,$ferror,$blank)=split( "|", $value);
if($ad==$fuser){
$ferror = 0;
$xaucu="$fname|$femail|$furl|$fbanner|$fuser|$fpass|$fcounter|$ferror|n";
$adadd = $xaucu;
$xaumoi="";
}
}
if($noexits==0){
$fp2=fopen($submitfile,"a");
fwrite($fp2,$adadd);
fclose($fp2);
print("<script>location.href='admin.php?a_u=$a_u&a_p=$a_p&action=del&ad=$ad&move=1';</script>");
}
else print("<p>ERROR: Username <b>$ad</b> has been used</p>");
}
if($action=='viewall'){
$file=file($adsfile);
$file = array_reverse($file);
$sf = sizeof($file);
if(!$page) $page=0;
$i = 0;
print("<h3>Database manager (" .($sf-1) ." members/" .(filesize($adsfile)-38) ." bytes)<br><font size=1>TIPS: Move your mouse over the image to showing infomations of it</font></h3>
<table width=100% border=0 cellpadding=1 cellspacing=2 bgcolor=#F0F0F0><tr><td width=1% align=center valign=middle background="inc/nentable.gif"><img src=blank width=1 height=26></td>
<td width=10% background="inc/nentable.gif" align=center valign=middle><b>Action</b></td><td width=450 background="inc/nentable.gif" align=center valign=middle><b>Banners</b></td>");
print("</tr>");
while(list(,$value)=each($file)){
list($fname,$femail,$furl,$fbanner,$fuser,$fpass,$fcounter,$ferror)=split( "|", $value);
if ($fuser!='root'){
if($i<($page*$entry_on_page + $entry_on_page) && $i>=($page*$entry_on_page)){
$xaucu="$fname|$femail|$furl|$fbanner|$fuser|$fpass|$fcounter|$ferror|n";
$fbanner = str_replace('^/','',$fbanner);
//$fbanner = str_replace('/','\',$fbanner);
print("<tr bgcolor=white><td width=1%>".($i+1)."</td>");
print("<td width=1%>
<a href="edit.php?mode=norm&a_u=$a_u&a_p=$a_p&action=login&username=$fuser&password=$fpass"><img src=inc/edit.gif border=0 width=10 height=10>Edit</a>
<br><a href="admin.php?a_u=$a_u&a_p=$a_p&action=move&ad=$fuser" onmouseover="mota('Move this banner to SUBMITER database');" onmouseout="tatmota();"><img src=inc/move.gif border=0 width=10 height=10>Move</a>
<br><a href="admin.php?a_u=$a_u&a_p=$a_p&action=del&ad=$fuser&move=0"><img src=inc/del.gif border=0 width=10 height=10>Delete</a>
</td>");
print("<td width=450><a href="$furl" target="_blank"><img src="$fbanner" width=$w height=$h border=0 onmouseover="mota('<b>Sitename</b> : $fname <br> <b>Banner</b> : $fbanner <br> <b>Email</b> : $femail <br> <b>Username</b> : $fuser <br> <b>Password</b> : $fpass <br> <b>Clicks</b> : $fcounter <br> <b>Error</b> : $ferror');" onmouseout="tatmota();"></a></td>");
}}
$i++;
}
print("</table><p><br></p>");
$tongsotrang=floor($sf/$entry_on_page)+1;
print("There are <b>$tongsotrang</b> pages<br>");
if($page!=0) print(" <a href="admin.php?a_u=$a_u&a_p=$a_p&action=viewall&page=" .($page-1) .""><img border=0 src=inc/prev.gif></a> ");
if($page*$entry_on_page<$sf-$entry_on_page-1) print(" <a href="admin.php?a_u=$a_u&a_p=$a_p&action=viewall&page=" .($page+1) .""><img border=0 src=inc/next.gif></a> </center>");
if ($tongsodata==0){print("<h4>Dabatase is empty</h4>");}
}
if($action=='submit'){
$file=file($submitfile);
$file = array_reverse($file);
$sf = sizeof($file);
if(!$page) $page=0;
$i = 0;
print("<h3>Submiter database manager (" .($sf-1) ." submiters/" .(filesize($submitfile)-38) ." bytes)<br><font size=1>TIPS: Move your mouse over the image to showing infomations of it</font></h3>
<table width=100% border=0 cellpadding=1 cellspacing=2 bgcolor=#F0F0F0><tr><td width=1% align=center valign=middle background="inc/nentable.gif"><img src=blank width=1 height=26></td>
<td width=10% background="inc/nentable.gif" align=center valign=middle><b>Action</b></td><td width=450 background="inc/nentable.gif" align=center valign=middle><b>Banners</b></td>");
print("</tr>");
while(list(,$value)=each($file)){
list($fname,$femail,$furl,$fbanner,$fuser,$fpass,$fcounter,$ferror)=split( "|", $value);
if ($fuser!='root'){
if($i<($page*$entry_on_page + $entry_on_page) && $i>=($page*$entry_on_page)){
$xaucu="$fname|$femail|$furl|$fbanner|$fuser|$fpass|$fcounter|$ferror|n";
$fbanner = str_replace('^/','',$fbanner);
print("<tr bgcolor=white><td width=1%>".($i+1)."</td>");
print("<td width=1%>");
if ($ferror>=$max) $xacnhan='onclick="return confirm('This is BAD imagennAre you sure to add it to your database','');"';
print("<a href="admin.php?a_u=$a_u&a_p=$a_p&action=add&ad=$fuser" onmouseover="mota('If banner is OK, ADD it to database');" onmouseout="tatmota();" $xacnhan><img src=inc/add.gif border=0 width=10 height=10>ADD</a>
<br><a href="edit.php?action=login&username=$fuser&password=$fpass&a_u=$a_u&a_p=$a_p"><img src=inc/edit.gif border=0 width=10 height=10>Edit</a>
<br><a href="admin.php?&a_u=$a_u&a_p=$a_p&action=delsubmit&ad=$fuser&add=0"><img src=inc/del.gif border=0 width=10 height=10>Delete</a>
</td>");
print("<td width=450>");
if ($ferror>=$max) print("<font color=red>Bad image</font><br>");
print("<a href="$furl" target="_blank"><img src="$fbanner" width=$w height=$h border=0 onmouseover="mota('<b>Sitename</b> : $fname <br> <b>Banner</b> : $fbanner <br> <b>Email</b> : $femail <br> <b>Username</b> : $fuser <br> <b>Password</b> : $fpass <br> <b>Clicks</b> : $fcounter <br> <b>Error</b> : $ferror');" onmouseout="tatmota();"></a></td>");
}}
$i++;
}
print("</table><p><br></p>");
$tongsotrang=floor($sf/$entry_on_page)+1;
print("There are <b>$tongsotrang</b> pages<br>");
if($page!=0) print(" <a href="admin.php?a_u=$a_u&a_p=$a_p&action=submit&page=" .($page-1) .""><img border=0 src=inc/prev.gif></a> ");
if($page*$entry_on_page<$sf-$entry_on_page-1) print(" <a href="admin.php?a_u=$a_u&a_p=$a_p&action=submit&page=" .($page+1) .""><img border=0 src=inc/next.gif></a> </center>");
if ($tongsosubmit==0){print("<h4>Submiter dabatase is empty</h4>");}
}
if ($action=='backup'){
$file2backup = 'obieAD_backup.txt';
$backuptime = date("m/j/y");
if(!$createbackup){
print("<h3>Backup data</h3><p>Files have been added to archive: config.php , $adsfile, $submitfile</p>
<Textarea name="backupdata" cols=60 rows=18 wrap=off style="background-color: #F0F0F0;">");
print("obieAD backup file. Created on $backuptime (mm/dd/yy)nn");
print("nn--------------------File: $adsfile (database)--------------------nn");
output($adsfile);
print("nn--------------------File: $submitfile (submiter database)--------------------n");
output($submitfile);
print("nn--------------------File: config.php (configuration file)--------------------n");
output("config.php");
print("nn--------------------End of backup file--------------------n");
print("obieAD backing up tool.nCopyright (c) http://obiewebsite.sourceforge.net. All right reserved.");
print("</Textarea>
<input type=button value="Copy to clipboard" onclick="copycode();">");
}
}
if(!$action){
print("<h3>ObieAD version $obieADversion control panel<br><font size=1>Welcome to obieAD control panel</font></h3>
<div align=left><img src=inc/blank.gif height=30 width=1>");
cchmod('config.php');
cchmod($adsfile);
cchmod($submitfile);
cchmod('obiead.js');
cchmod($termcontent);
cchmod('index.php');
print("<IFRAME width='0' height='0' scrolling='no' frameborder='0' src='#' name='chmodfr'></IFRAME>");
print("<p align=center><img src=inc/blank.gif height=100 width=1><br><img src=logo.gif></p>");
}
//END OF ADMIN CP FUNCTIONS
//FOOTER
print("</td></tr></table>");
}
?>
<?
//Admin login form
if($a_u!=$admin_username && $a_p!=$admin_password){
print("<center>
<h3>obieAD Control Panel<br><font size=1>Staff only</font></h3><p>
<form action="$PHP_SELF" method="POST">
Username <input type=text name="a_u" size=20><br>
Password <input type=password name="a_p" size=20><br>
<input type=submit value="Log me in">
</form>
<body onload="document.all.a_u.focus();">
</center>");}
?>
<p></p><p align="center">
Powered by <a target="_blank" href="http://obiewebsite.sourceforge.net"><b>obie</b>AD</a> version <? print($obieADversion); ?>. The AD banners management</p>
<?
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
printf("<center>Page loaded in %f seconds.</center>", $totaltime);
?>