<?php

include "../inc/session.php";
include "../config.php";
include "../inc/memberfunctions.php";
include "../inc/functions.php";
include "../style.php";

$adtype=$_GET["adtype"];
if($adtype=="admin") {
                $adminsoloresult = adminsoloquery($userid,$memtype);
                $adminsolo_row_count = mysql_num_rows($adminsoloresult);
                if($adminsolo_row_count) {
                echo "<H2 align=\"center\">You have unread admin messages to view</H2>";
                echo "<table width=100% border=0 cellpadding=2 cellspacing=0>";
	        while ($adminsololine = mysql_fetch_array($adminsoloresult)) {
  	            $id = $adminsololine["id"];
	            $subject = $adminsololine["subject"];
                    $subject2 = truncat($subject, 60);
	            $message = $adminsololine["message"];
	            $url = $adminsololine["url"];
                    $credits = $adminsololine["credits"];    
                    $num = $adminsololine["num"]; 
                    $name = trim($name);
                    $firstname = substr($name , 0, strpos($name, " "));
                    $soloadbody = str_replace("~userid~",$userid,str_replace("~fname~", $name, $adminsololine["message"]));
                    $solosubject = truncat($adminsololine["subject"], 60);
                    $solosubject2 = str_replace("~userid~",$userid,str_replace("~fname~",$name,$solosubject));

  	         ?>
                 <tr>
                  <td bgcolor="#000000"><font size=3 face="<?php echo $fonttype; ?>" color="#FFFFFF"><b><?php echo $solosubject2; ?></b></font></td>
                 </tr>
                 <tr>
                  <td bgcolor="#E6E8FA"><font size=2 face="<?php echo $fonttype; ?>" color="<?php echo $fontcolour; ?>"><div style="width: 550px; height: 200px; padding: 4px; overflow:auto; border-style: solid; border-size: 1px; border-color: #000000; background: #ffffff;"><?php echo stripslashes($soloadbody); ?></div></font></td>
                 </tr>
                 <?php
                 echo "<tr><td bgcolor=\"#E6E8FA\">";
                 echo "<a href=/earn.php?t=21&u=$uid&adid=$id&num=$num target=NEW>";
                 echo "<center><b>^^Click here to view this website for ".$credits." credits^^</b></center></a>";
                 echo "</td></tr>";
                 echo "<tr><td bgcolor=\"#E6E8FA\"><br><br><br></td></tr>";
                 }
                 echo "</table></center>" ;
                 } else echo "<p><center>No admin messages to view.</p></center>";
                 echo "</td></tr></table></font></div>";


}


if($adtype=="text") {
                $textsresult = textquery($userid);
                $text_row_count = mysql_num_rows($textsresult);
                if($text_row_count) {
                $textearn=adearn(5,$userid,$memtype,"");
                echo "<H2 align=center>You have unread text link ads to view</H2>";
                echo "<div align=center>You will earn $textearn credits for each link viewed";
                echo "<table bgcolor=#3D3D3D cellpadding=10 width=\"100%\" border=0>";
                $i=0;
                while($textinfo = mysql_fetch_array($textsresult)) {
		$textsubject=$textinfo['subject'];
		$textshortsubject = truncat($textsubject, 40);
                $bg=tbcolor($i);
                $i=$i+1;
 		echo "<tr><td bgcolor=".$bg." align=left><a href=\"/earn.php?t=5&u=$uid&adid=".$textinfo['id']."&num=".$textinfo['num']."\" target=\"_blank\"><u>".$textshortsubject."</u></a></td></tr>";
                updatetextadstats($textinfo['id']);
		}
		echo "</table>";
	        } else echo "<p><center>No text link ads to view.</p></center>";
                echo "</font></td></tr></table></div>";


}


if($adtype=="banner") {


                $bannerresult = bannerquery($userid);
                $banner_row_count = mysql_num_rows($bannerresult);
                if($banner_row_count) { 
                $bannerearn=adearn(7,$userid,$memtype,"");
                echo "<H2 align=\"center\">You have unviewed banner ads to view</H2>";
                echo "<div align=\"center\">You will earn $bannerearn credits for each link viewed";
                echo "<table bgcolor=#3D3D3D cellpadding=10 width=\"100%\" border=0>";
                $i=0;
                while($bannerinfo = mysql_fetch_array($bannerresult)) {
		$bannerurl=$bannerinfo['bannerurl'];
                if($bannerurl) {
                $bg=tbcolor($i);
                $i=$i+1;
 		  echo "<tr><td bgcolor=".$bg." align=center><a target=\"_blank\"  title=\"Click and earn $bannerearn credits\" href=\"/earn.php?t=7&u=$uid&adid=".$bannerinfo['id']."&num=".$bannerinfo['num']."\"><img src=".$bannerinfo['bannerurl']." width=\"468\" height=\"60\" border=\"0\"></a></td></tr>";
                updatebannerstats($bannerinfo['id']);
		}
                }
		echo "</table>";
	        } else echo "<p><center>No 468x60 banner ads to view.</p></center>";
                echo "</font></td></tr></table></div>";

}


if($adtype=="button") {


                $buttonresult = buttonquery($userid);
                $button_row_count = mysql_num_rows($buttonresult);
                if($button_row_count) { 
                $buttonearn=adearn(8,$userid,$memtype,"");
                $buttonearn=buttonearn($userid,$memtype);
                echo "<H2 align=\"center\">You have unviewed banner ads to view</H2>";
                echo "<div align=\"center\">You will earn $buttonearn credits for each link viewed";
                $counter = -1;
		$cols = 3;
                echo "<table bgcolor=#FFFFFF cellpadding=10 width=\"100%\" border=0>";
                while($buttoninfo = mysql_fetch_array($buttonresult)) {
		$buttonurl=$buttoninfo['bannerurl'];
                if($buttonurl) {
                $pos = ( ++$counter % $cols );
		if( $pos === 0 ) {
                $poscols=poscols();
                print $poscols;
                }
                echo "<td align=center><a target=\"_blank\"   title=\"Click and earn $buttonearn credits\" href=\"/earn.php?t=8&u=$uid&adid=".$buttoninfo['id']."&num=".$buttoninfo['num']."\"><img border=\"0\" src=".$buttonurl." width=\"125\" height=\"125\"></a></td>";
                }
	        if( $pos === $cols - 1 ) {
                $poscols2=poscols2();
                print $poscols2;
                }
                }
                if( $counter % $cols !== $cols - 1 ) {
                do {
                $docol=doscols();
                print $docol; 
                }
                while( ++$counter % $cols !== $cols - 1 );
                echo "</tr>";
                updatebuttonstats($buttoninfo['id']);
                }
                echo "</table>";
	        } else echo "<p><center>No 125x125 banner ads to view.</p></center>";
                echo "</font></td></tr></table></div></div>";
 
}

if($adtype=="mcredit") {

                $mcreditresult = mcreditquery($userid);
		$mcredit_row_count = mysql_num_rows($mcreditresult);
                $mcreditearn=adearn(22,$userid,$memtype,"");
                if($mcredit_row_count) {
                echo "<H2 align=\"center\">You have unread credit mails to view</H2>";
                echo "<table width=100% border=0 cellpadding=2 cellspacing=0>";
                while ($mcreditrow = mysql_fetch_array($mcreditresult)) {
                       $mcid = $mcreditrow["id"];
                       }
                $mcreditprocessresult = mcreditprocess($mcid);
                    while($mcreditline = mysql_fetch_array($mcreditprocessresult)) {
  	            $id = $mcreditline["id"];
	            $subject = $mcreditline["subject"];
                    $subject2 = truncat($subject, 60);
	            $message = $mcreditline["message"];
	            $url = $mcreditline["url"];
                    $num = $mcreditline["num"]; 
                    $name = trim($name);
                    $firstname = substr($name , 0, strpos($name, " "));
                    $soloadbody = str_replace("~userid~",$userid,str_replace("~fname~", $name, $mcreditline["message"]));
                    $solosubject = truncat($mcreditline["subject"], 60);
                    $solosubject2 = str_replace("~userid~",$userid,str_replace("~fname~",$name,$solosubject));
  	         ?>
                 <tr>
                  <td bgcolor="#000000"><font size=3 face="<?php echo $fonttype; ?>" color="#FFFFFF"><b><?php echo $solosubject2; ?></b></font></td>
                 </tr>
                 <tr>
                  <td bgcolor="#E6E8FA"><font size=2 face="<?php echo $fonttype; ?>" color="<?php echo $fontcolour; ?>"><div style="width: 550px; height: 200px; padding: 4px; overflow:auto; border-style: solid; border-size: 1px; border-color: #000000; background: #ffffff;"><?php echo stripslashes($soloadbody); ?></div></font></td>
                 </tr>
                 <?php
                 echo "<tr><td bgcolor=\"#E6E8FA\">";
                 echo "<a href=/earn.php?t=22&u=$uid&adid=$id&num=$num target=NEW>";
                 echo "<center><b>^^Click here to view this website for ".$mcreditearn." credits^^</b></center></a>";
                 echo "</td></tr>";
                 echo "<tr><td bgcolor=\"#E6E8FA\"><br><br><br></td></tr>";
                 }
                 echo "</table></center>" ;
                 } else echo "<p><center>No credit mails to view.</p></center>";
                 echo "</font></td></tr></table></div></div>";


}

?> 