This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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 | * @copyright {@link http://xoops.org/ XOOPS Project} |
||
14 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
||
15 | * @package |
||
16 | * @since |
||
17 | * @author XOOPS Development Team, |
||
18 | * @author GIJ=CHECKMATE (PEAK Corp. http://www.peak.ne.jp/) |
||
19 | */ |
||
20 | |||
21 | require_once __DIR__ . '/../../../include/cp_header.php'; |
||
22 | require_once __DIR__ . '/../include/gtickets.php'; |
||
23 | require_once XOOPS_ROOT_PATH . '/class/template.php'; |
||
24 | |||
25 | require_once __DIR__ . '/../include/Text_Diff.php'; |
||
26 | require_once __DIR__ . '/../include/Text_Diff_Renderer.php'; |
||
27 | require_once __DIR__ . '/../include/Text_Diff_Renderer_unified.php'; |
||
28 | |||
29 | $xoops_system_path = XOOPS_ROOT_PATH . '/modules/system'; |
||
30 | |||
31 | // initials |
||
32 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
||
33 | $myts = MyTextSanitizer::getInstance(); |
||
34 | |||
35 | // determine language |
||
36 | $language = $xoopsConfig['language']; |
||
37 | if (!file_exists("$xoops_system_path/language/$language/admin/tplsets.php")) { |
||
38 | $language = 'english'; |
||
39 | } |
||
40 | |||
41 | // load language constants |
||
42 | // to prevent from notice that constants already defined |
||
43 | $error_reporting_level = error_reporting(0); |
||
44 | require_once "$xoops_system_path/constants.php"; |
||
45 | require_once "$xoops_system_path/language/$language/admin.php"; |
||
46 | require_once "$xoops_system_path/language/$language/admin/tplsets.php"; |
||
47 | error_reporting($error_reporting_level); |
||
48 | |||
49 | // check $xoopsModule |
||
50 | if (!is_object($xoopsModule)) { |
||
51 | redirect_header(XOOPS_URL . '/user.php', 1, _NOPERM); |
||
52 | } |
||
53 | |||
54 | // check access right (needs system_admin of tplset) |
||
55 | $syspermHandler = xoops_getHandler('groupperm'); |
||
56 | View Code Duplication | if (!$syspermHandler->checkRight('system_admin', XOOPS_SYSTEM_TPLSET, $xoopsUser->getGroups())) { |
|
0 ignored issues
–
show
|
|||
57 | redirect_header(XOOPS_URL . '/user.php', 1, _NOPERM); |
||
58 | } |
||
59 | |||
60 | // tpl_file from $_GET |
||
61 | $tpl_file = $myts->stripSlashesGPC(@$_GET['tpl_file']); |
||
62 | $tpl_file4sql = addslashes($tpl_file); |
||
63 | |||
64 | // tpl_file from $_GET |
||
65 | $tpl_tplset = $myts->stripSlashesGPC(@$_GET['tpl_tplset']); |
||
66 | $tpl_tplset4sql = addslashes($tpl_tplset); |
||
67 | |||
68 | // get information from tplfile table |
||
69 | $sql = 'SELECT * FROM ' . $db->prefix('tplfile') . ' f NATURAL LEFT JOIN ' . $db->prefix('tplsource') . " s WHERE f.tpl_file='$tpl_file4sql' AND f.tpl_tplset='$tpl_tplset4sql'"; |
||
70 | $tpl = $db->fetchArray($db->query($sql)); |
||
71 | if (empty($tpl)) { |
||
72 | die('Invalid tpl_file or tpl_tplset.'); |
||
73 | } |
||
74 | |||
75 | //************// |
||
76 | // POST stage // |
||
77 | //************// |
||
78 | if (!empty($_POST['do_modify'])) { |
||
79 | // Ticket Check |
||
80 | if (!$xoopsGTicket->check()) { |
||
81 | redirect_header(XOOPS_URL . '/', 3, $xoopsGTicket->getErrors()); |
||
82 | } |
||
83 | |||
84 | $result = $db->query('SELECT tpl_id FROM ' . $db->prefix('tplfile') . " WHERE tpl_file='$tpl_file4sql' AND tpl_tplset='$tpl_tplset4sql'"); |
||
85 | while (list($tpl_id) = $db->fetchRow($result)) { |
||
86 | $sql = 'UPDATE ' . $db->prefix('tplsource') . " SET tpl_source='" . addslashes($myts->stripSlashesGPC($_POST['tpl_source'])) . "' WHERE tpl_id=$tpl_id"; |
||
87 | if (!$db->query($sql)) { |
||
88 | die('SQL Error'); |
||
89 | } |
||
90 | $db->query('UPDATE ' . $db->prefix('tplfile') . " SET tpl_lastmodified=UNIX_TIMESTAMP() WHERE tpl_id=$tpl_id"); |
||
91 | xoops_template_touch($tpl_id); |
||
92 | } |
||
93 | redirect_header('mytplsadmin.php?dirname=' . $tpl['tpl_module'], 1, _AM_APCALAM_APCALDBUPDATED); |
||
94 | exit; |
||
95 | } |
||
96 | |||
97 | xoops_cp_header(); |
||
98 | $mymenu_fake_uri = "/admin/mytplsadmin.php?dirname={$tpl['tpl_module']}"; |
||
99 | if (file_exists('./mymenu.php')) { |
||
100 | include __DIR__ . '/mymenu.php'; |
||
101 | } |
||
102 | |||
103 | echo "<h3 style='text-align:left;'>" |
||
104 | . _MD_APCAL_TPLSETS |
||
105 | . ' : ' |
||
106 | . htmlspecialchars($tpl['tpl_type'], ENT_QUOTES) |
||
107 | . ' : ' |
||
108 | . htmlspecialchars($tpl['tpl_file'], ENT_QUOTES) |
||
109 | . ' (' |
||
110 | . htmlspecialchars($tpl['tpl_tplset'], ENT_QUOTES) |
||
111 | . ")</h3>\n"; |
||
112 | |||
113 | // diff from file to selected DB template |
||
114 | $basefilepath = XOOPS_ROOT_PATH . '/modules/' . $tpl['tpl_module'] . '/templates/' . ($tpl['tpl_type'] === 'block' ? 'blocks/' : '') . $tpl['tpl_file']; |
||
115 | $diff_from_file4disp = ''; |
||
116 | if (file_exists($basefilepath)) { |
||
117 | $diff = new Text_Diff(file($basefilepath), explode("\n", $tpl['tpl_source'])); |
||
118 | $renderer = new Text_Diff_Renderer_unified(); |
||
119 | $diff_str = htmlspecialchars($renderer->render($diff), ENT_QUOTES); |
||
120 | View Code Duplication | foreach (explode("\n", $diff_str) as $line) { |
|
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. ![]() |
|||
121 | if (ord($line) == 0x2d) { |
||
122 | $diff_from_file4disp .= "<span style='color:red;'>" . $line . "</span>\n"; |
||
123 | } elseif (ord($line) == 0x2b) { |
||
124 | $diff_from_file4disp .= "<span style='color:blue;'>" . $line . "</span>\n"; |
||
125 | } else { |
||
126 | $diff_from_file4disp .= $line . "\n"; |
||
127 | } |
||
128 | } |
||
129 | } |
||
130 | |||
131 | // diff from DB-default to selected DB template |
||
132 | $diff_from_default4disp = ''; |
||
133 | if ($tpl['tpl_tplset'] !== 'default') { |
||
134 | list($default_source) = $db->fetchRow($db->query('SELECT tpl_source FROM ' |
||
135 | . $db->prefix('tplfile') |
||
136 | . ' NATURAL LEFT JOIN ' |
||
137 | . $db->prefix('tplsource') |
||
138 | . " WHERE tpl_tplset='default' AND tpl_file='" |
||
139 | . addslashes($tpl['tpl_file']) |
||
140 | . "' AND tpl_module='" |
||
141 | . addslashes($tpl['tpl_module']) |
||
142 | . "'")); |
||
143 | $diff = new Text_Diff(explode("\n", $default_source), explode("\n", $tpl['tpl_source'])); |
||
144 | $renderer = new Text_Diff_Renderer_unified(); |
||
145 | $diff_str = htmlspecialchars($renderer->render($diff), ENT_QUOTES); |
||
146 | View Code Duplication | foreach (explode("\n", $diff_str) as $line) { |
|
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. ![]() |
|||
147 | if (ord($line) == 0x2d) { |
||
148 | $diff_from_default4disp .= "<span style='color:red;'>" . $line . "</span>\n"; |
||
149 | } elseif (ord($line) == 0x2b) { |
||
150 | $diff_from_default4disp .= "<span style='color:blue;'>" . $line . "</span>\n"; |
||
151 | } else { |
||
152 | $diff_from_default4disp .= $line . "\n"; |
||
153 | } |
||
154 | } |
||
155 | } |
||
156 | |||
157 | echo " |
||
158 | <form class='apcalForm' name='diff_form' id='diff_form' action='' method='get'> |
||
159 | <input type='checkbox' name='display_diff2file' value='1' onClick=\"if (this.checked) {document.getElementById('diff2file').style.display='block'} else {document.getElementById('diff2file').style.display='none'};\" id='display_diff2file' checked /> <label for='display_diff2file'>diff from file</label> |
||
160 | <pre id='diff2file' style='display:block;border:1px solid black;'>$diff_from_file4disp</pre> |
||
161 | <input type='checkbox' name='display_diff2default' value='1' onClick=\"if (this.checked) {document.getElementById('diff2default').style.display='block'} else {document.getElementById('diff2default').style.display='none'};\" id='display_diff2default' /> <label for='display_diff2default'>diff from default</label> |
||
162 | <pre id='diff2default' style='display:none;border:1px solid black;'>$diff_from_default4disp</pre> |
||
163 | </form>\n"; |
||
164 | |||
165 | echo " |
||
166 | <form class='apcalForm' id='MainForm' name='MainForm' action='?tpl_file=" . htmlspecialchars($tpl['tpl_file'], ENT_QUOTES) . '&tpl_tplset=' . htmlspecialchars($tpl['tpl_tplset'], ENT_QUOTES) . "' method='post'> |
||
167 | " . $xoopsGTicket->getTicketHtml(__LINE__) . " |
||
168 | <textarea name='tpl_source' wrap='off' style='width:600px;height:400px;'>" . htmlspecialchars($tpl['tpl_source'], ENT_QUOTES) . "</textarea> |
||
169 | <br> |
||
170 | <input type='submit' name='do_modify' value='" . _SUBMIT . "' /> |
||
171 | <input type='reset' name='reset' value='reset' /> |
||
172 | </form>\n"; |
||
173 | |||
174 | xoops_cp_footer(); |
||
175 |
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.