forked from kevinowino869/mitrobill
QRCODE in voucher
This commit is contained in:
124
system/boot.php
124
system/boot.php
@ -1,22 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
||||
* PHP Mikrotik Billing (https://ibnux.github.io/phpmixbill/)
|
||||
|
||||
|
||||
* @copyright Copyright (C) 2014-2015 PHP Mikrotik Billing
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @copyright Copyright (C) 2014-2015 PHP Mikrotik Billing
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
|
||||
**/
|
||||
**/
|
||||
session_start();
|
||||
function r2($to,$ntype='e',$msg=''){
|
||||
if($msg==''){
|
||||
header("location: $to");
|
||||
exit;
|
||||
function r2($to, $ntype = 'e', $msg = '')
|
||||
{
|
||||
if ($msg == '') {
|
||||
header("location: $to");
|
||||
exit;
|
||||
}
|
||||
$_SESSION['ntype']=$ntype;
|
||||
$_SESSION['notify']=$msg;
|
||||
header("location: $to");
|
||||
exit;
|
||||
$_SESSION['ntype'] = $ntype;
|
||||
$_SESSION['notify'] = $msg;
|
||||
header("location: $to");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (file_exists('system/config.php')) {
|
||||
@ -25,21 +27,24 @@ if (file_exists('system/config.php')) {
|
||||
r2('system/install');
|
||||
}
|
||||
|
||||
function safedata($value){
|
||||
function safedata($value)
|
||||
{
|
||||
$value = trim($value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
function _post($param,$defvalue = '') {
|
||||
if(!isset($_POST[$param])) {
|
||||
function _post($param, $defvalue = '')
|
||||
{
|
||||
if (!isset($_POST[$param])) {
|
||||
return $defvalue;
|
||||
} else {
|
||||
return safedata($_POST[$param]);
|
||||
}
|
||||
}
|
||||
|
||||
function _get($param,$defvalue = ''){
|
||||
if(!isset($_GET[$param])) {
|
||||
function _get($param, $defvalue = '')
|
||||
{
|
||||
if (!isset($_GET[$param])) {
|
||||
return $defvalue;
|
||||
} else {
|
||||
return safedata($_GET[$param]);
|
||||
@ -56,19 +61,21 @@ ORM::configure('return_result_sets', true);
|
||||
ORM::configure('logging', true);
|
||||
|
||||
$result = ORM::for_table('tbl_appconfig')->find_many();
|
||||
foreach($result as $value){
|
||||
$config[$value['setting']]=$value['value'];
|
||||
foreach ($result as $value) {
|
||||
$config[$value['setting']] = $value['value'];
|
||||
}
|
||||
|
||||
date_default_timezone_set($config['timezone']);
|
||||
$_c = $config;
|
||||
|
||||
function _notify($msg,$type='e'){
|
||||
$_SESSION['ntype']=$type ; $_SESSION['notify']=$msg ;
|
||||
function _notify($msg, $type = 'e')
|
||||
{
|
||||
$_SESSION['ntype'] = $type;
|
||||
$_SESSION['notify'] = $msg;
|
||||
}
|
||||
|
||||
require_once('system/vendors/smarty/libs/Smarty.class.php');
|
||||
$_theme = APP_URL.'/ui/theme/'.$config['theme'];
|
||||
$_theme = APP_URL . '/ui/theme/' . $config['theme'];
|
||||
$lan_file = 'system/lan/' . $config['language'] . '/common.lan.php';
|
||||
require($lan_file);
|
||||
$ui = new Smarty();
|
||||
@ -77,8 +84,8 @@ $ui->setCompileDir('ui/compiled/');
|
||||
$ui->setConfigDir('ui/conf/');
|
||||
$ui->setCacheDir('ui/cache/');
|
||||
$ui->assign('app_url', APP_URL);
|
||||
define('U', APP_URL.'/index.php?_route=');
|
||||
$ui->assign('_url', APP_URL.'/index.php?_route=');
|
||||
define('U', APP_URL . '/index.php?_route=');
|
||||
$ui->assign('_url', APP_URL . '/index.php?_route=');
|
||||
$ui->assign('_theme', $_theme);
|
||||
$ui->assign('_path', __DIR__);
|
||||
$ui->assign('_c', $config);
|
||||
@ -86,7 +93,8 @@ $ui->assign('_L', $_L);
|
||||
$ui->assign('_system_menu', 'dashboard');
|
||||
$ui->assign('_title', $config['CompanyName']);
|
||||
|
||||
function _msglog($type,$msg){
|
||||
function _msglog($type, $msg)
|
||||
{
|
||||
$_SESSION['ntype'] = $type;
|
||||
$_SESSION['notify'] = $msg;
|
||||
}
|
||||
@ -95,68 +103,73 @@ if (isset($_SESSION['notify'])) {
|
||||
$notify = $_SESSION['notify'];
|
||||
$ntype = $_SESSION['ntype'];
|
||||
if ($ntype == 's') {
|
||||
$ui->assign('notify','<div class="alert alert-info">
|
||||
$ui->assign('notify', '<div class="alert alert-info">
|
||||
<button type="button" class="close" data-dismiss="alert">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<div>'.$notify.'</div></div>');
|
||||
<div>' . $notify . '</div></div>');
|
||||
} else {
|
||||
$ui->assign('notify','<div class="alert alert-danger">
|
||||
$ui->assign('notify', '<div class="alert alert-danger">
|
||||
<button type="button" class="close" data-dismiss="alert">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<div>'.$notify.'</div></div>');
|
||||
<div>' . $notify . '</div></div>');
|
||||
}
|
||||
unset($_SESSION['notify']);
|
||||
unset($_SESSION['ntype']);
|
||||
}
|
||||
|
||||
// on some server, it getting error because of slash is backwards
|
||||
function _autoloader($class) {
|
||||
function _autoloader($class)
|
||||
{
|
||||
if (strpos($class, '_') !== false) {
|
||||
$class = str_replace('_','/',$class);
|
||||
if(file_exists('autoload/' . $class . '.php')){
|
||||
$class = str_replace('_', '/', $class);
|
||||
if (file_exists('autoload/' . $class . '.php')) {
|
||||
include 'autoload/' . $class . '.php';
|
||||
}else{
|
||||
$class = str_replace("\\","/",$class);
|
||||
if(file_exists(__DIR__.'/autoload/' . $class . '.php'))
|
||||
include __DIR__.'/autoload/' . $class . '.php';
|
||||
} else {
|
||||
$class = str_replace("\\", "/", $class);
|
||||
if (file_exists(__DIR__ . '/autoload/' . $class . '.php'))
|
||||
include __DIR__ . '/autoload/' . $class . '.php';
|
||||
}
|
||||
} else{
|
||||
if(file_exists('autoload/' . $class . '.php')){
|
||||
} else {
|
||||
if (file_exists('autoload/' . $class . '.php')) {
|
||||
include 'autoload/' . $class . '.php';
|
||||
}else{
|
||||
$class = str_replace("\\","/",$class);
|
||||
if(file_exists(__DIR__.'/autoload/' . $class . '.php'))
|
||||
include __DIR__.'/autoload/' . $class . '.php';
|
||||
} else {
|
||||
$class = str_replace("\\", "/", $class);
|
||||
if (file_exists(__DIR__ . '/autoload/' . $class . '.php'))
|
||||
include __DIR__ . '/autoload/' . $class . '.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
spl_autoload_register('_autoloader');
|
||||
|
||||
function _auth(){
|
||||
if(isset($_SESSION['uid'])){
|
||||
function _auth()
|
||||
{
|
||||
if (isset($_SESSION['uid'])) {
|
||||
return true;
|
||||
} else{
|
||||
r2(U.'login');
|
||||
} else {
|
||||
r2(U . 'login');
|
||||
}
|
||||
}
|
||||
|
||||
function _admin(){
|
||||
if(isset($_SESSION['aid'])){
|
||||
function _admin()
|
||||
{
|
||||
if (isset($_SESSION['aid'])) {
|
||||
return true;
|
||||
} else{
|
||||
r2(U.'login');
|
||||
} else {
|
||||
r2(U . 'login');
|
||||
}
|
||||
}
|
||||
|
||||
function _raid($l){
|
||||
$r= substr(str_shuffle(str_repeat('0123456789',$l)),0,$l);
|
||||
function _raid($l)
|
||||
{
|
||||
$r = substr(str_shuffle(str_repeat('0123456789', $l)), 0, $l);
|
||||
return $r;
|
||||
}
|
||||
|
||||
function _log($description,$type='',$userid='0'){
|
||||
function _log($description, $type = '', $userid = '0')
|
||||
{
|
||||
$d = ORM::for_table('tbl_logs')->create();
|
||||
$d->date = date('Y-m-d H:i:s');
|
||||
$d->type = $type;
|
||||
@ -166,7 +179,8 @@ function _log($description,$type='',$userid='0'){
|
||||
$d->save();
|
||||
}
|
||||
|
||||
function time_elapsed_string($datetime, $full = false) {
|
||||
function time_elapsed_string($datetime, $full = false)
|
||||
{
|
||||
$now = new DateTime;
|
||||
$ago = new DateTime($datetime);
|
||||
$diff = $now->diff($ago);
|
||||
@ -206,5 +220,5 @@ $sys_render = 'system/controllers/' . $handler . '.php';
|
||||
if (file_exists($sys_render)) {
|
||||
include($sys_render);
|
||||
} else {
|
||||
exit ("$sys_render");
|
||||
exit("$sys_render");
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user