Skip to content

Commit

Permalink
Protector updates - PHP8 compatibility, update and remove legacy code (
Browse files Browse the repository at this point in the history
…#1098)

* Corrected class reference to the database class

* Formatting to match icms code syntax, addressing todo items

* Replacing dirname(__FILE__) with __DIR__

* Removing closing php tag at end of file

* Removed closing php tag and extra blank lines at end of file

* removing closing php tag a blank lines at end of file

* Replacing dirname(__FILE__) with __DIR__

* Removed get_magic_quotes_gpc usage

* Updating to use current class instead of deprecated IcmsPreloadItem

* Replacing intval with (int) - speed

* Removing tests for conditions that will never occur

* correcting logic for HTMLPurifier filter class_exists config

* Converting to icms_version files

* Wrong file was being included

* Replacing use of xoopsConfig with icmsConfig

* Removing search - do not include

* Didn't see the search config value at the bottom of the file

* Removed conditional check in language loading that was unnecessary

* Replacing the remaining $xoopsUser occurrences and global inclusions

* Removed deprecated references and conditionals that will not occur

* Updating version information for Protector
  • Loading branch information
skenow authored Dec 4, 2021
1 parent 4852a3b commit 1751e4a
Show file tree
Hide file tree
Showing 63 changed files with 2,860 additions and 3,208 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?php
if (!defined('ICMS_TRUST_PATH')) die('set ICMS_TRUST_PATH into mainfile.php');

if( ! defined( 'ICMS_TRUST_PATH' ) ) die( 'set ICMS_TRUST_PATH into mainfile.php' ) ;
$mydirname = basename(dirname(__DIR__));
$mydirpath = dirname(__DIR__);
require $mydirpath . '/mytrustdirname.php'; // set $mytrustdirname

$mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
$mydirpath = dirname( dirname( __FILE__ ) ) ;
require $mydirpath.'/mytrustdirname.php' ; // set $mytrustdirname

require ICMS_TRUST_PATH.'/modules/'.$mytrustdirname.'/admin_menu.php' ;

?>
require ICMS_TRUST_PATH . '/modules/' . $mytrustdirname . '/admin_menu.php';
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<?php
require '../../../mainfile.php';
if (!defined('ICMS_TRUST_PATH')) die('set ICMS_TRUST_PATH in mainfile.php');

require '../../../mainfile.php' ;
if( ! defined( 'ICMS_TRUST_PATH' ) ) die( 'set ICMS_TRUST_PATH in mainfile.php' ) ;
$mydirname = basename(dirname(__DIR__));
$mydirpath = dirname(__DIR__);
require $mydirpath . '/mytrustdirname.php'; // set $mytrustdirname

$mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
$mydirpath = dirname( dirname( __FILE__ ) ) ;
require $mydirpath.'/mytrustdirname.php' ; // set $mytrustdirname

require ICMS_TRUST_PATH.'/modules/'.$mytrustdirname.'/admin.php' ;

?>
require ICMS_TRUST_PATH . '/modules/' . $mytrustdirname . '/admin.php';
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?php
if (!defined('ICMS_TRUST_PATH')) die('set ICMS_TRUST_PATH into mainfile.php');

if( ! defined( 'ICMS_TRUST_PATH' ) ) die( 'set ICMS_TRUST_PATH into mainfile.php' ) ;
$mydirname = basename(dirname(__DIR__));
$mydirpath = dirname(__DIR__);
require $mydirpath . '/mytrustdirname.php'; // set $mytrustdirname

$mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
$mydirpath = dirname( dirname( __FILE__ ) ) ;
require $mydirpath.'/mytrustdirname.php' ; // set $mytrustdirname

require ICMS_TRUST_PATH.'/modules/'.$mytrustdirname.'/blocks.php' ;

?>
require ICMS_TRUST_PATH . '/modules/' . $mytrustdirname . '/blocks.php';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
if (!defined('ICMS_TRUST_PATH')) die('set ICMS_TRUST_PATH into mainfile.php');

$mydirname = basename(__DIR__);
$mydirpath = __DIR__;
require $mydirpath . '/mytrustdirname.php'; // set $mytrustdirname

require ICMS_TRUST_PATH . '/modules/' . $mytrustdirname . '/icms_version.php';
19 changes: 8 additions & 11 deletions htdocs/install/modules/protector/root/modules/protector/index.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<?php
require '../../mainfile.php';
if (!defined('ICMS_TRUST_PATH')) die('set ICMS_TRUST_PATH in mainfile.php');

require '../../mainfile.php' ;
if( ! defined( 'ICMS_TRUST_PATH' ) ) die( 'set ICMS_TRUST_PATH in mainfile.php' ) ;
$mydirname = basename(__DIR__);
$mydirpath = __DIR__;
require $mydirpath . '/mytrustdirname.php'; // set $mytrustdirname

$mydirname = basename( dirname( __FILE__ ) ) ;
$mydirpath = dirname( __FILE__ ) ;
require $mydirpath.'/mytrustdirname.php' ; // set $mytrustdirname

if( @$_GET['mode'] == 'admin' ) {
require ICMS_TRUST_PATH.'/modules/'.$mytrustdirname.'/admin.php' ;
if (@$_GET['mode'] == 'admin') {
require ICMS_TRUST_PATH . '/modules/' . $mytrustdirname . '/admin.php';
} else {
require ICMS_TRUST_PATH.'/modules/'.$mytrustdirname.'/main.php' ;
require ICMS_TRUST_PATH . '/modules/' . $mytrustdirname . '/main.php';
}

?>
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<?php
$xoopsOption['nocommon'] = true;
require '../../mainfile.php';

$xoopsOption['nocommon'] = true ;
require '../../mainfile.php' ;
if (!defined('ICMS_TRUST_PATH')) die('set ICMS_TRUST_PATH into mainfile.php');

if( ! defined( 'ICMS_TRUST_PATH' ) ) die( 'set ICMS_TRUST_PATH into mainfile.php' ) ;
$mydirname = basename(__DIR__);
$mydirpath = __DIR__;
require $mydirpath . '/mytrustdirname.php'; // set $mytrustdirname

$mydirname = basename( dirname( __FILE__ ) ) ;
$mydirpath = dirname( __FILE__ ) ;
require $mydirpath.'/mytrustdirname.php' ; // set $mytrustdirname

require ICMS_TRUST_PATH.'/modules/'.$mytrustdirname.'/module_icon.php' ;

?>
require ICMS_TRUST_PATH . '/modules/' . $mytrustdirname . '/module_icon.php';
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<?php
$mytrustdirname = 'protector' ;
?>
$mytrustdirname = 'protector';
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?php
if (!defined('ICMS_TRUST_PATH')) die('set ICMS_TRUST_PATH into mainfile.php');

if( ! defined( 'ICMS_TRUST_PATH' ) ) die( 'set ICMS_TRUST_PATH into mainfile.php' ) ;
$mydirname = basename(__DIR__);
$mydirpath = __DIR__;
require $mydirpath . '/mytrustdirname.php'; // set $mytrustdirname

$mydirname = basename( dirname( __FILE__ ) ) ;
$mydirpath = dirname( __FILE__ ) ;
require $mydirpath.'/mytrustdirname.php' ; // set $mytrustdirname

require ICMS_TRUST_PATH.'/modules/'.$mytrustdirname.'/notification.php' ;

?>
require ICMS_TRUST_PATH . '/modules/' . $mytrustdirname . '/notification.php';
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php
require '../../mainfile.php' ;
if( ! defined( 'ICMS_TRUST_PATH' ) ) die( 'set ICMS_TRUST_PATH in mainfile.php' ) ;
require '../../mainfile.php';
if (!defined('ICMS_TRUST_PATH')) die('set ICMS_TRUST_PATH in mainfile.php');

$mydirname = basename( dirname( __FILE__ ) ) ;
$mydirpath = dirname( __FILE__ ) ;
$mydirurl = ICMS_URL.'/modules/'.$mydirname;
$mydirname = basename(__DIR__);
$mydirpath = __DIR__;
$mydirurl = ICMS_URL . '/modules/' . $mydirname;

require $mydirpath.'/mytrustdirname.php' ; // set $mytrustdirname
require $mydirpath . '/mytrustdirname.php'; // set $mytrustdirname

$_GET['page'] = basename( __FILE__ , '.php');
$_GET['page'] = basename(__FILE__, '.php');

require ICMS_TRUST_PATH.'/modules/'.$mytrustdirname.'/main.php' ;
?>
require ICMS_TRUST_PATH . '/modules/' . $mytrustdirname . '/main.php';
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?php
if (!defined('ICMS_TRUST_PATH')) die('set ICMS_TRUST_PATH into mainfile.php');

if( ! defined( 'ICMS_TRUST_PATH' ) ) die( 'set ICMS_TRUST_PATH into mainfile.php' ) ;
$mydirname = basename(__DIR__);
$mydirpath = __DIR__;
require $mydirpath . '/mytrustdirname.php'; // set $mytrustdirname

$mydirname = basename( dirname( __FILE__ ) ) ;
$mydirpath = dirname( __FILE__ ) ;
require $mydirpath.'/mytrustdirname.php' ; // set $mytrustdirname

require ICMS_TRUST_PATH.'/modules/'.$mytrustdirname.'/oninstall.php' ;

?>
require ICMS_TRUST_PATH . '/modules/' . $mytrustdirname . '/oninstall.php';
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?php
if (!defined('ICMS_TRUST_PATH')) die('set ICMS_TRUST_PATH into mainfile.php');

if( ! defined( 'ICMS_TRUST_PATH' ) ) die( 'set ICMS_TRUST_PATH into mainfile.php' ) ;
$mydirname = basename(__DIR__);
$mydirpath = __DIR__;
require $mydirpath . '/mytrustdirname.php'; // set $mytrustdirname

$mydirname = basename( dirname( __FILE__ ) ) ;
$mydirpath = dirname( __FILE__ ) ;
require $mydirpath.'/mytrustdirname.php' ; // set $mytrustdirname

require ICMS_TRUST_PATH.'/modules/'.$mytrustdirname.'/onuninstall.php' ;

?>
require ICMS_TRUST_PATH . '/modules/' . $mytrustdirname . '/onuninstall.php';
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?php
if (!defined('ICMS_TRUST_PATH')) die('set ICMS_TRUST_PATH into mainfile.php');

if( ! defined( 'ICMS_TRUST_PATH' ) ) die( 'set ICMS_TRUST_PATH into mainfile.php' ) ;
$mydirname = basename(__DIR__);
$mydirpath = __DIR__;
require $mydirpath . '/mytrustdirname.php'; // set $mytrustdirname

$mydirname = basename( dirname( __FILE__ ) ) ;
$mydirpath = dirname( __FILE__ ) ;
require $mydirpath.'/mytrustdirname.php' ; // set $mytrustdirname

require ICMS_TRUST_PATH.'/modules/'.$mytrustdirname.'/onupdate.php' ;

?>
require ICMS_TRUST_PATH . '/modules/' . $mytrustdirname . '/onupdate.php';
11 changes: 0 additions & 11 deletions htdocs/install/modules/protector/root/modules/protector/search.php

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,73 +1,53 @@
<?php

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

// environment
require_once ICMS_ROOT_PATH.'/class/template.php' ;
$module_handler = icms::handler('icms_module') ;
$xoopsModule = $module_handler->getByDirname( $mydirname ) ;
$config_handler = icms::handler('icms_config') ;
$xoopsModuleConfig =& $config_handler->getConfigsByCat( 0 , $xoopsModule->getVar( 'mid' ) ) ;
$module_handler = icms::handler('icms_module');
$xoopsModule = $module_handler->getByDirname($mydirname);
$config_handler = icms::handler('icms_config');
$xoopsModuleConfig = &$config_handler->getConfigsByCat(0, $xoopsModule->getVar('mid'));

// check permission of 'module_admin' of this module
$moduleperm_handler = icms::handler('icms_member_groupperm') ;
if( ! is_object( @icms::$user ) || ! $moduleperm_handler->checkRight( 'module_admin' , $xoopsModule->getVar( 'mid' ) , icms::$user->getGroups() ) ) die( 'only admin can access this area' ) ;
$moduleperm_handler = icms::handler('icms_member_groupperm');
if (!is_object(@icms::$user) || !$moduleperm_handler->checkRight('module_admin', $xoopsModule->getVar('mid'), icms::$user->getGroups())) die('only admin can access this area');

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

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

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

// fork each pages of this module
$page = preg_replace('/[^a-zA-Z0-9_-]/', '', @$_GET['page']);


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( ICMS_TRUST_PATH.'/libs/'.$lib.'/'.$page.'.php' ) ) {
include ICMS_TRUST_PATH.'/libs/'.$lib.'/'.$page.'.php' ;
} else if( file_exists( ICMS_TRUST_PATH.'/libs/'.$lib.'/index.php' ) ) {
include ICMS_TRUST_PATH.'/libs/'.$lib.'/index.php' ;
} else {
die( 'wrong request' ) ;
}
if (file_exists("$mytrustdirpath/admin/$page.php")) {
include "$mytrustdirpath/admin/$page.php";
} else if (file_exists("$mytrustdirpath/admin/index.php")) {
include "$mytrustdirpath/admin/index.php";
} 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" ;
} else if( file_exists( "$mytrustdirpath/admin/index.php" ) ) {
include "$mytrustdirpath/admin/index.php" ;
} else {
die( 'wrong request' ) ;
}
die('wrong request');
}

?>
Loading

0 comments on commit 1751e4a

Please sign in to comment.