static function deleteVariable($app, $variableId) { if (!v::intVal()->validate($variableId)) { return $app->render(400, array('msg' => 'Could not find system config variable.')); } $savedConfig = ConfigData::getVariableById($variableId); if ($savedConfig && ($savedConfig->locked || $savedConfig->indestructible)) { return $app->render(400, array('msg' => 'This config variable is locked or indestructible and cannot deleted without special permissions.')); } if (ConfigData::deleteVariable($variableId)) { return $app->render(200, array('msg' => 'System config variable has been deleted.')); } else { return $app->render(400, array('msg' => 'Could not delete system config variable. Check your parameters and try again.')); } }
private static function forgotpassword_validateFoundUser($post, $app) { $user = AuthData::selectUserAndPasswordByEmail($post['email']); if (!$user) { // Validate existing user return array('frgtauthenticated' => false, 'msg' => 'Forgotpassword failed. A user with that email could not be found.'); } $usertoken = md5(date('Y-m-d H:i:s') * rand(9, 99999)); $fortgotpassword_duration = date('Y-m-d H:i:s'); $userforgotupdate = AuthData::updateforgotpassworddata(array(':email' => $post['email'], ':usertoken' => $usertoken, ':fortgotpassword_duration' => $fortgotpassword_duration)); $mail = new \PHPMailer(); $mail->IsSMTP(); $mail_variables = array("SMTP_SERVER_HOST" => "Host", "SMTP_SERVER_PORT" => "Port", "SMTP_SERVER_USERNAME" => "Username", "SMTP_SERVER_PASSWORD" => "Password", "SMTP_SMTP_DEBUG" => 'SMTPDebug', "SMTP_DEBUGOUTPUT" => 'Debugoutput', "SMTP_SECURE" => "SMTPSecure", "SMTP_AUTH" => "SMTPAuth", "PASSWORD_RESET_EMAIL_FROM" => "From", "PASSWORD_RESET_EMAIL_SUBJECT" => "Subject", "PASSWORD_RESET_EMAIL_BODY" => "Body"); foreach ($mail_variables as $name => $value) { $config_data = ConfigData::getVariableByName($name); if ($config_data && $config_data->disabled != 1) { $mail->{$value} = $config_data->value; } } $config_data = ConfigData::getVariableByName("PASSWORD_RESET_ROOT_URL"); $root_url = $config_data->value == '' ? ApiConfig::get('WEBSITE_URL') : $config_data->value; $mail->setFrom($mail->From, 'Triviajoint'); $mail->addAddress($user->email, $user->nameFirst . " " . $user->nameLast); $mail->isHTML(true); $fields = array("!@FIRSTNAME@!", "!@LASTNAME@!", '!@WEBSITEURL@!', '!@LINKID@!'); $values = array($user->nameFirst, $user->nameLast, $root_url, $usertoken); $mail->Body = str_replace($fields, $values, $mail->Body); if (!$mail->send()) { return array('frgtauthenticated' => false, 'msg' => 'Email could not be sent for reset password. Please try again later.'); } else { return array('frgtauthenticated' => true, 'msg' => 'Email has been sent to your email address for reset password.'); } }