XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
InstallerChecker.class.php
1<?php
10
11if (!defined('XOOPS_ROOT_PATH')) {
12 exit();
13}
14
15if (!defined('LEGACY_INSTALLERCHECKER_ACTIVE')) {
16 define('LEGACY_INSTALLERCHECKER_ACTIVE', true);
17}
18
19require_once XOOPS_ROOT_PATH . '/core/XCube_Utils.class.php';
26{
27
28 public function preBlockFilter()
29 {
30
31
32 if ( LEGACY_INSTALLERCHECKER_ACTIVE == true && is_dir(XOOPS_ROOT_PATH . '/install' ) ) {
33
34 $root =& XCube_Root::getSingleton();
35 $root->mLanguageManager->loadModuleMessageCatalog('legacy');
36 $xoopsConfig = $root->mContext->mXoopsConfig;
37
38
39 // Directory /Install
40 // File mainfile.php
41 // Action controls
42 $delete_path = XOOPS_ROOT_PATH . '/install';
43 $mainfile = XOOPS_ROOT_PATH . '/mainfile.php';
44 $pre_disable = XOOPS_ROOT_PATH . '/preload/disabled/AntiInstallerChecker.class.php';
45 $pre_active = XOOPS_ROOT_PATH . '/preload/AntiInstallerChecker.class.php';
46 $btn_chmod = 'chmod';
47 $btn_delete = 'Delete';
48 $btn_preload = 'Activate';
49
50 $permissions = fileperms( $mainfile );
51 $fperm = substr(sprintf( '%o', $permissions), -4 ); //output 0777
52 if ( is_writable( $mainfile ) ) {
53 $is_chmod = true;
54 } else{
55 $is_chmod = false;
56 }
57
58 // PRELOAD
59 // Copy preload from disabled directory
60 function preloadActive( string $pre_disable, string $pre_active ) {
61
62 if( !copy( $pre_disable, $pre_active ) ) {
63 echo "File can't be copied! \n";
64 } else {
65 echo "File has been copied! \n";
66 }
67
68 }
69
70
71 // ACTION CONTROLS
72 if( isset( $_POST[$btn_chmod] ) ) {
73 chmod( $mainfile, 0444 );
74 //echo "<meta http-equiv='refresh' content='0'>"; refresh permissions
75 header("Refresh: 0");
76 }
77
78 if( isset( $_POST[$btn_delete] ) ) {
79 (new XCube_Utils)->recursiveRemove( $delete_path );
80 header("Refresh: 0");
81 }
82
83 if( isset( $_POST[$btn_preload] ) ) {
84 preloadActive( $pre_disable, $pre_active );
85 //(new XCube_Utils)->preloadActive( $pre_disable, $pre_active );
86 header("Refresh: 0");
87 }
88
89 if( isset($_POST['submit'] ) ) {
90 header("Refresh: 0");
91 }
92
93 // Directory /Install Warning
94 if ( is_dir( $delete_path ) ) {
95 $install_warn_dir = XCube_Utils::formatString(_MD_LEGACY_MESSAGE_INSTALL_COMPLETE_WARNING, XOOPS_ROOT_PATH . '/install');
96 }
97
98
99
100 // RENDER view
101 require_once XOOPS_ROOT_PATH . '/class/template.php';
102
103 $xoopsTpl =new XoopsTpl();
104
105 $xoopsTpl->assign(
106 [
107 'xoops_sitename' => htmlspecialchars($xoopsConfig['sitename']),
108 'xoops_themecss' => xoops_getcss(),
109 'xoops_imageurl' => XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'] . '/',
110 'install_confirm' => XCube_Utils::formatString(_MD_LEGACY_MESSAGE_INSTALL_COMPLETE_CONFIRM, XOOPS_ROOT_PATH . '/install'),
111 'install_warning_dir' => $install_warn_dir,
112 'install_warning_tip' => XCube_Utils::formatString(_WARN_INSTALL_TIP),
113 'is_chmod' => $is_chmod,
114 'fperm' => $fperm,
115 'btn_chmod' => $btn_chmod,
116 'btn_delete' => $btn_delete,
117 'btn_preload' => $btn_preload,
118 ]
119 );
120
121 $xoopsTpl->compile_check = true;
122
123 // Filebase template with absolute file path
124 $xoopsTpl->display(XOOPS_ROOT_PATH . '/modules/legacy/templates/legacy_install_completed.html');
125 exit();
126 }
127 }
128}
preBlockFilter()
[Abstract] Executes the logic, when the controller executes preBlockFilter().
static formatString()
[Static] Formats string with special care for international.