Location: PHPKode > projects > Wiki Web Help > wwh/handlers/editsave.php
<?php
require_once("../config.php");
require_once("../class/revision.class.php");

$page = $_POST['id'];
if(!is_numeric($page)) exit; // something's wrong

$text = $_POST['text']; // prepare for database
$user = $_POST['user'];
$uid = $_POST['uid'];
$ip = $_POST['ip'];
$comment =$_POST['comment'];
$path = $_POST['path'];
if($path != ''){
	
	// create a new page from the path.
	require_once("../class/node.class.php");
	$NodeHandler = new Node($con,$_POST['lang']);
	$NodeHandler->position = 'in';
	$NodeHandler->comment = '';
	$NodeHandler->setUid($uid);
	$NodeHandler->name = $NodeHandler->PageFromPath($path); 
	$NodeHandler->target = $NodeHandler->ParentFromPath($path); // parent id
	$NodeHandler->ip=$_SERVER['REMOTE_ADDR'];
	$NodeHandler->NewNode(); // add the new node
	$NodeHandler->UpdateHistory('add'); // update
	$page = $NodeHandler->NodeFromPath($path); //
	$NodeHandler->Subscriptions($CFG_RETURN_ADDRESS, $action); 

}


$sql = "SELECT page_text,label FROM page INNER JOIN node ON page.node_id=node.node_id WHERE page.node_id=$page";
$result = mysql_query($sql,$con) or die("Database Error - Unable to save page.");
$from = addslashes(mysql_result($result,0,'page_text')); // they get removed when selected
$label = mysql_result($result,0,'label');

$sql = "UPDATE page SET page_text='$text' WHERE node_id=$page";
$result = mysql_query($sql,$con) or die("Database Error - Unable to save page.");

$sql = "SELECT page_text FROM page WHERE node_id=$page";
$result = mysql_query($sql,$con) or die("Database Error - Unable to save page.");
$to = addslashes(mysql_result($result,0,'page_text'));

// TODO: can this be done without updated then comparing?
if($to==$from){ // no need for history
	include('getpage.php');
	exit;
}

// revision
$rev = new Revision($con,$page,$uid,$CFG_RETURN_ADDRESS);
$rev->save($from,'page',$comment,$to);

include('getpage.php');
?>

Return current item: Wiki Web Help