当前位置: 首页>>代码示例>>PHP>>正文


PHP MD5函数代码示例

本文整理汇总了PHP中MD5函数的典型用法代码示例。如果您正苦于以下问题:PHP MD5函数的具体用法?PHP MD5怎么用?PHP MD5使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MD5函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: UserLogin

 public function UserLogin($userNIM, $password)
 {
     $this->db->where('userNIM', $userNIM);
     $this->db->where('userPass', MD5($password));
     $query = $this->db->get("msuser");
     return $query->result();
 }
开发者ID:mchiichi,项目名称:eLearning.v.1,代码行数:7,代码来源:usersModel.php

示例2: get_code

 /**
  * 生成支付代码.
  *
  * @param array $order   订单信息
  * @param array $payment 支付方式信息
  */
 public function get_code($order, $payment)
 {
     $billstr = date('His', time());
     $datestr = date('Ymd', time());
     $mer_code = $payment['ips_account'];
     $billno = str_pad($order['log_id'], 10, '0', STR_PAD_LEFT) . $billstr;
     $amount = sprintf('%0.02f', $order['order_amount']);
     $strcert = $payment['ips_key'];
     $strcontent = $billno . $amount . $datestr . 'RMB' . $strcert;
     // 签名验证串 //
     $signmd5 = MD5($strcontent);
     $def_url = '<br /><form style="text-align:center;" action="https://pay.ips.com.cn/ipayment.aspx" method="post" target="_blank">';
     $def_url .= "<input type='hidden' name='Mer_code' value='" . $mer_code . "'>\n";
     $def_url .= "<input type='hidden' name='Billno' value='" . $billno . "'>\n";
     $def_url .= "<input type='hidden' name='Gateway_type' value='" . $payment['ips_currency'] . "'>\n";
     $def_url .= "<input type='hidden' name='Currency_Type'  value='RMB'>\n";
     $def_url .= "<input type='hidden' name='Lang'  value='" . $payment['ips_lang'] . "'>\n";
     $def_url .= "<input type='hidden' name='Amount'  value='" . $amount . "'>\n";
     $def_url .= "<input type='hidden' name='Date' value='" . $datestr . "'>\n";
     $def_url .= "<input type='hidden' name='DispAmount' value='" . $amount . "'>\n";
     $def_url .= "<input type='hidden' name='OrderEncodeType' value='2'>\n";
     $def_url .= "<input type='hidden' name='RetEncodeType' value='12'>\n";
     $def_url .= "<input type='hidden' name='Merchanturl' value='" . return_url(basename(__FILE__, '.php')) . "'>\n";
     $def_url .= "<input type='hidden' name='SignMD5' value='" . $signmd5 . "'>\n";
     $def_url .= "<input type='submit' value='" . $GLOBALS['_LANG']['pay_button'] . "'>";
     $def_url .= '</form><br />';
     return $def_url;
 }
开发者ID:netroby,项目名称:ecshop,代码行数:34,代码来源:ips.php

示例3: create_user

 public function create_user($name, $mail, $psw)
 {
     $data = array('user_name' => $name, 'user_mail_address' => $mail, 'user_psw' => MD5($psw), 'user_created_at' => date('Y-m-d H:i:s'));
     $this->db->insert('users', $data);
     $result = array('is' => $this->db->insert_id(), 'status' => true);
     return $result;
 }
开发者ID:H0lyve,项目名称:choublog,代码行数:7,代码来源:m_user.php

示例4: update_password

 function update_password()
 {
     $username = $this->input->post('username');
     $password = $this->input->post('password');
     $password = MD5($password);
     $baru = $this->input->post('baru');
     $ulang = $this->input->post('ulang');
     $result = $this->admin_model->cek($username, $password);
     if ($result) {
         if ($baru == $ulang) {
             $id = $this->session->userdata('id');
             $data_admin = array('password' => md5($this->input->post('baru')), 'nama' => $this->input->post('nama'), 'username' => $this->input->post('username'));
             $this->admin_model->update_data('tbl_admin', 'id_admin', $id, $data_admin);
             $data['message'] = '<font color="#00B000">' . 'Anda berhasil ganti password !' . '</font>';
             $data['view'] = 'pages/profil_admin';
             $this->load->view('home/home', $data);
         } else {
             $data['message'] = '<font color="#FF0000">' . 'Pasword baru tidak cocok,Mohon di ulangi password baru anda !' . '</font>';
             $data['view'] = 'pages/profil_admin';
             $this->load->view('home/home', $data);
         }
     } else {
         //if form validate false
         $data['message'] = '<font color="#FF0000">' . 'Username dan Password lama salah  !' . '</font>';
         $data['view'] = 'pages/profil_admin';
         $this->load->view('home/home', $data);
         // return FALSE;
     }
 }
开发者ID:raflesngln,项目名称:att-system,代码行数:29,代码来源:admin.php

示例5: isvalidSession

 function isvalidSession($htoken, $maxidletime = 0, $checkip = false)
 {
     global $cfg;
     $token = rawurldecode($htoken);
     #check if we got what we expected....
     if ($token && !strstr($token, ":")) {
         return FALSE;
     }
     #get the goodies
     list($hash, $expire, $ip) = explode(":", $token);
     #Make sure the session hash is valid
     if (md5($expire . SESSION_SECRET . $this->userID) != $hash) {
         return FALSE;
     }
     #is it expired??
     if ($maxidletime && time() - $expire > $maxidletime) {
         return FALSE;
     }
     #Make sure IP is still same ( proxy access??????)
     if ($checkip && strcmp($ip, MD5($this->ip))) {
         return FALSE;
     }
     $this->validated = TRUE;
     return TRUE;
 }
开发者ID:ryan1432,项目名称:osTicket-1.7fork,代码行数:25,代码来源:class.usersession.php

示例6: __WriteCache

 private function __WriteCache($Url, $Data)
 {
     $Cache_File = $GLOBALS['Cache_Folder'] . MD5($Url);
     $Open = fopen($Cache_File, 'w');
     fwrite($Open, $Data);
     fclose($Open);
 }
开发者ID:pemiu01,项目名称:Plugin-play-videojs,代码行数:7,代码来源:Embed.php

示例7: loging

 public function loging()
 {
     if ($this->_session('verify') != md5($this->_post('proving'))) {
         $this->error('验证码错误!');
         exit;
     }
     $user = D("User");
     $condition['username'] = $this->_post('username');
     $condition['password'] = $user->userMd5($this->_post('password'));
     $list = $user->where($condition)->select();
     if ($list) {
         session('user_name', $condition['username']);
         //设置session
         session('user_uid', $list[0]['id']);
         session('user_verify', MD5($condition['username'] . DS_ENTERPRISE . $condition['password'] . DS_EN_ENTERPRISE));
         session('verify', null);
         //删除验证码
         //session(null); //清空
         $this->userLog('会员登陆', $this->_session('user_uid'));
         //会员记录
         $this->success("用户登录成功", '__ROOT__/Center.html');
         exit;
     } else {
         $this->error('用户名或密码错误');
         exit;
     }
 }
开发者ID:chenyongze,项目名称:Dswjcms,代码行数:27,代码来源:LogoAction.class.php

示例8: add

 public function add()
 {
     if ($this->request->is('post')) {
         $this->User->create();
         $this->request->data['Group']['Group'][] = (int) Configure::read('Settings.Company.DefaultGroupId');
         $this->request->data['User']['date_joined'] = gmdate('Y-m-d H:i:s');
         $password = getPassword();
         $this->request->data['User']['password'] = $password;
         $signature = substr(MD5($this->request->data['User']['email'] . $this->request->data['User']['date_joined']), 0, 7);
         $this->request->data['User']['signature'] = $signature;
         if ($this->User->save($this->request->data)) {
             //save Signature archive
             $arrSignature = array();
             $arrSignature['SignatureArchive']['user_id'] = $this->User->id;
             $arrSignature['SignatureArchive']['signature'] = $signature;
             $arrSignature['SignatureArchive']['user_modify'] = $this->Session->read('Auth.User.id');
             $arrSignature['SignatureArchive']['date_from'] = gmdate('Y-m-d H:i:s');
             $arrSignature['SignatureArchive']['date_till'] = gmdate('Y-m-d H:i:s');
             $this->SignatureArchive->save($arrSignature);
             $mail_content = "Account informations: \n\n" . "Name: " . $this->request->data['User']['name'] . "\n" . "Email login: " . $this->request->data['User']['email'] . "\n" . "Password: " . $password . "\n" . "Signature: " . $signature . "\n";
             $arr_options = array('to' => array($this->request->data['User']['email']), 'viewVars' => array('content' => $mail_content));
             $this->_sendEmail($arr_options);
             $this->Session->setFlash(__('The user has been saved'));
             return $this->redirect(array('action' => 'index'));
         }
     } else {
         $companyid = $this->Session->read('company_id');
         if ($companyid) {
             $this->request->data['User']['company_id'] = $companyid;
         }
     }
     $this->render('edit');
 }
开发者ID:a0108393,项目名称:cms-system,代码行数:33,代码来源:UsersController.php

示例9: db

function db($host = null, $port = null, $user = null, $password = null, $db_name = null)
{
    $db_key = MD5($host . '-' . $port . '-' . $user . '-' . $password . '-' . $db_name);
    if (!isset($GLOBALS['LP_' . $db_key])) {
        include_once AROOT . 'config/db.config.php';
        //include_once( CROOT .  'lib/db.function.php' );
        $db_config = $GLOBALS['config']['db'];
        if ($host == null) {
            $host = $db_config['db_host'];
        }
        if ($port == null) {
            $port = $db_config['db_port'];
        }
        if ($user == null) {
            $user = $db_config['db_user'];
        }
        if ($password == null) {
            $password = $db_config['db_password'];
        }
        if ($db_name == null) {
            $db_name = $db_config['db_name'];
        }
        //if( !$GLOBALS['LP_'.$db_key] = mysql_connect( $host.':'.$port , $user , $password , true ) )
        if (!($GLOBALS['LP_' . $db_key] = mysqli_connect($host, $user, $password, $db_name, $port))) {
            //
            echo 'can\'t connect to database';
            return false;
        }
        mysqli_query($GLOBALS['LP_' . $db_key], "SET NAMES 'UTF8'");
    }
    return $GLOBALS['LP_' . $db_key];
}
开发者ID:jfojfo,项目名称:LazyREST,代码行数:32,代码来源:mysqli.function.php

示例10: render

 /**
  * Render Template (php file aja)
  *
  * @param string $templateFile
  * @param unknown $data
  */
 public function render($templateFile = '', $data = array())
 {
     if (!empty($templateFile)) {
         $cacheDir = realpath($this->appPath . DS . '..') . DS . 'storage' . DS . 'cache' . DS . 'templates';
         $cacheFile = $cacheDir . DS . MD5($this->viewPath . str_replace('.' . $this->config['templateExtension'], '', $templateFile)) . '.php';
         if (!file_exists($cacheFile) || ($this->config['cache'] === 'false' || $this->config['cache'] === false)) {
             $templateTmp = file_get_contents($this->viewPath . DS . $templateFile);
             preg_match_all("~\\{\\{\\s*(.*?)\\s*\\}\\}~", $templateTmp, $block);
             foreach ($block[1] as $k => $v) {
                 if ($v === 'php') {
                     $templateTmp = str_replace('{{php}}', '<?php', $templateTmp);
                 } elseif ($v === '/php') {
                     $templateTmp = str_replace('{{/php}}', '?>', $templateTmp);
                 } else {
                     $blockTemplate = $this->includeBlock($v);
                     $templateTmp = str_replace('{{' . $v . '}}', $blockTemplate, $templateTmp);
                 }
             }
             $templateTmp .= "\n <!-- Generated at: " . date('Y-m-d H:i:s') . " -->";
             $fp = fopen($cacheFile, 'w');
             $write = fwrite($fp, $templateTmp);
             fclose($fp);
         }
         extract((array) $data);
         require_once $cacheFile;
     }
 }
开发者ID:transformatika,项目名称:mvc,代码行数:33,代码来源:View.php

示例11: __postLogin

 /** do login in cred. matches
  * @param $_post data
  * @redirect to dashboard if cred. matches
  */
 protected function __postLogin()
 {
     if (isset($_POST['submit'])) {
         $username = $_POST['username'];
         $password = $_POST['password'];
         $userData = $this->user->getBy('email', $username);
         if (isset($userData) && !empty($userData)) {
             if (MD5($password) == $userData['0']['password']) {
                 //set the session to true
                 Session::set('loggin', true);
                 // if matches username and password redirect to dashboard
                 $this->redirect('admin/dashboard');
             } else {
                 //when password is wrong
                 $response = array();
                 $response['message'][] = 'Your password is wrong, please try again !';
                 $this->view('admin/login', $response);
             }
         } else {
             // when username is wrong
             $response = array();
             $response['message'][] = 'Your Username is wrong, please try again !';
             $this->view('admin/login', $response);
         }
     } else {
         // if user press submit button without entering username and password
         $response = array();
         $response['message'][] = 'Please enter username and password to login !';
         $this->view('admin/login', $response);
     }
 }
开发者ID:viralsolani,项目名称:yapf,代码行数:35,代码来源:admin.php

示例12: _getConnect

 private function _getConnect($type)
 {
     try {
         if (empty($this->_conf['slave'])) {
             $this->_conf['slave'] = $this->_conf['master'];
         }
         if ($type === 'slave') {
             $key = MD5($this->_conf['slave']['database'] . $this->_conf['slave']['host'] . $this->_conf['slave']['port'] . $this->_conf['slave']['username'] . $this->_conf['slave']['password']);
             if (isset(self::$_instance[$key])) {
                 $this->_pdo = self::$_instance[$key];
                 return;
             }
             $dsn = "mysql:dbname=" . $this->_conf['slave']['database'] . ";host=" . $this->_conf['slave']['host'] . ';port=' . $this->_conf['slave']['port'];
             $username = $this->_conf['slave']['username'];
             $password = $this->_conf['slave']['password'];
         } else {
             $key = MD5($this->_conf['master']['database'] . $this->_conf['master']['host'] . $this->_conf['master']['port'] . $this->_conf['master']['username'] . $this->_conf['master']['password']);
             if (isset(self::$_instance[$key])) {
                 $this->_pdo = self::$_instance[$key];
                 return;
             }
             $dsn = "mysql:dbname=" . $this->_conf['master']['database'] . ";host=" . $this->_conf['master']['host'] . ';port=' . $this->_conf['master']['port'];
             $username = $this->_conf['master']['username'];
             $password = $this->_conf['master']['password'];
         }
         self::$_instance[$key] = new PDO($dsn, $username, $password, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES " . $this->_conf['charset']));
         $this->_pdo = self::$_instance[$key];
         $this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         // 设置错误模式为exceptions异常。
         $this->_pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
         //禁用预处理语句的模拟
     } catch (PDOException $e) {
         throw new Exception('连接数据库失败:' . $e->getMessage());
     }
 }
开发者ID:hexcode007,项目名称:yfcms,代码行数:35,代码来源:mysqlHandler.php

示例13: login

 public static function login(Cart66Account $account)
 {
     $name = $account->firstName . ' ' . $account->lastName;
     $email = $account->email;
     $externalId = $account->id;
     $organization = Cart66Setting::getValue('zendesk_organization');
     $key = Cart66Setting::getValue('zendesk_token');
     $prefix = Cart66Setting::getValue('zendesk_prefix');
     if (Cart66Setting::getValue('zendesk_jwt')) {
         $now = time();
         $token = array("jti" => md5($now . rand()), "iat" => $now, "name" => $name, "email" => $email);
         include_once CART66_PATH . "/pro/models/JWT.php";
         $jwt = JWT::encode($token, $key);
         // Redirect
         header("Location: https://" . $prefix . ".zendesk.com/access/jwt?jwt=" . $jwt);
         exit;
     } else {
         /* Build the message */
         $ts = isset($_GET['timestamp']) ? $_GET['timestamp'] : time();
         $message = $name . '|' . $email . '|' . $externalId . '|' . $organization . '|||' . $key . '|' . $ts;
         $hash = MD5($message);
         $remoteAuthUrl = 'http://' . $prefix . '.zendesk.com/access/remoteauth/';
         $arguments = array('name' => $name, 'email' => $email, 'external_id' => $externalId, 'organization' => $organization, 'timestamp' => $ts, 'hash' => $hash);
         $url = add_query_arg($arguments, $remoteAuthUrl);
         header("Location: " . $url);
         exit;
     }
 }
开发者ID:rbredow,项目名称:allyzabbacart,代码行数:28,代码来源:ZendeskRemoteAuth.php

示例14: img_thumb

 /**
 +--------------------------------------------------
 * 生成图片缩略图
 +--------------------------------------------------
 */
 public function img_thumb()
 {
     $gData = checkData($_GET);
     $w = $gData['w'] + 0;
     $h = $gData['h'] + 0;
     $allow_width = array(300, 720);
     $allow_height = array(168, 405);
     if (!in_array($w, $allow_width)) {
         die(json_encode(array('code' => -201, "msg" => "参数错误")));
     }
     if (!in_array($h, $allow_height)) {
         die(json_encode(array('code' => -202, "msg" => "参数错误")));
     }
     $img_path = substr(HTML_PATH, 0, -1);
     ///images/videos/14999572630/screenshot/1d1c67cd5c1926a6e379fb78c711b87b_360X640.png
     $img_file = MD5(xxx);
     if (!file_exists($img_file)) {
         //生成图片
     } else {
         //读取图片
     }
     //        $this->img_operate->open($img_path.$addData['pic_url']);
     //        if ($this->img_operate->width() == '135' && $this->img_operate->height() == '135') {
     //            $this->img_operate->save(HTML_PATH . '/images/videos/' . $_v['video_id'] . '/yingyongbao/', $imageName);
     //        } else {
     //            $this->img_operate->thumb(300, 300, 3)->save(HTML_PATH . '/images/videos/' . $_v['video_id'] . '/yingyongbao/', $imageName);
     //            $this->img_operate->open(HTML_PATH . '/images/videos/' . $_v['video_id'] . '/yingyongbao/' . $imageName);
     //            $this->img_operate->thumb(135, 135, 1)->save(HTML_PATH . '/images/videos/' . $_v['video_id'] . '/yingyongbao/', $imageName);
     //        }
     //
     //        $this->img_operate->thumb(300, 300, 3)->save(HTML_PATH . '/images/videos/' . $_v['video_id'] . '/yingyongbao/', $imageName);
     //        $this->img_operate->open(HTML_PATH . '/images/videos/' . $_v['video_id'] . '/yingyongbao/' . $imageName);
 }
开发者ID:bibyzhang,项目名称:produce_cms,代码行数:38,代码来源:img.php

示例15: onBeforeWrite

 /**
  * Set VerificationString if not set
  * If not verified log out user and display message.
  */
 function onBeforeWrite()
 {
     parent::onBeforeWrite();
     if (!$this->owner->VerificationString) {
         $this->owner->VerificationString = MD5(rand());
     }
     if (!$this->owner->Verified) {
         if (!$this->owner->VerificationEmailSent) {
             if (!self::$hasOnBeforeWrite) {
                 self::$hasOnBeforeWrite = true;
                 $this->owner->sendemail($this->owner, false);
             }
         }
         if (Member::currentUserID() && $this->owner->Email == Member::currentUser()->Email) {
             Security::logout(false);
             if (!is_null(Controller::redirectedTo())) {
                 $messageSet = array('default' => _t('EmailVerifiedMember.EMAILVERIFY', 'Please verify your email address by clicking on the link in the email before logging in.'));
             }
             Session::set("Security.Message.type", 'bad');
             Security::permissionFailure(Controller::curr(), $messageSet);
         } else {
             return;
         }
     } else {
         return;
     }
 }
开发者ID:helpfulrobot,项目名称:exadium-emailverifiedmember,代码行数:31,代码来源:EmailVerifiedMember.php


注:本文中的MD5函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。