<?php
ob_start();
include_once("functions.php");
include('config.php');
include("session.php");
// this setting activates tinyMCE for all textareas in the page
$set_mce = 1;
include("header.php");
?>
<?php
$user = loadUser($_SESSION['login'],$link,$table_users);
if(!$_SESSION["loggedIn"] || !$user['admin']){ echo "You don't have enough privileges to view this page."; exit; }
else
{
if($_POST['Submit']){
if(!$_POST[title])
{
$messages[]="$lang_enter_title";
}
// upload script
include("upload_files.php");
if(empty($messages)) {
if($_POST['mainpage']){
// make sure there's only one mainpage
$query="UPDATE $table_pages SET mainpage = '0'";
$result=mysql_query($query, $link) or die("Died inserting login info into db. Error returned if any: ".mysql_error());
}
$query="INSERT INTO $table_pages (title, text, image, imagewidth, imageheight, align, use_form, form_email, mainpage) VALUES ('$_POST[title]', '$_POST[text]', '$image', '$imagewidth', '$imageheight', '$_POST[align]', '$_POST[use_form]', '$_POST[form_email]', '$_POST[mainpage]')";
$result=mysql_query($query, $link) or die("Died inserting login info into db. Error returned if any: ".mysql_error());
$latestentry = mysql_insert_id(); // get the id of the latest entry
foreach ($aBestanden as $sFilename => $sFiletype)
{
// get image size
if($sFiletype == 'image/jpeg' || $sFiletype == 'image/gif'){
$imgsize = getimagesize("../upload/$sFilename");
}
// insert files into db
$query = "INSERT INTO $table_files (page_id, name, type, width, height) VALUES ('". $latestentry . "', '". $sFilename . "', '". $sFiletype . "', '". $imgsize[0] . "', '". $imgsize[1] . "')";
$result=mysql_query($query, $link) or die("Died inserting login info into db. Error returned if any: ".mysql_error());
}
if($_POST[embed]){
$query = "INSERT INTO $table_files (page_id, full_url, type) VALUES ('". $latestentry . "', '". $_POST[embed] . "', 'embed')";
$result=mysql_query($query, $link) or die("Died inserting login info into db. Error returned if any: ".mysql_error());
}
header("Location: $_SERVER[php_self]?message=10");
ob_end_flush();
}
}
}
?>
<div id="submenu"><a href="newpage.php" class="sub"><?php echo "$lang_newpage"; ?></a> | <a href="page.php" class="sub"><?php echo "$lang_edit_delete_page"; ?></a></div>
<div id="side">
<div class="title"> </div>
<div class="box"><?php
if(!empty($messages)){
displayErrors($messages);
}
elseif($_GET[message] && empty($messages)){
displayMessage($_GET[message]);
}
else{
echo "$lang_message002";
}
?>
</div>
<?php if ($user[admin]){ ?>
<br />
<div class="title"><?php echo "$lang_latest_pages"; ?></div>
<div class="box">
<?php
$query = "SELECT * FROM $table_pages ORDER BY id DESC LIMIT 10";
$result = mysql_query ($query, $link) or die("Died getting info from db. Error returned if any: ".mysql_error());
$numrows = mysql_num_rows($result);
$pages = arrayMaker($result,MYSQL_ASSOC);
if($pages){
foreach($pages as $page){
echo "<a href='editor_pages.php?id=$page[id]'>$page[title]</a><br />";
}
}
else
{
echo $lang_no_results;
}
?>
</div>
<?php } ?>
</div>
<div id="main">
<form method="post" name="editform" enctype="multipart/form-data">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="text">
<tr>
<td class="title"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><h1><?php echo "$lang_newpage"; ?></h1></td>
<td><input type="submit" name="Submit" value="<?php echo "$lang_submit"; ?>" id="button" /></td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top">
<fieldset id="titlediv">
<legend><?php echo "$lang_title"; ?></legend>
<input name="title" type="text" value="<?php echo "$_POST[title]"; ?>" size="30"> <input name="mainpage" type="checkbox" value="1" /> <?php echo"$lang_set_mainpage"; ?>
</fieldset>
</td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">
<fieldset id="titlediv">
<legend><?php echo "$lang_text"; ?></legend>
<?php
// present safari users with a different editor
$a_browser_data = browser_detection('full');
if ( $a_browser_data[0] == 'saf' || !$settings[use_tinymce])
{
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="34%" class="title"> </td>
<td width="66%">
<input type="button" class="button" value="<?php echo "$lang_bold"; ?>" name="bold2" onmousedown="javascript:tag_construct('bold','text'); return false;"/>
<input type="button" class="button" value="<?php echo "$lang_italic"; ?>" name="italic2" onmousedown="javascript:tag_construct('italic','text'); return false;"/>
<input type="button" class="button" value="<?php echo "$lang_underline"; ?>" name="underline2" onmousedown="javascript:tag_construct('underline','text'); return false;"/>
<input type="button" class="button" value="<?php echo "$lang_url"; ?>" name="url2" onmousedown="javascript:tag_construct('link','text'); return false;"/>
<input type="button" class="button" value="<?php echo "$lang_img"; ?>" name="img2" onmousedown="javascript:tag_construct('image','text'); return false;"/>
<input type="button" class="button" value="<?php echo "$lang_email"; ?>" name="email2" onmousedown="javascript:tag_construct('email','text'); return false;"/>
</td>
</tr>
</table>
<?
}
?>
<textarea rows="20" cols="75" name="text"><?php echo "$entry[text]"; ?></textarea>
</fieldset></td>
</tr>
<tr>
<td> </td>
</tr>
<?php if($settings[use_upload]){ ?>
<tr>
<td><?php include("file_manager_include.php"); ?></td>
</tr>
<tr>
<td>
<fieldset id="titlediv">
<legend><?php echo "$lang_upload_img_file"; ?></legend>
<input id="my_file_element" type="file" value="1" name="file_1" \ />
<div id="files_list"></div>
<script>
<!-- Create an instance of the multiSelector class, pass it the output target and the max number of files -->
var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 20 );
<!-- Pass in the file element -->
multi_selector.addElement( document.getElementById( 'my_file_element' ) );
</script>
</fieldset></td>
</tr>
<tr>
<td><div class="text" onclick="expandcontent(this, 'sc3')" style="cursor:hand; cursor:pointer">
<div align="right"><a name="upload" id="upload"></a><a href="#upload"><span class="showstate"></span><?php echo"$lang_options"; ?></a></div>
</div>
<div id="sc3" class="switchcontent">
<p>
<table width="100%" style='border: #CCCCCC solid; border-width: 5px 1px 1px 1px; padding: 5px 5px 5px 5px;'>
<tr>
<td width="20%">
<?php echo"$lang_jpeg_gif"; ?></td><td><input name="thumbnail" type="checkbox" value="1" checked="checked" />
<?php echo"$lang_thumbnails"; ?></td></tr>
<tr>
<td colspan="3"><?php echo "$lang_embed_code"; ?></td>
</tr>
<tr>
<td colspan="3">
<input name="embed" type="text" size="70" /></td>
</tr>
</table>
</p>
</div></td>
</tr>
<tr>
<td> </td>
</tr>
<?php } ?>
<tr>
<td> <fieldset id="titlediv">
<legend><?php echo "$lang_contactform"; ?></legend>
<?php echo "$lang_use_contactform"; ?>
<input name="use_form" type="checkbox" id="use_form" value="1" />
<br /> <?php echo "$lang_form_email"; ?>
<input type="text" name="form_email" value="<?php echo "$_POST[form_email]"; ?>" />
</fieldset> </td>
</tr>
<tr><td> </td></tr>
<tr>
<td><input type="submit" name="Submit" value="<?php echo "$lang_submit"; ?>" id="button"></td>
</tr>
</table>
</form>
</div>
<?php
include ("footer.php");
?>