Server : Apache System : Linux profile 3.10.0-1160.88.1.el7.x86_64 #1 SMP Tue Mar 7 15:41:52 UTC 2023 x86_64 User : apache ( 48) PHP Version : 8.0.28 Disable Function : NONE Directory : /var/www/html/mmishra/erp-10-07-2018/ |
<?php
// This is the requirements for ERP Framework
session_start();
//if (!$_SESSION['sessionID'] || !strpos($_SERVER["HTTP_REFERER"], 'outer')) {
//if (!$_SESSION['sessionID']) {
// print "<h1>Unauthorised access. Please login first.</h1>";
// exit; // exit brutally
//}
$url = isset($_SERVER['PATH_INFO']) ? explode('/', ltrim($_SERVER['PATH_INFO'],'/')) : '/';
if ($url[0] == '/') {
header("Location: /");
} else if ($url[0] != '' && $url[1] != '' && $url[2] != '' && $url[3] != '' ) {
// incoming request format /app/menu/action/tuple
// app is application MVC to be invoked
// menu is MVC method to be called
// action is MVC action to be performed
// tuple is record no. the MVC action is performed on
//echo $_SERVER['PATH_INFO'];
$app = $url[0]; // The first element should be an application controller
$menu = $url[1]; // The second element should be a view method
$action = $url[2]; // The third element should be a model action
$tuple = $url[3]; // The fourth element should be a tuple
$params = array_slice($url, 4); // rest of the elements
// Initiate the appropriate controller and render the required view
// Check if controller exists. NB: it is needed to check for model and view too
if ($app != 'erp') {
// include parent class files prior to child class file
require_once(__DIR__.'/models/erp_model.php');
require_once(__DIR__.'/controllers/erp_controller.php');
require_once(__DIR__.'/views/erp_view.php');
}
$appModel = __DIR__.'/models/'.$app.'_model.php';
$appController = __DIR__.'/controllers/'.$app.'_controller.php';
$appView = __DIR__.'/views/'.$app.'_view.php';
if (file_exists($appController) && file_exists($appModel) && file_exists($appView)) {
require_once($appModel);
require_once($appController);
require_once($appView);
$modelName = $app.'Model';
$controllerName = $app.'Controller';
$viewName = $app.'View';
$appModel = new $modelName();
$appController = new $controllerName($appModel);
$appView = new $viewName($appController, $appModel);
// set controllers appID and menuID
$appController->app = $app;
$appController->menu = $menu;
$appController->action = $action;
$appController->tuple = $tuple;
$appController->params = $params;
$viewMethod = $app.ucwords($menu); // first and second parameter
if ($action == 'render') {
//echo $menu;
switch ($menu) {
case 'module':
// render only modulebar
print $appView->erpModule($tuple, $app);
break;
case 'helper':
// render only modulebar
print $appView->erpHelper($tuple);
break;
default:
print $appView->erpError('Unsupported URL, ERP action not clear.');
}
} else if ($menu == 'HDFC' || $menu == 'payment' || $menu == 'PGPayment') {
// then we call the method via the view, dynamic call of the view
print "<form id='erpForm' name='erpForm' method='POST' action='https://secure.ebs.in/pg/ma/payment/request/' enctype='multipart/form-data' autocomplete='on' target='_blank'>";
print $appView->$viewMethod($action, $tuple); // third and fourth parameter
print "</form>";
} else {
// then we call the method via the view, dynamic call of the view
print "<form id='erpForm' name='erpForm' method='POST' action='inner/$app/$menu/$action/$tuple' enctype='multipart/form-data' autocomplete='on'>";
print $appView->$viewMethod($action, $tuple); // third and fourth parameter
print "</form>";
}
} else {
print "Controller for this ERP application does not exist.";
}
} else {
print 'Unsupported URL ' .$_SERVER['PATH_INFO'];
}
?>