PHP Classes

File: htdocs/xoops_lib/modules/protector/admin.php

Recommend this page to a friend!
  Classes of Michael Beck   Xoops 2.5   htdocs/xoops_lib/modules/protector/admin.php   Download  
File: htdocs/xoops_lib/modules/protector/admin.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Xoops 2.5
Modular content management publication system
Author: By
Last change: non-canonical order

In docblock var tags, use "type variableName" more consistently
Date: 5 years ago
Size: 3,279 bytes
 

Contents

Class file image Download
<?php
// start hack by Trabis
if (!class_exists('ProtectorRegistry')) {
    exit(
'Registry not found');
}

$registry = ProtectorRegistry::getInstance();
$mydirname = $registry->getEntry('mydirname');
$mydirpath = $registry->getEntry('mydirpath');
$language = $registry->getEntry('language');
// end hack by Trabis

$mytrustdirname = basename(__DIR__);
$mytrustdirpath = __DIR__;

// environment
require_once XOOPS_ROOT_PATH . '/class/template.php';
/* @var XoopsModuleHandler $module_handler */
$module_handler = xoops_getHandler('module');
$xoopsModule = $module_handler->getByDirname($mydirname);
/* @var XoopsConfigHandler $config_handler */
$config_handler = xoops_getHandler('config');
$xoopsModuleConfig = $config_handler->getConfigsByCat(0, $xoopsModule->getVar('mid'));

// check permission of 'module_admin' of this module
/* @var XoopsGroupPermHandler $moduleperm_handler */
$moduleperm_handler = xoops_getHandler('groupperm');
if (!
is_object(@$xoopsUser) || !$moduleperm_handler->checkRight('module_admin', $xoopsModule->getVar('mid'), $xoopsUser->getGroups())) {
    die(
'only admin can access this area');
}

$xoopsOption['pagetype'] = 'admin';
require
XOOPS_ROOT_PATH . '/include/cp_functions.php';

// language files (admin.php)
//$language = empty( $xoopsConfig['language'] ) ? 'english' : $xoopsConfig['language'] ; //hack by Trabis
if (file_exists("$mydirpath/language/$language/admin.php")) {
   
// user customized language file
   
include_once "$mydirpath/language/$language/admin.php";
} elseif (
file_exists("$mytrustdirpath/language/$language/admin.php")) {
   
// default language file
   
include_once "$mytrustdirpath/language/$language/admin.php";
} else {
   
// fallback english
   
include_once "$mytrustdirpath/language/english/admin.php";
}

// language files (main.php)
//$language = empty( $xoopsConfig['language'] ) ? 'english' : $xoopsConfig['language'] ; //hack by Trabis
if (file_exists("$mydirpath/language/$language/main.php")) {
   
// user customized language file
   
include_once "$mydirpath/language/$language/main.php";
} elseif (
file_exists("$mytrustdirpath/language/$language/main.php")) {
   
// default language file
   
include_once "$mytrustdirpath/language/$language/main.php";
} else {
   
// fallback english
   
include_once "$mytrustdirpath/language/english/main.php";
}

if (!empty(
$_GET['lib'])) {
   
// common libs (eg. altsys)
   
$lib = preg_replace('/[^a-zA-Z0-9_-]/', '', $_GET['lib']);
   
$page = preg_replace('/[^a-zA-Z0-9_-]/', '', @$_GET['page']);

    if (
file_exists(XOOPS_TRUST_PATH . '/libs/' . $lib . '/' . $page . '.php')) {
        include
XOOPS_TRUST_PATH . '/libs/' . $lib . '/' . $page . '.php';
    } elseif (
file_exists(XOOPS_TRUST_PATH . '/libs/' . $lib . '/index.php')) {
        include
XOOPS_TRUST_PATH . '/libs/' . $lib . '/index.php';
    } else {
        die(
'wrong request');
    }
} else {
   
// fork each pages of this module
   
$page = preg_replace('/[^a-zA-Z0-9_-]/', '', @$_GET['page']);

    if (
file_exists("$mytrustdirpath/admin/$page.php")) {
        include
"$mytrustdirpath/admin/$page.php";
    } elseif (
file_exists("$mytrustdirpath/admin/index.php")) {
        include
"$mytrustdirpath/admin/index.php";
    } else {
        die(
'wrong request');
    }
}