Autor Tópico: Advance SEF Urls  (Lida 2281 vezes)

0 Membros e 1 Visitante estão a ver este tópico.

Offline joomlamz

  • Fundador
  • *
  • Mensagens: 4262
  • Agradeceu: 1 Vezes
  • Rank: 4877
  • Sexo: Masculino
  • Joomla!
    • Web Master !
Advance SEF Urls
« em: 05 de Julho de 2012, 11:57 »
  • Publicar
  • Manuel İnstallation for SMF 2.0 Beta 4

    Sources/ManageSettings.php
    Pesquisar
    Código: [Seleccione]
    );

    if ($return_config)
    return $config_vars;


    Adicionar antes

    Código: [Seleccione]
    '',
    // 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
    Pesquisar
    Código: [Seleccione]
    global $board, $topic, $boardurl, $scripturl, $modSettings, $smcFunc;
    Trocar por
    Código: [Seleccione]
    global $board, $topic, $boardurl, $scripturl, $modSettings, $smcFunc, $disable_sef;
    Pesquisar
    Código: [Seleccione]
    // Makes it easier to refer to things this way.
    $scripturl = $boardurl . '/index.php';

    Adicionar antes

    Código: [Seleccione]
    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);

    Pesquisar
    Código: [Seleccione]
    function ob_sessrewrite($buffer)
    {

    Adicionar antes
    Código: [Seleccione]
    global $disable_sef;

    Pesquisar
    Código: [Seleccione]
    // If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit.
    Adicionar antes

    Código: [Seleccione]
    // 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) . '|';

    Pesquisar
    Código: [Seleccione]
    $buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?(?:' . SID . ';)((?:
    Trocar por

    Código: [Seleccione]
    $buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?(?:' . SID . ';)((?:' . $sef_urls . '
    Pesquisar
    Código: [Seleccione]
    $buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?((?:
    Trocar por
    Código: [Seleccione]
    $buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?((?:' . $sef_urls . '
    Pesquisar
    Código: [Seleccione]
    if (empty($_COOKIE) && SID != '' && empty($context['browser']['possibly_robot']) && @version_compare(PHP_VERSION, '4.3.0') != -1)
    Trocar por
    Código: [Seleccione]
    if (empty($_COOKIE) && SID != '' && empty($context['browser']['possibly_robot']) && @version_compare(PHP_VERSION, '4.3.0') != -1 && (empty($modSettings['enableNoFile']) || !empty($disable_sef)))

    Pesquisar
    Código: [Seleccione]
    if (isset($_GET['debug']))
    Trocar por
    Código: [Seleccione]
    if (isset($_GET['debug']) && !empty($disable_sef))

    Pesquisar
    Código: [Seleccione]
    // Return the changed buffer.
    return $buffer;

    Adicionar antes
    Código: [Seleccione]
    // 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
    Pesquisar
    Código: [Seleccione]
    // Put the session ID in.
    Adicionar Depois
    Código: [Seleccione]
    // 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) . '|';

    Pesquisar
    Código: [Seleccione]
    $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);

    Trocar por
    Código: [Seleccione]
    $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);

    Pesquisar
    Código: [Seleccione]
    // We send a Refresh header only in special cases because Location looks better. (and is quicker...)
    Trocar por
    Código: [Seleccione]
    if(!empty($modSettings['enableUseQuestion']) && empty($disable_sef))
    $setLocation = str_replace('??', '?', $setLocation);

    Themes/default/Post.template.php

    Pesquisar
    Código: [Seleccione]
    new_url = new_url.substr(0, new_url.indexOf("rand=") + 5);
    Trocar por
    Código: [Seleccione]
    new_url = new_url.substr(0, new_url.indexOf("rand") + 5);

    .htaccess

    Pesquisar
    Código: [Seleccione]
    ?>
    Adicionar depois
    Código: [Seleccione]
    <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

    Pesquisar
    Código: [Seleccione]
    ?>
    Adicionar depois
    Código: [Seleccione]
    $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>';


    A TRADUCAO EM PT Candidosa2 Vai fazer..e colocar aqui
    Apllic   Alojamentos Profissionais de Moçambique!

    Offline marcio-msa

    • Smfpt em 10%
    • *
    • Mensagens: 231
    • Rank: 0
    • GsmLiveFans
      • GsmLivefans
    Re: Advance SEF Urls
    « Responder #1 em: 09 de Julho de 2012, 04:42 »
  • Publicar
  • da quase para montar um mods

    ManageSettings.php
    Código: [Seleccione]
    <file name="$sourcedir/ManageSettings.php">
    <operation>
    <search position="before"><![CDATA[ );

    if ($return_config)
    return $config_vars;]]></search>
    <add><![CDATA[ '',
    // Action SEF URLS?
    array('check', 'enableActionurls'),
    array('check', 'enableSubActionurls'),
    array('check', 'enableCurls'),
    array('check', 'enablePageurls'),
    array('check', 'enableUseQuestion'),
    array('check', 'enableNoIndex'),
    array('check', 'enableNoFile'),
    ]]></add>
    </operation>
    </file>


    QueryString.php
    Código: [Seleccione]
    <file name="$sourcedir/QueryString.php">
    <operation>
    <search position="replace"><![CDATA[
    global $board, $topic, $boardurl, $scripturl, $modSettings, $smcFunc;
    ]]></search>
    <add><![CDATA[
    global $board, $topic, $boardurl, $scripturl, $modSettings, $smcFunc, $disable_sef;
    ]]></add>
    </operation>
    <operation>
    <search position="before"><![CDATA[
    // Makes it easier to refer to things this way.
    $scripturl = $boardurl . '/index.php';
    ]]></search>
    <add><![CDATA[
    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);
    ]]></add>
    </operation>
    <operation>
    <search position="before"><![CDATA[
    function ob_sessrewrite($buffer)
    {
    ]]></search>
    <add><![CDATA[
    global $disable_sef;
    ]]></add>
    </operation>


    <operation>
    <search position="after"><![CDATA[
    // If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit.
    ]]></search>
    <add><![CDATA[
    // 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) . '|';
    ]]></add>
    </operation>
    <operation>
    <search position="replace"><![CDATA[$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:]]></search>
    <add><![CDATA[$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:' . $sef_urls . ']]></add>
    </operation>
    <operation>
    <search position="replace"><![CDATA[$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?((?:]]></search>
    <add><![CDATA[$buffer = preg_replace('/"' . preg_quote($scripturl, '/') . '\?((?:' . $sef_urls . ']]></add>
    </operation>
    <operation>
    <search position="replace"><![CDATA[if (empty($_COOKIE) && SID != '' && empty($context['browser']['possibly_robot']) && @version_compare(PHP_VERSION, '4.3.0') != -1)]]></search>
    <add><![CDATA[if (empty($_COOKIE) && SID != '' && empty($context['browser']['possibly_robot']) && @version_compare(PHP_VERSION, '4.3.0') != -1 && (empty($modSettings['enableNoFile']) || !empty($disable_sef)))]]></add>
    </operation>
    <operation>
    <search position="replace"><![CDATA[if (isset($_GET['debug']))]]></search>
    <add><![CDATA[if (isset($_GET['debug']) && !empty($disable_sef))]]></add>
    </operation>
    <operation>
    <search position="after"><![CDATA[ // Return the changed buffer.
    return $buffer;
    ]]></search>
    <add><![CDATA[ // 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);
    ]]></add>
    </operation>
    </file>



    Subs.php
    Código: [Seleccione]
    <file name="$sourcedir/Subs.php">
    <operation>
    <search position="after"><![CDATA[
    // Put the session ID in.
    ]]></search>
    <add><![CDATA[
    // 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) . '|';
    ]]></add>
    </operation>

    <operation>
    <search position="replace"><![CDATA[ $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?: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);
    ]]></search>
    <add><![CDATA[ $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\?(?:' . SID . '(?:;|&|&amp;))((?:' . $sef_urls . 'board|topic)=[^#]+?)(#[^"]*?)?$/e', "\$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2?' . SID", $setLocation);
    else
    $setLocation = preg_replace('/^' . preg_quote($scripturl, '/') . '\?((?:' . $sef_urls . 'board|topic)=[^#"]+?)(#[^"]*?)?$/e', "\$scripturl . '/' . strtr('\$1', '&;=', '//,') . '.html\$2'", $setLocation);
    ]]></add>
    </operation>

    <operation>
    <search position="replace"><![CDATA[
    // We send a Refresh header only in special cases because Location looks better. (and is quicker...)
    ]]></search>
    <add><![CDATA[
    if(!empty($modSettings['enableUseQuestion']) && empty($disable_sef))
    $setLocation = str_replace('??', '?', $setLocation);
    ]]></add>
    </operation>
    </file>

    .htaccess
    Código: [Seleccione]
    <file name="$boarddir/.htaccess" error="skip">
    <operation>
    <search position="end" />
    <add><![CDATA[
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [QSA]
    </IfModule>
    ]]></add>
    </operation>
    </file>


    Modifications.english.php
    Código: [Seleccione]
    <file name="$languagedir/Modifications.english.php">
    <operation>
    <search position="end" />
    <add><![CDATA[
    $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>';
    ]]></add>
    </operation>
    </file>


    Modifications.english_utf8.php
    Código: [Seleccione]
    <file name="$languagedir/Modifications.english_utf8.php" error="skip">
    <operation>
    <search position="end" />
    <add><![CDATA[
    $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>';
    ]]></add>
    </operation>
    </file>

    Offline candidosa2

    • Suporte Tecnico
    • Fundador
    • *
    • Mensagens: 5044
    • Rank: 1658
    • Sexo: Masculino
    • Suporte
      • Hosting Moçambique
    Re: Advance SEF Urls
    « Responder #2 em: 09 de Julho de 2012, 07:54 »
  • Publicar
  • Sim pode montar se quiser nao a problema nisso

     


    Facebook Comentários