4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 29, 2016, 05:53:10 PM

Login with username, password and session length
Search:     Advanced search
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Modifications / Modifikationen
| |-+  Mods & Plugins (Releases & Support) (Moderators: mawenzi, Rembrandt)
| | |-+  [MOD] Google Friendly Urls For 4images Best Seo Mod
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 3 4 5 ... 32 » »» Print
Current Topic Rating: *****
Author Topic: [MOD] Google Friendly Urls For 4images Best Seo Mod  (Read 416013 times)
xox
Newbie
*
Offline Offline

Posts: 15

Thank You
-Given: 0
-Receive: 9


View Profile
« on: May 23, 2007, 04:34:24 PM »

1)open the .htaccess file and add the lines to the .htaccess
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/* 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 » Logged
al3aqeed
Newbie
*
Offline Offline

Posts: 17

Thank You
-Given: 0
-Receive: 1


View Profile
« 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

Logged
xox
Newbie
*
Offline Offline

Posts: 15

Thank You
-Given: 0
-Receive: 9


View Profile
« 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
Logged
al3aqeed
Newbie
*
Offline Offline

Posts: 17

Thank You
-Given: 0
-Receive: 1


View Profile
« 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 Sad



Logged
xox
Newbie
*
Offline Offline

Posts: 15

Thank You
-Given: 0
-Receive: 9


View Profile
« 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
Logged
al3aqeed
Newbie
*
Offline Offline

Posts: 17

Thank You
-Given: 0
-Receive: 1


View Profile
« Reply #5 on: May 24, 2007, 10:35:50 AM »

these is true ?

Logged
xox
Newbie
*
Offline Offline

Posts: 15

Thank You
-Given: 0
-Receive: 9


View Profile
« Reply #6 on: May 24, 2007, 10:40:56 AM »

yes
Logged
al3aqeed
Newbie
*
Offline Offline

Posts: 17

Thank You
-Given: 0
-Receive: 1


View Profile
« Reply #7 on: May 24, 2007, 10:44:20 AM »

it not have any Change  Sad
Logged
xox
Newbie
*
Offline Offline

Posts: 15

Thank You
-Given: 0
-Receive: 9


View Profile
« Reply #8 on: May 24, 2007, 10:59:35 AM »

revert the changes you made by modifying code and try again
Logged
al3aqeed
Newbie
*
Offline Offline

Posts: 17

Thank You
-Given: 0
-Receive: 1


View Profile
« 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 ? Sad
Logged
xox
Newbie
*
Offline Offline

Posts: 15

Thank You
-Given: 0
-Receive: 9


View Profile
« Reply #10 on: May 24, 2007, 11:48:06 AM »

try to repair all tables using phpmyadmin
Logged
al3aqeed
Newbie
*
Offline Offline

Posts: 17

Thank You
-Given: 0
-Receive: 1


View Profile
« Reply #11 on: May 24, 2007, 11:51:01 AM »

you have msn
add al_3aqeed@hotmail.com
Logged
al3aqeed
Newbie
*
Offline Offline

Posts: 17

Thank You
-Given: 0
-Receive: 1


View Profile
« Reply #12 on: May 24, 2007, 12:24:48 PM »

not have any change  Sad
Logged
yas3min
Pre-Newbie

Offline Offline

Posts: 4

Thank You
-Given: 0
-Receive: 0


View Profile
« Reply #13 on: May 25, 2007, 11:58:28 AM »

Teşekkrler emeğine sağlık

Thank you very much Wink
Logged
Vincent
4images Moderator
Addicted member
*****
Offline Offline

Posts: 1195

Thank You
-Given: 0
-Receive: 7


View Profile WWW
« 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
Logged

Beati pauperi spiritus

4images 1.7 // My Installed Mods

Pages: [1] 2 3 4 5 ... 32 » »» Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.235 seconds with 19 queries.