mambax7 /
avaman
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 | * Avaman module |
||
| 14 | * |
||
| 15 | * @copyright XOOPS Project (http://xoops.org) |
||
| 16 | * @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License} |
||
| 17 | * @package Avaman |
||
| 18 | * @since 2.5.0 |
||
| 19 | * @author GIJOE |
||
| 20 | */ |
||
| 21 | |||
| 22 | $avaman_allowed_exts = array( |
||
| 23 | 'gif' => 'image/gif', |
||
| 24 | 'jpg' => 'image/jpeg', |
||
| 25 | 'jpeg' => 'image/jpeg', |
||
| 26 | 'png' => 'image/png' |
||
| 27 | ); |
||
| 28 | $realmyname = 'smilies.php'; |
||
| 29 | |||
| 30 | include_once dirname(dirname(dirname(__DIR__))) . '/include/cp_header.php'; |
||
| 31 | include_once dirname(__DIR__) . '/include/gtickets.php'; |
||
| 32 | include_once __DIR__ . '/admin_header.php'; |
||
| 33 | $indexAdmin = new ModuleAdmin(); |
||
| 34 | |||
| 35 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 36 | $myts = MyTextSanitizer::getInstance(); |
||
| 37 | |||
| 38 | // |
||
| 39 | // POST Stage |
||
| 40 | // |
||
| 41 | |||
| 42 | if (!empty($_POST['modify_smilies'])) { |
||
| 43 | |||
| 44 | // Ticket Check |
||
| 45 | if (!$xoopsGTicket->check()) { |
||
| 46 | redirect_header(XOOPS_URL . '/', 3, $xoopsGTicket->getErrors()); |
||
| 47 | } |
||
| 48 | |||
| 49 | // rename emotion |
||
| 50 | $smiles_ids = array(); |
||
| 51 | View Code Duplication | if (is_array(@$_POST['emotions'])) { |
|
| 52 | foreach ($_POST['emotions'] as $smiles_id => $emotion) { |
||
| 53 | $smiles_id = (int)$smiles_id; |
||
| 54 | $db->query('UPDATE ' . $db->prefix('smiles') . " SET emotion='" . $myts->addSlashes($emotion) . "' WHERE id=" . (int)$smiles_id); |
||
| 55 | $smiles_ids[] = $smiles_id; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | |||
| 59 | // code |
||
| 60 | foreach ($smiles_ids as $smiles_id) { |
||
| 61 | $db->query('UPDATE ' . $db->prefix('smiles') . " SET code='" . $myts->addSlashes(@$_POST['codes'][$smiles_id]) . "' WHERE id=$smiles_id"); |
||
| 62 | } |
||
| 63 | |||
| 64 | // display |
||
| 65 | View Code Duplication | foreach ($smiles_ids as $smiles_id) { |
|
| 66 | if (empty($_POST['displays'][$smiles_id])) { |
||
| 67 | $db->query('UPDATE ' . $db->prefix('smiles') . " SET display=0 WHERE id=$smiles_id"); |
||
| 68 | } else { |
||
| 69 | $db->query('UPDATE ' . $db->prefix('smiles') . " SET display=1 WHERE id=$smiles_id"); |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | // delete |
||
| 74 | foreach ($smiles_ids as $smiles_id) { |
||
| 75 | if (!empty($_POST['deletes'][$smiles_id])) { |
||
| 76 | $result = $db->query('SELECT smile_url FROM ' . $db->prefix('smiles') . " WHERE id=$smiles_id"); |
||
| 77 | View Code Duplication | if ($result) { |
|
| 78 | list($file) = $db->fetchRow($result); |
||
| 79 | if (false !== strpos($file, '..')) { |
||
| 80 | die('.. found.'); |
||
| 81 | } |
||
| 82 | @unlink(XOOPS_UPLOAD_PATH . '/' . $file); |
||
| 83 | $db->query('DELETE FROM ' . $db->prefix('smiles') . " WHERE id=$smiles_id"); |
||
| 84 | } |
||
| 85 | } |
||
| 86 | } |
||
| 87 | |||
| 88 | redirect_header($realmyname, 2, _AM_AVAMAN_DBUPDATED); |
||
| 89 | exit; |
||
| 90 | } |
||
| 91 | |||
| 92 | // ARCHIVE UPLOAD |
||
| 93 | if (!empty($_FILES['upload_archive']['tmp_name']) && is_uploaded_file($_FILES['upload_archive']['tmp_name'])) { |
||
| 94 | |||
| 95 | // extract stage |
||
| 96 | $orig_filename4check = strtolower($_FILES['upload_archive']['name']); |
||
| 97 | $orig_ext4check = substr($orig_filename4check, strrpos($orig_filename4check, '.') + 1); |
||
| 98 | View Code Duplication | if ($orig_ext4check === 'zip') { |
|
| 99 | |||
| 100 | // zip |
||
| 101 | include_once dirname(__DIR__) . '/include/Archive_Zip.php'; |
||
| 102 | $reader = new Archive_Zip($_FILES['upload_archive']['tmp_name']); |
||
| 103 | $files = $reader->extract(array('extract_as_string' => true)); |
||
|
0 ignored issues
–
show
|
|||
| 104 | if (!is_array(@$files)) { |
||
| 105 | die($reader->errorName()); |
||
| 106 | } |
||
| 107 | } elseif ($orig_ext4check === 'tar' || $orig_ext4check === 'tgz' || $orig_ext4check === 'gz') { |
||
| 108 | |||
| 109 | // tar or tgz or tar.gz |
||
| 110 | include_once XOOPS_ROOT_PATH . '/class/class.tar.php'; |
||
| 111 | $tar = new tar(); |
||
| 112 | $tar->openTAR($_FILES['upload_archive']['tmp_name']); |
||
| 113 | $files = array(); |
||
| 114 | foreach ($tar->files as $id => $info) { |
||
| 115 | $files[] = array( |
||
| 116 | 'filename' => $info['name'], |
||
| 117 | 'mtime' => $info['time'], |
||
| 118 | 'content' => $info['file'] |
||
| 119 | ); |
||
| 120 | } |
||
| 121 | if (empty($files)) { |
||
| 122 | die(_AM_AVAMAN_ERR_INVALIDARCHIVE); |
||
| 123 | } |
||
| 124 | } elseif (!empty($avaman_allowed_exts[$orig_ext4check])) { |
||
| 125 | |||
| 126 | // a single image file |
||
| 127 | $files = array(); |
||
| 128 | $files[] = array( |
||
| 129 | 'filename' => $_FILES['upload_archive']['name'], |
||
| 130 | 'mtime' => time(), |
||
| 131 | 'content' => function_exists('file_get_contents') ? file_get_contents($_FILES['upload_archive']['tmp_name']) : implode(file($_FILES['upload_archive']['tmp_name'])) |
||
| 132 | ); |
||
| 133 | } else { |
||
| 134 | die(_AM_AVAMAN_INVALIDEXT); |
||
| 135 | } |
||
| 136 | |||
| 137 | // import stage |
||
| 138 | $imported = 0; |
||
| 139 | foreach ($files as $file) { |
||
| 140 | if (!empty($file['folder'])) { |
||
| 141 | continue; |
||
| 142 | } |
||
| 143 | $file_pos = strrpos($file['filename'], '/'); |
||
| 144 | $file_name = $file_pos === false ? $file['filename'] : substr($file['filename'], $file_pos + 1); |
||
| 145 | $ext_pos = strrpos($file_name, '.'); |
||
| 146 | if ($ext_pos === false) { |
||
| 147 | continue; |
||
| 148 | } |
||
| 149 | $ext = strtolower(substr($file_name, $ext_pos + 1)); |
||
| 150 | if (empty($avaman_allowed_exts[$ext])) { |
||
| 151 | continue; |
||
| 152 | } |
||
| 153 | $file_node = substr($file_name, 0, $ext_pos); |
||
| 154 | $save_file_name = uniqid('smil') . '.' . $ext; |
||
| 155 | $fw = fopen(XOOPS_UPLOAD_PATH . '/' . $save_file_name, 'w'); |
||
| 156 | if (!$fw) { |
||
| 157 | continue; |
||
| 158 | } |
||
| 159 | @fwrite($fw, $file['content']); |
||
| 160 | @fclose($fw); |
||
| 161 | $db->query('INSERT INTO ' . $db->prefix('smiles') . " SET smile_url='" . addslashes($save_file_name) . "', code='" . addslashes(rawurldecode($file_node)) . "', display=0, emotion=''"); |
||
| 162 | |||
| 163 | ++$imported; |
||
| 164 | } |
||
| 165 | |||
| 166 | redirect_header($realmyname, 3, sprintf(_AM_AVAMAN_FILEUPLOADED, $imported)); |
||
| 167 | exit; |
||
| 168 | } |
||
| 169 | |||
| 170 | // Form Stage |
||
| 171 | xoops_cp_header(); |
||
| 172 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
||
| 173 | |||
| 174 | //include(__DIR__.'/mymenu.php'); |
||
| 175 | |||
| 176 | $sql = 'SELECT id , code , smile_url , emotion , display FROM ' . $db->prefix('smiles') . ' ORDER BY id'; |
||
| 177 | $result = $db->query($sql); |
||
| 178 | |||
| 179 | echo " |
||
| 180 | <form action='$realmyname' id='avaman_upload' method='post' enctype='multipart/form-data' class='odd'> |
||
| 181 | <label for='upload_archive'>" . _AM_AVAMAN_UPLOAD . "</label> |
||
| 182 | <br> |
||
| 183 | <input type='file' id='upload_archive' name='upload_archive' size='60' /> |
||
| 184 | <input type='submit' value='" . _SUBMIT . "' /> |
||
| 185 | </form> |
||
| 186 | <form action='$realmyname' name='avaman_list' id='avaman_list' method='post'> |
||
| 187 | <table class='outer' id='avaman_main'> |
||
| 188 | <tr> |
||
| 189 | <th>" . _AM_AVAMAN_TH_ID . '</th> |
||
| 190 | <th>' . _AM_AVAMAN_TH_FILE . '</th> |
||
| 191 | <th>' . _AM_AVAMAN_TH_CODE . '</th> |
||
| 192 | <th>' . _AM_AVAMAN_TH_EMOTION . '</th> |
||
| 193 | <th>' . _AM_AVAMAN_TH_SMILEDISPLAY . '</th> |
||
| 194 | <th>' . _AM_AVAMAN_TH_DELETE . "<input type='checkbox' name='selectall' onclick=\"with(document.avaman_list){for (i=0;i<length;i++) {if(elements[i].type=='checkbox'&&elements[i].disabled==false&&elements[i].name.indexOf('deletes')>=0) {elements[i].checked=this.checked;}}}\" title='" |
||
| 195 | . _AM_AVAMAN_CB_SELECTALL . "' /></th> |
||
| 196 | </tr>\n"; |
||
| 197 | |||
| 198 | while (list($smiles_id, $code, $file, $emotion, $display) = $db->fetchRow($result)) { |
||
| 199 | $evenodd = @$evenodd === 'even' ? 'odd' : 'even'; |
||
| 200 | |||
| 201 | echo " |
||
| 202 | <tr> |
||
| 203 | <td class='$evenodd' align='center'>$smiles_id</td> |
||
| 204 | <td class='$evenodd' align='center'><img src='" . XOOPS_UPLOAD_URL . '/' . $file . "' alt='' /></td> |
||
| 205 | <td class='$evenodd' align='center'><input type='text' size='12' name='codes[$smiles_id]' value='" . htmlspecialchars($code, ENT_QUOTES) . "' /></td> |
||
| 206 | <td class='$evenodd' align='center'><input type='text' size='24' name='emotions[$smiles_id]' value='" . htmlspecialchars($emotion, ENT_QUOTES) . "' /></td> |
||
| 207 | <td class='$evenodd' align='center'><input type='checkbox' name='displays[$smiles_id]' " . ($display ? "checked='checked'" : '') . " /></td> |
||
| 208 | <td class='$evenodd' align='center'><input type='checkbox' name='deletes[$smiles_id]' /></td> |
||
| 209 | </tr>\n"; |
||
| 210 | } |
||
| 211 | echo " |
||
| 212 | </table> |
||
| 213 | <input type='submit' name='modify_smilies' value='" . _SUBMIT . "' /> |
||
| 214 | " . $xoopsGTicket->getTicketHtml(__LINE__) . ' |
||
| 215 | </form> |
||
| 216 | '; |
||
| 217 | |||
| 218 | include_once __DIR__ . '/admin_footer.php'; |
||
| 219 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: