Gönderen Konu: Advance SEF Urls  (Okunma sayısı 2624 defa)

0 Üye ve 1 Ziyaretçi konuyu incelemekte.

Çevrimdışı Balaban

  • SGT-Admin
  • *
  • İleti: 3804
  • PR ( Rep ) : 117
  • Cinsiyet: Bay
    • Metal Vids
Advance SEF Urls
« : SmfGrup Saati : 08 Eylül Pzt 2008, 23:32 »
This Mod creates and allows you do do some More SEF Options while using the default SMF SEF Urls.
You can have action urls be SEF Friendly, Page urls (from Tinyportal), and even Single Category urls be SEF friendly.
As well you can also choose to use /? or /index instead of /index.php as your scripturl string.

All options come with a shutoff that you can add to your Settings.php incase enabling one of these options causes  your server to fail. Just add the following to your Settings.php if your site fails to load or work after changing SEF options to disable them.
$disable_sef = true;


Manuel İnstallation for SMF 2.0 Beta 4

Sources/ManageSettings.php
Find

Kod: [Seç]
);

if ($return_config)
return $config_vars;

Beforee add..

Kod: [Seç]
'',
// Action SEF URLS?
array('check', 'enableActionurls'),
array('check', 'enableSubActionurls'),
array('check', 'enableCurls'),
array('check', 'enablePageurls'),
array('check', 'enableUseQuestion'),
array('check', 'enableNoIndex'),
array('check', 'enableNoFile'),

Sources/QueryString.php

Find
   
Kod: [Seç]
global $board, $topic, $boardurl, $scripturl, $modSettings, $smcFunc;
Replace With

Kod: [Seç]
global $board, $topic, $boardurl, $scripturl, $modSettings, $smcFunc, $disable_sef;
Find
Kod: [Seç]
// Makes it easier to refer to things this way.
$scripturl = $boardurl . '/index.php';

Add After
Kod: [Seç]
if(!empty($modSettings['enableUseQuestion']) && empty($disable_sef))
$scripturl = str_replace('/index.php', '/?', $scripturl);
elseif(!empty($modSettings['enableNoIndex']) && empty($disable_sef))
$scripturl = str_replace('/index.php', '/index', $scripturl);
// This will make all urls use a double /, but it is needed for detection by the script.
elseif(!empty($modSettings['enableNoFile']) && empty($disable_sef))
$scripturl = str_replace('/index.php', '//', $scripturl);

Find

Kod: [Seç]
function ob_sessrewrite($buffer)
{

Add After

Kod: [Seç]
global $disable_sef;
Find

Kod: [Seç]
// If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit.
add before

   
Kod: [Seç]
// Clean URL to start with.
$sef_urls = array();

// Check the Settings, with a backup.
if(!empty($modSettings['enableActionurls']) && empty($disable_sef))
$sef_urls[] = 'action';
if(!empty($modSettings['enableSubActionurls']))
$sef_urls[] = 'sa';
if(!empty($modSettings['enableCurls']) && empty($disable_sef))
$sef_urls[] = 'c';
if(!empty($modSettings['enablePageurls']) && empty($disable_sef))
$sef_urls[] = 'page';


// After all that, Rip it up and drop it in a single line.
$sef_urls = implode('|', $sef_urls) . '|';

find

Kod: [Seç]
$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?(?:' . SID . ';)((?:
Replace with
Kod: [Seç]
$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?(?:' . SID . ';)((?:' . $sef_urls . '
Find

Kod: [Seç]
$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?((?:
Replace with

Kod: [Seç]
$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?((?:' . $sef_urls . '
Find

Kod: [Seç]
if (empty($_COOKIE) && SID != '' && empty($context['browser']['possibly_robot']) && @version_compare(PHP_VERSION, '4.3.0') != -1)
Replace With
Kod: [Seç]
if (empty($_COOKIE) && SID != '' && empty($context['browser']['possibly_robot']) && @version_compare(PHP_VERSION, '4.3.0') != -1 && (empty($modSettings['enableNoFile']) || !empty($disable_sef)))
Find
Kod: [Seç]
if (isset($_GET['debug']))
Replace with

Kod: [Seç]
if (isset($_GET['debug']) && !empty($disable_sef))
Find

   
Kod: [Seç]
// Return the changed buffer.
return $buffer;

Add before

Kod: [Seç]
// If we are using SEF urls, we want a clean debug.
if (isset($_GET['debug']) && empty($disable_sef))
$buffer = str_replace($scripturl, substr($scripturl, 0, -1) . 'debug', $buffer);
// Maybe we want to clean slashes?
elseif(!empty($modSettings['enableNoFile']) && empty($disable_sef))
$buffer = str_replace($scripturl, substr($scripturl, 0, -2), $buffer);

Sources/Subs.php

Find

Kod: [Seç]
// Put the session ID in.
Add before

Kod: [Seç]
// Clean URL to start with.
$sef_urls = array();

// Check the Settings..
if(!empty($modSettings['enableActionurls']))
$sef_urls[] = 'action';
if(!empty($modSettings['enableSubActionurls']))
$sef_urls[] = 'sa';
if(!empty($modSettings['enableCurls']))
$sef_urls[] = 'c';
if(!empty($modSettings['enablePageurls']))
$sef_urls[] = 'page';

// After all that, Rip it up and drop it in a single line.
$sef_urls = implode('|', $sef_urls) . '|';

Find

         
Kod: [Seç]
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\?(?:' . SID . ';)((?:board|topic)=[^#]+?)(#[^"]*?)?$/e', "\$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2?' . SID", $setLocation);
else
$setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\?((?:board|topic)=[^#"]+?)(#[^"]*?)?$/e', "\$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2'", $setLocation);

Replace with

         
Kod: [Seç]
$setLocation = preg_replace('/"' . preg_quote($scripturl, '/') . '\?(?:' . SID . ';)((?:' . $sef_urls . 'board|topic)=[^#"]+?)(#[^"]*?)?"/e', "'\"' . \$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html?' . SID . '\$2\"'", $setLocation);
else
$setLocation = preg_replace('/"' . preg_quote($scripturl, '/') . '\?((?:' . $sef_urls . 'board|topic)=[^#"]+?)(#[^"]*?)?"/e', "'\"' . \$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2\"'", $setLocation);


Find

Kod: [Seç]
// We send a Refresh header only in special cases because Location looks better. (and is quicker...)
Replace with

Kod: [Seç]
if(!empty($modSettings['enableUseQuestion']) && empty($disable_sef))
$setLocation = str_replace('??', '?', $setLocation);

Themes/default/Post.template.php

Find

Kod: [Seç]
new_url = new_url.substr(0, new_url.indexOf("rand=") + 5);

Replace with

Kod: [Seç]
new_url = new_url.substr(0, new_url.indexOf("rand") + 5);
.htaccess

Find
Kod: [Seç]
?>
add before

Kod: [Seç]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [QSA]
</IfModule>

Themes/default/languages/Modifications.english.php

find
Kod: [Seç]
?>
add before

Kod: [Seç]
$txt['enableActionurls'] = 'Enable Action SEF URLS';
$txt['enableSubActionurls'] = 'Enable Sub Action SEF URLS';
$txt['enableCurls'] = 'Enable Category SEF URLS (For Single Category Mod)';
$txt['enablePageurls'] = 'Enable Page SEF URLS (For Tinyportal Pages)';
$txt['enableUseQuestion'] = 'Use a question Mark (?) Instead of index.php';
$txt['enableNoIndex'] = 'Use index instead of index.php <span class="smalltext">(Doesn\'t work on all servers, use "$disable_sef = true;" in your Settings.php if enabling this breaks your site)</span>';
$txt['enableNoFile'] = 'Use Nothing instead of index.php <span class="smalltext">(Doesn\'t work on all servers, use "$disable_sef = true;" in your Settings.php if enabling this breaks your site)</span>';



Çevrimdışı Linkinpark

  • Sr. Member
  • **
  • İleti: 2394
  • PR ( Rep ) : 133
  • Cinsiyet: Bay
  • slaytyeri.blogspot.com
    • janjanlı
Ynt: Advance SEF Urls
« Yanıtla #1 : SmfGrup Saati : 10 Eylül Çrş 2008, 13:50 »
thanks
ÖSS BİTTİ SONUNDA :)