Completed
Branch master (1b2f30)
by Michael
06:29 queued 03:22
created

admin/import.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * Module: SmartFAQ
5
 * Author: The SmartFactory <www.smartfactory.ca>
6
 * Licence: GNU
7
 */
8
9
include_once __DIR__ . '/admin_header.php';
10
11
$op = 'none';
12
13
if (isset($_GET['op'])) {
14
    $op = $_GET['op'];
15
}
16
if (isset($_POST['op'])) {
17
    $op = $_POST['op'];
18
}
19
20
global $xoopsDB;
21
22
switch ($op) {
23
    case 'importExecute':
0 ignored issues
show
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
24
25
        $importfile      = isset($_POST['importfile']) ? $_POST['importfile'] : 'nonselected';
26
        $importfile_path = XOOPS_ROOT_PATH . '/modules/smartfaq/admin/' . $importfile . '.php';
27
        if (!file_exists($importfile_path)) {
28
            $errs[] = sprintf(_AM_SF_IMPORT_FILE_NOT_FOUND, $importfile_path);
29
            $error  = true;
30
        } else {
31
            include_once($importfile_path);
32
        }
33
        foreach ($msgs as $m) {
34
            echo $m . '<br />';
35
        }
36
        echo '<br />';
37
        $endMsg = _AM_SF_IMPORT_SUCCESS;
38
        if ($error == true) {
39
            $endMsg = _AM_SF_IMPORT_ERROR;
40
        }
41
42
        echo $endMsg;
43
        echo '<br /><br />';
44
        echo "<a href='import.php'>" . _AM_SF_IMPORT_BACK . '</a>';
45
        echo '<br /><br />';
46
        break;
47
48
    case 'default':
49
    default:
0 ignored issues
show
The default body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a default statement must start on the line immediately following the statement.

switch ($expr) {
    default:
        doSomething(); //right
        break;
}


switch ($expr) {
    default:

        doSomething(); //wrong
        break;
}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
50
51
        $importfile = 'none';
52
53
        xoops_cp_header();
54
55
        sf_collapsableBar('bottomtable', 'bottomtableicon');
56
        echo "<img id='bottomtableicon' src=" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt='' /></a>&nbsp;" . _AM_SF_IMPORT_TITLE . '</h3>';
57
        echo "<div id='bottomtable'>";
58
        echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_SF_IMPORT_INFO . '</span>';
59
60
        global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $modify, $xoopsModuleConfig, $xoopsModule, $XOOPS_URL, $myts;
61
62
        include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
63
64
        $moduleHandler = xoops_getHandler('module');
65
        if ($moduleHandler->getByDirname('xoopsfaq')) {
66
            $importfile_select_array['xoopsfaq'] = _AM_SF_IMPORT_XOOPSFAQ_110;
67
        }
68
69
        if ($moduleHandler->getByDirname('wffaq')) {
70
            $importfile_select_array['wffaq'] = _AM_SF_IMPORT_WFFAQ_105;
71
        }
72
73
        if (isset($importfile_select_array) && count($importfile_select_array) > 0) {
74
            $sform = new XoopsThemeForm(_AM_SF_IMPORT_SELECTION, 'op', xoops_getenv('PHP_SELF'));
75
            $sform->setExtra('enctype="multipart/form-data"');
76
77
            // Q&A set to import
78
            $importfile_select = new XoopsFormSelect('', 'importfile', $importfile);
79
            $importfile_select->addOptionArray($importfile_select_array);
80
            $importfile_tray = new XoopsFormElementTray(_AM_SF_IMPORT_SELECT_FILE, '&nbsp;');
81
            $importfile_tray->addElement($importfile_select);
82
            $sform->addElement($importfile_tray);
83
84
            // Buttons
85
            $button_tray = new XoopsFormElementTray('', '');
86
            $hidden      = new XoopsFormHidden('op', 'importExecute');
87
            $button_tray->addElement($hidden);
88
89
            $butt_import = new XoopsFormButton('', '', _AM_SF_IMPORT, 'submit');
90
            $butt_import->setExtra('onclick="this.form.elements.op.value=\'importExecute\'"');
91
            $button_tray->addElement($butt_import);
92
93
            $butt_cancel = new XoopsFormButton('', '', _AM_SF_CANCEL, 'button');
94
            $butt_cancel->setExtra('onclick="history.go(-1)"');
95
            $button_tray->addElement($butt_cancel);
96
97
            $sform->addElement($button_tray);
98
            $sform->display();
99
            unset($hidden);
100
        } else {
101
            echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-weight: bold; font-size: small; display: block; \">" . _AM_SF_IMPORT_NO_MODULE . '</span>';
102
        }
103
104
        // End of collapsable bar
105
        echo '</div>';
106
107
        break;
108
}
109
110
include_once __DIR__ . '/admin_footer.php';
111