<?php
session_name("s".base64_decode($_COOKIE[register]));
session_start ();
$sesspass = "base64_decode($_COOKIE[register])";
if (session_id() == "" and $_SESSION[$sesspass] != session_id()) 
{
	session_unset ();
	session_destroy ();
	header ("location: ../index.php?n=503");
}
if (!session_is_registered("s".base64_decode($_COOKIE[register]))) 
{
	session_unset ();
	session_destroy ();
	header ("location: ../index.php?n=503");
}
if ($_POST[submit]){
	require "engine/actions.php";
	$expageimages = "";
	for ($n="0"; $n<(count($_POST[eximage]));$n++){
		if(strlen($_POST[eximage][$n]) > 3){
			$expageimages .= $_POST[eximage][$n].",";
		}
	}
	if (strlen($expageimages) > 3){
		$expageimages = substr($expageimages, 0, -1);
	}
	$pageimages = pimages($_POST[image1],$_POST[image2],$_POST[image3],$_POST[image4],$_POST[image5],$_POST[image6]);
	$_POST[actions]($_POST[pagetitle],$_POST[pageid],$_POST[pagetype],$_POST[pageorder],$_POST[pageparent],$_POST[pagekeywords],$_POST[pagedescription],$_POST[pagecontent],$expageimages,$pageimages,$_POST[pagelog],$_POST[expid]);
	rss();
	sitemap();	
}
require "../data/".editpage($_GET[p],$_GET[c]);?>



<h1><?php echo $l[editpage];?>: <?php echo $page[title];?></h1>
<form action="<?php echo $_SERVER['PHP_SELF']."?a=".$_GET[a];?>" method="post" name="editpage" id="editpage" class="form">

 			  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">
 			    <tr>
 			      <td colspan="2">
				<?php echo $l[pagetitle];?>: 
                  <abbr title="<?php echo $l[pagetitlenote];?>">[?]</abbr></td>
		        </tr>
 			    <tr>
 			      <td colspan="2"><input name="pagetitle" class="validate[required,length[2,24]] field" id="pagetitle"  style="width:99%; font-size:1.3em" value="<?php echo $page[title];?>"/></td>
		        </tr>
 			    <tr>
 			      <td width="70%" align="left"><?php echo $l[pageid];?>: <abbr title="<?php echo $l[pageidnoteedit];?>">[?]</abbr></td>
 			      <td align="left"><?php echo $l[pagetype];?>: <abbr title="<?php echo $l[pagetypenote];?>">[?]</abbr></td>
		        </tr>
 			    <tr>
 			      <td width="70%" align="left"><input name="pageid" class="field" id="pageid" style="width:99%;" value="<?php echo $page[id];?>" readonly="readonly"/></td>
 			      <td align="left"><select name="pagetype" class="field" id="pagetype" onchange="swapPreview();">
 			        <optgroup label="Mixed">
 			          <option value="mixed|left"<?php if($page[type]."|".$page[textpos] == "mixed|left"){ echo " selected";}?>><?php echo $l[mixedleft];?></option>
 			          <option value="mixed|right"<?php if($page[type]."|".$page[textpos] == "mixed|right"){ echo " selected";}?>><?php echo $l[mixedright];?></option>
		            </optgroup>
 			        <optgroup label="Gallery">
 			          <option value="gallery|top"<?php if($page[type]."|".$page[textpos] == "gallery|top"){ echo " selected";}?>><?php echo $l[gallerytop];?></option>
 			          <option value="gallery|bottom"<?php if($page[type]."|".$page[textpos] == "gallery|bottom"){ echo " selected";}?>><?php echo $l[gallerybottom];?></option>
		            </optgroup>
 			        <optgroup label="List">
 			          <option value="list|none"<?php if($page[type]."|".$page[textpos] == "list|none"){ echo " selected";}?>><?php echo $l[listtop];?></option>
		            </optgroup>
		          </select></td>
		        </tr>
 			    <tr>
 			      <td width="70%" align="left"><?php echo $l[pageorder];?>: <abbr title="<?php echo $l[pageordernote];?>">[?]</abbr>
                    <select name="pageorder" id="pageorder" class="field">
                      <option value="0"<?php if ($page[order] == "0") echo " selected";?>>0</option>
                      <option value="1"<?php if ($page[order] == "1") echo " selected";?>>1</option>
                      <option value="2"<?php if ($page[order] == "2") echo " selected";?>>2</option>
                      <option value="3"<?php if ($page[order] == "3") echo " selected";?>>3</option>
                      <option value="4"<?php if ($page[order] == "4") echo " selected";?>>4</option>
                      <option value="5"<?php if ($page[order] == "5") echo " selected";?>>5</option>
                      <option value="6"<?php if ($page[order] == "6") echo " selected";?>>6</option>
                      <option value="7"<?php if ($page[order] == "7") echo " selected";?>>7</option>
                      <option value="8"<?php if ($page[order] == "8") echo " selected";?>>8</option>
                      <option value="9"<?php if ($page[order] == "9") echo " selected";?>>9</option>
                    </select>
<?php echo $l[parentpage];?>: <abbr title="<?php echo $l[parentpagenote];?>">[?]</abbr>
<select name="pageparent" id="pageparent" class="field">
  <option value=""><?php echo $l[none];?></option>
  <?php parentselected($page[ch], $page[id]); ?>
</select></td>
 			      <td align="left"><?php echo $l[preview];?></td>
		        </tr>
 			    
 			    <tr>
 			      <td width="70%" align="left"><?php echo $l[keywords]; ?> <em>(<?php echo $l[commaseparated];?>)</em>: <abbr title="<?php echo $l[keywordsnote];?>">[?]</abbr></td>
 			      <td rowspan="4" align="left" valign="top"><img id="preview" src="style/<?php echo str_replace("|","_",$page[type]."|".$page[textpos]);?>.png" width="296" height="176" />
                  
                  </td>
		        </tr>
 			    <tr>
 			      <td width="70%" align="left"><input name="pagekeywords" type="text" class="field" id="pagekeywords" style="width:99%;" value="<?php echo $page[keywords];?>"/></td>
		        </tr>
 			    <tr>
 			      <td width="70%" align="left"><?php echo $l[description];?>: <abbr title="<?php echo $l[descriptionnote];?>">[?]</abbr></td>
		        </tr>
 			    <tr>
 			      <td width="70%" align="left" valign="top"><textarea name="pagedescription" id="pagedescription" rows="5" style="width:99%;" class="field"><?php echo $page[description];?></textarea></td>
		        </tr>
 			    <tr>
 			      <td colspan="2"><?php echo $l[content];?>: <abbr title="<?php echo $l[contentnote];?>">[?]</abbr></td>
		        </tr>
 			    <tr>
 			      <td colspan="2" align="left"><textarea name="pagecontent" id="pagecontent" style="width:99%; height:250px;" class="tinymce"><?php echo $page[content];?></textarea></td>
		        </tr>
 			    <tr>
 			      <td colspan="2">&nbsp;</td>
		        </tr>
 			    <tr>
 			      <td colspan="2">
                  <?php if(strlen($page[media]) != 0){ ?>
				  <?php echo $l[eximages];?> <abbr title="<?php echo $l[eximagesnote];?>">[?]
 			      </abbr>
                  <?php } ?>
                  </td>
		        </tr>
 			    <tr>
 			      <td colspan="2">
                  <?php if(strlen($page[media]) != 0){ ?>
				    <table width="400" border="0" cellpadding="2" cellspacing="1" id="pagemedia">
                      <?php 
					  $iid = 0;
					  $eximages = explode(",",$page[media]);
					  foreach ($eximages as $eximage){
						  $iid ++;
						  echo "<tr id=\"r".$iid."\">";
						  echo "<td width=\"25\" class=\"dndr\">";
						  echo $iid;
						  echo "</td>";
						  echo "<td width=\"120\">";
						  echo "<img src=\"../media/thumbs/".$eximage."\" width=\"50%\" height=\"50%\" />";
						  echo "</td>";
						  echo "<td>";
						  echo "<input id=\"f".$iid."\" name=\"eximage[]\" type=\"text\" value=\"".$eximage."\" readonly=\"readonly\" /> ";
						  echo "<a href=\"javascript:void(0);\" onclick=\"MM_setTextOfTextfield('f".$iid."','','')\">";
						  echo "<img src=\"style/remove.png\" width=\"24\" height=\"24\" border=\"0\" align=\"texttop\" />";
						  echo "</a>";
						  echo "</td>";
						  echo "</tr>";
					  }
					  ?>
				    </table>
				    
<?php
                  }
				  ?>
                  </td>
		        </tr>
 			    <tr>
 			      <td colspan="2"><?php echo $l[images];?> <abbr title="<?php echo $l[imagesnote];?>">[?]</abbr>
</td>
		        </tr>
 			    <tr>
 			      <td colspan="2"><table width="100%" border="0" cellspacing="2" cellpadding="0">
 			        <tr>
 			          <td width="33%" align="left" valign="middle"><input name="image1" type="text" class="fieldimage" id="image1" onclick="browse('inc/gallerybrowser.php?f=1&amp;d=editpage','Gallery browser','800','600')" readonly="readonly" />
                      <a href="javascript:void(0);" onclick="MM_setTextOfTextfield('image1','','')"><img src="style/remove.png" width="24" height="24" border="0" align="texttop" /></a></td>
 			          <td width="34%" align="left" valign="middle"><input name="image2" type="text" class="fieldimage" id="image2" onclick="browse('inc/gallerybrowser.php?f=2&amp;d=editpage','Gallery browser','800','600')" readonly="readonly" />
		              <a href="javascript:void(0);" onclick="MM_setTextOfTextfield('image2','','')"><img src="style/remove.png" width="24" height="24" border="0" align="texttop" /></a></td>
 			          <td width="33%" align="left" valign="middle"><input name="image3" type="text" class="fieldimage" id="image3" onclick="browse('inc/gallerybrowser.php?f=3&amp;d=editpage','Gallery browser','800','600')" readonly="readonly" />
		              <a href="javascript:void(0);" onclick="MM_setTextOfTextfield('image3','','')"><img src="style/remove.png" width="24" height="24" border="0" align="texttop" /></a></td>
		            </tr>
 			        <tr>
 			          <td width="33%" align="left" valign="middle"><input name="image4" type="text" class="fieldimage" id="image4" onclick="browse('inc/gallerybrowser.php?f=4&amp;d=editpage','Gallery browser','800','600')" readonly="readonly" />
		              <a href="javascript:void(0);" onclick="MM_setTextOfTextfield('image4','','')"><img src="style/remove.png" width="24" height="24" border="0" align="texttop" /></a></td>
 			          <td width="34%" align="left" valign="middle"><input name="image5" type="text" class="fieldimage" id="image5" onclick="browse('inc/gallerybrowser.php?f=5&amp;d=editpage','Gallery browser','800','600')" readonly="readonly" />
		              <a href="javascript:void(0);" onclick="MM_setTextOfTextfield('image5','','')"><img src="style/remove.png" width="24" height="24" border="0" align="texttop" /></a></td>
 			          <td width="33%" align="left" valign="middle"><input name="image6" type="text" class="fieldimage" id="image6" onclick="browse('inc/gallerybrowser.php?f=6&amp;d=editpage','Gallery browser','800','600')" readonly="readonly" />
		              <a href="javascript:void(0);" onclick="MM_setTextOfTextfield('image6','','')"><img src="style/remove.png" width="24" height="24" border="0" align="texttop" /></a></td>
		            </tr>
		          </table></td>
		        </tr>
 			    <tr>
 			      <td colspan="2" align="left"><input name="submit" type="hidden" id="submit" value="true" />
 			        <input name="pagelog" type="hidden" id="pagelog" value="<?php echo date("r");?>" />
		            <input name="expid" type="hidden" id="expid" value="<?php echo editpage($_GET[p],$_GET[c]);?>" />
	              <input name="actions" type="hidden" id="actions" value="editpages" /></td>
		        </tr>
 			    <tr>
 			      <td colspan="2" align="center"><input type="reset" name="button2" id="button2" value="<?php echo $l[cancelandreset];?>" onclick="$.validationEngine.closePrompt('.formError',true)" class="cancel"/> 			        <input type="submit" name="button" id="button" value="<?php echo $l[save];?>" class="save" /></td>
		        </tr>
 			    <tr>
 			      <td colspan="2" align="center">&nbsp;</td>
		        </tr>

  </table>
</form>

