Sākumlapa › Forumi › Mājas lapu izstrāde › PHPBB › Ajax čats bez garumzīmēm…
Mods
Datubāzē, valodas un ajax failā itkā kļūdas nemanu, bet, kad lietotājs ieraksta čatā kaut ko ar garumzīmēm, tad uzmetās ķeburi, kā šajā attēlā:
[img]
Iespējams, ka PHP kodā, kur pieslēdzas datu bāzei, vaig arī pievienot šādas 2 rindiņas:
mysql_query(“SET NAMES utf8”);
mysql_query(“SET CHARACTER SET utf8”);
uz aci varētu būt pie 1370. rindiņas.
//Lets delete this post :D
$sql = “DELETE FROM ” . SHOUTBOX_TABLE . ” WHERE shout_id = ” . $id;
if(!$db->sql_query($sql))
{
sql_error($sql, __LINE__, __FILE__);
}
else
{
print “
die;
}
}
break;
case “add”:
if($userdata[’user_id’] == ANONYMOUS )
{
}
else
{
//Remove all messages older as 2 weeks,
//Config option be a good thing for this?
$time = time() – (3600 * 24 * 14);//3600 seconds in 1 hour, 24 hours in a day, 14 days in 2 weeks.
$sql = “DELETE FROM ” . SHOUTBOX_TABLE . ” WHERE shout_time < $time";
if(!$db->sql_query($sql))
{
sql_error($SQL, __LINE__, __FILE__);
}
$current_time = time();
if($userdata[’user_level’] != ADMIN)
{
//
// Flood control
//
$sql = “SELECT MAX(shout_time) AS last_post_time
FROM ” . SHOUTBOX_TABLE . ”
WHERE shout_user_id = ” . $userdata[’user_id’];
if ( $result = $db->sql_query($sql) )
{
if ( $row = $db->sql_fetchrow($result) )
{
if ( $row[’last_post_time’] > 0 && ( $current_time – $row[’last_post_time’] ) sql_query($sql))
{
sql_error($sql, __LINE__, __FILE__);
}
print “
die;
}
}
break;
case “check”:
$last = intval($HTTP_GET_VARS[’last’]);
$sql = “SELECT shout_time AS s FROM ” . SHOUTBOX_TABLE . ”
ORDER BY shout_time DESC LIMIT 1″;
$result = $db->sql_query($sql);
if(!$result)
{
sql_error($sql, __LINE__, __FILE__);
}
else
{
$row = $db->sql_fetchrow($result);
$s = $row[’s’];
print “
die;
}
break;
case ‘nr’:
$sql = “SELECT COUNT(shout_id) as nr FROM ” . SHOUTBOX_TABLE;
$result = $db->sql_query($sql);
if(!$result)
{
sql_error($sql, __LINE__, __FILE__);
}
$row = $db->sql_fetchrow($result);
$row = (int)$row[’nr’];
print “
die;
break;
case ‘view’:
$start = intval($HTTP_GET_VARS[’start’]);
$start = ($start <0>sql_query($sql);
if(!$result)
{
sql_error($sql, __LINE__, __FILE__);
}
else
{
if(!$db->sql_numrows($result))
{
print “
die;
}
else
{
$i = 0;
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
while($row = $db->sql_fetchrow($result))
{
print “
$door = xml($row[’username’]);
$i++;
$row_color = ( !($i % 2) ) ? $theme[’td_color1’] : $theme[’td_color2’];
$row_class = ( !($i % 2) ) ? $theme[’td_class1’] : $theme[’td_class2’];
print “t
$row[’shout_time’] = create_date($board_config[’default_dateformat’], $row[’shout_time’], $board_config[’board_timezone’]);
if ( $board_config[’allow_smilies’] )
{
$row[’shout_text’] = smilies_pass($row[’shout_text’]);
}
if ( $board_config[’allow_bbcode’] )
{
$row[’shout_text’] = bbencode_second_pass($row[’shout_text’],$row[’shout_bbcode_uid’]);
}
$row[’shout_text’] = make_clickable($row[’shout_text’]);
$row[’shout_text’] = preg_replace($orig_word, $replacement_word, $row[’shout_text’]);
$row[’shout_text’] = str_replace(”n”, “
“, $row[’shout_text’]);
$x = (strlen(’
‘) – 1);
if(substr($row[’shout_text’], 0, $x) == ‘
‘)
{
$row[’shout_text’] = substr($row[’shout_text’], $x);
}
if($userdata[’user_level’] == ADMIN || $userdata[’user_level’] == MOD)
{
$row[’shout_ip’] = decode_ip($row[’shout_ip’]);
}
//Next items aren’t needed in XML.
unset($row[’shout_bbcode_uid’], $row[’user_allowsmile’]);
foreach($row as $el => $wa)
{
if(is_numeric($el))
{
continue;
}
print “t
}
print “n”;
}
print ““;
die;
}
}
break;
}
if(in_array($mode,$ajax_m))
{
print “
print ‘‘;
}
/**
* Returns cdata’d string
*
* @param string $txt
* @return string
*/
function xml($txt)
{
return “
}
/**
* Prints a XML error, if in XML modus. Else use default message_die.
*
* @param string $sql Sql query
* @param int $line Linenumber
* @param string $file Filename
*/
function sql_error($sql, $line = __LINE__, $file = __FILE__)
{
global $db, $mode, $ajax_m;
if(in_array($mode,$ajax_m))
{
$sql = xml($sql);
$err = $db->sql_error();
$err = xml($err[’message’]);
print “
print ‘‘;
die;
}
else
{
message_die(GENERAL_ERROR, “Could not run AJAX ShoutBox Query.”, “”, $line, $file, $sql);
}
}
?>
$row[’shout_text’] = preg_replace($orig_word, $replacement_word, $row[’shout_text’]);
$row[’shout_text’] = str_replace(”n”, “
“, $row[’shout_text’]);
starp vai aiz šīm rindiņām pamēģini ielikt
$row[’shout_text’] = urldecode($row[’shout_text’]);
Preses relīzes