@@ -5,12 +5,12 @@ |
||
| 5 | 5 | // Функция вызывается при добавлении комментария |
| 6 | 6 | function instruction_com_update($pageid, $total_num) |
| 7 | 7 | { |
| 8 | - $db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 9 | - $sql = 'UPDATE ' . $db->prefix('instruction_page') . ' SET comments = ' . $total_num . ' WHERE pageid = ' . $pageid; |
|
| 10 | - $db->query($sql); |
|
| 8 | + $db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 9 | + $sql = 'UPDATE ' . $db->prefix('instruction_page') . ' SET comments = ' . $total_num . ' WHERE pageid = ' . $pageid; |
|
| 10 | + $db->query($sql); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | function instruction_com_approve(&$comment) |
| 14 | 14 | { |
| 15 | - // notification mail here |
|
| 15 | + // notification mail here |
|
| 16 | 16 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // Типы страницы |
| 3 | 3 | return [ |
| 4 | - 0 => _AM_INSTR_PT_0, |
|
| 5 | - 1 => _AM_INSTR_PT_1 |
|
| 4 | + 0 => _AM_INSTR_PT_0, |
|
| 5 | + 1 => _AM_INSTR_PT_1 |
|
| 6 | 6 | ]; |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('INSTRUCTION_MODULE_PATH')) { |
| 21 | - define('INSTRUCTION_DIRNAME', basename(dirname(__DIR__))); |
|
| 22 | - define('INSTRUCTION_URL', XOOPS_URL . '/modules/' . INSTRUCTION_DIRNAME); |
|
| 23 | - define('INSTRUCTION_IMAGE_URL', INSTRUCTION_URL . '/assets/images/'); |
|
| 24 | - define('INSTRUCTION_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . INSTRUCTION_DIRNAME); |
|
| 25 | - define('INSTRUCTION_IMAGE_PATH', INSTRUCTION_ROOT_PATH . '/assets/images'); |
|
| 26 | - define('INSTRUCTION_ADMIN_URL', INSTRUCTION_URL . '/admin/'); |
|
| 27 | - define('INSTRUCTION_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . INSTRUCTION_DIRNAME); |
|
| 28 | - define('INSTRUCTION_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . INSTRUCTION_DIRNAME); |
|
| 21 | + define('INSTRUCTION_DIRNAME', basename(dirname(__DIR__))); |
|
| 22 | + define('INSTRUCTION_URL', XOOPS_URL . '/modules/' . INSTRUCTION_DIRNAME); |
|
| 23 | + define('INSTRUCTION_IMAGE_URL', INSTRUCTION_URL . '/assets/images/'); |
|
| 24 | + define('INSTRUCTION_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . INSTRUCTION_DIRNAME); |
|
| 25 | + define('INSTRUCTION_IMAGE_PATH', INSTRUCTION_ROOT_PATH . '/assets/images'); |
|
| 26 | + define('INSTRUCTION_ADMIN_URL', INSTRUCTION_URL . '/admin/'); |
|
| 27 | + define('INSTRUCTION_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . INSTRUCTION_DIRNAME); |
|
| 28 | + define('INSTRUCTION_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . INSTRUCTION_DIRNAME); |
|
| 29 | 29 | } |
| 30 | 30 | xoops_loadLanguage('common', INSTRUCTION_DIRNAME); |
| 31 | 31 | |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | $instruction->loadLanguage('common'); |
| 47 | 47 | |
| 48 | 48 | if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) { |
| 49 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 50 | - $xoopsTpl = new XoopsTpl(); |
|
| 49 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 50 | + $xoopsTpl = new XoopsTpl(); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $moduleDirName = basename(dirname(__DIR__)); |
@@ -3,66 +3,66 @@ |
||
| 3 | 3 | // Информация об теге |
| 4 | 4 | function instruction_tag_iteminfo(&$items) |
| 5 | 5 | { |
| 6 | - if (empty($items) || !is_array($items)) { |
|
| 7 | - return false; |
|
| 8 | - } |
|
| 6 | + if (empty($items) || !is_array($items)) { |
|
| 7 | + return false; |
|
| 8 | + } |
|
| 9 | 9 | |
| 10 | - $items_id = []; |
|
| 11 | - foreach (array_keys($items) as $cat_id) { |
|
| 12 | - foreach (array_keys($items[$cat_id]) as $item_id) { |
|
| 13 | - $items_id[] = (int)$item_id; |
|
| 14 | - } |
|
| 15 | - } |
|
| 10 | + $items_id = []; |
|
| 11 | + foreach (array_keys($items) as $cat_id) { |
|
| 12 | + foreach (array_keys($items[$cat_id]) as $item_id) { |
|
| 13 | + $items_id[] = (int)$item_id; |
|
| 14 | + } |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - $itemHandler = xoops_getModuleHandler('instruction', 'instruction'); |
|
| 18 | - $items_obj = $itemHandler->getObjects(new Criteria('instrid', '(' . implode(', ', $items_id) . ')', 'IN'), true); |
|
| 17 | + $itemHandler = xoops_getModuleHandler('instruction', 'instruction'); |
|
| 18 | + $items_obj = $itemHandler->getObjects(new Criteria('instrid', '(' . implode(', ', $items_id) . ')', 'IN'), true); |
|
| 19 | 19 | |
| 20 | - foreach (array_keys($items) as $cat_id) { |
|
| 21 | - foreach (array_keys($items[$cat_id]) as $item_id) { |
|
| 22 | - if (isset($items_obj[$item_id])) { |
|
| 23 | - $item_obj = $items_obj[$item_id]; |
|
| 24 | - $items[$cat_id][$item_id] = [ |
|
| 25 | - 'title' => $item_obj->getVar('title'), |
|
| 26 | - 'uid' => $item_obj->getVar('uid'), |
|
| 27 | - 'link' => "instr.php?id={$item_id}", |
|
| 28 | - 'time' => $item_obj->getVar('datecreated'), |
|
| 29 | - 'tags' => '', |
|
| 30 | - 'content' => '', |
|
| 31 | - ]; |
|
| 32 | - } |
|
| 33 | - } |
|
| 34 | - } |
|
| 35 | - unset($items_obj); |
|
| 20 | + foreach (array_keys($items) as $cat_id) { |
|
| 21 | + foreach (array_keys($items[$cat_id]) as $item_id) { |
|
| 22 | + if (isset($items_obj[$item_id])) { |
|
| 23 | + $item_obj = $items_obj[$item_id]; |
|
| 24 | + $items[$cat_id][$item_id] = [ |
|
| 25 | + 'title' => $item_obj->getVar('title'), |
|
| 26 | + 'uid' => $item_obj->getVar('uid'), |
|
| 27 | + 'link' => "instr.php?id={$item_id}", |
|
| 28 | + 'time' => $item_obj->getVar('datecreated'), |
|
| 29 | + 'tags' => '', |
|
| 30 | + 'content' => '', |
|
| 31 | + ]; |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | + unset($items_obj); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | // Синхронизация тегов |
| 39 | 39 | function instruction_tag_synchronization($mid) |
| 40 | 40 | { |
| 41 | - $itemHandler = xoops_getModuleHandler('instruction', 'instruction'); |
|
| 42 | - $linkHandler = xoops_getModuleHandler('link', 'tag'); |
|
| 41 | + $itemHandler = xoops_getModuleHandler('instruction', 'instruction'); |
|
| 42 | + $linkHandler = xoops_getModuleHandler('link', 'tag'); |
|
| 43 | 43 | |
| 44 | - /* clear tag-item links */ |
|
| 45 | - if (version_compare(mysqli_get_server_info(), '4.1.0', 'ge')): |
|
| 46 | - $sql = " DELETE FROM {$linkHandler->table}" |
|
| 47 | - . ' WHERE ' |
|
| 48 | - . " tag_modid = {$mid}" |
|
| 49 | - . ' AND ' |
|
| 50 | - . ' ( tag_itemid NOT IN ' |
|
| 51 | - . " ( SELECT DISTINCT {$itemHandler->keyName} " |
|
| 52 | - . " FROM {$itemHandler->table} " |
|
| 53 | - . " WHERE {$itemHandler->table}.status > 0" |
|
| 54 | - . ' ) ' |
|
| 55 | - . ' )'; else: |
|
| 56 | - $sql = " DELETE {$linkHandler->table} FROM {$linkHandler->table}" |
|
| 57 | - . " LEFT JOIN {$itemHandler->table} AS aa ON {$linkHandler->table}.tag_itemid = aa.{$itemHandler->keyName} " |
|
| 58 | - . ' WHERE ' |
|
| 59 | - . " tag_modid = {$mid}" |
|
| 60 | - . ' AND ' |
|
| 61 | - . " ( aa.{$itemHandler->keyName} IS NULL" |
|
| 62 | - . ' OR aa.status < 1' |
|
| 63 | - . ' )'; |
|
| 64 | - endif; |
|
| 65 | - if (!$result = $linkHandler->db->queryF($sql)) { |
|
| 66 | - //xoops_error($linkHandler->db->error()); |
|
| 67 | - } |
|
| 44 | + /* clear tag-item links */ |
|
| 45 | + if (version_compare(mysqli_get_server_info(), '4.1.0', 'ge')): |
|
| 46 | + $sql = " DELETE FROM {$linkHandler->table}" |
|
| 47 | + . ' WHERE ' |
|
| 48 | + . " tag_modid = {$mid}" |
|
| 49 | + . ' AND ' |
|
| 50 | + . ' ( tag_itemid NOT IN ' |
|
| 51 | + . " ( SELECT DISTINCT {$itemHandler->keyName} " |
|
| 52 | + . " FROM {$itemHandler->table} " |
|
| 53 | + . " WHERE {$itemHandler->table}.status > 0" |
|
| 54 | + . ' ) ' |
|
| 55 | + . ' )'; else: |
|
| 56 | + $sql = " DELETE {$linkHandler->table} FROM {$linkHandler->table}" |
|
| 57 | + . " LEFT JOIN {$itemHandler->table} AS aa ON {$linkHandler->table}.tag_itemid = aa.{$itemHandler->keyName} " |
|
| 58 | + . ' WHERE ' |
|
| 59 | + . " tag_modid = {$mid}" |
|
| 60 | + . ' AND ' |
|
| 61 | + . " ( aa.{$itemHandler->keyName} IS NULL" |
|
| 62 | + . ' OR aa.status < 1' |
|
| 63 | + . ' )'; |
|
| 64 | + endif; |
|
| 65 | + if (!$result = $linkHandler->db->queryF($sql)) { |
|
| 66 | + //xoops_error($linkHandler->db->error()); |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | $criteria->add(new Criteria('pageid ', $pageid)); |
| 29 | 29 | $criteria->add(new Criteria('status ', '0', '>')); |
| 30 | 30 | if (0 == $inspageHandler->getCount($criteria)) { |
| 31 | - redirect_header('index.php', 3, _MD_INSTRUCTION_PAGENOTEXIST); |
|
| 32 | - exit(); |
|
| 31 | + redirect_header('index.php', 3, _MD_INSTRUCTION_PAGENOTEXIST); |
|
| 32 | + exit(); |
|
| 33 | 33 | } |
| 34 | 34 | // |
| 35 | 35 | unset($criteria); |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | // Если админ и ссылка на отключение кэша |
| 43 | 43 | if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin() && $nocache) { |
| 44 | - // Отключаем кэш |
|
| 45 | - $GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0; |
|
| 44 | + // Отключаем кэш |
|
| 45 | + $GLOBALS['xoopsConfig']['module_cache'][$GLOBALS['xoopsModule']->getVar('mid')] = 0; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // Задание тайтла |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | // Права на просмотр инструкции |
| 60 | 60 | $categories = InstructionUtility::getItemIds(); |
| 61 | 61 | if (!in_array($objInsinstr->getVar('cid'), $categories)) { |
| 62 | - redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM); |
|
| 63 | - exit(); |
|
| 62 | + redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/', 3, _NOPERM); |
|
| 63 | + exit(); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | // Массив данных о странице |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | $footnote = $objInspage->getVar('footnote'); |
| 78 | 78 | // Если есть сноски |
| 79 | 79 | if ($footnote) { |
| 80 | - $pages['footnotes'] = explode('|', $objInspage->getVar('footnote')); |
|
| 80 | + $pages['footnotes'] = explode('|', $objInspage->getVar('footnote')); |
|
| 81 | 81 | } else { |
| 82 | - $pages['footnotes'] = false; |
|
| 82 | + $pages['footnotes'] = false; |
|
| 83 | 83 | } |
| 84 | 84 | // Мета-теги ключевых слов |
| 85 | 85 | $pages['keywords'] = $objInspage->getVar('keywords'); |
@@ -88,39 +88,39 @@ discard block |
||
| 88 | 88 | // |
| 89 | 89 | // Если админ, рисуем админлинк |
| 90 | 90 | if (is_object($GLOBALS['xoopsUser']) && $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid())) { |
| 91 | - $pages['adminlink'] = ' <a href="' |
|
| 92 | - . XOOPS_URL |
|
| 93 | - . '/modules/' |
|
| 94 | - . $moduleDirName |
|
| 95 | - . '/admin/instr.php?op=editpage&pageid=' |
|
| 96 | - . $pages['pageid'] |
|
| 97 | - . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' |
|
| 98 | - . _EDIT |
|
| 99 | - . ' title=' |
|
| 100 | - . _EDIT |
|
| 101 | - . '></a> <a href="' |
|
| 102 | - . XOOPS_URL |
|
| 103 | - . '/modules/' |
|
| 104 | - . $moduleDirName |
|
| 105 | - . '/admin/instr.php?op=delpage&pageid=' |
|
| 106 | - . $pages['pageid'] |
|
| 107 | - . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt=' |
|
| 108 | - . _DELETE |
|
| 109 | - . ' title=' |
|
| 110 | - . _DELETE |
|
| 111 | - . '></a> '; |
|
| 91 | + $pages['adminlink'] = ' <a href="' |
|
| 92 | + . XOOPS_URL |
|
| 93 | + . '/modules/' |
|
| 94 | + . $moduleDirName |
|
| 95 | + . '/admin/instr.php?op=editpage&pageid=' |
|
| 96 | + . $pages['pageid'] |
|
| 97 | + . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' |
|
| 98 | + . _EDIT |
|
| 99 | + . ' title=' |
|
| 100 | + . _EDIT |
|
| 101 | + . '></a> <a href="' |
|
| 102 | + . XOOPS_URL |
|
| 103 | + . '/modules/' |
|
| 104 | + . $moduleDirName |
|
| 105 | + . '/admin/instr.php?op=delpage&pageid=' |
|
| 106 | + . $pages['pageid'] |
|
| 107 | + . '"><img style="width:16px;" src="./assets/icons/delete_mini.png" alt=' |
|
| 108 | + . _DELETE |
|
| 109 | + . ' title=' |
|
| 110 | + . _DELETE |
|
| 111 | + . '></a> '; |
|
| 112 | 112 | } else { |
| 113 | - $pages['adminlink'] = ' '; |
|
| 114 | - // Если можно редактировать |
|
| 115 | - if ($gpermHandler->checkRight($moduleDirName . '_edit', $objInsinstr->getVar('cid'), $groups, $GLOBALS['xoopsModule']->getVar('mid'))) { |
|
| 116 | - $pages['adminlink'] .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/submit.php?op=editpage&pageid=' . $pages['pageid'] . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' . _EDIT . ' title=' . _EDIT . '></a>'; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - $pages['adminlink'] .= ' '; |
|
| 120 | - // Если нет админлика |
|
| 121 | - if ('[ ]' == $pages['adminlink']) { |
|
| 122 | - $pages['adminlink'] = ''; |
|
| 123 | - } |
|
| 113 | + $pages['adminlink'] = ' '; |
|
| 114 | + // Если можно редактировать |
|
| 115 | + if ($gpermHandler->checkRight($moduleDirName . '_edit', $objInsinstr->getVar('cid'), $groups, $GLOBALS['xoopsModule']->getVar('mid'))) { |
|
| 116 | + $pages['adminlink'] .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/submit.php?op=editpage&pageid=' . $pages['pageid'] . '"><img style="width:16px;" src="./assets/icons/edit_mini.png" alt=' . _EDIT . ' title=' . _EDIT . '></a>'; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + $pages['adminlink'] .= ' '; |
|
| 120 | + // Если нет админлика |
|
| 121 | + if ('[ ]' == $pages['adminlink']) { |
|
| 122 | + $pages['adminlink'] = ''; |
|
| 123 | + } |
|
| 124 | 124 | } |
| 125 | 125 | // Выводим в шаблон |
| 126 | 126 | $GLOBALS['xoopsTpl']->assign('insPage', $pages); |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $nav_parent_id = array_reverse($nav_parent_id); |
| 140 | 140 | $navigation = '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/">' . $GLOBALS['xoopsModule']->name() . '</a> : '; |
| 141 | 141 | foreach (array_keys($nav_parent_id) as $i) { |
| 142 | - $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $nav_parent_id[$i]->getVar('cid') . '">' . $nav_parent_id[$i]->getVar('title') . '</a> : '; |
|
| 142 | + $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $nav_parent_id[$i]->getVar('cid') . '">' . $nav_parent_id[$i]->getVar('title') . '</a> : '; |
|
| 143 | 143 | } |
| 144 | 144 | $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/index.php?cid=' . $objInscat->getVar('cid') . '">' . $objInscat->getVar('title') . '</a> : '; |
| 145 | 145 | $navigation .= '<a href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/instr.php?id=' . $pages['instrid'] . '">' . $objInsinstr->getVar('title') . '</a>'; |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | // Рейтинг |
| 173 | 173 | if (xoops_getModuleOption('userat', 'instruction')) { |
| 174 | - $xoopsTpl->assign('insUserat', true); |
|
| 174 | + $xoopsTpl->assign('insUserat', true); |
|
| 175 | 175 | } else { |
| 176 | - $xoopsTpl->assign('insUserat', false); |
|
| 176 | + $xoopsTpl->assign('insUserat', false); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | // Мета теги |
@@ -16,60 +16,60 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | trait ServerStats |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * serverStats() |
|
| 21 | - * |
|
| 22 | - * @return string |
|
| 23 | - */ |
|
| 24 | - public static function getServerStats() |
|
| 25 | - { |
|
| 26 | - //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); |
|
| 27 | - $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
| 28 | - $moduleDirNameUpper = strtoupper($moduleDirName); |
|
| 29 | - xoops_loadLanguage('common', $moduleDirName); |
|
| 30 | - $html = ''; |
|
| 31 | - // $sql = 'SELECT metavalue'; |
|
| 32 | - // $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta'); |
|
| 33 | - // $sql .= " WHERE metakey='version' LIMIT 1"; |
|
| 34 | - // $query = $GLOBALS['xoopsDB']->query($sql); |
|
| 35 | - // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); |
|
| 36 | - $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n"; |
|
| 37 | - $html .= "<div style='padding: 8px;'>\n"; |
|
| 38 | - // $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n"; |
|
| 39 | - // $html .= "<br>\n"; |
|
| 40 | - // $html .= "<br>\n"; |
|
| 41 | - $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n"; |
|
| 42 | - $html .= "<ul>\n"; |
|
| 43 | - // |
|
| 44 | - $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
|
| 45 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
| 46 | - if (function_exists('gd_info')) { |
|
| 47 | - if ($gdlib = true === gd_info()) { |
|
| 48 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - // |
|
| 52 | - // $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF'); |
|
| 53 | - // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode; |
|
| 54 | - // |
|
| 55 | - // $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>'; |
|
| 56 | - // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
|
| 57 | - // |
|
| 58 | - $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
|
| 59 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
| 60 | - // |
|
| 61 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n"; |
|
| 62 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n"; |
|
| 63 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . "</span></b>\n"; |
|
| 64 | - $html .= "</ul>\n"; |
|
| 65 | - $html .= "<ul>\n"; |
|
| 66 | - $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n"; |
|
| 67 | - $html .= "</ul>\n"; |
|
| 68 | - $html .= "<br>\n"; |
|
| 69 | - $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; |
|
| 70 | - $html .= '</div>'; |
|
| 71 | - $html .= '</fieldset><br>'; |
|
| 19 | + /** |
|
| 20 | + * serverStats() |
|
| 21 | + * |
|
| 22 | + * @return string |
|
| 23 | + */ |
|
| 24 | + public static function getServerStats() |
|
| 25 | + { |
|
| 26 | + //mb $wfdownloads = WfdownloadsWfdownloads::getInstance(); |
|
| 27 | + $moduleDirName = basename(dirname(dirname(__DIR__))); |
|
| 28 | + $moduleDirNameUpper = strtoupper($moduleDirName); |
|
| 29 | + xoops_loadLanguage('common', $moduleDirName); |
|
| 30 | + $html = ''; |
|
| 31 | + // $sql = 'SELECT metavalue'; |
|
| 32 | + // $sql .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta'); |
|
| 33 | + // $sql .= " WHERE metakey='version' LIMIT 1"; |
|
| 34 | + // $query = $GLOBALS['xoopsDB']->query($sql); |
|
| 35 | + // list($meta) = $GLOBALS['xoopsDB']->fetchRow($query); |
|
| 36 | + $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n"; |
|
| 37 | + $html .= "<div style='padding: 8px;'>\n"; |
|
| 38 | + // $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n"; |
|
| 39 | + // $html .= "<br>\n"; |
|
| 40 | + // $html .= "<br>\n"; |
|
| 41 | + $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n"; |
|
| 42 | + $html .= "<ul>\n"; |
|
| 43 | + // |
|
| 44 | + $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>'; |
|
| 45 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib; |
|
| 46 | + if (function_exists('gd_info')) { |
|
| 47 | + if ($gdlib = true === gd_info()) { |
|
| 48 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>'; |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + // |
|
| 52 | + // $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF'); |
|
| 53 | + // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode; |
|
| 54 | + // |
|
| 55 | + // $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>'; |
|
| 56 | + // $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals; |
|
| 57 | + // |
|
| 58 | + $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>'; |
|
| 59 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads; |
|
| 60 | + // |
|
| 61 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n"; |
|
| 62 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n"; |
|
| 63 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . "</span></b>\n"; |
|
| 64 | + $html .= "</ul>\n"; |
|
| 65 | + $html .= "<ul>\n"; |
|
| 66 | + $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n"; |
|
| 67 | + $html .= "</ul>\n"; |
|
| 68 | + $html .= "<br>\n"; |
|
| 69 | + $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n"; |
|
| 70 | + $html .= '</div>'; |
|
| 71 | + $html .= '</fieldset><br>'; |
|
| 72 | 72 | |
| 73 | - return $html; |
|
| 74 | - } |
|
| 73 | + return $html; |
|
| 74 | + } |
|
| 75 | 75 | } |
@@ -16,226 +16,226 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | trait FilesManagement |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
| 21 | - * |
|
| 22 | - * @param string $folder The full path of the directory to check |
|
| 23 | - * |
|
| 24 | - * @return void |
|
| 25 | - */ |
|
| 26 | - public static function createFolder($folder) |
|
| 27 | - { |
|
| 28 | - try { |
|
| 29 | - if (!file_exists($folder)) { |
|
| 30 | - if (!mkdir($folder) && !is_dir($folder)) { |
|
| 31 | - throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
| 35 | - } |
|
| 36 | - } catch (Exception $e) { |
|
| 37 | - echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @param $file |
|
| 43 | - * @param $folder |
|
| 44 | - * @return bool |
|
| 45 | - */ |
|
| 46 | - public static function copyFile($file, $folder) |
|
| 47 | - { |
|
| 48 | - return copy($file, $folder); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @param $src |
|
| 53 | - * @param $dst |
|
| 54 | - */ |
|
| 55 | - public static function recurseCopy($src, $dst) |
|
| 56 | - { |
|
| 57 | - $dir = opendir($src); |
|
| 58 | - @mkdir($dst); |
|
| 59 | - while (false !== ($file = readdir($dir))) { |
|
| 60 | - if (('.' !== $file) && ('..' !== $file)) { |
|
| 61 | - if (is_dir($src . '/' . $file)) { |
|
| 62 | - self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
| 63 | - } else { |
|
| 64 | - copy($src . '/' . $file, $dst . '/' . $file); |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - closedir($dir); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * |
|
| 73 | - * Remove files and (sub)directories |
|
| 74 | - * |
|
| 75 | - * @param string $src source directory to delete |
|
| 76 | - * |
|
| 77 | - * @uses \Xmf\Module\Helper::getHelper() |
|
| 78 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
| 79 | - * |
|
| 80 | - * @return bool true on success |
|
| 81 | - */ |
|
| 82 | - public static function deleteDirectory($src) |
|
| 83 | - { |
|
| 84 | - // Only continue if user is a 'global' Admin |
|
| 85 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 86 | - return false; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - $success = true; |
|
| 90 | - // remove old files |
|
| 91 | - $dirInfo = new SplFileInfo($src); |
|
| 92 | - // validate is a directory |
|
| 93 | - if ($dirInfo->isDir()) { |
|
| 94 | - $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); |
|
| 95 | - foreach ($fileList as $k => $v) { |
|
| 96 | - $fileInfo = new SplFileInfo("{$src}/{$v}"); |
|
| 97 | - if ($fileInfo->isDir()) { |
|
| 98 | - // recursively handle subdirectories |
|
| 99 | - if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
| 100 | - break; |
|
| 101 | - } |
|
| 102 | - } else { |
|
| 103 | - // delete the file |
|
| 104 | - if (!($success = unlink($fileInfo->getRealPath()))) { |
|
| 105 | - break; |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - // now delete this (sub)directory if all the files are gone |
|
| 110 | - if ($success) { |
|
| 111 | - $success = rmdir($dirInfo->getRealPath()); |
|
| 112 | - } |
|
| 113 | - } else { |
|
| 114 | - // input is not a valid directory |
|
| 115 | - $success = false; |
|
| 116 | - } |
|
| 117 | - return $success; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * |
|
| 122 | - * Recursively remove directory |
|
| 123 | - * |
|
| 124 | - * @todo currently won't remove directories with hidden files, should it? |
|
| 125 | - * |
|
| 126 | - * @param string $src directory to remove (delete) |
|
| 127 | - * |
|
| 128 | - * @return bool true on success |
|
| 129 | - */ |
|
| 130 | - public static function rrmdir($src) |
|
| 131 | - { |
|
| 132 | - // Only continue if user is a 'global' Admin |
|
| 133 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 134 | - return false; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // If source is not a directory stop processing |
|
| 138 | - if (!is_dir($src)) { |
|
| 139 | - return false; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - $success = true; |
|
| 143 | - |
|
| 144 | - // Open the source directory to read in files |
|
| 145 | - $iterator = new DirectoryIterator($src); |
|
| 146 | - foreach ($iterator as $fObj) { |
|
| 147 | - if ($fObj->isFile()) { |
|
| 148 | - $filename = $fObj->getPathname(); |
|
| 149 | - $fObj = null; // clear this iterator object to close the file |
|
| 150 | - if (!unlink($filename)) { |
|
| 151 | - return false; // couldn't delete the file |
|
| 152 | - } |
|
| 153 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 154 | - // Try recursively on directory |
|
| 155 | - self::rrmdir($fObj->getPathname()); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - $iterator = null; // clear iterator Obj to close file/directory |
|
| 159 | - return rmdir($src); // remove the directory & return results |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * Recursively move files from one directory to another |
|
| 164 | - * |
|
| 165 | - * @param string $src - Source of files being moved |
|
| 166 | - * @param string $dest - Destination of files being moved |
|
| 167 | - * |
|
| 168 | - * @return bool true on success |
|
| 169 | - */ |
|
| 170 | - public static function rmove($src, $dest) |
|
| 171 | - { |
|
| 172 | - // Only continue if user is a 'global' Admin |
|
| 173 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 174 | - return false; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - // If source is not a directory stop processing |
|
| 178 | - if (!is_dir($src)) { |
|
| 179 | - return false; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - // If the destination directory does not exist and could not be created stop processing |
|
| 183 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
| 184 | - return false; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - // Open the source directory to read in files |
|
| 188 | - $iterator = new DirectoryIterator($src); |
|
| 189 | - foreach ($iterator as $fObj) { |
|
| 190 | - if ($fObj->isFile()) { |
|
| 191 | - rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 192 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 193 | - // Try recursively on directory |
|
| 194 | - self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 195 | - // rmdir($fObj->getPath()); // now delete the directory |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - $iterator = null; // clear iterator Obj to close file/directory |
|
| 199 | - return rmdir($src); // remove the directory & return results |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * Recursively copy directories and files from one directory to another |
|
| 204 | - * |
|
| 205 | - * @param string $src - Source of files being moved |
|
| 206 | - * @param string $dest - Destination of files being moved |
|
| 207 | - * |
|
| 208 | - * @uses \Xmf\Module\Helper::getHelper() |
|
| 209 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
| 210 | - * |
|
| 211 | - * @return bool true on success |
|
| 212 | - */ |
|
| 213 | - public static function rcopy($src, $dest) |
|
| 214 | - { |
|
| 215 | - // Only continue if user is a 'global' Admin |
|
| 216 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 217 | - return false; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - // If source is not a directory stop processing |
|
| 221 | - if (!is_dir($src)) { |
|
| 222 | - return false; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - // If the destination directory does not exist and could not be created stop processing |
|
| 226 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
| 227 | - return false; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - // Open the source directory to read in files |
|
| 231 | - $iterator = new DirectoryIterator($src); |
|
| 232 | - foreach ($iterator as $fObj) { |
|
| 233 | - if ($fObj->isFile()) { |
|
| 234 | - copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 235 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 236 | - self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - return true; |
|
| 240 | - } |
|
| 19 | + /** |
|
| 20 | + * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
| 21 | + * |
|
| 22 | + * @param string $folder The full path of the directory to check |
|
| 23 | + * |
|
| 24 | + * @return void |
|
| 25 | + */ |
|
| 26 | + public static function createFolder($folder) |
|
| 27 | + { |
|
| 28 | + try { |
|
| 29 | + if (!file_exists($folder)) { |
|
| 30 | + if (!mkdir($folder) && !is_dir($folder)) { |
|
| 31 | + throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
| 35 | + } |
|
| 36 | + } catch (Exception $e) { |
|
| 37 | + echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @param $file |
|
| 43 | + * @param $folder |
|
| 44 | + * @return bool |
|
| 45 | + */ |
|
| 46 | + public static function copyFile($file, $folder) |
|
| 47 | + { |
|
| 48 | + return copy($file, $folder); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @param $src |
|
| 53 | + * @param $dst |
|
| 54 | + */ |
|
| 55 | + public static function recurseCopy($src, $dst) |
|
| 56 | + { |
|
| 57 | + $dir = opendir($src); |
|
| 58 | + @mkdir($dst); |
|
| 59 | + while (false !== ($file = readdir($dir))) { |
|
| 60 | + if (('.' !== $file) && ('..' !== $file)) { |
|
| 61 | + if (is_dir($src . '/' . $file)) { |
|
| 62 | + self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
| 63 | + } else { |
|
| 64 | + copy($src . '/' . $file, $dst . '/' . $file); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + closedir($dir); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * |
|
| 73 | + * Remove files and (sub)directories |
|
| 74 | + * |
|
| 75 | + * @param string $src source directory to delete |
|
| 76 | + * |
|
| 77 | + * @uses \Xmf\Module\Helper::getHelper() |
|
| 78 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
| 79 | + * |
|
| 80 | + * @return bool true on success |
|
| 81 | + */ |
|
| 82 | + public static function deleteDirectory($src) |
|
| 83 | + { |
|
| 84 | + // Only continue if user is a 'global' Admin |
|
| 85 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 86 | + return false; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + $success = true; |
|
| 90 | + // remove old files |
|
| 91 | + $dirInfo = new SplFileInfo($src); |
|
| 92 | + // validate is a directory |
|
| 93 | + if ($dirInfo->isDir()) { |
|
| 94 | + $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); |
|
| 95 | + foreach ($fileList as $k => $v) { |
|
| 96 | + $fileInfo = new SplFileInfo("{$src}/{$v}"); |
|
| 97 | + if ($fileInfo->isDir()) { |
|
| 98 | + // recursively handle subdirectories |
|
| 99 | + if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
| 100 | + break; |
|
| 101 | + } |
|
| 102 | + } else { |
|
| 103 | + // delete the file |
|
| 104 | + if (!($success = unlink($fileInfo->getRealPath()))) { |
|
| 105 | + break; |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + // now delete this (sub)directory if all the files are gone |
|
| 110 | + if ($success) { |
|
| 111 | + $success = rmdir($dirInfo->getRealPath()); |
|
| 112 | + } |
|
| 113 | + } else { |
|
| 114 | + // input is not a valid directory |
|
| 115 | + $success = false; |
|
| 116 | + } |
|
| 117 | + return $success; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * |
|
| 122 | + * Recursively remove directory |
|
| 123 | + * |
|
| 124 | + * @todo currently won't remove directories with hidden files, should it? |
|
| 125 | + * |
|
| 126 | + * @param string $src directory to remove (delete) |
|
| 127 | + * |
|
| 128 | + * @return bool true on success |
|
| 129 | + */ |
|
| 130 | + public static function rrmdir($src) |
|
| 131 | + { |
|
| 132 | + // Only continue if user is a 'global' Admin |
|
| 133 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 134 | + return false; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // If source is not a directory stop processing |
|
| 138 | + if (!is_dir($src)) { |
|
| 139 | + return false; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $success = true; |
|
| 143 | + |
|
| 144 | + // Open the source directory to read in files |
|
| 145 | + $iterator = new DirectoryIterator($src); |
|
| 146 | + foreach ($iterator as $fObj) { |
|
| 147 | + if ($fObj->isFile()) { |
|
| 148 | + $filename = $fObj->getPathname(); |
|
| 149 | + $fObj = null; // clear this iterator object to close the file |
|
| 150 | + if (!unlink($filename)) { |
|
| 151 | + return false; // couldn't delete the file |
|
| 152 | + } |
|
| 153 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 154 | + // Try recursively on directory |
|
| 155 | + self::rrmdir($fObj->getPathname()); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + $iterator = null; // clear iterator Obj to close file/directory |
|
| 159 | + return rmdir($src); // remove the directory & return results |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * Recursively move files from one directory to another |
|
| 164 | + * |
|
| 165 | + * @param string $src - Source of files being moved |
|
| 166 | + * @param string $dest - Destination of files being moved |
|
| 167 | + * |
|
| 168 | + * @return bool true on success |
|
| 169 | + */ |
|
| 170 | + public static function rmove($src, $dest) |
|
| 171 | + { |
|
| 172 | + // Only continue if user is a 'global' Admin |
|
| 173 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 174 | + return false; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + // If source is not a directory stop processing |
|
| 178 | + if (!is_dir($src)) { |
|
| 179 | + return false; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + // If the destination directory does not exist and could not be created stop processing |
|
| 183 | + if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
| 184 | + return false; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + // Open the source directory to read in files |
|
| 188 | + $iterator = new DirectoryIterator($src); |
|
| 189 | + foreach ($iterator as $fObj) { |
|
| 190 | + if ($fObj->isFile()) { |
|
| 191 | + rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 192 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 193 | + // Try recursively on directory |
|
| 194 | + self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 195 | + // rmdir($fObj->getPath()); // now delete the directory |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + $iterator = null; // clear iterator Obj to close file/directory |
|
| 199 | + return rmdir($src); // remove the directory & return results |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * Recursively copy directories and files from one directory to another |
|
| 204 | + * |
|
| 205 | + * @param string $src - Source of files being moved |
|
| 206 | + * @param string $dest - Destination of files being moved |
|
| 207 | + * |
|
| 208 | + * @uses \Xmf\Module\Helper::getHelper() |
|
| 209 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
| 210 | + * |
|
| 211 | + * @return bool true on success |
|
| 212 | + */ |
|
| 213 | + public static function rcopy($src, $dest) |
|
| 214 | + { |
|
| 215 | + // Only continue if user is a 'global' Admin |
|
| 216 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 217 | + return false; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + // If source is not a directory stop processing |
|
| 221 | + if (!is_dir($src)) { |
|
| 222 | + return false; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + // If the destination directory does not exist and could not be created stop processing |
|
| 226 | + if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
| 227 | + return false; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + // Open the source directory to read in files |
|
| 231 | + $iterator = new DirectoryIterator($src); |
|
| 232 | + foreach ($iterator as $fObj) { |
|
| 233 | + if ($fObj->isFile()) { |
|
| 234 | + copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 235 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 236 | + self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + return true; |
|
| 240 | + } |
|
| 241 | 241 | } |
@@ -23,37 +23,37 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class Instruction extends \Xmf\Module\Helper |
| 25 | 25 | { |
| 26 | - public $debugArray = []; |
|
| 26 | + public $debugArray = []; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @internal param $debug |
|
| 30 | - */ |
|
| 31 | - protected function __construct() |
|
| 32 | - { |
|
| 33 | - // $this->debug = $debug; |
|
| 34 | - $this->dirname = basename(dirname(__DIR__)); |
|
| 35 | - } |
|
| 28 | + /** |
|
| 29 | + * @internal param $debug |
|
| 30 | + */ |
|
| 31 | + protected function __construct() |
|
| 32 | + { |
|
| 33 | + // $this->debug = $debug; |
|
| 34 | + $this->dirname = basename(dirname(__DIR__)); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @param bool $debug |
|
| 39 | - * |
|
| 40 | - * @return Newbb |
|
| 41 | - */ |
|
| 42 | - public static function getInstance($debug = false) |
|
| 43 | - { |
|
| 44 | - static $instance; |
|
| 45 | - if (null === $instance) { |
|
| 46 | - $instance = new static($debug); |
|
| 47 | - } |
|
| 37 | + /** |
|
| 38 | + * @param bool $debug |
|
| 39 | + * |
|
| 40 | + * @return Newbb |
|
| 41 | + */ |
|
| 42 | + public static function getInstance($debug = false) |
|
| 43 | + { |
|
| 44 | + static $instance; |
|
| 45 | + if (null === $instance) { |
|
| 46 | + $instance = new static($debug); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return $instance; |
|
| 50 | - } |
|
| 49 | + return $instance; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @return string |
|
| 54 | - */ |
|
| 55 | - public function getDirname() |
|
| 56 | - { |
|
| 57 | - return $this->dirname; |
|
| 58 | - } |
|
| 52 | + /** |
|
| 53 | + * @return string |
|
| 54 | + */ |
|
| 55 | + public function getDirname() |
|
| 56 | + { |
|
| 57 | + return $this->dirname; |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -7,12 +7,12 @@ |
||
| 7 | 7 | |
| 8 | 8 | $com_itemid = Request::getInt('com_itemid', 0, 'GET'); |
| 9 | 9 | if ($com_itemid > 0) { |
| 10 | - $itemObj = $publisher->getHandler('item')->get($com_itemid); |
|
| 11 | - $com_replytext = _POSTEDBY . ' <strong>' . $itemObj->getLinkedPosterName() . '</strong> ' . _DATE . ' <strong>' . $itemObj->dateSub() . '</strong><br><br>' . $itemObj->summary(); |
|
| 12 | - $bodytext = $itemObj->body(); |
|
| 13 | - if ('' != $bodytext) { |
|
| 14 | - $com_replytext .= '<br><br>' . $bodytext . ''; |
|
| 15 | - } |
|
| 16 | - $com_replytitle = $itemObj->getTitle(); |
|
| 17 | - include_once $GLOBALS['xoops']->path('include/comment_new.php'); |
|
| 10 | + $itemObj = $publisher->getHandler('item')->get($com_itemid); |
|
| 11 | + $com_replytext = _POSTEDBY . ' <strong>' . $itemObj->getLinkedPosterName() . '</strong> ' . _DATE . ' <strong>' . $itemObj->dateSub() . '</strong><br><br>' . $itemObj->summary(); |
|
| 12 | + $bodytext = $itemObj->body(); |
|
| 13 | + if ('' != $bodytext) { |
|
| 14 | + $com_replytext .= '<br><br>' . $bodytext . ''; |
|
| 15 | + } |
|
| 16 | + $com_replytitle = $itemObj->getTitle(); |
|
| 17 | + include_once $GLOBALS['xoops']->path('include/comment_new.php'); |
|
| 18 | 18 | } |