| |
|
| :: |
| Author |
Message |
AmirAbbas phpBB SEO Team


Joined: 11 May 2006 Posts: 529 Location: IRAN
|
|
| Back to top |
|
 |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14279
|
Posted: Wed Jul 19, 2006 8:16 am Post subject: Re: mixed rewrite mod and persian UTF-8 encoding |
|
|
| dcz wrote: | All right I think I have got it
So forget about the suggested changes and do this instead, in the function.php code :
Find :
| Code: | function format_url($url)
{ |
After add :
| Code: |
$url = preg_replace('/&#[0-9]{4};/i', "", $url); |
And then, to take care of the empty case, when all is the title is posted in Persian, find :
Before add :
| Code: | | $url = ($url == '') ? 'topic' : $url; |
and as before add the topic rewriterule for the empty title case (all Persian).
Actually, this make the mod very powerful in utf-8 as, general titles are most likely not to be made with English words and will thus be rewritten statically where the mixed titles will see keywords injected in URLs.
Tell me what you think, I think it's final now
++ |
Soory it was function, but did you try this one, to me it worked nice. |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
AmirAbbas phpBB SEO Team


Joined: 11 May 2006 Posts: 529 Location: IRAN
|
Posted: Wed Jul 19, 2006 8:25 am Post subject: Re: mixed rewrite mod and persian UTF-8 encoding |
|
|
yes i tried both of that tricks
none of them work
you said that it works fine for you
are you sure that charset of your page is UTF-8 ?
you must change encoding form lang_main.php |
_________________ چهار گوش - طراحی وب - مجله طراحی وب |
|
| Back to top |
|
 |
AmirAbbas phpBB SEO Team


Joined: 11 May 2006 Posts: 529 Location: IRAN
|
Posted: Wed Jul 19, 2006 8:33 am Post subject: Re: mixed rewrite mod and persian UTF-8 encoding |
|
|
you can use this file
this files contains some persian utf-8 sentences
-http://rapidshare.de/files/26262995/utf-8_sentences.txt.html |
_________________ چهار گوش - طراحی وب - مجله طراحی وب |
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14279
|
Posted: Wed Jul 19, 2006 8:57 am Post subject: Re: mixed rewrite mod and persian UTF-8 encoding |
|
|
Well, there must be something wrong, because, all the sentences you sent me works fine
این فایل برای phpbb-seo site فرستاده شده
=> phpbb-seo-site
طراحی و ب را از HTML آغاز کنید
=> html
با این فایل میتوانید همه چیز را چک کنید
=> topic
The only example that cause problems to me is the one with "test" in it as it's too long to be pasted in the title box
All those are coded in html ASCII, no matter the initial standard it seems.
Quote this message and preview it, you'll see the source.
Then, if it's not working for you, please start again with a fresh format_url code before you add those two lines.
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
AmirAbbas phpBB SEO Team


Joined: 11 May 2006 Posts: 529 Location: IRAN
|
Posted: Fri Jul 21, 2006 6:54 am Post subject: Re: mixed rewrite mod and persian UTF-8 encoding |
|
|
| dcz wrote: | | Then, if it's not working for you, please start again with a fresh format_url code before you add those two lines. |
its not clear form me
i tested it many time
it doesn't work
you can test it yourself
-http://rapidshare.de/files/26486807/phpbbtest.zip.html
file size: 700 kb
first make a folder with name phpbbtest and pull all this files on it
after that make a database with name phpbbtest and import the database that is in zip package
it takes two minute
this package has phpbb 2.0.21 + persian language pack + a persian database with a few post and forums + advance rewrite mod + utf-8 trick
it takes two minute to test  |
_________________ چهار گوش - طراحی وب - مجله طراحی وب |
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14279
|
Posted: Fri Jul 21, 2006 11:34 am Post subject: Re: mixed rewrite mod and persian UTF-8 encoding |
|
|
All right,
Jeez, this char-set things are really tricky, humanity had to wait soooo long to come up with an alphabet, things seemed to have become stable, but oh well, only 5000 years after the first Babylonian writings, we managed to make it a lot more complex
So here is basically what happened, and I don't know why, but it seems Persian chars posted on a non UTF-8 install will be coded in HTML ASCII, that's why I first filtered the HTML ASCII chars.
By the way, you effort providing and UTF-8 phpBB installation where not thrown out the window as I think I got it this time.
So here is the UTF-8 format_url() function
| Code: | function format_url($url) // The UTF-8 candidate :-)
{
$find = array('"','&','\r\n','\n');
$url = str_replace ($find, '-', $url);
$url = rawurlencode(trim($url));
$url = ereg_replace('%[a-zA-Z0-9]{2}', " ", $url);
trim($url);
$url = str_replace ('ß', 'ss', $url);
$url = str_replace (array('ö','Ö'), 'oe', $url);
$url = str_replace (array('ä','Ä'), 'ae', $url);
$url = str_replace (array('ü','Ü'), 'ue', $url);
$find = "ÀÁÂÃÅàáâãåÒÓÔÕØòóôõøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛùúûÿÑñ";
$replace = "AAAAAaaaaaOOOOOoooooEEEEeeeeCcIIIIiiiiUUUuuuyNn";
$url = strtr($url,$find,$replace);
$url = strtolower($url);
$url = ereg_replace("[^a-zA-Z0-9]", "-", $url);
while (strstr($url, '--')) $url = str_replace('--', '-', $url);
$url = trim($url, '-');
$url = ($url == '') ? 'topic' : $url;
return $url;
} |
As you see it's kind of a dirty trick, first I convert the url with rawurlencode() and then filter the results, all special chars are replaced by % followed by two chars (letter and or numbers) which are then filtered with ease.
So there should be a more direct way but this one is still fast as rawurlencode() is very fast. It's just adding an ereg_replace().
Anyway, the 0.0.3 version of the mod rewrite will be faster again as I'll implement a minor change with major results as far as efficiency
Here I already used trim instead of the heavier previous method for endings "-"
Results for your example (by the way I'd prefer you'd translate Persian when posting, even when building example, just for us all to know what are we talking about ) :
انجمن phpbb ایران
=> phpbb
آموزش CSS و HTML
=> css-html
And preferably quote (no need to post just quote once to see the code) this message to grab the code from the source without the wrapping errors
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
AmirAbbas phpBB SEO Team


Joined: 11 May 2006 Posts: 529 Location: IRAN
|
Posted: Sat Jul 22, 2006 7:08 am Post subject: Re: mixed rewrite mod and persian UTF-8 encoding |
|
|
PERFECT
thanks you very much
everything is ok and it works like a charm
just a little thing
see this url
-http://localhost/Persia/topic-vf5.html
this url is the url of a forum that doesn't contain any english word
as you can see we have -vf in url. but we have word topic in forum url
it must be like this
-http://localhost/Persia/forum-vf5.html
its not very important. i can put english words in all of my forums. but if you
solve this little problem, this mod become complete and perfect
i tested it for persian (utf- and arabic (windows-1256) charset. its OK
i think it must be compatible with chinese and russian. i don't have installed
this two charset in my system but i think it must be OK with that two charsets
thanks a bunch  |
_________________ چهار گوش - طراحی وب - مجله طراحی وب |
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14279
|
Posted: Sat Jul 22, 2006 9:00 am Post subject: Re: mixed rewrite mod and persian UTF-8 encoding |
|
|
All right
And yes there is somethign to do about the enpty URLs, "topic" is not enough here.
This should be dealed with from sessions.php.
So here is the format_url() :
| Code: | function format_url($url) // The UTF-8 candidate :-)
{
$find = array('"','&','\r\n','\n');
$url = str_replace ($find, '-', $url);
$url = rawurlencode(trim($url));
$url = ereg_replace('%[a-zA-Z0-9]{2}', " ", $url);
trim($url);
$url = str_replace ('ß', 'ss', $url);
$url = str_replace (array('ö','Ö'), 'oe', $url);
$url = str_replace (array('ä','Ä'), 'ae', $url);
$url = str_replace (array('ü','Ü'), 'ue', $url);
$find = "ÀÁÂÃÅàáâãåÒÓÔÕØòóôõøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛùúûÿÑñ";
$replace = "AAAAAaaaaaOOOOOoooooEEEEeeeeCcIIIIiiiiUUUuuuyNn";
$url = strtr($url,$find,$replace);
$url = strtolower($url);
$url = ereg_replace("[^a-zA-Z0-9]", "-", $url);
while (strstr($url, '--')) $url = str_replace('--', '-', $url);
$url = trim($url, '-');
return $url;
} |
The for append_sid(), I am currently updating the method ant it will allow to go a lot faster especially in you case where you need to test if the URL title is empty.
Let me put together a beta updated install and I send you a PM
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
AmirAbbas phpBB SEO Team


Joined: 11 May 2006 Posts: 529 Location: IRAN
|
|
| Back to top |
|
 |
AmirAbbas phpBB SEO Team


Joined: 11 May 2006 Posts: 529 Location: IRAN
|
Posted: Sun Jul 23, 2006 6:37 am Post subject: Re: mixed rewrite mod and persian UTF-8 encoding |
|
|
i recieved your package in PM
i tried to install it but it seems there is problem in this part of code
| Code: | #
#-----[ OPEN ]------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------
#
if (isset($display_categories[$cat_id]) && $display_categories[$cat_id])
{
$template->assign_block_vars('catrow', array(
'CAT_ID' => $cat_id,
'CAT_DESC' => $category_rows[$i]['cat_title'],
'U_VIEWCAT' => append_sid("index.$phpEx?" . POST_CAT_URL . "=$cat_id"))
);
#
#-----[ REPLACE WITH ]------------------------------------------
#
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
$seo_cat_name = $category_rows[$i]['cat_title'];
// www.phpBB-SEO.com SEO TOOLKIT END
$template->assign_block_vars('catrow', array(
'CAT_ID' => $cat_id,
'CAT_DESC' => $category_rows[$i]['cat_title'],
'U_VIEWCAT' => append_sid("index.$phpEx?" . POST_CAT_URL . "=$cat_id"))
);
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
$seo_cat_name = FALSE;
// www.phpBB-SEO.com SEO TOOLKIT END
|
after i changed this part of code
the page didn't load , i saw only a white page
i think we must keep this part of code
| Code: |
if (isset($display_categories[$cat_id]) && $display_categories[$cat_id])
{ |
before
| Code: | // www.phpBB-SEO.com SEO TOOLKIT BEGIN
$seo_cat_name = $category_rows[$i]['cat_title'];
// www.phpBB-SEO.com SEO TOOLKIT END
$template->assign_block_vars('catrow', array(
'CAT_ID' => $cat_id,
'CAT_DESC' => $category_rows[$i]['cat_title'],
'U_VIEWCAT' => append_sid("index.$phpEx?" . POST_CAT_URL . "=$cat_id"))
);
// www.phpBB-SEO.com SEO TOOLKIT BEGIN
$seo_cat_name = FALSE;
// www.phpBB-SEO.com SEO TOOLKIT END |
|
_________________ چهار گوش - طراحی وب - مجله طراحی وب |
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14279
|
|
| Back to top |
|
 |
AmirAbbas phpBB SEO Team


Joined: 11 May 2006 Posts: 529 Location: IRAN
|
Posted: Mon Jul 24, 2006 6:27 am Post subject: Re: mixed rewrite mod and persian UTF-8 encoding |
|
|
i tested the mod
the mod itself works properly without any problem
but it has problem with:
simple subforum, google sitemap, mx sitemap, today/yesterday hack
first see this picture
as you can see there is persian words in url. i used the trick that you deliver in this post
http://boards.phpbb-seo.com/phpbb-mod-rewrite/discussions-vt41.html
now i clicked on that link and im in viewforum page, see this picture
now i clicked on that link and im in viewtopic page, see this picture
see the url
now i clicked on parent link (viewforum link) and i come back to previous page, see this picture
see the url. the shape of url was good but now ?!!!
and another problem with today/yesterday hack with trick you dliver in this post
[request] today-yesterday mod with
see this picture
pay attention to status bar !!!!
when you click on that link it will go to correct topic without problem but it shows a wrong url
in status bar
and problem with mx sitemap
see this picture
and another picture
and another one
it doesn't work with google sitemap
you sait to me that i must change some part of code in this way
| dcz wrote: | For mx Google sitemaps, open sitemap_forum.php (the advanced contrib one) and look for :
| Code: |
$forum_url = format_url($forum_data['forum_name']) . '-vf' . $forum_id . '.html'; |
replace with :
| Code: | $forum_title_tmp = format_url($forum_data['forum_name']);
$forum_url = ( ($forum_title_tmp != 'empty') ? $forum_title_tmp : 'forum' ) . '-vf' . $forum_id . '.html'; |
Find :
| Code: | | $topic_url = format_url($topic['topic_title']) . '-vt' . $topic['topic_id']; |
Replace with :
| Code: |
$topic_title_tmp = format_url($topic['topic_title'])
$topic_url = ( ($topic_title_tmp != 'empty') ? $topic_title_tmp : 'topic' ) . '-vt' . $topic['topic_id']; |
find :
| Code: | | $forum_urls = $server_url . format_url($forum_datas[$j]['forum_name']) . '-vf' . $forum_id . '.html'; |
Replace with :
| Code: | $forum_title_tmp = format_url($forum_data['forum_name']);
$forum_urls = $server_url . ( ($forum_title_tmp != 'empty') ? $forum_title_tmp : 'forum' ) . '-vf' . $forum_id . '.html'; |
|
i changed that part of code but after i refereshed the page, page didn't load and i saw only a white page
at last you said i must change somepart of MXsitemap files
unfortunately i couldn't understand you
exactly which files must be edited ?
thanks |
_________________ چهار گوش - طراحی وب - مجله طراحی وب |
|
| Back to top |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14279
|
Posted: Mon Jul 24, 2006 9:30 am Post subject: Re: mixed rewrite mod and persian UTF-8 encoding |
|
|
Don't Panic
You know some code is needed for simple sub forum, it's still phpBB SEO, like when it was not supporting UTF-8, you know
For the sub forum just ad format_url() to the seo var declaration ($seo_forum_name = $forum_row['forum_name']; => $seo_forum_name = format_url($forum_row['forum_name']) and so on.
Look in the includes files. Add format_url() to every $seo_ .... = line.
String to search for is "$seo_", file to look for, almost all in includes.
For the mx sitemaps modules, look for :
| Code: | | $topic_title_tmp = format_url($topic['topic_title']) |
and add the ";"
Besides, Is the core code working well ?
Have you made it to trick the format_url() function with very dirty titles ?
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
AmirAbbas phpBB SEO Team


Joined: 11 May 2006 Posts: 529 Location: IRAN
|
Posted: Tue Jul 25, 2006 8:40 am Post subject: Re: mixed rewrite mod and persian UTF-8 encoding |
|
|
thanks
i will test it
the core ocde of the mode works fine
i said that i tested it with two charset
UTF-8
windows-1265 (standard windows arabic charset) |
_________________ چهار گوش - طراحی وب - مجله طراحی وب |
|
| Back to top |
|
 |
|
|
| Navigation |
Similar Topics |
|
|
|
|
|
|
|