Location: PHPKode > projects > Wiki Web Help > wwh/handlers/editpage.php
<?php
require_once("../config.php");
include('language.php'); 
include('buttons.php'); 

$page = $_GET['id'];
if(!is_numeric($page)) exit;

$clip = $_GET['clip'];
$admin = $_GET['admin'];
$loggedon = isset($_GET['loggedon']) ? $_GET['loggedon'] : '';

header("Content-Type: text/html");
$path = $_GET['path'];
$pathinput = '';
if($path!=''){
	$parts = explode("/", $path);
	$title = preg_replace("/([a-z])([A-Z])/", "$1 $2", $parts[count($parts)-1]); // wiki word
	$text = "=$title=";
	$locked = 0;
	$pathinput = "<input type='hidden' id='path' name='path' value='$path'></input>";
}else{
	$sql = "SELECT page_text,label,locked 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 retrive page.");
	$text =  mysql_result($result, 0, 'page_text');
	$title = mysql_result($result, 0, 'label');
	$locked = mysql_result($result, 0, 'locked');
}

$ip=$_SERVER['REMOTE_ADDR'];

$sql = "SELECT ip_address FROM blocked WHERE ip_address='$ip'";
$result = mysql_query($sql,$con) or die("Database Error - Unable to retrive page.");
$blocked = mysql_num_rows($result) > 0;

$registered = ($CFG_REGISTERED_ONLY && $loggedon) || !$CFG_REGISTERED_ONLY;

$edit = ($locked == 0 && !$blocked && $registered) || $admin=='true';
$mode = $edit ? $language->menu->edit : "<span style='color:#d00;'>".$language->pagelocked."</span>, ".$language->sourceview;

$html =  "<div style='float:left;font-size:18px;'>$mode : </div><div style='float:left;color:#008;font-size:18px;padding-left:12px;'> $title</div>";
$html .= buttons();
if($edit)
	$html .=  "<div style='float:right;'><div style=';margin-right:20px;'><a href=\"javascript:imagepage();\">".$language->images."</a></div></div>";

$html .=  "<div id='imgins' style='float:right;display:none;'><div style=';margin-right:20px;'><a href=\"javascript:insertimage()\">".$language->insertimage."</a></div></div>";

$html .=  "<div style='height:100%;clear:both;'>";

$ro = "";
if(!$edit) $ro = " readonly";

$html .=  " <textarea id='edittext' rows='12' style='width:100%;border:1px solid black;padding-left:5px;' onkeyup='inlinepreview();' onfocus='inlinepreview();' onmouseup='previewscroll();'$ro>$text</textarea>";
$html .=  " <div id='previewbox' style='height:240px;width:100%;overflow:auto;border:1px solid black;margin-top:2px;padding-left:5px;'></div>";
$html .=  " <div id='editdiff' style='margin-top:2px;'></div>";

$html .=  " <div style='clear:both;'></div>";
$html .=  "</div>";

$html .=  "<div style='clear:both;margin-top:20px;'>";
if($edit){
	$html .=  " ".$language->comment.": <input id='commente' style='width:280px;margin-left:5px;'></input>";
}
	$html .=  " <div style='display:inline;margin-left:30px;'><input type='button' value='".$language->cancel."' onclick='tree.click(\"$page\")';></input></div>";

if($edit){
	$html.= $pathinput;
	$html .=  " <div style='display:inline;padding-left:30px;display:inline'>";
	$html .=  "  <input type='button' value='".$language->save."' onclick='editsave();'></input></div>";
	$html .=  " <div style='display:inline;padding-left:30px;display:inline'>";
	$html .=  "  <input type='button' value='Diff' onclick='editdiff();'></input></div>";
	$html .=  " <div style='display:inline;padding-left:30px;display:inline'>";
	$html .=  "  $language->preview.<input id='showpreview' type='checkbox' checked='checked'></input></div>";
	$html .=  " <div style='display:inline;padding-left:10px;display:inline'>";
	$html .=  "  Scroll.<input id='autoscroll' type='checkbox' checked='checked'></input></div>";

	session_start();
	if(isset($_SESSION["uid"])){
		$sql = "SELECT COUNT(*) AS cnt FROM `subscription` WHERE user_id={$_SESSION["uid"]} AND page_id=$page";
		$result = mysql_query($sql,$con);
		$cnt = mysql_result($result, 0, 'cnt');
		$check = $cnt > 0 ? " checked='checked'" :"";
		$html .=  " <div style='float:right'>";
		$html .=  "  <input id='esub' type='checkbox' value='subscribe' onclick='subscribe();'$check></input>".$language->subscribe."</div>";
	}
	$html .=  "</div>";
}

echo stripslashes($html);
?>
Return current item: Wiki Web Help