Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

108 users online



php code parser question

php code parser question

Currently viewing this thread: 1 (0 members and 1 guests)


Page 1 out of 2
DigitalDream

DigitalDream

ruby on weapon
Status: Offline!

php code parser question

im having a trouble again. im creating a table in my databases to store my websites template.
i've write the class for calling the template from the database and everything work fine until i found out that:
any php code inside the template wont be parsed!
in example, i create a template named "head" like this:

PHP:

<?php

<html>
<
title>$title</title>
$usecss
$metacode
</head>
<
body>

?>


then i call the template with:

PHP:

<?php

$skin
->maketmp("head");

?>

it didnt output the value of the variable. instead, the variables still as is.
i've try using eval() or \$ but neither are work.
is there anybody can help me?
thanks much and sorry for the english

___________________

digitalDream // complete Webdesign solution //
- - - - - - [ end signature ] - - - - - -

no3o5

no3o5

Neverside Newbie
Status: Offline!
PHP:

<?php

<html>
<
title><?php $title?></title>
<?php
$usecss
$metacode
?>
</head>
<body>

?>


else it will think it's html output not php

Last edited by no3o5, April 18th, 2005 03:19 PM (Edited 1 times)

DigitalDream

DigitalDream

ruby on weapon
Status: Offline!

ok thanks for the answer. though i think it's not gonna work.
but why must we using <? and ?> ? templates in vBulletin didnt required <? and ?> if there's a php code inside.
ill give it a shot though

___________________

digitalDream // complete Webdesign solution //
- - - - - - [ end signature ] - - - - - -

shufty

shufty

wibble bl00p
Status: Offline!

maybe try

PHP:

<?php
print ('
<html>
<title>'
.$title.'</title>
'
.$usecss
$metacode
.'
</head>
<body>
'
);
?>

Andy

Andy

Neverside Newbie
Status: Offline!
PHP:

<?php

print <<<EOF
<html>
<title>$title</title>
$usecss
$metacode
</head>
<body>
EOF;

?>

Should also work if you'd like to keep the html a little more tidy

I havn't used that in a while, but should still work.

___________________

Andy

BigToach

BigToach

Neversidian
Status: Offline!

just take away the top <?php and bottom ?> then do something like

PHP:

<?php

$var 
'print <<<EOF
'
$skin->maketmp("head").'
EOF;'
;
eval(
$var);

?>


Although i disagree with this method, it will work.

there are security risks with this, so doube, triple, and quadruple check the variables that are in your templates, and any data that a user submits

___________________

Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

Phil

Phil

with Mr. Jones
Status: Offline!

Whitelist user input, not blacklist.

IE, define what is OK, not whats not.

Say this must be an integer

rather then

Must not be a string or special characters or hex or or or

___________________

http://www.philbrodeur.com - Expert PHP Development and Tutorials

DigitalDream

DigitalDream

ruby on weapon
Status: Offline!

thanks all. i'll give it a try soon
i still dont understand why vbulletin can make it so easy

___________________

digitalDream // complete Webdesign solution //
- - - - - - [ end signature ] - - - - - -

BigToach

BigToach

Neversidian
Status: Offline!

they eval the values like i said afaik

___________________

Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

DigitalDream

DigitalDream

ruby on weapon
Status: Offline!

here is my template.php

PHP:

<?php

class template
{
    var 
$tmpname;
    
    function 
maketmp($name)
    {
        
$sql mysql_query("SELECT * from template where tmpname = '$name'");
        while(
$tp=mysql_fetch_array($sql))
        {
            
$blah $tp["template"];
            echo 
$blah;
        }
    }

    function 
get($name)
    {
        include 
"../tpl/"$name .".inc";
    }
}

$skin = new template;

?>

and this is my index.php where i call the template

PHP:

<?php

if(is_logged_in())
{
    
# show content here
    
switch($_GET["t"])
    {
        case 
'root':
        
$var 'print <<<EOF
        '
$skin->maketmp("admin_index_root").'
        EOF;'
;
        eval(
$var);
        break;
    }
}

?>

and the template of admin_index_root :

PHP:

<?php

<div class="logodiv"><img src="../img/logotop.jpg" alt="kioku.NET" /><img src="../img/top.jpg" /></div>
    <
div class="bgdiv">
    
    <!-- 
left table -->
    <
div class="left">
        <
div class="category"><img src="../img/journal.gif" /></div>
        <!-- 
display news -->
        <
div class="newstitle">testttttttt</div>
        <
class="newstext">
        
bla bla testing 1 2 3</p>
        <!-- 
end display news -->
    </
div>
    <!-- 
end left table -->
    <!-- 
right table -->
    <
div class="right">
        <
div class="category" style="margin-bottom: 7px;"><img src="../img/navigation.gif" /></div>
        
$objlink = new alink();
        
$objlink->newlink("main page""index.fx""""nav");
        
$objlink->newlink("portfolio""porto.fx""""nav");
        
$objlink->newlink("showcase""showcase.fx""""nav");
        
$objlink->newlink("respected""index.fx?bring=link""""nav");
        
$objlink->newlink("contact me""index.fx?bring=contact""""nav");
        <
br /><br />
        <
div class="category"><img src="../img/news.gif" /></div>
    </
div>
    <!-- 
end right table -->
    
    </
div>
    <
div class="logodiv"><img src="../img/bottom.jpg" /></div>

?>

didnt work for me. maybe there's something wrong with my codes? if anyone can fix it, i'll be very happy
thanks

___________________

digitalDream // complete Webdesign solution //
- - - - - - [ end signature ] - - - - - -

Last edited by DigitalDream, April 19th, 2005 10:21 AM (Edited 1 times)

Page 1 out of 2
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.012 seconds.