Re: [SMARTY] Basic question
Howler <[email protected]>
| Newsgroups | gmane.comp.php.smarty.general |
|---|---|
| Message-ID | <[email protected]> |
Monte,
I am using Smarty 2.6.10 PHP 4.3.11 hosted by www.pronicsolutions.com
I clipped out line 180 in context.
/* loop through text blocks */
for ($curr_tb = 0, $for_max = count($text_blocks); $curr_tb <
$for_max; $curr_tb++) {
/* match anything resembling php tags */
if
(preg_match_all('~(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?php[\"\']?)~is',
$text_blocks[$curr_tb], $sp_match)) {
/* replace tags with placeholders to prevent recursive
replacements */
$sp_match[1] = array_unique($sp_match[1]);
usort($sp_match[1], '_smarty_sort_length');
for ($curr_sp = 0, $for_max2 = count($sp_match[1]);
$curr_sp < $for_max2; $curr_sp++) {
LINE 180 ------> $text_blocks[$curr_tb] =
str_replace($sp_match[1][$curr_sp],'%%%SMARTYSP'.$curr_sp.'%%%',$text_blocks[$curr_tb]);
}
/* process each one */
for ($curr_sp = 0, $for_max2 = count($sp_match[1]);
$curr_sp < $for_max2; $curr_sp++) {
if ($this->php_handling == SMARTY_PHP_PASSTHRU) {
/* echo php contents */
$text_blocks[$curr_tb] =
str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '<?php echo
\''.str_replace("'", "\'", $sp_match[1][$curr_sp]).'\'; ?>'."\n",
$text_blocks[$curr_tb]);
} else if ($this->php_handling == SMARTY_PHP_QUOTE) {
/* quote php tags */
$text_blocks[$curr_tb] =
str_replace('%%%SMARTYSP'.$curr_sp.'%%%',
htmlspecialchars($sp_match[1][$curr_sp]), $text_blocks[$curr_tb]);
} else if ($this->php_handling == SMARTY_PHP_REMOVE) {
/* remove php tags */
$text_blocks[$curr_tb] =
str_replace('%%%SMARTYSP'.$curr_sp.'%%%', '', $text_blocks[$curr_tb]);
} else {
/* SMARTY_PHP_ALLOW, but echo non php starting
tags */
$sp_match[1][$curr_sp] =
preg_replace('~(<\?(?!php|=|$))~i', '<?php echo \'\\1\'?>'."\n",
$sp_match[1][$curr_sp]);
$text_blocks[$curr_tb] =
str_replace('%%%SMARTYSP'.$curr_sp.'%%%', $sp_match[1][$curr_sp],
$text_blocks[$curr_tb]);
}
}
}
}
Monte Ohrt wrote:
> no, wrong file. try Smarty_Compiler.class.php
>
> also, what is your smarty and php versions?
>
> Howler wrote:
>
>> Its a comment line, so my guess is that the real culprit is line 178.
>>
>> 169 /**
>> 170 * This is the number of seconds cached content will persist.
>> 171 * <ul>
>> 172 * <li>0 = always regenerate cache</li>
>> 173 * <li>-1 = never expires</li>
>> 174 * </ul>
>> 175 *
>> 176 * @var integer
>> 177 */
>> 178 var $cache_lifetime = 3600;
>> 179
>> 180 /**
>> 181 * Only used when $caching is enabled. If true, then
>> If-Modified-Since headers
>> 182 * are respected with cached content, and appropriate HTTP
>> headers are sent.
>> 183 * This way repeated hits to a cached page do not send the entire
>> page to the
>> 184 * client every time.
>> 185 *
>> 186 * @var boolean
>> 187 */
>> 188 var $cache_modified_check = false;
>>
>>
>>
>>
>>
>>
>>
>> Monte Ohrt wrote:
>>
>>
>>
>>> what does line 180 look like?
>>>
>>>
>>>
>>> Howler wrote:
>>>
>>>
>>>
>>>> Monte,
>>>>
>>>> Thanks, that turned off the |magic_quotes_runtime but I am still
>>>> getting
>>>> the error. :-/|
>>>>
>>>> *Warning*: Unexpected character in input: '\' (ASCII=92) state=1 in
>>>> */home/vomramha/smarty/Smarty_Compiler.class.php* on line *180*
>>>>
>>>> *Parse error*: parse error, unexpected ')', expecting ',' or ';' in
>>>> */home/myhomedir/smarty/Smarty_Compiler.class.php* on line *180*
>>>>
>>>>
>>>>
>>>> Monte Ohrt wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> http://www.phpinsider.com/smarty-forum/viewtopic.php?t=4936
>>>>>
>>>>> Howler wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> The line:
>>>>>>
>>>>>> ini_set('magic_quotes_gpc',0);
>>>>>>
>>>>>> Doesn't seem to turn off magic_quotes, perhaps this is something
>>>>>> that
>>>>>> needs to be set in the php.ini. I don't have access to the global
>>>>>> php.ini, but my understanding is that the script will look in the
>>>>>> current directory for a php.ini, then wwwroot, and then the global
>>>>>> position. Is this correct? My hosting service provider put a
>>>>>> copy of
>>>>>> php.ini in my directory for me, and I turned off magic_quotes in
>>>>>> it, but
>>>>>> still no joy.
>>>>>>
>>>>>> Thanks,
>>>>>> John
>>>>>>
>>>>>>
>>>>>> Monte Ohrt wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> I think so, see the PHP docs.
>>>>>>>
>>>>>>> Howler wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Monte,
>>>>>>>>
>>>>>>>> Thanks, is this something that I can turn off via ini_set()?
>>>>>>>>
>>>>>>>>
>>>>>>>> Monte Ohrt wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> A hunch, turn off PHP magic quotes?
>>>>>>>>>
>>>>>>>>> Howler wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Hello Everyone,
>>>>>>>>>>
>>>>>>>>>> I apologize in advance as I am sure that this question has been
>>>>>>>>>> answered
>>>>>>>>>> before. I have searched through mail lists and news groups and
>>>>>>>>>> have
>>>>>>>>>> not
>>>>>>>>>> found a satifactory answer.
>>>>>>>>>>
>>>>>>>>>> I am still pretty new to PHP/Smarty so please be patient.
>>>>>>>>>>
>>>>>>>>>> I have installed Smarty to my Linux hosting server. I
>>>>>>>>>> installed it
>>>>>>>>>> outside of the www directory per the recommendations.
>>>>>>>>>> /www
>>>>>>>>>> |_______>myappstuff
>>>>>>>>>> |_______>lib
>>>>>>>>>> .
>>>>>>>>>> .
>>>>>>>>>> .
>>>>>>>>>> /Smarty
>>>>>>>>>> |_____> internals
>>>>>>>>>> |_____>plugins
>>>>>>>>>> |_____>myappstuff
>>>>>>>>>> | |________>cache
>>>>>>>>>> | |________>configs
>>>>>>>>>> | |________>templates
>>>>>>>>>> | |________>templates_c
>>>>>>>>>> |
>>>>>>>>>> |
>>>>>>>>>> |________________>Config_file.class.php
>>>>>>>>>> |________________>debug.tpl
>>>>>>>>>> |________________>Smarty.class.php
>>>>>>>>>> |________________>Smarty_Compiler.class.php
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> I set the path using the ini_set and I can find the
>>>>>>>>>> Smarty.class.php
>>>>>>>>>> without issue, what seems to be the problem is that when my PHP
>>>>>>>>>> code
>>>>>>>>>> performs the $smSmarty->display('index.tpl'); I get the
>>>>>>>>>> following
>>>>>>>>>> error:
>>>>>>>>>>
>>>>>>>>>> =================
>>>>>>>>>>
>>>>>>>>>> *Warning*: Unexpected character in input: '\' (ASCII=92)
>>>>>>>>>> state=1 in
>>>>>>>>>> */home/vomramha/smarty/Smarty_Compiler.class.php* on line *180*
>>>>>>>>>>
>>>>>>>>>> *Parse error*: parse error, unexpected ')', expecting ',' or
>>>>>>>>>> ';' in
>>>>>>>>>> */home/myhomedir/smarty/Smarty_Compiler.class.php* on line *180*
>>>>>>>>>>
>>>>>>>>>> ==================
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> I believe that I have the permissions set correctly but I am not
>>>>>>>>>> sure,
>>>>>>>>>> it could be something that I missed in my code.
>>>>>>>>>>
>>>>>>>>>> ==================
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> index.php
>>>>>>>>>>
>>>>>>>>>> <?php
>>>>>>>>>>
>>>>>>>>>> ini_set
>>>>>>>>>> ('include_path',".:/usr/lib/php:/usr/local/lib/php:/home/myhomedir/smarty");
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> require_once ('Smarty.class.php');
>>>>>>>>>> require_once ('lib/my_dbconnect.php');
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> $smSmarty = new Smarty;
>>>>>>>>>>
>>>>>>>>>> $smSmarty->compile_check = true;
>>>>>>>>>> $smSmarty->debugging = true;
>>>>>>>>>>
>>>>>>>>>> $smSmarty->template_dir =
>>>>>>>>>> '/home/myhomedir/www/myappstuff/templates/';
>>>>>>>>>> $smSmarty->compile_dir =
>>>>>>>>>> '/home/myhomedir/www/myappstuff/templates_c/';
>>>>>>>>>> $smSmarty->cache_dir =
>>>>>>>>>> '/home/myhomedir/www/myappstuff/cache/';
>>>>>>>>>> $smSmarty->config_dir =
>>>>>>>>>> '/home/myhomedir/www/myappstuff/configs/';
>>>>>>>>>> $smSmarty->force_compile = true;
>>>>>>>>>>
>>>>>>>>>> $smSmarty->assign('Name', 'Joe');
>>>>>>>>>>
>>>>>>>>>> if ($smSmarty->template_exists('index.tpl'))
>>>>>>>>>> {
>>>>>>>>>> if(!$smSmarty->is_cached('index.tpl'))
>>>>>>>>>> {
>>>>>>>>>> $smSmarty->display('index.tpl');
>>>>>>>>>> }
>>>>>>>>>> }
>>>>>>>>>> else
>>>>>>>>>> {
>>>>>>>>>> $smSmarty->display('debug.tpl');
>>>>>>>>>> phpinfo();
>>>>>>>>>> }
>>>>>>>>>> ?>
>>>>>>>>>>
>>>>>>>>>> index.tpl
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> <html>
>>>>>>>>>> <head>
>>>>>>>>>> <title>My Smarty test App</title>
>>>>>>>>>> </head>
>>>>>>>>>>
>>>>>>>>>> <body>
>>>>>>>>>> This is a test: {$Name}
>>>>>>>>>> </body>
>>>>>>>>>> </html>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> ==================
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> index.php does find the template and executes the correct code,
>>>>>>>>>> however
>>>>>>>>>> when the line:
>>>>>>>>>>
>>>>>>>>>> $smSmarty->display('index.tpl');
>>>>>>>>>>
>>>>>>>>>> is executed I get the error.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Any assistance would be greatly appreciated.
>>>>>>>>>>
>>>>>>>>>> Thanks in advance!
>>>>>>>>>> John
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
>
>
>
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php