I Just Finish this script an i thought i should share. This is a Mini Classified script Edited & Coded by Me You can Add it to Your Community Forum such as Lavalair, wapdesire, etc.
The first script is the wapvibes_ads.php
wapvibes_ads.php
The second script is required to delete the Ads from the database every 7 days You can include this in a cron Job or Just include it at the top of Your pages so everytime someone access the page it will run.
delete_ads.php
And here is the sql to the script:
the usage to this script on Your site is:
Also You May Add this line in Your style/style.css
Hope You find this code useful
The first script is the wapvibes_ads.php
wapvibes_ads.php
PHP Code:
<?php
/*
Mini Classified Script Edited & Coded By Anthony wapvibes.net
*/
header("Content-type: text/html; charset=ISO-8859-1");
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";
echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\"\"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
include("config.php");
include("core.php");
$bcon = connectdb();
if (!$bcon)
{
echo "<head><title>$site_name</title>";
echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"style/style.css\" />";
echo "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />
<meta http-equiv=\"Cache-Control\" content=\"no-cache\"/>
<meta name=\"description\" content=\"wapvibes Classified Ads\" />
<meta name=\"keywords\" content=\"buy, sell, trade, services, jobs\" /></head>";
echo "<body>";
echo "<img src=\"images/exit.gif\" alt=\"*\"/><br/>";
echo "ERROR! cannot connect to database<br/><br/>";
echo "This error happens usually when backing up the database, please be patient, The site will be up any minute<br/><br/>";
echo "you can temperoray be in this site <a href=\"http://wapvibes.com\">$site_name</a> while $site_name is offline<br/>";
echo "<b>THANK YOU VERY MUCH</b>";
echo "</p>";
echo "</body></html>";
exit();
}
$brws = explode(" ",$_SERVER[HTTP_USER_AGENT] );
$ubr = $brws[0];
$uip = getip();
$action = $_GET["action"];
$sid = $_GET['sid'];
$page = $_GET["page"];
$who = $_GET["who"];
$uid = getuid_sid($sid);
$site_name = Wapvibes.net;
$uid = getuid_sid($sid);
cleardata();
if(isipbanned($uip,$ubr))
{
if(!isshield(getuid_sid($sid)))
{
echo "<head><title>$site_name</title>";
echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"style/style.css\" />";
echo "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />
<meta http-equiv=\"Cache-Control\" content=\"no-cache\"/>
<meta name=\"description\" content=\"wapvibes Classified Ads\" />
<meta name=\"keywords\" content=\"buy, sell, trade, services, jobs\" /></head>";
echo "<body>";
echo "<p align=\"center\">";
echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";
echo "This IP address is blocked<br/>";
echo "<br/>";
echo "How ever wapvibes grant a shield against IP-Ban for our great users, you can try to see if you are shielded by trying to log-in, if you kept coming to this page that means you are not shielded, so come back when the ip-ban period is over<br/><br/>";
$banto = mysql_fetch_array(mysql_query("SELECT timeto FROM ibwf_penalties WHERE penalty='2' AND ipadd='".$uip."' AND browserm='".$ubr."' LIMIT 1 "));
//echo mysql_error();
$remain = $banto[0] - time();
$rmsg = gettimemsg($remain);
echo " IP: $rmsg<br/><br/>";
echo "</p>";
echo "<p>";
echo "<form align=\"left\" action=\"login.php\" method=\"post\" ENCTYPE=\"multipart/form-data\">";
echo "UserID: <input name=\"loguid\" format=\"*x\" maxlength=\"30\"/><br/>";
echo "Password: <input type=\"password\" name=\"logpwd\" maxlength=\"30\"/><br/>";
echo "<postfield name=\"loguid\" value=\"$(loguid)\"/>";
echo "<postfield name=\"logpwd\" value=\"$(logpwd)\"/>";
echo "<input type=\"submit\" value=\"Login!\"/><br/>";
echo "</form>";
echo "</p>";
echo "</body></html>";
exit();
}
}
if(($action != "") && ($action!="terms"))
{
$uid = getuid_sid($sid);
if((islogged($sid)==false)||($uid==0))
{
echo "<head><title>$site_name</title>";
echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"style/style.css\" />";
echo "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />
<meta http-equiv=\"Cache-Control\" content=\"no-cache\"/>
<meta name=\"description\" content=\"wapvibes Classified Ads\" />
<meta name=\"keywords\" content=\"buy, sell, trade, services, jobs\" /></head>";
echo "<body>";
echo "<p align=\"center\">";
echo "You are not logged in<br/>";
echo "Or Your session has been expired<br/><br/>";
echo "<a href=\"index.php\">Login</a><br/><br/>";
echo "</p>";
echo "</body></html>";
exit();
}
}
//echo isbanned($uid);
if(isbanned($uid))
{
echo "<head><title>$site_name</title>";
echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"style/style.css\" />";
echo "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />
<meta http-equiv=\"Cache-Control\" content=\"no-cache\"/>
<meta name=\"description\" content=\"wapvibes Classified Ads\" />
<meta name=\"keywords\" content=\"buy, sell, trade, services, jobs\" /></head>";
echo "<body>";
echo "<p align=\"center\">";
echo "<img src=\"images/notok.gif\" alt=\"x\"/><br/>";
echo "You are <b>Banned</b><br/>";
$banto = mysql_fetch_array(mysql_query("SELECT timeto FROM ibwf_penalties WHERE uid='".$uid."' AND penalty='1'"));
$banres = mysql_fetch_array(mysql_query("SELECT lastpnreas FROM ibwf_users WHERE id='".$uid."'"));
$remain = $banto[0]- time();
$rmsg = gettimemsg($remain);
echo "Time to finish your penalty: $rmsg<br/><br/>";
echo "Ban Reason: $banres[0]";
//echo "<a href=\"index.php\">Login</a>";
echo "</p>";
echo "</body></html>";
exit();
}
$res = mysql_query("UPDATE ibwf_users SET browserm='".$brw."', ipadd='".$uip."' WHERE id='".getuid_sid($sid)."'");
addonline(getuid_sid($sid),"Viewing wapvibes Ads","wapvibes_ads.php?action=main");
////////////////////////////////////////MAIN PAGE
if($action=="main")
{
$result=mysql_query("select * from wapvibes_ads where cat='sale'");
$sale = mysql_num_rows($result);
$result=mysql_query("select * from wapvibes_ads where cat='services'");
$services = mysql_num_rows($result);
$result=mysql_query("select * from wapvibes_ads where cat='jobs'");
$jobs = mysql_num_rows($result);
$result=mysql_query("select * from wapvibes_ads where cat='events'");
$events = mysql_num_rows($result);
echo "<body>";
if(stristr($HTTP_USER_AGENT,"Windows NT"))
{
}else{
}
echo "<head><title>$site_name</title>";
echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"style/style.css\" />";
echo "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />
<meta http-equiv=\"Cache-Control\" content=\"no-cache\"/>
<meta name=\"description\" content=\"wapvibes Classified Ads\" />
<meta name=\"keywords\" content=\"buy, sell, trade, services, jobs\" /></head>";
echo "<body>";
echo "<p>";
echo "<div class=\"boxedTitle\">
<h1 style=\"text-align: center\" class=\"boxedTitleText\"><b>Classiffied Ads</b>
</h1>
</div>";
echo "<center><br/><big>Wapvibes Classifieds</big><br/><br/></center>";
echo "<big><u><b>Classifieds</b></u></p>";
echo "<p>»<a href=\"wapvibes_ads.php?action=show_ads&sid=$sid&cat=sale\">For Sale</a>($sale)<br/>";
echo "»<a href=\"wapvibes_ads.php?action=show_ads&sid=$sid&cat=services\">Services</a>($services)<br/>";
echo "»<a title=\"Enter\" href=\"wapvibes_ads.php?action=show_ads&sid=$sid&cat=jobs\">Guyana Jobs</a>($jobs)<br/>";
echo "»<a title=\"Enter\" href=\"wapvibes_ads.php?action=show_ads&sid=$sid&cat=events\">Upcoming Events</a>($events)<br/>";
echo "<br/><a title=\"Enter\" href=\"wapvibes_ads.php?action=post&sid=$sid\">Post Your Ads</a>";
echo "<br/><a title=\"Enter\" href=\"index.php?action=main&sid=$sid\">Home</a>";
echo "<div class=\"boxedTitle\">
<h1 style=\"text-align: center\" class=\"boxedTitleText\"><b>wapvibes.net</b>
</h1>
</div>";
echo "</p></big>";
if(stristr($HTTP_USER_AGENT,"Windows NT"))
{
}else{
}
echo "</body></html>";
}
else if($action=="show_ads")
{
echo "<body>";
if(stristr($HTTP_USER_AGENT,"Windows NT"))
{
}else{
}
echo "<head><title>$site_name</title>";
echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"style/style.css\" />";
echo "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />
<meta http-equiv=\"Cache-Control\" content=\"no-cache\"/>
<meta name=\"description\" content=\"wapvibes Classified Ads\" />
<meta name=\"keywords\" content=\"buy, sell, trade, services, jobs\" /></head>";
echo "<body>";
$cat=$_GET["cat"];
$page=$_GET["page"];
if($page=="")
{
$page=1;
}
$max_results = 7;
$from = (($page * $max_results) - $max_results);
echo "<div class=\"boxedTitle\">
<h1 style=\"text-align: center\" class=\"boxedTitleText\"><b>Classified Ads</b>
</h1>
</div>";
echo "<p><big>";
$total_results = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM wapvibes_ads WHERE cat='$cat'"));
if($total_results[0]<1)
{
echo "<p>Sorry No Ads to show yet!!!</p><br/>";
}else{
$total_pages = ceil($total_results[0] / $max_results);
echo "$page Of $total_pages<br/><br/>";
$sql = mysql_query("SELECT * FROM wapvibes_ads WHERE cat='$cat' ORDER BY id desc LIMIT $from, $max_results");
while($row = mysql_fetch_array($sql)){
$name = $row['uid'];
$name2 = $row['itemname'];
$key = $row['id'];
echo "<a href=\"wapvibes_ads.php?action=details&sid=$sid&cat=$cat&key=$key\">$name2</a><br/>" ;
}
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"wapvibes_ads.php?action=show_ads&sid=$sid&page=$next&cat=$cat\">Next</a><br />";
}
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"wapvibes_ads.php?action=show_ads&sid=$sid&page=$prev&cat=$cat\">Prev</a><br/>";
}
$i = 1; $i <= $total_pages; $i++ ;
}
echo "<br/><a href=\"wapvibes_ads.php?action=main&sid=$sid\">Classified Main</a>";
echo "</p></big>";
echo "<div class=\"boxedTitle\">
<h1 style=\"text-align: center\" class=\"boxedTitleText\"><b>wapvibes.net</b>
</h1>
</div>";
if(stristr($HTTP_USER_AGENT,"Windows NT"))
{
}else{
}
echo "</body>";
}
else if($action=="details")
{
$key=$_GET["key"];
$cat=$_GET["cat"];
$sql = mysql_fetch_array(mysql_query("SELECT * FROM wapvibes_ads WHERE id='$key'"));
$usid=$sql["uid"];
$who=$usid;
$name=getnick_uid($usid);
$ad=$sql["ad"];
$price=$sql["price"];
$contact=$sql["contact"];
$location=$sql["location"];
$posted=$sql["time"];
$wapvibes_ad_time = date("d/m/Y h:i:s A", $posted);
echo "<body>";
if(stristr($HTTP_USER_AGENT,"Windows NT"))
{
}else{
}
echo "<head><title>$site_name</title>";
echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"style/style.css\" />";
echo "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />
<meta http-equiv=\"Cache-Control\" content=\"no-cache\"/>
<meta name=\"description\" content=\"wapvibes Classified Ads\" />
<meta name=\"keywords\" content=\"buy, sell, trade, services, jobs\" /></head>";
echo "<body>";
echo "<div class=\"boxedTitle\">
<h1 style=\"text-align: center\" class=\"boxedTitleText\"><b>wapvibes Classifieds</b>
</h1>
</div><br/>";
echo "<p>";
echo "<big><b>*Seller</b><br/> <a href=\"index.php?action=viewuser&sid=$sid&who=$usid\">$name</a><br/><br/>";
echo "<b>*Description*</b><br/> $ad<br/><br/>";
echo "<b>*Price*</b><br/> $price<br/>";
echo "<b>*Contact*</b><br/> $contact<br/><br/>";
echo "<b>*Location*</b><br/> $location<br/>";
echo "<b>*Posted on</b><br/> $wapvibes_ad_time<br/>";
echo "<br/>";
echo "<a href=\"inbox.php?action=sendpm&who=$usid&sid=$sid\">[Send $name A PM]</a><br/><br/>";
$uid = getuid_sid($sid);
if(budres($uid, $who)==0)
{
echo "<a href=\"genproc.php?action=bud&who=$who&sid=$sid&todo=add\">Add to buddy list</a><br/>";
}else if(budres($uid, $who)==1)
{
echo "Queued Buddy Requests<br/>";
}else if(budres($uid, $who)==2)
{
echo "<a href=\"genproc.php?action=bud&who=$who&sid=$sid&todo=del\">Remove From buddy list</a><br/>";
}
$ires = ignoreres($uid, $who);
if(es==2)
{
echo "<a href=\"genproc.php?action=ign&who=$who&sid=$sid&todo=del\">Remove From Ignore list</a><br/>";
}else if($ires==1)
{
echo "<a href=\"genproc.php?action=ign&who=$who&sid=$sid&todo=add\">Add to Ignore list</a><br/>";
}
if (isadmin($uid)){
echo "<p><a href=\"wapvibes_ads.php?action=delete44&who=$who&sid=$sid\">Delete This Ad</a></p>";
}
echo "<a href=\"wapvibes_ads.php?action=show_ads&sid=$sid&cat=$cat\">Back</a>";
echo "<br/><a href=\"wapvibes_ads.php?action=main&sid=$sid\">Classified Main</a>";
echo "<div class=\"boxedTitle\">
<h1 style=\"text-align: center\" class=\"boxedTitleText\"><b>wapvibes.net</b>
</h1>
</div>";
echo "</p></big>";
if(stristr($HTTP_USER_AGENT,"Windows NT"))
{
}else{
}
echo "</body>";
}
else if($action=="post")
{
echo "<body>";
if(stristr($HTTP_USER_AGENT,"Windows NT"))
{
}else{
} echo "<head><title>$site_name</title>";
echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"style/style.css\" />";
echo "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />
<meta http-equiv=\"Cache-Control\" content=\"no-cache\"/>
<meta name=\"description\" content=\"wapvibes Classified Ads\" />
<meta name=\"keywords\" content=\"buy, sell, trade, services, jobs\" /></head>";
echo "<body>";
echo "<div class=\"boxedTitle\">
<h1 style=\"text-align: center\" class=\"boxedTitleText\"><b>Classified Ads</b>
</h1>
</div>";
echo "<p>";
echo "<big>Post an advertisement on wapvibes.net</p>";
echo "<form action=\"wapvibes_ads.php?action=post2&sid=$sid\" method=\"post\">";
echo "<p>";
echo "What is the Name of Your Item<br/>";
echo "<br/>";
echo "<textarea class=\"inputText\" name=\"name\"></textarea><br/>";
echo "Describe Your Item<br/>";
echo "<br/>";
echo "<textarea class=\"inputText\" name=\"ad\"></textarea><br/>";
echo "Choose Category";
echo "<br/><select name=\"listing\">";
echo "<option value=\"select\">select</option>";
echo "<option value=\"sale\">Selling</option>";
echo "<option value=\"services\">Services</option>";
echo "<option value=\"jobs\">Jobs</option>";
echo "<option value=\"events\">events</option>";
echo "</select><br/>";
echo "what is Your Price<br/>";
echo "<textarea class=\"inputText\" name=\"price\"></textarea><br/>";
echo "How can You be contacted:";
echo "<br/><textarea class=\"inputText\" name=\"contact\"></textarea><br/>";
echo "Where Are You Located";
echo "<br/><textarea class=\"inputText\" name=\"location\"></textarea><br/>";
$ui=getuid_sid($sid);
echo "<input type=\"hidden\" name=\"ui\" value=\"$ui\"/>";
echo "<br/><input name=\"submit\" value=\"Submit Your Ad\" type=\"submit\"/><br/></p></form><p>";
echo "<a href=\"index.php?action=main&sid=$sid\">Home</a></p>";
echo "<div class=\"boxedTitle\">
<h1 style=\"text-align: center\" class=\"boxedTitleText\"><b>wapvibes.net</b>
</h1>
</div></big>";
if(stristr($HTTP_USER_AGENT,"Windows NT"))
{
}else{
}
echo "</body>";
}
else if($action=="delete44")
{
echo "<body>";
if(stristr($HTTP_USER_AGENT,"Windows NT"))
{
}else{
} echo "<head><title>$site_name</title>";
echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"style/style.css\" />";
echo "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />
<meta http-equiv=\"Cache-Control\" content=\"no-cache\"/>
<meta name=\"description\" content=\"wapvibes Classified Ads\" />
<meta name=\"keywords\" content=\"buy, sell, trade, services, jobs\" /></head>";
echo "<body>";
echo "<div class=\"boxedTitle\">
<h1 style=\"text-align: center\" class=\"boxedTitleText\"><b>Dating Portal</b>
</h1>
</div>";
echo "<p>";
echo "<big>Ad was successfully Deleted From the system</p>";
mysql_query("DELETE FROM wapvibes_ads WHERE uid='".$who."'");
echo "<br/><p><a href=\"wapvibes_ads.php?action=main&sid=$sid\">Back to System</a></p><br/><br/>";
echo "<p><a href=\"index.php?action=main&sid=$sid\">Home</a></p>";
echo "<div class=\"boxedTitle\">
<h1 style=\"text-align: center\" class=\"boxedTitleText\"><b>wapvibes.net</b>
</h1>
</div></big>";
if(stristr($HTTP_USER_AGENT,"Windows NT"))
{
}else{
}
echo "</body>";
}
else if($action=="post2")
{
echo "<body>";
if(stristr($HTTP_USER_AGENT,"Windows NT"))
{
}else{
}
echo "<head><title>$site_name</title>";
echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"style/style.css\" />";
echo "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />
<meta http-equiv=\"Cache-Control\" content=\"no-cache\"/>
<meta name=\"description\" content=\"wapvibes Classified Ads\" />
<meta name=\"keywords\" content=\"buy, sell, trade, services, jobs\" /></head>";
echo "<body>";
echo "<div class=\"boxedTitle\">
<h1 style=\"text-align: center\" class=\"boxedTitleText\"><b>Classified</b>
</h1>
</div>";
echo "<p><big>";
$name=$_POST["name"];
$ad=$_POST["ad"];
$price=$_POST["price"];
$contact=$_POST["contact"];
$cat=$_POST["listing"];
$location=$_POST["location"];
$ui=$_POST["ui"];
$result=mysql_query("select * from wapvibes_ads where uid='$ui' and cat='$cat'");
$number_of_rows = mysql_num_rows($result);
if ($number_of_rows>0){
$problems="1";
echo "You already have a Ad in our system Please wait until your Ad expire in 7 days! <br/>";
echo "<br/><a href=\"wapvibes_ads.php?action=main&sid=$sid\">Classified Main</a><br/>";}
if ($problems==""){
echo "<img src=\"images/dating.gif\" alt=\"\"/>$sitename-Classified<img src=\"images/dating.gif\" alt=\"\"/><br/>";
$sql = "INSERT INTO wapvibes_ads (uid, cat, ad, itemname, time, price,contact,location) VALUES ('$ui','$cat','$ad','$name','".time()."','$price','$contact','$location')";
$result = mysql_query($sql);
echo "Your Advertisement was Successfully Posted it will be in the Classified for 7 days, After that it will expire<br/><br/>";
echo "<br/><a href=\"wapvibes_ads.php?action=main&sid=$sid\">classified Main</a><br/>";
}
echo "<a href=\"index.php?action=main&sid=$sid\">Home</a></p></big>";
echo "<div class=\"boxedTitle\">
<h1 style=\"text-align: center\" class=\"boxedTitleText\"><b>wapvibes.net</b>
</h1>
</div>";
if(stristr($HTTP_USER_AGENT,"Windows NT"))
{
}else{
}
echo "</body>";
}
echo "</html>";
?>
The second script is required to delete the Ads from the database every 7 days You can include this in a cron Job or Just include it at the top of Your pages so everytime someone access the page it will run.
delete_ads.php
PHP Code:
<?php
/*
Mini Classified Script Edited & Coded By Anthony wapvibes.net
*/
include("config.php");
$db = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname) or die(mysql_error());
$wapvibes_time_count = 7*24*60*60; ////// count the 7 days Ads will be deleted
$wapvibes_match_time = time()-$wapvibes_time_count;
$query = "SELECT id FROM wapvibes_ads WHERE time<'".$wapvibes_match_time."' ORDER BY RAND() LIMIT 1";
$result = mysql_query($query);
while($ad_id = mysql_fetch_array($result))
$delete =$ad_id[0];
mysql_query("DELETE FROM wapvibes_ads WHERE id='$delete'");
?>
Code:
CREATE TABLE IF NOT EXISTS `wapvibes_ads` ( `id` mediumint(4) NOT NULL auto_increment, `uid` varchar(20) NOT NULL default '', `cat` varchar(100) NOT NULL default '', `ad` text NOT NULL, `price` text NOT NULL, `time` int(100) NOT NULL, `contact` text NOT NULL, `itemname` text NOT NULL, `location` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=207 ;
PHP Code:
$ads = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM wapvibes_ads"));
<a href=\"wapvibes_ads.php?action=main&sid=$sid\" accesskey=\"Ads\">Classified Ads($ads[0])</a><br/>
Code:
.boxedTitle { height: 18px; padding: 0 0 0 2px; background: #2B60DE; } .boxedTitleText { font-size: 15px; color: #ffffff; }
Comment