Pretty URLs

Started by SMFHacks.com Team, January 31, 2007, 10:56:43 AM

Previous topic - Next topic

Jue

Cheers! Worked. :) Is there going to be a fix into this or is it not possible?

vbgamer45

There are a bunch of them that I don't want to rewrite such as stats and admin which also can cause issues
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

KensonPlays

Dream Portal .htaccess code? They use ?page=pagename (I think TinyPortal uses that format too, would TinyPortal .htaccess for page work for DP?)

Yes, I searched this topic for "portal" and all i saw was SimplePortal, TinyPortal, and "MKPortal"

Owner of Mesozoic Haven

cellax

#5843
is it possible to have pretty urls for tinyportal download items?

using smf 1.1.12

nice mod thx

EDIT: I wrote my own, I will post it tomorrow
EDIT2: here the code change to Download system, it is supposed that if you have Tinyportal download you dont have other download system.
On Install.php
Code (Find) Select
        "description" => "Download System filter for downloads",
        "enabled"  => 0,
        "filter"  => array(
            "priority"  => 32,
            "callback"  => "pretty_downloadssystem_filter"
        ),
        "rewrite"  => array(
            "priority"  => 32,
            "rule"  => array(
            "RewriteRule ^downloads/([^/]+)/([^/]+)/([0-9]*)/?$ ./index.php?action=downloads;sa=view;down=$3 [L,QSA]",
        ),
         ),
      "title"  => 'Download System Pretty Filter <a href="http://www.smfhacks.com/download-system-pro.php" target="_blank">Website</a>'
);

Code (Replace with) Select
        "description" => "Download item TinyPortal 1.0 RC1",
        "enabled"  => 0,
        "filter"  => array(
            "priority"  => 32,
            "callback"  => "pretty_downloadssystem_filter"
        ),
        "rewrite"  => array(
            "priority"  => 32,
            "rule"  => array(
            "RewriteRule ^downloads/([^/]+)/([^/]+)/([0-9]*)/?$ ./index.php?action=tpmod;dl=item$3 [L,QSA]",
        ),
         ),
      "title"  => 'Tiny Portal Download TP 1.0 RC1'
);


then open Sources-SMF1-1.xml

Code (Find) Select
// Filter Download System
function pretty_downloadssystem_filter($urls)
{
global $scripturl, $boardurl, $db_prefix;

// Do Download System Replacement
$pattern = '`' . $scripturl . '(.*)action=downloads;sa=view;down=([0-9]+)`S';
$query_data = array();
foreach ($urls as $url_id => $url)
{
// Get the data ready to query the database with
if (!isset($url['replacement']))
if (preg_match($pattern, $url['url'], $matches))
{
$urls[$url_id]['ID_FILE'] = (int) $matches[2];
$urls[$url_id]['match1'] = $matches[1];
$query_data[] = $urls[$url_id]['ID_FILE'];
}
}

if (count($query_data) != 0)
{

// Get the Download info
$fileIDs = array();
$filesNames = array();
$catNames = array();
$query = db_query("
SELECT
c.title as CatTitle, f.title, f.ID_FILE, c.ID_CAT
FROM {$db_prefix}down_cat as c, {$db_prefix}down_file as f
WHERE c.ID_CAT = f.ID_CAT AND f.ID_FILE IN (" . implode(', ', $query_data) . ")", __FILE__, __LINE__);

while ($filedata = mysql_fetch_assoc($query))
{
$fileIDs[$filedata['ID_FILE']] = $filedata['ID_FILE'];
$filesNames[$filedata['ID_FILE']] = rawurlencode(pretty_seo_url($filedata['title']));
$catNames[$filedata['ID_FILE']] = rawurlencode(pretty_seo_url($filedata['CatTitle']));
}


Code (Replace with) Select
// Download TinyPortal 1.0 RC1
function pretty_downloadssystem_filter($urls)
{
global $scripturl, $boardurl, $db_prefix;

// Do Download System Replacement
$pattern = '`' . $scripturl . '(.*)action=tpmod;dl=item([0-9]+)`S';
$query_data = array();
foreach ($urls as $url_id => $url)
{
// Get the data ready to query the database with
if (!isset($url['replacement']))
if (preg_match($pattern, $url['url'], $matches))
{
$urls[$url_id]['ID_FILE'] = (int) $matches[2];
$urls[$url_id]['match1'] = $matches[1];
$query_data[] = $urls[$url_id]['ID_FILE'];
}
}

if (count($query_data) != 0)
{

// Get the Download info
$fileIDs = array();
$filesNames = array();
$catNames = array();
$query = db_query("
SELECT
category, name, id
FROM {$db_prefix}tp_dlmanager
WHERE id IN (" . implode(', ', $query_data) . ")", __FILE__, __LINE__);

while ($filedata = mysql_fetch_assoc($query))
{
$fileIDs[$filedata['id']] = $filedata['id'];
$filesNames[$filedata['id']] = rawurlencode(pretty_seo_url($filedata['name']));

   $category_sub = abs($filedata['category']);
$query2 = db_query("
SELECT
name as CatTitle
FROM {$db_prefix}tp_dlmanager
WHERE type like 'dlcat' AND id like '$category_sub'", __FILE__, __LINE__);

while ($filedata2 = mysql_fetch_assoc($query2))
{
$catNames[$filedata['id']] = rawurlencode(pretty_seo_url($filedata2['CatTitle']));
}
mysql_free_result($query2);


}


I just post here to share, it isn't supposed to be safe :)

Uchiha

How can i change the actions? my forum is in Spanish and i want to rewrite ?action=forum to /foro not /forum, how i can do that?
PS: Sorry for use colors, is just to diferency
Sorry For My Bad English, I Dont Speak Good, But I Try

vbgamer45

Actions can't easily be changed since it based on SMF action code.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

milicik

Hello. Can somewone update lighttpd rewrite code for pretty url.

Here they are http://redmine.lighttpd.net/boards/2/topics/1705?r=2103#message-2103 but last update was about 1 year ago  wich make some things not working.

Tnx

vbgamer45

I think someone did it a couple posts back
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro


vbgamer45

You have to run the install script files copy them to root directory of your forum then run them via the browser
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Pawan

Quote from: vbgamer45 on January 19, 2011, 12:54:00 PM
You have to run the install script files copy them to root directory of your forum then run them via the browser
I have to run SMF2-0/install.php only or more files.

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro


Pawan

Sorry to disturb but when i am quote, Modifying or even posting any answer , i am getting the error.

Please see the attach file.

vbgamer45

If you have queryless urls enabled disable them
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Pawan

Quote from: vbgamer45 on January 19, 2011, 02:26:01 PM
If you have queryless urls enabled disable them
Sorry to ask but where to disable them  :-[

milicik

Quote from: SirReal on January 06, 2011, 06:45:46 AM
I get tired of hacking pretty urls to work with lighttpd every time.
Perhaps you could include this diff to fix the darned quotation bug.

--- Subs-PrettyUrls.php 2010-01-31 16:41:00.000000000 +0100
+++ Subs-PrettyUrls.txt 2011-01-06 12:36:52.669173100 +0100
@@ -40,11 +40,11 @@
                'y'     =>      array ('y', 'Y', 'ý', 'Ã
                                                                        'z'     =>      array ('z', 'Z', 'ż', 'Å»', 'ź', 'Ź', 'ž', 'Ž', 'Î'),
                '-'     =>      array ('-', ' ', '.', ','),
+               ''      =>      array ("'", '"', "`"),
                '_'     =>      array ('_'),
                '!'     =>      array ('!'),
                '~'     =>      array ('~'),
                '*'     =>      array ('*'),
-               "\x12"  =>      array ("'", '"'),
                '('     =>      array ('(', '{', '['),
                ')'     =>      array (')', '}', ']'),
                '$'     =>      array ('$'),
@@ -130,16 +130,23 @@
        $pretty_board_urls = isset($modSettings['pretty_board_urls']) ? unserialize($modSettings['pretty_board_urls']) : array();
        $pretty_board_lookup_old = isset($modSettings['pretty_board_lookup']) ? unserialize($modSettings['pretty_board_lookup']) : array();

-       //      Fix old boards by replacing ' with \x12
-       $pretty_board_urls = str_replace("'", "\x12", $pretty_board_urls);
+       //      Fix old boards by replacing ' with ^
+       $pretty_board_urls = str_replace("'", "", $pretty_board_urls);
+       $pretty_board_urls = str_replace("\x12", "", $pretty_board_urls);
        $pretty_board_lookup = array();
        foreach ($pretty_board_lookup_old as $board => $id)
-               $pretty_board_lookup[str_replace("'", "\x12", $board)] = $id;
+       {
+               $pretty_board_lookup[str_replace("'", "", $board)] = $id;
+               $pretty_board_lookup[str_replace("\x12", "", $board)] = $id;
+       }

        //      Fix old topics too
        db_query("
                UPDATE {$db_prefix}pretty_topic_urls
-               SET pretty_url = REPLACE(pretty_url, '\\'', '" . chr(18) . "')", __FILE__, __LINE__);
+               SET pretty_url = REPLACE(pretty_url, '\\'', '')", __FILE__, __LINE__);
+       db_query("
+               UPDATE {$db_prefix}pretty_topic_urls
+               SET pretty_url = REPLACE(pretty_url, CHAR(18), '')", __FILE__, __LINE__);
        $context['pretty']['maintenance_tasks'][] = 'Fixing any old boards and topics with broken quotes';

        //      Get the board names


Yeah, it's not pretty and could use some cleanup, but basically, quotes aren't safe, so just nuke them.
Quote from: vbgamer45 on January 18, 2011, 09:32:19 PM
I think someone did it a couple posts back


Where to put this code?

botb2

Just installed running SMF 1.1.12 and Avare MU template

Notice: Undefined index: pretty_action_array in /home/thepok8/public_html/index.php on line 83

Notice: Undefined index: pretty_board_urls in /home/thepok8/public_html/index.p

site is www.thepokerdream.net

vbgamer45

Do those errors repeat or one time? If repeat try resaving pretty urls settings
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Pawan


Advertisement: