本文整理汇总了PHP中get_hash函数的典型用法代码示例。如果您正苦于以下问题:PHP get_hash函数的具体用法?PHP get_hash怎么用?PHP get_hash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_hash函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: api_login
public function api_login()
{
//почта
$mail = isset($this->request->data['mail']) ? $this->request->data['mail'] : null;
//пароль
$password = isset($this->request->data['password']) ? $this->request->data['password'] : null;
if ($password == null or $mail == null) {
$status = 'error';
response_ajax(array('error' => 'password_invalid'), $status);
exit;
}
if ($mail == null) {
$status = 'error';
response_ajax(array('error' => 'mail_invalid'), $status);
exit;
}
$hashed_pass = get_hash(Configure::read('USER_AUTH_SALT'), $password);
$check_user = $this->User->find('count', array('conditions' => array('password' => $hashed_pass, 'mail' => $mail)));
if ($check_user > 0) {
//удачная авторизация
$this->Session->write('User', $mail);
$user_id_data = $this->User->find('first', array('conditions' => array('mail' => $mail)));
$user_id = $user_id_data['User']['id'];
$this->loadModel('Userauth');
$auth_data = array('user_id' => $user_id, 'ip' => get_ip(), 'browser' => get_ua(), 'os' => get_os());
$this->Userauth->save($auth_data);
$this->Session->write('user_id', $user_id);
$status = 'success';
response_ajax(array('result' => 'login'), $status);
} else {
$status = 'error';
response_ajax(array('error' => 'user_not_found'), $status);
}
exit;
}
示例2: gen_pass_hash
function gen_pass_hash($pass)
{
$salt = base64_encode(rand(1, 1000000) + microtime());
$hash_schema = get_hash();
$pass_hash = crypt($pass, $hash_schema . $salt . '$');
return $pass_hash;
}
示例3: save
public function save()
{
$id = isset($this->request->data['Admin']['id']) ? $this->request->data['Admin']['id'] : null;
$this->loadModel('Admin');
if ($id !== null and is_numeric($id)) {
$admin = $this->Admin->find('first', array('conditions' => array('id' => $id)));
if ($admin == null) {
//!!!!
$this->Error->setError('ERROR_201');
} else {
$this->Admin->save($this->request->data);
}
} else {
//добавление нового администратора
$pass = md5(time() . Configure::read('ADMIN_AUTH_SALT'));
$pass = substr($pass, 0, 8);
$pass_hash = get_hash(Configure::read('ADMIN_AUTH_SALT'), $pass);
//$mail_key
$mail_key = md5(Configure::read('ADMIN_AUTH_SALT') . time());
$save_array = $this->request->data;
$save_array['Admin']['password'] = $pass_hash;
$save_array['Admin']['mail_key'] = $mail_key;
$this->Admin->save($save_array);
$id = $this->Admin->getLastInsertId();
//pr($this->request->data);
if (is_numeric($id)) {
App::uses('CakeEmail', 'Network/Email');
//$this->Email->smtpOptions = Configure::read('SMTP_CONFIG');
// $this->Email->from = Configure::read('SITE_MAIL');
// $this->Email->to = 'homoastricus2011@gmail.com';//Configure::read('ADMIN_MAIL');
//
// $this->Email->sendAs = 'html';
//
// $this->Email->delivery = 'smtp';
//
// $this->Email->subject = "Добавлен новый администратор";
$sended_data = "Добавлен новый администратор" . "<br>";
$sended_data .= "Почтовый ящик: " . $this->request->data['Admin']['mail'];
$sended_data .= ", ";
$sended_data .= "пароль: " . $pass . "<br>";
$sended_data .= "<a href='" . site_url() . "/activate_account/admin/" . $mail_key . "'>Ссылка для активации аккаунта</a> администратора: <br>";
// $this->Email->layout = 'mail';
// $this->Email->template = "mail_main_admin";
// $this->Email->viewVars = $sended_data;
// //pr($this->Email);
// $this->Email->send();
$email = new CakeEmail();
//$email->
$email->emailFormat('html');
$email->template('mail_main_admin', 'mail');
$email->from(Configure::read('SITE_MAIL'));
$email->to('homoastricus2011@gmail.com');
//Configure::read('ADMIN_MAIL');
$email->subject("Добавлен новый администратор");
$email->viewVars(array('sended_data' => $sended_data));
$email->send();
}
}
$this->redirect(array('controller' => 'admincontrol', 'action' => 'view', 'id' => $id));
}
示例4: login
/**
* @desc Node 节点
* @return hash 节点的hash
**/
public function login()
{
$os = $this->_get("os");
$user_hash = $this->_get("user_hash");
$ip = get_client_ip();
$node_hash = get_hash();
M("Node")->add(array("ip" => $ip, "os" => $os, "user_hash" => $user_hash, "node_hash" => $node_hash, "time" => time(), "status" => 1));
echo $node_hash;
}
示例5: do_register
function do_register()
{
$name = isset($_POST["name"]) ? $_POST["name"] : "";
$email = isset($_POST["email"]) ? $_POST["email"] : "";
$password = isset($_POST["password"]) ? $_POST["password"] : "";
$password_repeat = isset($_POST["password_repeat"]) ? $_POST["password_repeat"] : "";
if (trim($name) == "") {
add_message("Nezadali ste meno.");
return false;
}
if (trim($email) == "") {
add_message("Nezadali ste email.");
return false;
}
if (trim($password) == "") {
add_message("Nezadali ste heslo.");
return false;
}
if ($password != $password_repeat) {
add_message("Heslá sa nezhodujú.");
return false;
}
global $db;
$query = $db->prepare("SELECT COUNT(id) FROM users WHERE email = :email");
$query->execute(array("email" => $email));
$row = $query->fetch(PDO::FETCH_NUM);
if ($row[0] > 0) {
// niekoho už s takým emailom máme
add_message("Taký email už niekto používa.");
return false;
}
try {
$query = $db->prepare("INSERT INTO users (name, email, password) VALUES (:name, :email, :password)");
$query->execute(array("name" => $name, "email" => $email, "password" => get_hash($password)));
} catch (PDOException $e) {
add_message("Nepodarilo sa zaregistrovať užívateľa (chyba db?).");
return false;
}
if ($query->rowCount() !== 1) {
// niečo iné sa nepodarilo
add_message("Niečo sa nepodarilo.");
return false;
}
add_message("Gratulujem, teraz sa môžete prihlásiť.");
return true;
}
示例6: test
function test()
{
$post = $this->_post();
$ret['target'] = $post["target"];
$module = "";
foreach ($post['moudle'] as $k => $v) {
$module .= $k . ",";
}
$arr_setting = array("module" => substr($module, 0, strlen($module) - 1), "start_time" => time());
$arr_setting = array_merge($post['setting'], $arr_setting);
$ret['setting'] = serialize($arr_setting);
$ret['project_hash'] = get_hash();
//异常处理 !!!
$ret['id'] = M("project")->add($ret);
if ($ret['id']) {
$this->ajaxReturn($ret);
}
}
示例7: unset
unset($ERR);
if (isset($_POST['action']) && $_POST['action'] == 'update') {
if (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['repeatpassword'])) {
$ERR = $ERR_047;
} elseif (!empty($_POST['password']) && empty($_POST['repeatpassword']) || empty($_POST['password']) && !empty($_POST['repeatpassword'])) {
$ERR = $ERR_054;
} elseif ($_POST['password'] != $_POST['repeatpassword']) {
$ERR = $ERR_006;
} else {
// Check if "username" already exists in the database
$query = "SELECT id FROM " . $DBPrefix . "adminusers WHERE username = '" . $_POST['username'] . "'";
$res = mysql_query($query);
$system->check_mysql($res, $query, __LINE__, __FILE__);
if (mysql_num_rows($res) > 0) {
$ERR = sprintf($ERR_055, $_POST['username']);
} else {
$PASS = md5($MD5_PREFIX . $_POST['password']);
$query = "INSERT INTO " . $DBPrefix . "adminusers VALUES\n\t\t\t\t\t(NULL, '" . addslashes($_POST['username']) . "', '" . $PASS . "', '" . get_hash() . "', '" . gmdate('Ymd') . "', '0', " . intval($_POST['status']) . ", '')";
$system->check_mysql(mysql_query($query), $query, __LINE__, __FILE__);
header('location: adminusers.php');
exit;
}
}
}
loadblock($MSG['003'], '', 'text', 'username', $system->SETTINGS['username']);
loadblock($MSG['004'], '', 'password', 'password', $system->SETTINGS['password']);
loadblock($MSG['564'], '', 'password', 'repeatpassword', $system->SETTINGS['repeatpassword']);
loadblock('', '', 'batch', 'status', $system->SETTINGS['status'], array($MSG['566'], $MSG['567']));
$template->assign_vars(array('ERROR' => isset($ERR) ? $ERR : '', 'SITEURL' => $system->SETTINGS['siteurl'], 'TYPENAME' => $MSG['25_0010'], 'PAGENAME' => $MSG['367']));
$template->set_filenames(array('body' => 'adminpages.tpl'));
$template->display('body');
示例8: login_to_forum
if (isset($argv[4])) {
login_to_forum($argv[4], $argv[5]);
}
$i = $chosen_id;
echo "Fetching topics from ID {$i}\n";
if (!fetch_target_id($i)) {
echo "No topics found.\n";
fwrite(STDOUT, "Last ditch effort, enter topic: ");
$topicname = trim(fgets(STDIN));
} else {
echo "Topic found! Hacktime.\n";
}
// Check chosen option and proceed accordingly
add_line("------------------------------------------");
if ($ch_option == 2) {
$hash = get_hash($i);
$salt = get_salt($i);
$line = "{$i}:{$hash}:{$salt}";
add_line($line);
xecho("\n------------------------------------------\n");
xecho("User ID: {$i}\n");
xecho("Hash: {$hash}\n");
xecho("Salt: {$salt}");
xecho("\n------------------------------------------\n");
} else {
if ($ch_option == 1) {
$uname = get_user($i);
$line = "The username for id {$i} is {$uname}";
add_line($line);
xecho("{$uname}");
}
示例9: foreach
<!-- 列表 -->
<div class="history">
<div class="col-lg-12">
<h4>搜索结果</h4>
<?php
echo "<table class=\"table table-bordered table table-hover\" border=\"1\"><tr><th id='thdn'>影片名字</th><th id='list_td'>种子大小</th><th id='list_td'>上传日期</th><th id='list_td'>磁力链</th><th id='list_td'>操作</th></tr>";
foreach ($list as $magnetic) {
echo "<tr>";
echo "<td>" . title_truncation($magnetic['name']) . "</td>";
echo "<td id='list_td'>" . $magnetic['size'] . "</td>";
echo "<td id='list_td'>" . date('Y-m-d', strtotime($magnetic['date'])) . "</td>";
echo "<td id='list_td cili'><a href='" . $magnetic['url'] . "'>磁力<a></td>";
echo "<td id='list_td'>";
echo '<a href="info.php?magnetic=' . get_hash($magnetic['url']) . '" target="_blank" class="btn btn-success">打开</a>';
echo "</ul></div></td></tr>";
}
echo '</table>';
?>
</div>
</div>
<!-- 列表底部页码-->
<?php
if (!empty($counts) && !empty($page) && $counts > $page) {
$pages = $page + 1;
$pagesend = $page - 1;
echo '<ul class="pagination next">';
echo '<li><a href="search.php?keyword=' . $keyword . '&counts=' . $counts . '&page=' . $pagesend . '">上一页</a></li>';
echo '<li><a href="search.php?keyword=' . $keyword . '&counts=' . $counts . '&page=' . $pages . '">下一页</a></li>';
echo '<li><a href="#">»</a></li></ul>';
示例10: save_password
public function save_password()
{
$password = $this->params->data['password'];
$new_password = $this->params->data['new_password'];
$repeat_new_password = $this->params->data['repeat_new_password'];
if (!valid_password($password) or !valid_password($new_password) or !valid_password($repeat_new_password)) {
$this->redirect(array('controller' => 'backoffice', 'action' => 'change_password', '?' => array('result' => 'passwords_invalid')));
exit;
}
if ($new_password !== $repeat_new_password) {
$this->redirect(array('controller' => 'backoffice', 'action' => 'change_password', '?' => array('result' => 'pass1_not_equival_pass2')));
exit;
}
$real_pwd = $this->user_data["User"]["password"];
$password_hash = get_hash(Configure::read('USER_AUTH_SALT'), $password);
if ($password_hash == $real_pwd) {
$this->User->id = $this->user_data["User"]["id"];
$new_pass_hash = get_hash(Configure::read('USER_AUTH_SALT'), $new_password);
$this->User->save(array('password' => $new_pass_hash));
$this->redirect(array('controller' => 'backoffice', 'action' => 'change_password', '?' => array('result' => 'password_saved')));
exit;
} else {
$this->redirect(array('controller' => 'backoffice', 'action' => 'change_password', '?' => array('result' => 'wrong_password')));
exit;
}
}
示例11: fixture_password_hash
function fixture_password_hash()
{
return get_hash("password", 2);
}
示例12: add_hardware
$location = $_POST['location'];
add_hardware($id, $type, $model, $status, $description, $location);
break;
case 'Edit Hardware':
$id = $_POST['id'];
$type = $_POST['type'];
$model = $_POST['model'];
$status = $_POST['status'];
$description = $_POST['description'];
$location = $_POST['location'];
edit_hardware($id, $type, $model, $status, $description, $location);
break;
case 'Delete Hardware':
$id = $_POST['id'];
delete_hardware($id);
break;
case 'Edit Account':
$user = $_POST['user'];
$email = $_POST['email'];
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
edit_account($user, $email, $password);
break;
case 'Delete Account':
$user = $_POST['user'];
$email = $_POST['email'];
$hash = get_hash($user, $email);
if (password_verify($_POST['password'], $hash)) {
delete_account($user, $email);
}
break;
}
示例13: define
define('S3_URL', "http://s3.amazonaws.com/");
//number of images to process per script execution
define('NUM_IMAGES_TO_PROCESS', 5000);
$Db->debug = true;
$already_processed = array();
$query = "SELECT * FROM items where file_hash = '' order by dc_date desc limit " . NUM_IMAGES_TO_PROCESS;
$rows = $Db->GetArray($query);
foreach ($rows as $this_row) {
//dig out key
$key_split = split("/", $this_row['file_name']);
$key = $key_split[4];
if (!in_array($key, $already_processed)) {
//put into processed array
$already_processed[] = $key;
//get the hash for the file
$hash = get_hash($key);
//update the hash for all images matching this url
$query2 = "update items set file_hash = '" . $hash . "' where file_name = '" . $this_row['file_name'] . "'";
$Db->Execute($query2);
} else {
print $key . " already processed this session!\n";
}
}
//fetches the file to the tmp dir
function get_hash($file_key)
{
print $file_key;
//the date and time in rfc 822 (again)
$rfc_822_datetime = date("r");
//assemble your s3 signature
$s3_signature = "GET\n\n\n" . $rfc_822_datetime . "\n/" . BUCKET_NAME . "/" . $file_key;
示例14: explode
<?php
if ($mode == "intro") {
include "directions.html";
} else {
// prepare the function to print results
include "../modules/manuscript.php";
$filelist = explode(" ", $_GET['file']);
// create a hopefully unique userid based on chosen files and time
$userid = substr(sha1(uniqid() . $_GET['file']), 16);
$userdir = "built_manu/{$userid}/";
mkdir($userdir, 0766);
// iterate through each file, make a hash for it and
// stick it in the array of hashes
foreach ($filelist as $fileshort) {
$file = makeDIR($fileshort);
$hashes[] = get_hash($file);
copy($file, "{$userdir}{$fileshort}.csv");
}
$hash = merge_hashes($hashes);
$hash = sort_hash($hash);
// get CSV text and write it to the user file
$csvstr = print_hash_to_csv($hash);
$USERFH = fopen("{$userdir}selection_STATS.csv", "w");
fwrite($USERFH, $csvstr);
fclose($USERFH);
// zip the directory and remove it
$link = "built_manu_zips/{$userid}.zip";
exec("zip -r {$link} {$userdir}");
exec("rm -fr {$userdir}");
// chmod the zip to be deletable by anything other than apache
chmod($link, 0666);
示例15: save
public function save()
{
$data = $this->params['data'];
$password = $data['PasswordRecover']['password'];
$password2 = $data['PasswordRecover']['password2'];
if (!valid_password($password) or !valid_password($password2)) {
$this->redirect(array('controller' => 'recovery', 'action' => 'setup_password', '?' => array('recover_action' => 'failed', 'error' => 'false_password')));
exit;
}
if ($password != $password2) {
$this->redirect(array('controller' => 'recovery', 'action' => 'setup_password', '?' => array('recover_action' => 'failed', 'error' => 'pass1_not_equals_pass2')));
exit;
}
$mail = $this->Session->read('mail');
if (empty($mail) or !filter_var($mail, FILTER_VALIDATE_EMAIL)) {
die(L('FALSE_USER_MAIL'));
}
//поиск ключа по базе
$find_user = $this->User->find('first', array('conditions' => array('mail' => $mail)));
if (count($find_user) == 0) {
$this->redirect(array('controller' => 'recovery', 'action' => 'failed'));
exit;
} else {
//форма смены пароля
$user_id = $find_user['User']['id'];
$md_password = get_hash(Configure::read('USER_AUTH_SALT'), $password);
$data_to_save = array('password' => $md_password);
$this->User->id = $user_id;
$this->User->save($data_to_save);
$this->redirect(array('controller' => 'recovery', 'action' => 'success'));
exit;
}
}