Completed
Push — master ( c8eead...62889a )
by Michael
04:13
created

admin/config.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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 52 and the first side effect is on line 31.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
// -------------------------------------------------------------------------
3
//	pedigree
4
//		Copyright 2004, James Cotton
5
// 		http://www.dobermannvereniging.nl
6
//	Template
7
//		Copyright 2004 Thomas Hill
8
//		<a href="http://www.worldware.com">worldware.com</a>
9
// -------------------------------------------------------------------------
10
// ------------------------------------------------------------------------- //
11
//  This program is free software; you can redistribute it and/or modify     //
12
//  it under the terms of the GNU General Public License as published by     //
13
//  the Free Software Foundation; either version 2 of the License, or        //
14
//  (at your option) any later version.                                      //
15
//                                                                           //
16
//  You may not change or alter any portion of this comment or credits       //
17
//  of supporting developers from this source code or any supporting         //
18
//  source code which is considered copyrighted (c) material of the          //
19
//  original comment or credit authors.                                      //
20
//                                                                           //
21
//  This program is distributed in the hope that it will be useful,          //
22
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
23
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
24
//  GNU General Public License for more details.                             //
25
//                                                                           //
26
//  You should have received a copy of the GNU General Public License        //
27
//  along with this program; if not, write to the Free Software              //
28
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
29
// ------------------------------------------------------------------------- //
30
31
require_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php';
32
//require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/include/pedigree_includes.php");
0 ignored issues
show
Unused Code Comprehensibility introduced by
51% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
33
//require_once dirname(__DIR__) . "/include/pedigree_includes.php";
34
/*
35
if (file_exists("../language/" . $xoopsConfig['language'] . "/modinfo.php")) {
36
    include_once '../language/' . $xoopsConfig['language'] . "/modinfo.php";
37
} else {
38
    include_once '../language/english/modinfo.php';
39
}
40
*/
41
xoops_loadLanguage('main', basename(dirname(dirname(__DIR__))));
42
require_once(XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . "/admin/menu.php");
43
44
// Get HTTP post/get parameters.
45
//import_request_variables("gp", "param_");
46
extract($_GET, EXTR_PREFIX_ALL, "param");
47
extract($_POST, EXTR_PREFIX_ALL, "param");
48
49
//
50
// Writes out the form to get all config parameters.
51
//
52
function pedigree_config_form()
53
{
54
    $config_fields = pedigree_get_config_fields();
55
    $values        = pedigree_get_config();
56
    print "
57
    <form action='config.php' method='POST' enctype='application/x-www-form-urlencoded'>\n
58
    <table border='1' cellpadding='0' cellspacing='0' width='100%'>\n
59
        <tr><th>" . _AM_PEDIGREE_CTITLE . "</th></tr>\n
60
        <tr>\n
61
        <td class='bg2'>\n
62
            <table width='100%' border='0' cellpadding='4' cellspacing='1'>\n";
63
64
    foreach ($config_fields as $field => $prompt) {
65
        if ($field == 'config_id') {
66
            continue;
67
        }
68
        $pname = "param_" . $field;
69
        print "
70
                <tr nowrap='nowrap'>\n
71
                <td class ='head'>" . $prompt . "</td>\n
72
                <td class='even' valign = 'top'>\n
73
                    <input type='text' name='$field' size='32' maxlength='32' value ='" . $values[$field] . "'>\n
74
                </td></tr>\n
75
                </tr>\n";
76
    }
77
    print "
78
                <td class='head'>&nbsp;</td>\n
79
                <td class='even'>\n
80
                    <input type='hidden' name='op' value='config' />\n
81
                    <input type='hidden' name='window' value='config' />\n
82
                    <input type='submit' value='" . _AM_PEDIGREE_BUT_GO . "' />\n
83
                </td></tr>\n
84
            </table>\n
85
        </td></tr>\n
86
    </table>\n
87
    </form>\n";
88
}
89
90
//
91
// Displays the main admin interface
92
//
93
function pedigree_config_main()
94
{
95
    //xoops_cp_header();
96
    $p_title = _AM_PEDIGREE_CONFIGURE;
97
    print "<h4 style='text-align:left;'>$p_title</h4>";
98
    pedigree_admin_hmenu();
99
    pedigree_config_form();
100
    xoops_cp_footer();
101
    exit();
102
}
103
104
// Processes the configuration update request, by
105
// getting the HTTP parameters, and putting them into the database.
106
function pedigree_config_post()
107
{
108
    global $xoopsDB;
109
    $config_fields = pedigree_get_config_fields();
110
    foreach ($config_fields as $field => $prompt) {
111
        $param = "param_" . $field;
112
        global $$param;
113
    }
114
    $param_config_id = 1;
115
    $sql             = "REPLACE INTO " . $xoopsDB->prefix("pedigree_config") . " (" . pedigree_to_string($config_fields) . ") VALUES (";
116
117
    $first = true;
118
    foreach ($config_fields as $field => $prompt) {
119
        $param = "param_" . $field;
120
        if (!$first) {
121
            $sql .= ", ";
122
        }
123
        // Handle a 'feature' of PHP that adds backslashes to HTTP parameters.
124
        $param_value = get_magic_quotes_gpc() ? stripslashes($$param) : $$param;
125
        $sql .= "'" . $xoopsDB->escape($param_value) . "'";
126
        $first = false;
127
    }
128
    $sql .= " )";
129
    if (!$xoopsDB->query($sql)) {
130
        $error = $xoopsDB->error();
131
        xoops_cp_header();
132
        pedigree_show_sql_error(_AM_PEDIGREE_ERR_ADD_FAILED, $error, $sql);
133
        xoops_cp_footer();
134
    } else {
135
        redirect_header("config.php", 1, _AM_PEDIGREE_OK_DB);
136
    }
137
    exit();
138
}
139
140
if (!isset($param_op)) {
141
    $param_op = 'main';
142
}
143
144
switch ($param_op) {
145
    case "main":
146
        pedigree_config_main();
147
        break;
148
    case "config":
149
        pedigree_config_post();
150
        break;
151
    default:
152
        //xoops_cp_header();
153
        print "<h1>Unknown method requested '$param_op'</h1>";
154
        xoops_cp_footer();
155
}
156