/** * Sends a notification to user who added a question * * @param string $email Email address of the user * @param string $userName Name of the user * @param string $url URL of answered FAQ * * @return void */ public function sendOpenQuestionAnswered($email, $userName, $url) { $this->mail->addTo($email, $userName); $this->mail->subject = $this->config->get('main.titleFAQ') . ' - ' . $this->pmfStr['msgQuestionAnswered']; $this->mail->message = sprintf($this->pmfStr['msgMessageQuestionAnswered'], $this->config->get('main.titleFAQ')) . "\n\r" . $url; $this->mail->send(); }
function sendAskedQuestion($username, $usermail, $usercat, $content) { global $IDN, $category, $PMF_LANG, $faq, $faqconfig; $retval = false; $cat = new PMF_Category(); $categories = $cat->getAllCategories(); if ($faqconfig->get('records.enableVisibilityQuestions')) { $visibility = 'N'; } else { $visibility = 'Y'; } $questionData = array('ask_username' => $username, 'ask_usermail' => $IDN->encode($usermail), 'ask_category' => $usercat, 'ask_content' => $content, 'ask_date' => date('YmdHis'), 'is_visible' => $visibility); list($user, $host) = explode("@", $questionData['ask_usermail']); if (PMF_Filter::filterVar($questionData['ask_usermail'], FILTER_VALIDATE_EMAIL) != false) { $faq->addQuestion($questionData); $questionMail = "User: "******", mailto:" . $questionData['ask_usermail'] . "\n" . $PMF_LANG["msgCategory"] . ": " . $categories[$questionData['ask_category']]["name"] . "\n\n" . wordwrap($content, 72); $userId = $category->getCategoryUser($questionData['ask_category']); $oUser = new PMF_User(); $oUser->getUserById($userId); $userEmail = $oUser->getUserData('email'); $mainAdminEmail = $faqconfig->get('main.administrationMail'); $mail = new PMF_Mail(); $mail->unsetFrom(); $mail->setFrom($questionData['ask_usermail'], $questionData['ask_username']); $mail->addTo($mainAdminEmail); // Let the category owner get a copy of the message if ($userEmail && $mainAdminEmail != $userEmail) { $mail->addCc($userEmail); } $mail->subject = '%sitename%'; $mail->message = $questionMail; $retval = $mail->send(); } return $retval; }
function sendAskedQuestion($username, $usermail, $usercat, $content) { global $PMF_LANG, $faq; $retval = false; $faqconfig = PMF_Configuration::getInstance(); $categoryNode = new PMF_Category_Node(); if ($faqconfig->get('records.enableVisibilityQuestions')) { $visibility = 'N'; } else { $visibility = 'Y'; } $questionData = array('id' => null, 'username' => $username, 'email' => $usermail, 'category_id' => $usercat, 'question' => $content, 'date' => date('YmdHis'), 'is_visible' => $visibility); list($user, $host) = explode("@", $questionData['email']); if (PMF_Filter::filterVar($questionData['email'], FILTER_VALIDATE_EMAIL) != false) { $faqQuestions = new PMF_Faq_Questions(); $faqQuestions->create($questionData); $categoryData = $categoryNode->fetch($questionData['category_id']); $questionMail = "User: "******", mailto:" . $questionData['email'] . "\n" . $PMF_LANG["msgCategory"] . ": " . $categoryData->name . "\n\n" . wordwrap($content, 72); $userId = $categoryData->user_id; $oUser = new PMF_User(); $oUser->getUserById($userId); $userEmail = $oUser->getUserData('email'); $mainAdminEmail = $faqconfig->get('main.administrationMail'); $mail = new PMF_Mail(); $mail->unsetFrom(); $mail->setFrom($questionData['email'], $questionData['username']); $mail->addTo($mainAdminEmail); // Let the category owner get a copy of the message if ($userEmail && $mainAdminEmail != $userEmail) { $mail->addCc($userEmail); } $mail->subject = '%sitename%'; $mail->message = $questionMail; $retval = $mail->send(); } return $retval; }
$urlToContent = $oLink->toString(); } else { $oNews = new PMF_News(); $news = $oNews->getNewsEntry($id); if ($news['authorEmail'] != '') { $emailTo = $news['authorEmail']; } $oLink = new PMF_Link(PMF_Link::getSystemUri() . '?action=news&newsid=' . $news['id'] . '&newslang=' . $news['lang']); $oLink->itemTitle = $news['header']; $urlToContent = $oLink->toString(); } $commentMail = 'User: '******'username'] . ', mailto:' . $commentData['usermail'] . "\n" . 'New comment posted on: ' . $urlToContent . "\n\n" . wordwrap($comment, 72); $mail = new PMF_Mail(); $mail->unsetFrom(); $mail->setFrom($commentData['usermail']); $mail->addTo($emailTo); // Let the category owner get a copy of the message if ($emailTo != $faqconfig->get('main.administrationMail')) { $mail->addCc($faqconfig->get('main.administrationMail')); } $mail->subject = '%sitename%'; $mail->message = strip_tags($commentMail); $result = $mail->send(); unset($mail); $message = $PMF_LANG['msgCommentThanks']; } else { $faqsession->userTracking('error_save_comment', $id); $message = $PMF_LANG['err_SaveComment']; } } else { if (!IPCheck($_SERVER['REMOTE_ADDR'])) {
if (count($messages) == 0) { // Create user account (login and password) // Note: password be automatically generated // and sent by email as soon if admin switch user to "active" if (!$user->createUser($user_name, '')) { $messages[] = $user->error(); } else { // set user data (realname, email) $user->userdata->set(array('display_name', 'email'), array($user_realname, $user_email)); // set user status $user->setStatus($defaultUserStatus); $text = sprintf("New user has been registrated:\n\nUsername: %s\nLoginname: %s\n\n" . "To activate this user do please use the administration interface.", $lastname, $loginname); $mail = new PMF_Mail(); $mail->unsetFrom(); $mail->setFrom($user_email); $mail->addTo($faqconfig->get('main.administrationMail')); $mail->subject = PMF_Utils::resolveMarkers($PMF_LANG['emailRegSubject']); $mail->message = $text; $result = $mail->send(); unset($mail); header("Location: index.php?action=thankyou"); exit; } } // no errors, show list if (count($messages) == 0) { $userAction = $defaultUserAction; // display error messages and show form again } else { $tpl->processTemplate('writeContent', array('regErrors' => sprintf("<strong>%s</strong> <br /> - %s <br /><br />", $PMF_LANG['msgRegError'], implode("<br />- ", $messages)), 'msgUserData' => $PMF_LANG['msgUserData'], 'login_errorRegistration' => !is_null($loginname) ? $PMF_LANG['errorRegistration'] : '', 'name_errorRegistration' => !is_null($lastname) ? $PMF_LANG['errorRegistration'] : '', 'email_errorRegistration' => !is_null($email) ? $PMF_LANG['errorRegistration'] : '', 'loginname' => $PMF_LANG["ad_user_loginname"], 'lastname' => $PMF_LANG["ad_user_realname"], 'email' => $PMF_LANG["ad_entry_email"], 'loginname_value' => $loginname, 'lastname_value' => $lastname, 'email_value' => $email, 'submitRegister' => $PMF_LANG['submitRegister'], 'captchaFieldset' => printCaptchaFieldset($PMF_LANG['msgCaptcha'], $captcha->printCaptcha('add'), $captcha->caplength, isset($captchaError) ? $captchaError : ''))); $tpl->includeTemplate('writeContent', 'index');
break; // Send mails to friends // Send mails to friends case 'sendtofriends': $name = PMF_Filter::filterInput(INPUT_POST, 'name', FILTER_SANITIZE_STRING); $email = PMF_Filter::filterInput(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL); $link = PMF_Filter::filterInput(INPUT_POST, 'link', FILTER_VALIDATE_URL); $attached = PMF_Filter::filterInput(INPUT_POST, 'message', FILTER_SANITIZE_STRIPPED); $mailto = PMF_Filter::filterInputArray(INPUT_POST, array('mailto' => array('filter' => FILTER_VALIDATE_EMAIL, 'flags' => FILTER_REQUIRE_ARRAY | FILTER_NULL_ON_FAILURE))); if (!is_null($name) && !empty($name) && !is_null($email) && !empty($email) && is_array($mailto) && !empty($mailto['mailto'][0]) && checkBannedWord(PMF_String::htmlspecialchars($attached))) { foreach ($mailto['mailto'] as $recipient) { $recipient = trim(strip_tags($recipient)); if (!empty($recipient)) { $mail = new PMF_Mail(); $mail->setReplyTo($email, $name); $mail->addTo($recipient); $mail->subject = $PMF_LANG["msgS2FMailSubject"] . $name; $mail->message = sprintf("%s\r\n\r\n%s\r\n%s\r\n\r\n%s", $faqconfig->get('main.send2friendText'), $PMF_LANG['msgS2FText2'], $link, $attached); // Send the email $result = $mail->send(); unset($mail); usleep(250); } } $message = array('success' => $PMF_LANG['msgS2FThx']); } else { $message = array('error' => $PMF_LANG['err_sendMail']); } break; } print json_encode($message);
$user = new PMF_User(); $user->getUserById($userId); $stats = $user->getStatus(); // set new password an send email if user is switched to active if ($stats == 'blocked' && $userStatus == 'active') { $consonants = array("b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "v", "w", "x", "y", "z"); $vowels = array("a", "e", "i", "o", "u"); $newPassword = ''; srand((double) microtime() * 1000000); for ($i = 1; $i <= 4; $i++) { $newPassword .= $consonants[rand(0, 19)]; $newPassword .= $vowels[rand(0, 4)]; } $user->changePassword($newPassword); $mail = new PMF_Mail(); $mail->addTo($userData['email']); $mail->subject = '[%sitename%] Username / activation'; $mail->message = sprintf("\nUsername: %s\nLoginname: %s\nNew Password: %s\n\n", $userData['display_name'], $user->getLogin(), $newPassword); $result = $mail->send(); unset($mail); } if (!$user->userdata->set(array_keys($userData), array_values($userData)) or !$user->setStatus($userStatus)) { $message .= '<p class="error">' . $errorMessages['updateUser'] . '</p>'; } else { $message .= '<p class="success">' . sprintf($successMessages['updateUser'], $user->getLogin()) . '</p>'; $message .= '<script type="text/javascript">updateUser(' . $userId . ');</script>'; } } } // delete user confirmation if ($userAction == 'delete_confirm') {
if (!is_null($username) && !is_null($email)) { $user = new PMF_User_CurrentUser(); $loginExist = $user->getUserByLogin($username); if ($loginExist && $email == $user->getUserData('email')) { $consonants = array('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'); $vowels = array('a', 'e', 'i', 'o', 'u'); $newPassword = ''; srand((double) microtime() * 1000000); for ($i = 1; $i <= 4; $i++) { $newPassword .= $consonants[rand(0, 19)]; $newPassword .= $vowels[rand(0, 4)]; } $user->changePassword($newPassword); $text = $PMF_LANG['lostpwd_text_1'] . "\nUsername: "******"\nNew Password: "******"\n\n" . $PMF_LANG["lostpwd_text_2"]; $mail = new PMF_Mail(); $mail->addTo($email); $mail->subject = '[%sitename%] Username / password request'; $mail->message = $text; $result = $mail->send(); unset($mail); // Trust that the email has been sent $message = sprintf('<p class="success">%s</p>', $PMF_LANG["lostpwd_mail_okay"]); print "<p><img src=\"images/arrow.gif\" width=\"11\" height=\"11\" alt=\"" . $PMF_LANG["ad"] . "\" border=\"0\" /> <a href=\"index.php\" title=\"" . $PMF_LANG["ad"] . "\">" . $PMF_LANG["ad"] . "</a></p>"; } else { $message = sprintf('<p class="error">%s</p>', $PMF_LANG["lostpwd_err_1"]); } } else { $message = sprintf('<p class="error">%s</p>', $PMF_LANG["lostpwd_err_2"]); } } ?>
\$PMF_LANG['metaCharset'] = '%s'; \$PMF_LANG['metaLanguage'] = '%s'; \$PMF_LANG['language'] = '%s'; \$PMF_LANG['dir'] = '%s'; \$PMF_LANG['nplurals'] = '%s'; FILE; $authorTpl = ''; foreach ($author as $authorData) { $authorTpl .= " * @author {$authorData}\n"; } $fileTpl = sprintf($fileTpl, $langDesc, $authorTpl, date('Y-m-d'), $langCode, date('Y'), $langCharset, strtolower($langCode), $langName, $langDir, $langNPlurals); $retval = @file_put_contents(PMF_ROOT_DIR . '/lang/language_' . strtolower($langCode) . '.php', $fileTpl); $response->setData(intval($retval)); break; case 'send_translated_file': $lang = PMF_Filter::filterInput(INPUT_GET, 'translang', FILTER_SANITIZE_STRING); $filename = PMF_ROOT_DIR . "/lang/language_" . $lang . ".php"; if (!file_exists($filename)) { $response->setData(0); break; } $letterTpl = ''; $mail = new PMF_Mail($faqConfig); $mail->subject = 'New phpMyFAQ language file submitted'; $mail->message = sprintf('The file below was sent by %s, which is using phpMyFAQ %s on %s', $user->userdata->get('email'), $faqConfig->get('main.currentVersion'), $_SERVER['HTTP_HOST']); $mail->addTo('*****@*****.**'); $mail->addAttachment($filename, null, 'text/plain'); $response->setData((int) $mail->send()); break; } $response->send();