• [MOD] Google Friendly Urls For 4images Best Seo Mod 4 0 5 1
Currently:  

Author Topic: [MOD] Google Friendly Urls For 4images Best Seo Mod  (Read 707250 times)

0 Members and 1 Guest are viewing this topic.

Offline xox

  • Newbie
  • *
  • Posts: 15
    • View Profile
[MOD] Google Friendly Urls For 4images Best Seo Mod
« on: May 23, 2007, 04:34:24 PM »
1)open the .htaccess file and add the lines to the .htaccess
Code: [Select]
RewriteEngine On

#RewriteBase /
RewriteRule ^cat-(.*)-([0-9]+)\.htm$ categories.php?cat_id=$2&%{QUERY_STRING}
RewriteRule ^cat\.htm$ categories.php?%{QUERY_STRING}
#Mod_bmollet : Image name in URL
RewriteRule ^img-(.*)-([0-9]+)\.htm$ details.php?image_id=$2&%{QUERY_STRING}
RewriteRule ^img([0-9]+)\.search.htm$ details.php?image_id=$1&%{QUERY_STRING}
RewriteRule ^img([0-9]+)\.lightbox.htm$ details.php?image_id=$1&%{QUERY_STRING}

#Mod_bmollet : This is to make search function work  ( redirect links from search results )
RewriteRule ^search\.htm$ search.php?%{QUERY_STRING}
RewriteRule ^search\.([0-9]+)\.htm$ search.php?page=$1&%{QUERY_STRING}
RewriteRule ^lightbox\.htm$ lightbox.php?%{QUERY_STRING}
RewriteRule ^lightbox\.([0-9]+)\.htm$ lightbox.php?page=$1&%{QUERY_STRING}

2.) open /include/sessions.php before the last line ?> add the following code
The following code in this step is not optimized. You should use an optimized code from this reply on page 11
Code: [Select]
//Mod_bmollet
/**
 * Get the category url
 * @param int $cat_id The id of the category
 * @param string $cat_url The current status of the URL
 */
function get_category_url($cat_id,$cat_url = '')
{
global $site_db;
$sql = "SELECT cat_name,cat_parent_id FROM ".CATEGORIES_TABLE." WHERE cat_id = '".$cat_id."'";
$result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
$row['cat_name'] = strtr($row['cat_name'], "éèêàëâúóíáABCDEFGHIJKLMNOPQRSTUVWXYZ","eeeaeauoiaabcdefghijklmnopqrstuvwxyz");
$cat_url  = '-'.str_replace('+','-',urlencode($row['cat_name'])).'-'.$cat_id.$cat_url;
// if you want full path of category in url, put next line in comment
return $cat_url;
if( $row['cat_parent_id'] != 0)
{
return get_category_url($row['cat_parent_id'],$cat_url);
}
else
{
return $cat_url;
}
}
//Mod_bmollet
/**
 * Get the image url
 * @param int $image_id The id of the image
 */
function get_image_url($image_id)
{
global $site_db;
$sql = "SELECT cat_id,image_name FROM ".IMAGES_TABLE." WHERE image_id = '".$image_id."'";
$result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
$row['image_name'] = strtr($row['image_name'], "éèêàëâúóíáABCDEFGHIJKLMNOPQRSTUVWXYZ","eeeaeauoiaabcdefghijklmnopqrstuvwxyz");
// if you want comlpete path to image in url, remove comment from following line
//return get_category_url($row['cat_id']).'-'.str_replace('+','-',urlencode($row['image_name'])).'-'.$image_id;
return '-'.str_replace('+','-',urlencode($row['image_name'])).'-'.$image_id;
}

3.)open /include/sessions.php find this code

Code: [Select]
function url($url, $amp = "&") {
    global $l;
    $dummy_array = explode("#", $url);
    $url = $dummy_array[0];

    if ($this->mode == "get" && !preg_match("/".SESSION_NAME."=/i", $url)) {
      $url .= preg_match("/\?/", $url) ? "$amp" : "?";
      $url .= SESSION_NAME."=".$this->session_id;
    }

    if (!empty($l)) {
      $url .= preg_match("/\?/", $url) ? "$amp" : "?";
      $url .= "l=".$l;
    }

    $url .= (isset($dummy_array[1])) ? "#".$dummy_array[1] : "";
    return $url;
  }

4.)Replace with this one

Code: [Select]
/* ORIGINAL CODE
  function url($url, $amp = "&") {
    global $l;
    $dummy_array = explode("#", $url);
    $url = $dummy_array[0];

    if ($this->mode == "get" && !preg_match("/".SESSION_NAME."=/i", $url)) {
      $url .= preg_match("/\?/", $url) ? "$amp" : "?";
      $url .= SESSION_NAME."=".$this->session_id;
    }

    if (!empty($l)) {
      $url .= preg_match("/\?/", $url) ? "$amp" : "?";
      $url .= "l=".$l;
    }

    $url .= (isset($dummy_array[1])) ? "#".$dummy_array[1] : "";
    return $url;
  }
*/
  function url($url, $amp = "&") {
    global $l, $user_info;
    $dummy_array = explode("#", $url);
    $url = $dummy_array[0];
    $url = str_replace('&', '&', $url);
    if (!defined('IN_CP')) {
      if (strstr($url, 'index.php')) {
        $url = str_replace('index.php', '', $url);
      }
      elseif (strstr($url, 'search.php')) {
        if (strstr($url, 'page=')) {
          preg_match('#page=([0-9]+)&?#', $url, $matches);
          if (isset($matches[1])) {
            $split = explode('?', $url);
            $url = $split[0];
            $query = @$split[1];
            $url   = str_replace('search.php', 'search.'.$matches[1].'.htm', $url);
            $query = str_replace('page='.$matches[1].'&', '', $query);
            $query = str_replace('&page='.$matches[1], '', $query);
            $query = str_replace('page='.$matches[1], '', $query);
            if (!empty($query)) {
              $url .= '?' . $query;
            }
          }
        }
        else {
          $url = str_replace('search.php', 'search.htm', $url);
        }
      }
      elseif (strstr($url, 'lightbox.php')) {
        if (strstr($url, 'page=')) {
          preg_match('#page=([0-9]+)&?#', $url, $matches);
          if (isset($matches[1])) {
            $split = explode('?', $url);
            $url = $split[0];
            $query = @$split[1];
            $url   = str_replace('lightbox.php', 'lightbox.'.$matches[1].'.htm', $url);
            $query = str_replace('page='.$matches[1].'&', '', $query);
            $query = str_replace('&page='.$matches[1], '', $query);
            $query = str_replace('page='.$matches[1], '', $query);
            if (!empty($query)) {
                $url .= '?' . $query;
            }
          }
        }
        else {
          $url = str_replace('lightbox.php', 'lightbox.htm', $url);
        }
      }
      elseif (strstr($url, 'categories.php')) {
        if (strstr($url, 'cat_id=') && strstr($url, 'page=')) {
          preg_match('#cat_id=([0-9]+)&?#', $url, $matches1);
          preg_match('#page=([0-9]+)&?#', $url, $matches2);
          if (isset($matches1[1]) && isset($matches2[1])) {
            $split = explode('?', $url);
            $url = $split[0];
            $query = @$split[1];
            $url   = str_replace('categories.php', 'cat'.$matches1[1].'.'.$matches2[1].'.htm', $url);
            $query = str_replace('cat_id='.$matches1[1].'&', '', $query);
            $query = str_replace('&cat_id='.$matches1[1], '', $query);
            $query = str_replace('cat_id='.$matches1[1], '', $query);
            $query = str_replace('page='.$matches2[1].'&', '', $query);
            $query = str_replace('&page='.$matches2[1], '', $query);
            $query = str_replace('page='.$matches2[1], '', $query);
            if (!empty($query)) {
              $url .= '?' . $query;
            }
          }
        }
        elseif (strstr($url, 'cat_id=')) {
          preg_match('#cat_id=([0-9]+)&?#', $url, $matches);
          if (isset($matches[1])) {
            $split = explode('?', $url);
            $url = $split[0];
            $query = @$split[1];
            $cat_url = get_category_url($matches[1]);
            $url   = str_replace('categories.php', 'cat'.$cat_url.'.htm', $url);
            $query = str_replace('cat_id='.$matches[1].'&', '', $query);
            $query = str_replace('&cat_id='.$matches[1], '', $query);
            $query = str_replace('cat_id='.$matches[1], '', $query);
            if (!empty($query)) {
              $url .= '?' . $query;
            }
          }
        }
        else {
          $url = str_replace('categories.php', 'cat.htm', $url);
        }
      }
      elseif (strstr($url, 'details.php?image_id=')) {
        if (strstr($url, 'image_id=') && strstr($url, 'mode=')) {
          preg_match('#image_id=([0-9]+)&?#', $url, $matches1);
          preg_match('#mode=([a-zA-Z0-9]+)&?#', $url, $matches2);
          if (isset($matches1[1]) && isset($matches2[1])) {
            $split = explode('?', $url);
            $url = $split[0];
            $query = @$split[1];
            $url   = str_replace('details.php', 'img'.$matches1[1].'.'.$matches2[1].'.htm', $url);
            $query = str_replace('image_id='.$matches1[1].'&', '', $query);
            $query = str_replace('&image_id='.$matches1[1], '', $query);
            $query = str_replace('image_id='.$matches1[1], '', $query);
            $query = str_replace('mode='.$matches2[1].'&', '', $query);
            $query = str_replace('&mode='.$matches2[1], '', $query);
            $query = str_replace('mode='.$matches2[1], '', $query);
            if (!empty($query)) {
              $url .= '?' . $query;
            }
          }
        }
        else {
          preg_match('#image_id=([0-9]+)&?#', $url, $matches);
          if (isset($matches[1])) {
            $split = explode('?', $url);
            $url = $split[0];
            $query = @$split[1];
            $url   = str_replace('details.php', 'img'.get_image_url($matches[1]).'.htm', $url);
            $query = str_replace('image_id='.$matches[1].'&', '', $query);
            $query = str_replace('&image_id='.$matches[1], '', $query);
            $query = str_replace('image_id='.$matches[1], '', $query);
            if (!empty($query)) {
              $url .= '?' . $query;
            }
          }
        }
      }
      elseif (strstr($url, 'postcards.php?image_id=')) {
        preg_match('#image_id=([0-9]+)&?#', $url, $matches);
        if (isset($matches[1])) {
          $split = explode('?', $url);
          $url = $split[0];
          $query = @$split[1];
          $url   = str_replace('postcards.php', 'postcard.img'.$matches[1].'.htm', $url);
          $query = str_replace('image_id='.$matches[1].'&', '', $query);
          $query = str_replace('&image_id='.$matches[1], '', $query);
          $query = str_replace('image_id='.$matches[1], '', $query);
          if (!empty($query)) {
            $url .= '?' . $query;
          }
        }
      }
    }
    if ($this->mode == "get" && strstr($url, $this->session_id)) {
      $url .= strpos($url, '?') !== false ? '&' : '?';
      $url .= SESSION_NAME."=".$this->session_id;
    }
    if (!empty($l)) {
      $url .= strpos($url, '?') ? '&' : '?';
      $url .= "l=".$l;
    }
    $url = str_replace('&', $amp, $url);
    $url .= isset($dummy_array[1]) ? "#".$dummy_array[1] : "";
    return $url;
  }

then it would like this
http://www.turkiye-resimleri.com/


also i have upload the pre-edited files for 1.7.4 http://rapidshare.com/files/33076491/seo.rar.html
this seo.rar file contains .htaccess file and /include/sessions.php file you can use it withour modifying
The files provided in the package are out of date, do not use them, install mod manually instead.
« Last Edit: July 11, 2010, 11:14:02 PM by V@no »

Offline al3aqeed

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #1 on: May 24, 2007, 09:44:56 AM »
i start whith you step to step but i have now big problem
can you help me
this my problem

DB Error: Bad SQL Query: DELETE FROM 4images_sessions WHERE session_lastaction < 1179992031
Incorrect key file for table '4images_sessions'; try to repair it

DB Error: Bad SQL Query: INSERT INTO 4images_sessions (session_id, session_user_id, session_lastaction, session_location, session_ip) VALUES ('9a70711b04e42b85bd059891e5e2a76c', -1, 1179992631, 'index.php', '62.150.109.129')
Duplicate entry '-1' for key 2

Warning: Cannot modify header information - headers already sent by (output started at /home/XXXXXX/public_html/gallery/includes/db_mysql.php:188) in /home/XXXXXX/public_html/gallery/includes/sessions.php on line 85

Warning: Cannot modify header information - headers already sent by (output started at /home/XXXXXX/public_html/gallery/includes/db_mysql.php:188) in /home/XXXXXX/public_html/gallery/includes/sessions.php on line 85

Warning: Cannot modify header information - headers already sent by (output started at /home/XXXXXX/public_html/gallery/includes/db_mysql.php:188) in /home/XXXXXX/public_html/gallery/includes/sessions.php on line 85


Offline xox

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #2 on: May 24, 2007, 10:13:22 AM »
try to repair the 4images_sessions table in phpmyadmin i dont think it is not related with this mod

Offline al3aqeed

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #3 on: May 24, 2007, 10:21:58 AM »
can you Explain whin i join phpmyadmin ?

Because these big problem and i can`t join cpanel admin my gallery :(




Offline xox

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #4 on: May 24, 2007, 10:24:38 AM »
login to cpanel go to mysql database under the menu and select repair near database name

Offline al3aqeed

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #5 on: May 24, 2007, 10:35:50 AM »
these is true ?


Offline xox

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #6 on: May 24, 2007, 10:40:56 AM »
yes

Offline al3aqeed

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #7 on: May 24, 2007, 10:44:20 AM »
it not have any Change  :(

Offline xox

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #8 on: May 24, 2007, 10:59:35 AM »
revert the changes you made by modifying code and try again

Offline al3aqeed

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #9 on: May 24, 2007, 11:47:12 AM »
i have buck-up to sessions.php and uploud now and not have any chang
why ? :(

Offline xox

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #10 on: May 24, 2007, 11:48:06 AM »
try to repair all tables using phpmyadmin

Offline al3aqeed

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #11 on: May 24, 2007, 11:51:01 AM »
you have msn
add al_3aqeed@hotmail.com

Offline al3aqeed

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #12 on: May 24, 2007, 12:24:48 PM »
not have any change  :(

Offline yas3min

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #13 on: May 25, 2007, 11:58:28 AM »
Teşekkürler emeğine sağlık

Thank you very much ;)

Offline Vincent

  • 4images Moderator
  • Addicted member
  • *****
  • Posts: 1.195
    • View Profile
    • www.foto-kocher.com
Re: [MOD] Google Friendly Urls For 4images Best Seo Mod
« Reply #14 on: May 30, 2007, 05:12:52 PM »
how to use it if you have no .htaccess file because of using a MS Server?

sincerly
vincent
Beati pauperi spiritus

4images 1.7 // My Installed Mods