Issues (807)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

admin/tools.php (5 issues)

1
<?php
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * @package         XoopsModules\Pedigree
14
 * @copyright       {@link https://xoops.org/ XOOPS Project}
15
 * @license         {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
16
 * @author          XOOPS Module Dev Team
17
 */
18
19
20
use Xmf\Request;
21
use XoopsModules\Pedigree\{
22
    Constants,
23
    Helper
24
};
25
26
require_once \dirname(__DIR__, 3) . '/mainfile.php';
27
28
// Include any common code for this module.
29
require_once \dirname(__DIR__) . '/include/common.php';
30
31
$GLOBALS['xoopsOption']['template_main'] = 'pedigree_tools.tpl';
32
33
require XOOPS_ROOT_PATH . '/header.php';
34
$helper = Helper::getInstance();
35
$helper->loadLanguage('main');
36
37
//@todo move language string to language file
38
$GLOBALS['xoopsTpl']->assign('page_title', 'Pedigree database - Add owner/breeder');
39
40
//check for access
41
$xoopsModule = XoopsModule::getByDirname($moduleDirName);
42
if (empty($GLOBALS['xoopsUser'])) {
43
    $helper->redirect('admin/index.php', 3, _NOPERM . '<br>' . _MA_PEDIGREE_REGIST);
44
}
45
46
//add JS routines
47
//@todo change this to send to Tpl addScript
48
echo "<script type=\"text/javascript\" src=\"assets/js/picker.js\"></script>\n";
49
50
//set form to be empty
51
$form = '';
52
53
$helper = Helper::getInstance();
54
////get module configuration
55
///** @var \XoopsModuleHandler $moduleHandler */
56
//$moduleHandler = xoops_getHandler('module');
57
//$module        = $moduleHandler->getByDirname($moduleDirName);
58
///** @var \XoopsConfigHandler $configHandler */
59
//$configHandler = xoops_getHandler('config');
60
//$moduleConfig  = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
61
62
$op = Request::getString('op', '', 'GET');
63
switch ($op) {
64
    case 'lang':
65
        lang();
66
        break;
67
    case 'langsave':
68
        langsave();
69
        break;
70
    case 'colours':
71
        colours();
72
        break;
73
    case 'settings':
74
        settings();
75
        break;
76
    case 'settingssave':
77
        settingssave();
78
        break;
79
    case 'pro':
80
        pro();
81
        break;
82
    case 'userfields':
83
        userfields();
84
        break;
85
    case 'deleted':
86
        deleted();
87
        break;
88
    case 'delperm':
89
        delperm($_GET['id']);
90
        break;
91
    case 'delall':
92
        delall();
93
        break;
94
    case 'restore':
95
        restore($_GET['id']);
96
        break;
97
    case 'database':
98
        database();
99
        $db = true;
100
        break;
101
    case 'dbanc':
102
        database_oa();
103
        $db = true;
104
        break;
105
    case 'fltypar':
106
        database_fp();
107
        $db = true;
108
        break;
109
    case 'credits':
110
        credits();
111
        break;
112
    default:
113
        index();
114
        break;
115
}
116
117
//create tools array
118
//@todo move language strings to language files
119
$tools[] = ['title' => 'General settings', 'link' => 'tools.php?op=settings', 'main' => '1'];
120
if ('1' == $helper->getConfig('proversion')) {
121
    $tools[] = ['title' => 'Pro-version settings', 'link' => 'tools.php?op=pro', 'main' => '1'];
122
}
123
$tools[] = ['title' => 'Language options', 'link' => 'tools.php?op=lang', 'main' => '1'];
124
$tools[] = ['title' => 'Create user fields', 'link' => 'tools.php?op=userfields', 'main' => '1'];
125
$tools[] = ['title' => 'Create colours', 'link' => 'tools.php?op=colours', 'main' => '1'];
126
$tools[] = ['title' => "Deleted pedigree's", 'link' => 'tools.php?op=deleted', 'main' => '1'];
127
$tools[] = ['title' => 'Database tools', 'link' => 'tools.php?op=database', 'main' => '1'];
128
if (isset($db)) {
129
    //create database submenu
130
    $tools[] = ['title' => 'Own ancestors', 'link' => 'tools.php?op=dbanc', 'main' => '0'];
131
    $tools[] = ['title' => 'Incorrect gender', 'link' => 'tools.php?op=fltypar', 'main' => '0'];
132
    $tools[] = ['title' => 'User Queries', 'link' => 'tools.php?op=userq', 'main' => '0'];
133
}
134
$tools[] = ['title' => 'Credits', 'link' => 'tools.php?op=credits', 'main' => '1'];
135
$tools[] = ['title' => 'Logout', 'link' => '../../user.php?op=logout', 'main' => '1'];
136
//add data (form) to smarty template
137
138
$xoopsTpl->assign('tools', $tools);
139
140
//footer
141
require XOOPS_ROOT_PATH . '/footer.php';
142
143
function index()
144
{
145
    $form = '';
0 ignored issues
show
The assignment to $form is dead and can be removed.
Loading history...
146
}
147
148
/**
149
 * @todo move language string to language file
150
 */
151
function colours()
152
{
153
    global $xoopsTpl, $femaleTextColour;
154
    $form = 'This will be the wizard to create and modify the website colourscheme.<hr>';
155
    $form .= '<form name="myForm" action=\'savecolors.php\' method=\'POST\'>';
156
    $form .= $GLOBALS['xoopsSecurity']->getTokenHTML();
157
    $form .= '<input type="text" id="ftxtcolor" name="ftxtcolor" value="#' . $femaleTextColour . '" size="11" maxlength="7">';
158
    $form .= '<a href="javascript:TCP.popup(document.forms[\'myForm\'].elements[\'ftxtcolor\'])">';
159
    $form .= '<img width="15" height="13" border="0" alt="Click here to pick the color" src="img/sel.gif"></a>';
160
    $form .= '</form>';
161
    $xoopsTpl->assign('form', $form);
162
}
163
164
/**
165
 * @todo move language string to language file
166
 */
167
function userfields()
168
{
169
    global $xoopsTpl;
170
    $form = 'This will be the wizard to create and modify the custom userfields.<hr>';
171
    $xoopsTpl->assign('form', $form);
172
}
173
174
/**
175
 * @todo move language string to language file
176
 */
177
function credits()
178
{
179
    global $xoopsTpl;
180
    $form = 'Pedigree database module<br><br><li>Programming : James Cotton<br><li>Design & Layout : Ton van der Hagen<br><br>Technical support :<br><li><a href="mailto:[email protected]">[email protected]<br><li><a href="http://www.animalpedigree.com">www.animalpedigree.com</a><hr>';
181
    $xoopsTpl->assign('form', $form);
182
}
183
184
function database()
185
{
186
    global $xoopsTpl;
187
    $form = _MA_PEDIGREE_QUERY_EXPLAN;
188
    $xoopsTpl->assign('form', $form);
189
}
190
191
/**
192
 * @todo move language string to language file
193
 */
194
function database_oa()
195
{
196
    global $xoopsTpl;
197
    $form   = _AM_PEDIGREE_DATABASE_CHECK_ANCESTORS;
198
    $sql    = 'SELECT d.id AS d_id, d.pname AS d_pname
199
            FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' d
200
            LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' m ON m.id = d.mother
201
            LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' f ON f.id = d.father
202
            LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' mm ON mm.id = m.mother
203
            LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' mf ON mf.id = m.father
204
            LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' fm ON fm.id = f.mother
205
            LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' ff ON ff.id = f.father
206
            WHERE
207
            d.mother = d.id
208
            OR d.father = d.id
209
            OR m.mother = d.id
210
            OR m.father = d.id
211
            OR f.mother = d.id
212
            OR f.father = d.id
213
            OR mm.mother = d.id
214
            OR mm.father = d.id
215
            OR mf.mother = d.id
216
            OR mf.father = d.id
217
            OR fm.mother = d.id
218
            OR fm.father = d.id
219
            OR ff.mother = d.id
220
            OR ff.father = d.id
221
            ';
222
    $result = $GLOBALS['xoopsDB']->query($sql);
223
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
224
        $form .= '<li><a href="pedigree.php?pedid=' . $row['d_id'] . '">' . $row['d_pname'] . '</a> [own parent or grandparent]<br>';
225
    }
226
    $xoopsTpl->assign('form', $form);
227
}
228
229
/**
230
 * @todo move language string to language file
231
 */
232
function database_fp()
233
{
234
    global $xoopsTpl;
235
    $form   = _AM_PEDIGREE_DATABASE_CHECK_GENDER;
236
    $sql    = 'SELECT d.id AS d_id, d.pname AS d_pname, m.roft AS m_roft
237
            FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' d
238
            LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " m ON m.id = d.mother
239
            WHERE
240
            d.mother = m.id
241
            AND m.roft = '0' ";
242
    $result = $GLOBALS['xoopsDB']->query($sql);
243
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
244
        $form .= '<li><a href="dog.php?id=' . $row['d_id'] . '">' . $row['d_pname'] . '</a> [mother seems to be male]<br>';
245
    }
246
    $sql    = 'SELECT d.id AS d_id, d.pname AS d_pname, f.roft AS f_roft
247
            FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' d
248
            LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . " f ON f.id = d.father
249
            WHERE
250
            d.father = f.id
251
            AND f.roft = '1' ";
252
    $result = $GLOBALS['xoopsDB']->query($sql);
253
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
254
        $form .= '<li><a href="dog.php?id=' . $row['d_id'] . '">' . $row['d_pname'] . '</a> [father seems to be female]<br>';
255
    }
256
    $xoopsTpl->assign('form', $form);
257
}
258
259
/**
260
 * @todo move language string to language file
261
 */
262
function pro()
263
{
264
    global $xoopsTpl;
265
    $form = 'Pro version settings go here.<hr>';
266
    $xoopsTpl->assign('form', $form);
267
}
268
269
/**
270
 * @todo refactor using {@see Pedigree\Trash} class
271
 */
272
function deleted()
273
{
274
    global $xoopsTpl;
275
    $helper = Helper::getInstance();
276
    $form   = "Below the line are the animals which have been deleted from your database.<br><br>By clicking on the name you can reinsert them into the database.<br>By clicking on the 'X' in front of the name you can permanently delete the animal.<hr>";
277
    $sql    = 'SELECT id, pname  FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_trash');
278
    $result = $GLOBALS['xoopsDB']->query($sql);
279
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
280
        $form .= '<a href="tools.php?op=delperm&id=' . $row['id'] . '"><img src="assets/images/delete.png"></a>&nbsp;<a href="tools.php?op=restore&id=' . $row['id'] . '">' . $row['pname'] . '</a><br>';
281
    }
282
    if ($GLOBALS['xoopsDB']->getRowsNum($result) > 0) {
283
        $form .= '<hr><a href="tools.php?op=delall">Click here</a> to remove all these ' . $helper->getConfig('animalTypes') . ' permenantly ';
284
    }
285
    $xoopsTpl->assign('form', $form);
286
}
287
288
/**
289
 * @param $id
290
 * @todo refactor using {@see Pedigree\Trash} class
291
 */
292
function delperm($id)
293
{
294
    global $xoopsTpl;
295
    $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_trash') . ' WHERE id = ' . $id;
296
    $GLOBALS['xoopsDB']->queryF($sql);
297
    deleted();
298
}
299
300
/**
301
 * @todo refactor using {@see Pedigree\Trash} class
302
 */
303
function delall()
304
{
305
    global $xoopsTpl;
306
    $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_trash');
307
    $GLOBALS['xoopsDB']->queryF($sql);
308
    deleted();
309
}
310
311
/**
312
 * @param $id
313
 */
314
function restore($id)
315
{
316
    global $xoopsTpl;
317
    $sql    = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_trash') . ' WHERE id = ' . $id;
318
    $result = $GLOBALS['xoopsDB']->query($sql);
319
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
320
        foreach ($row as $key => $values) {
321
            //          $queryvalues .= "'" . $values . "',";
322
            $queryvalues .= "'" . $GLOBALS['xoopsDB']->escape($values) . "',";
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $queryvalues does not exist. Did you maybe mean $query?
Loading history...
323
        }
324
        $outgoing = substr_replace($queryvalues, '', -1);
325
        $query    = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' VALUES (' . $outgoing . ')';
0 ignored issues
show
Are you sure $outgoing of type array|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

325
        $query    = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' VALUES (' . /** @scrutinizer ignore-type */ $outgoing . ')';
Loading history...
326
        $GLOBALS['xoopsDB']->queryF($query);
327
        $delquery = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_trash') . ' WHERE id = ' . $id;
328
        $GLOBALS['xoopsDB']->queryF($delquery);
329
        $form .= '<li><a href="pedigree.php?pedid=' . $row['id'] . '">' . $row['pname'] . '</a> has been restored into the database.<hr>';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $form seems to be never defined.
Loading history...
330
    }
331
    $xoopsTpl->assign('form', $form);
332
}
333
334
/**
335
 * @todo move language strings to language file
336
 */
337
function settings()
338
{
339
    global $xoopsTpl;
340
    $helper = Helper::getInstance();
341
    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
342
    $form = new \XoopsThemeForm('General settings', 'settings', 'tools.php?op=settingssave', 'POST', 1);
343
    $form->addElement(new \XoopsFormHiddenToken($name = 'XOOPS_TOKEN_REQUEST', $timeout = 360));
344
    $select  = new \XoopsFormSelect('<b>Number of results per page</b>', 'perpage', $value = $helper->getConfig('perpage'), $size = 1, $multiple = false);
345
    $options = [
346
        '50'    => 50,
347
        '100'   => 100,
348
        '250'   => 250,
349
        '500'   => 500,
350
        '1000'  => 1000,
351
        '2000'  => 2000,
352
        '5000'  => 5000,
353
        '10000' => 10000,
354
    ];
355
    foreach ($options as $key => $values) {
356
        $select->addOption($key, $name = $values);
357
    }
358
    unset($options);
359
    $form->addElement($select);
360
    $form->addElement(
361
        new \XoopsFormLabel(
362
            _MA_PEDIGREE_EXPLAIN, 'This field is used to set the number of results a page will return from a search. If more results are returned extra pages will be created for easy browsing.<br>Set this number higher as your database grows and the number of pages increase.'
363
        )
364
    );
365
    $radio = new \XoopsFormRadio('<b>Use owner/breeder fields</b>', 'ownerbreeder', $value = $helper->getConfig('ownerbreeder'));
366
    $radio->addOption(1, $name = 'yes');
367
    $radio->addOption(0, $name = 'no');
368
    $form->addElement($radio);
369
    $form->addElement(
370
        new \XoopsFormLabel(
371
            _MA_PEDIGREE_EXPLAIN,
372
            'Use this field to set if you would like to use the owner/breeder fields of the database.<br>As the name suggests the owner/breeder fields let you record and display information about the owner and or breeder.<br>The owner/breeder menu items will also be affected by this setting.'
373
        )
374
    );
375
    $radiobr = new \XoopsFormRadio('<b>Show brother & sister field</b>', 'brothers', $value = $helper->getConfig('brothers'));
376
    $radiobr->addOption(1, $name = 'yes');
377
    $radiobr->addOption(0, $name = 'no');
378
    $form->addElement($radiobr);
379
    $form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set if you would like to use the add a ' . $helper->getConfig('litter') . 'feature.<br>If your chosen animal only has one offspring at a time this feature will not be useful to you.'));
380
    $radiolit = new \XoopsFormRadio('<b>Use add a ' . $helper->getConfig('litter') . ' feature</b>', 'uselitter', $value = $helper->getConfig('uselitter'));
381
    $radiolit->addOption(1, $name = 'yes');
382
    $radiolit->addOption(0, $name = 'no');
383
    $form->addElement($radiolit);
384
    $form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set if you would like to display the brothers & sisters field on the detailed ' . $helper->getConfig('animalType') . ' information page.'));
385
    $radioch = new \XoopsFormRadio('<b>Show ' . $helper->getConfig('children') . ' field</b>', 'pups', $value = $helper->getConfig('pups'));
386
    $radioch->addOption(1, $name = 'yes');
387
    $radioch->addOption(0, $name = 'no');
388
    $form->addElement($radioch);
389
    $form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set if you would like to display the ' . $helper->getConfig('children') . ' field on the detailed ' . $helper->getConfig('animalType') . ' information page.'));
390
    $form->addElement(new \XoopsFormButton('', 'button_id', 'Submit', 'submit'));
391
    $xoopsTpl->assign('form', $form->render());
392
}
393
394
/**
395
 * @todo move language string to language file
396
 */
397
function settingssave()
398
{
399
    global $xoopsTpl;
400
    $form     = '';
401
    $settings = ['perpage', 'ownerbreeder', 'brothers', 'uselitter', 'pups'];
402
    foreach ($_POST as $key => $values) {
403
        if (in_array($key, $settings)) {
404
            //          $query = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('config') . " SET conf_value = '" . $values . "' WHERE conf_name = '" . $key . "'";
405
            $query = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('config') . " SET conf_value = '" . $GLOBALS['xoopsDB']->escape($values) . "' WHERE conf_name = '" . $GLOBALS['xoopsDB']->escape($key) . "'";
406
            $GLOBALS['xoopsDB']->query($query);
407
        }
408
    }
409
    $form .= 'Your settings have been saved.<hr>';
410
    $xoopsTpl->assign('form', $form);
411
}
412
413
/**
414
 * @todo move language string to language file
415
 */
416
function lang()
417
{
418
    global $xoopsTpl;
419
    $helper = Helper::getInstance();
420
    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
421
    $form = new \XoopsThemeForm('Language options', 'language', 'tools.php?op=langsave', 'post', true);
422
    $form->addElement(new \XoopsFormHiddenToken($name = 'XOOPS_TOKEN_REQUEST', $timeout = 360));
423
    $form->addElement(new \XoopsFormText('<b>type of animal</b>', 'animalType', $size = 50, $maxsize = 255, $value = $helper->getConfig('animalType')));
424
    $form->addElement(
425
        new \XoopsFormLabel(
426
            _MA_PEDIGREE_EXPLAIN,
427
            'Use this field to set the animal type which will be used in the application.<br><i>example : </i>snake, pigeon, dog, owl<br><br>The value should fit in the sentences below.<br>Please add optional information for this <b>'
428
            . $helper->getConfig('animalType')
429
            . '</b>.<br>Select the first letter of the <b>'
430
            . $helper->getConfig('animalType')
431
            . '</b>.'
432
        )
433
    );
434
    $form->addElement(new \XoopsFormText('<b>type of animal</b>', 'animalTypes', $size = 50, $maxsize = 255, $value = $value = $helper->getConfig('animalTypes')));
0 ignored issues
show
The assignment to $value is dead and can be removed.
Loading history...
435
    $form->addElement(
436
        new \XoopsFormLabel(
437
            _MA_PEDIGREE_EXPLAIN,
438
            'Use this field to set the animal type which will be used in the application.<br>This field is the plural of the previous field<br><i>example : </i>snakes, pigeons, dogs, owls<br><br>The value should fit in the sentence below.<br>No <b>'
439
            . $helper->getConfig('animalTypes')
440
            . '</b> meeting your query have been found.'
441
        )
442
    );
443
    $form->addElement(new \XoopsFormText('<b>male</b>', 'male', $size = 50, $maxsize = 255, $value = $helper->getConfig('male')));
444
    $form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the name used for the male animal.<br><i>example : </i>male, buck, sire etc.'));
445
    $form->addElement(new \XoopsFormText('<b>female</b>', 'female', $size = 50, $maxsize = 255, $value = $helper->getConfig('female')));
446
    $form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the name used for the female animal.<br><i>example : </i>female, vixen, dam etc.'));
447
    $form->addElement(new \XoopsFormText('<b>children</b>', 'children', $size = 50, $maxsize = 255, $value = $helper->getConfig('children')));
448
    $form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the name used for children of this type of animal (' . $helper->getConfig('animalTypes') . ').<br><i>example : </i>pups, cubs, kittens etc.'));
449
    $form->addElement(new \XoopsFormText('<b>mother</b>', 'mother', $size = 50, $maxsize = 255, $value = $helper->getConfig('mother')));
450
    $form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the name used for mother of this type of animal (' . $helper->getConfig('animalTypes') . ').<br><i>example : </i>dam, mare etc.'));
451
    $form->addElement(new \XoopsFormText('<b>father</b>', 'father', $size = 50, $maxsize = 255, $value = $helper->getConfig('father')));
452
    $form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the name used for father of this type of animal (' . $helper->getConfig('animalTypes') . ').<br><i>example : </i>sire, stallion etc.'));
453
    $form->addElement(new \XoopsFormText('<b>litter</b>', 'litter', $size = 50, $maxsize = 255, $value = $helper->getConfig('litter')));
454
    $form->addElement(new \XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the name used for a collection of newborn animals.<br><i>example : </i>litter, nest etc.'));
455
    $form->addElement(new \XoopsFormTextArea('<b>Welcome text</b>', 'welcome', $value = $helper->getConfig('welcome'), $rows = 15, $cols = 50));
456
457
    $form->addElement(
458
        new \XoopsFormLabel(
459
            _MA_PEDIGREE_EXPLAIN,
460
            'Use this field to set the text you would like to display for the welcome page.<br><br>You may use the follwing variables :<br>[animalType] = ' . $helper->getConfig('animalType') . '<br>[animalTypes] =' . $helper->getConfig('animalTypes') . '<br>[numanimals] = number of animals in the database.'
461
        )
462
    );
463
    $form->addElement(new \XoopsFormButton('', 'button_id', 'Submit', 'submit'));
464
    $xoopsTpl->assign('form', $form->render());
465
}
466
467
/**
468
 * @todo move language string to language file
469
 */
470
function langsave()
471
{
472
    global $xoopsTpl;
473
    $form     = '';
474
    $settings = [
475
        'animalType',
476
        'animalTypes',
477
        'male',
478
        'female',
479
        'children',
480
        'mother',
481
        'father',
482
        'litter',
483
        'welcome',
484
    ];
485
    foreach ($_POST as $key => $values) {
486
        if (in_array($key, $settings)) {
487
            //          $query = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('config') . " SET conf_value = '" . $values . "' WHERE conf_name = '" . $key . "'";
488
            $query = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('config') . " SET conf_value = '" . $GLOBALS['xoopsDB']->escape($values) . "' WHERE conf_name = '" . $GLOBALS['xoopsDB']->escape($key) . "'";
489
            $GLOBALS['xoopsDB']->query($query);
490
        }
491
    }
492
    $form .= 'Your settings have been saved.<hr>';
493
    $xoopsTpl->assign('form', $form);
494
}
495