cerbr
Messages postés14Date d'inscriptiondimanche 1 mai 2011StatutMembreDernière intervention20 août 2011
-
4 août 2011 à 15:21
cerbr
Messages postés14Date d'inscriptiondimanche 1 mai 2011StatutMembreDernière intervention20 août 2011
-
4 août 2011 à 15:58
Bonjour,
J'ai un probleme :
Fatal error: Cannot redeclare utf8RawUrlDecode() (previously declared in /home/httpd/c/e/r/cerbr/numericdoor.franceserv.com/chatbox.php:50) in /home/httpd/c/e/r/cerbr/numericdoor.franceserv.com/lang/French/chatbox.php on line 86
La page: http://numericdoor.franceserv.com/chatbox.php
PunBB is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
PunBB is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA
// Is it integrated with other page?
$inside = (basename($_SERVER['SCRIPT_FILENAME']) != 'chatbox.php');
if (!$inside)
{
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
}
require PUN_ROOT.'include/parser.php';
if (!$pun_config['cb_pbb_version'])
message('Poki BB Chatbox is not installed correctly. Please make sure you have launch install_mod.php');
if ($pun_user['g_read_board'] == '0')
message($lang_common['No view']);
$ajax = isset($_REQUEST['ajax']);
$errors = array();
// Load the chatbox.php and post.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/chatbox.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/post.php';
// Same funtion that php native rawurldecode() but with utf8 support
function utf8RawUrlDecode ($source)
{
$decodedStr = "";
$pos = 0;
$len = strlen($source);
while ($pos < $len)
{
$charAt = substr($source, $pos, 1);
if ($charAt == '%')
{
$pos++;
$charAt = substr($source, $pos, 1);
if ($charAt == 'u')
{
// We got a unicode character
$pos++;
$unicodeHexVal = substr($source, $pos, 4);
$unicode = hexdec($unicodeHexVal);
$entity = "". $unicode . ';';
$decodedStr .= utf8_encode($entity);
$pos += 4;
}
else
{
// We have an escaped ascii character
$hexVal = substr($source, $pos, 2);
$decodedStr .= chr(hexdec($hexVal));
$pos += 2;
}
} else
{
$decodedStr .= $charAt;
$pos++;
}
}
return $decodedStr;
}
// Error function for ajax queries
function error_ajax($message, $file = false, $line = false, $db_error = false)
{
global $pun_config, $db, $lang_chatbox, $errors, $ajax;
// If it's AJAX request
if ($ajax)
{
// Send no-cache headers
header('Expires: Thu, 21 Jul 1977 07:30:00 GMT'); // When yours truly first set eyes on this world! :)
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache'); // For HTTP/1.0 compability
header('Content-type: text/html; charset=utf-8');
}
if (isset($_GET['delete_message']))
{
$msg_id = intval($_GET['delete_message']);
if (!$pun_user['is_admmod'])
error_ajax($lang_common['No permission']);
if (empty($errors))
{
// We are not deleting message, but only "hide"
$db->query('UPDATE '.$db->prefix.'chatbox_msg SET poster_id=-1, posted='.time().' WHERE id='.$msg_id.' LIMIT 1') or error_ajax('Unable to delete post', __FILE__, __LINE__, $db->error());
}
if ($ajax)
{
echo 'delete;'.$msg_id;
$db->end_transaction();
$db->close();
exit;
}
}
if (isset($_POST['form_sent']))
{
// If new message was submit
if (isset($_POST['ajax']))
{
// Decode
$_POST['req_message'] = utf8RawUrlDecode($_POST['req_message']);
$_POST['form_user'] = utf8RawUrlDecode($_POST['form_user']);
if (isset($_POST['req_username']))
$_POST['req_username'] = utf8RawUrlDecode($_POST['req_username']);
if (isset($_POST['req_email']))
$_POST['req_email'] = utf8RawUrlDecode($_POST['req_email']);
if (isset($_POST['email']))
$_POST['email'] = utf8RawUrlDecode($_POST['email']);
}
// Make sure form_user is correct
if (($pun_user['is_guest'] && $_POST['form_user'] != 'Guest') || (!$pun_user['is_guest'] && $_POST['form_user'] != $pun_user['username']))
error_ajax($lang_common['Bad request']);
// Do we have permission to post?
if ($pun_user['g_post_chatbox'] != '1')
error_ajax($lang_chatbox['No Post Permission']);
// If it's Guest
if ($pun_user['is_guest'])
{
$result = $db->query('SELECT id, poster_ip, posted FROM '.$db->prefix.'chatbox_msg WHERE poster_ip=\''.get_remote_address().'\' ORDER BY posted DESC LIMIT 1') or error_ajax('Unable to fetch messages for flood protection', __FILE__, __LINE__, $db->error());
$cur_post = $db->fetch_assoc($result);
// If the user is logged in we get the username and e-mail from $pun_user
if (!$pun_user['is_guest'])
{
$username = $pun_user['username'];
$email = $pun_user['email'];
}
// Otherwise it should be in $_POST
else
{
$username = trim($_POST['req_username']);
$email = strtolower(trim(($pun_config['p_force_guest_email'] == '1') ? $_POST['req_email'] : $_POST['email']));
// Load the register.php/profile.php language files
require PUN_ROOT.'lang/'.$pun_user['language'].'/prof_reg.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/register.php';
// It's a guest, so we have to validate the username
if (strlen($username) < 2)
error_ajax($lang_prof_reg['Username too short']);
else if (!strcasecmp($username, 'Guest') || !strcasecmp($username, $lang_common['Guest']))
error_ajax($lang_prof_reg['Username guest']);
else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username))
error_ajax($lang_prof_reg['Username IP']);
// Check username for any censored words
$temp = censor_words($username);
if ($temp != $username)
error_ajax($lang_register['Username censor']);
// Check that the username (or a too similar username) is not already registered
$result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE username=\''.$db->escape($username).'\' OR username=\''.$db->escape(preg_replace('/[^\w]/', '', $username)).'\'') or error_ajax('Unable to fetch user info', __FILE__, __LINE__, $db->error());
if ($db->num_rows($result)) {
$busy = $db->result($result);
error_ajax($lang_register['Username dupe 1'].' '.pun_htmlspecialchars($busy).'. '.$lang_register['Username dupe 2']);
}
if ($pun_config['p_force_guest_email'] == '1' || $email != '') {
require PUN_ROOT.'include/email.php';
if (!is_valid_email($email))
error_ajax($lang_common['Invalid email']);
}
if (!empty($parse_errors))
error_ajax(implode("\n", $parse_errors));
// Get the time
$now = time();
if (empty($errors))
{
if (!$pun_user['is_guest'])
{
// Insert message
$db->query('INSERT INTO '.$db->prefix.'chatbox_msg (poster, poster_id, poster_ip, poster_email, message, posted) VALUES(\''.$db->escape($username).'\', '.$pun_user['id'].', \''.get_remote_address().'\', \''.$db->escape($email).'\', \''.$db->escape($message).'\', '.$now.')') or error_ajax('Unable to post message', __FILE__, __LINE__, $db->error());
// Increment his/her chatbox post count
$low_prio = ($db_type == 'mysql') ? 'LOW_PRIORITY ' : '';
$db->query('UPDATE '.$low_prio.$db->prefix.'users SET num_posts_chatbox=num_posts_chatbox+1, last_post_chatbox='.$now.' WHERE id='.$pun_user['id']) or error_ajax('Unable to update user', __FILE__, __LINE__, $db->error());
}
else
{
// Insert message
$email_sql = ($pun_config['p_force_guest_email'] == '1' || $email != '') ? '\''.$db->escape($email).'\'' : 'NULL';
$db->query('INSERT INTO '.$db->prefix.'chatbox_msg (poster, poster_id, poster_ip, poster_email, message, posted) VALUES(\''.$db->escape($username).'\', '.$pun_user['id'].', \''.get_remote_address().'\', '.$email_sql.', \''.$db->escape($message).'\', '.$now.')') or error_ajax('Unable to post message', __FILE__, __LINE__, $db->error());
}
$_POST['req_message'] = null;
}
if ($pun_config['cb_max_msg'] > 0)
{
$count = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'chatbox_msg') or error_ajax('Unable to fetch chatbox post count', __FILE__, __LINE__, $db->error());
$num_post = $db->result($count);
$result = $db->query('SELECT id, posted FROM '.$db->prefix.'chatbox_msg ORDER BY posted ASC LIMIT '.$limit) or error_ajax('Unable to select post to delete', __FILE__, __LINE__, $db->error());
while ($del_msg = $db->fetch_assoc($result))
$db->query('DELETE FROM '.$db->prefix.'chatbox_msg WHERE id = '.$del_msg['id'].' LIMIT 1') or error_ajax('Unable to delete post', __FILE__, __LINE__, $db->error());
}
}
// Now we list all new message
$cur_msg_txt = '';
$response = '';
$count_id = array();
if ($ajax)
{
// Are there any deleted messages?
$result = $db->query('SELECT m.id FROM '.$db->prefix.'chatbox_msg AS m WHERE m.id >= '.$first_msg_id.' AND m.id <= '.$last_msg_id.' AND m.poster_id = -1 ORDER BY m.id DESC') or error('Unable to fetch messages', __FILE__, __LINE__, $db->error());
if (count($del_msg_ids) > 0)
{
echo 'deleted:'.implode(',', $del_msg_ids)."\n";
// Clean temp messages
$db->query('DELETE FROM '.$db->prefix.'chatbox_msg WHERE poster_id = -1 AND posted < '.(time() - 60));// or error_ajax('Unable to delete post', __FILE__, __LINE__, $db->error());
}
}
// Are there any new messages?
$result = $db->query('SELECT m.id FROM '.$db->prefix.'chatbox_msg AS m WHERE m.id > '.$last_msg_id.' and m.poster_id != -1 ORDER BY m.id DESC LIMIT '.$pun_config['cb_max_msg']) or error_ajax('Unable to fetch messages', __FILE__, __LINE__, $db->error());
if (count($msg_ids) > 0)
{
$last_msg_id = $msg_ids[0];
$messages = $db->query('SELECT u.id, u.group_id, u.num_posts_chatbox, m.id AS m_id, m.poster_id, m.poster, m.poster_ip, m.poster_email, m.message, m.posted, g.g_id FROM '.$db->prefix.'chatbox_msg AS m INNER JOIN '.$db->prefix.'users AS u ON u.id=m.poster_id INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE m.id IN('.implode(',', $msg_ids).') ORDER BY m.id DESC') or error_ajax('Unable to fetch messages', __FILE__, __LINE__, $db->error());
if ($ajax)
{
echo $first_msg_id.';'.$last_msg_id."\n".$response;
$db->end_transaction();
$db->close();
exit;
}
// This particular function doesn't require forum-based moderator access. It can be used
// by all moderators and admins.
if (isset($_GET['get_host']))
{
if ($pun_user['g_id'] > PUN_MOD)
message($lang_common['No permission']);
// Is get_host an IP address or a post ID?
if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $_GET['get_host']))
$ip = $_GET['get_host'];
else {
$get_host = intval($_GET['get_host']);
if ($get_host < 1)
message($lang_common['Bad request']);
$result = $db->query('SELECT poster_ip FROM '.$db->prefix.'chatbox_msg WHERE id='.$get_host) or error('Unable to fetch post IP address', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
message($lang_common['Bad request']);
$ip = $db->result($result);
}
// Load the misc.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/misc.php';
message(sprintf($lang_misc['Host info 1'], $ip).'<br />'.sprintf($lang_misc['Host info 2'], @gethostbyaddr($ip)).'<br /><br /><a href="admin_users.php?show_users='.$ip.'">'.$lang_misc['Show more users'].'</a>');
}
Trouvez des réponses à vos questions sur la création de sites web, le référencement et les meilleures pratiques pour gérer un site. Échangez avec d'autres webmasters passionnés pour améliorer vos compétences en ligne et optimiser vos projets de site web.