JonnyH
October 15th, 2007, 12:31
I'm basically writing this script which when entered <%CONTENT%> on the HTML get what it needs etc. Here's the code:
$tpl = preg_replace("/<%CONTENT%>/si", $this->c_eval($this->e_array($this->content())), $tpl);
The three functions:
//Get's any content/plugin requested by user
function content()
{
if ($this->service == "0")
{
switch ($_GET['page'])
{
default:
if (!$_GET['page'])
{
header("Location:" . $this->config("default"));
} else
{
if (file_exists("style/" . $this->style . "/content_top.tpl") && file_exists("style/" .
$this->style . "/content_bottom.tpl"))
{
$cont = "<div id=\"contentcontainer\">";
$cont .= file_get_contents("style/" . $this->style . "/content_top.tpl");
} else
{
#echo "Hello";
$cont = array();
return $cont;
}
$page = strtolower($_GET['page']);
if (!file_exists("plugins/" . $page . "/main.php"))
{
$this->name("Doesn't Exist");
$cont .= "Sorry that page currently doesn't exist.";
} else
{
$cont .= file_get_contents("plugins/" . $page . "/main.php");
}
$cont .= file_get_contents("style/" . $this->style . "/content_bottom.tpl");
$cont .= "</div>";
$return[] = $cont;
return $return;
}
break;
}
} else
{
$cont[] = "<div id=\"contentcontainer\">";
$cont[] .= file_get_contents("style/" . $this->style . "/content_top.tpl");
$cont[] .= "<h2>Service Mode</h2>";
$cont[] .= "<title>" . $this->sitename . " » Service Mode</title>";
$cont[] .= "The website currently is in Service Mode.";
$cont[] .= file_get_contents("style/" . $this->style . "/content_bottom.tpl");
$cont[] .= "</div>";
return $cont;
}
}
//Eval's any php code and returns it
function c_eval($var)
{
eval('?>' . $var . '<?php ');
}
//Sets it out for the HTML return
function e_array($array)
{
foreach ($array as $value)
{
$bar .= $value;
}
return $bar;
}
The code works but doesn't return it. I need it to eval the code and return it to the content. If it doesn't, it looks like this:
http://kwix-host.com/site/
$tpl = preg_replace("/<%CONTENT%>/si", $this->c_eval($this->e_array($this->content())), $tpl);
The three functions:
//Get's any content/plugin requested by user
function content()
{
if ($this->service == "0")
{
switch ($_GET['page'])
{
default:
if (!$_GET['page'])
{
header("Location:" . $this->config("default"));
} else
{
if (file_exists("style/" . $this->style . "/content_top.tpl") && file_exists("style/" .
$this->style . "/content_bottom.tpl"))
{
$cont = "<div id=\"contentcontainer\">";
$cont .= file_get_contents("style/" . $this->style . "/content_top.tpl");
} else
{
#echo "Hello";
$cont = array();
return $cont;
}
$page = strtolower($_GET['page']);
if (!file_exists("plugins/" . $page . "/main.php"))
{
$this->name("Doesn't Exist");
$cont .= "Sorry that page currently doesn't exist.";
} else
{
$cont .= file_get_contents("plugins/" . $page . "/main.php");
}
$cont .= file_get_contents("style/" . $this->style . "/content_bottom.tpl");
$cont .= "</div>";
$return[] = $cont;
return $return;
}
break;
}
} else
{
$cont[] = "<div id=\"contentcontainer\">";
$cont[] .= file_get_contents("style/" . $this->style . "/content_top.tpl");
$cont[] .= "<h2>Service Mode</h2>";
$cont[] .= "<title>" . $this->sitename . " » Service Mode</title>";
$cont[] .= "The website currently is in Service Mode.";
$cont[] .= file_get_contents("style/" . $this->style . "/content_bottom.tpl");
$cont[] .= "</div>";
return $cont;
}
}
//Eval's any php code and returns it
function c_eval($var)
{
eval('?>' . $var . '<?php ');
}
//Sets it out for the HTML return
function e_array($array)
{
foreach ($array as $value)
{
$bar .= $value;
}
return $bar;
}
The code works but doesn't return it. I need it to eval the code and return it to the content. If it doesn't, it looks like this:
http://kwix-host.com/site/