<?php
//This script is written by and donwloaded from http://www.music-i-love.com website.
session_start();
if (($_GET["posting"] != "yes") && (($_GET["accept"] != "yes") && ($_GET["accept"] != "no")))
{
$_SESSION["ads"] = "step_1";
}
if ($_GET["posting"] == "yes")
{
if($_SESSION["ads"] == "step_1")
{
//paspaudus ant nuorodos turi ismesti anketa, kad leistu ideti video klipu nuorodas ir aprasymus
$posting = $_GET["posting"];
}
else
{
// redirect to current page so if we click the refresh button
// the form won't be resubmitted ( as that would make duplicate entries )
header('Location:' . $_SERVER['PHP_SELF']);
exit;
}
}
if (($_GET["accept"] == "yes") || ($_GET["accept"] == "no"))
{
session_unset($_SESSION["ads"]);
}
//*******************************************************************************************
//************ The variables that can be changed according to one's needs *******************
//*******************************************************************************************
//Create a folder with a desired name for storing ad files inside
$ads_folder = "ads_entries";
//Provide a number of how many days an ad is to be displayed before it's deleted. If set to 0, it earases everything
$how_old = 100;
//How many ads to display in 1 page
$entries_per_page = 10;
//How many pages to dispaly in 1 listing before clicking 'Next' link for the following one
$quantity_of_pages_per_listing = 3;
//Topics of classified ads. Change the names (array values) according to the needs, add new ones or delete
$topic_array = array();
$topic_array[0] = "Music";
$topic_array[1] = "Entertainment";
$topic_array[2] = "Services, job, cooperation";
$topic_array[3] = "Real Esteem";
$topic_array[4] = "Transport";
$topic_array[5] = "Computers, Household Appl.";
$topic_array[6] = "Websites";
$topic_array[7] = "Communication Appliances";
$topic_array[8] = "Dating";
$topic_array[9] = "Other";
$topic_array[10] = "Programming: Scripts";
//Forbidden expressions. Prevent the ads from being posted if they have it
$neleistinos_frazes = "/Content - Type|Content- Type|Content -Type|Content-Type|@manomuzika.com|poker|cash|america|slots|casino|game/i";
//The e-mail you would like to receive a notification to when an ad posting is made
$to = 'hide@address.com';
//********************************************************************************************
//************** Don't change anything below unless you know what you do *********************
//********************************************************************************************
$topic_get = $_GET["topic_get"] ;
if (!isset($topic_get))
{
$topic_get = "RECENT";
}
$id_get = $_GET["id_get"] ;
$topic_get_from_adsform = $_GET['topic_get_from_adsform'];
$next_id = ($_GET['max_id'])+1;
if (isset($_GET['page']))
{
$page_get = $_GET['page'];
}
else
{
$page_get = 1 ;
}
if (!empty($_GET['next_from']))
{
$next_from_get = $_GET['next_from'];
}
else
{
$next_from_get = 0;
}
$ads_dir = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) ."/" . $ads_folder ;
//***********************************
//Estimation and inclusion of posting
// check if the form is submitted
if(isset($_POST['btnSign']))
{
$name_without_slashes = stripslashes(trim($_POST['name']));
$name_without_tags = strip_tags($name_without_slashes);
$name_clean = str_replace("||", "", $name_without_tags) ;
$phone_without_slashes = stripslashes(trim($_POST['phone']));
$phone_without_tags = strip_tags($phone_without_slashes);
$phone_clean = str_replace("||", "", $phone_without_tags) ;
$email_without_slashes = stripslashes(trim($_POST['email']));
$email_without_tags = strip_tags($email_without_slashes);
$email_clean = str_replace("||", "", $email_without_tags) ;
$url_without_slashes = stripslashes(trim($_POST['url']));
$url_without_tags = strip_tags($url_without_slashes);
$url_clean = str_replace("||", "", $url_without_tags) ;
$location_without_slashes = stripslashes(trim($_POST['location']));
$location_without_tags = strip_tags($location_without_slashes);
$location_clean = str_replace("||", "", $location_without_tags) ;
$ad_without_slashes = stripslashes(trim($_POST['ad']));
$ad_without_tags = strip_tags($ad_without_slashes);
$ad_clean = str_replace("||", "", $ad_without_tags) ;
$ad_clean_short = substr_replace($ad_clean, '', 3000);
if ($url_clean == "http://www.")
{
$url_clean = "";
}
//An array of the entries to check
$irasai_is_anketos = array();
$irasai_is_anketos[0] = $name_clean ;
$irasai_is_anketos[1] = $phone_clean ;
$irasai_is_anketos[2] = $email_clean ;
$irasai_is_anketos[3] = $url_clean ;
$irasai_is_anketos[4] = $location_clean ;
$irasai_is_anketos[5] = $ad_clean_short ;
//Script that calculates the spaces between words. $per_ilgi_irasai variable calcultes how many GET entries have too long words
$per_ilgi_irasai = 0;
foreach ($irasai_is_anketos as $irasai_is_anketos_foreach)
{
$teksto_ilgis = strlen($irasai_is_anketos_foreach) ;
$tarpeliu_sk = substr_count($irasai_is_anketos_foreach, ' ') ;
$prival_tarpu_sk = $teksto_ilgis * 12 / 500 ;
list($sveikas_sk, $po_kablelio) = explode(".", $prival_tarpu_sk);
if ($tarpeliu_sk < $sveikas_sk)
{
$per_ilgi_irasai++ ;
}
}
//If the number of too long GET variables is not excessed the check sript goes to the next stage. It checks how many occurances of forbiden expressions it has
//It checks every GET variable from the ads form which is included in the array above
if ($per_ilgi_irasai <= 1)
{
$viso_rasta = 0;
foreach ($irasai_is_anketos as $tekstai)
{
if (preg_match($neleistinos_frazes, $tekstai))
{
$viso_rasta ++ ;
}
}
//$viso_rasta calculates the number of uccurances of the forbiden expression. if it is not excessed, go to the next stage
if ($viso_rasta <= 3)
{
$ads_file = $ads_dir ."/". $topic_get_from_adsform ."-". $next_id . ".txt" ;
if (!empty($name_clean) && !empty($ad_clean_short))
{
$search_for_topic = array_search($topic_get_from_adsform, array_flip($topic_array));
$ad_content = $next_id ."||". $search_for_topic ."||". date("Y-m-d G:i:s") ."||". $name_clean ."||". $phone_clean ."||". $email_clean ."||". $url_clean ."||". $ad_clean_short ."||". $location_clean ."||". $_SERVER['REMOTE_ADDR'] ."||". time() ."||" ;
$ads_file_open = fopen($ads_file, "w");
fwrite($ads_file_open, $ad_content);
fclose($ads_file_open);
$subject = 'New ad posted: ' . $search_for_topic ;
$message = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER["PHP_SELF"] . "?topic_get=" . $topic_get_from_adsform . "&id_get=" . $next_id ;
$headers = "From:". $email_clean . "\r\n" .
'Reply-To:'. $email_clean . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers) ;
$hederi_nukreipti = $_SERVER["PHP_SELF"] ;
// redirect to current page so if we click the refresh button
// the form won't be resubmitted ( as that would make duplicate entries )
header('Location:' . $hederi_nukreipti . '?accept=yes');
// force to quite the script. if we don't call exit the script may
// continue before the page is redirected
exit;
}
else
{
// redirect to current page so if we click the refresh button
// the form won't be resubmitted ( as that would make duplicate entries )
header('Location:' . $hederi_nukreipti . '?accept=no');
// force to quite the script. if we don't call exit the script may
// continue before the page is redirected
exit;
}
}
else
{
// redirect to current page so if we click the refresh button
// the form won't be resubmitted ( as that would make duplicate entries )
header('Location:' . $hederi_nukreipti . '?accept=no&found' . $viso_rasta);
exit;
}
}
}
?>