request_var and normalize_nfc

Discussion forum for MOD Writers regarding MOD Development.
Locked
User avatar
hah
Registered User
Posts: 85
Joined: Sat Feb 13, 2010 11:49 am
Location: Pernik, Bulgaria
Name: Alex Georgiev
Contact:

request_var and normalize_nfc

Post by hah » Fri Feb 18, 2011 4:17 pm

Hello, I have problem with request_var.If I use it with template everything is fine, but when don't use template (external pages) for that I can't get multibyte symbols to work.

I use - utf8_normalize_nfc(request_var('message', '', true)) and thats the correct using for multibyte.

$_POST['message'] == "asd"
after going through utf8_normalize & request_var
result
asd

$_POST['message'] == "асд"
after going through utf8_normalize & request_var
result

(nothing)

As I said with template its find, but without..
Actually I use the format_date for class user and the day names don't get in cyrillic, too.

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: request_var and normalize_nfc

Post by 4_seven » Fri Feb 18, 2011 9:15 pm

try this in a php outside of phpbb3

Code: Select all

$post_message = $_POST['message']; // or $_GET ;)
$post_message = iconv("ISO-8859-1", "UTF-8", $post_message); 
also try this, if you want to transform from inside phpbb3 to outside

Code: Select all

$post_message = request_var('message', '', true);
$post_message = iconv("ISO-8859-1", "UTF-8", $post_message);   
or

Code: Select all

$post_message = utf8_normalize_nfc(request_var('message', '', true));
$post_message = iconv("ISO-8859-1", "UTF-8", $post_message);  
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
hah
Registered User
Posts: 85
Joined: Sat Feb 13, 2010 11:49 am
Location: Pernik, Bulgaria
Name: Alex Georgiev
Contact:

Re: request_var and normalize_nfc

Post by hah » Sun Feb 20, 2011 10:41 am

Well, no it doesn't work.Thats really awful..

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: request_var and normalize_nfc

Post by 4_seven » Sun Feb 20, 2011 3:05 pm

well, for me it works in all cases with such construct.
i think, it's because we don't know how exactly your construct is build.
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
AmigoJack
Registered User
Posts: 5616
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: request_var and normalize_nfc

Post by AmigoJack » Mon Feb 21, 2011 10:08 am

4_seven wrote:it's because we don't know how exactly your construct is build.
...and which encodings all of your files and forms do have.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: request_var and normalize_nfc

Post by 4_seven » Mon Feb 21, 2011 6:12 pm

AmigoJack wrote:
4_seven wrote:it's because we don't know how exactly your construct is build.
...and which encodings all of your files and forms do have.
yap, so it's wired..
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
hah
Registered User
Posts: 85
Joined: Sat Feb 13, 2010 11:49 am
Location: Pernik, Bulgaria
Name: Alex Georgiev
Contact:

Re: request_var and normalize_nfc

Post by hah » Tue Feb 22, 2011 9:35 am

Well, I'm telling you, non of this works I tried with several encoding's..

Here is the code

Code: Select all

<?php

define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
   
global $user, $db, $phpbb_root_path, $phpEx, $template, $cache;

    $limit = "12";
    $sql = "SELECT * FROM " . TOPICS_TABLE . " WHERE topic_approved = '1' ORDER BY topic_id DESC";
    $result = $db->sql_query_limit($sql, $limit, false);

    echo "<table border=\"0\" cellpadding=\"4\" cellspacing=\"2\" width=\"592\">
    <tr style='border: 1px solid #000;  background: #444;'>
    <td style='border: 1px solid #000;  background: url(images/bggg.png) repeat-x;'><center><img src=\"images/cs.png\" /></center></td><td style='border: 1px solid #000;  background: url(images/bg.png) repeat-x;'>Тема</td><td style='border: 1px solid #000;  background: url(images/bg.png) repeat-x;'>Автор</td><td style='border: 1px solid #000;  background: url(images/bg.png) repeat-x; text-align: center;'>Видяна</td><td style='border: 1px solid #000;  background: url(images/bg.png) repeat-x;'><center>Отговори</center></td>";

    while($topic = $db->sql_fetchrow($result)) {

    $topic_title = iconv("ISO-8859-1", "UTF-8", $topic['topic_title']));

    $sql2 = "SELECT * FROM " . USERS_TABLE . " WHERE user_id = '{$db->sql_escape($topic['topic_poster'])}'";
    $result2 = $db->sql_query_limit($sql2, 1, false);
    $topic_info = $db->sql_fetchrow($result2);

    echo "<tr><td style=\"border: 1px solid #000;  background: url(images/bg.png) repeat-x;\"><center><img src=\"images/cs.png\" /></center></td><td style='border: 1px solid #000;  background: url(images/bg.png) repeat-x;'><font color=\"white\"> <a href=\"{$phpbb_root_path}/viewtopic.php?f={$db->sql_escape($topic['forum_id'])}&t={$db->sql_escape($topic['topic_id'])}\" target=\"_blank\">{$db->sql_escape($topic_title)}</a></td><td style=\"border: 1px solid #000;  background: url(images/bg.png) repeat-x;\">{$db->sql_escape($topic_info['username'])}</td><td style='border: 1px solid #000;  background: url(images/bg.png) repeat-x;'>{$db->sql_escape($topic['topic_views'])}<td style='border: 1px solid #000; background: url(images/bg.png) repeat-x;'>{$db->sql_escape($topic['topic_replies'])}</td></tr>";

    }

    echo "</table>";

$db->sql_freeresult($result2);
$db->sql_freeresult($result);

?>

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: request_var and normalize_nfc

Post by 4_seven » Tue Feb 22, 2011 9:42 am

u have a direct php/template mix in one file :shock:
try first to seperate them in phpbb3/template syntax, then it should work
http://www.phpbb.com/kb/article/add-a-n ... -to-phpbb/
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
hah
Registered User
Posts: 85
Joined: Sat Feb 13, 2010 11:49 am
Location: Pernik, Bulgaria
Name: Alex Georgiev
Contact:

Re: request_var and normalize_nfc

Post by hah » Tue Feb 22, 2011 10:41 am

..I'm telling you that I don't want to use template.

Here is a quote from the first post
As I said with template its find, but without..

User avatar
AmigoJack
Registered User
Posts: 5616
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: request_var and normalize_nfc

Post by AmigoJack » Tue Feb 22, 2011 11:41 am

hah wrote:

Code: Select all

<?php
...
    echo "...{$db->sql_escape($topic['forum_id'])}...{$db->sql_escape($topic['topic_id'])}...{$db->sql_escape($topic_title)}...";
...
?>
This doesn't make sense - sql_escape() is meant for concatenating data into an SQL command only. Furthermore we still see no encoding, since you haven't posted your HTML head (and where are your request_var() and normalize_nfc() calls?). I doubt iconv() is needed at all - lookup in which encoding your data is stored in the database table(s) (it should be UTF-8) and use this encoding consequently by saving your file in UTF-8 and specifying a HTML content encoding of UTF-8.
The worst thing about censorship is ███████████
Affin wrote:
Tue Nov 20, 2018 9:51 am
The problem is probably not my English but you do not want to understand correctly.
...
We will not come anybody anyway, nevertheless, it's best to shit this.

Locked

Return to “[3.0.x] MOD Writers Discussion”