Heyas;
First post. Hope I get some help. I'm still learning PHP and am working on a CMS type project using the spaw controls. I'm having some difficulty, and was hoping that I could get some help. The little project I have going consists of two files; edit.php, and edit_template.php. I'll cut and paste...
NOTE: edit.php - the first part
<?
// this part determines the physical root of your website
// it's up to you how to do this
// if (!ereg('/$', $HTTP_SERVER_VARS['DOCUMENT_ROOT']))
// $root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'].'/';
// else
// $root = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
$_root = '/public_html/admin/';
$page = $_GET['page'];
define('DR', $root);
unset($root);
// set $spaw_root variable to path were control resides
// modify other settings in config/spaw_control.config.php
// namely $spaw_dir and $spaw_base_url most likely require your modification
$spaw_root = DR.'admin/spaw/';
// include the control file
@include $spaw_root.'spaw_control.class.php';
// set page filename
//$page = "home.php";
$page = $_GET['page'];
if (empty($page))
{
$page = 'home';
}
// set the $file variable (path + content file), using $page as the name of the content file
$file = "/public_html/admin/$page.php";
// check to see if submit was clicked, if so update or create the file
if ($HTTP_POST_VARS[Save])
{
// update the files
update_file($HTTP_POST_VARS, $file);
}
// otherwise get the content from the content file
read_file($file);
// include the editor
include("edit_template.php");
// FUNCTIONS ********************************************
function update_file($frm, $file)
// create or update file with new content from form
{
$page_file = fopen("$file", "w+");
fwrite($page_file, stripslashes($frm[spaw_content]));
fclose($page_file);
$_SESSION[system_message] = "Content Updated";
}
function read_file($file)
// read the file and put the content into $content
{
global $content;
$read = fopen($file, "r");
$content = fread($read, filesize($file));
fclose ($read);
return $content;
}
?>
NOTE: edit_template.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Admin</title>
<style type="text/css" media="screen">@import "styles/style.css";</style>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="en-us" />
</head>
<body>
<div id="menu">
<b>Pages</b><br>
<a href="http://www.insertdomainhere.com/admin/edit.php?page=home">Home Page</a><br>
<br />
</div>
<div id="content">
<h1>Content Management System</h1>
<h2></h2>
<br />
Editing: <? echo "$page"; ?>
<br />
<form name="edit_form" method="post" action="<?=$PHP_SELF?>?page=<?=$page?>">
<?
//$spaw_dropdown_data['style']['font_14'] = 'Font 14';
if ($page == "") {
?>
<< Click a page to the left.<br>
<?php
}
else {
$sw = new SPAW_Wysiwyg('spaw_content' /name/,stripslashes($content) /value/,
'en' /language/, 'full' /toolbar mode/, '' /theme/,
'550px' /width/, '300px' /height/, '' /stylesheet file/,
'' /dropdown data/);
$sw->show();
?>
<br />
<input name="Save" type="submit" id="Save" value="Save">
<?php
}
?>
</form>
</div>
</body>
</html>
Ok, so the problem errors I'm getting is as follows;
Warning: fopen(/public_html/admin/home.php.php): failed to open stream: No such file or directory in /home/resilien/public_html/admin/edit.php on line 70
Warning: filesize(): Stat failed for /public_html/admin/home.php.php (errno=2 - No such file or directory) in /home/resilien/public_html/admin/edit.php on line 71
Warning: fread(): supplied argument is not a valid stream resource in /home/resilien/public_html/admin/edit.php on line 71
Warning: fclose(): supplied argument is not a valid stream resource in /home/resilien/public_html/admin/edit.php on line 72
Pages
Home Page
Content Management System
Editing: home.php
Fatal error: Cannot instantiate non-existent class: spaw_wysiwyg in /home/resilien/public_html/admin/edit_template.php on line 60
The problem is, home.php DOES exist in the specified directory, as does the spaw_wysiwyg. The fopen, fclose, and fread functions are not working correctly. What have I done wrong? Could someone please help me by giving me some pointers?