public function resetPassword($username, $link) { $newHash = PasswordHelper::getInstance()->createUniqueHash(); $admin = GenericDatabaseService::getInstance()->getSingle(new UserModel(), array("Username" => $username)); if ($admin instanceof UserModel) { $admin->setAuthHash($newHash); GenericDatabaseService::getInstance()->update($admin, array("Id", "AuthHash")); return EmailService::getInstance()->sendEmailFromServer(LocaleService::getInstance()->translate("password reset"), LocaleService::getInstance()->translate("your password was reset. click following link to set a new one: "), LocaleService::getInstance()->translate("your password ")); } return false; }
public function sendEmailFromServer($subject, $message, $emails, $names = '', $attachments = null, $ccEmails = null, $ccNames = null) { $mail = new PHPMailer(); $mail->CharSet = 'utf-8'; $mail->setLanguage(LocaleService::getInstance()->getActiveLang()->getName()); $mail->isSMTP(); $mail->Host = $this->getConfig("ServerHost"); $mail->SMTPAuth = true; $mail->Username = $this->getConfig("ServerUsername"); $mail->Password = $this->getConfig("ServerPassword"); $mail->SMTPSecure = $this->getConfig("ServerSecure"); $mail->Port = $this->getConfig("ServerPort"); $mail->From = $this->getConfig("SenderEmail"); $mail->FromName = $this->getConfig("SenderName"); if (!is_array($emails)) { $mail->addAddress($emails, $names); } else { for ($i = 0; $i < count($emails); $i++) { if (is_array($names) && count($names) > $i) { $mail->addAddress($emails[$i], $names[$i]); } else { $mail->addAddress($emails[$i]); } } } if ($ccEmails != null) { if (!is_array($ccEmails)) { $mail->addAddress($ccEmails, $names); } else { for ($i = 0; $i < count($ccEmails); $i++) { if (is_array($names) && count($names) > $i) { $mail->addAddress($ccEmails[$i], $names[$i]); } else { $mail->addAddress($ccEmails[$i]); } } } } $mail->addReplyTo($this->getConfig("RespondToEmail"), $this->getConfig("RespondToName")); if ($attachments != null) { for ($i = 0; $i < count($attachments); $i++) { $mail->addAttachment($attachments[$i]); } } $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = nl2br($message); $mail->AltBody = $message; if ($mail->send()) { return true; } LogHelper::getInstance()->logError($mail->ErrorInfo); return false; }
/** * Methode zum Anzeigen des Contents. * * @return String Content der Applikation. */ public function Display() { $view = new GenericView("import"); if (count($this->params) > 0) { if ($this->params[0] == "upload") { $fileType = FileHelper::getInstance()->getFileTypeUploadedFile('importfile'); $filePath = $_SERVER['DOCUMENT_ROOT'] . "/import/" . uniqid() . "." . $fileType; $resp = FileHelper::getInstance()->saveUploadedFile('importfile', $filePath); if ($resp !== true) { LogHelper::getInstance()->logError(FileHelper::getInstance()->evaluateFailure($resp)); } else { $resp = DatabaseService::getInstance()->importDatabase($filePath); if ($resp == true) { LogHelper::getInstance()->logUserInfo(LocaleService::getInstance()->getResources()->getKey("SUCCESS_GENERAL")); } else { LogHelper::getInstance()->logError(DatabaseService::getInstance()->evaluateError($resp)); } } } } return $this->returnView($view); }
protected function returnSuccess($code = ControllerBase::SUCCESS_GENERAL, $message = "") { if ($message == "") { if ($code == ControllerBase::SUCCESS_CREATED) { LogHelper::getInstance()->logUserInfo(LocaleService::getInstance()->getResources()->getKey("SUCCESS_CREATED")); } else { if ($code == ControllerBase::SUCCESS_UPDATED) { LogHelper::getInstance()->logUserInfo(LocaleService::getInstance()->getResources()->getKey("SUCCESS_UPDATED")); } else { if ($code == ControllerBase::SUCCESS_DELETED) { LogHelper::getInstance()->logUserInfo(LocaleService::getInstance()->getResources()->getKey("SUCCESS_DELETED")); } else { if ($code == ControllerBase::SUCCESS_GENERAL) { LogHelper::getInstance()->logUserInfo(LocaleService::getInstance()->getResources()->getKey("SUCCESS_GENERAL")); } else { LogHelper::getInstance()->logError("Unknown returnSuccess const!"); } } } } } $view = new MessageView(); return $this->returnView($view); }
$model = $this->retrieve("model"); if ($model instanceof LoginDatabaseModel) { ?> <?php echo PartHelper::getInstance()->getFormStart(); ?> <p><?php echo LocaleService::getInstance()->translate("Willkommen"); ?> <?php echo $model->getPersonalIdentification(); ?> , <?php echo LocaleService::getInstance()->translate("bitte legen Sie ihr\n Passwort fest"); ?> </p> <?php echo PartHelper::getInstance()->getHiddenInput($model, "AuthHash"); ?> <?php echo PartHelper::getInstance()->getInput($model, "Password", "password", "password"); ?> <br/> <?php echo PartHelper::getInstance()->getInput($model, "ConfirmPassword", "confirm password", "password"); ?> <br/>
use famoser\phpFrame\Interfaces\Models\IDatabaseModel; use famoser\phpFrame\Interfaces\Models\IModel; use famoser\phpFrame\Models\Database\BaseDatabaseModel; use famoser\phpFrame\Services\LocaleService; use famoser\phpFrame\Views\ViewBase; ?> <?php echo PartHelper::getInstance()->getFormStart(); ?> <?php if ($this instanceof ViewBase) { ?> <p><?php echo LocaleService::getInstance()->translate("Are you sure you want to delete this"); ?> ? <?php foreach ($this->getViewModels() as $viewModel) { $model = $this->retrieve($viewModel->getSingleListName()); if ($model instanceof BaseDatabaseModel) { ?> <p><?php echo $model->getIdentification(); ?> </p> <?php }
* Created by PhpStorm. * User: famoser * Date: 19.02.2016 * Time: 13:54 */ use famoser\phpFrame\Helpers\PartHelper; use famoser\phpFrame\Models\Database\BaseDatabaseModel; use famoser\phpFrame\Services\LocaleService; use famoser\phpFrame\Views\ViewBase; if ($this instanceof ViewBase) { foreach ($this->getViewModels() as $viewModel) { $model = $this->retrieve($viewModel->getSingleListName()); if ($model instanceof BaseDatabaseModel) { ?> <p><?php echo LocaleService::getInstance()->translate("View"); ?> <b><?php echo $model->getIdentification(); ?> </b></p> <?php echo PartHelper::getInstance()->readDatabaseProperties($model, $this); ?> <?php } } }
* Created by PhpStorm. * User: Florian Moser * Date: 24.05.2015 * Time: 10:15 */ use famoser\phpFrame\Helpers\PartHelper; use famoser\phpFrame\Services\LocaleService; use famoser\phpFrame\Views\MessageView; if ($this instanceof MessageView) { ?> <?php $this->includeFile(PartHelper::getInstance()->getPart(PartHelper::PART_HEADER_CENTER)); ?> <div class="clearfix"> <?php $this->includeFile(PartHelper::getInstance()->getPart(PartHelper::PART_MESSAGES)); ?> <?php if ($this->showLink()) { ?> <a href="/"><?php echo LocaleService::getInstance()->translate("back to frontpage"); ?> </a> <?php } ?> </div> <?php $this->includeFile(PartHelper::getInstance()->getPart(PartHelper::PART_FOOTER_CENTER)); }
use famoser\phpFrame\Views\ViewBase; ?> <?php echo PartHelper::getInstance()->getFormStart(); ?> <?php if ($this instanceof ViewBase) { foreach ($this->getViewModels() as $viewModel) { $model = $this->retrieve($viewModel->getSingleListName()); if ($model instanceof BaseDatabaseModel) { ?> <p><?php echo LocaleService::getInstance()->translate("Edit"); ?> <b><?php echo $model->getIdentification(); ?> </b></p> <?php echo PartHelper::getInstance()->editDatabaseProperties($model, $this); ?> <?php } } } ?>
*/ use famoser\phpFrame\Helpers\PartHelper; use famoser\phpFrame\Models\Database\LoginDatabaseModel; use famoser\phpFrame\Services\LocaleService; use famoser\phpFrame\Views\ViewBase; if ($this instanceof ViewBase) { $model = $this->tryRetrieve("model"); if ($model instanceof LoginDatabaseModel) { ?> <?php echo PartHelper::getInstance()->getFormStart(); ?> <p><?php echo LocaleService::getInstance()->translate("Geben Sie Ihre E-Mail an, mit der Sie hier registriert sind.\n Sofern diese E-Mail im System gefunden wird, bekommen Sie eine Email zugesendet mit Informationen, wie Sie das Passwort zurücksetzten können"); ?> </p> <?php echo PartHelper::getInstance()->getInput($model, "Username", "Email", "email"); ?> <br/> <?php echo PartHelper::getInstance()->getSubmit("send mail"); ?> <?php echo PartHelper::getInstance()->getFormEnd(false); ?>
public function Display() { $user = $this->authService->getUser(); if ($user !== false) { $this->exitWithControllerRedirect($this->loggedInRedirect); } if (count($this->params) == 0) { $view = new GenericCenterView("LoginController", "login", null, true); return $this->returnView($view); } else { if (count($this->params) > 0) { if ($this->params[0] == "login") { if (isset($this->request["login"]) && $this->request["login"] == "true") { //fill object ReflectionHelper::getInstance()->writeFromPostArrayToObjectProperties($this->instance, $this->request); $admin = GenericDatabaseService::getInstance()->getSingle($this->instance, array("Username" => $this->instance->getEmail()), true); if ($admin instanceof LoginDatabaseModel && PasswordHelper::getInstance()->validatePasswort($this->instance->getPassword(), $admin->getPasswordHash())) { AuthenticationService::getInstance()->setUser($admin); $this->exitWithRedirect($this->loggedInRedirect); } else { LogHelper::getInstance()->logUserError("login unsuccessful!"); $this->instance->setPassword(""); } } $view = new GenericCenterView("LoginController", "login", null, true); $view->assign("model", $this->instance); return $this->returnView($view); } else { if ($this->params[0] == "logout") { $this->authService->setUser(null); $this->exitWithControllerRedirect("/"); } else { return parent::Display(); } } } else { if (count($this->params) > 1) { if ($this->params[0] == "activateAccount" && PasswordHelper::getInstance()->checkIfHashIsValid($this->params[1])) { $admin = GenericDatabaseService::getInstance()->getSingle($this->instance, array("AuthHash" => $this->params[1]), true); if ($admin instanceof LoginDatabaseModel) { if (isset($this->request["activateAccount"]) && $this->request["activateAccount"] == true) { ReflectionHelper::getInstance()->writeFromPostArrayToObjectProperties($this->request, $admin); if ($this->canSetPassword($admin)) { $admin->setPasswordHash(PasswordHelper::getInstance()->convertToPasswordHash($admin->getPassword())); $admin->setAuthHash(""); GenericDatabaseService::getInstance()->update($admin, array("Id", "AuthHash", "PasswordHash")); } } $view = new GenericCenterView("LoginController", "addpass", null, true); return $this->returnView($view); } else { LogHelper::getInstance()->logUserInfo("link not valid anymore"); $view = new GenericCenterView("LoginController", "login", null, true); return $this->returnView($view); } } else { if ($this->params[0] == "forgotpass") { if (isset($this->request["forgotpass"]) && $this->request["forgotpass"] == "true") { $newHash = PasswordHelper::getInstance()->createUniqueHash(); $admin = GenericDatabaseService::getInstance()->getSingle($this->instance, array("Username" => $this->request["Username"])); if ($admin instanceof LoginDatabaseModel) { $admin->setAuthHash($newHash); GenericDatabaseService::getInstance()->update($admin, array("Id", "AuthHash")); return EmailService::getInstance()->sendEmailFromServer(LocaleService::getInstance()->translate("password reset"), LocaleService::getInstance()->translate("your password was reset. click following link to set a new one: " . RuntimeService::getInstance()->getRouteUrl() . "/activateAccount/" . $newHash), $admin->getAuthHash()); } LogHelper::getInstance()->logUserInfo("you will be contacted by us per email."); } $view = new GenericCenterView("LoginController", "forgotpass", null, true); return $this->returnView($view); } } } } } return parent::Display(); }
use famoser\phpFrame\Views\ViewBase; ?> <?php echo PartHelper::getInstance()->getFormStart(); ?> <?php if ($this instanceof ViewBase) { foreach ($this->getViewModels() as $viewModel) { $model = $this->retrieve($viewModel->getSingleListName()); if ($model instanceof BaseDatabaseModel) { ?> <p><?php echo LocaleService::getInstance()->translate("Create"); ?> <b><?php echo $model->getIdentification(); ?> </b></p> <?php echo PartHelper::getInstance()->editDatabaseProperties($model, $this); ?> <?php } } } ?>
echo PartHelper::getInstance()->getFormStart("login", false); ?> <?php echo PartHelper::getInstance()->getInput($model, "Username", "Email", "email"); ?> <br/> <?php echo PartHelper::getInstance()->getInput($model, "Password", "Password", "password"); ?> <br/> <p> <a href="<?php echo RouteService::getInstance()->getAbsoluteLink("forgotpass"); ?> "><?php echo LocaleService::getInstance()->translate("forgot password"); ?> </a> </p> <?php echo PartHelper::getInstance()->getSubmit("Login"); ?> <?php echo PartHelper::getInstance()->getFormEnd(false); ?> <?php }
public function __construct() { $this->formats = LocaleService::getInstance()->getFormats(); $this->resources = LocaleService::getInstance()->getResources(); }