Differences

Link to this comparison view

user_documentation:use:features:conf_locale [2016/07/10 11:36]
plg use php syntax color highlighter
user_documentation:use:features:conf_locale [2016/07/10 11:41] (current)
plg example for password_verify function
Line 43: Line 43:
 </WRAP> </WRAP>
 You can revert your changes by restoring the backup file.\\ You can revert your changes by restoring the backup file.\\
 +
 +===== Functions =====
 +
 +If you want to use a specific function to check password, you will have to "protect" the function definition with "function_exists". Here is an example:
 +
 +<code php>$conf['password_verify'] = 'smf_password_verify';
 +if (!function_exists('smf_password_verify'))
 +{
 +  function smf_password_verify($password_clear, $password_hash, $user_id)
 +  {
 +    global $conf;
 +
 +    if (empty($user_id))
 +    {
 +      return false;
 +    }
 +
 +    $query = '
 +SELECT
 +    memberName,
 +    passwd
 +  FROM '.$conf['users_table'].'
 +  WHERE ID_MEMBER = '.$user_id.'
 +    AND is_activated=1
 +;';
 +    $result = pwg_query($query);
 +    while ($row = pwg_db_fetch_assoc($result))
 +    {
 +      if (sha1(strtolower($row['memberName']).$password_clear) == $password_hash)
 +      {
 +        return true;
 +      }
 +      break;
 +    }
 +
 +    return false;
 +  }
 +}</code>
 +
  
 ===== Additional info ===== ===== Additional info =====
 
Back to top
user_documentation/use/features/conf_locale.txt · Last modified: 2016/07/10 11:41 by plg
 
 
github twitter facebook google+ newsletter Donate Piwigo.org © 2002-2018 · Contact