Permalink
Browse files

* Detect, if the user specified an md5 hash as password. If yes, do n…

…ot calculate the hashsum.

Fixed issue #5: Hashed passwords are not supported


git-svn-id: http://sms77-oo-api-wrapper.googlecode.com/svn/trunk@5 b81633a6-edc0-11de-a700-c3e9af1e83fa
  • Loading branch information...
1 parent b46928c commit 9bfde6793d8e84bd4eaf1af77c3a0d02358969eb @mibe committed Dec 21, 2009
Showing with 12 additions and 1 deletion.
  1. +12 −1 base.php
View
@@ -22,14 +22,25 @@ class Base
protected function ApiCall($data = array())
{
$data['u'] = $this->User;
- $data['p'] = md5($this->Pass);
+ $data['p'] = $this->getApiPassword();
$query = http_build_query($data);
$url = $this->buildUrl($query);
return file_get_contents($url);
}
+ private function getApiPassword()
+ {
+ $password = $this->Pass;
+
+ // detect if the user already specified an md5 hash
+ if (preg_match("#^[0-9a-f]{32}$#i", $this->Pass) == 0)
+ $password = md5($password);
+
+ return $password;
+ }
+
private function buildUrl($query)
{
$url = 'http';

0 comments on commit 9bfde67

Please sign in to comment.