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/validation/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/yellowleaf/public_html/staff/validation/BACKUP_1.postcode.php
<?php

$path = $_SERVER['DOCUMENT_ROOT'];
include_once $path . '/connect_db.php';

function validateUKPhoneNumber($number) {
    // Regular expression for UK phone number validation
    $pattern = '/^((\+44\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3}|\d{11})$/';
    return preg_match($pattern, $number);
}


function check_postcode_uk($original_postcode)
{
	// Set callback's custom error message (CI specific)
	// $this->set_message('check_postcode_uk', 'Invalid UK postcode format.');

	// Permitted letters depend upon their position in the postcode.
	// Character 1
	$alpha1 = "[abcdefghijklmnoprstuwyz]";
	// Character 2
	$alpha2 = "[abcdefghklmnopqrstuvwxy]";
	// Character 3
	$alpha3 = "[abcdefghjkpmnrstuvwxy]";
	// Character 4
	$alpha4 = "[abehmnprvwxy]";
	// Character 5
	$alpha5 = "[abdefghjlnpqrstuwxyz]";

	// Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA with a space
	$pcexp[0] = '/^('.$alpha1.'{1}'.$alpha2.'{0,1}[0-9]{1,2})([[:space:]]{0,})([0-9]{1}'.$alpha5.'{2})$/';

	// Expression for postcodes: ANA NAA
	$pcexp[1] = '/^('.$alpha1.'{1}[0-9]{1}'.$alpha3.'{1})([[:space:]]{0,})([0-9]{1}'.$alpha5.'{2})$/';

	// Expression for postcodes: AANA NAA
	$pcexp[2] = '/^('.$alpha1.'{1}'.$alpha2.'{1}[0-9]{1}'.$alpha4.')([[:space:]]{0,})([0-9]{1}'.$alpha5.'{2})$/';

	// Exception for the special postcode GIR 0AA
	$pcexp[3] = '/^(gir)([[:space:]]{0,})(0aa)$/';

	// Standard BFPO numbers
	$pcexp[4] = '/^(bfpo)([[:space:]]{0,})([0-9]{1,4})$/';

	// c/o BFPO numbers
	$pcexp[5] = '/^(bfpo)([[:space:]]{0,})(c\/o([[:space:]]{0,})[0-9]{1,3})$/';

	// Overseas Territories
	$pcexp[6] = '/^([a-z]{4})([[:space:]]{0,})(1zz)$/';

	// Anquilla
	$pcexp[7] = '/^ai-2640$/';

	// Load up the string to check, converting into lowercase
	$postcode = strtolower($original_postcode);

	// Assume we are not going to find a valid postcode
	$valid = FALSE;

	// Check the string against the six types of postcodes
	foreach ($pcexp as $regexp)
	{
		if (preg_match($regexp, $postcode, $matches))
		{
			// Load new postcode back into the form element
			$postcode = strtoupper ($matches[1] . ' ' . $matches [3]);

			// Take account of the special BFPO c/o format
			$postcode = preg_replace ('/C\/O([[:space:]]{0,})/', 'c/o ', $postcode);

			// Take acount of special Anquilla postcode format (a pain, but that's the way it is)
			preg_match($pcexp[7], strtolower($original_postcode), $matches) AND $postcode = 'AI-2640';

			// Remember that we have found that the code is valid and break from loop
			$valid = TRUE;
			break;
		}
	}

	// Return with the reformatted valid postcode in uppercase if the postcode was
	return $valid;
}

// $url = 'http://www.google.com';
// $headers = @get_headers($url);
// echo "website Url: ".$url."<br>";
// if ($headers && strpos($headers[0], '200 OK')) {
//     echo 'Website exists';
// } else {
//     echo 'Website does not exist';
// }

// die();

// die("Post code: W1H 1DP is: ".check_postcode_uk('W1H 1DP'));

// $postcode = 'ECIV 2NX';
// $check_postcode = check_postcode_uk($postcode);

// if ($check_postcode) {
// 	echo "Post code: $postcode is valid";
// } else {
// 	echo "Post code: $postcode is invalid";
// }
// die();
echo "<b>Step - 1 is running</b>";
// get * from ads table order by id desc and limit 20
// $sql = "SELECT * FROM `ads` WHERE `approval` = 0 ORDER BY `adid` DESC LIMIT 100";
$sql = "SELECT * FROM `ads` WHERE `approval` = 0 ORDER BY adid ASC LIMIT 100";
echo "Select sql: ".$sql."<br>";
// $sql = "SELECT * FROM `ads` WHERE `adid` = '46616' ";
$res_ads = $connect->query($sql);

if ($res_ads->num_rows > 0) {
	while ($row = $res_ads->fetch_array(MYSQLI_ASSOC)) {
		$adid = $row['adid'];
		$memberid = $row['memberid'];
		$memberemail = $row['email'];
		$postcode = trim($row['postcode']);
		$telephone = trim($row['tel']);
		if (!empty($postcode) || !empty($telephone)) {
			$check_44 = $telephone[0].$telephone[1];
			if ($telephone[0] == '0') {
				$telephone = substr($telephone, 1);
			}

			if ($check_44 != '44' && $check_44 != '0044') {
				$telephone = "44".$telephone;
			}
			
			$telephone = preg_replace('/\+44\(0\)?|0044?/', '+44', $telephone);
			if ($telephone[0] != '+') {
				$telephone = "+".$telephone;
			}
			$postcode = preg_replace('/[^a-zA-Z0-9]/', '', $postcode);
			$check_telephone = validateUKPhoneNumber($telephone);
			$check_postcode = check_postcode_uk($postcode);

			if ($check_postcode && $check_telephone) {
				$connect->query("UPDATE `ads` SET `approval` = 1, `decline_reason` = '' WHERE `adid` = '$adid'") or die("Error: ".$connect->error);
				echo "<span style='color: green;'>Ad: $adid -  Approved</span><br>";
			} else {
				if (!$check_postcode && !$check_telephone) {
					$decline_reason = 'INVALID POSTCODE AND TELEPHONE';
				}else if (!$check_postcode && $check_telephone) {
					$decline_reason = 'INVALID POSTCODE';
				}else if ($check_postcode && !$check_telephone) {
					$decline_reason = 'INVALID TELEPHONE';
				}else{
					$decline_reason = '';
				}
				$connect->query("UPDATE `ads` SET `approval` = -1, `decline_reason` = '$decline_reason' WHERE `adid` = '$adid'") or die("Error: ".$connect->error);
				echo "Sql: "."UPDATE `ads` SET `approval` = -1, `decline_reason` = '$decline_reason' WHERE `adid` = '$adid' <br>";
				// die();
				$to = $memberemail;
				$subject = "Your business submissions on Yellowleaf";
				$message = "Hello,
				
	Thank you for submitting your website, {$row['companyname']}, to our directory. 
				
	After reviewing your submission, we regret to inform you that it has been declined.
				
	Your login email is: $memberemail
				
	The reason for this decision is that your postcode was invalid.
				
	We understand that this may be disappointing news, but we encourage you to continue to improve your website and resubmit it for consideration in the future.
				
	Thank you for your understanding and for your interest in our directory.
				
	Best regards, 
	Yellowleaf Team";
				$headers = "From: no-reply@yellowleaf.co.uk" . "\r\n";
	
				// mail($to, $subject, $message, $headers);
				echo "In advert: $adid postcode or telephone is not valid.<br>";
			}
		}else{
			$connect->query("UPDATE `ads` SET `approval` = -1, `decline_reason` = 'EMPTY POSTCODE AND TELEPHONE'  WHERE `adid` = '$adid'") or die("Error: ".$connect->error);
	
			$to = $memberemail;
			$subject = "Your business submissions on Yellowleaf";
			$message = "Hello,
	
			Thank you for submitting your website, {$row['companyname']}, to our directory. 
			
			After reviewing your submission, we regret to inform you that it has been declined.
			
			Your login email is: $memberemail
			
			The reason for this decision is that your postcode was empty.
			
			We understand that this may be disappointing news, but we encourage you to continue to improve your website and resubmit it for consideration in the future.
			
			Thank you for your understanding and for your interest in our directory.
			
			Best regards, 
			Yellowleaf Team";;
			$headers = "From: no-reply@yellowleaf.co.uk" . "\r\n";
	
			// mail($to, $subject, $message, $headers);
			echo "In advert: $adid postcode is empty.<br>";
		}
	}
	
	echo ' <meta http-equiv="refresh" content="3">';
}else{
	echo "No more ads to approve";
	echo '<script>window.location.href = "https://www.yellowleaf.co.uk/staff/validation/2.website-php.php";</script>';

}
?>


Youez - 2016 - github.com/yon3zu
LinuXploit