PHP Smarty now function return random dates - php

I am using Smarty 2.6.9 and I am finding that I experience issues with the following block of code.
Copyright © {$smarty.now|date_format:'%Y'} CRMPicco. All rights reserved
The date generated by Smarty seems to be random, sometimes it's 8780, sometimes it's 1872...as I say, completely random.
What I am finding is this seems to be an environmental issue too, as it works in my development environment (CentOS 5.6) but is broken in a testing environment. Now, I realise this would point to a config issue on the testing environment but I am using PHP date functions all through the codebase and if it wasn't working i'd soon know about it.
I appreciate I may get suggestions along the lines of "if PHP date function works then send that through to your Smarty template", but there must be a way to do it in Smarty too?
Is this a bug in Smarty or a config issue?

It's a somewhat-known configuration issue, caused by $smarty->plugins_dir not being set correctly (or some other problem preventing access to that directory).
date_format is the name of a Smarty plugin, but it's also the name of a PHP function. If Smarty cannot locate its plugin it falls back to calling the PHP function, which expects a completely different set of arguments. The resulting breakage is what you see.

Related

PhpStorm does not recognize PHP

I saw many different questions here, but nothing was helpful to me.
I have no trouble with an interpreter, I tried to reset PhpStorm's cache.
It looks like file functions.php isn't accessible.
I really don't want to make a total reset. Maybe somebody has an idea how to solve it?
I'm not sure what I actually did and how to reproduce this issue again, but now it works well. I took previous version of PHPstorm. When I installed new one, the previous one was simply renamed to sth like 'phpstorm2'.
Here are my thoughts what actually happened:
As I understand for highlighting is responsible that part of application which is managed under Languages & Frameworks / PHP / PHP Runtime.
To reproduce this issue you may try to disable there "Core / Core" and try to write down in any place of your phpfile following:
\Exception::class();
And in your case this class will not be highlighted, as it presents in Core_c.php. In my case it is placed in
/opt/phpstorm/plugins/php/lib/php.jar!/stubs/Core/Core_c.php
I'm 100% sure that these libs were always enabled, but why I didn't saw this - that is the question.
So if I face this issue again my steps would be:
Try to verify Languages & Frameworks / PHP / PHP Runtime. The better way would be to enable ALL libs.
Check External Libraries in the project tree. Check read privileges for /opt/phpstorm/plugins/php/lib/php.jar and probably reinstall this plugin.
Try to find out function which I don't actually see in External Libraries.

List all loaded files in PHP

There is no way on denying that PHP is based on includes. Even PSR4 is responsible for including files from folders so, so far away.
Sometimes it become very difficult to debug code, mainly on third party code, don't matter how good it was written.
With PHP being so dynamic in function calling it is very easy to get lost. And the URL don't help much in software like MOODLE.
Is there a way to tell PHP to error_log every file that was loaded in a request? So I can know the files i need to debug.
I don't think using the PHP magic constants will help much.
get_included_files()
This function returns all required and included file names as array.

Expression Engine install differences

Not sure if this is the right place to ask this but I have a site with a staging and beta install of expression engine. Same versions same files everything appears to be identical. The config files are the same except for the url differences however the two sites behave differently for a number of extensions/modules. One issue was that on the staging site the previous developer had a template embedding another template and using it in a loop to execute another query so something like this:
{!-- template uri /example/uri --}
start loop
{embed="template/.thistemplate" id="{id}"}
end loop
{!--end template--}
This worked perfectly fine on staging but on the beta install it did not, it actually only embedded the last id passed through for every item in the loop which resulted in the same result for the whole loop.
To get this particular issue working I rewrote the code so that it didn't embed anything but I am having lots of other issues that are similar in the fact that they work on staging and not beta and I am wondering if anyone out there knows of any places where settings could drastically alter the behavior of the site.
In four years of EE development, I've never seen an issue like this. My only guess is that your beta environment may not use a supported version of PHP or may have modules configured in a way that parses EE's PHP code differently than your staging server does. If you haven't already done so, check the beta server's settings to make sure it fits EE's requirements. It's difficult to give you any other pointers without further information. Best of luck!
Sounds to me like the 2 sites are not truly in sync.
How was the 2nd site split off from the first site?
Were both the database and the filesystem cloned at the same time?
I would consider making a new snapshot of staging and using that as your beta site.

Drupal static homepage not working

First off, I'm completely new to Drupal, so I could be making a ridiculously simple mistake...
I'm using Drupal 7.9, and trying to use an HTML homepage that I've already created, that does not follow the Theme...
I've tried using the page-front.tpl.php file, but it is completely ignored. I then found that in Drupal 7 I should be using page--front.tpl.php, but that is ignored as well.
I've looked through many different tutorial and FAQs, but to no avail. Can someone possibly point out what I'm doing wrong? I've even added some test text to the page.tpl.php file, just to make sure that it's loading that one instead; which it is. Is there some setting that I'm missing that tells Drupal to use the page--front.tpl.php file?
Here's the server setup...
Windows Server 8;
IIS 7;
MySQL 5
PHP 5
I know, we should be using Linux and Apache... I'm still working on getting our Windows happy VP to let me make the switch...:)
Thanks for any help, I'm at a loss here...
--Charles
Drupal manages all pages dynamically and stores content in the database. You will be able to designate a specific page as your home page and render it differently than other pages if you wish. Drupal is extremely flexible and capable of almost anything by using the many expansion modules that are available for it. Having said that, you should also know that there is a 'learning curve' to Drupal so don't expect good results right off the bat. If this is a one-off project, you may want to look at other alternatives as well.

Adding postback date to scripts?

I'm writing some scripts that are free, but only to members within my teaching program. What I want to do is check what sites have installed the script.
I was thinking of obfuscating some PHP that posts back to my server when installed so I can see the domain it's used on. Obviously the user could remove this, but if I was to put a few application variables in with the code it might stop them removing because doing so would break the script.
Any comments on this approach?
if you really want to be sure, use something like Zend Guard (aka Zend Encoder) to encode the php file.
If you want some of it to be user-editable, just encode the core functions (along with your security check) in a separate file and then leave the higher level code open for them to tinker with/modify as required.

Categories