403Webshell
Server IP : 51.89.169.208  /  Your IP : 3.148.192.32
Web Server : Apache
System : Linux ns3209505.ip-198-244-202.eu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Tue Nov 5 04:50:16 EST 2024 x86_64
User : yellowleaf ( 1019)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/yellowleaf/public_html/staff/advert/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/yellowleaf/public_html/staff/advert/index.php
<?php
$path  = $_SERVER['DOCUMENT_ROOT'];
include_once $path.'/connect_db.php';
include_once($path.'/staff/advert/plural.php'); 
$id=addslashes($_GET['id']);

$example_list=array('e.g. Restaurant','e.g. Indian Food','e.g. Curry House');
$example_false=array('eg','eg','eg');
if(addslashes($_GET['approve'])==1)
{
	 $connect->query("UPDATE ads SET active = 1 , decline = 0 WHERE adid = '$id' ") or die($connect->error);
	 $mg = '<div id="mg" class="alert alert-success">Advert approved successfully.</div>';
}
if(addslashes($_GET['decline'])==1)
{
	 $connect->query("UPDATE ads SET active = 0 , decline = 1 WHERE adid = '$id' ") or die($connect->error);
	 $mg = '<div id="mg" class="alert alert-error">Advert declined successfully.</div>';
}
if(isset($_POST['submit'])){

	// echo "<pre>";
	// print_r($_POST);
	// die();
	$vaild = true;
	$companyname=addslashes($_POST['companyname']);
	$address1=addslashes($_POST['address1']);	
	$address2=addslashes($_POST['address2']);	
	$countys=addslashes($_POST['county']);	
	$countyDetails= explode("||",$countys);
	$county=$countyDetails[0];
	$county_name=$countyDetails[2];
	$town = addslashes($_POST['town']);
	$townDetails = explode("|", $town);
	$longitude=$townDetails[0];
	$latitude=$townDetails[1];
	$town_name=$townDetails[2];
	
	$postcode=addslashes($_POST['postcode']);
	$telephone=str_replace(' ','',addslashes($_POST['telephone']));
	$btype=addslashes($_POST['btype']);
	$mcategory=addslashes($_POST['mcategory']);
	$fax=addslashes($_POST['fax']);
	$email=addslashes($_POST['email']);
	$url=addslashes(trim($_POST['url']));
	$time = time();
	$aspect_ratio = 0;

	// die($btype);

	if (isset($_POST["aspect_ratio"])) {
		$aspect_ratio = 1;
	}else{
		$aspect_ratio = 0;
	}
	// if website url is "http://" only make field blank
	if($url=="http://"){$url=str_replace("http://","",$url);}
	
	if(!$companyname)
	{
	   $vaild = false;
	   $errorcompanyname = 'error-message';
	}
	if(!$address1)
	{
	   $vaild = false;
	   $erroraddress1 = 'error-message';
	}
	if(!$countys)
	{
	   $vaild = false;
	   $errorcounty = 'error-message';
	}
	if(!$town)
	{
	   $vaild = false;
	   $errortown = 'error-message';
	}
	if(!$postcode)
	{
	   $vaild = false;
	   $errorpostcode = 'error-message';
	}
	if(!$telephone)
	{
	   $vaild = false;
	   $errortelephone = 'error-message';
	}
	if(!$email)
	{
	   $vaild = false;
	   $erroremail = 'error-message';
	}
	if(!$btype)
	{
	   $vaild = false;
	   $errorbtype = 'error-message';
	}
	
	$description=addslashes($_POST['description']);
	$services=addslashes($_POST['services']);
	$refund=addslashes($_POST['refund']);
	$establishment=addslashes($_POST['establishment']);
	$areas_cover=addslashes($_POST['areas_cover']);
	if(!$description)
	{
	   $vaild = false;
	   $errordescription = 'error';
	}
	
	
	$fieldname = 'image_upload_box';
	if(is_uploaded_file($_FILES[$fieldname]['tmp_name'])){
		$fieldname = 'image_upload_box';
		$image_temp = $_FILES[$fieldname]["tmp_name"];
		$allowed_ext = array('jpeg','jpg','png','gif');
		$image_ext = strtolower(end(explode('.', $_FILES[$fieldname]['name'])));
		$destination = $path.'/members/uploads/logo/';
		$image_file = $id.'.'.$image_ext;
		if (in_array($image_ext, $allowed_ext) === false) {
			$vaild = false;
			$errorimage = '<span class="error">- Your photo must be either a JPG, PNG or GIF file format. Other file types are not allowed.</span>';
		}
		if($_FILES[$fieldname]["size"] > 4000000){
			$vaild = false;
			$errorimage='<span class="error">- Image file size must be less than 4 MB.</span>';
		}
		if(empty($errorimage)){
			include "img_upload.class.php";
			$image = new UploadImage();
			$image->load($image_temp);
			$image->resizeToWidthMaxHeight(300,150);
			$image->save($destination.$image_file);
			$imageExist=", image = '{$image_file}'";
		}
		
	}
	
	$monday=addslashes($_POST['monday']);
	$tuesday=addslashes($_POST['tuesday']);
	$wednesday=addslashes($_POST['wednesday']);
	$thursday=addslashes($_POST['thursday']);
	$friday=addslashes($_POST['friday']);
	$saturday=addslashes($_POST['saturday']);
	$sunday=addslashes($_POST['sunday']);
		
	// $serv1 = array_filter(array_map('trim',addslashes($_POST['serv'])));
	// $serv=implode(" || ", $serv1);
	
	$promotion=addslashes($_POST['promotion']);
	$urlPattern='#^http[s]?://+#i';
	$facebook=preg_replace($urlPattern,"",addslashes($_POST['facebook']));
	$twitter=preg_replace($urlPattern,"",addslashes($_POST['twitter']));
	$google=preg_replace($urlPattern,"",addslashes($_POST['googleplus']));
	$youtube=preg_replace($urlPattern,"",addslashes($_POST['youtube']));
	$linkedin=preg_replace($urlPattern,"",addslashes($_POST['linkedin']));
	
	
	
	// $categories=addslashes($_POST['category']);
	
	

	
	$q3 = "UPDATE `opening_hours` SET 
		 
		 `monday` = '$monday',
		 `tuesday` = '$tuesday',
		 `wednesday` = '$wednesday',
		 `thursday` = '$thursday',
		 `friday` = '$friday',
		 `saturday` = '$saturday',
		 `sunday` = '$sunday'
		 WHERE opadid = '$id' ";
	$r3 =  $connect->query($q3) or die($connect->error);
	
	$q6 = "UPDATE social_links SET
			facebook = '$facebook',
			googleplus = '$google',
			twitter = '$twitter',
			youtube = '$youtube',
			linkedin = '$linkedin'
			WHERE so_ad_id = '$id' ";

	$r6 = $connect->query($q6) or die($connect->error);
	

	
	 
	// $imageExist="image = '{$fname}',";
	
	
	        $q3 = "UPDATE ads SET
	       companyname = '$companyname',
		   street1 = '$address1',
		   street2 = '$address2',
		   county_name = '$county_name',
		   aspect_ratio = '$aspect_ratio',
		   town_name = '$town_name',
		   postcode = '$postcode',
		   tel = '$telephone',
		   fax = '$fax',
		   email = '$email',
		   url = '$url',
		   business_type = '$btype',
		   mcategory = '$mcategory',
		   postdate = '$time',
		   longitude = '$longitude',
		   latitude = '$latitude',
		   description='$description'
		   {$imageExist} 
		   
		   
		   WHERE adid = '$id' ";  

	$r3 = $connect->query($q3) or die($connect->error);
	$success=TRUE;
	
}

$add_que_sql = $connect->query("SELECT * FROM ads WHERE adid ='{$id}'");
$add_row = $add_que_sql->fetch_array();



foreach($add_row as $k=>$val){ $$k=$val; }
$adcounty_name = $add_row['county_name'];
$serv = explode('||',$services_offered);
$category_data = explode('||',$category);


$time_slot = $connect->query("SELECT * FROM opening_hours WHERE opadid  ='{$id}'");
$time_slot_data = $time_slot->fetch_array();

$social_link = $connect->query("SELECT * FROM social_links WHERE so_ad_id  ='{$id}'");
$social_data = $social_link->fetch_array();



$categoriess=explode("||",$add_row['products']);

for($i=0; $i<=4;$i++)
{
	   $ctt = $categoriess[$i];
		$categoryHtml.='
		<div class="category">
			<input value="'.$ctt.'" type="text"  name="product[]" class="form-control" >
		</div><br>';
}

$image_logo = $add_row["image"];
$mcategory = $add_row["mcategory"];

$aspect_ratio_checked = "";

if ($add_row["aspect_ratio"] == 1) {
	$aspect_ratio_checked = "checked";
}

	
	/////// FETCHING PHOTOS
	$query = $connect->query("SELECT * FROM ads WHERE adid = '$adid'");
	// $query = $connect->query("SELECT * FROM ads WHERE memberid = '$memberid' and adid = '$adid'");
	$row = $query->fetch_array();

	$photo1 = $row["photo_1"];
	$photo2 = $row["photo_2"];
	$photo3 = $row["photo_3"];
	$photo4 = $row["photo_4"];

	$business_type = $row["business_type"];

	$photos = "";
	if (!empty($photo1) && $photo1 != "0") {
		$path1 = "/members/uploads/1/$photo1";
		$photos .= "<div><img src='{$path1}' alt=''/><a pid='1' href='?del=yes&pid=1&adid=$adid' class='remove-image'><i class='bx bxs-trash'></i></a></div>";
	}

	if (!empty($photo2) && $photo2 != "0") {
		$path2 = "/members/uploads/2/$photo2";
		$photos .= "<div><img src='{$path2}' alt=''/><a pid='2' href='?del=yes&pid=1&adid=$adid' class='remove-image'><i class='bx bxs-trash'></i></a></div>";
	}

	if (!empty($photo3) && $photo3 != "0") {
		$path3 = "/members/uploads/3/$photo3";
		$photos .= "<div><img src='{$path3}' alt=''/><a pid='3' href='?del=yes&pid=1&adid=$adid' class='remove-image'><i class='bx bxs-trash'></i></a></div>";
	}

	if (!empty($photo4) && $photo4 != "0") {
		$path4 = "/members/uploads/4/$photo4";
		$photos .= "<div><img src='{$path4}' alt=''/><a pid='4' href='?del=yes&pid=1&adid=$adid' class='remove-image'><i class='bx bxs-trash'></i></a></div>";
	}

?>
<!DOCTYPE html>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>YellowLeaf UK</title>
<link href='https://unpkg.com/boxicons@2.0.9/css/boxicons.min.css' rel='stylesheet'>
<link rel="stylesheet" href="/header-footer/global.css">
<link rel="stylesheet" href="/staff/style_staff.css">

<style>
	.image-uploaded {
		display: grid;
		grid-template-columns: 1fr 1fr 1fr 1fr;
		gap: 20px;
		margin-bottom: 16px;
	}
	.image-uploaded > * {
		position: relative;
		max-height: 150px;
	}
	.image-uploaded img {
		width: 100%;
		height: 100%;
		display: block;
		object-fit: contain;
	}
	.remove-image {
		position: absolute;
		top: 8px;
		right: 8px;
		font-size: 16px;
		color: var(--red);
		width: 26px;
		height: 26px;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: var(--gray);
		text-decoration: none;
	}

	@media screen and (max-width: 767px) {
		.image-uploaded {
			grid-template-columns: 1fr 1fr;
		}
	}
</style>
</head>

<body>

<!-- start: Top Bar -->
<?php 
include_once($path.'/staff/staff_header.php'); 
?>
<!-- end: Top Bar -->
	<!-- start: Table -->
	<div class="table-section">
		<div class="container lg">
			<? if($success == TRUE){
				echo '<span style="padding: 5px;background: #c6ffc6;color: green;border: 1px solid green;border-radius: 5px;display: block;margin-bottom: 10px;">Advert update success</span>';
			} ?>
			<form class="submit-advert-form" action="" method="POST" enctype="multipart/form-data">
				<?=$mg?>
				<div class="submit-advert-form-group">
					<label for="name">Business Name:</label>
					<p class="submit-advert-label-description <?=$errorcompanyname?>">Please enter your business
						name.</p>
					<input value="<?=$companyname?>" type="text" name="companyname" id="companyname"
						class="form-control">

				</div>
				<div class="submit-advert-form-group">
					<label for="county">Business County:</label>
					<p class="submit-advert-label-description <?=$errorcounty?>">Please select the county of where
						your business is located.</p>
					<select id="county" name="county" class="form-control"
						onchange="get_town_drop(this.value,'')">
						<option value="" selected="">Select a County</option>
						<?
						$get=$connect->query("SELECT * FROM `county` WHERE `county_id`!='999' ORDER BY divide_country ASC, county_name ASC");
						
						while ($row_county = $get->fetch_assoc()) {
							foreach($row_county AS $key => $val){ $$key = stripslashes(strip_tags($val)); }
							if ($county_name == "Bedfordshire") { if ($newcat) { $county.='</optgroup>'; } $county.='<optgroup label="England">'; $newcat=1; }
							if ($county_name == "County Antrim") { if ($newcat) { $county.='</optgroup>'; } $county.='<optgroup label="Northern Ireland">'; $newcat=1; }
							if ($county_name == "Aberdeen") { if ($newcat) { $county.='</optgroup>'; } $county.='<optgroup label="Scotland">'; $newcat=1; }
							if ($county_name == "Blaenau Gwent") { if ($newcat) { $county.='</optgroup>'; } $county.='<optgroup label="Wales">'; $newcat=1; }
							if ($county_name == "Channel Islands") { if ($newcat) { $county.='</optgroup>'; } $county.='<optgroup label="Channel Islands">'; $newcat=1; }
							$sel = $county_name== $add_row['county_name'] ? 'selected' : ''  ;
							
							$county.='<option '.$sel.' value="'.$county_id.'||'.$divide_country.'||'.$county_name.'">'.$county_name.'</option>';
						}
						echo $county;
						?>

					</select>
				</div>

				<div class="submit-advert-form-group">
					<label for="county">Business Town / Area:</label>
					<p class="submit-advert-label-description <?=$errortown?>">Please select the town of where your
						business is located.</p>
					<select id="town" name="town" class="form-control">
						<option value="" selected="">Select a Town</option>
					</select>
				</div>


				<div class="submit-advert-form-group">
					<label for="address">Business Address:</label>
					<p class="submit-advert-label-description <?=$erroraddress1?>">Please enter the address of your
						business.</p>
					<textarea id="address1" name="address1" cols="30" rows="5"
						class="form-control"><?=$street1?></textarea>
				</div>
				<div class="submit-advert-form-group">
					<label for="postcode">Postcode:</label>
					<p class="submit-advert-label-description <?=$errorpostcode?>">Please enter your business
						postcode.</p>
					<input value="<?=$postcode?>" name="postcode" type="text" id="postcode" class="form-control">
				</div>
				<div class="submit-advert-form-group">
					<label for="phone">Telephone:</label>
					<p class="submit-advert-label-description <?=$errortelephone?>">Please enter your business
						telephone number.</p>
					<input value="<?=$tel?>" name="telephone" type="tel" id="phone" class="form-control">
				</div>
				<div class="submit-advert-form-group">
					<label for="fax">FAX (optional):</label>
					<p class="submit-advert-label-description">Please enter your business FAX number.</p>
					<input value="<?=$fax?>" type="text" name="fax" id="fax" class="form-control">
				</div>
				<div class="submit-advert-form-group">
					<label for="email">Email:</label>
					<p class="submit-advert-label-description <?=$erroremail?>">Please enter your business email
						address. This will be kept confidential.</p>
					<input value="<?=$email?>" type="email" id="email" name="email" class="form-control">
				</div>
				<div class="submit-advert-form-group">
					<label for="website">Website URL (optional):</label>
					<p class="submit-advert-label-description">Please enter your business website URL.</p>
					<input value="<?=$url?>" type="text" id="url" name="url" class="form-control">
				</div>
				<div class="submit-advert-form-group">
					<label for="type">Type of Business:</label>
					<p class="submit-advert-label-description <?=$errorbtype?>">Please choose a type of business.
					</p>

					<select class="form-control" size="1" id="btype" name="btype">
						<option value="" selected="">Please select</option>

						<option <?=$business_type=='Offering Services' ? 'selected' : '' ?> value="Offering Services">Offering Services</option>
						<option <?=$business_type=='Selling Products' ? 'selected' : '' ?> value="Selling Products">Selling
							Products</option>
					</select>

				</div>
				<div class="submit-advert-form-group">
					<label for="category">Please select a category for your business</label>
					<p class="submit-advert-label-description">PLEASE NOTE: You can only choose one relevant
						category</p>
					<div class="form-control-autocomplete">
						<!-- <input type="hidden" id="category-id" name="bcat">
						<input type="text" class="form-control" id="category" name="bcat"> -->
						<select class="form-control" name="mcategory">
										<option value="" selected>Select a category</option>
										<?
										$get = $connect->query("SELECT * FROM `main_cats` ORDER BY main_cats ASC");
										$category = '';

										while ($row_category = $get->fetch_assoc()) {
											foreach ($row_category as $key => $val) {
												$key = stripslashes(strip_tags($val));

											}
										
											if($mcategory == $row_category["main_cats_id"]){
												$sel = "selected";
											}else{
												$sel = "";
											}
											$category .= '<option value="' . $row_category['main_cats_id'] . '" '.$sel.'>' . $row_category['main_cats'] . '</option>';
										}
										echo $category;
										?>
									</select>
					</div>
					<?php 
							$get=$connect->query("SELECT * FROM `main_cats` ORDER BY `main_cats` ASC LIMIT 100");
							$cats = array();

							while ($row = $get->fetch_assoc()) {
								foreach($row AS $key => $val){ $$key = stripslashes(strip_tags($val)); }
								// $display = preg_replace('/(' . $value . ')/i', '<b class="ls_hghlight">\1</b>', $main_cats);
								// $sel = $bcategory == $main_cats_id ? 'selected' : '';
								$cats[] = ['keyword'=> $main_cats, 'value'=> $main_cats_id, 'html'=>'<li data-keyword="'.$main_cats.'" data-value="'.$main_cats_id.'">'.$main_cats.'</li>'];
							}

							$jsonCats = json_encode($cats);
							
						?>
				</div>

				<div class="image-uploaded" id="image-uploaded">
					<?= $photos ?>
				</div>

				<div class="">
						<label for="name">Upload logo (optional):</label>
						<p class="submit-advert-label-description ">Please upload the logo of your business.</p>
						<?php
						if (!empty($image_logo)) {
							$img_l = "/members/uploads/logo/".$image_logo;
						}else{
							$img_l = "/img/not-found.jpg";
						}

						?>
						<div><img id="logo" style="border-radius: 10px;" height="100px" width="200px" src="<?=$img_l?>"></div>
						<input name="image_upload_box" class="form-control" type="file">
						<?=$errorimage?>
						<div style="margin: 15px"><input type="checkbox" id="url" name="aspect_ratio" <?= $aspect_ratio_checked ?>> Aspect Ratio</div>
					</div>
					
					
					<div class="submit-advert-form-group">
						<label for="address">Description For Your Business:</label>
						<p class="submit-advert-label-description <?=$errordescription?>">Please enter a brief description about your business.</p>
						<textarea id="description" name="description" cols="30" rows="5" class="form-control"><?=$description?></textarea>
					</div>
					
					<!-- <div class="submit-advert-form-group">
						<label for="name">Opening Times:</label>
						<p class="submit-advert-label-description <?=$errorcompanyname?>">Please enter products, services or facilities that your business offers.</p>
						<?php
						$days = [
							'monday','tuesday','wednesday','thursday','friday','saturday','sunday'
						];
						foreach($days as $day) { ?>
						<input value="<?=$time_slot_data[$day]; ?>" placeholder="<?=ucfirst($day)?>"  type="text" name="<?=$day?>"  class="form-control">
						<br>
						<?php } ?>
						
					</div> -->
					
					<div class="submit-advert-form-group">
						<label for="facebook">Your Social Links (optional):</label>
						<p class="submit-advert-label-description <?=$errorpostcode?>">Please provide the links to your social pages</p><br>
						<?php
						$socails = [
							'facebook','googleplus','twitter','youtube','linkedin'
						];
						foreach($socails as $socail) { ?>
						<label for=""><?=ucfirst($socail)?></label><br>
						<input value="<?=$social_data[$socail]?>" placeholder="<?=ucfirst($socail)?>"  type="text" name="<?=$socail?>"  class="form-control">
						<br>
						<?php } ?>
						
					</div>
					
					<?php 
							$get=$connect->query("SELECT * FROM `main_cats` ORDER BY `main_cats` ASC LIMIT 100");
							while ($row = $get->fetch_assoc()) {
							$categorys[] = $row;
							}
					?>
					<!-- <div class="submit-advert-form-group">
						<label for="name">Categories & Tags:</label>
						<p class="submit-advert-label-description <?=$errorcompanyname?>">Please enter a minimum of 3 categories or tags that is related to your business.</p>
						<select class="form-control"  name="category[]">
							<option value="" selected="">Please category</option>
							<?php 
							
							foreach($categorys as $row) {
								foreach($row AS $key => $val){ $$key = stripslashes(strip_tags($val)); }
								$display = preg_replace('/(' . $value . ')/i', '<b class="ls_hghlight">\1</b>', $main_cats); 
								$sel = $bcategory == $main_cats_id ? 'selected' : '';
								$cats.='<option '.$sel.' value="'.$main_cats_id.'">'.$display.'</option>';
								
							}
							echo $cats;
						?>
						</select>
						<br>
						<select class="form-control"  name="category[]">
							<option value="" selected="">Please category</option>
							<?php 
							foreach($categorys as $row) {
								foreach($row AS $key => $val){ $$key = stripslashes(strip_tags($val)); }
								$display = preg_replace('/(' . $value . ')/i', '<b class="ls_hghlight">\1</b>', $main_cats); 
								$sel = $bcategory == $main_cats_id ? 'selected' : '';
								$cats.='<option '.$sel.' value="'.$main_cats_id.'">'.$display.'</option>';
								
							}
							echo $cats;
						?>
						</select>
						<br>
						<select class="form-control"  name="category[]">
							<option value="" selected="">Please category</option>
							<?php 
							foreach($categorys as $row) {
								foreach($row AS $key => $val){ $$key = stripslashes(strip_tags($val)); }
								$display = preg_replace('/(' . $value . ')/i', '<b class="ls_hghlight">\1</b>', $main_cats); 
								$sel = $bcategory == $main_cats_id ? 'selected' : '';
								$cats.='<option '.$sel.' value="'.$main_cats_id.'">'.$display.'</option>';
								
							}
							echo $cats;
						?>
						</select>
						
					</div> -->
					
					
					
					
					
					
				<div class="submit-advert-form-group">
				    <button type="submit" name="submit" class="btn btn-yellow">Update</button>
					<a href="/staff/advert/?id=<?=$_GET['id']?>&approve=1"  class="btn btn-yellow">Approve</a>
					<a href="/staff/advert/?id=<?=$_GET['id']?>&decline=1"  class="btn btn-red">Decline</a>
				</div>
				
			</form>
		</div>
	</div>
	<!-- end: Table -->
  
	<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
	
	<script>
		function getUrlParameter(sParam) {
			var sPageURL = window.location.search.substring(1),
				sURLVariables = sPageURL.split('&'),
				sParameterName,
				i;

			for (i = 0; i < sURLVariables.length; i++) {
				sParameterName = sURLVariables[i].split('=');

				if (sParameterName[0] === sParam) {
					return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
				}
			}
			return false;
		};

	const params = new URLSearchParams(window.location.search);
	if(params.has('decline') || params.has('approve'))
	{
		window.history.pushState('page2', 'Title', '/staff/advert/?id=<?=$id?>'); 
	}
	
	
	var mg = document.getElementById('mg');
	if(mg){
		setTimeout(function(){
		  
		  mg.remove();
		 
		}, 5000)
	}
	var categoryStringify = JSON.stringify(<?= $jsonCats ?>)
	var jsonCategory = JSON.parse(categoryStringify)
	var country = '<?=$adcounty_name?>';
	var town = '<?=$town_name?>';
	var categoryInputEl = document.getElementById('category')
	var categoryIdEl = document.getElementById('category-id')
    
	get_town_drop(country, town);
	
	// autocompleteCategory(categoryInputEl, jsonCategory, categoryIdEl)

	function get_town_drop(value, town) {
    
		var xmlhttp = false;
		var xmlhttp = (window.XMLHttpRequest) ? xmlhttp = new XMLHttpRequest() : xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp.onreadystatechange = function () {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				document.getElementById("town").innerHTML = xmlhttp.responseText;
				return true;
			}
		}
		xmlhttp.open("GET", "ajax/get_town.ajax.php?value=" + value + '&town=' + town, true);
		xmlhttp.send();
	}


	// function autocompleteCategory(inp, arr, inpValue) {
	// 	/*the autocomplete function takes two arguments,
	// 	the text field element and an array of possible autocompleted values:*/
	// 	var currentFocus;
	// 	/*execute a function when someone writes in the text field:*/
	// 	inp.addEventListener("input", function (e) {
	// 		var a, b, i, val = this.value;
	// 		var isEmpty = true
	// 		/*close any already open lists of autocompleted values*/
	// 		closeAllLists();
	// 		if (!val) { return false; }
	// 		currentFocus = -1;
	// 		/*create a DIV element that will contain the items (values):*/
	// 		a = document.createElement("ul");
	// 		a.setAttribute("class", "form-control-autocomplete-list");
	// 		/*append the DIV element as a child of the autocomplete container:*/
	// 		this.parentNode.appendChild(a);
	// 		/*for each item in the array...*/
	// 		for (i = 0; i < 5; i++) {
	// 			/*check if the item starts with the same letters as the text field value:*/
	// 			if (arr[i].keyword.substr(0, val.length).toUpperCase() == val.toUpperCase()) {
	// 				isEmpty = false
	// 				/*create a DIV element for each matching element:*/
	// 				b = document.createElement("li");
	// 				/*make the matching letters bold:*/
	// 				b.dataset.value = arr[i].value
	// 				b.dataset.keyword = arr[i].keyword
	// 				b.innerHTML = "<strong>" + arr[i].keyword.substr(0, val.length) + "</strong>";
	// 				b.innerHTML += arr[i].keyword.substr(val.length);
	// 				/*insert a input field that will hold the current array item's value:*/
	// 				// b.innerHTML += "<input type='hidden' value='" + arr[i] + "'>";
	// 				/*execute a function when someone clicks on the item value (DIV element):*/
	// 				b.addEventListener("click", function (e) {
	// 					/*insert the value for the autocomplete text field:*/
	// 					inp.value = this.dataset.keyword;
	// 					inpValue.value = this.dataset.value;
	// 					/*close the list of autocompleted values,
	// 					(or any other open lists of autocompleted values:*/
	// 					closeAllLists();
	// 				});
	// 				a.appendChild(b);
	// 			}
	// 		}
	// 		if(isEmpty) {
	// 			b = document.createElement("li");
	// 			b.setAttribute("class", "no-event");
	// 			b.innerHTML = 'No matching categories found'
	// 			a.appendChild(b);
	// 		}
	// 	});
	// 	/*execute a function presses a key on the keyboard:*/
	// 	inp.addEventListener("keydown", function (e) {
	// 		var x = inp.nextElementSibling;
	// 		if (x) x = x.getElementsByTagName("li");
	// 		if (e.keyCode == 40) {
	// 			/*If the arrow DOWN key is pressed,
	// 			increase the currentFocus variable:*/
	// 			currentFocus++;
	// 			/*and and make the current item more visible:*/
	// 			addActive(x);
	// 		} else if (e.keyCode == 38) { //up
	// 			/*If the arrow UP key is pressed,
	// 			decrease the currentFocus variable:*/
	// 			currentFocus--;
	// 			/*and and make the current item more visible:*/
	// 			addActive(x);
	// 		} else if (e.keyCode == 13) {
	// 			/*If the ENTER key is pressed, prevent the form from being submitted,*/
	// 			e.preventDefault();
	// 			if (currentFocus > -1) {
	// 				/*and simulate a click on the "active" item:*/
	// 				if (x) x[currentFocus].click();
	// 			}
	// 		}
	// 	});
	// 	function addActive(x) {
	// 		/*a function to classify an item as "active":*/
	// 		if (!x) return false;
	// 		/*start by removing the "active" class on all items:*/
	// 		removeActive(x);
	// 		if (currentFocus >= x.length) currentFocus = 0;
	// 		if (currentFocus < 0) currentFocus = (x.length - 1);
	// 		/*add class "autocomplete-active":*/
	// 		x[currentFocus].classList.add("active");
	// 	}
	// 	function removeActive(x) {
	// 		/*a function to remove the "active" class from all autocomplete items:*/
	// 		for (var i = 0; i < x.length; i++) {
	// 			x[i].classList.remove("active");
	// 		}
	// 	}
	// 	function closeAllLists(elmnt) {
	// 		/*close all autocomplete lists in the document,
	// 		except the one passed as an argument:*/
	// 		var x = document.getElementsByClassName("form-control-autocomplete-list");
	// 		for (var i = 0; i < x.length; i++) {
	// 			if (elmnt != x[i] && elmnt != inp) {
	// 				x[i].parentNode.removeChild(x[i]);
	// 			}
	// 		}
	// 	}
	// 	/*execute a function when someone clicks in the document:*/
	// 	document.addEventListener("click", function (e) {
	// 		closeAllLists(e.target);
	// 	});
	// }


	var pid = 0;
	var images = [];
	let all_images = document.querySelectorAll(".remove-image");
	
	all_images.forEach((e, i) => {
		let p = parseInt(e.getAttribute("pid"));
		images.push(p);
	});


	$(document).on('click', '.remove-image', function(e) {
		e.preventDefault()
		
		let pid = parseInt(this.getAttribute("pid"));
		images.splice(images.indexOf(pid), 1);
		

		$.ajax({
			url: './ajax/ajax_upload_ads_images.php',
			type: 'POST',
			data: {
				delete: true,
				adid: getUrlParameter('id'),
				pid: pid
			},
			beforeSend: () => {
				// $("upload_label").html("Uploading...")
				// console.log("sending..")
			},
			success: (data) => {
				console.log(data);
				// if (data == "UPLOAD_SUCCESS") {
				// 	alert("Logo Upload success")
				// } else if (data == "UPLOAD_FAILED") {
				// 	alert("Image upload failed, please try again");
				// }
			}
		});
		$(this).parent().remove()
	})

	
</script>





</html>

Youez - 2016 - github.com/yon3zu
LinuXploit