Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Is user accessing page via https or http
Goto page Previous  1, 2
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Mar 01, 2018 11:36 pm    Post subject: Reply with quote

Why so complicated?
Code:
{$SITE_URL|strstr:"//"}
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Fri Mar 02, 2018 1:15 am    Post subject: Reply with quote

Not that I was thinking of this earlier, but I choose Smarty modifiers first on the possibility there may be security policies in place.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Mar 02, 2018 9:25 am    Post subject: Reply with quote

Point.
Back to top
View user's profile Send private message
emmanouel
Smarty Rookie


Joined: 02 Nov 2017
Posts: 7

PostPosted: Fri Mar 02, 2018 4:43 pm    Post subject: Reply with quote

Hello, thank your for you reply.

To get in a line,
1. First I found inside head.tpl file the lines of code which cause the problem

(example) <script type="text/javascript" src="{$baseURL}/assets/javascript/jquery/jquery.min.js"></script>

2. So,the problem is caused by the {$baseURL}. My problem here is that I can't find,no matter how long I spend where is declared.

3. The given code seems to work fine and really I appriciate it.

but to avoid a number of replacements where is declared the {$baseURL} ?

Thanks
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Fri Mar 02, 2018 7:18 pm    Post subject: Reply with quote

It could be anywhere in your PHP scripts.
Code:
$Smarty->assign('baseURL',"whatever");

If you can't find it, then try finding the final:
Code:
$Smarty->display("name_of_master_template");

Just above that, add a new line:
Code:
$tmpBaseURL = $Smarty->getTemplateVars('baseURL');
$tmpBaseURL = somefunction($tmpBaseURL); // strip http|https
$Smarty->assign('baseURL',$tmpBaseURL);
Back to top
View user's profile Send private message
emmanouel
Smarty Rookie


Joined: 02 Nov 2017
Posts: 7

PostPosted: Fri Mar 02, 2018 9:20 pm    Post subject: Reply with quote

1. From your experience, files inside smarty,includes,themes, index, config??
Debugger says smarty root scope

2. The alternative solution you gave me has a 'somefunction', which is?'
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Fri Mar 02, 2018 10:08 pm    Post subject: Reply with quote

1. I use a program to search through files. It is very fast.

If index.php is more than 50 lines, it might be at the end of that file. Otherwise, maybe a controller file or class method in the /includes/ folder.

2. Whatever it takes. Try:
Code:
$tmpBaseURL = strstr($tmpBaseURL, "//");
Back to top
View user's profile Send private message
emmanouel
Smarty Rookie


Joined: 02 Nov 2017
Posts: 7

PostPosted: Sun Mar 04, 2018 12:51 pm    Post subject: Reply with quote

Fianlly I brought off to debug the site! Very Happy

It was assinged to another variable, $siteurl,which was assinged array() with settings etc...

By the way, the given code didn't work, I put it inside index.php before the line code
Code:

$Smarty->display("index.tpl");

Any considerations in order to got understand why thw website was collapsed?


Many thanks
Emmanouel
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Sun Mar 04, 2018 9:09 pm    Post subject: Reply with quote

I do not understand your use of the word 'collapsed'.
Back to top
View user's profile Send private message
emmanouel
Smarty Rookie


Joined: 02 Nov 2017
Posts: 7

PostPosted: Wed Mar 14, 2018 10:04 pm    Post subject: Reply with quote

Sorry for the delay.

I mean the site breaks, do not load pages. At this moment I can't try again the code to see what was the http error to refer it. It's ok if there is no suggestions.

Thank you for your help anyway
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Thu Mar 15, 2018 1:05 am    Post subject: Reply with quote

According to your initial post, the Smarty object is named $smarty, not $Smarty.

If you used $Smarty, then PHP probably crashed because $Smarty is a non-object.

If your code uses $smarty (lower-case), then these experiments should also use $smarty->display("index.tpl"); (lower-case) but not $Smarty->display("index.tpl"); (capitalized).
Back to top
View user's profile Send private message
emmanouel
Smarty Rookie


Joined: 02 Nov 2017
Posts: 7

PostPosted: Mon Mar 19, 2018 12:40 am    Post subject: Reply with quote

Well, it seems that you have right! Finally, that was the reason. Now i'llnever forget such kind of mistakes... Very Happy .
Thanks again
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP