PhpBB et URL Rewriting : les solutions !

JeromeRookie

WRInaute occasionnel
Bonjour,
sans mettre en place l'url rewriting sur phpbb(trop compliqué pour moi... :oops: ) j'ai modifié le fichier session.php selon ce qui m'avait été expliqué ici pour enlever les numero de session et permettre donc à google de visiter mon forum.

par contre, chaque fois que je souhaite me servir de la plate-forme d'admin du forum, je dois remodifier ce meme fichier.
Y a-t-il une solution (simple) pour éviter cela?

question subsidiaire : pourquoi phpbb ne met pas a dispo un forum url rewritée ???

merci et bonne année à tous
 

mahefarivony

WRInaute accro
pourquoi phpbb ne met pas a dispo un forum url rewritée ???

si si, je suis sur d'avoir vu un jour un pack (mod's) permettant de rendre le phpBB "spiderable".. mais je sais plus ou j'ai vu ca.. une petite recherche sur... google par exemple ? :lol:
 

Kounte

WRInaute impliqué
Voici la méthode vu dans ce fameux post, en faite on trouve la bonne solution sur 2 posts, j'ai suivit exactement celle-ci-dessous pour obtenir un forum phpbb url rewrité en quelques minutes de modification des fichiers concernés en ftp et sans connaissances de php...

Acid Paul wrote:
I have modified the Googlifier mod for PHPNuke with PHPBB2 port found at www.orientalgate.org to work with standalone PHPBB2. This mod allows you to turn dynamic forum urls into static ones and therefore get better indexed and ranked by Google & co., as well as picked by search engines, that don't like dynamic URLs (e.g. AllTheWeb).

The effect is like this:

> viewtopic.php?t=157 => ftopic28.html

(affects all topics, posts, forum folders and pagination; member profiles, search, lorgin and usergroups URL stay unchanged; the main page remains index.php)

Requirements: you need mod_rewrite enabled as well as ability to use .htaccess or modify apache config files.

Implementation:


Step 1. In /includes/page_header.php before

Code:
// 
// Generate logged in/logged out status 
//


add this code (make sure there are no space breaks at line ends after you paste):

Code:
// 
// Short URL implementation 
// 
ob_start(); 
function replace_for_mod_rewrite(&$s) 
{ 
$urlin = 
array( 
"'(?<!/)viewforum.php\?f=([0-9]*)&(?:amp;)topicdays=([0-9]*)&(?:amp;)start=([0-9]*)'", 
"'(?<!/)viewforum.php\?f=([0-9]*)&(?:amp;)mark=topics'", 
"'(?<!/)viewforum.php\?f=([0-9]*)'", 
"'(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)view=previous'", 
"'(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)view=next'", 
"'(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)postdays=([0-9]*)&(?:amp;)postorder=([a-zA-Z]*)&(?:amp;)start=([0-9]*)'", 
"'(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)start=([0-9]*)&(?:amp;)postdays=([0-9]*)&(?:amp;)postorder=([a-zA-Z]*)&(?:amp;)highlight=([a-zA-Z0-9]*)'", 
"'(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)start=([0-9]*)'", 
"'(?<!/)viewtopic.php\?t=([0-9]*)'", 
"'(?<!/)viewtopic.php&(?:amp;)p=([0-9]*)'", 
"'(?<!/)viewtopic.php\?p=([0-9]*)'", 
); 
$urlout = array( 
"viewforum\\1-\\2-\\3.html", 
"forum\\1.html", 
"forum\\1.html", 
"ptopic\\1.html", 
"ntopic\\1.html", 
"ftopic\\1-\\2-\\3-\\4.html", 
"ftopic\\1.html", 
"ftopic\\1-\\2.html", 
"ftopic\\1.html", 
"sutra\\1.html", 
"sutra\\1.html", 
); 
$s = preg_replace($urlin, $urlout, $s); 
return $s; 
}

Step 2. In /includes/page_tail.php after


Code:
$db->sql_close();


add this:

Code:
$contents = ob_get_contents(); 
ob_end_clean(); 
echo replace_for_mod_rewrite($contents); 
global $dbg_starttime;



in the same file after

Code:
ob_end_clean();


add this:

Code:
echo replace_for_mod_rewrite($contents); 
global $dbg_starttime;


Step 3. In your .htaccess file (if you don't have one create it; should be located in you forum root directory) paste these lines:

Code:
RewriteEngine On 
RewriteRule ^forums.* index.php 
RewriteRule ^forum([0-9]*).* viewforum.php?f=$1&mark=topic 
RewriteRule ^viewforum([0-9]*)-([0-9]*)-([0-9]*).* viewforum.php?f=$1&topicdays=$2&start=$3 
RewriteRule ^forum([0-9]*).* viewforum.php?f=$1 
RewriteRule ^ptopic([0-9]*).* viewtopic.php?t=$1&view=previous 
RewriteRule ^ntopic([0-9]*).* viewtopic.php?t=$1&view=next 
RewriteRule ^ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4 
RewriteRule ^ftopic([0-9]*)-([0-9]*).* viewtopic.php?t=$1&start=$2 
RewriteRule ^ftopic([0-9]*).* viewtopic.php?t=$1 
RewriteRule ^ftopic([0-9]*).html viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5 
RewriteRule ^sutra([0-9]*).* viewtopic.php?p=$1


Note: sometimes this .htaccess code won't work properly if the forum is on a subdomain (was the case with me), you may need to try this variation:

Code:
RewriteEngine On 
RewriteRule ^forums.* /index.php 
RewriteRule ^forum([0-9]*).* /viewforum.php?f=$1&mark=topic 
RewriteRule ^viewforum([0-9]*)-([0-9]*)-([0-9]*).* /viewforum.php?f=$1&topicdays=$2&start=$3 
RewriteRule ^forum([0-9]*).* /viewforum.php?f=$1 
RewriteRule ^ptopic([0-9]*).* /viewtopic.php?t=$1&view=previous 
RewriteRule ^ntopic([0-9]*).* /viewtopic.php?t=$1&view=next 
RewriteRule ^ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* /viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4 
RewriteRule ^ftopic([0-9]*)-([0-9]*).* /viewtopic.php?t=$1&start=$2 
RewriteRule ^ftopic([0-9]*).* /viewtopic.php?t=$1 
RewriteRule ^ftopic([0-9]*).html /viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5 
RewriteRule ^sutra([0-9]*).* /viewtopic.php?p=$1


Step 4. Very important! In your robots.txt file (goes at the *site* root) add these lines:

Code:
Disallow: /your-forum-folder/sutra*.html$ 
Disallow: /your-forum-folder/ptopic*.html$ 
Disallow: /your-forum-folder/ntopic*.html$ 
Disallow: /your-forum-folder/ftopic*asc*.html$


(This is required to avoid feeding duplicate content to Google)

Step 5. Apply Google Mod #1 described at this page.

Congrats! Now you now have traffic-generating mogul.
 

JeromeRookie

WRInaute occasionnel
ca fonctionne!
tu es vraiment un champion Kali!!!

il ne me reste plus qu'à savoir quoi faire avec le robot.txt...

de plus, chez moi (contrairement à chez toi), l'url est rewritée mais contient encore un numéro de session du type : http://www.ateliermagique.com/forum/for ... f2e4d221ca

je sais l'enlever en modifiant l'include/sessions.php mais toi, tu ne l'as pas fait et ca fonctionne chez toi non ?

d'ici la je remets l'ancienne version en ligne pour que GG ne me pose pas de pb de double referencement...

merci encore et a te lire.
 

JeromeRookie

WRInaute occasionnel
HORREUR !!!
je n'arrive plus a acceder à la plate-forme d'admin... cela arrivait lorsque je changeais la fonction sesions.php mais je savais la refaire venir.

j'ai fait toutes les manips à l'envers et la gestion des forums ne marche plus...

as-tu le meme problème Kali ?
 

Karbon

WRInaute discret
Pas de chance Jerome

je viens a l'instant de modifier mon fichier session.php
j'ai plus les sid et ca marche

j'ai toujours acces a l'admin
 

Karbon

WRInaute discret
oui

Code:
function append_sid($url, $non_html_amp = false) 
{ 
  global $SID; 
//  if ( !empty($SID) && !eregi('sid=', $url) ) 
//  { 
//     $url .= ( ( strpos($url, '?') != false ) ?  ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID; 
//  } 
  return($url); 
}
 

JeromeRookie

WRInaute occasionnel
et cela combiné a la procédure qu'a trouvé Kali, tu as url rewrité ?
ca remarche... j'avais du faire une erreur....

Connais-tu la reponse à mon post ci-dessus sur robot.txt ???
as-tu compris la step 5 de la procédure?
 

Karbon

WRInaute discret
oui ca fonctionne
je viens de verouiller un forum pour faire le test

par contre je fais fais l'url rewriting car mon hebergeur de merde ne le gere pas
 

JeromeRookie

WRInaute occasionnel
chez moi, je ne sais pas de koi venait le pb... j'ai l'impression que mon hebergeur mettait du temps a prendre en compte le nouveau fichier sessions.php...

donc tu ne sais faire que disparaitre le Sid ?
 

Karbon

WRInaute discret
non c'est pas enorme
je suis pas du tout une bete en php
remplacer du code je sais faire
mais programmé et comprendre le code non :)
 

JeromeRookie

WRInaute occasionnel
mahefarivony a dit:
JeromeRookie a dit:
donc tu ne sais faire que disparaitre le Sid ?

c'est deja enorme...

ce n'etait bien entendu pas une critique....

je remarque que personne ne me réponds sur ma question au sujet du step 5 et du robots.txt....

J'espere que tous ceux qui passe sur ce fil se rendent bien compte de la PERLE qu'a trouvé Kali !!!! il mérite une médaille et tous les non informaticiens qui ont cherché a url rewrité leur phpbb sauront l'apprécier à sa juste valeur...

pour Kali, hip hip hip !!!! hourraaaa
 

JeromeRookie

WRInaute occasionnel
oui
le numero de session SID
et les paramètres trop nombreux qu'il faut enlever par la procédure de l'url rewriting... ci-dessus
 

Karbon

WRInaute discret
jonh2 modifie ton ficher session.php comme indiqué plus haut
et ca marcheras

ensuite tu vas sur webmasterplan pour analyser ton site et tu verras que les sid ont disparu
 

john2

WRInaute discret
c'est ca qu'il faut modifier ?

function admin_sid($url, $non_html_amp = false)
{
global $SID;
$url = "../../../modules.php?name=Forums&file=$url";

if ( !empty($SID) && !eregi('sid=', $url) )
{
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}

return($url);
}

je l'ait remplacer par ca :

function admin_sid($url, $non_html_amp = false)
{
global $SID;
$url = "../../../modules.php?name=Forums&file=$url";

//if ( !empty($SID) && !eregi('sid=', $url) )
//{
// $url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
//}

return($url);
}

mais apparament, ca ne marche pas... Que dois-je remplacer d'autre ?
 

JeromeRookie

WRInaute occasionnel
john2 a dit:
c'est ca qu'il faut modifier ?

function admin_sid($url, $non_html_amp = false)
{
global $SID;
$url = "../../../modules.php?name=Forums&file=$url";

if ( !empty($SID) && !eregi('sid=', $url) )
{
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}

return($url);
}

je l'ait remplacer par ca :

function admin_sid($url, $non_html_amp = false)
{
global $SID;
$url = "../../../modules.php?name=Forums&file=$url";

//if ( !empty($SID) && !eregi('sid=', $url) )
//{
// $url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
//}

return($url);
}

mais apparament, ca ne marche pas... Que dois-je remplacer d'autre ?

c'est normal, ce n'est pas la bonne fonction que tu as modifiée.... :lol: tu dois modifier la fonction append_sid (la dernière) du fichier include/sessions.php...
:idea: :D
 

JeromeRookie

WRInaute occasionnel
ok merci Kali
Peux-tu me dire si tu as du mettre en commentaire ce if pour le supprimer ou si la procédure que tu avais trouvé sur phpbb.com a suffit chez toi ?

enfin, si je crée mon fichier robots.txt, dois-je le mettre à la racine du site ou a celle du forum ?

la syntaxe est bien :
Disallow: /forum/sutra*.html$ ???
 

Karbon

WRInaute discret
JeromeRookie
sur webmasterplan tu utilise le service analyse prereferencement en haut a gauche

tu n'as plus de SID

Bon par contre moi je vais esayer d'installer le add on qui permet de gerer les balises meta du forum phpbb depuis l'admin
 

Kounte

WRInaute impliqué
JeromeRookie a dit:
ok merci Kali
Peux-tu me dire si tu as du mettre en commentaire ce if pour le supprimer ou si la procédure que tu avais trouvé sur phpbb.com a suffit chez toi ?

enfin, si je crée mon fichier robots.txt, dois-je le mettre à la racine du site ou a celle du forum ?

la syntaxe est bien :
Disallow: /forum/sutra*.html$ ???

J'avais supprimé les sid avant de faire l'url rewriting en commentant 4 lignes consécutives :

Code:
{
	global $SID;

//	if ( !empty($SID) && !preg_match('#sid=#', $url) )
//	{
//		$url .= ( ( strpos($url, '?') != false ) ?  ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
//	}

	return $url;
}

Quant au robots.txt, habituellement c'est à la racine...
 

john2

WRInaute discret
c'est normal, ce n'est pas la bonne fonction que tu as modifiée.... tu dois modifier la fonction append_sid (la dernière) du fichier include/sessions.php...

C'est pourtant ca que j'ai tout en bas.


function admin_sid($url, $non_html_amp = false)
{
global $SID;
$url = "../../../modules.php?name=Forums&file=$url";

if ( !empty($SID) && !eregi('sid=', $url) )
{
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}

return($url);
}

c'est ici qu'il faut modifier quelque chose ?



function append_sid($url, $non_html_amp = false)
{
global $SID, $admin;
if (ereg("admin=1", $url) || ereg("admin_", $url) || ereg("pane=", $url)){
// The format is fine, don't change a thing.
} else if (ereg("Your_Account", $url)){
$url = str_replace(".php", "", $url); // Strip the .php from all the files,
$url = str_replace("modules", "modules.php", $url); // and put it back for the modules.php
}
else if (ereg("redirect", $url))
{
$url = str_replace("login.php", "modules.php?name=Your_Account", $url); // Strip the .php from all the files,
$url = str_replace(".php", "", $url); // Strip the .php from all the files,
$url = str_replace("?redirect", "&redirect", $url); // Strip the .php from all the files,
$url = str_replace("modules", "modules.php", $url); // and put it back for the modules.php
}
else if (ereg("menu=1", $url))
{
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace(".php", "", $url); // Strip the .php from all the files,
$url = "../../../modules.php?name=Forums&file=$url";
}
else if ((ereg("privmsg", $url)) && (!ereg("highlight=privmsg", $url)))
{
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace("privmsg.php", "modules.php?name=Private_Messages&file=index", $url); // and put it back for the modules.php
}
else if ((ereg("profile", $url)) && (!ereg("highlight=profile", $url)))
{
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace("profile.php", "modules.php?name=Forums&file=profile", $url); // and put it back for the modules.php
$dummy = 1;
}
else if ((ereg("memberlist", $url)) && (!ereg("highlight=memberlist", $url)))
{
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace("memberlist.php", "modules.php?name=Members_List&file=index", $url); // and put it back for the modules.php
} else {
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace(".php", "", $url);
$url = "modules.php?name=Forums&file=".$url; //Change to Nuke format
}

if ( !empty($SID) && !eregi('sid=', $url) && !areyouabot() )
{
if ( !empty($SID) && !eregi('sid=', $url) ) {
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}
}
return($url);
}
 

john2

WRInaute discret
ca serai donc mieu que je change de forum ? ou télécharger phpbb ? et esque je pourrait récupéré mes messages ?

au sinon, personne si connait en phpbz ??
 

john2

WRInaute discret
a bon...

c'est que j'y connait pas grand chose...

au sinon, j'ai pas trouver les ligne a modifier, mais elle ne correspond pas avec les mienne

je n'est trouver null part :

function append_sid($url, $non_html_amp = false)
{
global $SID;
if ( !empty($SID) && !eregi('sid=', $url) )
{
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}
return($url);
}
 

john2

WRInaute discret
c'est ca non :

<?php
/***************************************************************************
* sessions.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: sessions.php,v 1.58.2.8 2002/12/18 01:06:19 psotfx Exp $
*
*
***************************************************************************/
/***************************************************************************
* phpbb2 forums port version 2.1 (c) 2003 - Nuke Cops (http://nukecops.com)
*
* Ported by Paul Laudanski (Zhen-Xjell) to phpbb2 standalone 2.0.4. Test
* and debugging completed by the Elite Nukers at Nuke Cops: ArtificialIntel,
* Chatserv, MikeM, sixonetonoffun, Zhen-Xjell. Thanks to some heavy debug
* work by AI in Nuke 6.5.
*
* You run this package at your sole risk. Nuke Cops and affiliates cannot
* be held liable if anything goes wrong. You are advised to test this
* package on a development system. Backup everything before implementing
* in a production environment. If something goes wrong, you can always
* backout and restore your backups.
*
* Installing and running this also means you agree to the terms of the AUP
* found at Nuke Cops.
*
* This is version 2.1 of the phpbb2 forum port for PHP-Nuke. Work is based
* on Tom Nitzschner's forum port version 2.0.6. Tom's 2.0.6 port was based
* on the phpbb2 standalone version 2.0.3. Our version 2.1 from Nuke Cops is
* now reflecting phpbb2 standalone 2.0.4 that fixes some major SQL
* injection exploits.
***************************************************************************/
/***************************************************************************
* This file is part of the phpBB2 port to Nuke 6.0 (c) copyright 2002
* by Tom Nitzschner (tom@toms-home.com)
* http://bbtonuke.sourceforge.net (or http://www.toms-home.com)
*
* As always, make a backup before messing with anything. All code
* release by me is considered sample code only. It may be fully
* functual, but you use it at your own risk, if you break it,
* you get to fix it too. No waranty is given or implied.
*
* Please post all questions/request about this port on http://bbtonuke.sourceforge.net first,
* then on my site. All original header code and copyright messages will be maintained
* to give credit where credit is due. If you modify this, the only requirement is
* that you also maintain all original copyright messages. All my work is released
* under the GNU GENERAL PUBLIC LICENSE. Please see the README for more information.
*
***************************************************************************/

/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/

//
// Adds/updates a new session to the database for the given userid.
// Returns the new session ID on success.
//
function session_begin($user_id, $user_ip, $page_id, $auto_create = 0, $enable_autologin = 0)
{
global $db, $board_config;
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;

$cookiename = $board_config['cookie_name'];
$cookiepath = $board_config['cookie_path'];
$cookiedomain = $board_config['cookie_domain'];
$cookiesecure = $board_config['cookie_secure'];

if ( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename . '_data']) )
{
$session_id = isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : '';
$sessiondata = isset($HTTP_COOKIE_VARS[$cookiename . '_data']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename . '_data'])) : '';
$sessionmethod = SESSION_METHOD_COOKIE;
}
else
{
$sessiondata = '';
$session_id = ( isset($HTTP_GET_VARS['sid']) ) ? $HTTP_GET_VARS['sid'] : '';
$sessionmethod = SESSION_METHOD_GET;
}

$last_visit = 0;
$current_time = time();
$expiry_time = $current_time - $board_config['session_length'];

//
// Try and pull the last time stored in a cookie, if it exists
//
$sql = "SELECT *
FROM " . USERS_TABLE . "
WHERE user_id = $user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Could not obtain lastvisit data from user table', '', __LINE__, __FILE__, $sql);
}

$userdata = $db->sql_fetchrow($result);

if ( $user_id != ANONYMOUS )
{
$auto_login_key = $userdata['user_password'];

if ( $auto_create )
{
if ( isset($sessiondata['autologinid']) && $userdata['user_active'] )
{
// We have to login automagically
if( $sessiondata['autologinid'] == $auto_login_key )
{
// autologinid matches password
$login = 1;
$enable_autologin = 1;
}
else
{
// No match; don't login, set as anonymous user
$login = 0;
$enable_autologin = 0;
$user_id = ANONYMOUS;
}
}
else
{
// Autologin is not set. Don't login, set as anonymous user
$login = 0;
$enable_autologin = 0;
$user_id = ANONYMOUS;
}
}
else
{
$login = 1;
}
}
else
{
$login = 0;
$enable_autologin = 0;
}

//
// Initial ban check against user id, IP and email address
//
preg_match('/(..)(..)(..)(..)/', $user_ip, $user_ip_parts);

$sql = "SELECT ban_ip, ban_userid, ban_email
FROM " . BANLIST_TABLE . "
WHERE ban_ip IN ('" . $user_ip_parts[1] . $user_ip_parts[2] . $user_ip_parts[3] . $user_ip_parts[4] . "', '" . $user_ip_parts[1] . $user_ip_parts[2] . $user_ip_parts[3] . "ff', '" . $user_ip_parts[1] . $user_ip_parts[2] . "ffff', '" . $user_ip_parts[1] . "ffffff')
OR ban_userid = $user_id";
if ( $user_id != ANONYMOUS )
{
$sql .= " OR ban_email LIKE '" . str_replace("\'", "''", $userdata['user_email']) . "'
OR ban_email LIKE '" . substr(str_replace("\'", "''", $userdata['user_email']), strpos(str_replace("\'", "''", $userdata['user_email']), "@")) . "'";
}
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Could not obtain ban information', '', __LINE__, __FILE__, $sql);
}

if ( $ban_info = $db->sql_fetchrow($result) )
{
if ( $ban_info['ban_ip'] || $ban_info['ban_userid'] || $ban_info['ban_email'] )
{
message_die(CRITICAL_MESSAGE, 'You_been_banned');
}
}

//
// Create or update the session
//
$sql = "UPDATE " . SESSIONS_TABLE . "
SET session_user_id = $user_id, session_start = $current_time, session_time = $current_time, session_page = $page_id, session_logged_in = $login
WHERE session_id = '" . $session_id . "'
AND session_ip = '$user_ip'";
if ( !$db->sql_query($sql) || !$db->sql_affectedrows() )
{
$session_id = md5(uniqid($user_ip));

$sql = "INSERT INTO " . SESSIONS_TABLE . "
(session_id, session_user_id, session_start, session_time, session_ip, session_page, session_logged_in)
VALUES ('$session_id', $user_id, $current_time, $current_time, '$user_ip', $page_id, $login)";
if ( !$db->sql_query($sql) )
{
$error = TRUE;
if (SQL_LAYER == "mysql" || SQL_LAYER == "mysql4")
{
$sql_error = $db->sql_error($result);
if ($sql_error["code"] == 1114)
{
$result = $db->sql_query('SHOW TABLE STATUS LIKE "'.SESSIONS_TABLE.'"');
$row = $db->sql_fetchrow($result);
if ($row["Type"] == "HEAP")
{
if ($row["Rows"] > 2500)
{
$delete_order = (SQL_LAYER=="mysql4") ? " ORDER BY session_time ASC" : "";
$db->sql_query("DELETE QUICK FROM ".SESSIONS_TABLE."$delete_order LIMIT 50");
}
else
{
$db->sql_query("ALTER TABLE ".SESSIONS_TABLE." MAX_ROWS=".($row["Rows"]+50));
}
if ($db->sql_query($sql))
{
$error = FALSE;
}
}
}
}
if ($error)
{
message_die(CRITICAL_ERROR, "Error creating new session", "", __LINE__, __FILE__, $sql);
}
}
}

if ( $user_id != ANONYMOUS )
{// ( $userdata['user_session_time'] > $expiry_time && $auto_create ) ? $userdata['user_lastvisit'] : (
$last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : $current_time;

$sql = "UPDATE " . USERS_TABLE . "
SET user_session_time = $current_time, user_session_page = $page_id, user_lastvisit = $last_visit
WHERE user_id = $user_id";
if ( !$db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Error updating last visit time', '', __LINE__, __FILE__, $sql);
}

$userdata['user_lastvisit'] = $last_visit;

$sessiondata['autologinid'] = ( $enable_autologin && $sessionmethod == SESSION_METHOD_COOKIE ) ? $auto_login_key : '';
$sessiondata['userid'] = $user_id;
}

$userdata['session_id'] = $session_id;
$userdata['session_ip'] = $user_ip;
$userdata['session_user_id'] = $user_id;
$userdata['session_logged_in'] = $login;
$userdata['session_page'] = $page_id;
$userdata['session_start'] = $current_time;
$userdata['session_time'] = $current_time;

setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);
$SID = ( $sessionmethod == SESSION_METHOD_GET ) ? 'sid=' . $session_id : '';

return $userdata;
}

//
// Checks for a given user session, tidies session table and updates user
// sessions at each page refresh
//
function session_pagestart($user_ip, $thispage_id, $nukeuser)
{
global $db, $lang, $board_config, $session_id;
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;

$cookiename = $board_config['cookie_name'];
$cookiepath = $board_config['cookie_path'];
$cookiedomain = $board_config['cookie_domain'];
$cookiesecure = $board_config['cookie_secure'];

$current_time = time();
unset($userdata);

if ( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename . '_data']) )
{
$sessiondata = isset( $HTTP_COOKIE_VARS[$cookiename . '_data'] ) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename . '_data'])) : '';
$session_id = isset( $HTTP_COOKIE_VARS[$cookiename . '_sid'] ) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : '';
$sessionmethod = SESSION_METHOD_COOKIE;
}
else
{
$sessiondata = '';
$session_id = ( isset($HTTP_GET_VARS['sid']) ) ? $HTTP_GET_VARS['sid'] : '';
$sessionmethod = SESSION_METHOD_GET;
}
if ( ($nukeuser != "") && ($userdata['session_logged_in'] == "" )) {
bblogin($nukeuser, $session_id);
} else {
$sessiondata = '';
}

//
// Does a session exist?
//
if ( !empty($session_id) )
{
//
// session_id exists so go ahead and attempt to grab all
// data in preparation
//
$sql = "SELECT u.*, s.*
FROM " . SESSIONS_TABLE . " s, " . USERS_TABLE . " u
WHERE s.session_id = '$session_id'
AND u.user_id = s.session_user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);
}

$userdata = $db->sql_fetchrow($result);

//
// Did the session exist in the DB?
//
if ( isset($userdata['user_id']) )
{
//
// Do not check IP assuming equivalence, if IPv4 we'll check only first 24
// bits ... I've been told (by vHiker) this should alleviate problems with
// load balanced et al proxies while retaining some reliance on IP security.
//
$ip_check_s = substr($userdata['session_ip'], 0, 6);
$ip_check_u = substr($user_ip, 0, 6);

if ($ip_check_s == $ip_check_u)
{
$SID = ( $sessionmethod == SESSION_METHOD_GET ) ? 'sid=' . $session_id : '';

//
// Only update session DB a minute or so after last update
//
if ( $current_time - $userdata['session_time'] > 600 )
{
$sql = "UPDATE " . SESSIONS_TABLE . "
SET session_time = $current_time, session_page = $thispage_id
WHERE session_id = '" . $userdata['session_id'] . "'";
if ( !$db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Error updating sessions table', '', __LINE__, __FILE__, $sql);
}

if ( $userdata['user_id'] != ANONYMOUS )
{
$sql = "UPDATE " . USERS_TABLE . "
SET user_session_time = $current_time, user_session_page = $thispage_id
WHERE user_id = " . $userdata['user_id'];
if ( !$db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Error updating sessions table', '', __LINE__, __FILE__, $sql);
}
}

//
// Delete expired sessions
//
$expiry_time = $current_time - $board_config['session_length'];
$sql = "DELETE FROM " . SESSIONS_TABLE . "
WHERE session_time < $expiry_time
AND session_id <> '$session_id'";
if ( !$db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Error clearing sessions table', '', __LINE__, __FILE__, $sql);
}

setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);
}

return $userdata;
}
}
}

//
// If we reach here then no (valid) session exists. So we'll create a new one,
// using the cookie user_id if available to pull basic user prefs.
//
$user_id = ( isset($sessiondata['userid']) ) ? intval($sessiondata['userid']) : ANONYMOUS;

if ( !($userdata = session_begin($user_id, $user_ip, $thispage_id, TRUE)) )
{
message_die(CRITICAL_ERROR, 'Error creating user session', '', __LINE__, __FILE__, $sql);
}

return $userdata;

}

//
// session_end closes out a session
// deleting the corresponding entry
// in the sessions table
//
function session_end($session_id, $user_id)
{
global $db, $lang, $board_config;
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;

$cookiename = $board_config['cookie_name'];
$cookiepath = $board_config['cookie_path'];
$cookiedomain = $board_config['cookie_domain'];
$cookiesecure = $board_config['cookie_secure'];

//
// Pull cookiedata or grab the URI propagated sid
//
if ( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) )
{
$session_id = isset( $HTTP_COOKIE_VARS[$cookiename . '_sid'] ) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : '';
$sessionmethod = SESSION_METHOD_COOKIE;
}
else
{
$session_id = ( isset($HTTP_GET_VARS['sid']) ) ? $HTTP_GET_VARS['sid'] : '';
$sessionmethod = SESSION_METHOD_GET;
}

//
// Delete existing session
//
$sql = "DELETE FROM " . SESSIONS_TABLE . "
WHERE session_id = '$session_id'
AND session_user_id = $user_id";
if ( !$db->sql_query($sql) )
{
message_die(CRITICAL_ERROR, 'Error removing user session', '', __LINE__, __FILE__, $sql);
}

setcookie($cookiename . '_data', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);
setcookie($cookiename . '_sid', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);

return true;
}

//
// Append $SID to a url. Borrowed from phplib and modified. This is an
// extra routine utilised by the session code above and acts as a wrapper
// around every single URL and form action. If you replace the session
// code you must include this routine, even if it's empty.
//
function append_sid($url, $non_html_amp = false)
{
global $SID, $admin;
if (ereg("admin=1", $url) || ereg("admin_", $url) || ereg("pane=", $url)){
// The format is fine, don't change a thing.
} else if (ereg("Your_Account", $url)){
$url = str_replace(".php", "", $url); // Strip the .php from all the files,
$url = str_replace("modules", "modules.php", $url); // and put it back for the modules.php
}
else if (ereg("redirect", $url))
{
$url = str_replace("login.php", "modules.php?name=Your_Account", $url); // Strip the .php from all the files,
$url = str_replace(".php", "", $url); // Strip the .php from all the files,
$url = str_replace("?redirect", "&redirect", $url); // Strip the .php from all the files,
$url = str_replace("modules", "modules.php", $url); // and put it back for the modules.php
}
else if (ereg("menu=1", $url))
{
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace(".php", "", $url); // Strip the .php from all the files,
$url = "../../../modules.php?name=Forums&file=$url";
}
else if ((ereg("privmsg", $url)) && (!ereg("highlight=privmsg", $url)))
{
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace("privmsg.php", "modules.php?name=Private_Messages&file=index", $url); // and put it back for the modules.php
}
else if ((ereg("profile", $url)) && (!ereg("highlight=profile", $url)))
{
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace("profile.php", "modules.php?name=Forums&file=profile", $url); // and put it back for the modules.php
$dummy = 1;
}
else if ((ereg("memberlist", $url)) && (!ereg("highlight=memberlist", $url)))
{
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace("memberlist.php", "modules.php?name=Members_List&file=index", $url); // and put it back for the modules.php
} else {
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace(".php", "", $url);
$url = "modules.php?name=Forums&file=".$url; //Change to Nuke format
}

if ( !empty($SID) && !eregi('sid=', $url) && !areyouabot() )
{
if ( !empty($SID) && !eregi('sid=', $url) ) {
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}
}
return($url);
}
function areyouabot()
{
global $HTTP_SERVER_VARS;
$RobotsList = array (
"antibot",
"appie",
"architext",
"bjaaland",
"digout4u",
"echo",
"fast-webcrawler",
"ferret",
"googlebot",
"gulliver",
"harvest",
"htdig",
"ia_archiver",
"jeeves",
"jennybot",
"linkwalker",
"lycos",
"mercator",
"moget",
"muscatferret",
"myweb",
"netcraft",
"nomad",
"petersnews",
"scooter",
"slurp",
"unlost_web_crawler",
"voila",
"voyager",
"webbase",
"weblayers",
"wget",
"wisenutbot",
"acme.spider",
"ahoythehomepagefinder",
"alkaline",
"arachnophilia",
"aretha",
"ariadne",
"arks",
"aspider",
"atn.txt",
"atomz",
"auresys",
"backrub",
"bigbrother",
"blackwidow",
"blindekuh",
"bloodhound",
"brightnet",
"bspider",
"cactvschemistryspider",
"cassandra",
"cgireader",
"checkbot",
"churl",
"cmc",
"collective",
"combine",
"conceptbot",
"coolbot",
"core",
"cosmos",
"cruiser",
"cusco",
"cyberspyder",
"deweb",
"dienstspider",
"digger",
"diibot",
"directhit",
"dnabot",
"download_express",
"dragonbot",
"dwcp",
"e-collector",
"ebiness",
"eit",
"elfinbot",
"emacs",
"emcspider",
"esther",
"evliyacelebi",
"nzexplorer",
"fdse",
"felix",
"fetchrover",
"fido",
"finnish",
"fireball",
"fouineur",
"francoroute",
"freecrawl",
"funnelweb",
"gama",
"gazz",
"gcreep",
"getbot",
"geturl",
"golem",
"grapnel",
"griffon",
"gromit",
"hambot",
"havindex",
"hometown",
"htmlgobble",
"hyperdecontextualizer",
"iajabot",
"ibm",
"iconoclast",
"ilse",
"imagelock",
"incywincy",
"informant",
"infoseek",
"infoseeksidewinder",
"infospider",
"inspectorwww",
"intelliagent",
"irobot",
"iron33",
"israelisearch",
"javabee",
"jbot",
"jcrawler",
"jobo",
"jobot",
"joebot",
"jubii",
"jumpstation",
"katipo",
"kdd",
"kilroy",
"ko_yappo_robot",
"labelgrabber.txt",
"larbin",
"legs",
"linkidator",
"linkscan",
"lockon",
"logo_gif",
"macworm",
"magpie",
"marvin",
"mattie",
"mediafox",
"merzscope",
"meshexplorer",
"mindcrawler",
"momspider",
"monster",
"motor",
"mwdsearch",
"netcarta",
"netmechanic",
"netscoop",
"newscan-online",
"nhse",
"northstar",
"occam",
"octopus",
"openfind",
"orb_search",
"packrat",
"pageboy",
"parasite",
"patric",
"pegasus",
"perignator",
"perlcrawler",
"phantom",
"piltdownman",
"pimptrain",
"pioneer",
"pitkow",
"pjspider",
"pka",
"plumtreewebaccessor",
"poppi",
"portalb",
"puu",
"python",
"raven",
"rbse",
"resumerobot",
"rhcs",
"roadrunner",
"robbie",
"robi",
"robofox",
"robozilla",
"roverbot",
"rules",
"safetynetrobot",
"search_au",
"searchprocess",
"senrigan",
"sgscout",
"shaggy",
"shaihulud",
"sift",
"simbot",
"site-valet",
"sitegrabber",
"sitetech",
"slcrawler",
"smartspider",
"snooper",
"solbot",
"spanner",
"speedy",
"spider_monkey",
"spiderbot",
"spiderline",
"spiderman",
"spiderview",
"spry",
"ssearcher",
"suke",
"suntek",
"sven",
"tach_bw",
"tarantula",
"tarspider",
"techbot",
"templeton",
"teoma_agent1",
"titin",
"titan",
"tkwww",
"tlspider",
"ucsd",
"udmsearch",
"urlck",
"valkyrie",
"victoria",
"visionsearch",
"vwbot",
"w3index",
"w3m2",
"wallpaper",
"wanderer",
"wapspider",
"webbandit",
"webcatcher",
"webcopy",
"webfetcher",
"webfoot",
"weblinker",
"webmirror",
"webmoose",
"webquest",
"webreader",
"webreaper",
"websnarf",
"webspider",
"webvac",
"webwalk",
"webwalker",
"webwatch",
"whatuseek",
"whowhere",
"wired-digital",
"wmir",
"wolp",
"wombat",
"worm",
"wwwc",
"wz101",
"xget",
"awbot",
"bobby",
"boris",
"bumblebee",
"cscrawler",
"daviesbot",
"ezresult",
"gigabot",
"gnodspider",
"internetseer",
"justview",
"linkbot",
"linkchecker",
"nederland.zoek",
"perman",
"pompos",
"psbot",
"redalert",
"shoutcast",
"slysearch",
"ultraseek",
"webcompass",
"yandex",
"robot",
"crawl"
);
$botID = strtolower($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
for ($i = 0; $i < count($RobotsList); $i++)
{
if ( strstr($botID, $RobotsList[$i]) )
{
return TRUE;
}
}
return FALSE;

}

function admin_sid($url, $non_html_amp = false)
{
global $SID;
$url = "../../../modules.php?name=Forums&file=$url";

if ( !empty($SID) && !eregi('sid=', $url) )
{
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}

return($url);
}

?>
 

Karbon

WRInaute discret
Code:
<?php
/***************************************************************************
 *                                sessions.php
 *                            -------------------
 *   begin                : Saturday, Feb 13, 2001
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: sessions.php,v 1.58.2.6 2002/07/19 22:19:08 psotfx Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

//
// Adds/updates a new session to the database for the given userid.
// Returns the new session ID on success.
//
function session_begin($user_id, $user_ip, $page_id, $auto_create = 0, $enable_autologin = 0)
{
	global $db, $board_config;
	global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;

	$cookiename = $board_config['cookie_name'];
	$cookiepath = $board_config['cookie_path'];
	$cookiedomain = $board_config['cookie_domain'];
	$cookiesecure = $board_config['cookie_secure'];

	if ( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename . '_data']) )
	{
		$session_id = isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : '';
		$sessiondata = isset($HTTP_COOKIE_VARS[$cookiename . '_data']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename . '_data'])) : '';
		$sessionmethod = SESSION_METHOD_COOKIE;
	}
	else
	{
		$sessiondata = '';
		$session_id = ( isset($HTTP_GET_VARS['sid']) ) ? $HTTP_GET_VARS['sid'] : '';
		$sessionmethod = SESSION_METHOD_GET;
	}

	$last_visit = 0;
	$current_time = time();
	$expiry_time = $current_time - $board_config['session_length'];

	//
	// Try and pull the last time stored in a cookie, if it exists
	//
	$sql = "SELECT * 
		FROM " . USERS_TABLE . " 
		WHERE user_id = $user_id";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(CRITICAL_ERROR, 'Could not obtain lastvisit data from user table', '', __LINE__, __FILE__, $sql);
	}

	$userdata = $db->sql_fetchrow($result);

	if ( $user_id != ANONYMOUS )
	{
		$auto_login_key = $userdata['user_password'];

		if ( $auto_create )
		{
			if ( isset($sessiondata['autologinid']) && $userdata['user_active'] )
			{
				// We have to login automagically
				if( $sessiondata['autologinid'] == $auto_login_key )
				{
					// autologinid matches password
					$login = 1;
					$enable_autologin = 1;
				}
				else
				{
					// No match; don't login, set as anonymous user
					$login = 0; 
					$enable_autologin = 0; 
					$user_id = ANONYMOUS;
				}
			}
			else
			{
				// Autologin is not set. Don't login, set as anonymous user
				$login = 0;
				$enable_autologin = 0;
				$user_id = ANONYMOUS;
			}
		}
		else
		{
			$login = 1;
		}
	}
	else
	{
		$login = 0;
		$enable_autologin = 0;
	}

	//
	// Initial ban check against user id, IP and email address
	//
	preg_match('/(..)(..)(..)(..)/', $user_ip, $user_ip_parts);

	$sql = "SELECT ban_ip, ban_userid, ban_email 
		FROM " . BANLIST_TABLE . " 
		WHERE ban_ip IN ('" . $user_ip_parts[1] . $user_ip_parts[2] . $user_ip_parts[3] . $user_ip_parts[4] . "', '" . $user_ip_parts[1] . $user_ip_parts[2] . $user_ip_parts[3] . "ff', '" . $user_ip_parts[1] . $user_ip_parts[2] . "ffff', '" . $user_ip_parts[1] . "ffffff')
			OR ban_userid = $user_id";
	if ( $user_id != ANONYMOUS )
	{
		$sql .= " OR ban_email LIKE '" . str_replace("\'", "''", $userdata['user_email']) . "' 
			OR ban_email LIKE '" . substr(str_replace("\'", "''", $userdata['user_email']), strpos(str_replace("\'", "''", $userdata['user_email']), "@")) . "'";
	}
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(CRITICAL_ERROR, 'Could not obtain ban information', '', __LINE__, __FILE__, $sql);
	}

	if ( $ban_info = $db->sql_fetchrow($result) )
	{
		if ( $ban_info['ban_ip'] || $ban_info['ban_userid'] || $ban_info['ban_email'] )
		{
			message_die(CRITICAL_MESSAGE, 'You_been_banned');
		}
	}

	//
	// Create or update the session
	//
	$sql = "UPDATE " . SESSIONS_TABLE . "
		SET session_user_id = $user_id, session_start = $current_time, session_time = $current_time, session_page = $page_id, session_logged_in = $login
		WHERE session_id = '" . $session_id . "' 
			AND session_ip = '$user_ip'";
	if ( !$db->sql_query($sql) || !$db->sql_affectedrows() )
	{
		$session_id = md5(uniqid($user_ip));

		$sql = "INSERT INTO " . SESSIONS_TABLE . "
			(session_id, session_user_id, session_start, session_time, session_ip, session_page, session_logged_in)
			VALUES ('$session_id', $user_id, $current_time, $current_time, '$user_ip', $page_id, $login)";
		if ( !$db->sql_query($sql) )
		{
			message_die(CRITICAL_ERROR, 'Error creating new session', '', __LINE__, __FILE__, $sql);
		}
	}

	if ( $user_id != ANONYMOUS )
	{// ( $userdata['user_session_time'] > $expiry_time && $auto_create ) ? $userdata['user_lastvisit'] : ( 
		$last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : $current_time; 

		$sql = "UPDATE " . USERS_TABLE . " 
			SET user_session_time = $current_time, user_session_page = $page_id, user_lastvisit = $last_visit
			WHERE user_id = $user_id";
		if ( !$db->sql_query($sql) )
		{
			message_die(CRITICAL_ERROR, 'Error updating last visit time', '', __LINE__, __FILE__, $sql);
		}

		$userdata['user_lastvisit'] = $last_visit;

		$sessiondata['autologinid'] = ( $enable_autologin && $sessionmethod == SESSION_METHOD_COOKIE ) ? $auto_login_key : '';
		$sessiondata['userid'] = $user_id;
	}

	$userdata['session_id'] = $session_id;
	$userdata['session_ip'] = $user_ip;
	$userdata['session_user_id'] = $user_id;
	$userdata['session_logged_in'] = $login;
	$userdata['session_page'] = $page_id;
	$userdata['session_start'] = $current_time;
	$userdata['session_time'] = $current_time;

	setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
	setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);

	$SID = ( $sessionmethod == SESSION_METHOD_GET ) ? 'sid=' . $session_id : '';

	return $userdata;
}

//
// Checks for a given user session, tidies session table and updates user
// sessions at each page refresh
//
function session_pagestart($user_ip, $thispage_id)
{
	global $db, $lang, $board_config;
	global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;

	$cookiename = $board_config['cookie_name'];
	$cookiepath = $board_config['cookie_path'];
	$cookiedomain = $board_config['cookie_domain'];
	$cookiesecure = $board_config['cookie_secure'];

	$current_time = time();
	unset($userdata);

	if ( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) || isset($HTTP_COOKIE_VARS[$cookiename . '_data']) )
	{
		$sessiondata = isset( $HTTP_COOKIE_VARS[$cookiename . '_data'] ) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookiename . '_data'])) : '';
		$session_id = isset( $HTTP_COOKIE_VARS[$cookiename . '_sid'] ) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : '';
		$sessionmethod = SESSION_METHOD_COOKIE;
	}
	else
	{
		$sessiondata = '';
		$session_id = ( isset($HTTP_GET_VARS['sid']) ) ? $HTTP_GET_VARS['sid'] : '';
		$sessionmethod = SESSION_METHOD_GET;
	}

	//
	// Does a session exist?
	//
	if ( !empty($session_id) )
	{
		//
		// session_id exists so go ahead and attempt to grab all
		// data in preparation
		//
		$sql = "SELECT u.*, s.*
			FROM " . SESSIONS_TABLE . " s, " . USERS_TABLE . " u
			WHERE s.session_id = '$session_id'
				AND u.user_id = s.session_user_id";
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch', '', __LINE__, __FILE__, $sql);
		}

		$userdata = $db->sql_fetchrow($result);

		//
		// Did the session exist in the DB?
		//
		if ( isset($userdata['user_id']) )
		{
			//
			// Do not check IP assuming equivalence, if IPv4 we'll check only first 24
			// bits ... I've been told (by vHiker) this should alleviate problems with 
			// load balanced et al proxies while retaining some reliance on IP security.
			//
			$ip_check_s = substr($userdata['session_ip'], 0, 6);
			$ip_check_u = substr($user_ip, 0, 6);

			if ( $ip_check_s == $ip_check_u )
			{
				$SID = ( $sessionmethod == SESSION_METHOD_GET ) ? 'sid=' . $session_id : '';

				//
				// Only update session DB a minute or so after last update
				//
				if ( $current_time - $userdata['session_time'] > 60 )
				{
					$sql = "UPDATE " . SESSIONS_TABLE . " 
						SET session_time = $current_time, session_page = $thispage_id 
						WHERE session_id = '" . $userdata['session_id'] . "'";
					if ( !$db->sql_query($sql) )
					{
						message_die(CRITICAL_ERROR, 'Error updating sessions table', '', __LINE__, __FILE__, $sql);
					}

					if ( $userdata['user_id'] != ANONYMOUS )
					{
						$sql = "UPDATE " . USERS_TABLE . " 
							SET user_session_time = $current_time, user_session_page = $thispage_id 
							WHERE user_id = " . $userdata['user_id'];
						if ( !$db->sql_query($sql) )
						{
							message_die(CRITICAL_ERROR, 'Error updating sessions table', '', __LINE__, __FILE__, $sql);
						}
					}

					//
					// Delete expired sessions
					//
					$expiry_time = $current_time - $board_config['session_length'];
					$sql = "DELETE FROM " . SESSIONS_TABLE . " 
						WHERE session_time < $expiry_time 
							AND session_id <> '$session_id'";
					if ( !$db->sql_query($sql) )
					{
						message_die(CRITICAL_ERROR, 'Error clearing sessions table', '', __LINE__, __FILE__, $sql);
					}

					setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
					setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);
				}

				return $userdata;
			}
		}
	}

	//
	// If we reach here then no (valid) session exists. So we'll create a new one,
	// using the cookie user_id if available to pull basic user prefs.
	//
	$user_id = ( isset($sessiondata['userid']) ) ? intval($sessiondata['userid']) : ANONYMOUS;

	if ( !($userdata = session_begin($user_id, $user_ip, $thispage_id, TRUE)) )
	{
		message_die(CRITICAL_ERROR, 'Error creating user session', '', __LINE__, __FILE__, $sql);
	}

	return $userdata;

}

//
// session_end closes out a session
// deleting the corresponding entry
// in the sessions table
//
function session_end($session_id, $user_id)
{
	global $db, $lang, $board_config;
	global $HTTP_COOKIE_VARS, $HTTP_GET_VARS, $SID;

	$cookiename = $board_config['cookie_name'];
	$cookiepath = $board_config['cookie_path'];
	$cookiedomain = $board_config['cookie_domain'];
	$cookiesecure = $board_config['cookie_secure'];

	//
	// Pull cookiedata or grab the URI propagated sid
	//
	if ( isset($HTTP_COOKIE_VARS[$cookiename . '_sid']) )
	{
		$session_id = isset( $HTTP_COOKIE_VARS[$cookiename . '_sid'] ) ? $HTTP_COOKIE_VARS[$cookiename . '_sid'] : '';
		$sessionmethod = SESSION_METHOD_COOKIE;
	}
	else
	{
		$session_id = ( isset($HTTP_GET_VARS['sid']) ) ? $HTTP_GET_VARS['sid'] : '';
		$sessionmethod = SESSION_METHOD_GET;
	}

	//
	// Delete existing session
	//
	$sql = "DELETE FROM " . SESSIONS_TABLE . " 
		WHERE session_id = '$session_id' 
			AND session_user_id = $user_id";
	if ( !$db->sql_query($sql) )
	{
		message_die(CRITICAL_ERROR, 'Error removing user session', '', __LINE__, __FILE__, $sql);
	}

	setcookie($cookiename . '_data', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);
	setcookie($cookiename . '_sid', '', $current_time - 31536000, $cookiepath, $cookiedomain, $cookiesecure);

	return true;
}

//
// Append $SID to a url. Borrowed from phplib and modified. This is an
// extra routine utilised by the session code above and acts as a wrapper
// around every single URL and form action. If you replace the session
// code you must include this routine, even if it's empty.
//
function append_sid($url, $non_html_amp = false) 
{ 
  global $SID; 
//  if ( !empty($SID) && !eregi('sid=', $url) ) 
//  { 
//     $url .= ( ( strpos($url, '?') != false ) ?  ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID; 
//  } 
  return($url); 
}
?>

le code a été modifié pour supprimer les sid a la fin en bas
 

john2

WRInaute discret
sur le fichier que vous venez de mettre, il est marqué ca en dessous de la fonction session_end


function append_sid($url, $non_html_amp = false)
{
global $SID;
// if ( !empty($SID) && !eregi('sid=', $url) )
// {
// $url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
// }
return($url);
}
?>

et c'est finit...

tandis que moi, il est marqué ca en dessous :


f
unction append_sid($url, $non_html_amp = false)
{
global $SID, $admin;
if (ereg("admin=1", $url) || ereg("admin_", $url) || ereg("pane=", $url)){
// The format is fine, don't change a thing.
} else if (ereg("Your_Account", $url)){
$url = str_replace(".php", "", $url); // Strip the .php from all the files,
$url = str_replace("modules", "modules.php", $url); // and put it back for the modules.php
}
else if (ereg("redirect", $url))
{
$url = str_replace("login.php", "modules.php?name=Your_Account", $url); // Strip the .php from all the files,
$url = str_replace(".php", "", $url); // Strip the .php from all the files,
$url = str_replace("?redirect", "&redirect", $url); // Strip the .php from all the files,
$url = str_replace("modules", "modules.php", $url); // and put it back for the modules.php
}
else if (ereg("menu=1", $url))
{
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace(".php", "", $url); // Strip the .php from all the files,
$url = "../../../modules.php?name=Forums&file=$url";
}
else if ((ereg("privmsg", $url)) && (!ereg("highlight=privmsg", $url)))
{
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace("privmsg.php", "modules.php?name=Private_Messages&file=index", $url); // and put it back for the modules.php
}
else if ((ereg("profile", $url)) && (!ereg("highlight=profile", $url)))
{
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace("profile.php", "modules.php?name=Forums&file=profile", $url); // and put it back for the modules.php
$dummy = 1;
}
else if ((ereg("memberlist", $url)) && (!ereg("highlight=memberlist", $url)))
{
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace("memberlist.php", "modules.php?name=Members_List&file=index", $url); // and put it back for the modules.php
} else {
$url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
$url = str_replace(".php", "", $url);
$url = "modules.php?name=Forums&file=".$url; //Change to Nuke format
}

if ( !empty($SID) && !eregi('sid=', $url) && !areyouabot() )
{
if ( !empty($SID) && !eregi('sid=', $url) ) {
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}
}
return($url);
}
function areyouabot()
{
global $HTTP_SERVER_VARS;
$RobotsList = array (
"antibot",
"appie",
"architext",
"bjaaland",
"digout4u",
"echo",
"fast-webcrawler",
"ferret",
"googlebot",
"gulliver",
"harvest",
"htdig",
"ia_archiver",
"jeeves",
"jennybot",
"linkwalker",
"lycos",
"mercator",
"moget",
"muscatferret",
"myweb",
"netcraft",
"nomad",
"petersnews",
"scooter",
"slurp",
"unlost_web_crawler",
"voila",
"voyager",
"webbase",
"weblayers",
"wget",
"wisenutbot",
"acme.spider",
"ahoythehomepagefinder",
"alkaline",
"arachnophilia",
"aretha",
"ariadne",
"arks",
"aspider",
"atn.txt",
"atomz",
"auresys",
"backrub",
"bigbrother",
"blackwidow",
"blindekuh",
"bloodhound",
"brightnet",
"bspider",
"cactvschemistryspider",
"cassandra",
"cgireader",
"checkbot",
"churl",
"cmc",
"collective",
"combine",
"conceptbot",
"coolbot",
"core",
"cosmos",
"cruiser",
"cusco",
"cyberspyder",
"deweb",
"dienstspider",
"digger",
"diibot",
"directhit",
"dnabot",
"download_express",
"dragonbot",
"dwcp",
"e-collector",
"ebiness",
"eit",
"elfinbot",
"emacs",
"emcspider",
"esther",
"evliyacelebi",
"nzexplorer",
"fdse",
"felix",
"fetchrover",
"fido",
"finnish",
"fireball",
"fouineur",
"francoroute",
"freecrawl",
"funnelweb",
"gama",
"gazz",
"gcreep",
"getbot",
"geturl",
"golem",
"grapnel",
"griffon",
"gromit",
"hambot",
"havindex",
"hometown",
"htmlgobble",
"hyperdecontextualizer",
"iajabot",
"ibm",
"iconoclast",
"ilse",
"imagelock",
"incywincy",
"informant",
"infoseek",
"infoseeksidewinder",
"infospider",
"inspectorwww",
"intelliagent",
"irobot",
"iron33",
"israelisearch",
"javabee",
"jbot",
"jcrawler",
"jobo",
"jobot",
"joebot",
"jubii",
"jumpstation",
"katipo",
"kdd",
"kilroy",
"ko_yappo_robot",
"labelgrabber.txt",
"larbin",
"legs",
"linkidator",
"linkscan",
"lockon",
"logo_gif",
"macworm",
"magpie",
"marvin",
"mattie",
"mediafox",
"merzscope",
"meshexplorer",
"mindcrawler",
"momspider",
"monster",
"motor",
"mwdsearch",
"netcarta",
"netmechanic",
"netscoop",
"newscan-online",
"nhse",
"northstar",
"occam",
"octopus",
"openfind",
"orb_search",
"packrat",
"pageboy",
"parasite",
"patric",
"pegasus",
"perignator",
"perlcrawler",
"phantom",
"piltdownman",
"pimptrain",
"pioneer",
"pitkow",
"pjspider",
"pka",
"plumtreewebaccessor",
"poppi",
"portalb",
"puu",
"python",
"raven",
"rbse",
"resumerobot",
"rhcs",
"roadrunner",
"robbie",
"robi",
"robofox",
"robozilla",
"roverbot",
"rules",
"safetynetrobot",
"search_au",
"searchprocess",
"senrigan",
"sgscout",
"shaggy",
"shaihulud",
"sift",
"simbot",
"site-valet",
"sitegrabber",
"sitetech",
"slcrawler",
"smartspider",
"snooper",
"solbot",
"spanner",
"speedy",
"spider_monkey",
"spiderbot",
"spiderline",
"spiderman",
"spiderview",
"spry",
"ssearcher",
"suke",
"suntek",
"sven",
"tach_bw",
"tarantula",
"tarspider",
"techbot",
"templeton",
"teoma_agent1",
"titin",
"titan",
"tkwww",
"tlspider",
"ucsd",
"udmsearch",
"urlck",
"valkyrie",
"victoria",
"visionsearch",
"vwbot",
"w3index",
"w3m2",
"wallpaper",
"wanderer",
"wapspider",
"webbandit",
"webcatcher",
"webcopy",
"webfetcher",
"webfoot",
"weblinker",
"webmirror",
"webmoose",
"webquest",
"webreader",
"webreaper",
"websnarf",
"webspider",
"webvac",
"webwalk",
"webwalker",
"webwatch",
"whatuseek",
"whowhere",
"wired-digital",
"wmir",
"wolp",
"wombat",
"worm",
"wwwc",
"wz101",
"xget",
"awbot",
"bobby",
"boris",
"bumblebee",
"cscrawler",
"daviesbot",
"ezresult",
"gigabot",
"gnodspider",
"internetseer",
"justview",
"linkbot",
"linkchecker",
"nederland.zoek",
"perman",
"pompos",
"psbot",
"redalert",
"shoutcast",
"slysearch",
"ultraseek",
"webcompass",
"yandex",
"robot",
"crawl"
);
$botID = strtolower($HTTP_SERVER_VARS['HTTP_USER_AGENT']);
for ($i = 0; $i < count($RobotsList); $i++)
{
if ( strstr($botID, $RobotsList[$i]) )
{
return TRUE;
}
}
return FALSE;

}

function admin_sid($url, $non_html_amp = false)
{
global $SID;
$url = "../../../modules.php?name=Forums&file=$url";

if ( !empty($SID) && !eregi('sid=', $url) )
{
$url .= ( ( strpos($url, '?') != false ) ? ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
}

return($url);
}

?>

je l'ai pourtant jamais modifier
 

troops

WRInaute occasionnel
Il y a un forum sur le site concerner normalement pour ça... C'est moi qu'on va engueuler après si ont fé du HS. Bon le soft tu le met ou tu veux y a pas besoin de le mettre à un endroit spécifique
 

volvoman

Nouveau WRInaute
Bonjour à tous à tous!

Ceci est mon premier post, il faut toujours un début à tout...

Je viens de tester la solution proposée en page 1 à savoir celle-ci:

Step 1. In /includes/page_header.php before

Code:
//
// Generate logged in/logged out status
//



add this code (make sure there are no space breaks at line ends after you paste):

Code:
//
// Short URL implementation
//
ob_start();
function replace_for_mod_rewrite(&$s)
{
$urlin =
array(
"'(?<!/)viewforum.php\?f=([0-9]*)&(?:amp;)topicdays=([0-9]*)&(?:amp;)start=([0-9]*)'",
"'(?<!/)viewforum.php\?f=([0-9]*)&(?:amp;)mark=topics'",
"'(?<!/)viewforum.php\?f=([0-9]*)'",
"'(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)view=previous'",
"'(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)view=next'",
"'(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)postdays=([0-9]*)&(?:amp;)postorder=([a-zA-Z]*)&(?:amp;)start=([0-9]*)'",
"'(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)start=([0-9]*)&(?:amp;)postdays=([0-9]*)&(?:amp;)postorder=([a-zA-Z]*)&(?:amp;)highlight=([a-zA-Z0-9]*)'",
"'(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)start=([0-9]*)'",
"'(?<!/)viewtopic.php\?t=([0-9]*)'",
"'(?<!/)viewtopic.php&(?:amp;)p=([0-9]*)'",
"'(?<!/)viewtopic.php\?p=([0-9]*)'",
);
$urlout = array(
"viewforum\\1-\\2-\\3.html",
"forum\\1.html",
"forum\\1.html",
"ptopic\\1.html",
"ntopic\\1.html",
"ftopic\\1-\\2-\\3-\\4.html",
"ftopic\\1.html",
"ftopic\\1-\\2.html",
"ftopic\\1.html",
"sutra\\1.html",
"sutra\\1.html",
);
$s = preg_replace($urlin, $urlout, $s);
return $s;
}


Step 2. In /includes/page_tail.php after


Code:
$db->sql_close();



add this:

Code:
$contents = ob_get_contents();
ob_end_clean();
echo replace_for_mod_rewrite($contents);
global $dbg_starttime;




in the same file after

Code:
ob_end_clean();



add this:

Code:
echo replace_for_mod_rewrite($contents);
global $dbg_starttime;



Step 3. In your .htaccess file (if you don't have one create it; should be located in you forum root directory) paste these lines:

Code:
RewriteEngine On
RewriteRule ^forums.* index.php
RewriteRule ^forum([0-9]*).* viewforum.php?f=$1&mark=topic
RewriteRule ^viewforum([0-9]*)-([0-9]*)-([0-9]*).* viewforum.php?f=$1&topicdays=$2&start=$3
RewriteRule ^forum([0-9]*).* viewforum.php?f=$1
RewriteRule ^ptopic([0-9]*).* viewtopic.php?t=$1&view=previous
RewriteRule ^ntopic([0-9]*).* viewtopic.php?t=$1&view=next
RewriteRule ^ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4
RewriteRule ^ftopic([0-9]*)-([0-9]*).* viewtopic.php?t=$1&start=$2
RewriteRule ^ftopic([0-9]*).* viewtopic.php?t=$1
RewriteRule ^ftopic([0-9]*).html viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5
RewriteRule ^sutra([0-9]*).* viewtopic.php?p=$1



Note: sometimes this .htaccess code won't work properly if the forum is on a subdomain (was the case with me), you may need to try this variation:

Code:
RewriteEngine On
RewriteRule ^forums.* /index.php
RewriteRule ^forum([0-9]*).* /viewforum.php?f=$1&mark=topic
RewriteRule ^viewforum([0-9]*)-([0-9]*)-([0-9]*).* /viewforum.php?f=$1&topicdays=$2&start=$3
RewriteRule ^forum([0-9]*).* /viewforum.php?f=$1
RewriteRule ^ptopic([0-9]*).* /viewtopic.php?t=$1&view=previous
RewriteRule ^ntopic([0-9]*).* /viewtopic.php?t=$1&view=next
RewriteRule ^ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* /viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4
RewriteRule ^ftopic([0-9]*)-([0-9]*).* /viewtopic.php?t=$1&start=$2
RewriteRule ^ftopic([0-9]*).* /viewtopic.php?t=$1
RewriteRule ^ftopic([0-9]*).html /viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5
RewriteRule ^sutra([0-9]*).* /viewtopic.php?p=$1



Step 4. Very important! In your robots.txt file (goes at the *site* root) add these lines:

Code:
Disallow: /your-forum-folder/sutra*.html$
Disallow: /your-forum-folder/ptopic*.html$
Disallow: /your-forum-folder/ntopic*.html$
Disallow: /your-forum-folder/ftopic*asc*.html$



(This is required to avoid feeding duplicate content to Google)

Step 5. Apply Google Mod #1 described at this page.

J'ai également mis en commentaire le fameux morceau de texte dans le fichier sessions.php

Le résultat est que tout fonctionne (miracle?), personnellement je ne constate aucune anomalie (ou je me trompe?? vous pouvez toujours jeter un coup d'oeil sur le forum: http://www.volvo300mania.com/forum/) et j'ai parfaitement accès au panneau d'administration.

La seule chose qui m'intrigue maintenant, c'est ceci: l'étape 5, le fichier robots.txt pour éviter que Google ne pénalise pour "contenu dédoublé". j'ai créé ce fichier comme indiqué:

Very important! In your robots.txt file (goes at the *site* root) add these lines:

Code:
Disallow: /your-forum-folder/sutra*.html$
Disallow: /your-forum-folder/ptopic*.html$
Disallow: /your-forum-folder/ntopic*.html$
Disallow: /your-forum-folder/ftopic*asc*.html$

J'ai donc ceci dans mon cas:

User-agent: *
Disallow: /forum/sutra*.html$
Disallow: /forum/ptopic*.html$
Disallow: /forum/ntopic*.html$
Disallow: /forum/ftopic*asc*.html$


L'ennui, c'est que quand je teste ce fichier sur de nombreux sites qui permettent de le faire, j'obtiens ceci:


It validates, but has some bad style.

2 warning Possible Missplaced Wildcard. Although Google supports wildcards in the Disallow field, it is nonstandard.

Disallow: /forum/sutra*.html$
3 warning Possible Missplaced Wildcard. Although Google supports wildcards in the Disallow field, it is nonstandard.

Disallow: /forum/ptopic*.html$
4 warning Possible Missplaced Wildcard. Although Google supports wildcards in the Disallow field, it is nonstandard.

Disallow: /forum/ntopic*.html$
5 warning Possible Missplaced Wildcard. Although Google supports wildcards in the Disallow field, it is nonstandard.

Disallow: /forum/ftopic*asc*.html$

Le ficher serait donc accepté mais avec réserves!! Le coup des étoiles ne semble pas très propre... Et j'espère même que le fichier fonctionnera vraiment!! Quelqu'un peut-il m'éclairer? Merci d'avance!!
 

volvoman

Nouveau WRInaute
A nouveau moi... Toujours concernant cette étape 5 avec le fichier robots.txt...

Je me rends compte de quelque chose: l'instruction dans ce fichier demandant de ne PAS visiter les liens "propres" sans n° de session ou je ne sais quoi est finalement stupide, non?

C'est justement l'inverse qu'on veut! Ne pas faire visiter les pages avec les codes mais bien celles avec une adresse propre pour espérer que Google référence!

Ou alors je n'ai rien compris, LOL
 

WebRankInfo

Olivier Duffez (admin)
Membre du personnel
effectivement c'est étrange. je n'ai pas suivi tout le topo mais ces lignes dans le robots.txt c'est étrange.
sinon effectivement le standard de ce fichier ne permet pas de mettre des * dans les lignes Disallow
c'est utilisable seulement pour définir des robots (user agent)
 

marck5

WRInaute discret
Souhaitant à mon tour rewriter un forum phpbb 2.0.6 sous ovh, j'ai scrupuleusement suivi le descriptif donné par Kali et qui semble avoir marché pour certain d'entre vous.

A ma grande desillusion, lorsque je clique sur les forums ça ne trouve pas les pages. Si vous voulez voir ce que ça donne :

http://www.paranormal-ondes.com/forum/index.php

J'avoue avoir bien tout regardé et je comprends pas bien ou ça foire...

Si qq pouvait me donner des pistes pour corriger ce sérieux problème ce serait sympa

Merci
 

mahefarivony

WRInaute accro
dans tes regles faut pt'et mettre un truc dans ce genre

Code:
RewriteRule ^forum([0-9]*).* /forum/viewforum.php?f=$1

au lieu de

Code:
RewriteRule ^forum([0-9]*).* /viewforum.php?f=$1
 

JeromeRookie

WRInaute occasionnel
c'est etrange...
pourtant c'est très simple; tu peux essayer de reinstaller ton forum et a nouveau de faire la manip.
je tiens à la dispo de ceux que ca intéresse un fichier word avec la procédure.
 

St3phane

Nouveau WRInaute
Bonjour,

J'ai essayé de faire un url rewriting sur mon forum, mais ça n'a marché! :(

sachant que le forum est un répertoire à la racine : -www.domaine.com/forums/
voilà le code que j'ai utilisé :

Code:
RewriteEngine on

RewriteRule ^viewforum_([0-9]+)_([0-9]+)_([0-9]+)\.htm$ /viewforum.php?f=$1topicdays=$2&start=$3 [L]
RewriteRule ^viewforum_([0-9]+)\.htm$ /viewforum.php?f=$1 [L]
RewriteRule ^viewtopic_([0-9]+)_([0-9]+)_(asc|desc)_([0-9]+)\.htm$ /viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4 [L]
RewriteRule ^viewtopic_([0-9]+)_([0-9]+)\.htm$ /viewtopic.php?t=$1&start=$2 [L]
RewriteRule ^viewtopic_([0-9]+)_newest\.htm$ /viewtopic.php?t=$1&view=newest [L]
RewriteRule ^viewtopic_([0-9]+)_previous\.htm$ /viewtopic.php?t=$1&view=previous [L]
RewriteRule ^viewtopic_([0-9]+)_next\.htm$ /viewtopic.php?t=$1&view=next [L]
RewriteRule ^viewtopic_([0-9]+)\.htm$ /viewtopic.php?t=$1 [L]
RewriteRule ^viewprofile_([0-9]+)\.htm$ /profile.php?mode=viewprofile&u=$1 [L]
RewriteRule ^viewmessage_([0-9]+)\.htm$ /viewtopic.php?p=$1 [L]

Où se situe le problème? J'ai mis ce code dans le répertoire du forum, mais ça n'a pas marché.

Merci de m'éclairer!
 

mahefarivony

WRInaute accro
en mettant un truc dans ce genre

Code:
RewriteRule ^viewtopic_([0-9]+)_([0-9]+)\.htm$ /viewtopic.php?t=$1&start=$2 [L]

il ira chercher viewtopic.php a la racine de ton site et comme tu es dans un sous repertoire, il ne trouvera pas, forcement..

Code:
RewriteRule ^viewtopic_([0-9]+)_([0-9]+)\.htm$ /forums/viewtopic.php?t=$1&start=$2 [L]
peut etre ?
 

St3phane

Nouveau WRInaute
mahefarivony a dit:
Code:
RewriteRule ^viewtopic_([0-9]+)_([0-9]+)\.htm$ /forums/viewtopic.php?t=$1&start=$2 [L]
peut etre ?

J'ai testé avec cette modif mais sans succès. L'hébergeur m'assure que le mod_rewrite est activé! :?
 

marck5

WRInaute discret
Bon ben ça marche maintenant avec ce code :

RewriteEngine On
RewriteRule ^forums.* /forum/index.php
RewriteRule ^forum([0-9]*).* /forum/viewforum.php?f=$1&mark=topic
RewriteRule ^viewforum([0-9]*)-([0-9]*)-([0-9]*).* /forum/viewforum.php?f=$1&topicdays=$2&start=$3
RewriteRule ^forum([0-9]*).* /forum/viewforum.php?f=$1
RewriteRule ^ptopic([0-9]*).* /forum/viewtopic.php?t=$1&view=previous
RewriteRule ^ntopic([0-9]*).* /forum/viewtopic.php?t=$1&view=next
RewriteRule ^ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* /forum/viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4
RewriteRule ^ftopic([0-9]*)-([0-9]*).* /forum/viewtopic.php?t=$1&start=$2
RewriteRule ^ftopic([0-9]*).* /forum/viewtopic.php?t=$1
RewriteRule ^ftopic([0-9]*).html /forum/viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5
RewriteRule ^sutra([0-9]*).* /forum/viewtopic.php?p=$1
 

moutyk

WRInaute impliqué
Google me référence que les pages avec sessions

Bonjour,

J'ai un petit probleme avec un des mes forums

Voila j'ai mis en place L UR expliquée précedement j'ai tout fait comme il fallait je pense en tout cas tout fontionne parfaitement

probleme google me référence les pages avec les SID ?

par exemple : /Forum/ftopic5582.html&highlight=&sid=8b8e8e73e0b60621784b81c654e97572 20:15:33 1 64.68.92.178 crawl5.googlebot.com
idem pour les viewforum_9.html
J'en ai deja une dizaine de crawlée comme cela

Ca me fait un peu chier la parceque je vais avoir un paquet de page identique

j'ai apporté les modifs dans le fichier sessions.php pourtant

est ce que que quelqu'un aurait un exemple de fichier sessions.php modifié et qui ne pose pas de probleme avec les SID ou une explication a ca
afin que je modifie au plus vite pour google

Merci de votre aide
 

sdamain

WRInaute passionné
J'ai suivi la procédure, tout est ok.... sauf que lorsque je veux accéder à la console admoin - Administration des Forums - Gestion, je reçois ce message d'erreur : "No input file specified"

Quelqu'un a t'il déjà eu ce problème?
 

spacejoe

Nouveau WRInaute
Bonjour à tous .
j'avoue que j ai ete surpris quand j'ai lu sur votre forum que l'url rewriting est la solution pour l'optimisation d'un forum pour son referencement .

c'est vrai c'est une sollution parmis d'autres ... mais elle reste la plus compliquée, et la moins efficace.

la sollution la plus facile est de zapper les SID de votre url, voici c ki fo faire :
Code:
# 
#-----[ OUVRIR ]------------------------------------------ 
#  
includes/sessions.php 

# 
#-----[ Trouver ]----- 
# 
$SID = 'sid=' . $session_id; 

# 
#-----[ Remplacer par ]-
# 
if ( $userdata['session_user_id'] != ANONYMOUS ){ 
   $SID = 'sid=' . $session_id; 
} else { 
   $SID = ''; 
}

cette solution precedente reste la plus pratique , si , dans votre forum seuls les membres inscrits peuvent publier des posts.

je l ai recement testé sur mon forum, et ca a l'air de plutot bien marcher .

donc heuuu pour eviter tout hors sujet, voici la solution url-rewriting complete :
Code:
Requirements: you need mod_rewrite enabled as well as ability to use .htaccess or modify apache config files. 

Implementation: 

Step 1. In /includes/page_header.php before 

Code: 

// 
// Generate logged in/logged out status 
// 


add this code (make sure there are no space breaks at line ends after you paste): 

Code: 
ob_start(); 
function replace_for_mod_rewrite(&$s) 
{ 
$urlin = 
array( 
"'(?<!/)viewforum.php\?f=([0-9]*)&topicdays=([0-9]*)&start=([0-9]*)'", 
"'(?<!/)viewforum.php\?f=([0-9]*)&mark=topics'", 
"'(?<!/)viewforum.php\?f=([0-9]*)'", 
"'(?<!/)viewtopic.php\?t=([0-9]*)&view=previous'", 
"'(?<!/)viewtopic.php\?t=([0-9]*)&view=next'", 
"'(?<!/)viewtopic.php\?t=([0-9]*)&postdays=([0-9]*)&postorder=([a-zA-Z]*)&start=([0-9]*)'", 
"'(?<!/)viewtopic.php\?t=([0-9]*)&start=([0-9]*)&postdays=([0-9]*)&postorder=([a-zA-Z]*)&highlight=([a-zA-Z0-9]*)'", 
"'(?<!/)viewtopic.php\?t=([0-9]*)&start=([0-9]*)'", 
"'(?<!/)viewtopic.php\?t=([0-9]*)'", 
"'(?<!/)viewtopic.php&p=([0-9]*)'", 
"'(?<!/)viewtopic.php\?p=([0-9]*)'", 
); 
$urlout = array( 
"viewforum\\1-\\2-\\3.html", 
"forum\\1.html", 
"forum\\1.html", 
"ptopic\\1.html", 
"ntopic\\1.html", 
"ftopic\\1-\\2-\\3-\\4.html", 
"ftopic\\1.html", 
"ftopic\\1-\\2.html", 
"ftopic\\1.html", 
"sutra\\1.html", 
"sutra\\1.html", 
); 
$s = preg_replace($urlin, $urlout, $s); 
return $s; 
} 


Step 2. In /includes/page_tail.php after 

Code: 
$db->sql_close(); 


add this: 

Code: 
$contents = ob_get_contents(); 
ob_end_clean(); 
echo replace_for_mod_rewrite($contents); 
global $dbg_starttime; 
  


in the same file after 

Code: 
ob_end_clean(); 


add this: 

Code: 
echo replace_for_mod_rewrite($contents); 
global $dbg_starttime; 


Step 3. In your .htaccess file (if you don't have one create it; should be located in you forum root directory) paste these lines: 

Code: 
RewriteEngine On 
RewriteRule ^forums.* index.php 
RewriteRule ^forum([0-9]*).* viewforum.php?f=$1&mark=topic 
RewriteRule ^viewforum([0-9]*)-([0-9]*)-([0-9]*).* viewforum.php?f=$1&topicdays=$2&start=$3 
RewriteRule ^forum([0-9]*).* viewforum.php?f=$1 
RewriteRule ^ptopic([0-9]*).* viewtopic.php?t=$1&view=previous 
RewriteRule ^ntopic([0-9]*).* viewtopic.php?t=$1&view=next 
RewriteRule ^ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4 
RewriteRule ^ftopic([0-9]*)-([0-9]*).* viewtopic.php?t=$1&start=$2 
RewriteRule ^ftopic([0-9]*).* viewtopic.php?t=$1 
RewriteRule ^ftopic([0-9]*).html viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5 
RewriteRule ^sutra([0-9]*).* viewtopic.php?p=$1 


Note: sometimes this .htaccess code won't work properly if the forum is on a subdomain (was the case with me), you may need to try this variation: 

Code: 
RewriteEngine On 
RewriteRule ^forums.* /index.php 
RewriteRule ^forum([0-9]*).* /viewforum.php?f=$1&mark=topic 
RewriteRule ^viewforum([0-9]*)-([0-9]*)-([0-9]*).* /viewforum.php?f=$1&topicdays=$2&start=$3 
RewriteRule ^forum([0-9]*).* /viewforum.php?f=$1 
RewriteRule ^ptopic([0-9]*).* /viewtopic.php?t=$1&view=previous 
RewriteRule ^ntopic([0-9]*).* /viewtopic.php?t=$1&view=next 
RewriteRule ^ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* /viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4 
RewriteRule ^ftopic([0-9]*)-([0-9]*).* /viewtopic.php?t=$1&start=$2 
RewriteRule ^ftopic([0-9]*).* /viewtopic.php?t=$1 
RewriteRule ^ftopic([0-9]*).html /viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5 
RewriteRule ^sutra([0-9]*).* /viewtopic.php?p=$1 


Step 4. Very important! In your robots.txt file (goes at the *site* root) add these lines: 

Code: 
Disallow: /your-forum-folder/sutra*.html$ 
Disallow: /your-forum-folder/ptopic*.html$ 
Disallow: /your-forum-folder/ntopic*.html$ 
Disallow: /your-forum-folder/ftopic*asc*.html$ 


(This is required to avoid feeding duplicate content to Google) 




#-----[ OPEN  ]------------------------------------------ 
includes/sessions.php 

#-----[ FIND ]------------------------------------------ 
   global $SID; 

if ( !empty($SID) && !preg_match('#sid=#', $url) ) 

#-----[ REPLACE WITH ]------------------------------------------ 
   global $SID, $HTTP_SERVER_VARS; 

   if ( !empty($SID) && !preg_match('sid=', $url) && !strstr($HTTP_SERVER_VARS['HTTP_USER_AGENT'] ,'Googlebot') && !strstr($HTTP_SERVER_VARS['HTTP_USER_AGENT'] ,'slurp@inktomi.com')) 

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM


ce dernier code a ete trouvé dans le forum officiel de phpbb ... mais aparement ca genere pas mal de bugs ... :\ (je parle pour moi)

----
----

Aussi, mis à part le SID, y a un autre truc qui bloque google , c est le fait d'avoir plus de 100 liens dans la page d accueil du forum, google n aime pas ca :\
 

WebRankInfo

Olivier Duffez (admin)
Membre du personnel
c'est vrai que sans les SID, Google viendra plus facilement. Mais il ne viendra pas indexer toutes les pages, par exemple celles qui y 3 variables ou plus dans l'URL.
ensuite d'autres moteurs n'indexeront pas ou pas bien les pages avec des variables dans l'URL. C'est le cas d'un petit nouveau dont on reparlera...
 

Twister

WRInaute occasionnel
Si cela peut vous aider, voici un code que j'utilise sur phpBB 2.0.8 pour faciliter les passages des robots. Je n'ai pas encore trouvé de bug. Si vous en trouvez, dites le moi.
Ce code réécrit les url des pages à lire et empêche les sid quand le visiteur est un robot. Je me suis inspiré de quelques codes donnés dans ce forum.

Dans le fichier sessions.php ( dans le dossier include ), remplacez
Code:
function append_sid($url, $non_html_amp = false)
{
	global $SID;

	if ( !empty($SID) && !preg_match('#sid=#', $url)  )
	{ 
		$url .= ( ( strpos($url, '?') != false ) ?  ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
	}

	return $url;
}
par
Code:
function append_sid($url, $non_html_amp = false)   //fonction modifiée pour l'url-rewriting
{
   global $SID;

   if ( !empty($SID) && !preg_match('#sid=#', $url)  )
   {
      $url .= ( ( strpos($url, '?') != false ) ?  ( ( $non_html_amp ) ? '&' : '&' ) : '?' ) . $SID;
   }

   if ( REFERENCEMENT_BOOST )
   {
      $url = url_rewrite( $url );
   }

   return $url;
}

//Fonction qui vérifie si le visiteur est un robot comme google
function est_robot() {
   global $HTTP_SERVER_VARS;
   $RobotsList = array (
      "antibot",
      "appie",
      "architext",
      "bjaaland",
      "digout4u",
      "echo",
      "fast-webcrawler",
      "ferret",
      "googlebot",
      "gulliver",
      "harvest",
      "htdig",
      "ia_archiver",
      "jeeves",
      "jennybot",
      "linkwalker",
      "lycos",
      "mercator",
      "moget",
      "muscatferret",
      "myweb",
      "netcraft",
      "nomad",
      "petersnews",
      "scooter",
      "slurp",
      "unlost_web_crawler",
      "voila",
      "voyager",
      "webbase",
      "weblayers",
      "wget",
      "wisenutbot",
      "acme.spider",
      "ahoythehomepagefinder",
      "alkaline",
      "arachnophilia",
      "aretha",
      "ariadne",
      "arks",
      "aspider",
      "atn.txt",
      "atomz",
      "auresys",
      "backrub",
      "bigbrother",
      "blackwidow",
      "blindekuh",
      "bloodhound",
      "brightnet",
      "bspider",
      "cactvschemistryspider",
      "cassandra",
      "cgireader",
      "checkbot",
      "churl",
      "cmc",
      "collective",
      "combine",
      "conceptbot",
      "coolbot",
      "core",
      "cosmos",
      "cruiser",
      "cusco",
      "cyberspyder",
      "deweb",
      "dienstspider",
      "digger",
      "diibot",
      "directhit",
      "dnabot",
      "download_express",
      "dragonbot",
      "dwcp",
      "e-collector",
      "ebiness",
      "eit",
      "elfinbot",
      "emacs",
      "emcspider",
      "esther",
      "evliyacelebi",
      "nzexplorer",
      "fdse",
      "felix",
      "fetchrover",
      "fido",
      "finnish",
      "fireball",
      "fouineur",
      "francoroute",
      "freecrawl",
      "funnelweb",
      "gama",
      "gazz",
      "gcreep",
      "getbot",
      "geturl",
      "golem",
      "grapnel",
      "griffon",
      "gromit",
      "hambot",
      "havindex",
      "hometown",
      "htmlgobble",
      "hyperdecontextualizer",
      "iajabot",
      "ibm",
      "iconoclast",
      "ilse",
      "imagelock",
      "incywincy",
      "informant",
      "infoseek",
      "infoseeksidewinder",
      "infospider",
      "inspectorwww",
      "intelliagent",
      "irobot",
      "iron33",
      "israelisearch",
      "javabee",
      "jbot",
      "jcrawler",
      "jobo",
      "jobot",
      "joebot",
      "jubii",
      "jumpstation",
      "katipo",
      "kdd",
      "kilroy",
      "ko_yappo_robot",
      "labelgrabber.txt",
      "larbin",
      "legs",
      "linkidator",
      "linkscan",
      "lockon",
      "logo_gif",
      "macworm",
      "magpie",
      "marvin",
      "mattie",
      "mediafox",
      "merzscope",
      "meshexplorer",
      "mindcrawler",
      "momspider",
      "monster",
      "motor",
      "mwdsearch",
      "netcarta",
      "netmechanic",
      "netscoop",
      "newscan-online",
      "nhse",
      "northstar",
      "occam",
      "octopus",
      "openfind",
      "orb_search",
      "packrat",
      "pageboy",
      "parasite",
      "patric",
      "pegasus",
      "perignator",
      "perlcrawler",
      "phantom",
      "piltdownman",
      "pimptrain",
      "pioneer",
      "pitkow",
      "pjspider",
      "pka",
      "plumtreewebaccessor",
      "poppi",
      "portalb",
      "puu",
      "python",
      "raven",
      "rbse",
      "resumerobot",
      "rhcs",
      "roadrunner",
      "robbie",
      "robi",
      "robofox",
      "robozilla",
      "roverbot",
      "rules",
      "safetynetrobot",
      "search_au",
      "searchprocess",
      "senrigan",
      "sgscout",
      "shaggy",
      "shaihulud",
      "sift",
      "simbot",
      "site-valet",
      "sitegrabber",
      "sitetech",
      "slcrawler",
      "smartspider",
      "snooper",
      "solbot",
      "spanner",
      "speedy",
      "spider_monkey",
      "spiderbot",
      "spiderline",
      "spiderman",
      "spiderview",
      "spry",
      "ssearcher",
      "suke",
      "suntek",
      "sven",
      "tach_bw",
      "tarantula",
      "tarspider",
      "techbot",
      "templeton",
      "teoma_agent1",
      "titin",
      "titan",
      "tkwww",
      "tlspider",
      "ucsd",
      "udmsearch",
      "urlck",
      "valkyrie",
      "victoria",
      "visionsearch",
      "vwbot",
      "w3index",
      "w3m2",
      "wallpaper",
      "wanderer",
      "wapspider",
      "webbandit",
      "webcatcher",
      "webcopy",
      "webfetcher",
      "webfoot",
      "weblinker",
      "webmirror",
      "webmoose",
      "webquest",
      "webreader",
      "webreaper",
      "websnarf",
      "webspider",
      "webvac",
      "webwalk",
      "webwalker",
      "webwatch",
      "whatuseek",
      "whowhere",
      "wired-digital",
      "wmir",
      "wolp",
      "wombat",
      "worm",
      "wwwc",
      "wz101",
      "xget",
      "awbot",
      "bobby",
      "boris",
      "bumblebee",
      "cscrawler",
      "daviesbot",
      "ezresult",
      "gigabot",
      "gnodspider",
      "internetseer",
      "justview",
      "linkbot",
      "linkchecker",
      "nederland.zoek",
      "perman",
      "pompos",
      "psbot",
      "redalert",
      "shoutcast",
      "slysearch",
      "ultraseek",
      "webcompass",
      "yandex",
      "robot",
      "crawl"
   );
   $botID = strtolower( $HTTP_SERVER_VARS['HTTP_USER_AGENT'] );
   for ($i = 0; $i < count( $RobotsList ); $i++)
   {
      if ( strstr( $botID, $RobotsList[$i] ) )
      {
      return true;
      }
   }
   return false;
}

//fonction qui réécrit l'url des pages de lecture
function url_rewrite($url){

	$inf_url = parse_url( html_entity_decode( $url ) );
	$get_url = array();
	parse_str( $inf_url['query'], $get_url );

   //index.php
   if ( substr_count( $inf_url['path'], "index" ) == 1 ){
      //les catégories
      if ( count( $get_url ) == 1 && isset( $get_url['c'] )){
         return 'categorie-'.$get_url['c'].'.html';
      }
   }

   //viewforum.php
   if ( substr_count( $inf_url['path'], "viewforum" ) == 1 ){
      //le numéro du forum seul
      if ( count( $get_url ) == 1 && isset( $get_url['f'] )){
         return 'forum-'.$get_url['f'].'.html';
      }
      //f, topicdays et start
      if ( count( $get_url ) == 3 && isset( $get_url['f'] ) && isset( $get_url['topicdays'] ) && isset( $get_url['start'] ) ){
         return 'forum-'.$get_url['f'].'-'.$get_url['topicdays'].'-'.$get_url['start'].'.html';
      }
   }

   //viewtopic.php
   if ( substr_count( $inf_url['path'], "viewtopic" ) == 1 ){
      //le numéro du sujet seul
      if ( count( $get_url ) == 1 && isset( $get_url['t'] )){
         return 'sujet-'.$get_url['t'].'.html';
      }
      //le numéro du sujet seul avec p
      if ( count( $get_url ) == 1 && isset( $get_url['p'] )){
         return 'vsujet-'.$get_url['p'].'.html';
      }
      //le numéro du sujet avec p et highlight
      if ( count( $get_url ) == 2 && isset( $get_url['p'] ) && isset( $get_url['highlight'] )  ){
         return 'vsujet-'.$get_url['p'].'('.urlencode($get_url['highlight']).').html';
      }
      //sujet précédent ou suivant
      if ( count( $get_url ) == 2 && isset( $get_url['t'] ) && isset( $get_url['view'] ) ){
         if ( $get_url['view'] == 'previous' ){
            return 'prec-sujet-'.$get_url['t'].'.html';
         }elseif ( $get_url['view'] == 'next' ){
            return 'suiv-sujet-'.$get_url['t'].'.html';
         }
      }
      //le numéro du sujet et highlight
      if ( count( $get_url ) == 2 && isset( $get_url['t'] ) && isset( $get_url['highlight'] )  ){
         return 'sujet-'.$get_url['t'].'('.urlencode($get_url['highlight']).').html';
      }
      //le numéro du sujet et start
      if ( count( $get_url ) == 2 && isset( $get_url['t'] ) && isset( $get_url['start'] )  ){
         return 'sujet-'.$get_url['t'].'-'.$get_url['start'].'.html';
      }
      //le numéro du sujet et postdays et postorder et start
      if ( count( $get_url ) == 4 && isset( $get_url['t'] ) && isset( $get_url['start'] ) && isset( $get_url['postdays'] ) && isset( $get_url['postorder'] )  ){
         return 'sujet-'.$get_url['t'].'-'.$get_url['start'].'-'.$get_url['postdays'].'-'.$get_url['postorder'].'.html';
      }
      //le numéro du sujet et postdays et postorder et start et highlight
      if ( count( $get_url ) == 5 && isset( $get_url['t'] ) && isset( $get_url['start'] ) && isset( $get_url['postdays'] ) && isset( $get_url['postorder'] ) && isset( $get_url['highlight'] )  ){
         return 'sujet-'.$get_url['t'].'-'.$get_url['start'].'-'.$get_url['postdays'].'-'.$get_url['postorder'].'('.urlencode($get_url['highlight']).').html';
      }

   }
   
   //profile.php
   if ( substr_count( $inf_url['path'], "profile" ) == 1 ){
		//mode=viewprofile et num du profil
		if ( count( $get_url ) == 2 && isset( $get_url['mode'] ) && $get_url['mode'] == "viewprofile" && isset( $get_url['u'] )  ){
		   return 'profil-'.$get_url['u'].'.html';
		}
	}

   return $url;
}

Dans ce même fichier, remplacez
Code:
$SID = 'sid=' . $session_id;
par
Code:
	if ( est_robot() && REFERENCEMENT_BOOST ){	//if ajouté pour supprimer les sessions pour les robots
		$SID = '';
	}else{
		$SID = 'sid=' . $session_id;
	}

Dans le fichier constants.php (dans le dossier includes ), avant
Code:
// Session parameters
define('SESSION_METHOD_COOKIE', 100);
define('SESSION_METHOD_GET', 101);
ajoutez
Code:
//amélioration du référencement : suppression des sessid pour les robots et url-rewriting
define('REFERENCEMENT_BOOST', true);

Si vous définissez la constante précédente à faux, c'est à dire si vous remplacez le code précédent par
Code:
//amélioration du référencement : suppression des sessid pour les robots et url-rewriting
define('REFERENCEMENT_BOOST',false);
votre forum se comportera comme si vous n'aviez rien modifié.

Dans le fichier .htaccess à la racine de votre forum, ajoutez ce code (créez ce fichier s'il n'existe pas)
Code:
RewriteEngine On

RewriteRule ^categorie\-([0-9]*)\.html$ index\.php\?c=$1 [L]

RewriteRule ^forum\-([0-9]*)\.html$ viewforum\.php\?f=$1 [L]

RewriteRule ^forum\-([0-9]*)\-([0-9]*)\-([0-9]*)\.html$ viewforum\.php\?f=$1&topicdays=$2&start=$3 [L]

RewriteRule ^sujet\-([0-9]*)\.html$ viewtopic\.php\?t=$1 [L]

RewriteRule ^sujet\-([0-9]*)\-([0-9]*)\.html$ viewtopic\.php\?t=$1&start=$2 [L]

RewriteRule ^sujet\-([0-9]*)\(([^()]*)\)\.html$ viewtopic\.php\?t=$1&highlight=$2 [L]

RewriteRule ^sujet\-([0-9]*)\-([0-9]*)\-([0-9]*)\-([a-zA-Z]*)\.html$ viewtopic\.php\?t=$1&start=$2&postdays=$3&postorder=$4 [L]

RewriteRule ^sujet\-([0-9]*)\-([0-9]*)\-([0-9]*)\-([a-zA-Z]*)\(([^()]*)\)\.html$ viewtopic\.php\?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5 [L]

RewriteRule ^vsujet\-([0-9]*)\.html$ viewtopic\.php\?p=$1 [L]

RewriteRule ^vsujet\-([0-9]*)\(([^()]*)\)\.html$ viewtopic\.php\?p=$1&highlight=$2 [L]

RewriteRule ^prec\-sujet\-([0-9]*)\.html$ viewtopic\.php\?t=$1&view=previous [L]

RewriteRule ^suiv\-sujet\-([0-9]*)\.html$ viewtopic\.php\?t=$1&view=next [L]

RewriteRule ^profil\-([0-9]*)\.html$ profile\.php\?mode=viewprofile&u=$1 [L]

Il ne manque que le fichier robots.txt qui a déjà été décrit dans ce forum.

Ce code est un peu long, mais comme il n'utilise pas les expressions régulières, il ne devrait normalement pas modifier d'adresse qu'il ne faut pas modifier. 8)
 
C

calou

Guest
salut je débute dans ce domaine et je viens de faire toutes tes modifs mais quand je me connecte voila le message qui apparait :

You don't have permission to access /mycotdaz/admin/index.php on this server.

à préciser que j'utilise phpbb2.0.8a + ezportal avec .htaccess à la racine qui contient :

DirectoryIndex index.html index.htm portal.php index.php ( comme c'est indiqué sur le mod ezportal )

donc si j ajoutes ce que tu dis dans mon .htaccess , j' ai un message d'erreur et bien sur si je garde la ligne de départ , ca fonctionne , enfin je peux accéder au site !!

donc ??
 

mindsurfer

Nouveau WRInaute
Bonjour à toutes et tous! ;)

bon... je suis un peu perdu la... serait-ce due à la quantité de message sur ce topic?? :p

donc voilà j'ai un seul souhait : qu'une bonne âme veuille bien poster ici un message reprennant les différentes modifications/créations de fichiers à opérer pour avoir des url réécrites et un site facilement visitable par les robots, et ce pour un site en phpBB v.2.0.8 (dernière version en date).

un grand MERCI à celles et ceux qui prendront le temps de s'y atteler! :D
 

T-Tus

Nouveau WRInaute
Hello,

moi j'ai juste un bleme au niveau du .htaccess ...

Voila tout fonctionne mais quand je met l'url avec un &sub

ex : viewforum.php?id=1&sub=test

ben il me le remplace automatiquement par : ,"

quelqu'un aurrait une idée SVP ?
 

tahngarth

Nouveau WRInaute
j'ai un ptit probleme avec mon forum :)

le rewriting fonctionne :) mais ya un chtit bug :oops:

Lors de la connection ou deconnection on tombe sur une page blanche :evil:

Qqun peut m'aider ?
 

Polux

Nouveau WRInaute
Bonjour,

Quelq'un sait où est passé l'article qui traîte de ce sujet sur le site? 8O Avec le code à appliquer en FR, etc. Je l'ai lu au matin et maintenant plus rien...

Polux

*A L'AIDE*
add_icon_cry.gif
 

sebseb

Nouveau WRInaute
Bonjour,

Je viens de tester l'url rewriting pour mon forum.
J'ai donc utilisé ce très bon article : https://www.webrankinfo.com/dossiers/webmastering mais j'ai juste qq réflexions pour aider ceux qui pourraient rencontrer les mêmes problèmes (vite réglés) que j'ai eu.

D'abord au début du htaccess ne pas oublier de lancer le module de réécriture :

Code:
RewriteEngine On

Bien sûr, ne pas oublier de bien agencer (comme c'est dit) le fichier htacces.

Pour tout passer en html, modifier le code du tableau $urlout .

Par contre, mon forum est dans le dossier forum (ce qui peut arriver à d'autres), j'ai donc réécrit la ligne du htaccess.
Le problème du coup venait de la page forum1.html par exemple qui du coup retournait à la page d'index du forum.

La solution, renommer la page forumx.html par voirforum.html dans le fichier htacces et dans le tabkeau $urlout et c'est ok.

Voila ça pourra peut être dépanner certains.
Pour voir le résultat : www.dakardantan.com

@+
Seb
 

AmarokProg

Nouveau WRInaute
Je viens d'essayer le code signalé en page 1 de ce topic mais lorsque je veux consulter le forum, le résultat est :

The requested URL /amarokpr/phpBB2/forum8.html was not found on this server.

par exemple..... :cry:
 

AmarokProg

Nouveau WRInaute
Je viens d'essayer le code signalé en page 1 de ce topic mais lorsque je veux consulter le forum, le résultat est :

The requested URL /phpBB2/forum8.html was not found on this server.

par exemple..... :cry:
 

AmarokProg

Nouveau WRInaute
tout en haut du .htaccess oui

RewriteEngine on
Options +FollowSymlinks
RewriteRule ^forums.* index.php
RewriteRule ^forum([0-9]*).* viewforum.php?f=$1&mark=topic
RewriteRule ^viewforum([0-9]*)-([0-9]*)-([0-9]*).* viewforum.php?f=$1&topicdays=$2&start=$3
RewriteRule ^forum([0-9]*).* viewforum.php?f=$1
RewriteRule ^ptopic([0-9]*).* viewtopic.php?t=$1&view=previous
RewriteRule ^ntopic([0-9]*).* viewtopic.php?t=$1&view=next
RewriteRule ^ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4
RewriteRule ^ftopic([0-9]*)-([0-9]*).* viewtopic.php?t=$1&start=$2
RewriteRule ^ftopic([0-9]*).* viewtopic.php?t=$1
RewriteRule ^ftopic([0-9]*).html viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5
RewriteRule ^sutra([0-9]*).* viewtopic.php?p=$1
 

AmarokProg

Nouveau WRInaute
comme je te l'ai dit, je suis actuellement en local (sur mon DD) et je me demande si cela fonctionne en local (pour tester) ????
Sinon je suis chez OVH et normalement ça tourne il me semble...
 

Ohax

WRInaute accro
non je parle de la configuration de apache


tu fait tourner en local avec easyphp ou bien tu as installé tous les serveurs manuellement un par un?
 

AmarokProg

Nouveau WRInaute
je suis avec easyphp...

autre chose... j'ai édité le .htaccess avec notepad ce qui donne .htaccess.txt

cela peut-il créer un pb ?
 

Ohax

WRInaute accro
:lol:

fait le directement sur ton site ça prend 5 minutes car si je commence à tous expliquer il va y en avoir pour des heures et je suis pas sur que tu comprenne tout sur l'url rewriting


sauvegarde ton ftp et fai les modifications croi moi ça ne risque rien mi à par de mettre ton forum hs 2 minutes le temps du transfer des fichiers rien de plus ;-)
 

AmarokProg

Nouveau WRInaute
Je viens de faire les modifs et ça ne fonctionne plus... comme en local...

je ne sais pas si l'extension de .htaccess.txt pose problème...

je ne vois pas d'où vient le pb non plus...
 

AmarokProg

Nouveau WRInaute
je verrai ce soir car au boulot, je n'ai pas de client ftp...

tu pourras m'expliquer l'url rewriting que je pige dans les largeurs mais ne pouvant me connecter longuement du boulot, je ne peux que survoler les questions/réponses...

A +
 

Discussions similaires

Haut