Is this possible somehow? I have allready made a page which includes a code to get the template from the database. But would it somehow be possible to include PHP functions in the database? I really need to know if this is possible, if so. How Really need this.
I'm not quite sure I understand what you mean and I'm not sure why you would do this. Why not just include a functions file instead of storing PHP code in your database? <?php include_once(DIRNAME(__FILE__).'/includes/functions.php'); if(!function_exists('my_function')) { //do nothing } else { //do something } PHP:
Cause I am trying to make a template system for my script. Like this page: <?php//This file cannot be viewed, it must be includeddefined('IN_EZRPG') or exit; /* Class: Module_Terms This is a very simple module, designed to simply display a static template page.*/class Module_Terms extends Base_Module{ /* Function: start Displays the terms.tpl template. That's all! */ public function start() { //Require the user to be logged in // OFF requireLogin(); $con = mysql_connect("HOST","USER","PASS");if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("DATABASE", $con); $result = mysql_query("SELECT * FROM templates WHERE id='1'"); while($row = mysql_fetch_array($result)) { echo $row['terms']; } mysql_close($con); }}?> PHP: Uses this template, which is inside the database: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta name="Description" content="ezRPG Project, the free, open source browser-based game engine!" /><meta name="Keywords" content="ezrpg, game, game engine, pbbg, browser game, browser games, rpg, ezrpg project" /><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><meta name="Distribution" content="Global" /><meta name="Robots" content="index,follow" /><link rel="stylesheet" href="static/snowie/style.css" type="text/css" /> <title>ezRPG :: {$TITLE|default:""}</title><script type="text/javascript" src="count.js"></script> </head><body> <div id="wrapper"> <div id="header"> <span id="title">ezRPG</span> <span id="time">{$smarty.now|date_format:'%A %T'} <br /> <strong>Players Online</strong>: {$ONLINE}</span></div> <div id="container"> <div id="nav"> <ul> {if $LOGGED_IN == 'TRUE'} <li><a href="index.php">Home</a></li> <li><a href="index.php?mod=EventLog">Log</a></li> <li><a href="index.php?mod=City">City</a></li> <li><a href="index.php?mod=Members">Members</a></li> <li><a href="index.php?mod=AccountSettings">Account</a></li> <li><a href="index.php?mod=Logout">Log Out</a></li> {else} <li><a href="index.php">Home</a></li> <li><a href="index.php?mod=Register">Register</a></li> {/if} </ul></div> <span class="space"></span> {if $LOGGED_IN == 'TRUE'}<div id="sidebar"><img src="images/avatars/{$player->avatar}.png"><strong>Level</strong>: {$player->level}<br /><strong>Gold</strong>: {$player->money}<br /><strong>Diamonds</strong>: {$player->diamonds}<br /> <span id="count" class="timeClass"></span><DIV onMouseover="ddrivetip('This DIV has a tip!', '#EFEFEF')"; onMouseout="hideddrivetip()">Some text here. Some text here.</div><img src="bar.php?width=140&type=exp" alt="EXP: {$player->exp} / {$player->max_exp}" /><br /><img src="bar.php?width=140&type=hp" alt="HP: {$player->hp} / {$player->max_hp}" /><br /><img src="bar.php?width=140&type=energy" alt="Energy: {$player->energy} / {$player->max_energy}" /><br /> {if $new_logs > 0}<a href="index.php?mod=EventLog" class="red"><strong>{$new_logs} New Log Events!</strong></a>{/if}</div>{/if} <div id="{if $LOGGED_IN == 'TRUE'}gamebody{else}body{/if}"> {if $GET_MSG != ''}<div class="msg"> <span class="red"><strong>{$GET_MSG}</strong></span> </div> <span class="space"></span>{/if} PHP: And when I do this the functions on the page doesn't work because they was inside the template in the database. What is why I need this. Demo: http://www.ezrpg.apps.gamerstick.com/index.php?mod=terms NOTE: I am willing to pay if someone can help me solved this
Right, so why don't you store the include in the database that includes the functions? When you update your database with the code, add a line somewhere: <?php include_once(DIRNAME(__FILE__).'/functions.php') ?> PHP:
The reason I need it to be inside the database is that I am trying to do so the script admin can change the design from their Admin Panel which makes it possible to edit inside the database. Hope you understand me.
Yeah, I understand. I don't see why you don't just include the functions file in the database as well?
<div id="{if $LOGGED_IN == 'TRUE'}gamebody{else}body{/if}"> {if $GET_MSG != ''}<div class="msg"> <span class="red"><strong>{$GET_MSG}</strong></span> </div> <span class="space"></span>{/if} PHP: isn't proper PHP, so the "functions" (which are just HTML because you have no PHP tags) aren't going to "work". Try <div id="<?php if($LOGGED_IN === 'TRUE') { echo 'gamebody'; } else { echo 'body'; } ?>"><?php if($GET_MSG != '') { echo '<div class="msg"><span class="red"><strong>'.$GET_MSG.'</strong></span> </div> <span class="space"></span>'; } PHP: The same for the rest of the data.
Well. I still had no luck for some reason. What about making a include function to the page. Which includes a lot of strings. Like a string called header. Which should get the input from the database. Then the PHP commands could be run as a string, is it possible? Would that be possible somehow?