Friendly URLs

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
BomBas
Forum Commoner
Posts: 41
Joined: Wed Mar 04, 2009 1:04 pm

Friendly URLs

Post by BomBas »

Hi, I'm having a little problem with Hebrew in URL.

Lets say this is my URL:
http://example.com/f...um-name-f1.html

this URL will show me the forum "forum-name".

Now, I have a lot of Hebrew names. (forums)
lets say:
http://example.com/forum/?????-f3.html

It will show a browser error, infinite loop.

This is the function that cause the error(I guess):

Code: Select all

 
    function dice_the_url()
    {
 
 
        $url = $_SERVER['REQUEST_URI'];
        $this->current_url = 'http://'.$_SERVER['HTTP_HOST'].$url;
 
        uksort($this->the_rules, array($this,'sortr_longer'));
        foreach ($this->the_rules as $key => $value)
        {
            $all_rules[$this->the_rules[$key][2]] = $this->the_rules[$key][0];
        }
        //      $all_rules[$this->the_rules['topic_view_getnewpost'][2]] = $this->the_rules['topic_view_getnewpost'][0];
        //      $all_rules[$this->the_rules['topic_view_getlastpost'][2]] = $this->the_rules['topic_view_getlastpost'][0];  $all_rules[$this->the_rules['topic_multipage_rule'][2]] = $this->the_rules['topic_multipage_rule'][0];
        //      $all_rules[$this->the_rules['forum_multipage_rule'][2]] = $this->the_rules['forum_multipage_rule'][0];
        //      $all_rules[$this->the_rules['topic_rule'][2]] = $this->the_rules['topic_rule'][0];
        //      $all_rules[$this->the_rules['forum_rule'][2]] = $this->the_rules['forum_rule'][0];
        //      $all_rules[$this->the_rules['showuser_rule'][2]] = $this->the_rules['showuser_rule'][0];
 
        if($this->call_list)
        {
            foreach ($this->call_list as $plugin)
            {
                $all_rules  = $this->loaded_plugin[$plugin]->build_rule($all_rules);
            }
        }
        //      $all_rules['act=help$matches[1]'] = 'help.html(.*)';
 
        //if we pop we dont continue
        $poped = 0;
        foreach($all_rules as $key_rule => $rule)
        {
            if(!$poped)
            {
                if(preg_match('@'.$rule.'@si',$url,$matches))
                {
 
                    eval("\$new_query =  \"{$key_rule}\";");
                    parse_str($new_query,$this->ipsclass->input);
                    //                  print_r($matches);
                    $poped = 1;
                }
            } 
        }
 
What should I do? thanks alot.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Friendly URLs

Post by omniuni »

Could you please post a link to an example? I found one on wikipedia (http://meta.wikimedia.org/wiki/%D7%95%D ... 7%99%D7%94) but that seemed to work just fine for me.

http://meta.wikimedia.org/wiki/ויקיפדיה

Edit: It seems near impossible to get it to "work" with the actual ascii characters. I bet several people won't even be able to read the line right above this. Maybe you need to use HTMLentities?
BomBas
Forum Commoner
Posts: 41
Joined: Wed Mar 04, 2009 1:04 pm

Re: Friendly URLs

Post by BomBas »

Already have one, here is my cleaning function:

Code: Select all

function clean_url($title,$skip_spacer=null)
{
    unset($ntitle);
 
 
    $ntitle = trim($title);
    $ntitle = urldecode($ntitle);
    $ntitle = strip_tags($ntitle);
    $ntitle = html_entity_decode($ntitle);
 
    //$ntitle = $this->str_char_replacement($ntitle);
    $ntitle = strtolower($ntitle);
    //$ntitle = preg_replace('/\^|"|\'/','',$ntitle);
    //$ntitle = preg_replace('/&.*?;/','',$ntitle);
    //$ntitle = preg_replace( "/[^a-zA-Z0-9]/", ',', $ntitle );
 
    $spacer = ($skip_spacer)?$skip_spacer:$this->ipsclass->vars['mseo_seperator'];
 
    $ntitle = $this->ipsclass->clean_comma( $ntitle );
    $ntitle = $this->ipsclass->trim_trailing_comma( $ntitle );
    $ntitle = $this->ipsclass->trim_leading_comma( $ntitle );
    $ntitle = str_replace(',',$spacer ,$ntitle);
    $ntitle = str_replace(' ', $this->ipsclass->vars['mseo_seperator'], $ntitle);
 
 
    return $ntitle;
}
I know it is possible, I just don't know how.. :(

Here is my forum:
igamer.co.il/forum

But you wont understand nothing.. It's in Hebrew.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: Friendly URLs

Post by omniuni »

BomBas, I can't find any links that don't work! I clicked around for a while, but everything seems to work just fine. Maybe you can provide a more specific link to where I can find an example of what's going wrong? Oh, and my friend from Israel should have no trouble understanding your website, if I needed to know what it says! 8)
BomBas
Forum Commoner
Posts: 41
Joined: Wed Mar 04, 2009 1:04 pm

Re: Friendly URLs

Post by BomBas »

Yeah, all of the links are working because I can't show broken links to my members..

now, the URL of the hebrew forums is:
http://igamer.co.il/forum/-fid.html


Without their name, if you didnt understand.

Thanks alot.
BomBas
Forum Commoner
Posts: 41
Joined: Wed Mar 04, 2009 1:04 pm

Re: Friendly URLs

Post by BomBas »

Someone?
Post Reply