PHP in templates

Download plugins, language packs and stuff.

Still won't work

Postby snatch518 » Mon Jun 23, 2008 6:02 pm

After enabling the script, my template still will not display PHP.

Here's the code I'm using:

Code: Select all
<?php include("/home/wrestl76/public_html/news/latest_news.php"); ?>


Any idea as to why this won't display?
snatch518
 
Posts: 8
Joined: Sat Jun 07, 2008 6:29 am

Php in Templates

Postby daves » Wed Sep 03, 2008 8:58 am

Hi

Does this plugin work with the latest version of Cutenews.RU cos I cannot get it to call a php function using

<php functionname(); ?>

Thanks for any help
daves
 
Posts: 1
Joined: Wed Sep 03, 2008 8:55 am

Postby flesh » Fri Sep 19, 2008 9:03 am

I am trying to use this code ...

Code: Select all

<?php
if ({phpbbname}=="Anonymous"){
?>
<iframe src="login.php" name="iframe" frameborder="0" scrolling="auto" width="100%" height="270px"></iframe>

<?php
   return;
}
?>

why isn't it working ...
flesh
 
Posts: 103
Joined: Sat Mar 04, 2006 3:51 pm
Location: Poland

Postby flesh » Fri Sep 19, 2008 9:28 am

or this :

Code: Select all
<?
if ({phpbbact}>0)
{
echo 'Comment form';
}
else
{
echo 'Login form';

}

?>

I've added this {phpbbact} and it is 1 when the user is active and 0 when it is not active ... but why is it not working ...
when I test it it shows
Code: Select all
0) { echo 'comment form'; } else { echo 'login form'; } ?>
flesh
 
Posts: 103
Joined: Sat Mar 04, 2006 3:51 pm
Location: Poland

Postby FI-DD » Thu Sep 25, 2008 5:52 pm

A quotation from the first page:
Make sure you use the full PHP tags: <?php echo 'blahblah'; ?>

This won't work: <? echo 'blahblah'; ?>
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby flesh » Fri Sep 26, 2008 12:14 pm

FI-DD wrote:A quotation from the first page:
Make sure you use the full PHP tags: <?php echo 'blahblah'; ?>

This won't work: <? echo 'blahblah'; ?>

I actually did it this way:
Code: Select all
<?php
if ({phpbbact}==1)
{
echo "comment form";
}
else
{
echo "login form";

}

?>

it shows nothing ...
flesh
 
Posts: 103
Joined: Sat Mar 04, 2006 3:51 pm
Location: Poland

Postby flesh » Fri Sep 26, 2008 12:34 pm

Do I have to do all this stuff http://www.xs4all.nl/~cvdtak/phpintemplates_1.2.htm
with replacing and adding code or I just have to add the php-in-templates.php file in the plugins folder and to activate it ?

for me is not working even
Code: Select all
<?PHP echo "login form"; ?>
flesh
 
Posts: 103
Joined: Sat Mar 04, 2006 3:51 pm
Location: Poland

Postby flesh » Fri Sep 26, 2008 1:20 pm

Ok I did it this way
copy in inc/show.commentform.php:

$output = preg_replace_callback('/<\\?php(.*?)\\?>/is', 'phpTemplateEval', $output);

and now it is working ... sorry for bothering
flesh
 
Posts: 103
Joined: Sat Mar 04, 2006 3:51 pm
Location: Poland

Postby flesh » Sat Sep 27, 2008 8:53 am

OK now I can use PHP in the templates but it is not working this code:

Code: Select all
<?PHP
if ({phpbbact}==1)
{ echo '<input type="hidden" id="name" type="text" size="20" name="name" tabindex="1" value="{phpbbname}" /><br /><label for="mail"><input type="hidden" id="mail" type="text" size="20" name="mail" tabindex="2" value="{phpbbavatar}" /></label><br />{smilies}<br /><textarea cols="50" rows="8" name="comments" tabindex="3"></textarea><br /><input class="input" type="submit" tabindex="4" name="submit" value="Leave a comment" /><br/>';}
else
{
echo '<form action="login2.php" method="post" style="margin: 0px;"><input type="hidden" name="redirect" value="indexsite" /><input type="hidden" name="redirect" value="../r.html" /><table border="0" style="font-size:12px;" width="130" cellspacing="0" cellpadding="0"><tr><td class="left" height="25"><b>User:</b></td></tr><tr>
<td class="left" height="25">
<input type="text" name="username" size="10" maxlength="25">
</td>
</tr>
<tr>
<td class="left" height="25">
<b>Password:</b>
</td>
</tr>
<tr>
<td class="left" height="25">
<input type="password" name="password" size="10" maxlength="25">
</td>
</tr>
<tr>
<td class="left" height="35">
<input type="submit" name="login" value="Login">
</td>
</tr>
</table>
</form>
';} ?>


When I change the first echo with something else (for example echo "lala";) it works ... so the problem I have is in the first echo ...
The first echo is with the comment form ... it is like this:
Code: Select all
<input type="hidden" id="name" type="text" size="20" name="name" tabindex="1" value="{phpbbname}" /><br /><label for="mail"><input type="hidden" id="mail" type="text" size="20" name="mail" tabindex="2" value="{phpbbavatar}" /></label><br />{smilies}<br /><textarea cols="50" rows="8" name="comments" tabindex="3"></textarea><br /><input class="input" type="submit" tabindex="4" name="submit" value="Leave a comment" /><br/>


it sows me this error:
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting ',' or ';' in /php-in-templates.php(28) : eval()'d code on line 2

what is wrong with this comment form code ... do I have to add <form> tag and if I have to ... what to write in it ...
I don't have an idea :(
flesh
 
Posts: 103
Joined: Sat Mar 04, 2006 3:51 pm
Location: Poland

Postby FI-DD » Fri Oct 03, 2008 9:24 am

flesh wrote:When I change the first echo with something else (for example echo "lala";) it works ... so the problem I have is in the first echo ...

Then add your echo code word by word and check the result after each word. That way you will find out what's causing the error.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby azn_romeo_4u » Mon Oct 20, 2008 5:49 pm

Quick question where do you put this file in? The plugin folder and it should work asap?
azn_romeo_4u
 
Posts: 123
Joined: Thu Sep 18, 2008 5:06 am

Postby FI-DD » Fri Oct 24, 2008 2:49 pm

It should work after activation.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby jackavin » Wed Mar 25, 2009 12:57 pm

FI-DD can i have php in comment and comment from

Code: Select all
<?php
/*
Plugin Name:   Eval
Plugin URI:     http://www.xs4all.nl/~cvdtak/phpintemplates_1.2.htm
Description:   Use PHP in templates.
Application:    Cutenews
Author:         cvdtak
Author URI:      http://www.xs4all.nl/~cvdtak/
*/

add_filter('news-entry', 'php_in_template');
add_filter('news-comment', 'comment_in_template');

function php_in_template($output){

    $output = preg_replace_callback('/<\\?php(.*?)\\?>/is', 'phpTemplateEval', $output);

return $output;
}

function comment_in_template($output){

    $output = preg_replace_callback('/<\\?php(.*?)\\?>/is', 'phpTemplateEval2', $output);

return $output;
}

#-------------------------------------------------------------------------------

function phpTemplateEval($match){

   $match[1] = replace_news('admin', $match[1]);
   $match[1] = str_replace('<br />', '', $match[1]);

   ob_start();
      eval($match[1]);
   return ob_get_clean();
}

function phpTemplateEval2($match){

   $match[1] = replace_comment('admin', $match[1]);
   $match[1] = str_replace('<br />', '', $match[1]);

   ob_start();
      eval($match[1]);
   return ob_get_clean();
}
?>


can u fix this thx
jackavin
 
Posts: 53
Joined: Wed Oct 01, 2008 7:21 pm

Postby FI-DD » Wed Apr 08, 2009 2:51 pm

Why do you want to allow visitors to execute php code? I think that's quite dangerous. :shock:
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby Hawk » Wed Apr 08, 2009 2:55 pm

Very dangerous... quite sure you'll get suspended very shortly by your host when "weird" files start running off from your webspace. I wouldn't recommend that.
User avatar
Hawk
 
Posts: 248
Joined: Tue Aug 29, 2006 9:00 pm

PreviousNext

Return to Additional Downloads



Who is online

Users browsing this forum: No registered users and 0 guests

cron