@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | |
| 408 | 408 | /** |
| 409 | 409 | * Creates a seed with microseconds. |
| 410 | - * @return float|int |
|
| 410 | + * @return integer|null |
|
| 411 | 411 | */ |
| 412 | 412 | private static function makeSeed() |
| 413 | 413 | { |
@@ -417,8 +417,8 @@ discard block |
||
| 417 | 417 | |
| 418 | 418 | /** |
| 419 | 419 | * Returns a random number. |
| 420 | - * @param $min |
|
| 421 | - * @param $max |
|
| 420 | + * @param integer $min |
|
| 421 | + * @param integer $max |
|
| 422 | 422 | * @return int |
| 423 | 423 | */ |
| 424 | 424 | public static function createRandomNumber($min, $max) |
@@ -867,10 +867,10 @@ |
||
| 867 | 867 | |
| 868 | 868 | if ($loginExist && ($email == $user->getUserData('email'))) { |
| 869 | 869 | $consonants = array( |
| 870 | - 'b','c','d','f','g','h','j','k','l','m','n','p','r','s','t','v','w','x','y','z', |
|
| 870 | + 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z', |
|
| 871 | 871 | ); |
| 872 | 872 | $vowels = array( |
| 873 | - 'a','e','i','o','u', |
|
| 873 | + 'a', 'e', 'i', 'o', 'u', |
|
| 874 | 874 | ); |
| 875 | 875 | $newPassword = ''; |
| 876 | 876 | for ($i = 1; $i <= 4; ++$i) { |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $leftVarsOnly = array_slice($_SESSION['trans']['leftVarsOnly'], |
| 61 | - ($page - 1) * $itemsPerPage, |
|
| 61 | + ($page - 1)*$itemsPerPage, |
|
| 62 | 62 | $itemsPerPage); |
| 63 | 63 | $rightVarsOnly = &$_SESSION['trans']['rightVarsOnly']; |
| 64 | 64 | |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | foreach ($userList as $single_user) { |
| 67 | 67 | $user->getUserById($single_user, true); |
| 68 | 68 | $users[] = array('user_id' => $user->getUserId(), |
| 69 | - 'login' => $user->getLogin(), ); |
|
| 69 | + 'login' => $user->getLogin(),); |
|
| 70 | 70 | } |
| 71 | 71 | echo json_encode($users); |
| 72 | 72 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | foreach ($memberList as $single_member) { |
| 79 | 79 | $user->getUserById($single_member, true); |
| 80 | 80 | $members[] = array('user_id' => $user->getUserId(), |
| 81 | - 'login' => $user->getLogin(), ); |
|
| 81 | + 'login' => $user->getLogin(),); |
|
| 82 | 82 | } |
| 83 | 83 | echo json_encode($members); |
| 84 | 84 | } |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | case 'upload': |
| 40 | 40 | |
| 41 | - $uploadDir = PMF_ROOT_DIR . '/images/'; |
|
| 41 | + $uploadDir = PMF_ROOT_DIR.'/images/'; |
|
| 42 | 42 | $uploadFile = basename($_FILES['upload']['name']); |
| 43 | 43 | $isUploaded = false; |
| 44 | 44 | $height = $width = 0; |
| 45 | - $validFileExtensions = [ 'gif', 'jpg', 'jpeg', 'png' ]; |
|
| 45 | + $validFileExtensions = ['gif', 'jpg', 'jpeg', 'png']; |
|
| 46 | 46 | |
| 47 | 47 | if ($csrfOkay) { |
| 48 | 48 | if (is_uploaded_file($uploadedFile['tmp_name']) && |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | if ($fileInfo && $isUploaded) { |
| 72 | 72 | list($width, $height) = $fileInfo; |
| 73 | - if (move_uploaded_file($uploadedFile['tmp_name'], $uploadDir . $uploadFile)) { |
|
| 73 | + if (move_uploaded_file($uploadedFile['tmp_name'], $uploadDir.$uploadFile)) { |
|
| 74 | 74 | $isUploaded = true; |
| 75 | 75 | } else { |
| 76 | 76 | $isUploaded = false; |
@@ -238,28 +238,28 @@ |
||
| 238 | 238 | echo intval($retval); |
| 239 | 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 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 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) { |
|
| 48 | + foreach ((array)@$_POST['PMF_LANG'] as $key => $val) { |
|
| 49 | 49 | if (is_string($val)) { |
| 50 | 50 | $val = str_replace(array('\\\\', '\"', '\\\''), array('\\', '"', "'"), $val); |
| 51 | 51 | $val = str_replace("'", "\\'", $val); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - foreach ((array) @$_POST['LANG_CONF'] as $key => $val) { |
|
| 65 | + foreach ((array)@$_POST['LANG_CONF'] as $key => $val) { |
|
| 66 | 66 | // if string like array(blah-blah-blah), extract the contents inside the brackets |
| 67 | 67 | if (preg_match('/^\s*array\s*\(\s*(\d+.+)\s*\).*$/', $val, $matches1)) { |
| 68 | 68 | // split the resulting string of delimiters such as "number =>" |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | $langDir = PMF_Filter::filterInput(INPUT_POST, 'langdir', FILTER_SANITIZE_STRING); |
| 193 | 193 | $langNPlurals = strval(PMF_Filter::filterVar(@$_POST['langnplurals'], FILTER_VALIDATE_INT, -1)); |
| 194 | 194 | $langDesc = PMF_Filter::filterInput(INPUT_POST, 'langdesc', FILTER_SANITIZE_STRING); |
| 195 | - $author = (array) @$_POST['author']; |
|
| 195 | + $author = (array)@$_POST['author']; |
|
| 196 | 196 | |
| 197 | 197 | if (empty($langCode) || empty($langName) || empty($langCharset) || |
| 198 | 198 | empty($langDir) || empty($langDesc) || empty($author)) { |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | $dateEnd = PMF_Filter::filterInput(INPUT_POST, 'dateEnd', FILTER_SANITIZE_STRING); |
| 42 | 42 | $question = PMF_Filter::filterInput(INPUT_POST, 'question', FILTER_SANITIZE_STRING); |
| 43 | 43 | $categories = PMF_Filter::filterInputArray(INPUT_POST, array('rubrik' => array('filter' => FILTER_VALIDATE_INT, |
| 44 | - 'flags' => FILTER_REQUIRE_ARRAY, ))); |
|
| 44 | + 'flags' => FILTER_REQUIRE_ARRAY,))); |
|
| 45 | 45 | $record_lang = PMF_Filter::filterInput(INPUT_POST, 'lang', FILTER_SANITIZE_STRING); |
| 46 | 46 | $tags = PMF_Filter::filterInput(INPUT_POST, 'tags', FILTER_SANITIZE_STRING); |
| 47 | 47 | $active = PMF_Filter::filterInput(INPUT_POST, 'active', FILTER_SANITIZE_STRING); |
@@ -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 | } |
@@ -138,16 +138,16 @@ |
||
| 138 | 138 | return $filename; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Clean the filename of any uploaded file by the user and force an error |
|
| 143 | - * when calling is_uploaded_file($_FILES[key]['tmp_name']) if the cleanup goes wrong. |
|
| 144 | - */ |
|
| 145 | - private static function _cleanFilenames() |
|
| 146 | - { |
|
| 147 | - reset($_FILES); |
|
| 148 | - foreach ($_FILES as $key => $value) { |
|
| 149 | - if (is_array($_FILES[$key]['name'])) { |
|
| 150 | - reset($_FILES[$key]['name']); |
|
| 141 | + /** |
|
| 142 | + * Clean the filename of any uploaded file by the user and force an error |
|
| 143 | + * when calling is_uploaded_file($_FILES[key]['tmp_name']) if the cleanup goes wrong. |
|
| 144 | + */ |
|
| 145 | + private static function _cleanFilenames() |
|
| 146 | + { |
|
| 147 | + reset($_FILES); |
|
| 148 | + foreach ($_FILES as $key => $value) { |
|
| 149 | + if (is_array($_FILES[$key]['name'])) { |
|
| 150 | + reset($_FILES[$key]['name']); |
|
| 151 | 151 | // We have a multiple upload with the same name for <input /> |
| 152 | 152 | while (list($idx, $value2) = each($_FILES[$key]['name'])) { |
| 153 | 153 | $_FILES[$key]['name'][$idx] = self::_basicFilenameClean($_FILES[$key]['name'][$idx]); |