Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/theyoungdesigners_com/modules/freightLocalPickup/ |
Upload File : |
<?php
namespace modules\freightLocalPickup;
class main extends \moduleMain {
use \modules\input\traits {
\modules\input\traits::__construct as __ConstructInput;
}
use \modules\output\traits {
\modules\output\traits::__construct as __ConstructOutput;
}
private $identifier;
public function __construct() {
parent::__construct(__DIR__);
$this->__ConstructInput();
$this->__ConstructOutput();
$this->identifier = 'local';
$this->DATA = NULL;
}
public function Activate() {
$filename = __DIR__ . '/zipcode.json';
if (file_exists($filename)) {
$this->DATA = json_decode(file_get_contents($filename), TRUE);
hook_add('freight.calculate', [$this, '__get_calculate']); // calculate the freight cost for the given service(s)
}
}
protected function getCoords($zip) {
if (($p = strpos($zip, '-')) !== FALSE) {
$zip = substr($zip, 0, $p);
}
if (isset($this->DATA[$zip])) {
return $this->DATA[$zip];
} else {
return NULL;
}
}
public function __get_calculate($params) {
if (empty($params->originZip)) {
return $params->status = 'error: no origin zip';
}
$distance = $this->getDistance($this->getCoords($params->originZip), $this->getCoords($params->targetZip));
if ($distance < $this->settings['radius']) {
$x = sprintf('%0.1f', $distance);
$x .= ($distance > 1) ? ' miles' : ' mile';
$params->services[] = [
'source' => $this->identifier,
'key' => 'local',
'value' => 'local',
'caption' => "Free Local Pickup ($x from {$params->originZip})",
'cost' => 0,
'shipdate' => $params->shipdate,
];
}
}
function getDistance($point1, $point2, $unit = 'M') {
if (is_null($point1) || is_null($point2)) return 9999;
$lat1 = $point1['lat']; $lat2 = $point2['lat'];
$lon1 = $point1['lng']; $lon2 = $point2['lng'];
if (($lat1 == $lat2) && ($lon1 == $lon2)) {
return 0;
}
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +
cos(deg2rad($lat1)) * cos(deg2rad($lat2)) *
cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist * 60 * 1.1515;
$unit = strtoupper($unit);
if ($unit == "K") {
return ($miles * 1.609344); // Kilometers
} else if ($unit == "N") {
return ($miles * 0.8684); // Nautical Miles
} else {
return $miles; // Miles
}
}
// the original sqlite3 is downloaded from:
// https://objects.githubusercontent.com/github-production-repository-file-5c1aeb/43776942/5183256?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20260512%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260512T192317Z&X-Amz-Expires=300&X-Amz-Signature=5b8d6c741fe87d09cabc3254c0d32d37893d31ff6aa26abf34b2788cd2ff269b&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3Bfilename%3Dsimple_db.log&response-content-type=text%2Fx-log
// just extract the info we need:
final function import() {
header('Content-type: text/plain');
die("Function Disabled");
$content = file_get_contents(__DIR__ . '/simple_zipcode.json');
$temp = json_decode($content, TRUE);
$result = [];
foreach($temp as $item) {
$zip = $item['zipcode'];
if ($item['zipcode_type'] == 'Standard') {
$result[$zip] = [
'state' => $item['state'],
'city' => $item['major_city'],
'lat' => $item['lat'],
'lng' => $item['lng'],
];
}
}
file_put_contents(HOME . '/storage/zipcode.json', json_encode($result, JSON_UNESCAPED_SLASHES));
die("\nExported to storage folder\n");
}
}