$f3->BASE not working under PHP 7.1

106 views
Skip to first unread message

Farid Silva Aboid

unread,
Feb 20, 2017, 2:42:09 PM2/20/17
to Fat-Free Framework
Hello buddies, I have made a bilingual site using F3 v.3.6 and everything is working fine under testing server which has PHP 5.6x but in production server there is a lampp with PHP 7.1 and some issues are rising

  • $f3->BASE and {{ @BASE }} returns empty strings
  • $language=$f3->get('COOKIE.language');  returns empty strings (This cookie is set by jQuery on language button click)
  • ajax post to form processor returns error 405 method not allowed
Is there something I can do to solve those issues?

Thank you in advance.

ikkez

unread,
Feb 20, 2017, 3:09:16 PM2/20/17
to f3-fra...@googlegroups.com
if the project is located on the web-root, BASE is empty, that's correct.
the cookie issue could also be a problem with the cookie domain path
not sure what your form processor is doing, but error 405 is a known issue that means your routing to a class method is probably not existing

Farid Silva Aboid

unread,
Mar 2, 2017, 8:41:31 AM3/2/17
to Fat-Free Framework
Hello ikkez and thank you for your gently reply.

I have noticed what you said about BASE empty value on webroot, and after made a test in other directories, I agree with you in that point.

Form processor finally was solve by switch to phpmailer instead of smtp class

[27-Feb-2017 21:37:15 Europe/Berlin] HTTP 500 (GET /form-send.php)
[27-Feb-2017 21:37:15 Europe/Berlin] [lib/smtp.php:201] Base->error()
[27-Feb-2017 21:37:15 Europe/Berlin] [form-send.php:32] SMTP->send()



About cookies, it results still strange to me because if I set a cookie via javascript in plain html file, it works fine, but if I do in a f3 view, the cookie is not registered.

I'm using those simple javascript functions

function createCookie(name,value,days) {
   
if (days) {
       
var date = new Date();
        date
.setTime(date.getTime()+(days*24*60*60*1000));
       
var expires = "; expires="+date.toGMTString();
   
}
   
else {var expires = ""; }
    document
.cookie = name+"="+value+expires+"; path=/";
}


function readCookie(name) {
   
var nameEQ = name + "=";
   
var ca = document.cookie.split(';');
   
for(var i=0;i < ca.length;i++) {
       
var c = ca[i];
       
while (c.charAt(0)==' ') c = c.substring(1,c.length);
       
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
   
}
   
return null;
}


function eraseCookie(name) {
    createCookie
(name,"",-1);
}


and you can see it in action at




Regards.

Anatol

unread,
Mar 2, 2017, 2:04:19 PM3/2/17
to Fat-Free Framework
 
Hi your examples are different from your js code.


Here nothing happens on click english in your top menu
here the value is undefined.


Does this simplified code work for you?

    <script>
        $( document ).ready(function() {
      function setLang(name,value,days) {
          if (days) {
              $.cookie(name, value, { expires: days }, { path: '/' });
              showLang(name);
              // reload page or whatever is needed to change your lang
          } else {
              $.cookie(name, value, { expires: '365' });
          }
      }

      // if you like to inform the user about the current code ...
      function showLang(name) {
          $('#output').html( '<p  class="alert alert-info" >Idioma >> '+$.cookie(name)+'</p>' );
      }

      // in case you need to fire it from somewhere
      function eraseCookie(name) {
          $.removeCookie(name);
      }

      /* SET LANGUAGE EN */
      $('#botEn').click(function(){
          setLang('idioma','en', 7);
      });

      /* SET LANGUAGE ES */
      $('#botEs').click(function(){
          setLang('idioma','es', 7);
      }); 
    });
</script>


 
Reply all
Reply to author
Forward
0 new messages