<?php
###################################################################
##                           WARNING!                            ##
##                                                               ##
##        THIS SCRIPT IS COPYRIGHTED TO STOREBUILDR.COM          ##
##      DUPLICATING, SELLING OR TRANSFERRING OF THIS SCRIPT      ##
##    IS A VIOLATION OF THE COPYRIGHT AND PURCHASE AGREEMENT     ##
##          PLEASE READ THE TERMS AND CONDITIONS HERE:           ##
##      HTTP://STOREBUILDR.COM/ADMIN-TERMS-AND-CONDITIONS        ##
## ANY VIOLATION OF THESE TERMS WILL BE DEALT WITH LEGAL ACTION! ##
##                                                               ##
###################################################################
error_reporting(0);
ini_set('display_errors','off');
      session_start();

       if($_SESSION[logged_in]!=true)
	     {
			header("location:index.php?flag=2");
			exit;
	     }
		if($_REQUEST[flag]==2) 
		  {
			if(!$handle = fopen("../content_pages/$_REQUEST[edit]", 'w')) 
			  {
				 echo "Cannot open file ($filename)";
				 exit;
			  } 
			  
			if($_REQUEST[display_title]=="on")
			{
			$display_title=1;
			}
			else
			{
			$display_title=0;
			}
			
			  
			$content .="#_1_#title:::".$_REQUEST[title];
			$content .="#_1_#code:::".$_REQUEST[code];
			$content .="#_1_#display_title:::".$display_title;
			$content .="#_1_#content_above:::".$_REQUEST[content_above];
			$content .="#_1_#content_below:::".$_REQUEST[content_below];

			if(fwrite($handle, $content) === FALSE) 
			  {
				echo "Cannot write to file ($filename)";
				exit;
			  }
			  $flag=3;
		  }

        if($_REQUEST[flag]==1 || $_REQUEST[flag]==2) 
		  {
			$filename="../content_pages/$_REQUEST[edit]";
			if(!$handle = fopen($filename, 'r')) 
			  {
				 echo "Cannot open file ($filename)";
				 exit;
			  }
			$contents = @fread($handle, filesize($filename));
			@fclose($handle);
			$argument_arr=explode("#_1_#",$contents);
            $argument_arr_page=explode(":::",$argument_arr[0]);
		  }
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Store Buildr Admin Area</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
#help_sel_page {display:none; }
#help_title {display:none; }
#help_code {display:none; }
#help_display_title {display:none; }
#help_content_above {display:none; }
#help_content_below {display:none; }
-->
</style>
<script src="ckeditor/ckeditor.js"></script>
<script type="text/javascript">
function mm_showHide(id)
{
    a=document.getElementById(id);
    if(a.style.display != 'none' && a.style.display != 'block') a.style.display='none';
    if(a.style.display == 'block') {
        a.style.display='none';
    }
    else {
        a.style.display='block';
    }
    return false;
}
function mm_showHide1(id)
{
    a=document.getElementById(id);
    if(a.style.display != 'none' && a.style.display != 'block') a.style.display='none';
    if(a.style.display == 'block') {
        //a.style.display='none';
    }
    else {
        a.style.display='block';
		what_hide = 'showrow';
		$(what_hide+"1").style.display='none';
		$(what_hide+"2").style.display='none';
		$(what_hide+"3").style.display='none';
		$(what_hide+"4").style.display='none';
		$(what_hide+"5").style.display='none';
		$(what_hide+"6").style.display='none';
		$(what_hide+"7").style.display='none';
		$(what_hide+"8").style.display='none';
		what_hide = 'hiderow';
		$(what_hide+"1").style.display='none';
		$(what_hide+"2").style.display='none';
		$(what_hide+"3").style.display='none';
		$(what_hide+"4").style.display='none';
		$(what_hide+"5").style.display='none';
		$(what_hide+"6").style.display='none';
		$(what_hide+"7").style.display='none';
		$(what_hide+"8").style.display='none';
    }
    return false;
}
</script>
</head>

<body>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" class="table_border">
  <tr>
    <td colspan="2" align="left" valign="top"><div align="center" style="background-color:#5cadcb"><img src="images/logo450.png" width="450" height="96" /></div></td>
  </tr>
  <tr>
    <td width="250" align="center" valign="top" style="padding-left:10px; padding-right:10px; padding-top:20px; padding-bottom:20px">
<!--Side Nav -->
<table width="250" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td align="center" valign="middle"></td>
          </tr>
          <tr>
            <td align="center" valign="middle"><div class="members_title"><strong>Navigation</strong></div></td>
          </tr>
          <tr>
            <td height="10" align="center" valign="middle"></td>
          </tr>
          <tr>
            <td height="30" align="center" valign="middle"><div id="link"><a href="../" target="_blank" id="link"><b>View Your Website</b></a></div></td>
          </tr>
          <tr>
            <td height="10" align="center" valign="middle"></td>
          </tr>
          <tr>
            <td height="30" align="center" valign="middle"><div id="link"><a id="link" href="welcome.php"><b>Home</b></a></div></td>
          </tr>
          <tr>
            <td height="30" align="center" valign="middle"><div id="link"><a id="link" href="admin_settings.php"><b>Admin Settings</b></a></div></td>
          </tr>
          <tr>
            <td height="30" align="center" valign="middle"><div id="link"><a id="link" href="design_settings.php"><b>Design Settings</b></a></div></td>
          </tr>
          <tr>
            <td height="30" align="center" valign="middle"><div id="link"><a id="link" href="home_page_settings.php"><b>Home/Main Page Settings</b></a></div></td>
          </tr>
          <tr>
            <td height="30" align="center" valign="middle"><div id="link"><a id="link" href="sidebar_settings.php"><b>Sidebar Settings</b></a></div></td>
          </tr>
          <tr>
            <td height="10" align="center" valign="middle"></td>
          </tr>
          <tr>
            <td height="30" align="center" valign="middle"><div id="link"><a id="link" href="add_content_pages.php"><b>Add/Remove Pages</b></a></div></td>
          </tr>
          <tr>
            <td height="30" align="center" valign="middle"><div id="link"><a id="link" href="edit_content_pages.php"><b>Edit Pages</b></a></div></td>
          </tr>
          <tr>
            <td height="10" align="center" valign="middle"></td>
          </tr>
          <tr>
            <td height="30" align="center" valign="middle"><div id="link"><a id="link" href="seo_settings.php"><b>S.E.O Settings</b></a></div></td>
          </tr>
          <tr>
            <td height="10" align="center" valign="middle"></td>
          </tr>
          <tr>
            <td height="30" align="center" valign="middle"><div id="link"><a id="link" href="logout.php"><b>Log Out</b></a></div></td>
          </tr>
          <tr>
            <td align="center" valign="middle"></td>
          </tr>
        </table>
<!--Side Nav -->
    </td>
<!--Side Nav -->
    <td width="706" align="left" valign="top" style="padding-left:10px; padding-right:10px; padding-top:20px; padding-bottom:20px"><div class="members_title"><strong>Edit Website Pages </strong></div>
<!--Main -->
<script language="javascript">

 function submit_form()
 {
	 if(document.frm.edit.value=="")
	   {
		 alert("Please Select a Page To Edit");
         document.frm.edit.focus();
		 return false;
	   }
	 document.frm.flag.value=1;
	 document.frm.submit();
 }

function submitform()
 {
	 document.frm.flag.value=2;
 }
</script>
          <script language="JavaScript">     

	function chk()
	{
		if(document.frm.edit.value=="-1")
		{
			alert("Please Select a Page To Edit");
			document.frm.edit.focus();
			return false;
		}
	}

        </script>
<table width="705" border="0" align="center" cellpadding="0" cellspacing="0">
          <form name="frm" method="post" enctype="multipart/form-data" action="edit_content_pages.php" onSubmit="return submitform()">
            <input type="hidden" name="flag" >
            <?php

		if($_REQUEST[flag]==2)

		  {

?>
            <tr>
              <td width="705" height="50" colspan="2" align="center" valign="middle" class="saved">Data Saved Successfully <img src="images/check-green2.png" width="20" height="20" align="absmiddle" /></td>
            </tr>
            <?php

		}

?>
            <tr>
              <td height="80"align="center" valign="middle" class="main2"><p>New pages allow you to add any content you like. Simply select a page that you created in '<a href="add_content_pages.php"><u>Add/Remove  Pages</u></a>'
and enter the content for that page below.</p>                </td>
            </tr>
            <tr>
              <td height="50" align="center" valign="middle" class="main2">Please Select a Page To Edit:<a href="#" onclick="mm_showHide('help_sel_page');return false;"><img src="images/help.png" width="20" height="20" hspace="8" border="0" align="top" /></a><a href="#" onClick="mm_showHide('help_sel_page');return false;"></a></td>
            </tr>
            <tr>
              <td align="center" valign="middle" class="main2"><div class="userhelp_cell" id="help_sel_page">
                Simply select a page from the drop down menu below that you wish to edit.</div></td>
            </tr>
            <tr>
              <td height="50" align="center" valign="middle" class="main2"><div align="center">
                  <select name="edit" id="edit" onChange="submit_form()">
                    <option value="" selected disabled>&nbsp;&nbsp;Please Select a Page To Edit&nbsp;&nbsp;</option>
                    <?php
					if ($handle = opendir('../content_pages')) {
						while (false !== ($file = readdir($handle))) {
							if($file=="." || $file=="..")
								continue;
							if($file==$_REQUEST[edit])
							  {
								$selected="selected";
							  }
							else
							  {
								$selected="";
							  }
							echo "<option value='$file' $selected>$file</option>";
						}
						closedir($handle);
					}
					?>
                  </select>
                  <script>
                function awgr_do_change()
                {
                	q = document.getElementById('edit');
                	if(q.selectedIndex==0) //page edit
                	{
						awgr_show_hide('showrow', 'hiderow');
		 			    a.style.display='none';						
                	}
                	
                }
              	function awgr_show_hide(what_show, what_hide)
              	{
              		
              		$(what_show+"1").style.display='table-row';
              		$(what_show+"2").style.display='table-row';
					$(what_show+"3").style.display='table-row';
					$(what_show+"4").style.display='table-row';
					$(what_show+"5").style.display='table-row';
					$(what_show+"6").style.display='table-row';
					$(what_show+"7").style.display='table-row';
					$(what_show+"8").style.display='table-row';

              		$(what_hide+"1").style.display='none';
              		$(what_hide+"2").style.display='none';
					$(what_hide+"3").style.display='none';
					$(what_hide+"4").style.display='none';
					$(what_hide+"5").style.display='none';
					$(what_hide+"6").style.display='none';
					$(what_hide+"7").style.display='none';
					$(what_hide+"8").style.display='none';

              	}
              	function $(id) { return document.getElementById(id); }
              	f=window.onload;
              	window.onload=function() {
              		if(f) f();
              		awgr_do_change();              		
              	};
              	
              </script>
              </div></td>
            </tr>
            <tr>
              <td height="50" align="center" valign="middle" class="main2">&nbsp;</td>
            </tr>
            <tr id="showrow1">
              <td></td>
            </tr>
            <tr id="showrow2">
              <td></td>
            </tr>
            <tr id="showrow3">
              <td></td>
            </tr>
            <tr id="showrow4">
              <td></td>
            </tr>
            <tr id="showrow5">
              <td></td>
            </tr>
            <tr id="showrow6">
              <td></td>
            </tr>
            <tr id="showrow7">
              <td></td>
            </tr>
            <tr id="showrow8">
              <td></td>
            </tr>
            <tr id="hiderow1">
              <td height="50" align="center" valign="middle" class="main2">Enter a Page Title For Navigation Links:<a href="#" onclick="mm_showHide('help_title');return false;"><img src="images/help.png" width="20" height="20" hspace="8" border="0" align="top" /></a><a href="#" onClick="mm_showHide('help_title');return false;"></a></td>
            </tr>
            <tr>
              <td align="center" valign="middle" class="main2"><div class="userhelp_cell" id="help_title">
                Enter a title for your selected  page This 
                    title is the title that you will see in your navigation links, try not to use irregular characters,
                    standard letters, spaces and numbers will work fine.<br>
              </div></td>
            </tr>
            <tr id="hiderow2">
              <td height="50" align="center" valign="middle" class="main2"><p>
                <input name="title" type="text" id="title" size="45" value="<?php $arr=explode(":::",$argument_arr[1]);
			  echo $arr[1]; ?>">
              </p></td>
            </tr>
            
            <tr id="hiderow3">
              <td height="60" align="center" valign="middle" class="main2">Enter Content Above Advert (if required):<a href="#" onclick="mm_showHide('help_content_above');return false;"><img src="images/help.png" width="20" height="20" hspace="8" border="0" align="top" /></a></td>
            </tr>
            <tr>
              <td align="center" valign="top" class="main2"><div class="userhelp_cell" id="help_content_above">Enter any content for your page that will be placed <b>above</b> your ads here,<br />
should you require it, using the WYSIWYG editor.<br />
                There is no limit to the amount of information you place here but we suggest you add a little at a time and keep checking your page to make sure it looks OK.<br />
                    <br />
                    We also recommend that if you are pasting a block of text in here, you paste your text in a basic notepad document first, then copy from there to here, so that it
                  removes all the hidden formatting and makes it simpler for you to edit.<br />
Use the WYSIWYG editor below to easily format your text.
              </div></td>
            </tr>
            <tr>
              <td height="60" align="center" valign="middle" class="main2">
              <table width="705" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr id="hiderow4">
                  <td align="center" valign="top">        
<textarea style="width:705px" name="content_above" rows="4" id="content_above" class="main_text"><?php $arr=explode(":::",$argument_arr[4]);
			  echo $arr[1]; ?></textarea>
<script>
			CKEDITOR.replace( 'content_above' );
		</script>        </td>
    </tr>
</table>              </td>
            </tr>
            <tr id="hiderow5">
              <td height="80" align="center" valign="middle" class="main2">Your InstantAzon Advert Code:<a href="#" onclick="mm_showHide('help_code');return false;"><img src="images/help.png" width="20" height="20" hspace="8" border="0" align="top" /></a><br />
              This is the code you get from your InstantAzon when you '<b>Generate Website Code</b>'</td>
            </tr>
            <tr>
              <td align="center" valign="top" class="main2"><div class="userhelp_cell" id="help_code">Enter your generated <b>WEBSITE</b> code here for your InstantAzon Adverts.<br />
This is the code you get from your InstantAzon when you '<b>Generate Website Code</b>' </div></td>
            </tr>
            <tr>
              <td height="60" align="center" valign="middle" class="main2">
              <table width="705" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr id="hiderow6">
                  <td align="center" valign="top">        
<textarea style="width:705px; font-family:Tahoma; font-size:12px;" name="code" rows="8" id="code"><?php $arr=explode(":::",$argument_arr[2]);
			  echo $arr[1]; ?></textarea>
                  </td>
                </tr>
</table>              </td>
            </tr>
            <tr id="hiderow7">
              <td height="60" align="center" valign="middle" class="main2">Enter Content Below Advert (if required):<a href="#" onclick="mm_showHide('help_content_below');return false;"><img src="images/help.png" width="20" height="20" hspace="8" border="0" align="top" /></a></td>
            </tr>
            <tr>
              <td align="center" valign="top" class="main2"><div class="userhelp_cell" id="help_content_below">Enter any content for your page that will be placed <b>below</b> your ads here,<br />
should you require it, using the WYSIWYG editor.<br />
                There is no limit to the amount of information you place here but we suggest you add a little at a time and keep checking your page to make sure it looks OK.<br />
                    <br />
                    We also recommend that if you are pasting a block of text in here, you paste your text in a basic notepad document first, then copy from there to here, so that it
                  removes all the hidden formatting and makes it simpler for you to edit.<br />
Use the WYSIWYG editor below to easily format your text.
              </div></td>
            </tr>
            <tr>
              <td height="60" align="center" valign="middle" class="main2">
              <table width="705" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr id="hiderow8">
                  <td align="center" valign="top">        
<textarea style="width:705px" name="content_below" rows="4" id="content_below" class="main_text"><?php $arr=explode(":::",$argument_arr[5]);
			  echo $arr[1]; ?></textarea>
<script>
			CKEDITOR.replace( 'content_below' );
		</script>        </td>
    </tr>
</table>              </td>
            </tr>
            <tr>
              <td height="50" align="center" valign="middle" class="main2">&nbsp;</td>
            </tr>
            
            <tr>
              <td height="50" align="center" valign="middle" class="main2"><p>
                  <input type="submit" name="Submit" value="Save Edited Page" id="submit-butt" onclick='form_submit_2()'>
              </p></td>
            </tr>
            <tr>
              <td height="50" align="center" valign="middle" class="main2">&nbsp;</td>
            </tr>
          </form>
      </table>  
<!--Main --></td>
  </tr>
</table>
<div align="center"><span class="footer_policy">No part of this website may be reproduced or transmitted in any form or by any means without written permission from StoreBuildr.com<br />
        <strong>Copyright
<script type="text/javascript" language="JavaScript">function getCorrectedYear(year) {
year = year - 0;
if (year < 70) return (2000 + year);
if (year < 1900) return (1900 + year);
return year;
}
var lmod = new Date();
var yearstr = getCorrectedYear(lmod.getYear());
document.write(yearstr);
// -->
</script>, StoreBuildr.com. All Rights Reserved.</strong></span></div>
</body>
</html>
