Post: OOP Template Editor
07-19-2012, 01:13 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); editPage.php
    <html>
<form action="" method="Get">
<select name="id">
<option value="noneselected" selected="ns">None Selected</option>
<option value="index">Index</option>
<option value="register">Register</option>
</select>
<input type="submit" value="Edit" />
</form>
</html>
<?php
include("system/templates/Template_editor.php");
$id = $_GET['id'];
$template->edit_templates($id);
$template->update_templates($id);

?>





system/templates/Template_editor.php
    
<?php


class Template
{


function get_templates()
{

}

function edit_templates($id)
{
$filename = $id;
if ($filename != ''Winky Winky {
$fh = fopen("view/templates/" . $filename . ".php", "r") or die("Could not open the template!");
$data = fread($fh, filesize("view/templates/" . $filename . ".php")) or die("Could not read the template");
fclose($fh);
echo "<center><form action='$_SERVER[php_self]' method= 'post' ><textarea name='update' cols='150%' rows='20'>$data</textarea>
<input name='id' type='hidden' value='" .$filename. "'/><input type='submit' value='Change'></form></center>";
$this->update_templates($filename);

}

}

function update_templates($id)
{

$newdata = $_POST['update'];
$filename = $_POST['id'];
if ($filename != ''Winky Winky {
$fw = fopen("view/templates/" . $filename . ".php", 'w'Winky Winky or die('Could not open the template!'Winky Winky;
$fb = fwrite($fw, stripslashes($newdata)) or die('Could not update your template'Winky Winky;
fclose($fw);
?>
<META HTTP-EQUIV=Refresh CONTENT="1">
<?php
}
}

}

$template = new Template;

?>
(adsbygoogle = window.adsbygoogle || []).push({});
07-19-2012, 01:17 PM #2
Nice job man, you should really code another forum, I think it will turn out brilliant! Smile
07-19-2012, 01:20 PM #3
Originally posted by LEzStarz View Post
Nice job man, you should really code another forum, I think it will turn out brilliant! Smile


I know, I might do one in my spare time, but I've been doing my site below :P

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo