1 | <?php |
||||
2 | // $Id: xdir_migrate.php wtravel |
||||
3 | // ------------------------------------------------------------------------ // |
||||
4 | // EFQ Directory // |
||||
5 | // Copyright (c) 2006 EFQ Consultancy // |
||||
6 | // <http://www.efqdirectory.com/> // |
||||
7 | // ------------------------------------------------------------------------ // |
||||
8 | // This program is free software; you can redistribute it and/or modify // |
||||
9 | // it under the terms of the GNU General Public License as published by // |
||||
10 | // the Free Software Foundation; either version 2 of the License, or // |
||||
11 | // (at your option) any later version. // |
||||
12 | // // |
||||
13 | // You may not change or alter any portion of this comment or credits // |
||||
14 | // of supporting developers from this source code or any supporting // |
||||
15 | // source code which is considered copyrighted (c) material of the // |
||||
16 | // original comment or credit authors. // |
||||
17 | // // |
||||
18 | // This program is distributed in the hope that it will be useful, // |
||||
19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||||
20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||||
21 | // GNU General Public License for more details. // |
||||
22 | // // |
||||
23 | // You should have received a copy of the GNU General Public License // |
||||
24 | // along with this program; if not, write to the Free Software // |
||||
25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||||
26 | // ------------------------------------------------------------------------ // |
||||
27 | // Part of the efqDirectory module provided by: wtravel // |
||||
28 | // e-mail: [email protected] // |
||||
29 | // Purpose: Create a business directory for xoops. // |
||||
30 | // Based upon the mylinks and the mxDirectory modules // |
||||
31 | // ------------------------------------------------------------------------- // |
||||
32 | include __DIR__ . '/../../../include/cp_header.php'; |
||||
33 | View Code Duplication | if (file_exists(__DIR__ . '/../language/' . $xoopsConfig['language'] . '/main.php')) { |
|||
0 ignored issues
–
show
|
|||||
34 | include __DIR__ . '/../language/' . $xoopsConfig['language'] . '/main.php'; |
||||
35 | } else { |
||||
36 | include __DIR__ . '/../language/english/main.php'; |
||||
37 | } |
||||
38 | include __DIR__ . '/../include/functions.php'; |
||||
39 | include __DIR__ . '/../class/class.fieldtype.php'; |
||||
40 | include __DIR__ . '/../class/class.datatype.php'; |
||||
41 | include __DIR__ . '/../class/class.directory.php'; |
||||
42 | include __DIR__ . '/../class/class.xdir.php'; |
||||
43 | include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||||
0 ignored issues
–
show
|
|||||
44 | include_once XOOPS_ROOT_PATH . '/class/module.errorhandler.php'; |
||||
45 | $myts = MyTextSanitizer::getInstance(); |
||||
0 ignored issues
–
show
The type
MyTextSanitizer was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
46 | $eh = new ErrorHandler; |
||||
0 ignored issues
–
show
The type
ErrorHandler was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
47 | |||||
48 | $moddir = $xoopsModule->getVar('dirname'); |
||||
49 | |||||
50 | if (isset($_GET['dirid'])) { |
||||
51 | $get_dir = (int)$_GET['dirid']; |
||||
52 | } |
||||
53 | |||||
54 | function xdirConfig() |
||||
55 | { |
||||
56 | global $xoopsDB, $xoopsModule, $xoopsUser, $myts, $moddir; |
||||
57 | xoops_cp_header(); |
||||
0 ignored issues
–
show
The function
xoops_cp_header was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
58 | adminmenu(0, _MD_A_DIRADMIN); |
||||
59 | echo '<h4>' . _MD_MIGRATE_FROM_XDIR . '</h4>'; |
||||
0 ignored issues
–
show
|
|||||
60 | echo "<table width='100%' border='0' cellspacing='1' class='outer'><tr><td>"; |
||||
61 | $form = new XoopsThemeForm(_MD_XIDR_MIGRATE_TO_NEWDIR, 'submitform', 'xdir_migrate.php'); |
||||
0 ignored issues
–
show
The type
XoopsThemeForm was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
62 | $form->addElement(new XoopsFormText(_MD_DIRNAME, 'dirname', 100, 150, ''), true); |
||||
0 ignored issues
–
show
The type
XoopsFormText was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
63 | $form_diropen = new XoopsFormCheckBox(_MD_OPENYN, 'open', 0); |
||||
0 ignored issues
–
show
The type
XoopsFormCheckBox was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
64 | $form_diropen->addOption(1, _MD_YESNO); |
||||
65 | $form->addElement($form_diropen); |
||||
66 | $form->addElement(new XoopsFormButton('', 'submit', _MD_SUBMIT, 'submit')); |
||||
0 ignored issues
–
show
The type
XoopsFormButton was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
67 | $form->addElement(new XoopsFormHidden('op', 'newdir')); |
||||
0 ignored issues
–
show
The type
XoopsFormHidden was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
68 | $form->addElement(new XoopsFormHidden('uid', $xoopsUser->getVar('uid'))); |
||||
69 | $form->display(); |
||||
70 | echo '</td></tr></table>'; |
||||
71 | xoops_cp_footer(); |
||||
0 ignored issues
–
show
The function
xoops_cp_footer was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
72 | } |
||||
73 | |||||
74 | function newDir() |
||||
75 | { |
||||
76 | global $xoopsDB, $_POST, $myts, $eh; |
||||
77 | if (isset($_POST['dirname']) and $_POST['dirname'] !== '') { |
||||
78 | $p_dirname = $_POST['dirname']; |
||||
79 | } else { |
||||
80 | redirect_header("directories.php?op=moddir&dirid=$db_dirid", 2, _MD_XDIR_CREATE_EMPTY_DIR); |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
The function
redirect_header was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
81 | } |
||||
82 | if (isset($_POST['open'])) { |
||||
83 | $p_open = $_POST['open']; |
||||
84 | } else { |
||||
85 | $p_open = 0; |
||||
86 | } |
||||
87 | $directory = new efqDirectory; |
||||
88 | $directory->setVar('name', $p_dirname); |
||||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
89 | $directory->setVar('open', $p_open); |
||||
90 | $directoryHandler = new efqDirectoryHandler; |
||||
91 | $directoryHandler->insertDirectory($directory); |
||||
92 | $db_dirid = $directory->getVar('dirid'); |
||||
93 | |||||
94 | if ($db_dirid > 0) { |
||||
95 | $xdirHandler = new efqXdirHandler(); |
||||
96 | $xdirHandler->doMigrate($db_dirid); |
||||
97 | $migration_errors = $xdirHandler->get_errors(); |
||||
98 | if (count($migration_errors) > 0) { |
||||
99 | redirect_header('xdir_migrate.php', 2, _MD_XDIR_MIGRATION_FAILED); |
||||
0 ignored issues
–
show
|
|||||
100 | } else { |
||||
101 | redirect_header('directories.php?op=moddir&dirid=' . $db_dirid, 2, _MD_XDIR_MIGRATION_COMPLETED); |
||||
0 ignored issues
–
show
|
|||||
102 | } |
||||
103 | } else { |
||||
104 | redirect_header('xdir_migrate.php', 2, _MD_XDIR_MIGRATION_FAILED); |
||||
105 | } |
||||
106 | } |
||||
107 | |||||
108 | View Code Duplication | if (!isset($_POST['op'])) { |
|||
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||||
109 | $op = isset($_GET['op']) ? $_GET['op'] : 'dirConfig'; |
||||
110 | } else { |
||||
111 | $op = $_POST['op']; |
||||
112 | } |
||||
113 | switch ($op) { |
||||
114 | |||||
115 | case 'newdir': |
||||
116 | newDir(); |
||||
117 | break; |
||||
118 | default: |
||||
119 | xdirConfig(); |
||||
120 | break; |
||||
121 | } |
||||
122 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.