<?PHP
include "inc/global.php";
include "temp.fun.php";
$rq = $_REQUEST;
$pst = $_POST;
$do = $_REQUEST['do'];
$system = $DB->sys_optn("sys");
set_visitor();
if($rq['tag'])
{
$sql_chk = $DB->fetch_q("select * from tags where tags_name='".urlencode($rq['tag'])."' ");
if($sql_chk['con'] != 0)
{
$tag = str_replace(" ", "+", $rq['tag']);
$pst['search_fr'] = $tag;
$clk = $sql_chk['rs']['clicks'];
$clk++;
$tags_up['clicks'] = $clk;
$ups = $DB->updt("tags", $tags_up, "where idtags='".$sql_chk['rs']['idtags']."' ");
$_SESSION['tags'] = $tag;
}
}
$style_file = "styles/".$style.".html";
$file_lang = @fopen("lang/".$lang_file.".php", r);
$_Phrase = array();
while(!feof($file_lang))
{
$line = fgets($file_lang);
if(!ereg("die()", $line) && !ereg("//", $line))
{
$phrase_ar = explode("=", $line);
if($phrase_ar[0] && $phrase_ar[1])
{
$_Phrase[strip_space($phrase_ar[0])] = str_replace("\n", "", strip_space($phrase_ar[1]));
}
}
}
//Database
if($_POST['titl'] && $_POST['nam'] && $_POST['website'] && $_POST['data'] && $_POST['cap'] && $_POST['email'] && !$pst['name_contact'])
{
if(check_mail($_POST['email']))
{
//check submit time
if($rq['ads_typ'] == 0)
{
$rs_guest = $DB->fetch_f("select * from ads where email='".urlencode($_POST['email'])."' and type='0' ");
}
elseif($rq['ads_typ'] == 1)
{
$rs_guest = $DB->fetch_f("select * from ads where email='".urlencode($_POST['email'])."' and type='1' ");
}
if(chk_hours($rs_guest['u_time'], $system['numfeehor']))
{
$real_time = date("U");
if($rq['ads_typ'] == 0)
{
//free
//{
//active by mail
if($system['chk_feeadsmal'] == 1)
{
//send activation mail
$actv_mal = 0;
$actv_link = actvation_link($real_time, $_POST['email']);
}
else
{
$actv_mal = 1;
}
//activtions
if($system['dasfeeactv'] == 1)
{
$actvs = 2;
}
elseif($system['dasfeeactv'] == 2)
{
$actvs = 1;
}
//}
}
elseif($rq['ads_typ'] == 1)
{
//prmuim
//{
//active by mail
if($system['chk_prmadsmal'] == 1)
{
//send activation mail
$actv_mal = 0;
$actv_link = actvation_link($real_time, $_POST['email']);
}
else
{
$actv_mal = 1;
}
//activtions
if($system['dasprmactv'] == 1)
{
$actvs = 2;
}
elseif($system['dasprmactv'] == 2)
{
$actvs = 1;
}
//}
}
$_SESSION['msg'] = "";
if(strtoupper($_POST['cap']) == $_SESSION['image_string'])
{
$ins = $DB->_query("insert into ads (email, name, title, details, cat, websaite, u_time, actv, actv_mal, type)values('".urlencode($_POST['email'])."', '".urlencode($_POST['gustname'])."', '".$DB->f_data($_POST['titl'])."', '".$DB->f_data(strip_tags($_POST['data']))."', '".$_POST['nam']."' ,'".$DB->f_data($_POST['website'])."' ,'".$real_time."', '".$actvs."', '".$actv_mal."', '".$rq['ads_typ']."') ");
$theid = mysql_insert_id();
if(!$actv_link)
{
$data_temp['msg'] = "<font color=#339966>".$_Phrase['data_saved']."</font> ";
}
else
{
$elemnts = array('[name]', '[actvlink]');
$newelemnts = array($_POST['gustname'], '<a href="'._rootpath.'?id='.$theid.'&lnk='.$actv_link.'">'._rootpath.'?id='.$theid.'&lnk='.$actv_link.'</a>');
send_mail($_POST['email'], $_Phrase['actvmail_title'], str_replace($elemnts, $newelemnts, $_Phrase['actvmail_msg']), _admin_Mail, '', '');
if($rq['ads_typ'] == 0)
{
if($system['malfeesbmtads'] == 1)
{
$ads_typ = $_Phrase['free_ads'];
}
}
else
{
if($system['malprmsbmtads'] == 1)
{
$ads_typ = $_Phrase['prm_ads'];
}
}
if($ads_typ)
{
$elemnts = array('[name]', '[ads_type]', '[title_ads]','[ads_content]');
$newelemnts = array($_POST['gustname'], $ads_typ, $_POST['titl'], str_replace("\n", "<br />", $_POST['data']));
send_mail( _admin_Mail, str_replace( "[ads_type]", $ads_typ, $_Phrase['actvmail_admn_title']), str_replace($elemnts, $newelemnts, $_Phrase['actvmail_admn_msg']), $_POST['email'], '', '');
}
$data_temp['msg'] = "<font color=#339966>".$_Phrase['data_saved']."<br />".$_Phrase['plz_chkmal']."</font> ";
}
}
else
{
$data_temp['msg'] = "<font color=red>".$_Phrase['rngcpta']."</font>";
}
}
else
{
$data_temp['msg'] = "<font color=red>".str_replace("x", $system['numfeehor'], $_Phrase['cant_new_fee'])."</font>";
}
}
else
{
$data_temp['msg'] = "<font color=red>".$_Phrase['plz_err_mal']."</font>";
}
$do = "url";
}
elseif($_POST['nam'])
{
$data_temp['msg'] = "<font color=red>".$_Phrase['rngcpta']."</font>";
$do = "url";
}
elseif($rq['lnk'] && $rq['id'])
{
$rs_actv = $DB->fetch_q("select * from ads where adsid='".$rq['id']."' ");
if($rs_actv["con"] == 1)
{
if(actvation_link($rs_actv["rs"]["u_time"], $rs_actv["rs"]["email"], $rq['lnk']) == 1)
{
$ups['actv_mal'] = "1";
$sql = $DB->updt("ads", $ups, "where adsid='".$rq['id']."' ");
$data_temp['msg'] = "<font color=#339966>".$_Phrase['ur_actv_right']."</font>";
}
else
{
$data_temp['msg'] = "<font color=red>".$_Phrase['ur_actv_wrong']."</font>";
}
}
else
{
$data_temp['msg'] = "<font color=red>".$_Phrase['ur_actv_wrong']."</font>";
}
$do = "url";
}
//-------------------------------------------------------- *search*
elseif($pst['search_fr'])
{
if(strtoupper($pst['captxt_srch']) != $_SESSION['image_string_srch'] && !$_SESSION['tags'])
{
$data_temp['msg'] = "<font color=red>".$_Phrase['rngcpta']."</font>";
}
else
{
$serch_for = explode(" ", $pst['search_fr']);
$nums = 0;
$wehers .= "(";
foreach($serch_for as $key=>$value)
{
if($value && $value != " ")
{
$wehers .= "title like '%".$value."%' || details like '%".$value."%' || ";
$nums++;
}
}
if($nums > 0)
{
$wehers = substr($wehers, 0, strlen($wehers) - 3).") ";
if($pst['Category'])
{
$wehers .= "and cat='".$pst['Category']."' ";
}
if($pst['Website'])
{
$wehers .= "and websaite='".urlencode($pst['Website'])."' ";
}
}
else
{
$wehers = "";
}
if($wehers)
{
$sql = $DB->_query("select * from ads where ".$wehers." order by u_time desc");
if($DB->_nrow($sql) != 0)
{
$search_res = array();
while($rs_ar = $DB->_fetch($sql))
{
$search_res[$rs_ar['adsid']] = urldecode($rs_ar['title']);
}
$_SESSION['search_res'] = $search_res;
$_SESSION['hieghlights'] = str_replace(" ", "+", $pst['search_fr']);
$data_temp['msg'] = "<font color=#339966>".str_replace("x", $DB->_nrow($sql), $_Phrase['fnd_srch'])."</font>";
}
else
{
$data_temp['msg'] = "<font color=red>".$_Phrase['cnt_fnd_srch']."</font>";
}
}
}
$do = "url";
$data_temp['url'] = "index.php?go=search";
}
elseif($pst['name_contact'])
{
if(strtoupper($pst['captxt_contact']) != $_SESSION['image_string_srch'])
{
$data_temp['msg'] = "<font color=red>".$_Phrase['rngcpta']."</font>";
}
else
{
$msg['name'] = $pst['name_contact'];
$msg['email'] = $pst['email_contact'];
$msg['msg'] = strip_tags($pst['message_contact']);
$msg['u_time'] = date("U");
$DB->ins("messages", $msg);
$data_temp['msg'] = "<font color=#339966>".$_Phrase['data_send']."</font> ";
}
}
elseif($rq['ids_exps'])
{
$exps_ar = explode("/", $rq['exps']);
if(count($exps_ar) == 3)
{
$data_ars = mktime(date("H"), date("i"), date("s"), $exps_ar[1], $exps_ar[0], $exps_ar[2]);
}
else
{
$data_ars = "";
}
$DB->_query("update ads set exp='".$data_ars ."' where adsid='".$rq['ids_exps']."' ");
$data_temp['msg'] = "<font color=#339966>".$_Phrase['data_saved']."</font> ";
$do = "url";
}
elseif($rq['del_ads'])
{
$DB->_query("delete from ads where adsid='".$rq['del_ads']."' ");
$data_temp['msg'] = "<font color=#339966>".$_Phrase['data_deleted']."</font> ";
$do = "url";
}
switch($do)
{
case'url':
if($data_temp['msg'])
{
if(!$data_temp['url'])
{
$data_temp['url'] = "index.php";
}
$data_temp['time'] = "2";
echo($TMP->get_template($data_temp, "_redirect"));
}
else
{
header("location: index.php");
}
break;
case'login':
if($_REQUEST['unam'] && $_REQUEST['pword'])
{
$perm = $user->do_login($_REQUEST['unam'], $_REQUEST['pword']);
if($perm == "Right")
{
$data_temp['msg'] = "<font color=#339966>".$_Phrase['welcome_msg']." ".$_REQUEST['unam']."</font> ";
$data_temp['url'] = "?";
$data_temp['time'] = "1";
}
else
{
$data_temp['msg'] = "<font color=red>Wrong Login, try again !!</font>";
$data_temp['url'] = "?";
$data_temp['time'] = "2";
}
}
echo $TMP->get_template($data_temp, "_redirect");
break;
case'logout':
$perm = $user->do_logout();
$data_temp['msg'] = "<font color=#339966>You are now logout</font> ";
$data_temp['url'] = "?";
$data_temp['time'] = "1";
echo $TMP->get_template($data_temp, "_redirect");
break;
default;
$title = _SiteName." - Powered by EXPBuilder Ads v1.0 2008".$nxtyer;
$keywords = $system['keywords'];
$description = $system['description'];
$sql_words = $DB->fetch_f("select * from sys where _name='words_details' ");
$wordss = str_replace("\n", "<br />", stripslashes($sql_words['_note']));
if($wordss)
{
$words['contents_word'] = $wordss;
$contents = $TMP->get_template($words, "words_guid");
}
$types = 2;
$data_ads_free = "";
$data_ads_prm = "";
$contents_prm = 0;
$contents_fee = 0;
$page_prm = $rq['page_prm'];
$page_f = $rq['page_f'];
while($types >= 0)
{
if($types == 2)
{
$limits = 0;
$num_ads = 3;
}
elseif($types == 1)
{
$pagelimt = $page_prm;
$pagelimt--;
$num_ads = $system['prem_ads_count'];
$limits = $pagelimt * $num_ads;
}
elseif($types == 0)
{
$pagelimt = $page_f;
$pagelimt--;
$num_ads = $system['free_ads_count'];
$limits = $pagelimt * $num_ads;
}
$sql = $DB->_query("select * from ads where actv='1' and actv_mal='1' and type='".$types."' order by u_time DESC limit ".$limits.", ".$num_ads." ");
while($rs = $DB->_fetch($sql))
{
$Reads = $rs['views'];
$Reads++;
$sites_temp['websaite'] = '?adsid='.$rs['adsid'];
$details = urldecode($rs['details']);
if(strlen($details) > 150)
{
$details = substr($details, 0, 150).'.... <a href="'.$sites_temp['websaite'].'">'.$_Phrase['details'].'</a>';
}
if($types != 0)
{
$details = str_replace("\n", "<br />", $details);
}
$rs_cat = $DB->fetch_f("select * from cat where catid='".$rs['cat']."' ");
$sites_temp['title'] = urldecode($rs['title']);
$sites_temp['details'] = $details;
$sites_temp['cat'] = $rs_cat['cat_name'];
$sites_temp['site_name'] = get_server(urldecode($rs['websaite']));
$sites_temp['Reads'] = $Reads;
$sites_temp['Clicks'] = $rs['click'];
$sites_temp['Categorys'] = $Categorys;
if($types == 0)
{
if(($rs['u_time'] + 1296000) < date("U"))
{
$del = $DB->_query("delete from ads where adsid='".$rs['adsid']."' ");
}
else
{
$data_ads_free .= $TMP->get_template($sites_temp, "ads_temp");
$freeads = 1;
$contents_fee ++;
}
}
elseif($types == 1)
{
if($rs['exp'] > date("U") || $rs['exp'] == 0)
{
if($rs['exp'] != 0)
{
$sites_temp['expdat'] = date("d / m / Y - H:i", $rs['exp']);
}
else
{
$sites_temp['expdat'] = "unlimited";
}
if($_SESSION['type'] != 2)
{
$sites_temp['edits'] = "";
$sites_temp['data_edit'] = "";
}
else
{
if($rs['exp'] > 0)
{
$expss = date("d/m/Y", $rs['exp']);
}
else
{
$expss="";
}
$sites_temp['edits'] = '<a href="javascript: void(0);" style="color: #CC0033;" onclick="$(\'.exps\').hide(\'slow\');$(\'#prm_'.$rs['adsid'].'\').show(\'slow\');">'.$_Phrase['edit'].'</a> |';
$sites_temp['data_edit'] = '
<div id="prm_'.$rs['adsid'].'" class="exps" style="display: none;">
<form action="index.php?do=url" method="post">
'.$_Phrase['exp'].' <input type=text name="exps" size="15" value="'.$expss.'" class="calender" readonly>
<input type=hidden name="ids_exps" value="'.$rs['adsid'].'">
<input type=submit size="15" value="'.$_Phrase['update'].'" class="butn">
</form>
<br />
<input type="button" value="'.$_Phrase['delete'].'" class="butn" onclick="if(confirm(\''.$_Phrase['askdel'].'\')) { window.open(\'index.php?do=url&del_ads='.$rs['adsid'].'\', \'_self\');}">
</div>
';
}
$data_ads_prm .= $TMP->get_template($sites_temp, "prmads_temp");
$prmads = 1;
$contents_prm ++;
}
else
{
//expired
$up = $DB->_query("delete from ads where adsid='".$rs['adsid']."' ");
}
} elseif($types == 2)
{
if($rs['exp'] > date("U") || $rs['exp'] == 0)
{
$pics = 'images/banners/'.$rs['adsid'].'.gif';
if(file_exists($pics))
{
if($rs['exp'] != 0)
{
$sites_temp['expdat'] = date("d / m / Y - H:i", $rs['exp']);
}
else
{
$sites_temp['expdat'] = "unlimited";
}
$clicks = ", click='".$clck."'";
$sites_temp['views'] = $Reads;
$sites_temp['pic'] = $pics;
$sites_temp['websaite'] = urldecode($rs['websaite']);
$data_ads_bnrs .= $TMP->get_template($sites_temp, "bnr_temp");
}
}
}
$up = $DB->_query("update ads set views='".$Reads."' where adsid='".$rs['adsid']."' ");
}
$types--;
}
$Categorys = "";
$qury = $DB->fetch_ar("select * from cat order by ords asc");
if(is_array($qury))
{
foreach($qury as $key=> $cat)
{
$Categorys .='<option value="'.$cat['catid'].'">'.$cat['cat_name'].'</option>';
}
}
$New_ads_temp['Categorys'] = $Categorys;
if(!$rq['ads'])
{
$New_ads_temp['ads_type'] = $_Phrase['free_ads'];
if($system['numfeewrd'] == 0)
{
$New_ads_temp['numfeewrd'] = 2000;
}
else
{
$New_ads_temp['numfeewrd'] = $system['numfeewrd'];
}
}
else
{
$New_ads_temp['ads_type'] = $_Phrase['prm_ads'];
if($system['numprmwrd'] == 0)
{
$New_ads_temp['numfeewrd'] = 2000;
}
else
{
$New_ads_temp['numfeewrd'] = $system['numprmwrd'];
}
}
$New_ads_temp['ads_vals'] = $_REQUEST['ads'];
$ads_temp = $TMP->get_template($New_ads_temp, "add_adstemp");
$num_ads = _num_ads;
$data_puts .= $TMP->mask_box();
//pagers
if(!$page_prm)
{
$page_prm = 1;
}
if(!$page_f)
{
$page_f = 1;
}
$res_prm = $DB->fetch_q("select * from ads where actv='1' and actv_mal='1' and type='1'");
if($res_prm["con"] > _num_ads)
{
$pager = pager($page_prm, $res_prm["con"], "index.php?page_f=".$page_f."&page_prm=", _num_ads);
$data_ads_prm = '<br />'.$pager.'<br />'.$data_ads_prm.$pager;
}
$res_free = $DB->fetch_q("select * from ads where actv='1' and actv_mal='1' and type='0'");
if($res_free["con"] > _num_ads)
{ $pager = pager($page_f, $res_prm["con"], "index.php?page_prm=".$page_prm."&page_f=", _num_ads);
$data_ads_free = '<br />'.$pager.'<br />'.$data_ads_free.$pager;
}
if($rq['adsid'])
{
$rs = $DB->fetch_f("select * from ads where adsid='".$rq['adsid']."' ");
if($rs['actv'] == '1' && $rs['actv_mal'] == '1')
{
$clcs = $rs['click'];
$clcs++;
$Reads = $rs['views'];
$Reads++;
$hieghlights = $rq['hieghlights'];
$hieghlights_ar = explode(" ", $hieghlights);
if(is_array($hieghlights_ar))
{
foreach($hieghlights_ar as $key=>$value)
{
$old[] = $value;
$new[] = '<span class="highlights">'.$value.'</span>';
}
}
$sites_temp['title'] = urldecode($rs['title']);
$details = str_replace("\n", "<br />", urldecode($rs['details']));
$sites_temp['details'] = str_replace($old, $new, $details);
$rs_cat = $DB->fetch_f("select * from cat where catid='".$rs['cat']."' ");
$sites_temp['cat'] = $rs_cat['cat_name'];
$sites_temp['site_name'] = $sites_temp['websaite'] = urldecode($rs['websaite']);
$sites_temp['Reads'] = $Reads;
$sites_temp['Clicks'] = $clcs;
$sites_temp['Categorys'] = $Categorys;
$dtls['click'] = $clcs;
$dtls['views'] = $Reads;
//meta tags info
//{
$keywords = urldecode($rs['title']).', '.$keywords;
$description = urldecode($rs['title']).' - '.$rs_cat['cat_name'].' '.$_Phrase['Category'];
//}
$title = urldecode($rs['title']).' - '.$title;
$topics = $TMP->get_template($sites_temp, "readads_temp");
$ups = $DB->updt("ads", $dtls, "where adsid='".$rs['adsid']."' ");
$data_ads_free = "";
$data_ads_free = "";
$freeads = 0;
}
else
{
header("location: index.php");
}
}
//tags
$sql_tags = $DB->fetch_ar("select * from tags");
if(is_array($sql_tags))
{
foreach($sql_tags as $key=>$rs_tags)
{
$tags_name = $rs_tags['tags_name'];
$tags_elemnts[$tags_name] = $rs_tags['clicks'];
}
}
$tags['tags_content'] = "";
if(is_array($tags_elemnts))
{
$tags_ar = generate_action_tags($tags_elemnts);
foreach($tags_ar as $names=>$nums)
{
$tags_contents .= '<a href="index.php?do=url&go=search&tag='.$names.'" style="font-size: '.$nums.'px;">'.$names.'</a> ';
}
$tagso['tags_con'] = $tags_contents;
}
$tags = $TMP->get_template($tagso, "tags_temp");
if($rq['go'])
{
switch($rq['go'])
{
case'search':
if(is_array($_SESSION['search_res']) && ($_SESSION['hieghlights'] || $rq['hieghlights']))
{
$page_srch = $rq['page_srch'];
if(!$page_srch)
{
$page_srch = 1;
}
$num_serch = $system['srch_ads_count'];
$cons_srch = count($_SESSION['search_res']);
$end = $page_srch * $num_serch;
$start = $end - ($num_serch - 1);
if($rq['hieghlights'])
{
$_SESSION['hieghlights'] = $rq['hieghlights'];
}
foreach($_SESSION['search_res'] as $key=>$value)
{
$num_ar++;
if($num_ar >= $start && $num_ar <= $end)
{
$contents .= '<h3>'.$num_ar.' - <a href="index.php?adsid='.$key.'&hieghlights='.$_SESSION['hieghlights'].'" title="'.$value.'">'.$value.'</a></h3><br />';
}
}
$pager = pager($page_srch, $cons_srch, "index.php?go=search&hieghlights=".$_SESSION['hieghlights']."&page_srch=", $num_serch);
$contents = '<center><h2>'.$_Phrase['search_fr'].' '.str_replace("+", " ", $_SESSION['hieghlights']).'</h2></center><br />'.$pager.'<br />'.$contents.'<br />'.$pager.'<br /><hr>';
$_SESSION['hieghlights'] = "";
}
else
{
$_SESSION['search_res'] = "";
$search = array();
$search['Categorys'] = $Categorys;
$contents = $TMP->get_template($search, "search");
}
$title = $_Phrase['advnsd_srch'].' - '.$title;
break;
case'contactus':
$title = $_Phrase['contact_us'].' - '.$title;
$contact = array();
$contents = $TMP->get_template($contact, "contactus_temp");
break;
case'newads':
$sbmt = $ads_temp;
$ads_temp = "";
break;
default;
$_SESSION['search_res'] = "";
}
$data_ads_free = "";
$data_ads_free = "";
$freeads = 0;
}
//statics
$ana = analitics_ar();
$static['tody_sbmtd_ad'] = $ana['total_sbmt_today'];
$static['yody_sbmtd_ad'] = $ana['total_sbmt_yesterday'];
$static['all_sbmtd_ad'] = $ana['total_sbmt_total'];
$static['visitors_today'] = $ana['visittoday'];
$static['visitors_overall'] = $ana['visittotal'];
$statics = $TMP->get_template($static, "analytics_temp");
$rs_ads = $DB->fetch_ar("select * from ads where actv='1' and actv_mal='1' order by u_time DESC limit 0, ".$system['srch_ads_count']." ");
$last_ads = '<h2>'.str_replace("x", $system['srch_ads_count'], $_Phrase['last_ads']).'</h2><br />';
if(is_array($rs_ads))
{
foreach($rs_ads as $key=>$rs)
{
$titles = $rs['title'];
if(strlen($titles) > 30)
{
$titles = substr($titles, 0, 30).'...';
}
$last_ads .= '<li class="lis"><a href="index.php?adsid='.$rs['adsid'].'" title="'.$rs['title'].'">'.strtoupper($titles).'</a></li>';
}
}
include $style_file;
}
?>