/[drupal]/contributions/modules/openid/openid.inc
ViewVC logotype

Diff of /contributions/modules/openid/openid.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2.2.3, Sun Oct 14 20:19:21 2007 UTC revision 1.2.2.4, Wed Jan 30 20:43:20 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: openid.inc,v 1.2.2.2 2007/05/24 15:01:21 walkah Exp $  // $Id: openid.inc,v 1.2.2.3 2007/10/14 20:19:21 walkah Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 193  function _openid_link_href($rel, $html) Line 193  function _openid_link_href($rel, $html)
193    $rel = preg_quote($rel);    $rel = preg_quote($rel);
194    preg_match('|<link\s+rel=["\'](.*)'. $rel .'(.*)["\'](.*)/?>|iU', $html, $matches);    preg_match('|<link\s+rel=["\'](.*)'. $rel .'(.*)["\'](.*)/?>|iU', $html, $matches);
195    if (isset($matches[3])) {    if (isset($matches[3])) {
196      preg_match('|href=["\']([^"]+)["\']|iU', $matches[0], $href);      preg_match('|href=["\']([^"]+)["\']|iU', $matches[3], $href);
197      return trim($href[1]);      return trim($href[1]);
198    }    }
199    return FALSE;    return FALSE;
# Line 206  function _openid_meta_httpequiv($equiv, Line 206  function _openid_meta_httpequiv($equiv,
206    preg_match('|<meta\s+http-equiv=["\']'. $equiv .'["\'](.*)/?>|iU', $html, $matches);    preg_match('|<meta\s+http-equiv=["\']'. $equiv .'["\'](.*)/?>|iU', $html, $matches);
207    if (isset($matches[1])) {    if (isset($matches[1])) {
208      preg_match('|content=["\']([^"]+)["\']|iU', $matches[1], $content);      preg_match('|content=["\']([^"]+)["\']|iU', $matches[1], $content);
209      return $content[1];      if (isset($content[1])) {
210          return $content[1];
211        }
212    }    }
213    return FALSE;    return FALSE;
214  }  }
# Line 382  function _openid_get_bytes($num_bytes) { Line 384  function _openid_get_bytes($num_bytes) {
384    return $bytes;    return $bytes;
385  }  }
386    
387  /**  function _openid_response($str = NULL) {
388   * Fix PHP's habit of replacing '.' by '_' in posted data.    $data = array();
389   */  
390  function _openid_fix_post(&$post) {    if (isset($_SERVER['REQUEST_METHOD'])) {
391    $extensions = module_invoke_all('openid', 'extension');      $data = _openid_get_params($_SERVER['QUERY_STRING']);
392    foreach ($post as $key => $value) {  
393      if (strpos($key, 'openid_') === 0) {      if ($_SERVER['REQUEST_METHOD'] == 'POST') {
394        $fixed_key = str_replace('openid_', 'openid.', $key);        $str = file_get_contents('php://input');
395        $fixed_key = str_replace('openid.ns_', 'openid.ns.', $fixed_key);  
396        $fixed_key = str_replace('openid.sreg_', 'openid.sreg.', $fixed_key);        $post = array();
397        foreach ($extensions as $ext) {        if ($str !== false) {
398          $fixed_key = str_replace('openid.'.$ext.'_', 'openid.'.$ext.'.', $fixed_key);          $post = _openid_get_params($str);
399        }        }
400        unset($post[$key]);  
401        $post[$fixed_key] = $value;        $data = array_merge($data, $post);
402        }
403      }
404    
405      return $data;
406    }
407    
408    function _openid_get_params($str) {
409      $chunks = explode("&", $str);
410    
411      $data = array();
412      foreach ($chunks as $chunk) {
413        $parts = explode("=", $chunk, 2);
414    
415        if (count($parts) == 2) {
416          list($k, $v) = $parts;
417          $data[$k] = urldecode($v);
418      }      }
419    }    }
420      return $data;
421  }  }
422    
423  /**  /**

Legend:
Removed from v.1.2.2.3  
changed lines
  Added in v.1.2.2.4

  ViewVC Help
Powered by ViewVC 1.1.2