@@ -40,167 +40,167 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | switch ($ajax_action) { |
| 42 | 42 | |
| 43 | - case 'save_page_buffer': |
|
| 44 | - /* |
|
| 43 | + case 'save_page_buffer': |
|
| 44 | + /* |
|
| 45 | 45 | * Build language variable definitions |
| 46 | 46 | * @todo Change input handling using PMF_Filter |
| 47 | 47 | */ |
| 48 | - foreach ((array) @$_POST['PMF_LANG'] as $key => $val) { |
|
| 49 | - if (is_string($val)) { |
|
| 50 | - $val = str_replace(array('\\\\', '\"', '\\\''), array('\\', '"', "'"), $val); |
|
| 51 | - $val = str_replace("'", "\\'", $val); |
|
| 52 | - $_SESSION['trans']['rightVarsOnly']["PMF_LANG[$key]"] = $val; |
|
| 53 | - } elseif (is_array($val)) { |
|
| 54 | - /* |
|
| 48 | + foreach ((array) @$_POST['PMF_LANG'] as $key => $val) { |
|
| 49 | + if (is_string($val)) { |
|
| 50 | + $val = str_replace(array('\\\\', '\"', '\\\''), array('\\', '"', "'"), $val); |
|
| 51 | + $val = str_replace("'", "\\'", $val); |
|
| 52 | + $_SESSION['trans']['rightVarsOnly']["PMF_LANG[$key]"] = $val; |
|
| 53 | + } elseif (is_array($val)) { |
|
| 54 | + /* |
|
| 55 | 55 | * Here we deal with a two dimensional array |
| 56 | 56 | */ |
| 57 | - foreach ($val as $key2 => $val2) { |
|
| 58 | - $val2 = str_replace(array('\\\\', '\"', '\\\''), array('\\', '"', "'"), $val2); |
|
| 59 | - $val2 = str_replace("'", "\\'", $val2); |
|
| 60 | - $_SESSION['trans']['rightVarsOnly']["PMF_LANG[$key][$key2]"] = $val2; |
|
| 57 | + foreach ($val as $key2 => $val2) { |
|
| 58 | + $val2 = str_replace(array('\\\\', '\"', '\\\''), array('\\', '"', "'"), $val2); |
|
| 59 | + $val2 = str_replace("'", "\\'", $val2); |
|
| 60 | + $_SESSION['trans']['rightVarsOnly']["PMF_LANG[$key][$key2]"] = $val2; |
|
| 61 | + } |
|
| 61 | 62 | } |
| 62 | 63 | } |
| 63 | - } |
|
| 64 | - |
|
| 65 | - foreach ((array) @$_POST['LANG_CONF'] as $key => $val) { |
|
| 66 | - // if string like array(blah-blah-blah), extract the contents inside the brackets |
|
| 67 | - if (preg_match('/^\s*array\s*\(\s*(\d+.+)\s*\).*$/', $val, $matches1)) { |
|
| 68 | - // split the resulting string of delimiters such as "number =>" |
|
| 69 | - $valArr = preg_split( |
|
| 70 | - '/\s*(\d+)\s*\=\>\s*/', |
|
| 71 | - $matches1[1], |
|
| 72 | - null, |
|
| 73 | - PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY |
|
| 74 | - ); |
|
| 75 | - $numVal = count($valArr); |
|
| 76 | - if ($numVal > 1) { |
|
| 77 | - $newValArr = []; |
|
| 78 | - for ($i = 0; $i < $numVal; $i += 2) { |
|
| 79 | - if (is_numeric($valArr[$i])) { |
|
| 80 | - // clearing quotes |
|
| 81 | - if (preg_match('/^\s*\\\\*[\"|\'](.+)\\\\*[\"|\'][\s\,]*$/', $valArr[$i + 1], $matches2)) { |
|
| 82 | - $subVal = $matches2[1]; |
|
| 83 | - // normalize quotes |
|
| 84 | - $subVal = str_replace(array('\\\\', '\"', '\\\''), array('\\', '"', "'"), $subVal); |
|
| 85 | - $subVal = str_replace("'", "\\'", $subVal); |
|
| 86 | - // assembly of the original substring back |
|
| 87 | - $newValArr[] = $valArr[$i].' => \''.$subVal.'\''; |
|
| 64 | + |
|
| 65 | + foreach ((array) @$_POST['LANG_CONF'] as $key => $val) { |
|
| 66 | + // if string like array(blah-blah-blah), extract the contents inside the brackets |
|
| 67 | + if (preg_match('/^\s*array\s*\(\s*(\d+.+)\s*\).*$/', $val, $matches1)) { |
|
| 68 | + // split the resulting string of delimiters such as "number =>" |
|
| 69 | + $valArr = preg_split( |
|
| 70 | + '/\s*(\d+)\s*\=\>\s*/', |
|
| 71 | + $matches1[1], |
|
| 72 | + null, |
|
| 73 | + PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY |
|
| 74 | + ); |
|
| 75 | + $numVal = count($valArr); |
|
| 76 | + if ($numVal > 1) { |
|
| 77 | + $newValArr = []; |
|
| 78 | + for ($i = 0; $i < $numVal; $i += 2) { |
|
| 79 | + if (is_numeric($valArr[$i])) { |
|
| 80 | + // clearing quotes |
|
| 81 | + if (preg_match('/^\s*\\\\*[\"|\'](.+)\\\\*[\"|\'][\s\,]*$/', $valArr[$i + 1], $matches2)) { |
|
| 82 | + $subVal = $matches2[1]; |
|
| 83 | + // normalize quotes |
|
| 84 | + $subVal = str_replace(array('\\\\', '\"', '\\\''), array('\\', '"', "'"), $subVal); |
|
| 85 | + $subVal = str_replace("'", "\\'", $subVal); |
|
| 86 | + // assembly of the original substring back |
|
| 87 | + $newValArr[] = $valArr[$i].' => \''.$subVal.'\''; |
|
| 88 | + } |
|
| 88 | 89 | } |
| 89 | 90 | } |
| 91 | + $_SESSION['trans']['rightVarsOnly']["LANG_CONF[$key]"] = 'array('.implode(', ', $newValArr).')'; |
|
| 90 | 92 | } |
| 91 | - $_SESSION['trans']['rightVarsOnly']["LANG_CONF[$key]"] = 'array('.implode(', ', $newValArr).')'; |
|
| 93 | + } else { // compatibility for old behavior |
|
| 94 | + $val = str_replace(array('\\\\', '\"', '\\\''), array('\\', '"', "'"), $val); |
|
| 95 | + $val = str_replace("'", "\\'", $val); |
|
| 96 | + $_SESSION['trans']['rightVarsOnly']["LANG_CONF[$key]"] = $val; |
|
| 92 | 97 | } |
| 93 | - } else { // compatibility for old behavior |
|
| 94 | - $val = str_replace(array('\\\\', '\"', '\\\''), array('\\', '"', "'"), $val); |
|
| 95 | - $val = str_replace("'", "\\'", $val); |
|
| 96 | - $_SESSION['trans']['rightVarsOnly']["LANG_CONF[$key]"] = $val; |
|
| 97 | 98 | } |
| 98 | - } |
|
| 99 | 99 | |
| 100 | - echo 1; |
|
| 101 | - break; |
|
| 100 | + echo 1; |
|
| 101 | + break; |
|
| 102 | 102 | |
| 103 | - case 'save_translated_lang': |
|
| 104 | - |
|
| 105 | - if (!$user->perm->checkRight($user->getUserId(), 'edittranslation')) { |
|
| 106 | - echo $PMF_LANG['err_NotAuth']; |
|
| 107 | - exit; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - $lang = strtolower($_SESSION['trans']['rightVarsOnly']['PMF_LANG[metaLanguage]']); |
|
| 111 | - $filename = PMF_ROOT_DIR.'/lang/language_'.$lang.'.php'; |
|
| 112 | - |
|
| 113 | - if (!is_writable(PMF_ROOT_DIR.'/lang')) { |
|
| 114 | - echo 0; |
|
| 115 | - exit; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - if (!copy($filename, PMF_ROOT_DIR.'/lang/language_'.$lang.'.bak.php')) { |
|
| 119 | - echo 0; |
|
| 120 | - exit; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $newFileContents = ''; |
|
| 124 | - $tmpLines = []; |
|
| 125 | - |
|
| 126 | - // Read in the head of the file we're writing to |
|
| 127 | - $fh = fopen($filename, 'r'); |
|
| 128 | - do { |
|
| 129 | - $line = fgets($fh); |
|
| 130 | - array_push($tmpLines, rtrim($line)); |
|
| 131 | - } while ('*/' != substr(trim($line), -2)); |
|
| 132 | - fclose($fh); |
|
| 133 | - |
|
| 134 | - // Construct lines with variable definitions |
|
| 135 | - foreach ($_SESSION['trans']['rightVarsOnly'] as $key => $val) { |
|
| 136 | - if (0 === strpos($key, 'PMF_LANG')) { |
|
| 137 | - $val = "'$val'"; |
|
| 103 | + case 'save_translated_lang': |
|
| 104 | + |
|
| 105 | + if (!$user->perm->checkRight($user->getUserId(), 'edittranslation')) { |
|
| 106 | + echo $PMF_LANG['err_NotAuth']; |
|
| 107 | + exit; |
|
| 138 | 108 | } |
| 139 | - array_push($tmpLines, '$'.str_replace(array('[', ']'), array("['", "']"), $key)." = $val;"); |
|
| 140 | - } |
|
| 141 | 109 | |
| 142 | - $newFileContents .= implode("\n", $tmpLines); |
|
| 110 | + $lang = strtolower($_SESSION['trans']['rightVarsOnly']['PMF_LANG[metaLanguage]']); |
|
| 111 | + $filename = PMF_ROOT_DIR.'/lang/language_'.$lang.'.php'; |
|
| 143 | 112 | |
| 144 | - unset($_SESSION['trans']); |
|
| 113 | + if (!is_writable(PMF_ROOT_DIR.'/lang')) { |
|
| 114 | + echo 0; |
|
| 115 | + exit; |
|
| 116 | + } |
|
| 145 | 117 | |
| 146 | - $retval = file_put_contents($filename, $newFileContents); |
|
| 147 | - echo intval($retval); |
|
| 148 | - break; |
|
| 118 | + if (!copy($filename, PMF_ROOT_DIR.'/lang/language_'.$lang.'.bak.php')) { |
|
| 119 | + echo 0; |
|
| 120 | + exit; |
|
| 121 | + } |
|
| 149 | 122 | |
| 150 | - case 'remove_lang_file': |
|
| 123 | + $newFileContents = ''; |
|
| 124 | + $tmpLines = []; |
|
| 125 | + |
|
| 126 | + // Read in the head of the file we're writing to |
|
| 127 | + $fh = fopen($filename, 'r'); |
|
| 128 | + do { |
|
| 129 | + $line = fgets($fh); |
|
| 130 | + array_push($tmpLines, rtrim($line)); |
|
| 131 | + } while ('*/' != substr(trim($line), -2)); |
|
| 132 | + fclose($fh); |
|
| 133 | + |
|
| 134 | + // Construct lines with variable definitions |
|
| 135 | + foreach ($_SESSION['trans']['rightVarsOnly'] as $key => $val) { |
|
| 136 | + if (0 === strpos($key, 'PMF_LANG')) { |
|
| 137 | + $val = "'$val'"; |
|
| 138 | + } |
|
| 139 | + array_push($tmpLines, '$'.str_replace(array('[', ']'), array("['", "']"), $key)." = $val;"); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $newFileContents .= implode("\n", $tmpLines); |
|
| 151 | 143 | |
| 152 | - if (!$user->perm->checkRight($user->getUserId(), 'deltranslation')) { |
|
| 153 | - echo $PMF_LANG['err_NotAuth']; |
|
| 154 | - exit; |
|
| 155 | - } |
|
| 144 | + unset($_SESSION['trans']); |
|
| 156 | 145 | |
| 157 | - $lang = PMF_Filter::filterInput(INPUT_GET, 'translang', FILTER_SANITIZE_STRING); |
|
| 146 | + $retval = file_put_contents($filename, $newFileContents); |
|
| 147 | + echo intval($retval); |
|
| 148 | + break; |
|
| 158 | 149 | |
| 159 | - if (!is_writable(PMF_ROOT_DIR.'/lang')) { |
|
| 160 | - echo 0; |
|
| 161 | - exit; |
|
| 162 | - } |
|
| 150 | + case 'remove_lang_file': |
|
| 163 | 151 | |
| 164 | - if (!copy(PMF_ROOT_DIR."/lang/language_$lang.php", PMF_ROOT_DIR."/lang/language_$lang.bak.php")) { |
|
| 165 | - echo 0; |
|
| 166 | - exit; |
|
| 167 | - } |
|
| 152 | + if (!$user->perm->checkRight($user->getUserId(), 'deltranslation')) { |
|
| 153 | + echo $PMF_LANG['err_NotAuth']; |
|
| 154 | + exit; |
|
| 155 | + } |
|
| 168 | 156 | |
| 169 | - if (!unlink(PMF_ROOT_DIR."/lang/language_$lang.php")) { |
|
| 170 | - echo 0; |
|
| 171 | - exit; |
|
| 172 | - } |
|
| 157 | + $lang = PMF_Filter::filterInput(INPUT_GET, 'translang', FILTER_SANITIZE_STRING); |
|
| 173 | 158 | |
| 174 | - echo 1; |
|
| 175 | - break; |
|
| 159 | + if (!is_writable(PMF_ROOT_DIR.'/lang')) { |
|
| 160 | + echo 0; |
|
| 161 | + exit; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + if (!copy(PMF_ROOT_DIR."/lang/language_$lang.php", PMF_ROOT_DIR."/lang/language_$lang.bak.php")) { |
|
| 165 | + echo 0; |
|
| 166 | + exit; |
|
| 167 | + } |
|
| 176 | 168 | |
| 177 | - case 'save_added_trans': |
|
| 178 | - |
|
| 179 | - if (!$user->perm->checkRight($user->getUserId(), 'addtranslation')) { |
|
| 180 | - echo $PMF_LANG['err_NotAuth']; |
|
| 181 | - exit; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - if (!is_writable(PMF_ROOT_DIR.'/lang')) { |
|
| 185 | - echo 0; |
|
| 186 | - exit; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - $langCode = PMF_Filter::filterInput(INPUT_POST, 'translang', FILTER_SANITIZE_STRING); |
|
| 190 | - $langName = @$languageCodes[$langCode]; |
|
| 191 | - $langCharset = 'UTF-8'; |
|
| 192 | - $langDir = PMF_Filter::filterInput(INPUT_POST, 'langdir', FILTER_SANITIZE_STRING); |
|
| 193 | - $langNPlurals = strval(PMF_Filter::filterVar(@$_POST['langnplurals'], FILTER_VALIDATE_INT, -1)); |
|
| 194 | - $langDesc = PMF_Filter::filterInput(INPUT_POST, 'langdesc', FILTER_SANITIZE_STRING); |
|
| 195 | - $author = (array) @$_POST['author']; |
|
| 196 | - |
|
| 197 | - if (empty($langCode) || empty($langName) || empty($langCharset) || |
|
| 198 | - empty($langDir) || empty($langDesc) || empty($author)) { |
|
| 199 | - echo 0; |
|
| 200 | - exit; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - $fileTpl = <<<FILE |
|
| 169 | + if (!unlink(PMF_ROOT_DIR."/lang/language_$lang.php")) { |
|
| 170 | + echo 0; |
|
| 171 | + exit; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + echo 1; |
|
| 175 | + break; |
|
| 176 | + |
|
| 177 | + case 'save_added_trans': |
|
| 178 | + |
|
| 179 | + if (!$user->perm->checkRight($user->getUserId(), 'addtranslation')) { |
|
| 180 | + echo $PMF_LANG['err_NotAuth']; |
|
| 181 | + exit; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + if (!is_writable(PMF_ROOT_DIR.'/lang')) { |
|
| 185 | + echo 0; |
|
| 186 | + exit; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + $langCode = PMF_Filter::filterInput(INPUT_POST, 'translang', FILTER_SANITIZE_STRING); |
|
| 190 | + $langName = @$languageCodes[$langCode]; |
|
| 191 | + $langCharset = 'UTF-8'; |
|
| 192 | + $langDir = PMF_Filter::filterInput(INPUT_POST, 'langdir', FILTER_SANITIZE_STRING); |
|
| 193 | + $langNPlurals = strval(PMF_Filter::filterVar(@$_POST['langnplurals'], FILTER_VALIDATE_INT, -1)); |
|
| 194 | + $langDesc = PMF_Filter::filterInput(INPUT_POST, 'langdesc', FILTER_SANITIZE_STRING); |
|
| 195 | + $author = (array) @$_POST['author']; |
|
| 196 | + |
|
| 197 | + if (empty($langCode) || empty($langName) || empty($langCharset) || |
|
| 198 | + empty($langDir) || empty($langDesc) || empty($author)) { |
|
| 199 | + echo 0; |
|
| 200 | + exit; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + $fileTpl = <<<FILE |
|
| 204 | 204 | <?php |
| 205 | 205 | /** |
| 206 | 206 | * %s |
@@ -226,40 +226,40 @@ discard block |
||
| 226 | 226 | \$PMF_LANG['nplurals'] = '%s'; |
| 227 | 227 | FILE; |
| 228 | 228 | |
| 229 | - $authorTpl = ''; |
|
| 230 | - foreach ($author as $authorData) { |
|
| 231 | - $authorTpl .= " * @author $authorData\n"; |
|
| 232 | - } |
|
| 229 | + $authorTpl = ''; |
|
| 230 | + foreach ($author as $authorData) { |
|
| 231 | + $authorTpl .= " * @author $authorData\n"; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - $fileTpl = sprintf($fileTpl, $langDesc, $authorTpl, date('Y-m-d'), $langCode, date('Y'), |
|
| 235 | - $langCharset, strtolower($langCode), $langName, $langDir, $langNPlurals); |
|
| 234 | + $fileTpl = sprintf($fileTpl, $langDesc, $authorTpl, date('Y-m-d'), $langCode, date('Y'), |
|
| 235 | + $langCharset, strtolower($langCode), $langName, $langDir, $langNPlurals); |
|
| 236 | 236 | |
| 237 | - $retval = @file_put_contents(PMF_ROOT_DIR.'/lang/language_'.strtolower($langCode).'.php', $fileTpl); |
|
| 238 | - echo intval($retval); |
|
| 239 | - break; |
|
| 237 | + $retval = @file_put_contents(PMF_ROOT_DIR.'/lang/language_'.strtolower($langCode).'.php', $fileTpl); |
|
| 238 | + echo intval($retval); |
|
| 239 | + break; |
|
| 240 | 240 | |
| 241 | - case 'send_translated_file': |
|
| 241 | + case 'send_translated_file': |
|
| 242 | 242 | |
| 243 | - $lang = PMF_Filter::filterInput(INPUT_GET, 'translang', FILTER_SANITIZE_STRING); |
|
| 244 | - $filename = PMF_ROOT_DIR.'/lang/language_'.$lang.'.php'; |
|
| 243 | + $lang = PMF_Filter::filterInput(INPUT_GET, 'translang', FILTER_SANITIZE_STRING); |
|
| 244 | + $filename = PMF_ROOT_DIR.'/lang/language_'.$lang.'.php'; |
|
| 245 | 245 | |
| 246 | - if (!file_exists($filename)) { |
|
| 247 | - echo 0; |
|
| 248 | - exit; |
|
| 249 | - } |
|
| 246 | + if (!file_exists($filename)) { |
|
| 247 | + echo 0; |
|
| 248 | + exit; |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - $letterTpl = ''; |
|
| 251 | + $letterTpl = ''; |
|
| 252 | 252 | |
| 253 | - $mail = new PMF_Mail($faqConfig); |
|
| 254 | - $mail->subject = 'New phpMyFAQ language file submitted'; |
|
| 255 | - $mail->message = sprintf('The file below was sent by %s, which is using phpMyFAQ %s on %s', |
|
| 256 | - $user->userdata->get('email'), |
|
| 257 | - $faqConfig->get('main.currentVersion'), |
|
| 258 | - $_SERVER['HTTP_HOST']); |
|
| 253 | + $mail = new PMF_Mail($faqConfig); |
|
| 254 | + $mail->subject = 'New phpMyFAQ language file submitted'; |
|
| 255 | + $mail->message = sprintf('The file below was sent by %s, which is using phpMyFAQ %s on %s', |
|
| 256 | + $user->userdata->get('email'), |
|
| 257 | + $faqConfig->get('main.currentVersion'), |
|
| 258 | + $_SERVER['HTTP_HOST']); |
|
| 259 | 259 | |
| 260 | - $mail->addTo('[email protected]'); |
|
| 261 | - $mail->addAttachment($filename, null, 'text/plain'); |
|
| 260 | + $mail->addTo('[email protected]'); |
|
| 261 | + $mail->addAttachment($filename, null, 'text/plain'); |
|
| 262 | 262 | |
| 263 | - echo (int) $mail->send(); |
|
| 264 | - break; |
|
| 263 | + echo (int) $mail->send(); |
|
| 264 | + break; |
|
| 265 | 265 | } |
@@ -48,98 +48,98 @@ |
||
| 48 | 48 | switch ($ajax_action) { |
| 49 | 49 | |
| 50 | 50 | // save active FAQs |
| 51 | - case 'save_active_records': |
|
| 52 | - if ($user->perm->checkRight($user->getUserId(), 'approverec')) { |
|
| 53 | - if (!empty($items)) { |
|
| 54 | - $faq = new PMF_Faq($faqConfig); |
|
| 55 | - |
|
| 56 | - foreach ($items as $item) { |
|
| 57 | - if (is_array($item) && count($item) == 3 && PMF_Language::isASupportedLanguage($item[1])) { |
|
| 58 | - echo $faq->updateRecordFlag((int) $item[0], addslashes($item[1]), $item[2], 'active'); |
|
| 51 | + case 'save_active_records': |
|
| 52 | + if ($user->perm->checkRight($user->getUserId(), 'approverec')) { |
|
| 53 | + if (!empty($items)) { |
|
| 54 | + $faq = new PMF_Faq($faqConfig); |
|
| 55 | + |
|
| 56 | + foreach ($items as $item) { |
|
| 57 | + if (is_array($item) && count($item) == 3 && PMF_Language::isASupportedLanguage($item[1])) { |
|
| 58 | + echo $faq->updateRecordFlag((int) $item[0], addslashes($item[1]), $item[2], 'active'); |
|
| 59 | + } |
|
| 59 | 60 | } |
| 60 | 61 | } |
| 62 | + } else { |
|
| 63 | + echo $PMF_LANG['err_NotAuth']; |
|
| 61 | 64 | } |
| 62 | - } else { |
|
| 63 | - echo $PMF_LANG['err_NotAuth']; |
|
| 64 | - } |
|
| 65 | - break; |
|
| 66 | - |
|
| 67 | - // save sticky FAQs |
|
| 68 | - case 'save_sticky_records': |
|
| 69 | - if ($user->perm->checkRight($user->getUserId(), 'editbt')) { |
|
| 70 | - if (!empty($items)) { |
|
| 71 | - $faq = new PMF_Faq($faqConfig); |
|
| 72 | - |
|
| 73 | - foreach ($items as $item) { |
|
| 74 | - if (is_array($item) && count($item) == 3 && PMF_Language::isASupportedLanguage($item[1])) { |
|
| 75 | - echo $faq->updateRecordFlag((int) $item[0], addslashes($item[1]), $item[2], 'sticky'); |
|
| 65 | + break; |
|
| 66 | + |
|
| 67 | + // save sticky FAQs |
|
| 68 | + case 'save_sticky_records': |
|
| 69 | + if ($user->perm->checkRight($user->getUserId(), 'editbt')) { |
|
| 70 | + if (!empty($items)) { |
|
| 71 | + $faq = new PMF_Faq($faqConfig); |
|
| 72 | + |
|
| 73 | + foreach ($items as $item) { |
|
| 74 | + if (is_array($item) && count($item) == 3 && PMF_Language::isASupportedLanguage($item[1])) { |
|
| 75 | + echo $faq->updateRecordFlag((int) $item[0], addslashes($item[1]), $item[2], 'sticky'); |
|
| 76 | + } |
|
| 76 | 77 | } |
| 77 | 78 | } |
| 79 | + } else { |
|
| 80 | + echo $PMF_LANG['err_NotAuth']; |
|
| 78 | 81 | } |
| 79 | - } else { |
|
| 80 | - echo $PMF_LANG['err_NotAuth']; |
|
| 81 | - } |
|
| 82 | - break; |
|
| 82 | + break; |
|
| 83 | 83 | |
| 84 | - // search FAQs for suggestions |
|
| 85 | - case 'search_records': |
|
| 86 | - if ($user->perm->checkRight($user->getUserId(), 'editbt')) { |
|
| 87 | - $faq = new PMF_Faq($faqConfig); |
|
| 88 | - $faqSearch = new PMF_Search($faqConfig); |
|
| 89 | - $faqSearch->setCategory(new PMF_Category($faqConfig)); |
|
| 90 | - $faqSearchResult = new PMF_Search_Resultset($user, $faq, $faqConfig); |
|
| 91 | - $searchResult = ''; |
|
| 92 | - $searchString = PMF_Filter::filterInput(INPUT_POST, 'search', FILTER_SANITIZE_STRIPPED); |
|
| 84 | + // search FAQs for suggestions |
|
| 85 | + case 'search_records': |
|
| 86 | + if ($user->perm->checkRight($user->getUserId(), 'editbt')) { |
|
| 87 | + $faq = new PMF_Faq($faqConfig); |
|
| 88 | + $faqSearch = new PMF_Search($faqConfig); |
|
| 89 | + $faqSearch->setCategory(new PMF_Category($faqConfig)); |
|
| 90 | + $faqSearchResult = new PMF_Search_Resultset($user, $faq, $faqConfig); |
|
| 91 | + $searchResult = ''; |
|
| 92 | + $searchString = PMF_Filter::filterInput(INPUT_POST, 'search', FILTER_SANITIZE_STRIPPED); |
|
| 93 | 93 | |
| 94 | - if (!is_null($searchString)) { |
|
| 94 | + if (!is_null($searchString)) { |
|
| 95 | 95 | |
| 96 | - $searchResult = $faqSearch->search($searchString, false); |
|
| 96 | + $searchResult = $faqSearch->search($searchString, false); |
|
| 97 | 97 | |
| 98 | - $faqSearchResult->reviewResultset($searchResult); |
|
| 98 | + $faqSearchResult->reviewResultset($searchResult); |
|
| 99 | 99 | |
| 100 | - $searchHelper = new PMF_Helper_Search($faqConfig); |
|
| 101 | - $searchHelper->setSearchterm($searchString); |
|
| 100 | + $searchHelper = new PMF_Helper_Search($faqConfig); |
|
| 101 | + $searchHelper->setSearchterm($searchString); |
|
| 102 | 102 | |
| 103 | - echo $searchHelper->renderAdminSuggestionResult($faqSearchResult); |
|
| 103 | + echo $searchHelper->renderAdminSuggestionResult($faqSearchResult); |
|
| 104 | + } |
|
| 105 | + } else { |
|
| 106 | + echo $PMF_LANG['err_NotAuth']; |
|
| 104 | 107 | } |
| 105 | - } else { |
|
| 106 | - echo $PMF_LANG['err_NotAuth']; |
|
| 107 | - } |
|
| 108 | - break; |
|
| 109 | - |
|
| 110 | - // delete FAQs |
|
| 111 | - case 'delete_record': |
|
| 112 | - if ($user->perm->checkRight($user->getUserId(), 'delbt')) { |
|
| 113 | - $recordId = PMF_Filter::filterInput(INPUT_POST, 'record_id', FILTER_VALIDATE_INT); |
|
| 114 | - $recordLang = PMF_Filter::filterInput(INPUT_POST, 'record_lang', FILTER_SANITIZE_STRING); |
|
| 115 | - |
|
| 116 | - $logging = new PMF_Logging($faqConfig); |
|
| 117 | - $logging->logAdmin($user, 'Deleted FAQ ID '.$recordId); |
|
| 118 | - |
|
| 119 | - $faq->deleteRecord($recordId, $recordLang); |
|
| 120 | - echo $PMF_LANG['ad_entry_delsuc']; |
|
| 121 | - } else { |
|
| 122 | - echo $PMF_LANG['err_NotAuth']; |
|
| 123 | - } |
|
| 124 | - break; |
|
| 125 | - |
|
| 126 | - // delete open questions |
|
| 127 | - case 'delete_question': |
|
| 128 | - if ($user->perm->checkRight($user->getUserId(), 'delquestion')) { |
|
| 129 | - $checks = array( |
|
| 130 | - 'filter' => FILTER_VALIDATE_INT, |
|
| 131 | - 'flags' => FILTER_REQUIRE_ARRAY, |
|
| 132 | - ); |
|
| 133 | - $questionIds = PMF_Filter::filterInputArray(INPUT_POST, array('questions' => $checks)); |
|
| 134 | - |
|
| 135 | - if (!is_null($questionIds['questions'])) { |
|
| 136 | - foreach ($questionIds['questions'] as $questionId) { |
|
| 137 | - $faq->deleteQuestion((int) $questionId); |
|
| 108 | + break; |
|
| 109 | + |
|
| 110 | + // delete FAQs |
|
| 111 | + case 'delete_record': |
|
| 112 | + if ($user->perm->checkRight($user->getUserId(), 'delbt')) { |
|
| 113 | + $recordId = PMF_Filter::filterInput(INPUT_POST, 'record_id', FILTER_VALIDATE_INT); |
|
| 114 | + $recordLang = PMF_Filter::filterInput(INPUT_POST, 'record_lang', FILTER_SANITIZE_STRING); |
|
| 115 | + |
|
| 116 | + $logging = new PMF_Logging($faqConfig); |
|
| 117 | + $logging->logAdmin($user, 'Deleted FAQ ID '.$recordId); |
|
| 118 | + |
|
| 119 | + $faq->deleteRecord($recordId, $recordLang); |
|
| 120 | + echo $PMF_LANG['ad_entry_delsuc']; |
|
| 121 | + } else { |
|
| 122 | + echo $PMF_LANG['err_NotAuth']; |
|
| 123 | + } |
|
| 124 | + break; |
|
| 125 | + |
|
| 126 | + // delete open questions |
|
| 127 | + case 'delete_question': |
|
| 128 | + if ($user->perm->checkRight($user->getUserId(), 'delquestion')) { |
|
| 129 | + $checks = array( |
|
| 130 | + 'filter' => FILTER_VALIDATE_INT, |
|
| 131 | + 'flags' => FILTER_REQUIRE_ARRAY, |
|
| 132 | + ); |
|
| 133 | + $questionIds = PMF_Filter::filterInputArray(INPUT_POST, array('questions' => $checks)); |
|
| 134 | + |
|
| 135 | + if (!is_null($questionIds['questions'])) { |
|
| 136 | + foreach ($questionIds['questions'] as $questionId) { |
|
| 137 | + $faq->deleteQuestion((int) $questionId); |
|
| 138 | + } |
|
| 138 | 139 | } |
| 140 | + echo $PMF_LANG['ad_entry_delsuc']; |
|
| 141 | + } else { |
|
| 142 | + echo $PMF_LANG['err_NotAuth']; |
|
| 139 | 143 | } |
| 140 | - echo $PMF_LANG['ad_entry_delsuc']; |
|
| 141 | - } else { |
|
| 142 | - echo $PMF_LANG['err_NotAuth']; |
|
| 143 | - } |
|
| 144 | - break; |
|
| 144 | + break; |
|
| 145 | 145 | } |
@@ -36,47 +36,47 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | switch ($ajaxAction) { |
| 38 | 38 | |
| 39 | - case 'upload': |
|
| 39 | + case 'upload': |
|
| 40 | 40 | |
| 41 | - $uploadDir = PMF_ROOT_DIR . '/images/'; |
|
| 42 | - $uploadFile = basename($_FILES['upload']['name']); |
|
| 43 | - $isUploaded = false; |
|
| 44 | - $height = $width = 0; |
|
| 45 | - $validFileExtensions = [ 'gif', 'jpg', 'jpeg', 'png' ]; |
|
| 41 | + $uploadDir = PMF_ROOT_DIR . '/images/'; |
|
| 42 | + $uploadFile = basename($_FILES['upload']['name']); |
|
| 43 | + $isUploaded = false; |
|
| 44 | + $height = $width = 0; |
|
| 45 | + $validFileExtensions = [ 'gif', 'jpg', 'jpeg', 'png' ]; |
|
| 46 | 46 | |
| 47 | - if ($csrfOkay) { |
|
| 48 | - if (is_uploaded_file($uploadedFile['tmp_name']) && |
|
| 49 | - $uploadedFile['size'] < $faqConfig->get('records.maxAttachmentSize') |
|
| 50 | - ) { |
|
| 47 | + if ($csrfOkay) { |
|
| 48 | + if (is_uploaded_file($uploadedFile['tmp_name']) && |
|
| 49 | + $uploadedFile['size'] < $faqConfig->get('records.maxAttachmentSize') |
|
| 50 | + ) { |
|
| 51 | 51 | |
| 52 | - $fileInfo = getimagesize($uploadedFile['tmp_name']); |
|
| 53 | - $fileExtension = pathinfo($uploadFile, PATHINFO_EXTENSION);; |
|
| 52 | + $fileInfo = getimagesize($uploadedFile['tmp_name']); |
|
| 53 | + $fileExtension = pathinfo($uploadFile, PATHINFO_EXTENSION);; |
|
| 54 | 54 | |
| 55 | - if (false === $fileInfo) { |
|
| 56 | - $isUploaded = false; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - if (($fileInfo[2] !== IMAGETYPE_GIF) && |
|
| 60 | - ($fileInfo[2] !== IMAGETYPE_JPEG) && |
|
| 61 | - ($fileInfo[2] !== IMAGETYPE_PNG)) { |
|
| 62 | - $isUploaded = false; |
|
| 63 | - } else { |
|
| 64 | - $isUploaded = true; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - if (!in_array($fileExtension, $validFileExtensions)) { |
|
| 68 | - $isUploaded = false; |
|
| 69 | - } |
|
| 55 | + if (false === $fileInfo) { |
|
| 56 | + $isUploaded = false; |
|
| 57 | + } |
|
| 70 | 58 | |
| 71 | - if ($fileInfo && $isUploaded) { |
|
| 72 | - list($width, $height) = $fileInfo; |
|
| 73 | - if (move_uploaded_file($uploadedFile['tmp_name'], $uploadDir . $uploadFile)) { |
|
| 74 | - $isUploaded = true; |
|
| 59 | + if (($fileInfo[2] !== IMAGETYPE_GIF) && |
|
| 60 | + ($fileInfo[2] !== IMAGETYPE_JPEG) && |
|
| 61 | + ($fileInfo[2] !== IMAGETYPE_PNG)) { |
|
| 62 | + $isUploaded = false; |
|
| 75 | 63 | } else { |
| 64 | + $isUploaded = true; |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + if (!in_array($fileExtension, $validFileExtensions)) { |
|
| 76 | 68 | $isUploaded = false; |
| 77 | 69 | } |
| 78 | - } |
|
| 79 | - ?> |
|
| 70 | + |
|
| 71 | + if ($fileInfo && $isUploaded) { |
|
| 72 | + list($width, $height) = $fileInfo; |
|
| 73 | + if (move_uploaded_file($uploadedFile['tmp_name'], $uploadDir . $uploadFile)) { |
|
| 74 | + $isUploaded = true; |
|
| 75 | + } else { |
|
| 76 | + $isUploaded = false; |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | + ?> |
|
| 80 | 80 | <script> |
| 81 | 81 | window.parent.window.pmfImageUpload.uploadFinished({ |
| 82 | 82 | filename: '<?php echo $faqConfig->getDefaultUrl() . 'images/' . $uploadFile ?>', |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | }); |
| 88 | 88 | </script> |
| 89 | 89 | <?php |
| 90 | - } else { |
|
| 91 | - ?> |
|
| 90 | + } else { |
|
| 91 | + ?> |
|
| 92 | 92 | <script> |
| 93 | 93 | window.parent.window.pmfImageUpload.uploadFinished({ |
| 94 | 94 | filename: '', |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | }); |
| 100 | 100 | </script> |
| 101 | 101 | <?php |
| 102 | - } |
|
| 103 | - } else { |
|
| 104 | - ?> |
|
| 102 | + } |
|
| 103 | + } else { |
|
| 104 | + ?> |
|
| 105 | 105 | <script> |
| 106 | 106 | window.parent.window.pmfImageUpload.uploadFinished({ |
| 107 | 107 | filename: '', |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | }); |
| 113 | 113 | </script> |
| 114 | 114 | <?php |
| 115 | - } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - break; |
|
| 117 | + break; |
|
| 118 | 118 | } |
| 119 | 119 | \ No newline at end of file |