@@ -22,12 +22,12 @@ |
||
22 | 22 | */ |
23 | 23 | class InstructionCorePreload extends XoopsPreloadItem |
24 | 24 | { |
25 | - // to add PSR-4 autoloader |
|
26 | - /** |
|
27 | - * @param $args |
|
28 | - */ |
|
29 | - public static function eventCoreIncludeCommonEnd($args) |
|
30 | - { |
|
31 | - include __DIR__ . '/autoloader.php'; |
|
32 | - } |
|
25 | + // to add PSR-4 autoloader |
|
26 | + /** |
|
27 | + * @param $args |
|
28 | + */ |
|
29 | + public static function eventCoreIncludeCommonEnd($args) |
|
30 | + { |
|
31 | + include __DIR__ . '/autoloader.php'; |
|
32 | + } |
|
33 | 33 | } |
@@ -4,29 +4,29 @@ |
||
4 | 4 | * @see http://www.php-fig.org/psr/psr-4/examples/ |
5 | 5 | */ |
6 | 6 | spl_autoload_register(function ($class) { |
7 | - // project-specific namespace prefix |
|
8 | - $prefix = 'Xoopsmodules\\instruction\\'; |
|
7 | + // project-specific namespace prefix |
|
8 | + $prefix = 'Xoopsmodules\\instruction\\'; |
|
9 | 9 | |
10 | - // base directory for the namespace prefix |
|
11 | - $base_dir = __DIR__ . '/../class/'; |
|
10 | + // base directory for the namespace prefix |
|
11 | + $base_dir = __DIR__ . '/../class/'; |
|
12 | 12 | |
13 | - // does the class use the namespace prefix? |
|
14 | - $len = strlen($prefix); |
|
13 | + // does the class use the namespace prefix? |
|
14 | + $len = strlen($prefix); |
|
15 | 15 | |
16 | - if (0 !== strncmp($prefix, $class, $len)) { |
|
17 | - return; |
|
18 | - } |
|
16 | + if (0 !== strncmp($prefix, $class, $len)) { |
|
17 | + return; |
|
18 | + } |
|
19 | 19 | |
20 | - // get the relative class name |
|
21 | - $relative_class = substr($class, $len); |
|
20 | + // get the relative class name |
|
21 | + $relative_class = substr($class, $len); |
|
22 | 22 | |
23 | - // replace the namespace prefix with the base directory, replace namespace |
|
24 | - // separators with directory separators in the relative class name, append |
|
25 | - // with .php |
|
26 | - $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
|
23 | + // replace the namespace prefix with the base directory, replace namespace |
|
24 | + // separators with directory separators in the relative class name, append |
|
25 | + // with .php |
|
26 | + $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
|
27 | 27 | |
28 | - // if the file exists, require it |
|
29 | - if (file_exists($file)) { |
|
30 | - require $file; |
|
31 | - } |
|
28 | + // if the file exists, require it |
|
29 | + if (file_exists($file)) { |
|
30 | + require $file; |
|
31 | + } |
|
32 | 32 | }); |
@@ -3,7 +3,7 @@ |
||
3 | 3 | /** |
4 | 4 | * @see http://www.php-fig.org/psr/psr-4/examples/ |
5 | 5 | */ |
6 | -spl_autoload_register(function ($class) { |
|
6 | +spl_autoload_register(function($class) { |
|
7 | 7 | // project-specific namespace prefix |
8 | 8 | $prefix = 'Xoopsmodules\\instruction\\'; |
9 | 9 |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | $module = $helper->getModule(); |
49 | 49 | |
50 | 50 | if (Xoopsmodules\instruction\Utility::checkVerXoops($module, '2.5.9')) { |
51 | - $cat_select = $mytree->makeSelectElement('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'", ''); |
|
52 | - $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select->render()); |
|
51 | + $cat_select = $mytree->makeSelectElement('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'", ''); |
|
52 | + $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select->render()); |
|
53 | 53 | } else { |
54 | - $cat_select = $mytree->makeSelBox('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'"); |
|
55 | - $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select); |
|
54 | + $cat_select = $mytree->makeSelBox('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'"); |
|
55 | + $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | // Находим список всех инструкций |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | $criteria->add(new \Criteria('status', '0', '>')); |
63 | 63 | // Если есть категория |
64 | 64 | if ($cid) { |
65 | - // Если нельзя просматривать эту категорию |
|
66 | - if (!in_array($cid, $categories)) { |
|
67 | - redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT); |
|
68 | - } |
|
69 | - $criteria->add(new \Criteria('cid', $cid, '=')); |
|
70 | - // Иначе находим список всех |
|
65 | + // Если нельзя просматривать эту категорию |
|
66 | + if (!in_array($cid, $categories)) { |
|
67 | + redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT); |
|
68 | + } |
|
69 | + $criteria->add(new \Criteria('cid', $cid, '=')); |
|
70 | + // Иначе находим список всех |
|
71 | 71 | } else { |
72 | - $criteria->add(new \Criteria('cid', '( ' . implode(', ', $categories) . ' )', 'IN')); |
|
72 | + $criteria->add(new \Criteria('cid', '( ' . implode(', ', $categories) . ' )', 'IN')); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // Число инструкций, удовлетворяющих данному условию |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | $instr_arr = $instructionHandler->getall($criteria); |
87 | 87 | // Если записей больше чем $limit, то выводим пагинатор |
88 | 88 | if ($numrows > $limit) { |
89 | - $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'cid=' . $cid); |
|
90 | - $pagenav = $pagenav->renderNav(4); |
|
89 | + $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'cid=' . $cid); |
|
90 | + $pagenav = $pagenav->renderNav(4); |
|
91 | 91 | } else { |
92 | - $pagenav = ''; |
|
92 | + $pagenav = ''; |
|
93 | 93 | } |
94 | 94 | // Выводим пагинатор в шаблон |
95 | 95 | $GLOBALS['xoopsTpl']->assign('insPagenav', $pagenav); |
@@ -100,53 +100,53 @@ discard block |
||
100 | 100 | |
101 | 101 | // Если есть записи |
102 | 102 | if ($numrows > 0) { |
103 | - $class = 'odd'; |
|
104 | - foreach (array_keys($instr_arr) as $i) { |
|
105 | - |
|
106 | - // |
|
107 | - $class = ('even' === $class) ? 'odd' : 'even'; |
|
108 | - // ID |
|
109 | - $insinstr_instrid = $instr_arr[$i]->getVar('instrid'); |
|
110 | - // Название |
|
111 | - $insinstr_title = $instr_arr[$i]->getVar('title'); |
|
112 | - // Статус |
|
113 | - $insinstr_status = $instr_arr[$i]->getVar('status'); |
|
114 | - // Количество страниц |
|
115 | - $insinstr_pages = $instr_arr[$i]->getVar('pages'); |
|
116 | - // Категория |
|
117 | - $insinstr_cid = $instr_arr[$i]->getVar('cid'); |
|
118 | - $insinstr_cat = $categoryHandler->get($insinstr_cid); |
|
119 | - // Права на добавление |
|
120 | - $perm_submit = in_array($insinstr_cid, $cat_submit) ? true : false; |
|
121 | - // Права на редактирование |
|
122 | - $perm_edit = in_array($insinstr_cid, $cat_edit) ? true : false; |
|
123 | - //Мета-теги ключевых слов |
|
124 | - $insinstr_metakeywords = $instr_arr[$i]->getVar('metakeywords'); |
|
125 | - // Если есть - добавляем в мета-теги страницы |
|
126 | - if ($insinstr_metakeywords) { |
|
127 | - $index_metakeywords[] = $insinstr_metakeywords; |
|
128 | - } |
|
129 | - // Мета-теги описания |
|
130 | - $insinstr_metadescript = $instr_arr[$i]->getVar('metadescription'); |
|
131 | - // Если есть - добавляем в мета-теги страницы |
|
132 | - if ($insinstr_metadescript) { |
|
133 | - $index_metadescript[] = $insinstr_metadescript; |
|
134 | - } |
|
135 | - |
|
136 | - // Выводим в шаблон |
|
137 | - $GLOBALS['xoopsTpl']->append('insListInstr', |
|
138 | - ['instrid' => $insinstr_instrid, 'title' => $insinstr_title, 'status' => $insinstr_status, 'pages' => $insinstr_pages, 'ctitle' => $insinstr_cat->getVar('title'), 'cid' => $insinstr_cid, 'permsubmit' => $perm_submit, 'permedit' => $perm_edit, 'class' => $class]); |
|
139 | - } |
|
140 | - |
|
141 | - // Языковые константы |
|
103 | + $class = 'odd'; |
|
104 | + foreach (array_keys($instr_arr) as $i) { |
|
105 | + |
|
106 | + // |
|
107 | + $class = ('even' === $class) ? 'odd' : 'even'; |
|
108 | + // ID |
|
109 | + $insinstr_instrid = $instr_arr[$i]->getVar('instrid'); |
|
110 | + // Название |
|
111 | + $insinstr_title = $instr_arr[$i]->getVar('title'); |
|
112 | + // Статус |
|
113 | + $insinstr_status = $instr_arr[$i]->getVar('status'); |
|
114 | + // Количество страниц |
|
115 | + $insinstr_pages = $instr_arr[$i]->getVar('pages'); |
|
116 | + // Категория |
|
117 | + $insinstr_cid = $instr_arr[$i]->getVar('cid'); |
|
118 | + $insinstr_cat = $categoryHandler->get($insinstr_cid); |
|
119 | + // Права на добавление |
|
120 | + $perm_submit = in_array($insinstr_cid, $cat_submit) ? true : false; |
|
121 | + // Права на редактирование |
|
122 | + $perm_edit = in_array($insinstr_cid, $cat_edit) ? true : false; |
|
123 | + //Мета-теги ключевых слов |
|
124 | + $insinstr_metakeywords = $instr_arr[$i]->getVar('metakeywords'); |
|
125 | + // Если есть - добавляем в мета-теги страницы |
|
126 | + if ($insinstr_metakeywords) { |
|
127 | + $index_metakeywords[] = $insinstr_metakeywords; |
|
128 | + } |
|
129 | + // Мета-теги описания |
|
130 | + $insinstr_metadescript = $instr_arr[$i]->getVar('metadescription'); |
|
131 | + // Если есть - добавляем в мета-теги страницы |
|
132 | + if ($insinstr_metadescript) { |
|
133 | + $index_metadescript[] = $insinstr_metadescript; |
|
134 | + } |
|
135 | + |
|
136 | + // Выводим в шаблон |
|
137 | + $GLOBALS['xoopsTpl']->append('insListInstr', |
|
138 | + ['instrid' => $insinstr_instrid, 'title' => $insinstr_title, 'status' => $insinstr_status, 'pages' => $insinstr_pages, 'ctitle' => $insinstr_cat->getVar('title'), 'cid' => $insinstr_cid, 'permsubmit' => $perm_submit, 'permedit' => $perm_edit, 'class' => $class]); |
|
139 | + } |
|
140 | + |
|
141 | + // Языковые константы |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | // Если есть мета-теги |
145 | 145 | if (count($index_metakeywords)) { |
146 | - $xoTheme->addMeta('meta', 'keywords', implode(', ', $index_metakeywords)); |
|
146 | + $xoTheme->addMeta('meta', 'keywords', implode(', ', $index_metakeywords)); |
|
147 | 147 | } |
148 | 148 | if (count($index_metadescript)) { |
149 | - $xoTheme->addMeta('meta', 'description', implode(', ', $index_metadescript)); |
|
149 | + $xoTheme->addMeta('meta', 'description', implode(', ', $index_metadescript)); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | // Подвал |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | // Стили |
18 | 18 | $xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/style.css'); |
19 | 19 | // |
20 | -$cid = isset($_GET['cid']) ? (int)$_GET['cid'] : 0; |
|
20 | +$cid = isset($_GET['cid']) ? (int) $_GET['cid'] : 0; |
|
21 | 21 | // |
22 | -$start = isset($_GET['start']) ? (int)$_GET['start'] : 0; |
|
22 | +$start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
23 | 23 | // |
24 | 24 | |
25 | 25 | //mb $limit = xoops_getModuleOption('perpagemain', 'instruction'); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | // Если есть категория |
64 | 64 | if ($cid) { |
65 | 65 | // Если нельзя просматривать эту категорию |
66 | - if (!in_array($cid, $categories)) { |
|
66 | + if ( ! in_array($cid, $categories)) { |
|
67 | 67 | redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT); |
68 | 68 | } |
69 | 69 | $criteria->add(new \Criteria('cid', $cid, '=')); |
@@ -17,77 +17,77 @@ |
||
17 | 17 | */ |
18 | 18 | trait VersionChecks |
19 | 19 | { |
20 | - /** |
|
21 | - * |
|
22 | - * Verifies XOOPS version meets minimum requirements for this module |
|
23 | - * @static |
|
24 | - * @param \XoopsModule|null $module |
|
25 | - * |
|
26 | - * @param null|string $requiredVer |
|
27 | - * @return bool true if meets requirements, false if not |
|
28 | - */ |
|
29 | - public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) |
|
30 | - { |
|
31 | - $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
32 | - if (null === $module) { |
|
33 | - $module = \XoopsModule::getByDirname($moduleDirName); |
|
34 | - } |
|
35 | - xoops_loadLanguage('admin', $moduleDirName); |
|
36 | - //check for minimum XOOPS version |
|
37 | - $currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string |
|
38 | - $currArray = explode('.', $currentVer); |
|
39 | - if (null === $requiredVer) { |
|
40 | - $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
41 | - } |
|
42 | - $reqArray = explode('.', $requiredVer); |
|
43 | - $success = true; |
|
44 | - foreach ($reqArray as $k => $v) { |
|
45 | - if (isset($currArray[$k])) { |
|
46 | - if ($currArray[$k] > $v) { |
|
47 | - break; |
|
48 | - } elseif ($currArray[$k] == $v) { |
|
49 | - continue; |
|
50 | - } else { |
|
51 | - $success = false; |
|
52 | - break; |
|
53 | - } |
|
54 | - } else { |
|
55 | - if ((int)$v > 0) { // handles versions like x.x.x.0_RC2 |
|
56 | - $success = false; |
|
57 | - break; |
|
58 | - } |
|
59 | - } |
|
60 | - } |
|
20 | + /** |
|
21 | + * |
|
22 | + * Verifies XOOPS version meets minimum requirements for this module |
|
23 | + * @static |
|
24 | + * @param \XoopsModule|null $module |
|
25 | + * |
|
26 | + * @param null|string $requiredVer |
|
27 | + * @return bool true if meets requirements, false if not |
|
28 | + */ |
|
29 | + public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null) |
|
30 | + { |
|
31 | + $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
32 | + if (null === $module) { |
|
33 | + $module = \XoopsModule::getByDirname($moduleDirName); |
|
34 | + } |
|
35 | + xoops_loadLanguage('admin', $moduleDirName); |
|
36 | + //check for minimum XOOPS version |
|
37 | + $currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string |
|
38 | + $currArray = explode('.', $currentVer); |
|
39 | + if (null === $requiredVer) { |
|
40 | + $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
|
41 | + } |
|
42 | + $reqArray = explode('.', $requiredVer); |
|
43 | + $success = true; |
|
44 | + foreach ($reqArray as $k => $v) { |
|
45 | + if (isset($currArray[$k])) { |
|
46 | + if ($currArray[$k] > $v) { |
|
47 | + break; |
|
48 | + } elseif ($currArray[$k] == $v) { |
|
49 | + continue; |
|
50 | + } else { |
|
51 | + $success = false; |
|
52 | + break; |
|
53 | + } |
|
54 | + } else { |
|
55 | + if ((int)$v > 0) { // handles versions like x.x.x.0_RC2 |
|
56 | + $success = false; |
|
57 | + break; |
|
58 | + } |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - if (false === $success) { |
|
63 | - $module->setErrors(sprintf(_AM_WFL_ERROR_BAD_XOOPS, $requiredVer, $currentVer)); |
|
64 | - } |
|
62 | + if (false === $success) { |
|
63 | + $module->setErrors(sprintf(_AM_WFL_ERROR_BAD_XOOPS, $requiredVer, $currentVer)); |
|
64 | + } |
|
65 | 65 | |
66 | - return $success; |
|
67 | - } |
|
66 | + return $success; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * |
|
71 | - * Verifies PHP version meets minimum requirements for this module |
|
72 | - * @static |
|
73 | - * @param \XoopsModule $module |
|
74 | - * |
|
75 | - * @return bool true if meets requirements, false if not |
|
76 | - */ |
|
77 | - public static function checkVerPhp(\XoopsModule $module) |
|
78 | - { |
|
79 | - xoops_loadLanguage('admin', $module->dirname()); |
|
80 | - // check for minimum PHP version |
|
81 | - $success = true; |
|
82 | - $verNum = PHP_VERSION; |
|
83 | - $reqVer = $module->getInfo('min_php'); |
|
84 | - if (false !== $reqVer && '' !== $reqVer) { |
|
85 | - if (version_compare($verNum, $reqVer, '<')) { |
|
86 | - $module->setErrors(sprintf(_AM_WFL_ERROR_BAD_PHP, $reqVer, $verNum)); |
|
87 | - $success = false; |
|
88 | - } |
|
89 | - } |
|
69 | + /** |
|
70 | + * |
|
71 | + * Verifies PHP version meets minimum requirements for this module |
|
72 | + * @static |
|
73 | + * @param \XoopsModule $module |
|
74 | + * |
|
75 | + * @return bool true if meets requirements, false if not |
|
76 | + */ |
|
77 | + public static function checkVerPhp(\XoopsModule $module) |
|
78 | + { |
|
79 | + xoops_loadLanguage('admin', $module->dirname()); |
|
80 | + // check for minimum PHP version |
|
81 | + $success = true; |
|
82 | + $verNum = PHP_VERSION; |
|
83 | + $reqVer = $module->getInfo('min_php'); |
|
84 | + if (false !== $reqVer && '' !== $reqVer) { |
|
85 | + if (version_compare($verNum, $reqVer, '<')) { |
|
86 | + $module->setErrors(sprintf(_AM_WFL_ERROR_BAD_PHP, $reqVer, $verNum)); |
|
87 | + $success = false; |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - return $success; |
|
92 | - } |
|
91 | + return $success; |
|
92 | + } |
|
93 | 93 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | break; |
52 | 52 | } |
53 | 53 | } else { |
54 | - if ((int)$v > 0) { // handles versions like x.x.x.0_RC2 |
|
54 | + if ((int) $v > 0) { // handles versions like x.x.x.0_RC2 |
|
55 | 55 | $success = false; |
56 | 56 | break; |
57 | 57 | } |
@@ -17,60 +17,60 @@ |
||
17 | 17 | */ |
18 | 18 | trait ServerStats |
19 | 19 | { |
20 | - /** |
|
21 | - * serverStats() |
|
22 | - * |
|
23 | - * @return string |
|
24 | - */ |
|
25 | - public static function getServerStats() |
|
26 | - { |
|
27 | - //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); |
|
28 | - $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
29 | - $moduleDirNameUpper = strtoupper($moduleDirName); |
|
30 | - xoops_loadLanguage('common', $moduleDirName); |
|
31 | - $html = ''; |
|
32 | - // $sql = 'SELECT metavalue'; |
|
33 | - // $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta'); |
|
34 | - // $sql .= " WHERE metakey='version' LIMIT 1"; |
|
35 | - // $query = $GLOBALS['xoopsDB']->query($sql); |
|
36 | - // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); |
|
37 | - $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n"; |
|
38 | - $html .= "<div style='padding: 8px;'>\n"; |
|
39 | - // $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n"; |
|
40 | - // $html .= "<br>\n"; |
|
41 | - // $html .= "<br>\n"; |
|
42 | - $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n"; |
|
43 | - $html .= "<ul>\n"; |
|
44 | - // |
|
45 | - $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
|
46 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
47 | - if (function_exists('gd_info')) { |
|
48 | - if ($gdlib = (true === gd_info())) { |
|
49 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
|
50 | - } |
|
51 | - } |
|
52 | - // |
|
53 | - // $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF'); |
|
54 | - // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode; |
|
55 | - // |
|
56 | - // $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>'; |
|
57 | - // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
|
58 | - // |
|
59 | - $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
|
60 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
61 | - // |
|
62 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n"; |
|
63 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n"; |
|
64 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . "</span></b>\n"; |
|
65 | - $html .= "</ul>\n"; |
|
66 | - $html .= "<ul>\n"; |
|
67 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n"; |
|
68 | - $html .= "</ul>\n"; |
|
69 | - $html .= "<br>\n"; |
|
70 | - $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; |
|
71 | - $html .= '</div>'; |
|
72 | - $html .= '</fieldset><br>'; |
|
20 | + /** |
|
21 | + * serverStats() |
|
22 | + * |
|
23 | + * @return string |
|
24 | + */ |
|
25 | + public static function getServerStats() |
|
26 | + { |
|
27 | + //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); |
|
28 | + $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
29 | + $moduleDirNameUpper = strtoupper($moduleDirName); |
|
30 | + xoops_loadLanguage('common', $moduleDirName); |
|
31 | + $html = ''; |
|
32 | + // $sql = 'SELECT metavalue'; |
|
33 | + // $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta'); |
|
34 | + // $sql .= " WHERE metakey='version' LIMIT 1"; |
|
35 | + // $query = $GLOBALS['xoopsDB']->query($sql); |
|
36 | + // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); |
|
37 | + $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n"; |
|
38 | + $html .= "<div style='padding: 8px;'>\n"; |
|
39 | + // $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n"; |
|
40 | + // $html .= "<br>\n"; |
|
41 | + // $html .= "<br>\n"; |
|
42 | + $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n"; |
|
43 | + $html .= "<ul>\n"; |
|
44 | + // |
|
45 | + $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
|
46 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
47 | + if (function_exists('gd_info')) { |
|
48 | + if ($gdlib = (true === gd_info())) { |
|
49 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
|
50 | + } |
|
51 | + } |
|
52 | + // |
|
53 | + // $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF'); |
|
54 | + // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode; |
|
55 | + // |
|
56 | + // $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>'; |
|
57 | + // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
|
58 | + // |
|
59 | + $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
|
60 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
61 | + // |
|
62 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n"; |
|
63 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n"; |
|
64 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . "</span></b>\n"; |
|
65 | + $html .= "</ul>\n"; |
|
66 | + $html .= "<ul>\n"; |
|
67 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n"; |
|
68 | + $html .= "</ul>\n"; |
|
69 | + $html .= "<br>\n"; |
|
70 | + $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; |
|
71 | + $html .= '</div>'; |
|
72 | + $html .= '</fieldset><br>'; |
|
73 | 73 | |
74 | - return $html; |
|
75 | - } |
|
74 | + return $html; |
|
75 | + } |
|
76 | 76 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $html .= "<ul>\n"; |
44 | 44 | // |
45 | 45 | $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
46 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
46 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
47 | 47 | if (function_exists('gd_info')) { |
48 | 48 | if ($gdlib = (true === gd_info())) { |
49 | 49 | $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
58 | 58 | // |
59 | 59 | $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
60 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
60 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
61 | 61 | // |
62 | 62 | $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n"; |
63 | 63 | $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n"; |
@@ -17,228 +17,228 @@ |
||
17 | 17 | */ |
18 | 18 | trait FilesManagement |
19 | 19 | { |
20 | - /** |
|
21 | - * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
22 | - * |
|
23 | - * @param string $folder The full path of the directory to check |
|
24 | - * |
|
25 | - * @return void |
|
26 | - * @throws \RuntimeException |
|
27 | - */ |
|
28 | - public static function createFolder($folder) |
|
29 | - { |
|
30 | - try { |
|
31 | - if (!file_exists($folder)) { |
|
32 | - if (!mkdir($folder) && !is_dir($folder)) { |
|
33 | - throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
34 | - } |
|
35 | - |
|
36 | - file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
37 | - } |
|
38 | - } |
|
39 | - catch (\Exception $e) { |
|
40 | - echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
41 | - } |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * @param $file |
|
46 | - * @param $folder |
|
47 | - * @return bool |
|
48 | - */ |
|
49 | - public static function copyFile($file, $folder) |
|
50 | - { |
|
51 | - return copy($file, $folder); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * @param $src |
|
56 | - * @param $dst |
|
57 | - */ |
|
58 | - public static function recurseCopy($src, $dst) |
|
59 | - { |
|
60 | - $dir = opendir($src); |
|
61 | - @mkdir($dst); |
|
62 | - while (false !== ($file = readdir($dir))) { |
|
63 | - if (('.' !== $file) && ('..' !== $file)) { |
|
64 | - if (is_dir($src . '/' . $file)) { |
|
65 | - self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
66 | - } else { |
|
67 | - copy($src . '/' . $file, $dst . '/' . $file); |
|
68 | - } |
|
69 | - } |
|
70 | - } |
|
71 | - closedir($dir); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * |
|
76 | - * Remove files and (sub)directories |
|
77 | - * |
|
78 | - * @param string $src source directory to delete |
|
79 | - * |
|
80 | - * @uses \Xmf\Module\Helper::getHelper() |
|
81 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
82 | - * |
|
83 | - * @return bool true on success |
|
84 | - */ |
|
85 | - public static function deleteDirectory($src) |
|
86 | - { |
|
87 | - // Only continue if user is a 'global' Admin |
|
88 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
89 | - return false; |
|
90 | - } |
|
91 | - |
|
92 | - $success = true; |
|
93 | - // remove old files |
|
94 | - $dirInfo = new \SplFileInfo($src); |
|
95 | - // validate is a directory |
|
96 | - if ($dirInfo->isDir()) { |
|
97 | - $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); |
|
98 | - foreach ($fileList as $k => $v) { |
|
99 | - $fileInfo = new \SplFileInfo("{$src}/{$v}"); |
|
100 | - if ($fileInfo->isDir()) { |
|
101 | - // recursively handle subdirectories |
|
102 | - if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
103 | - break; |
|
104 | - } |
|
105 | - } else { |
|
106 | - // delete the file |
|
107 | - if (!($success = unlink($fileInfo->getRealPath()))) { |
|
108 | - break; |
|
109 | - } |
|
110 | - } |
|
111 | - } |
|
112 | - // now delete this (sub)directory if all the files are gone |
|
113 | - if ($success) { |
|
114 | - $success = rmdir($dirInfo->getRealPath()); |
|
115 | - } |
|
116 | - } else { |
|
117 | - // input is not a valid directory |
|
118 | - $success = false; |
|
119 | - } |
|
120 | - return $success; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * |
|
125 | - * Recursively remove directory |
|
126 | - * |
|
127 | - * @todo currently won't remove directories with hidden files, should it? |
|
128 | - * |
|
129 | - * @param string $src directory to remove (delete) |
|
130 | - * |
|
131 | - * @return bool true on success |
|
132 | - */ |
|
133 | - public static function rrmdir($src) |
|
134 | - { |
|
135 | - // Only continue if user is a 'global' Admin |
|
136 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
137 | - return false; |
|
138 | - } |
|
139 | - |
|
140 | - // If source is not a directory stop processing |
|
141 | - if (!is_dir($src)) { |
|
142 | - return false; |
|
143 | - } |
|
144 | - |
|
145 | - $success = true; |
|
146 | - |
|
147 | - // Open the source directory to read in files |
|
148 | - $iterator = new \DirectoryIterator($src); |
|
149 | - foreach ($iterator as $fObj) { |
|
150 | - if ($fObj->isFile()) { |
|
151 | - $filename = $fObj->getPathname(); |
|
152 | - $fObj = null; // clear this iterator object to close the file |
|
153 | - if (!unlink($filename)) { |
|
154 | - return false; // couldn't delete the file |
|
155 | - } |
|
156 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
157 | - // Try recursively on directory |
|
158 | - self::rrmdir($fObj->getPathname()); |
|
159 | - } |
|
160 | - } |
|
161 | - $iterator = null; // clear iterator Obj to close file/directory |
|
162 | - return rmdir($src); // remove the directory & return results |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Recursively move files from one directory to another |
|
167 | - * |
|
168 | - * @param string $src - Source of files being moved |
|
169 | - * @param string $dest - Destination of files being moved |
|
170 | - * |
|
171 | - * @return bool true on success |
|
172 | - */ |
|
173 | - public static function rmove($src, $dest) |
|
174 | - { |
|
175 | - // Only continue if user is a 'global' Admin |
|
176 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
177 | - return false; |
|
178 | - } |
|
179 | - |
|
180 | - // If source is not a directory stop processing |
|
181 | - if (!is_dir($src)) { |
|
182 | - return false; |
|
183 | - } |
|
184 | - |
|
185 | - // If the destination directory does not exist and could not be created stop processing |
|
186 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
187 | - return false; |
|
188 | - } |
|
189 | - |
|
190 | - // Open the source directory to read in files |
|
191 | - $iterator = new \DirectoryIterator($src); |
|
192 | - foreach ($iterator as $fObj) { |
|
193 | - if ($fObj->isFile()) { |
|
194 | - rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
195 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
196 | - // Try recursively on directory |
|
197 | - self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
198 | - // rmdir($fObj->getPath()); // now delete the directory |
|
199 | - } |
|
200 | - } |
|
201 | - $iterator = null; // clear iterator Obj to close file/directory |
|
202 | - return rmdir($src); // remove the directory & return results |
|
203 | - } |
|
204 | - |
|
205 | - /** |
|
206 | - * Recursively copy directories and files from one directory to another |
|
207 | - * |
|
208 | - * @param string $src - Source of files being moved |
|
209 | - * @param string $dest - Destination of files being moved |
|
210 | - * |
|
211 | - * @uses \Xmf\Module\Helper::getHelper() |
|
212 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
213 | - * |
|
214 | - * @return bool true on success |
|
215 | - */ |
|
216 | - public static function rcopy($src, $dest) |
|
217 | - { |
|
218 | - // Only continue if user is a 'global' Admin |
|
219 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
220 | - return false; |
|
221 | - } |
|
222 | - |
|
223 | - // If source is not a directory stop processing |
|
224 | - if (!is_dir($src)) { |
|
225 | - return false; |
|
226 | - } |
|
227 | - |
|
228 | - // If the destination directory does not exist and could not be created stop processing |
|
229 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
230 | - return false; |
|
231 | - } |
|
232 | - |
|
233 | - // Open the source directory to read in files |
|
234 | - $iterator = new \DirectoryIterator($src); |
|
235 | - foreach ($iterator as $fObj) { |
|
236 | - if ($fObj->isFile()) { |
|
237 | - copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
238 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
239 | - self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
240 | - } |
|
241 | - } |
|
242 | - return true; |
|
243 | - } |
|
20 | + /** |
|
21 | + * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
22 | + * |
|
23 | + * @param string $folder The full path of the directory to check |
|
24 | + * |
|
25 | + * @return void |
|
26 | + * @throws \RuntimeException |
|
27 | + */ |
|
28 | + public static function createFolder($folder) |
|
29 | + { |
|
30 | + try { |
|
31 | + if (!file_exists($folder)) { |
|
32 | + if (!mkdir($folder) && !is_dir($folder)) { |
|
33 | + throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
34 | + } |
|
35 | + |
|
36 | + file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
37 | + } |
|
38 | + } |
|
39 | + catch (\Exception $e) { |
|
40 | + echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
41 | + } |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * @param $file |
|
46 | + * @param $folder |
|
47 | + * @return bool |
|
48 | + */ |
|
49 | + public static function copyFile($file, $folder) |
|
50 | + { |
|
51 | + return copy($file, $folder); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * @param $src |
|
56 | + * @param $dst |
|
57 | + */ |
|
58 | + public static function recurseCopy($src, $dst) |
|
59 | + { |
|
60 | + $dir = opendir($src); |
|
61 | + @mkdir($dst); |
|
62 | + while (false !== ($file = readdir($dir))) { |
|
63 | + if (('.' !== $file) && ('..' !== $file)) { |
|
64 | + if (is_dir($src . '/' . $file)) { |
|
65 | + self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
66 | + } else { |
|
67 | + copy($src . '/' . $file, $dst . '/' . $file); |
|
68 | + } |
|
69 | + } |
|
70 | + } |
|
71 | + closedir($dir); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * |
|
76 | + * Remove files and (sub)directories |
|
77 | + * |
|
78 | + * @param string $src source directory to delete |
|
79 | + * |
|
80 | + * @uses \Xmf\Module\Helper::getHelper() |
|
81 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
82 | + * |
|
83 | + * @return bool true on success |
|
84 | + */ |
|
85 | + public static function deleteDirectory($src) |
|
86 | + { |
|
87 | + // Only continue if user is a 'global' Admin |
|
88 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
89 | + return false; |
|
90 | + } |
|
91 | + |
|
92 | + $success = true; |
|
93 | + // remove old files |
|
94 | + $dirInfo = new \SplFileInfo($src); |
|
95 | + // validate is a directory |
|
96 | + if ($dirInfo->isDir()) { |
|
97 | + $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); |
|
98 | + foreach ($fileList as $k => $v) { |
|
99 | + $fileInfo = new \SplFileInfo("{$src}/{$v}"); |
|
100 | + if ($fileInfo->isDir()) { |
|
101 | + // recursively handle subdirectories |
|
102 | + if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
103 | + break; |
|
104 | + } |
|
105 | + } else { |
|
106 | + // delete the file |
|
107 | + if (!($success = unlink($fileInfo->getRealPath()))) { |
|
108 | + break; |
|
109 | + } |
|
110 | + } |
|
111 | + } |
|
112 | + // now delete this (sub)directory if all the files are gone |
|
113 | + if ($success) { |
|
114 | + $success = rmdir($dirInfo->getRealPath()); |
|
115 | + } |
|
116 | + } else { |
|
117 | + // input is not a valid directory |
|
118 | + $success = false; |
|
119 | + } |
|
120 | + return $success; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * |
|
125 | + * Recursively remove directory |
|
126 | + * |
|
127 | + * @todo currently won't remove directories with hidden files, should it? |
|
128 | + * |
|
129 | + * @param string $src directory to remove (delete) |
|
130 | + * |
|
131 | + * @return bool true on success |
|
132 | + */ |
|
133 | + public static function rrmdir($src) |
|
134 | + { |
|
135 | + // Only continue if user is a 'global' Admin |
|
136 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
137 | + return false; |
|
138 | + } |
|
139 | + |
|
140 | + // If source is not a directory stop processing |
|
141 | + if (!is_dir($src)) { |
|
142 | + return false; |
|
143 | + } |
|
144 | + |
|
145 | + $success = true; |
|
146 | + |
|
147 | + // Open the source directory to read in files |
|
148 | + $iterator = new \DirectoryIterator($src); |
|
149 | + foreach ($iterator as $fObj) { |
|
150 | + if ($fObj->isFile()) { |
|
151 | + $filename = $fObj->getPathname(); |
|
152 | + $fObj = null; // clear this iterator object to close the file |
|
153 | + if (!unlink($filename)) { |
|
154 | + return false; // couldn't delete the file |
|
155 | + } |
|
156 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
157 | + // Try recursively on directory |
|
158 | + self::rrmdir($fObj->getPathname()); |
|
159 | + } |
|
160 | + } |
|
161 | + $iterator = null; // clear iterator Obj to close file/directory |
|
162 | + return rmdir($src); // remove the directory & return results |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Recursively move files from one directory to another |
|
167 | + * |
|
168 | + * @param string $src - Source of files being moved |
|
169 | + * @param string $dest - Destination of files being moved |
|
170 | + * |
|
171 | + * @return bool true on success |
|
172 | + */ |
|
173 | + public static function rmove($src, $dest) |
|
174 | + { |
|
175 | + // Only continue if user is a 'global' Admin |
|
176 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
177 | + return false; |
|
178 | + } |
|
179 | + |
|
180 | + // If source is not a directory stop processing |
|
181 | + if (!is_dir($src)) { |
|
182 | + return false; |
|
183 | + } |
|
184 | + |
|
185 | + // If the destination directory does not exist and could not be created stop processing |
|
186 | + if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
187 | + return false; |
|
188 | + } |
|
189 | + |
|
190 | + // Open the source directory to read in files |
|
191 | + $iterator = new \DirectoryIterator($src); |
|
192 | + foreach ($iterator as $fObj) { |
|
193 | + if ($fObj->isFile()) { |
|
194 | + rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
195 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
196 | + // Try recursively on directory |
|
197 | + self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
198 | + // rmdir($fObj->getPath()); // now delete the directory |
|
199 | + } |
|
200 | + } |
|
201 | + $iterator = null; // clear iterator Obj to close file/directory |
|
202 | + return rmdir($src); // remove the directory & return results |
|
203 | + } |
|
204 | + |
|
205 | + /** |
|
206 | + * Recursively copy directories and files from one directory to another |
|
207 | + * |
|
208 | + * @param string $src - Source of files being moved |
|
209 | + * @param string $dest - Destination of files being moved |
|
210 | + * |
|
211 | + * @uses \Xmf\Module\Helper::getHelper() |
|
212 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
213 | + * |
|
214 | + * @return bool true on success |
|
215 | + */ |
|
216 | + public static function rcopy($src, $dest) |
|
217 | + { |
|
218 | + // Only continue if user is a 'global' Admin |
|
219 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
220 | + return false; |
|
221 | + } |
|
222 | + |
|
223 | + // If source is not a directory stop processing |
|
224 | + if (!is_dir($src)) { |
|
225 | + return false; |
|
226 | + } |
|
227 | + |
|
228 | + // If the destination directory does not exist and could not be created stop processing |
|
229 | + if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
230 | + return false; |
|
231 | + } |
|
232 | + |
|
233 | + // Open the source directory to read in files |
|
234 | + $iterator = new \DirectoryIterator($src); |
|
235 | + foreach ($iterator as $fObj) { |
|
236 | + if ($fObj->isFile()) { |
|
237 | + copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
238 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
239 | + self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
240 | + } |
|
241 | + } |
|
242 | + return true; |
|
243 | + } |
|
244 | 244 | } |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | public static function createFolder($folder) |
29 | 29 | { |
30 | 30 | try { |
31 | - if (!file_exists($folder)) { |
|
32 | - if (!mkdir($folder) && !is_dir($folder)) { |
|
31 | + if ( ! file_exists($folder)) { |
|
32 | + if ( ! mkdir($folder) && ! is_dir($folder)) { |
|
33 | 33 | throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
34 | 34 | } |
35 | 35 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public static function deleteDirectory($src) |
86 | 86 | { |
87 | 87 | // Only continue if user is a 'global' Admin |
88 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
88 | + if ( ! ($GLOBALS['xoopsUser'] instanceof XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) { |
|
89 | 89 | return false; |
90 | 90 | } |
91 | 91 | |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | $fileInfo = new \SplFileInfo("{$src}/{$v}"); |
100 | 100 | if ($fileInfo->isDir()) { |
101 | 101 | // recursively handle subdirectories |
102 | - if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
102 | + if ( ! $success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
103 | 103 | break; |
104 | 104 | } |
105 | 105 | } else { |
106 | 106 | // delete the file |
107 | - if (!($success = unlink($fileInfo->getRealPath()))) { |
|
107 | + if ( ! ($success = unlink($fileInfo->getRealPath()))) { |
|
108 | 108 | break; |
109 | 109 | } |
110 | 110 | } |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | public static function rrmdir($src) |
134 | 134 | { |
135 | 135 | // Only continue if user is a 'global' Admin |
136 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
136 | + if ( ! ($GLOBALS['xoopsUser'] instanceof XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) { |
|
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | |
140 | 140 | // If source is not a directory stop processing |
141 | - if (!is_dir($src)) { |
|
141 | + if ( ! is_dir($src)) { |
|
142 | 142 | return false; |
143 | 143 | } |
144 | 144 | |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | if ($fObj->isFile()) { |
151 | 151 | $filename = $fObj->getPathname(); |
152 | 152 | $fObj = null; // clear this iterator object to close the file |
153 | - if (!unlink($filename)) { |
|
153 | + if ( ! unlink($filename)) { |
|
154 | 154 | return false; // couldn't delete the file |
155 | 155 | } |
156 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
156 | + } elseif ( ! $fObj->isDot() && $fObj->isDir()) { |
|
157 | 157 | // Try recursively on directory |
158 | 158 | self::rrmdir($fObj->getPathname()); |
159 | 159 | } |
160 | 160 | } |
161 | - $iterator = null; // clear iterator Obj to close file/directory |
|
161 | + $iterator = null; // clear iterator Obj to close file/directory |
|
162 | 162 | return rmdir($src); // remove the directory & return results |
163 | 163 | } |
164 | 164 | |
@@ -173,17 +173,17 @@ discard block |
||
173 | 173 | public static function rmove($src, $dest) |
174 | 174 | { |
175 | 175 | // Only continue if user is a 'global' Admin |
176 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
176 | + if ( ! ($GLOBALS['xoopsUser'] instanceof XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) { |
|
177 | 177 | return false; |
178 | 178 | } |
179 | 179 | |
180 | 180 | // If source is not a directory stop processing |
181 | - if (!is_dir($src)) { |
|
181 | + if ( ! is_dir($src)) { |
|
182 | 182 | return false; |
183 | 183 | } |
184 | 184 | |
185 | 185 | // If the destination directory does not exist and could not be created stop processing |
186 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
186 | + if ( ! is_dir($dest) && ! mkdir($dest, 0755)) { |
|
187 | 187 | return false; |
188 | 188 | } |
189 | 189 | |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | foreach ($iterator as $fObj) { |
193 | 193 | if ($fObj->isFile()) { |
194 | 194 | rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
195 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
195 | + } elseif ( ! $fObj->isDot() && $fObj->isDir()) { |
|
196 | 196 | // Try recursively on directory |
197 | 197 | self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
198 | 198 | // rmdir($fObj->getPath()); // now delete the directory |
199 | 199 | } |
200 | 200 | } |
201 | - $iterator = null; // clear iterator Obj to close file/directory |
|
201 | + $iterator = null; // clear iterator Obj to close file/directory |
|
202 | 202 | return rmdir($src); // remove the directory & return results |
203 | 203 | } |
204 | 204 | |
@@ -216,17 +216,17 @@ discard block |
||
216 | 216 | public static function rcopy($src, $dest) |
217 | 217 | { |
218 | 218 | // Only continue if user is a 'global' Admin |
219 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
219 | + if ( ! ($GLOBALS['xoopsUser'] instanceof XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) { |
|
220 | 220 | return false; |
221 | 221 | } |
222 | 222 | |
223 | 223 | // If source is not a directory stop processing |
224 | - if (!is_dir($src)) { |
|
224 | + if ( ! is_dir($src)) { |
|
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
228 | 228 | // If the destination directory does not exist and could not be created stop processing |
229 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
229 | + if ( ! is_dir($dest) && ! mkdir($dest, 0755)) { |
|
230 | 230 | return false; |
231 | 231 | } |
232 | 232 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | foreach ($iterator as $fObj) { |
236 | 236 | if ($fObj->isFile()) { |
237 | 237 | copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
238 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
238 | + } elseif ( ! $fObj->isDot() && $fObj->isDir()) { |
|
239 | 239 | self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
240 | 240 | } |
241 | 241 | } |
@@ -35,8 +35,7 @@ |
||
35 | 35 | |
36 | 36 | file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
37 | 37 | } |
38 | - } |
|
39 | - catch (\Exception $e) { |
|
38 | + } catch (\Exception $e) { |
|
40 | 39 | echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
41 | 40 | } |
42 | 41 | } |
@@ -33,48 +33,48 @@ |
||
33 | 33 | */ |
34 | 34 | class Breadcrumb |
35 | 35 | { |
36 | - public $dirname; |
|
37 | - private $bread = []; |
|
36 | + public $dirname; |
|
37 | + private $bread = []; |
|
38 | 38 | |
39 | - /** |
|
40 | - * |
|
41 | - */ |
|
42 | - public function __construct() |
|
43 | - { |
|
44 | - $this->dirname = basename(dirname(__DIR__)); |
|
45 | - } |
|
39 | + /** |
|
40 | + * |
|
41 | + */ |
|
42 | + public function __construct() |
|
43 | + { |
|
44 | + $this->dirname = basename(dirname(__DIR__)); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Add link to breadcrumb |
|
49 | - * |
|
50 | - * @param string $title |
|
51 | - * @param string $link |
|
52 | - */ |
|
53 | - public function addLink($title = '', $link = '') |
|
54 | - { |
|
55 | - $this->bread[] = [ |
|
56 | - 'link' => $link, |
|
57 | - 'title' => $title |
|
58 | - ]; |
|
59 | - } |
|
47 | + /** |
|
48 | + * Add link to breadcrumb |
|
49 | + * |
|
50 | + * @param string $title |
|
51 | + * @param string $link |
|
52 | + */ |
|
53 | + public function addLink($title = '', $link = '') |
|
54 | + { |
|
55 | + $this->bread[] = [ |
|
56 | + 'link' => $link, |
|
57 | + 'title' => $title |
|
58 | + ]; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Render Pedigree BreadCrumb |
|
63 | - * |
|
64 | - */ |
|
65 | - public function render() |
|
66 | - { |
|
67 | - if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
68 | - require_once $GLOBALS['xoops']->path('class/theme.php'); |
|
69 | - $GLOBALS['xoTheme'] = new xos_opal_Theme(); |
|
70 | - } |
|
61 | + /** |
|
62 | + * Render Pedigree BreadCrumb |
|
63 | + * |
|
64 | + */ |
|
65 | + public function render() |
|
66 | + { |
|
67 | + if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
68 | + require_once $GLOBALS['xoops']->path('class/theme.php'); |
|
69 | + $GLOBALS['xoTheme'] = new xos_opal_Theme(); |
|
70 | + } |
|
71 | 71 | |
72 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
73 | - $breadcrumbTpl = new \XoopsTpl(); |
|
74 | - $breadcrumbTpl->assign('breadcrumb', $this->bread); |
|
75 | - $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
|
76 | - unset($breadcrumbTpl); |
|
72 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
73 | + $breadcrumbTpl = new \XoopsTpl(); |
|
74 | + $breadcrumbTpl->assign('breadcrumb', $this->bread); |
|
75 | + $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
|
76 | + unset($breadcrumbTpl); |
|
77 | 77 | |
78 | - return $html; |
|
79 | - } |
|
78 | + return $html; |
|
79 | + } |
|
80 | 80 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | */ |
64 | 64 | public function render() |
65 | 65 | { |
66 | - if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
66 | + if ( ! isset($GLOBALS['xoTheme']) || ! is_object($GLOBALS['xoTheme'])) { |
|
67 | 67 | require_once $GLOBALS['xoops']->path('class/theme.php'); |
68 | 68 | $GLOBALS['xoTheme'] = new xos_opal_Theme(); |
69 | 69 | } |
@@ -24,38 +24,38 @@ |
||
24 | 24 | */ |
25 | 25 | class Helper extends \Xmf\Module\Helper |
26 | 26 | { |
27 | - public $debug; |
|
27 | + public $debug; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @internal param $debug |
|
31 | - * @param bool $debug |
|
32 | - */ |
|
33 | - protected function __construct($debug = false) |
|
34 | - { |
|
35 | - $this->debug = $debug; |
|
36 | - $this->dirname = basename(dirname(__DIR__)); |
|
37 | - } |
|
29 | + /** |
|
30 | + * @internal param $debug |
|
31 | + * @param bool $debug |
|
32 | + */ |
|
33 | + protected function __construct($debug = false) |
|
34 | + { |
|
35 | + $this->debug = $debug; |
|
36 | + $this->dirname = basename(dirname(__DIR__)); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param bool $debug |
|
41 | - * |
|
42 | - * @return \Xoopsmodules\instruction\Helper |
|
43 | - */ |
|
44 | - public static function getInstance($debug = false) |
|
45 | - { |
|
46 | - static $instance; |
|
47 | - if (null === $instance) { |
|
48 | - $instance = new static($debug); |
|
49 | - } |
|
39 | + /** |
|
40 | + * @param bool $debug |
|
41 | + * |
|
42 | + * @return \Xoopsmodules\instruction\Helper |
|
43 | + */ |
|
44 | + public static function getInstance($debug = false) |
|
45 | + { |
|
46 | + static $instance; |
|
47 | + if (null === $instance) { |
|
48 | + $instance = new static($debug); |
|
49 | + } |
|
50 | 50 | |
51 | - return $instance; |
|
52 | - } |
|
51 | + return $instance; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - public function getDirname() |
|
58 | - { |
|
59 | - return $this->dirname; |
|
60 | - } |
|
54 | + /** |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + public function getDirname() |
|
58 | + { |
|
59 | + return $this->dirname; |
|
60 | + } |
|
61 | 61 | } |
@@ -12,60 +12,60 @@ |
||
12 | 12 | */ |
13 | 13 | class PageHandler extends \XoopsPersistableObjectHandler |
14 | 14 | { |
15 | - /** |
|
16 | - * @param null|mixed $db |
|
17 | - */ |
|
18 | - public function __construct(\XoopsDatabase $db = null) |
|
19 | - { |
|
20 | - parent::__construct($db, 'instruction_page', Page::class, 'pageid', 'title'); |
|
21 | - } |
|
15 | + /** |
|
16 | + * @param null|mixed $db |
|
17 | + */ |
|
18 | + public function __construct(\XoopsDatabase $db = null) |
|
19 | + { |
|
20 | + parent::__construct($db, 'instruction_page', Page::class, 'pageid', 'title'); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Generate function for update user post |
|
25 | - * |
|
26 | - * @ Update user post count after send approve content |
|
27 | - * @ Update user post count after change status content |
|
28 | - * @ Update user post count after delete content |
|
29 | - * @param $uid |
|
30 | - * @param $status |
|
31 | - * @param $action |
|
32 | - */ |
|
33 | - public function updateposts($uid, $status, $action) |
|
34 | - { |
|
35 | - // |
|
36 | - switch ($action) { |
|
37 | - // Добавление страницы |
|
38 | - case 'add': |
|
39 | - if ($uid && $status) { |
|
40 | - $user = new \XoopsUser($uid); |
|
41 | - $memberHandler = xoops_getHandler('member'); |
|
42 | - // Добавялем +1 к комментам |
|
43 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
44 | - } |
|
45 | - break; |
|
46 | - // Удаление страницы |
|
47 | - case 'delete': |
|
48 | - if ($uid && $status) { |
|
49 | - $user = new \XoopsUser($uid); |
|
50 | - $memberHandler = xoops_getHandler('member'); |
|
51 | - // Декримент комментов |
|
52 | - //$user->setVar( 'posts', $user->getVar( 'posts' ) - 1 ); |
|
53 | - // Сохраняем |
|
54 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
55 | - } |
|
56 | - break; |
|
23 | + /** |
|
24 | + * Generate function for update user post |
|
25 | + * |
|
26 | + * @ Update user post count after send approve content |
|
27 | + * @ Update user post count after change status content |
|
28 | + * @ Update user post count after delete content |
|
29 | + * @param $uid |
|
30 | + * @param $status |
|
31 | + * @param $action |
|
32 | + */ |
|
33 | + public function updateposts($uid, $status, $action) |
|
34 | + { |
|
35 | + // |
|
36 | + switch ($action) { |
|
37 | + // Добавление страницы |
|
38 | + case 'add': |
|
39 | + if ($uid && $status) { |
|
40 | + $user = new \XoopsUser($uid); |
|
41 | + $memberHandler = xoops_getHandler('member'); |
|
42 | + // Добавялем +1 к комментам |
|
43 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
44 | + } |
|
45 | + break; |
|
46 | + // Удаление страницы |
|
47 | + case 'delete': |
|
48 | + if ($uid && $status) { |
|
49 | + $user = new \XoopsUser($uid); |
|
50 | + $memberHandler = xoops_getHandler('member'); |
|
51 | + // Декримент комментов |
|
52 | + //$user->setVar( 'posts', $user->getVar( 'posts' ) - 1 ); |
|
53 | + // Сохраняем |
|
54 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
55 | + } |
|
56 | + break; |
|
57 | 57 | |
58 | - case 'status': |
|
59 | - if ($uid) { |
|
60 | - $user = new \XoopsUser($uid); |
|
61 | - $memberHandler = xoops_getHandler('member'); |
|
62 | - if ($status) { |
|
63 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
64 | - } else { |
|
65 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
66 | - } |
|
67 | - } |
|
68 | - break; |
|
69 | - } |
|
70 | - } |
|
58 | + case 'status': |
|
59 | + if ($uid) { |
|
60 | + $user = new \XoopsUser($uid); |
|
61 | + $memberHandler = xoops_getHandler('member'); |
|
62 | + if ($status) { |
|
63 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
64 | + } else { |
|
65 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
66 | + } |
|
67 | + } |
|
68 | + break; |
|
69 | + } |
|
70 | + } |
|
71 | 71 | } |