smarty

Caching a PHP Array

风流意气都作罢 提交于 2019-11-29 17:58:25
问题 My problem is im creating a large nested PHP array which is parsing information from multiple external sources. On the first return I would like to cache this data. Im pretty new to caching so don't really know what I should be looking for, any good or bad methods or even if this is common practise! Have googled but not really found anything decent for a cache noob. Im already using smarty to cache my page content (excluding the dynamic bits), done apache tweaks, minifying etc to increase

关于模板引擎一

♀尐吖头ヾ 提交于 2019-11-29 08:08:36
本文转载于: 猿2048 网站⇒ 关于模板引擎一 前端模板引擎需要有开发时的透明性 透明性即指我在搭建好开发环境后,随手写代码随手刷新浏览器就能看到最新的效果,而不需要额外地执行任何命令或有任何的等待过程。 所以一切依赖编译过程的模板引擎并不适合前端使用,编译只能是模板引擎的一个特性,而不能是使用的前提 更严格地说,使用FileWatch等手段进行文件变更检测并自动编译也不在我的考虑范围之内,因为这会造成额外的等待, 由此可以推出,前端的模板引擎应该是具备 可在纯前端环境中解析使用 的能力的。 前端模板引擎要有良好的运行时调试能力 由于用户行为的不确定性、执行环境的不确定性、各种第三方脚本的影响等,前端很难做到完全的错误处理和跟踪,这也导致前端必然存在需要直接在线上排查问题的情况 而当问题出现在模板引擎这一层时,就需要模板引擎提供良好的调试能力 一般来说,编译后生成的函数的调试能力是弱于原先手动编写的模板片断的,因为自动生成的函数基本不具备可读性和可断点跟踪性 因此在这一点上,一个供前端使用的模板引擎应该具备在特定情况下从“执行编译后函数获取HTML”换回“解析原模板再执行函数获取HTML”的模式,即应该支持在两种模式间切换 或者更好地,一个强大的前端模板引擎编译生成的函数,可以使用Source Map或其它自定义的手段直接映射回原模板片段,不过现在并没有什么模板引擎实现了这一功能

How to convert an array into comma separated strings in smarty template?

跟風遠走 提交于 2019-11-29 06:17:28
问题 I've an array titled $preview_data assigned to smarty template as follows: Array ( [applicable_states] => Array ( [0] => 1 [1] => 3 [2] => 4 [3] => 10 [4] => 11 ) ) Now I want to show the above array elements as comma separated values in a div element of a smarty template. In short it should behave like implode() in php. Can someone please help me in achieving this in smarty template? Thanks in advance. 回答1: Try this: {', '|implode:$preview_data.applicable_states} It will give you what you

Organizing files of a website powered by PHP, Smarty, JavaScript, MySQL

那年仲夏 提交于 2019-11-29 05:17:47
I am writing an web application powered by PHP, Smarty, JavaScript, CSS, MySQL. There will be some classes, which will be used through out the application. There will be some scripts which will use those classes. Any good article, tutorial, architecture on how to organize files for a web site? P.S. It should contain how to organize all the files (PHP, JavaScript, CSS, template files.) Just remember PHP libraries and template files should not be directly accessible over the web server. You can make class names like My_Db_Table and load them with __autoload . /project - /config - /html - - /css

What is the best way to handle recursion in smarty?

我与影子孤独终老i 提交于 2019-11-29 04:23:51
I found a couple of ways to handle recursion in Smarty, mostly based on including templates into themselves, which seems like ridiculous waste of resources. I found one solution, by Messju over at Smarty that seemed to be just right - but it is not supported and fails in the latest version of smarty :( For people asking: What I want smarty to print out is a discussion thread that is defined by an array of entries. If an entry has one or more answers, those are listed as children to said entry in an array, and so on. array( array( 'id'=>0, 'headline'=>"My parent headline", 'body' =>"My parent

php.ini文件中的include_path设置

断了今生、忘了曾经 提交于 2019-11-28 15:38:55
下面以安装smarty为例:   下面内容中,我们都是假设你的文件放在了D:\Appserv\www\Smarty下。   1、找到你的php.ini配置文件修改php.ini的include_path选项,把smarty的库文件路径加上,比如:   include_path = "D:\Appserv\www\Smarty\libs"   提醒一下,php.ini中一共有两处include_path,一处是Unix下使用的,一处是windows下使用的,要修改windows下使用的:   -------------------------------------------------------------   ; Windows: "path1;path2"   ;include_path = ".:/php/includes"   修改为:   ; Windows: "\path1;\path2"   include_path = "D:\Appserv\www\Smarty\libs"   保存即可,这个是PHP的包含文件路径,可以设置多个,用";"格开。   2、载入Smarty库,如果在php.ini设置了include_path为D:\Appserv\www\Mysmarty\libs,那么可以直接用include("Smarty.class.php")

composer 多仓库

我的未来我决定 提交于 2019-11-28 14:53:20
存储库repositories说明 repositories 不会递归解析。您只能将它们添加到您的主要的composer.json。依赖项的存储库声明composer.json被忽略 多存储库范例: 详情参考: https://getcomposer.org/doc/05-repositories.md { "repositories": [ { "type": "composer", "url": "http://packages.example.com" }, { "type": "composer", "url": "https://packages.example.com", "options": { "ssl": { "verify_peer": "true" } } }, { "type": "vcs", "url": "https://github.com/Seldaek/monolog" }, { "type": "path", "url": "..\\packages\\package_name" }, { "type": "pear", "url": "https://pear2.php.net" }, { "type": "package", "package": { "name": "smarty/smarty", "version": "3.1.7",

PHP “Document Expired” after using the back button

痴心易碎 提交于 2019-11-28 13:03:00
问题 I have a form where I am filing some informations in a wizard. This page is reaching by POST and displayed with Smarty. Once I filed all the informations in, I am using another post to get to another page. Now, the problem is that when I am trying to go back with the BACK button, I am geting the "Document expired" message. Is than a normal thing while I am using POST or? I am trying right now to use GET but nothing changes, or my GET is written wrong. Here is a small schema: Page 1 -> POST ->

代码审计思路

拜拜、爱过 提交于 2019-11-28 12:59:08
两大审计的基本方法 1. 跟踪用户的输入数据,判断数据进入的每一个代码逻辑是否有可利用的点,此处的代码逻辑可以是一个函数,或者是条小小的条件判断语句。 2. 根据不同编程语言的特性,及其历史上经常产生漏洞的一些函数,功能,把这些点找出来,在分析函数调用时的参数,如果参数是用户可控,就很有可能引发安全漏洞 1、寻找漏洞前准备理解 理解现在的 cms 大致可分为两种,单入口模式和多入口模式 .   多入口模式 cms : 每一个功能都 需要访问不同的文件。   单入口模式的 cms : MVC的开发出来的 So ,挖掘漏洞方式   1、 搜索一些获取用户输入数据的函数,来找到用户输入数据的源头,之后我们从这里为起点,跟踪数据的流向,分析在这整个过程中数据的处理情况,进而定位可能触发漏洞的点。   2、 搜索一些经常产生安全问题的函数,比如执行数 据库查询的函数,执行系统命令的函数,文件操作类函数等等,在通过回溯这些函数在被调用时参数,判断参数是否我们可控,进而定位漏洞点。 常用的正则 PHP \$_SERVER|\$_COOKIE|\$_REQUEST|\$_GET|\$_POST 获取用户输入 eval\(|assert\(|system\( 命令执行 require\(|require_once\(|include\(|include_once\( 文件包含 file_get

500 Internal Server Error?

﹥>﹥吖頭↗ 提交于 2019-11-28 12:26:09
Recently, I put my project which is php+smarty+mysql in my httpd server. But I encountered an error that says: 500 Internal Server Error My OS is archlinux, and the httpd server and php were installed like this: sudo pacman -S apache php If I use a test native php file which contains the following: <html> <head> <title>PHP Test Page</title> </head> <body> This is Arch Linux, running PHP. <?php phpinfo(); ?> </body> </html> it runs correctly. It tells me that the php can work well. But why is my project with smarty not working? Is there any one who has encountered this problem? With the info