diff options
| author | Meik Sievertsen <acydburn@phpbb.com> | 2005-04-10 11:21:01 +0000 |
|---|---|---|
| committer | Meik Sievertsen <acydburn@phpbb.com> | 2005-04-10 11:21:01 +0000 |
| commit | c9478353171267a3ebc5d87b43d759d22684b21e (patch) | |
| tree | 0c2de101bd65d5c24e73344be53b2d9619ce037d /phpBB/includes | |
| parent | a01705c7d04581871c3028d7369815ecd06fca75 (diff) | |
| download | forums-c9478353171267a3ebc5d87b43d759d22684b21e.tar forums-c9478353171267a3ebc5d87b43d759d22684b21e.tar.gz forums-c9478353171267a3ebc5d87b43d759d22684b21e.tar.bz2 forums-c9478353171267a3ebc5d87b43d759d22684b21e.tar.xz forums-c9478353171267a3ebc5d87b43d759d22684b21e.zip | |
- fixed custom profile field get/store
- changed tz lang array to hold more descriptive timezones (no more tz+-13, dst is a seperate option)
- fixed bugs after jabber queue processing (data being escaped differently)
git-svn-id: file:///svn/phpbb/trunk@5116 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
| -rw-r--r-- | phpBB/includes/acm/acm_file.php | 2 | ||||
| -rw-r--r-- | phpBB/includes/functions.php | 28 | ||||
| -rw-r--r-- | phpBB/includes/functions_jabber.php | 384 | ||||
| -rw-r--r-- | phpBB/includes/functions_messenger.php | 28 | ||||
| -rw-r--r-- | phpBB/includes/functions_profile_fields.php | 21 | ||||
| -rw-r--r-- | phpBB/includes/session.php | 1 |
6 files changed, 235 insertions, 229 deletions
diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php index 17dc484cb6..6ab8b53668 100644 --- a/phpBB/includes/acm/acm_file.php +++ b/phpBB/includes/acm/acm_file.php @@ -31,7 +31,7 @@ class acm global $phpEx; if (file_exists($this->cache_dir . 'data_global.' . $phpEx)) { - @include($this->cache_dir . 'data_global.' . $phpEx); + include($this->cache_dir . 'data_global.' . $phpEx); } else { diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 0e08133c23..7eacbe91fd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -96,6 +96,7 @@ function set_config($config_name, $config_value, $is_dynamic = false) if (!$is_dynamic) { $cache->destroy('config'); + $cache->save(); } } @@ -380,6 +381,18 @@ function make_jumpbox($action, $forum_id = false, $select_all = false, $acl_list while ($row = $db->sql_fetchrow($result)) { + if ($row['left_id'] < $right) + { + $padding++; + $padding_store[$row['parent_id']] = $padding; + } + else if ($row['left_id'] > $right + 1) + { + $padding = $padding_store[$row['parent_id']]; + } + + $right = $row['right_id']; + if ($row['forum_type'] == FORUM_CAT && ($row['left_id'] + 1 == $row['right_id'])) { // Non-postable forum with no subforums, don't display @@ -409,18 +422,6 @@ function make_jumpbox($action, $forum_id = false, $select_all = false, $acl_list $display_jumpbox = true; } - if ($row['left_id'] < $right) - { - $padding++; - $padding_store[$row['parent_id']] = $padding; - } - else if ($row['left_id'] > $right + 1) - { - $padding = $padding_store[$row['parent_id']]; - } - - $right = $row['right_id']; - $template->assign_block_vars('jumpbox_forums', array( 'FORUM_ID' => $row['forum_id'], 'FORUM_NAME' => $row['forum_name'], @@ -1360,6 +1361,7 @@ function login_forum_box(&$forum_data) } while ($row = $db->sql_fetchrow($result)); + // Remove expired sessions $sql = 'DELETE FROM ' . FORUMS_ACCESS_TABLE . ' WHERE session_id NOT IN (' . implode(', ', $sql_in) . ')'; $db->sql_query($sql); @@ -1887,7 +1889,7 @@ function page_header($page_title = '') 'S_CONTENT_ENCODING' => $user->lang['ENCODING'], 'S_CONTENT_DIR_LEFT' => $user->lang['LEFT'], 'S_CONTENT_DIR_RIGHT' => $user->lang['RIGHT'], - 'S_TIMEZONE' => ($user->data['user_dst'] || ($user->data['user_id'] == ANONYMOUS && $config['board_dst'])) ? sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], ''), + 'S_TIMEZONE' => ($user->data['user_dst'] || ($user->data['user_id'] == ANONYMOUS && $config['board_dst'])) ? sprintf($user->lang['ALL_TIMES'], (($tz >= 0) ? '+' . $tz : $tz), $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], (($tz >= 0) ? '+' . $tz : $tz), ''), 'S_DISPLAY_ONLINE_LIST' => (!empty($config['load_online'])) ? 1 : 0, 'S_DISPLAY_SEARCH' => (!empty($config['load_search'])) ? 1 : 0, 'S_DISPLAY_PM' => (!empty($config['allow_privmsg'])) ? 1 : 0, diff --git a/phpBB/includes/functions_jabber.php b/phpBB/includes/functions_jabber.php index dad000c088..a679b1508a 100644 --- a/phpBB/includes/functions_jabber.php +++ b/phpBB/includes/functions_jabber.php @@ -25,7 +25,7 @@ * Removed functions/support not critical to integration with phpBB * */ -class Jabber +class jabber { var $server; var $port; @@ -57,100 +57,99 @@ class Jabber var $returned_keep_alive; var $txnid; - var $CONNECTOR; + var $connector; - function Jabber() + function jabber() { - $this->port = "5222"; - + $this->port = '5222'; $this->resource = NULL; + $this->packet_queue = $this->subscription_queue = array(); + $this->iq_sleep_timer = $this->delay_disconnect = 1; - $this->packet_queue = $this->subscription_queue = array(); - - $this->iq_sleep_timer = $this->delay_disconnect = 1; - - $this->returned_keep_alive = TRUE; + $this->returned_keep_alive = true; $this->txnid = 0; $this->iq_version_name = "Class.Jabber.PHP -- http://phpjabber.g-blog.net -- by Carlo 'Gossip' Zottmann, gossip@jabber.g-blog.net"; $this->iq_version_version = '0.4'; $this->iq_version_os = $_SERVER['SERVER_SOFTWARE']; - $this->error_codes = array(400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Registration Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Remove Server Error', - 503 => 'Service Unavailable', - 504 => 'Remove Server Timeout', - 510 => 'Disconnected'); + $this->error_codes = array( + 400 => 'Bad Request', + 401 => 'Unauthorized', + 402 => 'Payment Required', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Registration Required', + 408 => 'Request Timeout', + 409 => 'Conflict', + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Remove Server Error', + 503 => 'Service Unavailable', + 504 => 'Remove Server Timeout', + 510 => 'Disconnected' + ); } - function Connect() + function connect() { - $this->CONNECTOR = new CJP_StandardConnector; + $this->connector = new cjp_standard_connector; - if ($this->CONNECTOR->OpenSocket($this->server, $this->port)) + if ($this->connector->open_socket($this->server, $this->port)) { - $this->SendPacket("<?xml version='1.0' encoding='UTF-8' ?" . ">\n"); - $this->SendPacket("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>\n"); + $this->send_packet("<?xml version='1.0' encoding='UTF-8' ?" . ">\n"); + $this->send_packet("<stream:stream to='{$this->server}' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>\n"); sleep(2); if ($this->_check_connected()) { - $this->connected = TRUE; // Nathan Fritz - return TRUE; + $this->connected = true; // Nathan Fritz + return true; } else { - return FALSE; + return false; } } else { - return FALSE; + return false; } } - function Disconnect() + function disconnect() { if (is_int($this->delay_disconnect)) { sleep($this->delay_disconnect); } - $this->SendPacket('</stream:stream>'); - $this->CONNECTOR->CloseSocket(); + $this->send_packet('</stream:stream>'); + $this->connector->close_socket(); } - function CruiseControl($seconds = -1) + function cruise_control($seconds = -1) { $count = 0; while ($count != $seconds) { - $this->Listen(); + $this->listen(); do { - $packet = $this->GetFirstFromQueue(); + $packet = $this->get_first_from_queue(); if ($packet) { - $this->CallHandler($packet); + $this->call_handler($packet); } } - while (count($this->packet_queue) > 1); + while (sizeof($this->packet_queue) > 1); $count += 0.25; usleep(250000); @@ -158,38 +157,38 @@ class Jabber if ($this->last_ping_time != date('H:i')) { // Modified by Nathan Fritz - if ($this->returned_keep_alive == FALSE) + if ($this->returned_keep_alive == false) { - $this->connected = FALSE; - $this->AddToLog('EVENT: Disconnected'); + $this->connected = false; + //EVENT: Disconnected } $this->returned_keep_alive = FALSE; $this->keep_alive_id = 'keep_alive_' . time(); - $this->SendPacket("<iq id='{$this->keep_alive_id}'/>", 'CruiseControl'); - $this->last_ping_time = date("H:i"); + $this->send_packet("<iq id='{$this->keep_alive_id}'/>", 'cruise_control'); + $this->last_ping_time = date('H:i'); } } - return TRUE; + return true; } - function SendAuth() + function send_auth() { $this->auth_id = 'auth_' . md5(time() . $_SERVER['REMOTE_ADDR']); $this->jid = "{$this->username}@{$this->server}/{$this->resource}"; // request available authentication methods $payload = "<username>{$this->username}</username>"; - $packet = $this->SendIq(NULL, 'get', $this->auth_id, 'jabber:iq:auth', $payload); + $packet = $this->send_iq(NULL, 'get', $this->auth_id, 'jabber:iq:auth', $payload); // was a result returned? - if ($this->GetInfoFromIqType($packet) == 'result' && $this->GetInfoFromIqId($packet) == $this->auth_id) + if ($this->get_info_from_iq_type($packet) == 'result' && $this->get_info_from_iq_id($packet) == $this->auth_id) { if (@function_exists('mhash') && isset($packet['iq']['#']['query'][0]['#']['sequence'][0]['#']) && isset($packet['iq']['#']['query'][0]['#']['token'][0]['#'])) { // auth_0k - return $this->_sendauth_0k($packet['iq']['#']['query'][0]['#']['token'][0]['#'], $packet['iq']['#']['query'][0]['#']['sequence'][0]['#']); + return $this->_sendauth_ok($packet['iq']['#']['query'][0]['#']['token'][0]['#'], $packet['iq']['#']['query'][0]['#']['sequence'][0]['#']); } elseif (@function_exists('mhash') && isset($packet['iq']['#']['query'][0]['#']['digest'])) { @@ -205,17 +204,17 @@ class Jabber else { // no result returned - return FALSE; + return false; } } - function AccountRegistration($reg_email = NULL, $reg_name = NULL) + function account_registration($reg_email = NULL, $reg_name = NULL) { - $packet = $this->SendIq($this->server, 'get', 'reg_01', 'jabber:iq:register'); + $packet = $this->send_iq($this->server, 'get', 'reg_01', 'jabber:iq:register'); if ($packet) { - $key = $this->GetInfoFromIqKey($packet); // just in case a key was passed back from the server + $key = $this->get_info_from_iq_key($packet); // just in case a key was passed back from the server unset($packet); $payload = "<username>{$this->username}</username> @@ -225,14 +224,14 @@ class Jabber $payload .= ($key) ? "<key>$key</key>\n" : ''; - $packet = $this->SendIq($this->server, 'set', 'reg_01', 'jabber:iq:register', $payload); + $packet = $this->send_iq($this->server, 'set', 'reg_01', 'jabber:iq:register', $payload); - if ($this->GetInfoFromIqType($packet) == 'result') + if ($this->get_info_from_iq_type($packet) == 'result') { $return_code = (isset($packet['iq']['#']['query'][0]['#']['registered'][0]['#'])) ? 1 : 2; $this->jid = ($this->resource) ? "{$this->username}@{$this->server}/{$this->resource}" : "{$this->username}@{$this->server}"; } - elseif ($this->GetInfoFromIqType($packet) == 'error' && isset($packet['iq']['#']['error'][0]['#'])) + elseif ($this->get_info_from_iq_type($packet) == 'error' && isset($packet['iq']['#']['error'][0]['#'])) { // "conflict" error, i.e. already registered if ($packet['iq']['#']['error'][0]['@']['code'] == '409') @@ -253,26 +252,26 @@ class Jabber } } - function ChangePassword($new_password) + function change_password($new_password) { - $packet = $this->SendIq($this->server, 'get', 'A0', 'jabber:iq:register'); + $packet = $this->send_iq($this->server, 'get', 'A0', 'jabber:iq:register'); if ($packet) { - $key = $this->GetInfoFromIqKey($packet); // just in case a key was passed back from the server + $key = $this->get_info_from_iq_key($packet); // just in case a key was passed back from the server unset($packet); $payload = "<username>{$this->username}</username> <password>{$new_password}</password>\n"; $payload .= ($key) ? "<key>$key</key>\n" : ''; - $packet = $this->SendIq($this->server, 'set', 'A0', 'jabber:iq:register', $payload); + $packet = $this->send_iq($this->server, 'set', 'A0', 'jabber:iq:register', $payload); - if ($this->GetInfoFromIqType($packet) == 'result') + if ($this->get_info_from_iq_type($packet) == 'result') { $return_code = (isset($packet['iq']['#']['query'][0]['#']['registered'][0]['#'])) ? 1 : 2; } - elseif ($this->GetInfoFromIqType($packet) == 'error' && isset($packet['iq']['#']['error'][0]['#'])) + elseif ($this->get_info_from_iq_type($packet) == 'error' && isset($packet['iq']['#']['error'][0]['#'])) { // "conflict" error, i.e. already registered if ($packet['iq']['#']['error'][0]['@']['code'] == '409') @@ -293,19 +292,19 @@ class Jabber } } - function SendPacket($xml) + function send_packet($xml) { $xml = trim($xml); - return ($this->CONNECTOR->WriteToSocket($xml)) ? TRUE : FALSE; + return ($this->connector->write_to_socket($xml)) ? true : false; } // get the transport registration fields // method written by Steve Blinch, http://www.blitzaffe.com - function TransportRegistrationDetails($transport) + function transport_registration_details($transport) { $this->txnid++; - $packet = $this->SendIq($transport, 'get', "reg_{$this->txnid}", "jabber:iq:register", NULL, $this->jid); + $packet = $this->send_iq($transport, 'get', "reg_{$this->txnid}", "jabber:iq:register", NULL, $this->jid); if ($packet) { @@ -329,14 +328,14 @@ class Jabber // register with the transport // method written by Steve Blinch, http://www.blitzaffe.com - function TransportRegistration($transport, $details) + function transport_registration($transport, $details) { $this->txnid++; - $packet = $this->SendIq($transport, 'get', "reg_{$this->txnid}", "jabber:iq:register", NULL, $this->jid); + $packet = $this->send_iq($transport, 'get', "reg_{$this->txnid}", "jabber:iq:register", NULL, $this->jid); if ($packet) { - $key = $this->GetInfoFromIqKey($packet); // just in case a key was passed back from the server + $key = $this->get_info_from_iq_key($packet); // just in case a key was passed back from the server unset($packet); $payload = ($key) ? "<key>$key</key>\n" : ''; @@ -345,9 +344,9 @@ class Jabber $payload .= "<$element>$value</$element>\n"; } - $packet = $this->SendIq($transport, 'set', "reg_{$this->txnid}", "jabber:iq:register", $payload); + $packet = $this->send_iq($transport, 'set', "reg_{$this->txnid}", "jabber:iq:register", $payload); - if ($this->GetInfoFromIqType($packet) == 'result') + if ($this->get_info_from_iq_type($packet) == 'result') { if (isset($packet['iq']['#']['query'][0]['#']['registered'][0]['#'])) { @@ -358,12 +357,12 @@ class Jabber $return_code = 2; } } - elseif ($this->GetInfoFromIqType($packet) == 'error') + elseif ($this->get_info_from_iq_type($packet) == 'error') { if (isset($packet['iq']['#']['error'][0]['#'])) { $return_code = "Error " . $packet['iq']['#']['error'][0]['@']['code'] . ": " . $packet['iq']['#']['error'][0]['#']; - $this->AddToLog('ERROR: TransportRegistration()'); + // ERROR: TransportRegistration() } } @@ -375,11 +374,11 @@ class Jabber } } - function Listen() + function listen() { - unset($incoming); + $incoming = ''; - while ($line = $this->CONNECTOR->ReadFromSocket(4096)) + while ($line = $this->connector->read_from_socket(4096)) { $incoming .= $line; } @@ -396,16 +395,16 @@ class Jabber } } - return TRUE; + return true; } - function StripJID($jid = NULL) + function strip_jid($jid = NULL) { preg_match('#(.*)\/(.*)#Ui', $jid, $temp); return ($temp[1] != '') ? $temp[1] : $jid; } - function SendMessage($to, $type = 'normal', $id = NULL, $content = NULL, $payload = NULL) + function send_message($to, $type = 'normal', $id = NULL, $content = NULL, $payload = NULL) { if ($to && is_array($content)) { @@ -418,12 +417,12 @@ class Jabber $xml = "<message to='$to' type='$type' id='$id'>\n"; - if ($content['subject']) + if (isset($content['subject']) && $content['subject']) { $xml .= '<subject>' . $content['subject'] . "</subject>\n"; } - if ($content['thread']) + if (isset($content['thread']) && $content['thread']) { $xml .= '<thread>' . $content['thread'] . "</thread>\n"; } @@ -432,22 +431,22 @@ class Jabber $xml .= $payload; $xml .= "</message>\n"; - if ($this->SendPacket($xml)) + if ($this->send_packet($xml)) { - return TRUE; + return true; } else { - return FALSE; + return false; } } else { - return FALSE; + return false; } } - function SendPresence($type = NULL, $to = NULL, $status = NULL, $show = NULL, $priority = NULL) + function send_presence($type = NULL, $to = NULL, $status = NULL, $show = NULL, $priority = NULL) { $xml = '<presence'; $xml .= ($to) ? " to='$to'" : ''; @@ -460,10 +459,10 @@ class Jabber $xml .= ($status || $show || $priority) ? "</presence>\n" : ''; - return ($this->SendPacket($xml)) ? TRUE : FALSE; + return ($this->send_packet($xml)) ? true : false; } - function SendError($to, $id = NULL, $error_number, $error_message = NULL) + function send_error($to, $id = NULL, $error_number, $error_message = NULL) { $xml = "<iq type='error' to='$to'"; $xml .= ($id) ? " id='$id'" : ''; @@ -473,17 +472,17 @@ class Jabber $xml .= "</error>\n"; $xml .= '</iq>'; - $this->SendPacket($xml); + $this->send_packet($xml); } - function GetFirstFromQueue() + function get_first_from_queue() { return array_shift($this->packet_queue); } - function GetFromQueueById($packet_type, $id) + function get_from_queue_by_id($packet_type, $id) { - $found_message = FALSE; + $found_message = false; foreach ($this->packet_queue as $key => $value) { @@ -496,30 +495,30 @@ class Jabber } } - return (is_array($found_message)) ? $found_message : FALSE; + return (is_array($found_message)) ? $found_message : false; } - function CallHandler($packet = NULL) + function call_handler($packet = NULL) { - $packet_type = $this->_get_packet_type($packet); + $packet_type = $this->_get_packet_type($packet); if ($packet_type == 'message') { $type = $packet['message']['@']['type']; $type = ($type != '') ? $type : 'normal'; - $funcmeth = "Handler_message_$type"; + $funcmeth = "handler_message_$type"; } elseif ($packet_type == 'iq') { $namespace = $packet['iq']['#']['query'][0]['@']['xmlns']; $namespace = str_replace(':', '_', $namespace); - $funcmeth = "Handler_iq_$namespace"; + $funcmeth = "handler_iq_$namespace"; } elseif ($packet_type == 'presence') { $type = $packet['presence']['@']['type']; $type = ($type != '') ? $type : 'available'; - $funcmeth = "Handler_presence_$type"; + $funcmeth = "handler_presence_$type"; } if ($funcmeth != '') @@ -534,20 +533,20 @@ class Jabber } else { - $this->Handler_NOT_IMPLEMENTED($packet); + $this->handler_not_implemented($packet); } } } - function SendIq($to = NULL, $type = 'get', $id = NULL, $xmlns = NULL, $payload = NULL, $from = NULL) + function send_iq($to = NULL, $type = 'get', $id = NULL, $xmlns = NULL, $payload = NULL, $from = NULL) { if (!preg_match('#^(get|set|result|error)$#', $type)) { unset($type); - return FALSE; + return false; } - elseif ($id && $xmlns) + else if ($id && $xmlns) { $xml = "<iq type='$type' id='$id'"; $xml .= ($to) ? " to='$to'" : ''; @@ -558,15 +557,15 @@ class Jabber </query> </iq>"; - $this->SendPacket($xml); + $this->send_packet($xml); sleep($this->iq_sleep_timer); - $this->Listen(); + $this->listen(); - return (preg_match('#^(get|set)$#', $type)) ? $this->GetFromQueueById('iq', $id) : TRUE; + return (preg_match('#^(get|set)$#', $type)) ? $this->get_from_queue_by_id('iq', $id) : true; } else { - return FALSE; + return false; } } @@ -575,7 +574,7 @@ class Jabber // private methods // ====================================================================== - function _sendauth_0k($zerok_token, $zerok_sequence) + function _sendauth_ok($zerok_token, $zerok_sequence) { // initial hash of password $zerok_hash = @mhash(MHASH_SHA1, $this->password); @@ -596,10 +595,10 @@ class Jabber <hash>$zerok_hash</hash> <resource>{$this->resource}</resource>"; - $packet = $this->SendIq(NULL, 'set', $this->auth_id, 'jabber:iq:auth', $payload); + $packet = $this->send_iq(NULL, 'set', $this->auth_id, 'jabber:iq:auth', $payload); // was a result returned? - return ($this->GetInfoFromIqType($packet) == 'result' && $this->GetInfoFromIqId($packet) == $this->auth_id) ? TRUE : FALSE; + return ($this->get_info_from_iq_type($packet) == 'result' && $this->get_info_from_iq_id($packet) == $this->auth_id) ? true : false; } function _sendauth_digest() @@ -608,10 +607,10 @@ class Jabber <resource>{$this->resource}</resource> <digest>" . bin2hex(mhash(MHASH_SHA1, $this->stream_id . $this->password)) . "</digest>"; - $packet = $this->SendIq(NULL, 'set', $this->auth_id, 'jabber:iq:auth', $payload); + $packet = $this->send_iq(NULL, 'set', $this->auth_id, 'jabber:iq:auth', $payload); // was a result returned? - return ($this->GetInfoFromIqType($packet) == 'result' && $this->GetInfoFromIqId($packet) == $this->auth_id) ? TRUE : FALSE; + return ($this->get_info_from_iq_type($packet) == 'result' && $this->get_info_from_iq_id($packet) == $this->auth_id) ? true : false; } function _sendauth_plaintext() @@ -620,17 +619,17 @@ class Jabber <password>{$this->password}</password> <resource>{$this->resource}</resource>"; - $packet = $this->SendIq(NULL, 'set', $this->auth_id, 'jabber:iq:auth', $payload); + $packet = $this->send_iq(NULL, 'set', $this->auth_id, 'jabber:iq:auth', $payload); // was a result returned? - return ($this->GetInfoFromIqType($packet) == 'result' && $this->GetInfoFromIqId($packet) == $this->auth_id) ? TRUE : FALSE; + return ($this->get_info_from_iq_type($packet) == 'result' && $this->get_info_from_iq_id($packet) == $this->auth_id) ? true : false; } function _listen_incoming() { - unset($incoming); - - while ($line = $this->CONNECTOR->ReadFromSocket(4096)) + $incoming = ''; + + while ($line = $this->connector->read_from_socket(4096)) { $incoming .= $line; } @@ -651,16 +650,16 @@ class Jabber { $this->stream_id = $incoming_array['stream:stream']['@']['id']; - return TRUE; + return true; } else { - return FALSE; + return false; } } else { - return FALSE; + return false; } } @@ -669,7 +668,7 @@ class Jabber $temp = preg_split('#<(message|iq|presence|stream)#', $incoming, -1, PREG_SPLIT_DELIM_CAPTURE); $array = array(); - for ($a = 1; $a < count($temp); $a = $a + 2) + for ($a = 1; $a < sizeof($temp); $a = $a + 2) { $array[] = '<' . $temp[$a] . $temp[($a + 1)]; } @@ -685,7 +684,7 @@ class Jabber $packet_type = key($packet); } - return ($packet_type) ? $packet_type : FALSE; + return ($packet_type) ? $packet_type : false; } // _array_htmlspecialchars() @@ -707,82 +706,82 @@ class Jabber // <message/> parsers // ====================================================================== - function GetInfoFromMessageFrom($packet = NULL) + function get_info_from_message_from($packet = NULL) { - return (is_array($packet)) ? $packet['message']['@']['from'] : FALSE; + return (is_array($packet)) ? $packet['message']['@']['from'] : false; } - function GetInfoFromMessageType($packet = NULL) + function get_info_from_message_type($packet = NULL) { - return (is_array($packet)) ? $packet['message']['@']['type'] : FALSE; + return (is_array($packet)) ? $packet['message']['@']['type'] : false; } - function GetInfoFromMessageId($packet = NULL) + function get_info_from_message_id($packet = NULL) { - return (is_array($packet)) ? $packet['message']['@']['id'] : FALSE; + return (is_array($packet)) ? $packet['message']['@']['id'] : false; } - function GetInfoFromMessageThread($packet = NULL) + function get_info_from_message_thread($packet = NULL) { - return (is_array($packet)) ? $packet['message']['#']['thread'][0]['#'] : FALSE; + return (is_array($packet)) ? $packet['message']['#']['thread'][0]['#'] : false; } - function GetInfoFromMessageSubject($packet = NULL) + function get_info_from_message_subject($packet = NULL) { - return (is_array($packet)) ? $packet['message']['#']['subject'][0]['#'] : FALSE; + return (is_array($packet)) ? $packet['message']['#']['subject'][0]['#'] : false; } - function GetInfoFromMessageBody($packet = NULL) + function get_info_from_message_body($packet = NULL) { - return (is_array($packet)) ? $packet['message']['#']['body'][0]['#'] : FALSE; + return (is_array($packet)) ? $packet['message']['#']['body'][0]['#'] : false; } - function GetInfoFromMessageError($packet = NULL) + function get_info_from_message_error($packet = NULL) { $error = preg_replace('#^\/$#', '', ($packet['message']['#']['error'][0]['@']['code'] . '/' . $packet['message']['#']['error'][0]['#'])); - return (is_array($packet)) ? $error : FALSE; + return (is_array($packet)) ? $error : false; } // ====================================================================== // <iq/> parsers // ====================================================================== - function GetInfoFromIqFrom($packet = NULL) + function get_info_from_iq_from($packet = NULL) { - return (is_array($packet)) ? $packet['iq']['@']['from'] : FALSE; + return (is_array($packet)) ? $packet['iq']['@']['from'] : false; } - function GetInfoFromIqType($packet = NULL) + function get_info_from_iq_type($packet = NULL) { - return (is_array($packet)) ? $packet['iq']['@']['type'] : FALSE; + return (is_array($packet)) ? $packet['iq']['@']['type'] : false; } - function GetInfoFromIqId($packet = NULL) + function get_info_from_iq_id($packet = NULL) { - return (is_array($packet)) ? $packet['iq']['@']['id'] : FALSE; + return (is_array($packet)) ? $packet['iq']['@']['id'] : false; } - function GetInfoFromIqKey($packet = NULL) + function get_info_from_iq_key($packet = NULL) { - return (is_array($packet)) ? $packet['iq']['#']['query'][0]['#']['key'][0]['#'] : FALSE; + return (is_array($packet)) ? $packet['iq']['#']['query'][0]['#']['key'][0]['#'] : false; } - function GetInfoFromIqError($packet = NULL) + function get_info_from_iq_error($packet = NULL) { $error = preg_replace('#^\/$#', '', ($packet['iq']['#']['error'][0]['@']['code'] . '/' . $packet['iq']['#']['error'][0]['#'])); - return (is_array($packet)) ? $error : FALSE; + return (is_array($packet)) ? $error : false; } // ====================================================================== // <message/> handlers // ====================================================================== - function Handler_message_normal($packet) + function handler_message_normal($packet) { $from = $packet['message']['@']['from']; } - function Handler_message_error($packet) + function handler_message_error($packet) { $from = $packet['message']['@']['from']; } @@ -792,29 +791,29 @@ class Jabber // ====================================================================== // simple client authentication - function Handler_iq_jabber_iq_auth($packet) + function handler_iq_jabber_iq_auth($packet) { - $from = $this->GetInfoFromIqFrom($packet); - $id = $this->GetInfoFromIqId($packet); + $from = $this->get_info_from_iq_from($packet); + $id = $this->get_info_from_iq_id($packet); - $this->SendError($from, $id, 501); + $this->send_error($from, $id, 501); } // method for interactive registration - function Handler_iq_jabber_iq_register($packet) + function handler_iq_jabber_iq_register($packet) { - $from = $this->GetInfoFromIqFrom($packet); - $id = $this->GetInfoFromIqId($packet); + $from = $this->get_info_from_iq_from($packet); + $id = $this->get_info_from_iq_id($packet); - $this->SendError($from, $id, 501); + $this->send_error($from, $id, 501); } // keepalive method, added by Nathan Fritz - function Handler_iq_($packet) + function handler_iq_($packet) { - if ($this->keep_alive_id == $this->GetInfoFromIqId($packet)) + if ($this->keep_alive_id == $this->get_info_from_iq_id($packet)) { - $this->returned_keep_alive = TRUE; + $this->returned_keep_alive = true; } } @@ -823,13 +822,13 @@ class Jabber // ====================================================================== // Generic handler for unsupported requests - function Handler_NOT_IMPLEMENTED($packet) + function handler_not_implemented($packet) { $packet_type = $this->_get_packet_type($packet); - $from = call_user_func(array(&$this, 'GetInfoFrom' . ucfirst($packet_type) . 'From'), $packet); - $id = call_user_func(array(&$this, 'GetInfoFrom' . ucfirst($packet_type) . 'Id'), $packet); + $from = call_user_func(array(&$this, 'get_info_from_' . strtolower($packet_type) . '_from'), $packet); + $id = call_user_func(array(&$this, 'get_info_from_' . strtolower($packet_type) . '_id'), $packet); - $this->SendError($from, $id, 501); + $this->send_error($from, $id, 501); } // Third party code @@ -861,12 +860,12 @@ class Jabber { $children = array(); - if ($vals[$i]['value']) + if (isset($vals[$i]['value']) && $vals[$i]['value']) { array_push($children, trim($vals[$i]['value'])); } - while (++$i < count($vals)) + while (++$i < sizeof($vals)) { switch ($vals[$i]['type']) { @@ -876,9 +875,9 @@ class Jabber case 'complete': $tagname = $vals[$i]['tag']; - $size = sizeof($children[$tagname]); - $children[$tagname][$size]['#'] = trim($vals[$i]['value']); - if ($vals[$i]['attributes']) + $size = (isset($children[$tagname])) ? sizeof($children[$tagname]) : 0; + $children[$tagname][$size]['#'] = (isset($vals[$i]['value'])) ? trim($vals[$i]['value']) : ''; + if (isset($vals[$i]['attributes']) && $vals[$i]['attributes']) { $children[$tagname][$size]['@'] = $vals[$i]['attributes']; } @@ -886,7 +885,7 @@ class Jabber case 'open': $tagname = $vals[$i]['tag']; - $size = sizeof($children[$tagname]); + $size = (isset($children[$tagname])) ? sizeof($children[$tagname]) : 0; if ($vals[$i]['attributes']) { $children[$tagname][$size]['@'] = $vals[$i]['attributes']; @@ -907,9 +906,9 @@ class Jabber return $children; } - // TraverseXMLize() + // traverse_xmlize() // (c) acebone@f2s.com, a HUGE help! - function TraverseXMLize($array, $arrName = 'array', $level = 0) + function traverse_xmlize($array, $arr_name = 'array', $level = 0) { if ($level == 0) { @@ -920,11 +919,11 @@ class Jabber { if (is_array($val)) { - $this->TraverseXMLize($val, $arrName . '[' . $key . ']', $level + 1); + $this->traverse_xmlize($val, $arr_name . '[' . $key . ']', $level + 1); } else { - echo '$' . $arrName . '[' . $key . '] = "' . $val . "\"\n"; + echo '$' . $arr_name . '[' . $key . '] = "' . $val . "\"\n"; } } @@ -937,18 +936,19 @@ class Jabber /** * @package phpBB3 -* MakeXML +* make_xml +* Currently not in use */ -class MakeXML extends Jabber +class make_xml extends jabber { var $nodes; - function MakeXML() + function make_xml() { $nodes = array(); } - function AddPacketDetails($string, $value = NULL) + function add_packet_details($string, $value = NULL) { if (preg_match('#\(([0-9]*)\)$#i', $string)) { @@ -971,7 +971,7 @@ class MakeXML extends Jabber eval('$this->nodes' . $node . ' = "' . htmlspecialchars($value) . '";'); } - function BuildPacket($array = NULL) + function build_packet($array = NULL) { if (!$array) { @@ -1010,7 +1010,7 @@ class MakeXML extends Jabber $text .= '>'; } - $text .= $this->BuildPacket($value[$a]); + $text .= $this->build_packet($value[$a]); $text .= "</$key>\n"; } } @@ -1034,47 +1034,47 @@ class MakeXML extends Jabber $newarray[$key] = $val; } } - return (is_array($newarray)) ? $newarray : FALSE; + return (is_array($newarray)) ? $newarray : false; } } /** * @package phpBB3 -* Connector +* connector */ -class CJP_StandardConnector +class cjp_standard_connector { var $active_socket; - function OpenSocket($server, $port) + function open_socket($server, $port) { if ($this->active_socket = @fsockopen($server, $port, $err, $err2, 5)) { @socket_set_blocking($this->active_socket, 0); @socket_set_timeout($this->active_socket, 31536000); - return TRUE; + return true; } else { - return FALSE; + return false; } } - function CloseSocket() + function close_socket() { return @fclose($this->active_socket); } - function WriteToSocket($data) + function write_to_socket($data) { return @fwrite($this->active_socket, $data); } - function ReadFromSocket($chunksize) + function read_from_socket($chunksize) { $buffer = stripslashes(@fread($this->active_socket, $chunksize)); - @set_magic_quotes_runtime(get_magic_quotes_gpc()); + //@set_magic_quotes_runtime(get_magic_quotes_gpc()); return $buffer; } diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 1e731fecff..fdcbf74ab5 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -370,7 +370,7 @@ class messenger if (!$use_queue) { include_once($phpbb_root_path . 'includes/functions_jabber.'.$phpEx); - $this->jabber = new Jabber; + $this->jabber = new jabber; $this->jabber->server = $config['jab_host']; $this->jabber->port = ($config['jab_port']) ? $config['jab_port'] : 5222; @@ -378,32 +378,32 @@ class messenger $this->jabber->password = $config['jab_password']; $this->jabber->resource = ($config['jab_resource']) ? $config['jab_resource'] : ''; - if (!$this->jabber->Connect()) + if (!$this->jabber->connect()) { $this->error('JABBER', 'Could not connect to Jabber server'); return false; } - if (!$this->jabber->SendAuth()) + if (!$this->jabber->send_auth()) { $this->error('JABBER', 'Could not authorise on Jabber server'); return false; } - $this->jabber->SendPresence(NULL, NULL, 'online'); + $this->jabber->send_presence(NULL, NULL, 'online'); foreach ($addresses as $address) { - $this->jabber->SendMessage($address, 'normal', NULL, array('body' => $msg)); + $this->jabber->send_message($address, 'normal', NULL, array('body' => $msg)); } sleep(1); - $this->jabber->Disconnect(); + $this->jabber->disconnect(); } else { $this->queue->put('jabber', array( 'addresses' => $addresses, - 'subject' => htmlentities($subject), + 'subject' => htmlentities($this->subject), 'msg' => htmlentities($this->msg)) ); } @@ -449,7 +449,7 @@ class queue { global $db, $config, $phpEx, $phpbb_root_path; - set_config('last_queue_run', time()); + set_config('last_queue_run', time(), true); // Delete stale lock file if (file_exists($this->cache_file . '.lock') && !file_exists($this->cache_file)) @@ -494,7 +494,7 @@ class queue } include_once($phpbb_root_path . 'includes/functions_jabber.'.$phpEx); - $this->jabber = new Jabber; + $this->jabber = new jabber; $this->jabber->server = $config['jab_host']; $this->jabber->port = ($config['jab_port']) ? $config['jab_port'] : 5222; @@ -502,18 +502,18 @@ class queue $this->jabber->password = $config['jab_password']; $this->jabber->resource = ($config['jab_resource']) ? $config['jab_resource'] : ''; - if (!$this->jabber->Connect()) + if (!$this->jabber->connect()) { messenger::error('JABBER', 'Could not connect to Jabber server'); continue 2; } - if (!$this->jabber->SendAuth()) + if (!$this->jabber->send_auth()) { messenger::error('JABBER', 'Could not authorise on Jabber server'); continue 2; } - $this->jabber->SendPresence(NULL, NULL, 'online'); + $this->jabber->send_presence(NULL, NULL, 'online'); break; default: @@ -545,7 +545,7 @@ class queue case 'jabber': foreach ($addresses as $address) { - $this->jabber->SendMessage($address, 'normal', NULL, array('body' => $msg)); + $this->jabber->send_message($address, 'normal', NULL, array('body' => $msg)); } break; } @@ -564,7 +564,7 @@ class queue // Hang about a couple of secs to ensure the messages are // handled, then disconnect sleep(1); - $this->jabber->Disconnect(); + $this->jabber->disconnect(); break; } } diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index 2133463eb7..f0d44dd1c1 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -153,7 +153,7 @@ class custom_profile } // Assign fields to template, mode can be profile (for profile change) or register (for registration) -// function generate_profile_fields($mode, $lang_id, $cp_error) + // function generate_profile_fields($mode, $lang_id, $cp_error) function generate_profile_fields($mode, $lang_id) { global $db, $template, $auth; @@ -227,7 +227,7 @@ class custom_profile else if ($i = strpos($ident, '_bbcode')) { // Add extra data (bbcode_uid and bbcode_bitfield) to the data for this profile field. - // TODO: Maybe we should try to make this a bit more generic (not limited to bbcode)? + // TODO: Maybe we should try to make this a bit more generic (not limited to bbcode)? $field = substr($ident, 0, $i); $subfield = substr($ident, $i+1); $user_fields[$row['user_id']][$field]['data'][$subfield] = $value; @@ -373,7 +373,7 @@ class custom_profile break; case 'text': // Prepare further, censor_text, smilies, bbcode, html, whatever - if ($ident_ary['data']['bbcode_bitfield']) + if ($ident_ary['data']['bbcode_bitfield']) { $bbcode = new bbcode($ident_ary['data']['bbcode_bitfield']); $bbcode->bbcode_second_pass($value, $ident_ary['data']['bbcode_uid'], $ident_ary['data']['bbcode_bitfield']); @@ -416,7 +416,7 @@ class custom_profile } else { - $value = (isset($_REQUEST[$profile_row['field_ident']])) ? request_var($profile_row['field_ident'], $default_value) : ((!isset($user->profile_fields[$profile_row['field_ident']]) || $preview) ? $default_value : $user->profile_fields[$profile_row['field_ident']]); + $value = (isset($_REQUEST[$profile_row['field_ident']])) ? request_var($profile_row['field_ident'], $default_value) : ((!isset($user->profile_fields[str_replace('pf_', '', $profile_row['field_ident'])]) || $preview) ? $default_value : $user->profile_fields[str_replace('pf_', '', $profile_row['field_ident'])]); } switch ($field_validation) @@ -526,7 +526,7 @@ class custom_profile global $template; // Get the data associated with this field for this user - $value = $this->get_var('', $profile_row, $profile_row['lang_default_value'], $preview); + $value = $this->get_var('', $profile_row, $profile_row['lang_default_value'], $preview); $this->set_tpl_vars($profile_row, $value); return $this->get_cp_html(); @@ -538,7 +538,8 @@ class custom_profile global $user; $value = $this->get_var('', $profile_row, $profile_row['lang_default_value'], $preview); - if ($preview == false) + + if ($preview == false) { $message_parser = new parse_message(); $message_parser->message = $value; @@ -663,12 +664,14 @@ class custom_profile $message_parser = new parse_message(request_var($var_name, '')); // Get the allowed settings from the global settings. Magic URLs are always set to true. - // TODO: It might be nice to make this a per field setting. + // TODO: It might be nice to make this a per field setting. $message_parser->parse($config['allow_html'], $config['allow_bbcode'], true, $config['allow_smilies']); - $var = array($profile_row['field_ident'] => $message_parser->message, + $var = array( + $profile_row['field_ident'] => $message_parser->message, $profile_row['field_ident'] . '_bbcode_uid' => $message_parser->bbcode_uid, $profile_row['field_ident'] . '_bbcode_bitfield' => $message_parser->bbcode_bitfield, - 'submitted' => request_var($var_name, '')); + 'submitted' => request_var($var_name, '') + ); break; default: $var = request_var($var_name, $profile_row['field_default_value']); diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index d443e5bac1..28d46dd5d6 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1220,6 +1220,7 @@ class auth // If login returned anything other than an array there was an error if (!is_array($login)) { + // TODO: Login Attempt++ return $login; } |
