/[drupal]/contributions/modules/xmpp_server/xmpp_server.module
ViewVC logotype

Diff of /contributions/modules/xmpp_server/xmpp_server.module

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

revision 1.4, Thu Sep 25 08:23:37 2008 UTC revision 1.5, Thu Sep 25 21:55:22 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: xmpp_server.module,v 1.3 2008/09/25 06:45:41 t0talmeltd0wn Exp $  // $Id: xmpp_server.module,v 1.4 2008/09/25 08:23:37 t0talmeltd0wn Exp $
3    
4  $xmpp_server_xml_router = array();  $xmpp_server_xml_router = array();
5    
6    function xmpp_server_perm() {
7      return array('access xmpp server', 'administer xmpp server');
8    }
9    
10  /**  /**
11   * Implementation of hook_init().   * Implementation of hook_init().
12   */   */
# Line 109  function xmpp_server_xmpp_server_protoco Line 113  function xmpp_server_xmpp_server_protoco
113        //Shift the client and node onto the arguments to be passed.        //Shift the client and node onto the arguments to be passed.
114        array_unshift($rules['args'], $client, $node);        array_unshift($rules['args'], $client, $node);
115        //Call the function and keep the result to be sent back.        //Call the function and keep the result to be sent back.
116          echo "Calling $func()\n";
117        $ret[] = call_user_func_array($func, $rules['args']);        $ret[] = call_user_func_array($func, $rules['args']);
118      }      }
119    }    }
# Line 140  function _xmpp_server_is_callback_allowe Line 145  function _xmpp_server_is_callback_allowe
145    
146      //If the rules require authentication and we're not, return false.      //If the rules require authentication and we're not, return false.
147      if ($rules['authed'] && !$session['authed']) {      if ($rules['authed'] && !$session['authed']) {
148        return false;        return FALSE;
149      }      }
150      elseif ($rules['authed'] === false && $session['authed']) {      elseif ($rules['authed'] === FALSE && $session['authed']) {
151        return false;        return FALSE;
152      }      }
153    
154      //If the rules require us to be bound and we're not, return false.      //If the rules require us to be bound and we're not, return false.
155      if ($rules['bound'] && !$session['bound']) {      if ($rules['bound'] && !$session['bound']) {
156        return false;        return FALSE;
157      }      }
158      elseif ($rules['bound'] === false && $session['bound']) {      elseif ($rules['bound'] === FALSE && $session['bound']) {
159        return false;        return FALSE;
160      }      }
161    
162      if($rules['protocol'] && $rules['protocol'] != $client->protocol) {      if($rules['protocol'] && $rules['protocol'] != $client->protocol) {
163        return false;        return FALSE;
164      }      }
165    }    }
166    
167    //If our tag doesn't match the node's tag, return false.    //If our tag doesn't match the node's tag, return false.
168    if (!_xmpp_server_match_pair($rules['tag'], $node->tag)) {    if (!_xmpp_server_match_pair($rules['tag'], $node->tag)) {
169      return false;      return FALSE;
170    }    }
171    
172    //If any option fails, return false.    //If any option fails, return false.
# Line 223  function _xmpp_server_match_pair($patter Line 228  function _xmpp_server_match_pair($patter
228    
229    $replacement = NULL;    $replacement = NULL;
230    
     drupal_set_message("$pattern vs. $value");  
231    $first = substr($pattern, 0, 1);    $first = substr($pattern, 0, 1);
232    $controlchars = array('#', '!', '?');    $controlchars = array('#', '!', '?', '+');
233    if (in_array($first, $controlchars)) {    if (in_array($first, $controlchars)) {
234      $rest = substr($pattern, 1);      $rest = substr($pattern, 1);
235      switch ($first) {      switch ($first) {
# Line 242  function _xmpp_server_match_pair($patter Line 246  function _xmpp_server_match_pair($patter
246    
247          break;          break;
248        case '!':        case '!':
 /*        if (empty($rest) && !empty($value)) {  
           // The string '!' means 'Nothing allowed here'  
           return false;  
         }  
         else*/  
249          if (fnmatch($rest, $value) && !empty($value)) {          if (fnmatch($rest, $value) && !empty($value)) {
250            // The string '!*' means 'Anything but this value'            // The string '!*' means 'Anything but this value'
251            return false;            return false;
# Line 256  function _xmpp_server_match_pair($patter Line 255  function _xmpp_server_match_pair($patter
255          if (!empty($value) && !fnmatch($rest, $value)) {          if (!empty($value) && !fnmatch($rest, $value)) {
256            return false;            return false;
257          }          }
   
258          break;          break;
259        case '@': //Preprogrammed translated value        case '@': //Preprogrammed translated value
260          //If we've already gotten to it...          //If we've already gotten to it...
# Line 294  function _xmpp_server_match_pair($patter Line 292  function _xmpp_server_match_pair($patter
292            }            }
293          }          }
294          break;          break;
295          case '+':
296            if (empty($value)) {
297              return false;
298            }
299            break;
300      }      }
301    }    }
302    else {    else {
     drupal_set_message("$pattern vs. $value");  
303      if (!fnmatch($pattern, $value)) {      if (!fnmatch($pattern, $value)) {
304        //If the value did not match our pattern...        //If the value did not match our pattern...
305        return false;        return false;

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.2