Codoforum related discussions
[Solved] URL bugs - Callig Adesh here please ;)

Hello smile

I have a bug with smileys on my installation, and begin to think I have a problem with URL or URL rewriting.

You can check my forum here: http://supra-mk3.club

Smiley problem

When the smileys

:D :) etc..

are posted, the posted message won't point to the good URL, but will in preview:
55c356a60e493.png

http://supra-mk3.club/index.php?u=/sites/default/assets/img/smileys/bigsmile.gif

instead of

http://supra-mk3.club/sites/default/assets/img/smileys/bigsmile.gif

I may have broke something, because for older posts it's working:
55c359d75de09.png

URLs

Also, for cleanURL, when I've previously talked here with @nguoianphu , he answered:

Your word système becomes syst-amp-egrave-me. I afraid that you have to edit his file for your French language. smile

codoforum\sys\CODOF\Filter.php

I don't know why it doesn't work althought the Filter.php has this:

'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e'

You may ask @adesh1414127033 for help. I had to replace the Filter.php with another one for my Vietnamese language.

Here is my .htaccess:

<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  Options +Indexes
  RewriteEngine on

  # if your app is in a subfolder
  #RewriteBase /my_app/ 

  # test string is a valid files
  RewriteCond %{SCRIPT_FILENAME} !-f
  # test string is a valid directory
  RewriteCond %{SCRIPT_FILENAME} !-d

  RewriteRule ^(.*)$   index.php?u=/$1    [NC,L,QSA]
  # with QSA flag (query string append),
  # forces the rewrite engine to append a query string part of the
  # substitution string to the existing string, instead of replacing it.
</IfModule>

AddType text/css .less
AddType image/svg+xml svg svgz
AddEncoding gzip svgz

<IfModule mod_deflate.c>
  <FilesMatch ".(js|css|html|php|txt)$">
    SetOutputFilter DEFLATE
  </FilesMatch>
</IfModule>

Here are my modifications in constant.php:

define('CODO_DEBUG', 0);
define('DISPLAY_ERRORS', 'ON');
define('MODE', 'PRODUCTION'); //Can be DEVELOPMENT or PRODUCTION

define('SEF', 1); //Search engine freindly urls , 1=> enable , 0=> disable
define('LOCALE', 'fr_FR');

Am I doing something wrong?

Please help,

Reynald

Hello :) I have a bug with smileys on my installation, and begin to think I have a problem with URL or URL rewriting. You can check my forum here: http://supra-mk3.club ##Smiley problem When the smileys ```` :D :) etc.. ```` are posted, the posted message won&#039;t point to the good URL, but will in preview: ![55c356a60e493.png](serve/attachment&amp;amp;path=55c356a60e493.png) ```` http://supra-mk3.club/index.php?u=/sites/default/assets/img/smileys/bigsmile.gif ```` instead of ```` http://supra-mk3.club/sites/default/assets/img/smileys/bigsmile.gif ```` I may have broke something, because for older posts it&#039;s working: ![55c359d75de09.png](serve/attachment&amp;amp;path=55c359d75de09.png) ### URLs Also, for cleanURL, when I&#039;ve previously talked [here](http://codologic.com/forum/index.php?u=/topic/4238/tables-in-post-using-markdown/1#post-11166) with @nguoianphu , he answered: &amp;gt;Your word ```syst&amp;egrave;me ``` becomes ```syst-amp-egrave-me ```. I afraid that you have to edit his file for your French language. |( &amp;gt;``` codoforum\sys\CODOF\Filter.php ``` &amp;gt;I don&#039;t know why it doesn&#039;t work althought the ```Filter.php``` has this: &amp;gt;```&#039;&amp;egrave;&#039; =&amp;gt; &#039;e&#039;, &#039;&amp;eacute;&#039; =&amp;gt; &#039;e&#039;, &#039;&amp;ecirc;&#039; =&amp;gt; &#039;e&#039;, &#039;&amp;euml;&#039; =&amp;gt; &#039;e&#039; ``` &amp;gt;You may ask @adesh1414127033 for help. I had to replace the Filter.php with another one for my Vietnamese language. Here is my .htaccess: ```` &amp;lt;IfModule mod_rewrite.c&amp;gt; Options +FollowSymlinks Options +Indexes RewriteEngine on # if your app is in a subfolder #RewriteBase /my_app/ # test string is a valid files RewriteCond %{SCRIPT_FILENAME} !-f # test string is a valid directory RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*)$ index.php?u=/$1 [NC,L,QSA] # with QSA flag (query string append), # forces the rewrite engine to append a query string part of the # substitution string to the existing string, instead of replacing it. &amp;lt;/IfModule&amp;gt; AddType text/css .less AddType image/svg+xml svg svgz AddEncoding gzip svgz &amp;lt;IfModule mod_deflate.c&amp;gt; &amp;lt;FilesMatch &quot;.(js|css|html|php|txt)$&quot;&amp;gt; SetOutputFilter DEFLATE &amp;lt;/FilesMatch&amp;gt; &amp;lt;/IfModule&amp;gt; ```` Here are my modifications in constant.php: ```` define(&#039;CODO_DEBUG&#039;, 0); define(&#039;DISPLAY_ERRORS&#039;, &#039;ON&#039;); define(&#039;MODE&#039;, &#039;PRODUCTION&#039;); //Can be DEVELOPMENT or PRODUCTION define(&#039;SEF&#039;, 1); //Search engine freindly urls , 1=&amp;gt; enable , 0=&amp;gt; disable define(&#039;LOCALE&#039;, &#039;fr_FR&#039;); ```` Am I doing something wrong? Please help, Reynald
edited Aug 7 '15 at 8:53 pm

Hi,

The absolute urls are not getting converted to relative urls.

Did you change anything in sys/Ext/Html.php ?

Hi, The absolute urls are not getting converted to relative urls. Did you change anything in sys/Ext/Html.php ?

Hi,

Did you change anything in sys/Ext/Html.php ?

No, nothing. Just to be sure, Diff confirms it smile

If I try a new post with a smiley, here is the smiley adress in preview:

http://supra-mk3.club/sites/default/assets/img/smileys/smile.gif

and here once posted:

http://supra-mk3.club/index.php?u=/sites/default/assets/img/smileys/smile.gif
Hi, &amp;gt;Did you change anything in sys/Ext/Html.php ? No, nothing. Just to be sure, Diff confirms it ;) If I try a new post with a smiley, here is the smiley adress in preview: ```` http://supra-mk3.club/sites/default/assets/img/smileys/smile.gif ```` and here once posted: ```` http://supra-mk3.club/index.php?u=/sites/default/assets/img/smileys/smile.gif ````
edited Aug 6 '15 at 8:53 pm

@RolluS

Can you make this trick?

codoforum\sites\default\constants.php

Line 75 change to

    if (!SEF) {
        define('RURI', $ruri . 'index.php?u=/');
        define('NRURI', RURI);            
    } else {
        define('RURI', $ruri);
        // define('NRURI', $ruri . 'index.php?u=/');
        define('NRURI', $ruri);
    }
@RolluS Can you make this trick? ```codoforum\sites\default\constants.php``` Line 75 change to if (!SEF) { define(&#039;RURI&#039;, $ruri . &#039;index.php?u=/&#039;); define(&#039;NRURI&#039;, RURI); } else { define(&#039;RURI&#039;, $ruri); // define(&#039;NRURI&#039;, $ruri . &#039;index.php?u=/&#039;); define(&#039;NRURI&#039;, $ruri); }
NguoiAnPhu.com Powered by Codoforum 4.3 (https://github.com/nguoianphu/codoforums-vietnam).
edited Aug 7 '15 at 3:05 am

@nguoianphu

That's working! many thanks.

Smiley problem:

Solved (or worked around thanks to @nguoianphu):

  • in sites/default/constants.php:
    75 if (!SEF) {
    76        define('RURI', $ruri . 'index.php?u=/');
    77        define('NRURI', RURI);            
    78 } else {
    79        define('RURI', $ruri);
    80        define('NRURI', $ruri); // define('NRURI', $ruri . 'index.php?u=/');
    81 }
    

URLs

Still not solved, and maybe breaking SEO and sitemap generator

Workaround would be to edit all my titles, but I would prefer it to work because I don't want to edit my users topic eventually..

@nguoianphu That&#039;s working! many thanks. ##Smiley problem: Solved (or worked around thanks to @nguoianphu): - in sites/default/constants.php: ```` 75 if (!SEF) { 76 define(&#039;RURI&#039;, $ruri . &#039;index.php?u=/&#039;); 77 define(&#039;NRURI&#039;, RURI); 78 } else { 79 define(&#039;RURI&#039;, $ruri); 80 define(&#039;NRURI&#039;, $ruri); // define(&#039;NRURI&#039;, $ruri . &#039;index.php?u=/&#039;); 81 } ```` ##URLs Still not solved, and maybe breaking SEO and sitemap generator Workaround would be to edit all my titles, but I would prefer it to work because I don&#039;t want to edit my users topic eventually..
edited Aug 7 '15 at 2:06 pm

URLs

OK,
I've opened the trunk and found a workaround:

  • repair URL_Safe:

    • in sys/CODOF/Filter.php:

      26 static function URL_safe($str, $options = array()) {
      ...
      29     $str = mb_convert_encoding((string) html_entity_decode($str), 'UTF-8', mb_list_encodings()); //$str = mb_convert_encoding((string) $str, 'UTF-8', mb_list_encodings());
      
      Note: line 29: I think it's a bug because obviously if the topic name is encoded before entering the function, there is no symbol to convert.
  • in sys/CODOF/Topic.php:

    625 public function gen_topic_arr_all_topics($topics, $search = false) {
    ...
    740                "safe_title" => \CODOF\Filter::URL_safe($topic['title']), //"safe_title" => \CODOF\Filter::URL_safe(html_entity_decode($topic['title'])),
    
    Note: as url is decoded inside URL_safe{}no need to convert here.
  • in sites/default/themes/default/templates/forum/topic.tpl:

    09 {block name=body}
    10
    11    {assign "safe_title" html_entity_decode($title)|URL_safe}
    
    I'd prefer directly the function to be modified, but can't understand how that work here (that's already a big thing I achieved to modify CODOF/php files).
  • some customisation:

    • add ° like in N°1 (=#1 in French) or °C in sys/CODOF/Filter.php:

      26 static function URL_safe($str, $options = array()) {
      ...
      43    $char_map = array(
      ...
      55    // Latin symbols
      56        '©' => '(c)',
      57        '°' => 'o-', //added
      
    • removed gg at the start of the url in sys/CODOF/Topic.php:

      625 public function gen_topic_arr_all_topics($topics, $search = false) {
      ...
      653         "safe_title" => \CODOF\Filter::URL_safe($topic['title']),  // "safe_title" => "gg''.\CODOF\Filter::URL_safe($topic['title']),
      

Hopefully @adesh1414127033, @avinash, all this could be added in the next release.

###URLs OK, I&#039;ve opened the trunk and found a workaround: - ####repair URL_Safe: - in sys/CODOF/Filter.php: ```` 26 static function URL_safe($str, $options = array()) { ... 29 $str = mb_convert_encoding((string) html_entity_decode($str), &#039;UTF-8&#039;, mb_list_encodings()); //$str = mb_convert_encoding((string) $str, &#039;UTF-8&#039;, mb_list_encodings()); ```` #####Note: line 29: I think it&#039;s a bug because obviously if the topic name is encoded before entering the function, there is no symbol to convert. - in sys/CODOF/Topic.php: ```` 625 public function gen_topic_arr_all_topics($topics, $search = false) { ... 740 &quot;safe_title&quot; =&amp;gt; \CODOF\Filter::URL_safe($topic[&#039;title&#039;]), //&quot;safe_title&quot; =&amp;gt; \CODOF\Filter::URL_safe(html_entity_decode($topic[&#039;title&#039;])), ```` #####Note: as url is decoded inside ``URL_safe{}``no need to convert here. - in sites/default/themes/default/templates/forum/topic.tpl: ```` 09 {block name=body} 10 11 {assign &quot;safe_title&quot; html_entity_decode($title)|URL_safe} ```` #####I&#039;d prefer directly the function to be modified, but can&#039;t understand how that work here (that&#039;s already a big thing I achieved to modify CODOF/php files). - #### some customisation: - add ``&amp;deg;`` like in ``N&amp;deg;1`` (=``#1`` in French) or ``&amp;deg;C`` in sys/CODOF/Filter.php: ```` 26 static function URL_safe($str, $options = array()) { ... 43 $char_map = array( ... 55 // Latin symbols 56 &#039;&amp;copy;&#039; =&amp;gt; &#039;(c)&#039;, 57 &#039;&amp;deg;&#039; =&amp;gt; &#039;o-&#039;, //added ```` - removed ``gg`` at the start of the url in sys/CODOF/Topic.php: ````` 625 public function gen_topic_arr_all_topics($topics, $search = false) { ... 653 &quot;safe_title&quot; =&amp;gt; \CODOF\Filter::URL_safe($topic[&#039;title&#039;]), // &quot;safe_title&quot; =&amp;gt; &quot;gg&#039;&#039;.\CODOF\Filter::URL_safe($topic[&#039;title&#039;]), ```` Hopefully @adesh1414127033, @avinash, all this could be added in the next release.
edited Aug 7 '15 at 8:45 pm
607
7
4
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft