本文整理汇总了PHP中md5函数的典型用法代码示例。如果您正苦于以下问题:PHP md5函数的具体用法?PHP md5怎么用?PHP md5使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了md5函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
function login()
{
$this->admin_security->check_no_admin_login();
// Process the inputs if form is posted
if ($_POST) {
// To avoid mysql injection
$this->admin_security->avoid_mysql_injection();
// Setting validation rules
$this->form_validation->set_rules($this->admin_rules->login());
$this->form_validation->set_error_delimiters('<div class="er">', '</div>');
//provide div to show message
// Continue authentication if form is valid
if ($this->form_validation->run() == FALSE) {
$this->data['error'] = 1;
} else {
// make sessions and redirect to home page if admin is authenticated
if ($admin_id = $this->admin_security->authenticate_admin($_POST['username'], md5($_POST['password']))) {
// Set session data
$this->session->set_userdata('admin_id', $admin_id);
redirect(base_url() . 'admin/dashboard');
} else {
// Assign error message
$this->data['err_msg_invalid'] = 'Invalid username or password.';
}
}
}
// Load login page
$this->load->view('admin/login', $this->data);
}
示例2: generateSecurekey
/**
*
* @ORM\PrePersist
*/
public function generateSecurekey()
{
$generator = new SecureRandom();
$random = $generator->nextBytes(150);
$securekey = md5($random . time());
$this->setSecurekey($securekey);
}
示例3: _process
public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
{
$m = $this->getConfig('methods');
if (@count($m) == 1) {
$a = new Am_Paysystem_Action_Form(self::URL . $m[0] . '/event/');
} else {
$a = new Am_Paysystem_Action_HtmlTemplate_Micropayment($this->getDir(), 'micropayment-confirm.phtml');
$methods = array();
if (@count($m)) {
$a->url = self::URL . $m[0] . '/event/';
foreach ($m as $title) {
$methods[self::URL . $title . '/event/'] = $this->getConfig($title . '.title');
}
} else {
foreach ($this->getConfig() as $k => $v) {
if (is_array($v) && !empty($v['title'])) {
$methods[self::URL . $k . '/event/'] = $v['title'];
}
}
$a->url = array_shift(array_keys($methods));
}
$a->methods = $methods;
}
$a->project = $this->getConfig('project');
$a->amount = $invoice->first_total * 100;
$a->freepaymentid = $invoice->public_id;
$a->seal = md5("project={$a->project}&amount={$a->amount}&freepaymentid={$a->freepaymentid}" . $this->getConfig('key'));
$result->setAction($a);
}
示例4: actionModify
function actionModify()
{
$id = (int) $this->_context->get('id');
$rs = Account::find('user_id = ?', $id)->getOne();
if (!$rs->id()) {
return $this->msg($tip = '参数错误', url('manage::account'));
}
$form = Form_Common::createForm('', 'manage/profile');
if ($this->_context->isPOST() && $form->validate($_POST)) {
$post = $form->values();
$user_mail = $post['user_mail'];
$user_pass = $post['user_pass'];
$is_locked = $post['is_locked'] ? '1' : '0';
#dump($post);
if ($user_pass) {
$user_pass = sha1(md5('sike' . $post['user_pass'] . Q::ini('appini/secret_key')));
$rs->user_pass;
}
$rs->user_mail = $user_mail;
$rs->is_locked = $is_locked;
$rs->save();
return $this->msg($tip = '修改成功', url('manage::account/modify', array('id' => $id)));
}
$form->import($rs->toArray());
$form->element('user_pass')->value = '';
$form->element('is_locked')->checked = $rs->is_locked;
#dump($form->element('is_locked'));
$this->_view['form'] = $form;
$this->_view['rs'] = $rs;
$order = Order::find('user_id = ?', $id)->order('created DESC')->getAll();
$this->_view['order'] = $order;
$this->_view['_UDI'] = 'manage::account/index';
}
示例5: wpcom_static_url
function wpcom_static_url($file)
{
$i = hexdec(substr(md5($file), -1)) % 2;
$http = is_ssl() ? 'https' : 'http';
$url = $http . '://s' . $i . '.wp.com' . $file;
return $url;
}
示例6: getkey
public function getkey($actionUrl = null, $mktime = null)
{
$actionUrl = $this->_getActionUrl($actionUrl);
if ($mktime == null) {
$lifetime = Centurion_Config_Manager::get('ticket.lifetime');
list($lifetimeValue, $lifetimeUnit) = sscanf($lifetime, '%d%s');
$mktime = new Zend_Date();
switch ($lifetimeUnit) {
case 'j':
case 'd':
$mktime->setHour(0);
case 'h':
$mktime->setMinute(0);
case 'm':
default:
$mktime->setSecond(0);
}
}
if ($mktime instanceof Zend_Date) {
$date = $mktime->toString('YYYYMMdd-HH:mm');
} else {
$date = date('Ymd-H:i', $mktime);
}
$salt = Centurion_Config_Manager::get('ticket.salt');
$ticket = md5($salt . $actionUrl . $date);
return $ticket;
}
示例7: get_token_from_guids
function get_token_from_guids($guids)
{
$guids = array_unique($guids);
sort($guids);
$string = implode(',', $guids);
return md5($string);
}
示例8: session_init
/**
* Initialize session.
* @param boolean $keepopen keep session open? The default is
* to close the session after $_SESSION has been populated.
* @uses $_SESSION
*/
function session_init($keepopen = false)
{
$settings = new phpVBoxConfigClass();
// Sessions provided by auth module?
if (@$settings->auth->capabilities['sessionStart']) {
call_user_func(array($settings->auth, $settings->auth->capabilities['sessionStart']), $keepopen);
return;
}
// No session support? No login...
if (@$settings->noAuth || !function_exists('session_start')) {
global $_SESSION;
$_SESSION['valid'] = true;
$_SESSION['authCheckHeartbeat'] = time();
$_SESSION['admin'] = true;
return;
}
// start session
session_start();
// Session is auto-started by PHP?
if (!ini_get('session.auto_start')) {
ini_set('session.use_trans_sid', 0);
ini_set('session.use_only_cookies', 1);
// Session path
if (isset($settings->sessionSavePath)) {
session_save_path($settings->sessionSavePath);
}
session_name(isset($settings->session_name) ? $settings->session_name : md5('phpvbx' . $_SERVER['DOCUMENT_ROOT'] . $_SERVER['HTTP_USER_AGENT']));
session_start();
}
if (!$keepopen) {
session_write_close();
}
}
示例9: encrypt
/**
* Encrypts password with salt and entered password
* Stucture => saltedHash:salt
* @param $pass
* @return string
*
*/
function encrypt($pass)
{
$password = $pass;
$salt = 'LSAS213saddEASDRAs2135SDA';
$password = md5($salt . $password) . ":" . $salt;
return $password;
}
示例10: getSQLValue
function getSQLValue()
{
if (is_array($this->property_info['value'])) {
return md5($this->property_info['value']['original']);
}
return md5($this->property_info['value']);
}
示例11: generatePassword
public static function generatePassword($request, $seed)
{
$context = $request['context'];
$username = $request['username'];
$pass = convBase(md5($context . $username . $seed), '0123456789abcdef', "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNIOPQRSTUVWXYZ()-_!\$%&=@#");
return $pass;
}
示例12: iCMS_link
/**
* @package iCMS
* @copyright 2007-2010, iDreamSoft
* @license http://www.idreamsoft.com iDreamSoft
* @author coolmoo <idreamsoft@qq.com>
*/
function iCMS_link($vars)
{
$limit = isset($vars['row']) ? (int) $vars['row'] : "100";
$cache_time = isset($vars['time']) ? (int) $vars['time'] : -1;
switch ($vars['type']) {
case "text":
$sql[] = " `logo`='' ";
break;
case "logo":
$sql[] = " `logo`!='' ";
break;
}
isset($vars['cid']) && ($sql[] = " cid='" . $vars['cid'] . "'");
$sql && ($where = 'WHERE ' . implode(' AND ', $sql));
$iscache = true;
if ($vars['cache'] == false || isset($vars['page'])) {
$iscache = false;
$rs = '';
} else {
$cacheName = 'links/' . md5($sql);
$rs = iCache::get($cacheName);
}
if (empty($rs)) {
$rs = iDB::all("SELECT * FROM `#iCMS@__links`{$where} ORDER BY ordernum ASC,id ASC LIMIT 0 , {$limit}");
$iscache && iCache::set($cacheName, $rs, $cache_time);
}
return $rs;
}
示例13: is_auth
public static function is_auth($cookie)
{
$request = APF::get_instance()->get_request();
if ($cookie) {
$is_flash = @$request->get_parameter("is_flash");
if ($is_flash) {
$browser = $request->get_parameter("user_agent");
} else {
$browser = $_SERVER['HTTP_USER_AGENT'];
}
$iBugsecques = APF::get_instance()->get_config('iBugSecques');
$cookieStr = Util_AuthorCrypt::decrypt($cookie, md5($browser . $iBugsecques));
if (empty($cookieStr)) {
return false;
}
$cookieArr = explode("\t", $cookieStr);
@(list($user_id, $username, $cookietime) = $cookieArr);
if (empty($user_id) || empty($username)) {
return false;
}
$request->set_user_id($user_id);
$request->set_username($username);
return true;
} else {
return false;
}
}
示例14: addUser
public function addUser($add = array())
{
if (empty($add['staff_name']) and empty($add['username']) and empty($add['password'])) {
return TRUE;
}
$this->db->where('staff_email', strtolower($add['site_email']));
$this->db->delete('staffs');
$this->db->set('staff_email', strtolower($add['site_email']));
$this->db->set('staff_name', $add['staff_name']);
$this->db->set('staff_group_id', '11');
$this->db->set('staff_location_id', '0');
$this->db->set('language_id', '11');
$this->db->set('timezone', '0');
$this->db->set('staff_status', '1');
$this->db->set('date_added', mdate('%Y-%m-%d', time()));
$query = $this->db->insert('staffs');
if ($this->db->affected_rows() > 0 and $query === TRUE) {
$staff_id = $this->db->insert_id();
$this->db->where('username', $add['username']);
$this->db->delete('users');
$this->db->set('username', $add['username']);
$this->db->set('staff_id', $staff_id);
$this->db->set('salt', $salt = substr(md5(uniqid(rand(), TRUE)), 0, 9));
$this->db->set('password', sha1($salt . sha1($salt . sha1($add['password']))));
$query = $this->db->insert('users');
}
return $query;
}
示例15: testRegularUser
public function testRegularUser()
{
$originalUser = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface');
$user = new UserWrapped($originalUser, $this->apiUser);
$this->assertTrue($user->isEnabled());
$this->assertTrue($user->isAccountNonExpired());
$this->assertTrue($user->isAccountNonLocked());
$this->assertTrue($user->isCredentialsNonExpired());
$this->assertTrue($user->isEqualTo($this->getMock('Symfony\\Component\\Security\\Core\\User\\UserInterface')));
$originalUser->expects($this->once())->method('eraseCredentials');
$user->eraseCredentials();
$username = 'lolautruche';
$password = 'NoThisIsNotMyRealPassword';
$roles = array('ROLE_USER', 'ROLE_TEST');
$salt = md5(microtime(true));
$originalUser->expects($this->exactly(2))->method('getUsername')->will($this->returnValue($username));
$originalUser->expects($this->once())->method('getPassword')->will($this->returnValue($password));
$originalUser->expects($this->once())->method('getRoles')->will($this->returnValue($roles));
$originalUser->expects($this->once())->method('getSalt')->will($this->returnValue($salt));
$this->assertSame($username, $user->getUsername());
$this->assertSame($username, (string) $user);
$this->assertSame($password, $user->getPassword());
$this->assertSame($roles, $user->getRoles());
$this->assertSame($salt, $user->getSalt());
$this->assertSame($originalUser, $user->getWrappedUser());
}