[ Index ] |
PHP Cross Reference of phpBB 3.0 Beta 3 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * @package acp 5 * @version $Id: acp_jabber.php,v 1.15 2006/10/03 18:35:57 acydburn Exp $ 6 * @copyright (c) 2005 phpBB Group 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License 8 * 9 * @todo Check/enter/update transport info 10 */ 11 12 /** 13 * @package acp 14 */ 15 class acp_jabber 16 { 17 var $u_action; 18 19 function main($id, $mode) 20 { 21 global $db, $user, $auth, $template; 22 global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; 23 24 $user->add_lang('acp/board'); 25 26 include_once($phpbb_root_path . 'includes/functions_jabber.' . $phpEx); 27 28 $action = request_var('action', ''); 29 $submit = (isset($_POST['submit'])) ? true : false; 30 31 if ($mode != 'settings') 32 { 33 return; 34 } 35 36 $this->tpl_name = 'acp_jabber'; 37 $this->page_title = 'ACP_JABBER_SETTINGS'; 38 39 $jab_enable = request_var('jab_enable', $config['jab_enable']); 40 $jab_host = request_var('jab_host', $config['jab_host']); 41 $jab_port = request_var('jab_port', $config['jab_port']); 42 $jab_username = request_var('jab_username', $config['jab_username']); 43 $jab_password = request_var('jab_password', $config['jab_password']); 44 $jab_resource = request_var('jab_resource', $config['jab_resource']); 45 $jab_package_size = request_var('jab_package_size', $config['jab_package_size']); 46 47 $jabber = new jabber($jab_host, $jab_port, $jab_username, $jab_password, $jab_resource); 48 $error = array(); 49 50 $message = $user->lang['JAB_SETTINGS_CHANGED']; 51 $log = 'JAB_SETTINGS_CHANGED'; 52 53 // Are changing (or initialising) a new host or username? If so run some checks and 54 // try to create account if it doesn't exist 55 if ($jab_enable) 56 { 57 if (($jab_host != $config['jab_host'] || $jab_username != $config['jab_username']) && $jab_username) 58 { 59 if (!$jabber->connect()) 60 { 61 trigger_error($user->lang['ERR_JAB_CONNECT'] . adm_back_link($this->u_action), E_USER_WARNING); 62 } 63 64 // First we'll try to authorise using this account, if that fails we'll try to create it. 65 if (!($result = $jabber->send_auth())) 66 { 67 if (($result = $jabber->account_registration($config['board_email'], $config['sitename'])) <> 2) 68 { 69 $error[] = ($result == 1) ? $user->lang['ERR_JAB_USERNAME'] : sprintf($user->lang['ERR_JAB_REGISTER'], $result); 70 } 71 else 72 { 73 $message = $user->lang['JAB_REGISTERED']; 74 $log = 'JAB_REGISTER'; 75 } 76 } 77 else 78 { 79 $message = $user->lang['JAB_CHANGED']; 80 $log = 'JAB_CHANGED'; 81 } 82 83 sleep(1); 84 $jabber->disconnect(); 85 } 86 else if ($jab_password != $config['jab_password']) 87 { 88 if (!$jabber->connect()) 89 { 90 trigger_error($user->lang['ERR_JAB_CONNECT'] . adm_back_link($this->u_action), E_USER_WARNING); 91 } 92 93 if (!$jabber->send_auth()) 94 { 95 trigger_error($user->lang['ERR_JAB_AUTH'] . adm_back_link($this->u_action), E_USER_WARNING); 96 } 97 $jabber->send_presence(NULL, NULL, 'online'); 98 99 if (($result = $jabber->change_password($jab_password)) <> 2) 100 { 101 $error[] = ($result == 1) ? $user->lang['ERR_JAB_PASSCHG'] : sprintf($user->lang['ERR_JAB_PASSFAIL'], $result); 102 } 103 else 104 { 105 $message = $user->lang['JAB_PASS_CHANGED']; 106 $log = 'JAB_PASSCHG'; 107 } 108 109 sleep(1); 110 $jabber->disconnect(); 111 } 112 } 113 114 // Pull relevant config data 115 $sql = 'SELECT * 116 FROM ' . CONFIG_TABLE . " 117 WHERE config_name LIKE 'jab_%'"; 118 $result = $db->sql_query($sql); 119 120 while ($row = $db->sql_fetchrow($result)) 121 { 122 $config_name = $row['config_name']; 123 $config_value = $row['config_value']; 124 125 $default_config[$config_name] = $config_value; 126 $new[$config_name] = (isset($_POST[$config_name])) ? request_var($config_name, '') : $default_config[$config_name]; 127 128 if ($submit && !sizeof($error)) 129 { 130 set_config($config_name, $new[$config_name]); 131 } 132 } 133 134 if ($submit && !sizeof($error)) 135 { 136 add_log('admin', 'LOG_' . $log); 137 trigger_error($message . adm_back_link($this->u_action)); 138 } 139 140 if (sizeof($error)) 141 { 142 $template->assign_vars(array( 143 'S_WARNING' => true, 144 'WARNING_MSG' => implode('<br />', $error)) 145 ); 146 } 147 148 $template->assign_vars(array( 149 'U_ACTION' => $this->u_action, 150 'JAB_ENABLE' => $new['jab_enable'], 151 'L_JAB_SERVER_EXPLAIN' => sprintf($user->lang['JAB_SERVER_EXPLAIN'], '<a href="http://www.xmpp.net/" rel="external">', '</a>'), 152 'JAB_HOST' => $new['jab_host'], 153 'JAB_PORT' => $new['jab_port'], 154 'JAB_USERNAME' => $new['jab_username'], 155 'JAB_PASSWORD' => $new['jab_password'], 156 'JAB_RESOURCE' => $new['jab_resource'], 157 'JAB_PACKAGE_SIZE' => $new['jab_package_size']) 158 ); 159 } 160 } 161 162 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 22 00:35:05 2006 | Cross-referenced by PHPXref 0.6 |