/** * Desription: * This file init the base for all modules. It only loads about parameters the default screen and init the modules * * Author: m.ginesta@ncag.ch */ define('BASE', realpath(dirname(__FILE__))); /* First load the lib-files to init db and other needed stuff. */ require_once(BASE . '/lib/std.php'); // check controller. If a controller is available, then it was called from ajax and need just the return.. if($cu->hasController(postGet('ctr'))) { try{ $ret = $cu->useController(postGet('ctr')); if(is_string($ret) OR is_int($ret) OR is_float($ret)) echo $ret; if(is_array($ret)) { header('Content-type: application/json'); header('X-Return-Count: ' . count($ret)); $str = json_encode($ret); if(strlen($str)==0 && count($ret)>0) { echo json_last_error_msg(); exit(); } echo $str; } unset($cu); die(); } catch(Exception $e){ if($cu->_user->isNC()){ if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']=='XMLHttpRequest'){ header('Content-type: application/json'); $errMsg = "ERROR\n\n" . $e->getMessage() . "\n\nWHERE\n" . $e->getFile() .' ('.$e->getLine().')' . "\n\nBACKTRACE:\n" . $e->getTraceAsString(); echo json_encode([['a'=>'showError', 'p'=>'
'.$errMsg.'']]); exit(0); } else { header('Content-type: text/plain'); echo "ERROR\n\n" . $e->getMessage() . "\n\nWHERE\n" . $e->getFile() .' ('.$e->getLine().')' . "\n\nBACKTRACE:\n" . $e->getTraceAsString(); exit(0); } } header('Content-type: application/json'); echo json_encode([['a'=>'showError', 'p'=>$e->getMessage()]]); exit(0); } } if(!is_null(postGet('ctr', NULL))){ echo "controller not found: " . postGet('ctr'); die(); } //var_dump($cu->_config['design']); $cu->loadPage(); unset($cu);