/** * Get valid hash for maintenance mode * * @return string */ static function getValidHash() { return saltedHash("md5", __FILE__); }
/** * Get value from cache * null returned if key not found * * @param string $key The cache key * @return mixed|false False if key not found OR value is false */ public function get($key) { $key = saltedHash("crc32b", $key); return $this->memcache->get($key); }
function requestRegisterAuthentication($username, $email, $password, $ipaddr) { $user = new User(); $user->username = $username; $user->passwd = saltedHash($password, $username); $user->name = $email; $user->gender = "Unknown"; $user->phone = "XXX-XXX-XXXX"; $user->email = $email; $user->admin = "0"; $user->pic = "./images/default.jpg"; $user->bio = "Tell us something about yourself!"; addPendingUser($user, $ipaddr); }
/** * Check if password match with the stored one * * @param string $password * @return bool */ public function passwordMatch($password) { return $this->password === saltedHash("sha512", $this->salt . $password); }
$newPW = $_POST['newPassword']; $confirmPW = $_POST['confirmPassword']; $ip = $_SERVER['REMOTE_ADDR']; if (!empty($oldPW) && !empty($newPW) && !empty($confirmPW)) { //TODO: Check that old password is correct, and make sure newPW and // confirmPW match before changing password, also check that IP matches the DB if (saltedHash($oldPW, $username) != getUser($username)->passwd) { $error .= "Old password is incorrect. "; } else { if ($newPW != $confirmPW) { $error .= "Confirmed password does not match entered password. "; } else { if ($ip != getPWchangeIP($username)) { $error .= "You must change your password from the IP address you requested from. "; } else { changePassword($_POST['username'], saltedHash($newPW, $username)); echo "<p>Your password has been changed successfully. Please logout and log back in using your new password.</p>"; } } } } else { $error .= "Please make sure all fields are complete before submitting. "; } ?> <?php } else { if (!empty($_GET['username']) && !empty($_GET['key'])) { ?> <!-- FORM TO CHANGE PASSWORD:
/** * Get content */ public function getContent() { headline(t("rss.1")); echo t("rss.2") . '<div class="spacer"></div>'; headline(t("rss.3")); $categories = user()->getCategories(); $i = 1; foreach ($categories as $category) { $feeds = $category->feeds; ?> <div class="category" style="margin-bottom: 10px;"> <div class="inner"> <div class="title" data-category="<?php echo $category->getId(); ?> " data-feed="0"> <input type="checkbox" class="cat" checked="checked"/> <b><?php echo s($category->name); ?> </b> </div> <?php if ($feeds) { foreach ($feeds as $feed) { ?> <div class="feed" data-category="<?php echo $category->getId(); ?> " data-feed="<?php echo $feed->getId(); ?> " style="margin-left: 10px; font-size: 12px;"> <input type="checkbox" class="feed" checked="checked" value="<?php echo $feed->getId(); ?> "/> <?php echo s($feed->getCustomName($category)); ?> </div> <?php } } ?> </div> </div> <?php } $table = new Form_Table($this->getForm()); $table->addButton(t("rss.9"), array("onclick" => "checkSubmit()")); echo $table->getHtml(); ?> <script type="text/javascript"> function checkSubmit(){ var formtable = $("#form-rss").parent().data("formtable"); if(formtable.validateAllFields()){ var ids = []; $("input.feed:checked").each(function(){ ids.push(this.value); }); window.open('<?php echo url()->getModifiedUri(false); ?> ?f='+ids.join(",")+"&token=<?php echo user()->getId() . "." . saltedHash("sha256", user()->getId()); ?> &title="+encodeURIComponent($("input[name='title']").val())+"&desc="+encodeURIComponent($("input[name='desc']").val())+"&max="+encodeURIComponent($("input[name='max']").val())+"&catmax="+encodeURIComponent($("input[name='catmax']").val())+"&feedmax="+encodeURIComponent($("input[name='feedmax']").val())); } } $("input.cat").on("click", function(){ $(this).parent().parent().find("input.feed").prop("checked", this.checked); }); </script> <?php }
/** * Get a hashed index name * * @param array $parts * @return string */ public function getIndexName(array $parts) { return "i" . saltedHash("crc32b", implode("-", $parts)); }
*/ $error = ""; if (isset($_POST['username'])) { if (isPendingUser($_POST['username'])) { $error = "Sorry, you are still a pending user. You may not login."; } else { $uname = sanitize($_POST['username']); $pass = ""; if (isset($_POST['enteredPassword'])) { $pass = $_POST['enteredPassword']; } // authentication $users = readUsers(); foreach ($users as $user) { if ($user->username == $uname) { if (saltedHash($pass, $uname) == $user->passwd) { // authentication successful! $_SESSION['username'] = $uname; $success = "User {$uname} logged in successfully!"; } else { $error = "Invalid password for user {$uname}. Try again."; } break; } } if (empty($error)) { $error = "User {$uname} does not exist."; } } } if (isset($_POST['logOutFlag'])) {