Fork me on GitHub




« 1 2 3 (4) 5 »


Re: simplified url avec le titre dans l'url
Aspirant
Inscrit: 29/03/2007 21:03
Messages: 93
C'est vrai que la reqète ce n'est pas top, mais ça peut déjà permettre de voir si la réécriture fonctionne : le mieux étant d'utiliser les classes du module news.

pour l'include, tu ne crois pas qu'il vaudrait mieux mettre le chemin absolu pour être sûr qu'il touve bien le fichier?
include [b]XOOPS_ROOT_PATH."/[/b]modules/news/class/class.newsstory.php";


et rajouter (pour être sûr de ne rien oublier ) :
include_once XOOPS_ROOT_PATH."/modules/news/class/class.newsstory.php";
include_once 
XOOPS_ROOT_PATH.'/modules/news/class/class.sfiles.php';
include_once 
XOOPS_ROOT_PATH.'/modules/news/include/functions.php';
include_once 
XOOPS_ROOT_PATH."/modules/news/class/class.newstopic.php";
include_once 
XOOPS_ROOT_PATH."/modules/news/class/keyhighlighter.class.php";

Posté le : 19/04/2007 11:41

Echange gratuit de bannières publicitaires

Open in new window

www.diadema.fr
Partager Twitter Partagez cette article sur GG+
Re: simplified url avec le titre dans l'url
Régulier
Inscrit: 07/03/2004 18:48
De Alger
Messages: 201
je te rassure j'ai essayer avec le chemin absolue c'est exactement la meme chose.

je viens d'essayer avec une requete sql; et bien plus de page blanche mais les url reste comme avant. comme si que j'ai rien toucher?

Posté le : 19/04/2007 12:06
Partager Twitter Partagez cette article sur GG+
Re: simplified url avec le titre dans l'url
Aspirant
Inscrit: 29/03/2007 21:03
Messages: 93

peux-tu poster ton code stp?

Posté le : 19/04/2007 12:34

Echange gratuit de bannières publicitaires

Open in new window

www.diadema.fr
Partager Twitter Partagez cette article sur GG+
Re: simplified url avec le titre dans l'url
Régulier
Inscrit: 07/03/2004 18:48
De Alger
Messages: 201
voici tous le code du fichier

<?php
// $Id: simplified_url.php,v 1.5 2005/07/02 17:15:00 suin Exp $
//  ------------------------------------------------------------------------ //
//              SIMPLIFIED URLs FOR XOOPS based on ShortURLs                 //
//              Copyright (c) 2004 suin and Reynaldo Alvarez                 //
//                         <http://www.suin.jp>  &nb ... nbsp;   //
//  ------------------------------------------------------------------------ //
//  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.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  ------------------------------------------------------------------------ //
// 
if (!defined("XOOPS_ROOT_PATH") || !defined("XOOPS_URL") ) {
    exit();
}
// ´Ê°×²½¤ò̵¸ú¤Ë¤¹¤ë¥â¥¸¥å¡¼¥ë
// "|"¤Ç¥â¥¸¥å¡¼¥ë¤Î¥Ç¥£¥ì¥¯¥È¥ê¤ò¶èÀڤ롣 If you do not want to simplify any module, divide the module's dir with "|".

$cancel_module "";
//$cancel_module = "xoopspoll|newbb|news";

if( !empty( $cancel_module ) && isset( $sd_res ) ){
    if( ( 
preg_match("//modules/(".$cancel_module.")//"$_SERVER['SCRIPT_NAME']) )){
        
header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
        exit();
    }
}
if(  ( !
preg_match("//modules/([^/]*)/admin//"$_SERVER['SCRIPT_NAME']) ) 
  && ( !
preg_match("//modules/system//"$_SERVER['SCRIPT_NAME']) )
  && ( !
preg_match("/admin.php/"$_SERVER['SCRIPT_NAME']) )  ) {
    
//ob_start('ob_gzhandler');
    //ob_start('absolutize');
    
ob_start('simplify_urls');
}else{
    if( isset( 
$sd_res ) ){
        
header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
        exit();
    }
}

function 
simplify_urls($s
{
    
$XPS_URL str_replace('/','/'quotemeta(XOOPS_URL) );
    
$s absolutize($s); 
    
// Fix URLs and HTML.    //if (strpos($s, "storyid")) {




//include_once XOOPS_ROOT_PATH."/modules/news/class/class.newsstory.php";
//include_once XOOPS_ROOT_PATH.'/modules/news/class/class.sfiles.php';
//include_once XOOPS_ROOT_PATH.'/modules/news/include/functions.php';
//include_once XOOPS_ROOT_PATH."/modules/news/class/class.newstopic.php";
//include_once XOOPS_ROOT_PATH."/modules/news/class/keyhighlighter.class.php";
//$newsStory = new NewsStory($storyid);
//$title=urlencode($newsStory->title);
//$s .= "&title=".urlencode($newsStory->title);

//}
preg_match('/(storyid=)(.*)(.*)/iUs',$s$recherche);
    
$storyid $recherche[2];    
$title null;
global 
$xoopsDB;
$sql "SELECT title FROM ".$xoopsDB->prefix("stories")." WHERE storyid = ".intval($storyid);
if (
$res $xoopsDB->query($sql)) {
   if (
$oRS mysql_fetch_object($res)) {
      
$title $oRS->title;
   }
}

if (
$title) {
$s str_replace("news-article.storyid-([a-zA-Z0-9_-]+).htm""article-$1-$title.htm"$s);
   
$s .= "&title=".urlencode($title);
}
    
$in = array(
        
// Search URLs of Xoops's root directry.
          
'/<(a|meta)([^>]*)(href|url)=(['"]{0,1})'.$XPS_URL.'/([a-zA-Z0-9_-]+).php(#?[a-zA-Z0-9]*)(['"]{1})([^>]*)>/i'
        , '
/<(a|meta)([^>]*)(href|url)=(['"]{0,1})'.$XPS_URL.'/([a-zA-Z0-9_-]+).php?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)(#?[a-zA-Z0-9]*)(['"]{1})([^>]*)>/i'
        , '/<(a|meta)([^>]*)(href|url)=(['"
]{0,1})'.$XPS_URL.'/([a-zA-Z0-9_-]+).php?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)(#?[a-zA-Z0-9]*)(['"]{1})([^>]*)>/i'
        // Search URLs of modules' directry.
                                                                  
        
'/<(a|meta)([^>]*)(href|url)=(['"]{0,1})'.$XPS_URL.'/modules/([a-zA-Z0-9_-]+)/(#?[a-zA-Z0-9]*)(['"]{1})([^>]*)>/i'
        , '
/<(a|meta)([^>]*)(href|url)=(['"]{0,1})'.$XPS_URL.'/modules/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+).php(#?[a-zA-Z0-9]*)(['"]{1})([^>]*)>/i'
           , '/<(a|meta)([^>]*)(href|url)=(['"
]{0,1})'.$XPS_URL.'/modules/news/article.php?storyid=([a-zA-Z0-9_-]*)&title=([a-zA-Z0-9_-]*)(#?[a-zA-Z0-9]*)(['"]{1})([^>]*)>/i'    

        
'/<(a|meta)([^>]*)(href|url)=(['"]{0,1})'.$XPS_URL.'/modules/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+).php?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)(#?[a-zA-Z0-9]*)(['"]{1})([^>]*)>/i'
            , '
/<(a|meta)([^>]*)(href|url)=(['"]{0,1})'.$XPS_URL.'/modules/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+).php?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)(#?[a-zA-Z0-9]*)(['"]{1})([^>]*)>/i'
        , '/<(a|meta)([^>]*)(href|url)=(['"
]{0,1})'.$XPS_URL.'/modules/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+).php?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)(#?[a-zA-Z0-9]*)(['"]{1})([^>]*)>/i'
        
'/<(a|meta)([^>]*)(href|url)=(['"]{0,1})'.$XPS_URL.'/modules/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+).php?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)(#?[a-zA-Z0-9]*)(['"]{1})([^>]*)>/i'
        , '
/<(a|meta)([^>]*)(href|url)=(['"]{0,1})'.$XPS_URL.'/modules/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+).php?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)(#?[a-zA-Z0-9]*)(['"]{1})([^>]*)>/i'
        , '/<(a|meta)([^>]*)(href|url)=(['"
]{0,1})'.$XPS_URL.'/modules/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+).php?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)&?(?:amp;)?([a-zA-Z0-9_-]+)=([a-zA-Z0-9_-]*)(#?[a-zA-Z0-9]*)(['"]{1})([^>]*)>/i'
    
);
    
    
$out = array(
        
// Replace URLs of Xoops's root directry.
          
'<$1$2$3=$4'.XOOPS_URL.'/$5.html$6$7$8>'
        
'<$1$2$3=$4'.XOOPS_URL.'/$5.$6-$7.html$8$9$10>'
        
'<$1$2$3=$4'.XOOPS_URL.'/$5.$6-$7-$8-$9.html$10$11$12>'
        
// Replace URLs of modules' directry.
        
'<$1$2$3=$4'.XOOPS_URL.'/$5-index.htm$6$7$8>'
        
'<$1$2$3=$4'.XOOPS_URL.'/$5-$6.htm$7$8$9>'
         
'<$1$2$3=$4'.XOOPS_URL.'/article-$5-$6.htm$7$8$9>'
        
'<$1$2$3=$4'.XOOPS_URL.'/$5-$6.$7-$8.htm$9$10$11>'
        
'<$1$2$3=$4'.XOOPS_URL.'/$5-$6.$7-$8-$9-$10.htm$11$12$13>'
        
'<$1$2$3=$4'.XOOPS_URL.'/$5-$6.$7-$8-$9-$10-$11-$12.htm$13$14$15>'
        
'<$1$2$3=$4'.XOOPS_URL.'/$5-$6.$7-$8-$9-$10-$11-$12-$13-$14.htm$15$16$17>'
        
'<$1$2$3=$4'.XOOPS_URL.'/$5-$6.$7-$8-$9-$10-$11-$12-$13-$14-$15-$16.htm$17$18$19>'
        
'<$1$2$3=$4'.XOOPS_URL.'/$5-$6.$7-$8-$9-$10-$11-$12-$13-$14-$15-$16-$17-$18.htm$19$20$21>'
    
);


    



    
$s preg_replace($in$out$s); 
//    $s = preg_replace('/<([^>]*)>/i','{\1}', $s);
//    $s = $s.'<!-- Simplified URLs Version 1.1 http://www.suin.jp/ -->';
    
return $s;    
}

function 
absolutize($s){
    if(
preg_match('//$/',$_SERVER['REQUEST_URI'])){
        
$req_dir=preg_replace('//$/','',$_SERVER['REQUEST_URI']);
        
$req_php="";
    }else{
        
$req_dir=dirname($_SERVER['REQUEST_URI']);
        
$req_php=preg_replace('/.*(/[a-zA-Z0-9_-]+).php.*/','\1.php',$_SERVER['REQUEST_URI']);
    }
    
$req_dir = ($req_dir == "\" || $req_dir == "/" ) ? "" $req_dir ;
    
$dir_arr=explode('/'$req_dir);
    
$m count($dir_arr)-1;
    
$d1 = @str_replace('/'.$dir_arr[$m],   ''$req_dir);
    
$d2 = @str_replace('/'.$dir_arr[$m-1], ''$d1);
    
$d3 = @str_replace('/'.$dir_arr[$m-2], ''$d2);
    
$d4 = @str_replace('/'.$dir_arr[$m-3], ''$d3);
    
$d5 = @str_replace('/'.$dir_arr[$m-4], ''$d4);
    
$host 'http://'.$_SERVER['HTTP_HOST'];
    
$in = array(
         
'/<([^>?&]*)(href|src|action|background|window.location)=([^"' >]+)([^>]*)>/i'
//off1        ,'
/<([^>?&]*)(href|src|action|background|window.location)=(["']{1})../../../../../([^"']*)(["']{1})([^>]*)>/i'
//off2        ,'
/<([^>?&]*)(href|src|action|background|window.location)=(["']{1})../../../../([^"']*)(["']{1})([^>]*)>/i'
        ,'
/<([^>?&]*)(href|src|action|background|window.location)=(["']{1})../../../([^"']*)(["']{1})([^>]*)>/i'
        ,'
/<([^>?&]*)(href|src|action|background|window.location)=(["']{1})../../([^"']*)(["']{1})([^>]*)>/i'
        ,'
/<([^>?&]*)(href|src|action|background|window.location)=(["']{1})../([^"']*)(["']{1})([^>]*)>/i'
        ,'
/<([^>?&]*)(href|src|action|background|window.location)=(["']{1})/([^"']*)(["']{1})([^>]*)>/i'
        ,'
/<([^>?&]*)(href|src|action|background|window.location)=(["']{1})?([^"']*)(["']{1})([^>]*)>/i'
        //This dir
        ,'
/<([^>?&]*)(href|src|action|background|window.location)=(["']{1})(?:./)?([^"'/:]*/*)?([^"'/:]*/*)?([^"'/:]*/*)?([a-zA-Z0-9_-]+).([^"'>]*)(["']{1})([^>]*)>/i'
        
,'/[^"'a-zA-Z_0-9](window.open|url)((["']{0,1})(?:./)?([^"'/]*).([^"'/]+)(["']*)([^)]*)/i'
        ,'/<meta([^>]*)url=([a-zA-Z0-9_-]+).([^"'>]*)(["'
]{1})([^>]*)>/i'
    );
    $out = array(
         '
<\1\2="\3"\4>'
//off1        ,'
<\1\2=\3'.$host.$d5.'/\4\5\6>'
//off2        ,'
<\1\2=\3'.$host.$d4.'/\4\5\6>'
        ,'
<\1\2=\3'.$host.$d3.'/\4\5\6>'
        ,'
<\1\2=\3'.$host.$d2.'/\4\5\6>'
        ,'
<\1\2=\3'.$host.$d1.'/\4\5\6>'
        ,'
<\1\2=\3'.$host.'/\4\5\6>'
        ,'
<\1\2=\3'.$host.$_SERVER['PHP_SELF'].'?\4\5\6>'
        //This dir.
        ,'
<\1\2=\3'.$host.$req_dir.'/\4\5\6\7.\8\9\10>'
        ,'
$1($2'.$host.$req_dir.'/$3.$4$5$6'
        ,'
<meta$1url='.$host.$req_dir.'/$2.$3$4$5>'
    );


    $s = preg_replace($in, $out, $s); 
//off3    z$s = preg_replace('
/<([^>]*)>/i','{\1}', $s);
    
    return $s;
}
?>

Posté le : 19/04/2007 13:27
Partager Twitter Partagez cette article sur GG+
Re: simplified url avec le titre dans l'url
Aspirant
Inscrit: 29/03/2007 21:03
Messages: 93
Es-tu sûr de ton expression régulière pour la récupération de $storyid?

Posté le : 19/04/2007 17:41

Echange gratuit de bannières publicitaires

Open in new window

www.diadema.fr
Partager Twitter Partagez cette article sur GG+
Re: simplified url avec le titre dans l'url
Régulier
Inscrit: 07/03/2004 18:48
De Alger
Messages: 201
d'aprés mes modestes connaisances en php je croix que c'est bon à ce niveau. je comrend pas rien ne se produit avec le script pas d'erreur et pas de resultat comme si qu'il ne s'execute pas??

Posté le : 19/04/2007 18:39
Partager Twitter Partagez cette article sur GG+
Re: simplified url avec le titre dans l'url
Aspirant
Inscrit: 29/03/2007 21:03
Messages: 93
C'est vraiment bizarre...
je vais essayer d'installer ça chez moi pour pouvoir mieux tester

Posté le : 20/04/2007 09:14

Echange gratuit de bannières publicitaires

Open in new window

www.diadema.fr
Partager Twitter Partagez cette article sur GG+
Re: simplified url avec le titre dans l'url
Régulier
Inscrit: 07/03/2004 18:48
De Alger
Messages: 201
bonjour
j'ai essayer cet partie du code pour recuperer le titre et ca marche nickel.

<?php
include "mainfile.php";
$title null;
$storyid='1954';
global 
$xoopsDB;
$sql "SELECT title FROM ".$xoopsDB->prefix("stories")." WHERE storyid = ".intval($storyid);
if (
$res $xoopsDB->query($sql)) {
 if (
$oRS mysql_fetch_object($res)) {
  
$title $oRS->title;
 }
}

if (
$title) {
 
$titleurlencode($title);
 echo 
$title;

 }
?>


donc ca doit bugger ailleur faut chercher du coté de la récupération de storyid ou bien de l'injection du titre dans l'url;
en tous cas moi je ne c vraiment pas ce qui cloche dans ce script

Posté le : 20/04/2007 11:09
Partager Twitter Partagez cette article sur GG+
Re: simplified url avec le titre dans l'url
Aspirant
Inscrit: 29/03/2007 21:03
Messages: 93
Si tu stockes en dûr l'URL non-réécrite et que tu la passes par le preg_match, tu obtiens le bon storyid?

Posté le : 20/04/2007 11:36

Echange gratuit de bannières publicitaires

Open in new window

www.diadema.fr
Partager Twitter Partagez cette article sur GG+
Re: simplified url avec le titre dans l'url
Régulier
Inscrit: 07/03/2004 18:48
De Alger
Messages: 201
i will check shortly.

Posté le : 20/04/2007 11:45
Partager Twitter Partagez cette article sur GG+

 Haut   Précédent   Suivant
« 1 2 3 (4) 5 »



Vous pouvez voir les sujets.
Vous ne pouvez pas débuter de nouveaux sujets.
Vous ne pouvez pas répondre aux contributions.
Vous ne pouvez pas éditer vos contributions.
Vous ne pouvez pas effacez vos contributions.
Vous ne pouvez pas ajouter de nouveaux sondages.
Vous ne pouvez pas voter en sondage.
Vous ne pouvez pas attacher des fichiers à vos contributions.
Vous ne pouvez pas poster sans approbation.

Propulsé avec XOOPS | Graphisme adapté par Tatane, Grosdunord, Montuy337513

99 Personne(s) en ligne (97 Personne(s) connectée(s) sur Forum) | Utilisateur(s): 0 | Invité(s): 99 | Plus ...