| 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 |
*/ |
*/ |
| 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 |
} |
} |
| 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. |
| 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) { |
| 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; |
| 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... |
| 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; |