//e-mail als link is goedgekeurd of afgekeurd
header("content-type:text/html; charset=UTF-8");
include ("GetHandler.php");
include ("TemplatePower.php");
class Index{
private $TPLFILE;
public $tpl;
private $page;
private $numbertotal = 0;
public function Index()
{
mysql_connect("sql11.pcextreme.nl", "46772webprom", "dkz644");
mysql_select_db("46772webprom");
$this->page = GetHandler::getPage();
if($this->page == "home" || $this->page == "linkruilen" || $this->page == "admin" || $this->page == "contact" || $this->page == "adverteren" || $this->page == "voorwaarden")
$this->TPLFILE = $this->page.".tpl";
else
$this->TPLFILE = "page.tpl";
$this->tpl = new TemplatePower ($this->TPLFILE);
$this->tpl->prepare ();
$this->parse();
}
public function parseColumn($location,$number)
{
$aSql="SELECT id,name FROM links_cat ORDER BY id LIMIT $this->numbertotal,$number";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock ($location);
$this->tpl->assign ("cattitel",$aObj->name);
$this->tpl->assign ("cattitelurl",$aObj->id."/".str_replace("'","",str_replace(" ","_",$aObj->name)));
$bSql="SELECT name,url,tip FROM links WHERE cat_id='".$aObj->id."' AND accept LIKE 'yes' ORDER BY id";
$bSql_query = mysql_query($bSql);
while($bObj = mysql_fetch_object($bSql_query))
{
$this->tpl->newblock ("link_".$location);
$this->tpl->assign("naam",$bObj->name);
$this->tpl->assign("url",$bObj->url);
if($bObj->tip=="yes")
$this->tpl->assign("class", " class=\"tip\"");
}
}
$this->numbertotal = $this->numbertotal+$number;
}
public function parseAdverteren()
{
if($_POST[submit])
{
$error = false;
$name = htmlspecialchars($_POST[name], ENT_QUOTES);
$url = htmlspecialchars($_POST[url], ENT_QUOTES);
$url_banner = htmlspecialchars($_POST[url_banner], ENT_QUOTES);
$email = htmlspecialchars($_POST[email], ENT_QUOTES);
if($_POST[name]=="")
{
$error = true;
$nameerror = "U moet uw websitenaam invullen.";
}
if(!ereg("^http://.+\..+$",$_POST[url]))
{
$error = true;
$urlerror = "U moet uw websiteurl correct invullen.";
}
if(!ereg("^http://.+\..+$",$_POST[url_banner]))
{
$error = true;
$url_bannererror = "U moet de url van uw banner correct invullen.";
}
if(($_POST[type]=="468x60" && $_POST[location]=="links") || ($_POST[type]=="234x60" && $_POST[location]=="links") || ($_POST[type]=="120x600" && $_POST[location]=="onderaan") || ($_POST[type]=="120x600" && $_POST[location]=="bovenaan") || ($_POST[type]=="120x300" && $_POST[location]=="onderaan") || ($_POST[type]=="120x300" && $_POST[location]=="bovenaan"))
{
$error = true;
$advertentieerror = "Een banner met formaat ".$_POST[type]." kan niet ".$_POST[location]." worden geplaatst.";
}
if(!ereg("^.+@.+\..+$",$_POST[email]))
{
$error = true;
$emailerror = "U moet uw emailadres correct invullen.";
}
if($error)
{
$this->tpl->newblock("beginform");
$this->tpl->assign ("namevalue",$name);
$this->tpl->assign ("nameerror",$nameerror);
$this->tpl->assign ("urlvalue",$url);
$this->tpl->assign ("urlerror",$urlerror);
$this->tpl->assign ("url_bannervalue",$url_banner);
$this->tpl->assign ("url_bannererror",$url_bannererror);
$this->tpl->assign ("advertentieerror",$advertentieerror);
$this->tpl->assign ("emailvalue",$email);
$this->tpl->assign ("emailerror",$emailerror);
$aSql="SELECT type FROM banner_type ORDER BY id";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock("type");
$this->tpl->assign ("type",$aObj->type);
if($aObj->type=="tekstlink")
$this->tpl->assign ("typename",$aObj->type);
else
$this->tpl->assign ("typename","banner ".$aObj->type);
if($aObj->type == $_POST[type])
$this->tpl->assign("geselecteerd", " selected=\"selected\"");
}
$aSql="SELECT location FROM banner_location ORDER BY id";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock("locatie");
$this->tpl->assign ("locatie",$aObj->location);
if($aObj->location == $_POST[location])
$this->tpl->assign("geselecteerd", " selected=\"selected\"");
}
$aSql="SELECT page FROM banner_page ORDER BY id";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock("pagina");
$this->tpl->assign ("pagina",$aObj->page);
if($aObj->page == $_POST[page])
$this->tpl->assign("geselecteerd", " selected=\"selected\"");
}
}
else
{
$insert = "INSERT INTO ads (name, url, url_banner, banner_type, banner_location, banner_page, email) VALUES ('$name', '$url', '$url_banner', '$_POST[type]', '$_POST[location]', '$_POST[page]', '$email')";
$query = mysql_query($insert)or die(mysql_error());
mail("info@websitepromoten.be", "Adverteren - Aanvraag", "Hallo webmaster,
De website met volgende gegevens wil adverteren op Website Promoten:
Naam website: $name
Url website: $url
Url banner: $url_banner
Type banner: $_POST[type]
Locatie banner: $_POST[location]
Pagina banner: $_POST[page]
E-mailadres: $email
", "From: $name<$email>\nReturn-path: $email");
$this->tpl->newblock("eindeform");
}
}
else
{
$this->tpl->newblock("beginform");
$this->tpl->assign ("urlvalue","http://");
$this->tpl->assign ("url_bannervalue","http://");
$aSql="SELECT type FROM banner_type ORDER BY id";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock("type");
$this->tpl->assign ("type",$aObj->type);
if($aObj->type=="tekstlink")
$this->tpl->assign ("typename",$aObj->type);
else
$this->tpl->assign ("typename","banner ".$aObj->type);
}
$aSql="SELECT location FROM banner_location ORDER BY id";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock("locatie");
$this->tpl->assign ("locatie",$aObj->location);
}
$aSql="SELECT page FROM banner_page ORDER BY id";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock("pagina");
$this->tpl->assign ("pagina",$aObj->page);
}
$this->tpl->assign ("emailvalue",$_POST[email]);
$this->tpl->assign ("emailerror",$emailerror);
}
}
public function parseLinks()
{
if(GetHandler::getCat()!="")
$this->tpl->assign ("subtitel"," ~ ".GetHandler::getCat());
if($_POST[submit])
{
$error = false;
$name = htmlspecialchars($_POST[name], ENT_QUOTES);
$url = htmlspecialchars($_POST[url], ENT_QUOTES);
$url_link = htmlspecialchars($_POST[url_link], ENT_QUOTES);
$email = htmlspecialchars($_POST[email], ENT_QUOTES);
preg_match_all("/[A-Z]/", $_POST[name], $your_match) ;
$total_upper_case_count = count($your_match [0]);
if($total_upper_case_count>3)
{
$error = true;
$nameerror = "U websitenaam bevat teveel hoofdletters.";
}
if($_POST[name]=="")
{
$error = true;
$nameerror = "U moet uw websitenaam invullen.";
}
$aSql = mysql_query("SELECT * FROM links WHERE url LIKE '%".$_POST[url]."%'");
$indb = mysql_num_rows($aSql);
if($indb!=0)
{
$error = true;
$urlerror = "Uw website staat al in onze database.";
}
if(!ereg("^http://.+\..+$",$_POST[url]))
{
$error = true;
$urlerror = "U moet uw websiteurl correct invullen.";
}
if(!ereg("^http://.+\..+$",$_POST[url_link]))
{
$error = true;
$url_linkerror = "U moet de pagina waarop de link staat naar Website Promoten correct invullen.";
}
if(!ereg("^.+@.+\..+$",$_POST[email]))
{
$error = true;
$emailerror = "U moet uw emailadres correct invullen.";
}
if($error)
{
$this->tpl->newblock("beginform");
$this->tpl->assign ("namevalue",$name);
$this->tpl->assign ("nameerror",$nameerror);
$this->tpl->assign ("urlvalue",$url);
$this->tpl->assign ("urlerror",$urlerror);
$this->tpl->assign ("url_linkvalue",$url_link);
$this->tpl->assign ("url_linkerror",$url_linkerror);
$this->tpl->assign ("emailvalue",$email);
$this->tpl->assign ("emailerror",$emailerror);
$aSql="SELECT id,name FROM links_cat ORDER BY id";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock("categorien");
$this->tpl->assign ("id",$aObj->id);
$this->tpl->assign ("categorie",$aObj->name);
if($aObj->id == $_POST[cat])
$this->tpl->assign("geselecteerd", " selected=\"selected\"");
}
}
else
{
$insert = "INSERT INTO links (cat_id, name, url, url_link, email) VALUES ($_POST[cat], '$name', '$url', '$url_link', '$email')";
$query = mysql_query($insert)or die(mysql_error());
mail("info@websitepromoten.be", "Link Ruilen - Aanvraag", "Hallo webmaster,
De website met volgende gegevens is toegevoegd aan de database:
Categorie id: $_POST[cat]
Naam website: $name
Url website: $url
Url pagina met link naar Website Promoten: $url_link
E-mailadres: $email
Admin pagina: http://www.websitepromoten.be/admin/
", "From: $name<$email>\nReturn-path: $email");
$this->tpl->newblock("eindeform");
}
}
else
{
$this->tpl->newblock("beginform");
$this->tpl->assign ("urlvalue","http://");
$this->tpl->assign ("url_linkvalue","http://");
$aSql="SELECT id,name FROM links_cat ORDER BY id";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock("categorien");
$this->tpl->assign ("id",$aObj->id);
$this->tpl->assign ("categorie",$aObj->name);
if($aObj->name == GetHandler::getCat())
$this->tpl->assign("geselecteerd", " selected=\"selected\"");
}
}
}
public function parseContact()
{
if($_POST[submit])
{
$error = false;
$name = htmlspecialchars($_POST[name], ENT_QUOTES);
$email = htmlspecialchars($_POST[email], ENT_QUOTES);
$url = htmlspecialchars($_POST[url], ENT_QUOTES);
$subject = htmlspecialchars($_POST[subject], ENT_QUOTES);
$context = htmlspecialchars($_POST[context], ENT_QUOTES);
if($_POST[name]=="")
{
$error = true;
$nameerror = "U moet uw naam invullen.";
}
if(!ereg("^.+@.+\..+$",$_POST[email]))
{
$error = true;
$emailerror = "U moet uw emailadres correct invullen.";
}
if(!ereg("^http://.+\..+$",$_POST[url]) && $_POST[url]!="" && $_POST[url]!="http://")
{
$error = true;
$urlerror = "U moet uw websiteurl correct invullen.";
}
if($_POST[subject]=="")
{
$error = true;
$subjecterror = "U moet een onderwerp invullen.";
}
if($_POST[context]=="")
{
$error = true;
$contexterror = "U moet een bericht invullen.";
}
if($error)
{
$this->tpl->newblock("beginform");
$this->tpl->assign ("namevalue",$name);
$this->tpl->assign ("nameerror",$nameerror);
$this->tpl->assign ("emailvalue",$email);
$this->tpl->assign ("emailerror",$emailerror);
$this->tpl->assign ("urlvalue",$url);
$this->tpl->assign ("urlerror",$urlerror);
$this->tpl->assign ("subjectvalue",$subject);
$this->tpl->assign ("subjecterror",$subjecterror);
$this->tpl->assign ("contextvalue",$context);
$this->tpl->assign ("contexterror",$contexterror);
}
else
{
mail("info@websitepromoten.be", "$subject", "$context
$name
$url
", "From: $name<$email>\nReturn-path: $email");
$this->tpl->newblock("eindeform");
}
}
else
{
$this->tpl->newblock("beginform");
$this->tpl->assign ("urlvalue","http://");
}
}
public function parseVoorwaarden()
{
}
public function parseAdmin()
{
if(GetHandler::getId()!="" && GetHandler::getAction()!="")
{
if($_GET[action]=="goedkeuren" || $_GET[action]=="afkeuren")
{
$query = "UPDATE links SET accept='".GetHandler::getAction()."' WHERE id=".GetHandler::getId()."";
mysql_query($query) or die(mysql_error());
$aSql="SELECT * FROM links WHERE id=".GetHandler::getId()."";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
if(GetHandler::getAction()=="yes")
{
mail("$aObj->email", "Website goedgekeurd", "Geachte,
Uw website, $aObj->name, is succesvol opgenomen op de startpagina van Website Promoten.
Groeten,
de webmasters
http://www.websitepromoten.be", "From: Website Promoten\nReturn-path: info@websitepromoten.be");
}
else
{
mail("$aObj->email", "Website afgekeurd", "Geachte,
Helaas is uw website, $aObj->name, niet opgenomen op de startpagina van Website Promoten.
Dit komt waarschijnlijk omdat het niet voldoet aan de voorwaarden:
http://www.websitepromoten.be/voorwaarden
Voor meer informatie kunt u ons altijd bereiken via info@websitepromoten.be.
Groeten,
de webmasters
http://www.websitepromoten.be", "From: Website Promoten\nReturn-path: info@websitepromoten.be");
}
}
}
else
{
$query = "UPDATE ads SET accept='".GetHandler::getAction()."' WHERE id=".GetHandler::getId()."";
mysql_query($query) or die(mysql_error());
}
}
$aSql="SELECT * FROM links WHERE accept LIKE 'no' ORDER BY id";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock("valideren");
$this->tpl->assign ("categorie",$aObj->cat_id);
$this->tpl->assign ("url",$aObj->url);
$this->tpl->assign ("naam",$aObj->name);
$this->tpl->assign ("url_link",$aObj->url_link);
$this->tpl->assign ("id",$aObj->id);
}
$aSql="SELECT * FROM links WHERE accept LIKE 'yes' ORDER BY id";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock("goedgekeurd");
$this->tpl->assign ("categorie",$aObj->cat_id);
$this->tpl->assign ("url",$aObj->url);
$this->tpl->assign ("naam",$aObj->name);
$this->tpl->assign ("url_link",$aObj->url_link);
$this->tpl->assign ("id",$aObj->id);
}
$aSql="SELECT * FROM links WHERE accept LIKE 'never' ORDER BY id";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock("afgekeurd");
$this->tpl->assign ("categorie",$aObj->cat_id);
$this->tpl->assign ("url",$aObj->url);
$this->tpl->assign ("naam",$aObj->name);
$this->tpl->assign ("url_link",$aObj->url_link);
$this->tpl->assign ("id",$aObj->id);
}
$aSql="SELECT * FROM ads WHERE accept LIKE 'no' ORDER BY id";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock("validerenad");
$this->tpl->assign ("url",$aObj->url);
$this->tpl->assign ("naam",$aObj->name);
$this->tpl->assign ("locatie",$aObj->banner_location);
$this->tpl->assign ("pagina",$aObj->banner_page);
$this->tpl->assign ("url_banner",$aObj->url_banner);
$this->tpl->assign ("id",$aObj->id);
}
$aSql="SELECT * FROM ads WHERE accept LIKE 'yes' ORDER BY id";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock("goedgekeurdad");
$this->tpl->assign ("url",$aObj->url);
$this->tpl->assign ("naam",$aObj->name);
$this->tpl->assign ("locatie",$aObj->banner_location);
$this->tpl->assign ("pagina",$aObj->banner_page);
$this->tpl->assign ("url_banner",$aObj->url_banner);
$this->tpl->assign ("id",$aObj->id);
}
$aSql="SELECT * FROM ads WHERE accept LIKE 'never' ORDER BY id";
$aSql_query = mysql_query($aSql);
while($aObj = mysql_fetch_object($aSql_query))
{
$this->tpl->newblock("afgekeurdad");
$this->tpl->assign ("url",$aObj->url);
$this->tpl->assign ("naam",$aObj->name);
$this->tpl->assign ("locatie",$aObj->banner_location);
$this->tpl->assign ("pagina",$aObj->banner_page);
$this->tpl->assign ("url_banner",$aObj->url_banner);
$this->tpl->assign ("id",$aObj->id);
}
}
public function parse()
{
$this->tpl->assign ("titel",GetHandler::getSubject($this->page));
if($this->page == "home")
{
if(time()<1425164400)
$this->tpl->assign ("advert","OpeningsurenGids.be - ");
$this->parseColumn("links",5);
$this->parseColumn("midden",5);
$this->parseColumn("rechts",6);
}
elseif($this->page == "linkruilen")
$this->parseLinks();
elseif($this->page == "admin")
$this->parseAdmin();
elseif($this->page == "contact")
$this->parseContact();
elseif($this->page == "adverteren")
$this->parseAdverteren();
elseif($this->page == "voorwaarden")
$this->parseVoorwaarden();
$this->tpl->printToScreen ();
}
}
$index = new Index();
?>