<?php
####################################################################################
##                                      WARNING!                                  ##
##                                                                                ##
##             This script is copyrighted to Free Monthly Websites.               ##
##               Duplication, selling, or transferring of this script             ##
##              is a violation of the copyright and purchase agreement.           ##
##                   Please read the Terms and Conditions here:                   ##
##   https://freemonthlywebsites2.com/legal/Copyright_Terms_and_Conditions.pdf    ##
##      Any violation of these terms will be dealt with serious 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;
			  } 
			$content .=stripslashes("#_1_#Title:::".$_REQUEST['title']);
			$content .=stripslashes("#_1_#Details:::".$_REQUEST['details']);

			if(fwrite($handle, $content) === FALSE) 
			  {
				echo "Cannot write to file ($filename)";
				exit;
			  }
			  $flag=3;
			 // $_REQUEST['edit']="";
		  }
		if(!empty($_REQUEST['flag']) and ($_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>
<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Admin Control Panel</title>
<link href="css/admin_style.css" rel="stylesheet" type="text/css">
<script src="ckeditor/ckeditor.js"></script>
<style type="text/css">
<!--
#help_sel_page {display:none; }
#help_title {display:none; }
#help_content {display:none; }
-->
</style>
<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;
}
</script>
</head>
<body>
<table width="914" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td height="160" colspan="3" align="center" valign="middle" class="header">
	</td>
  </tr>
  <tr>
    <td colspan="3" align="center" valign="top" class="main_mid"><table width="888" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="3" height="5" class="table_topl">&nbsp;</td>
        <td width="220" height="5" class="table_top">&nbsp;</td>
        <td width="5" class="table_topr">&nbsp;</td>
        <td width="1" rowspan="3">&nbsp;</td>
        <td width="3" class="table_topl">&nbsp;</td>
        <td width="645" class="table_top">&nbsp;</td>
        <td width="5" height="5" class="table_topr">&nbsp;</td>
      </tr>
      <tr>
        <td width="3" class="table_left">&nbsp;</td>
        <td width="220" align="center" valign="top"><table width="215" border="0" align="left" cellpadding="0" cellspacing="0">
          <tr>
            <td width="215" height="80" colspan="2" align="center" valign="middle" class="admin_button"><a href="../" target="_blank"><strong>View Your Website</strong></a></td>
          </tr>
          <tr>
            <td height="45" colspan="2" align="center" valign="middle" class="admin_button"><a href="welcome.php"><strong>Home</strong></a></td>
            </tr>
          <tr>
            <td height="60" colspan="2" align="center" valign="middle"><img src="images/bulletaro_dn.gif" width="13" height="9" hspace="10"><span class="style1">Standard Settings</span><img src="images/bulletaro_dn.gif" width="13" height="9" hspace="10"></td>
          </tr>
          <tr>
            <td height="45" colspan="2" align="center" valign="middle" class="admin_button"><a href="admin_settings.php"><strong>Admin Settings</strong></a></td>
          </tr>
          <tr>
            <td height="45" colspan="2" align="center" valign="middle" class="admin_button"><a href="personal_settings.php"><strong>Personal Settings</strong></a></td>
          </tr>
          <tr>
            <td height="45" colspan="2" align="center" valign="middle" class="admin_button"><a href="website_settings.php"><strong>Basic Website Settings</strong></a></td>
          </tr>
          <tr>
            <td height="45" colspan="2" align="center" valign="middle" class="admin_button"><a href="seo_settings.php"><strong>S.E.O Settings</strong></a></td>
          </tr>
          <tr>
            <td height="45" colspan="2" align="center" valign="middle" class="admin_button"><a href="theme_settings.php"><strong>Theme Settings</strong></a></td>
          </tr>
          <tr>
            <td height="45" colspan="2" align="center" valign="middle" class="admin_button"><a href="advert_settings.php"><strong>Advert Settings</strong></a></td>
          </tr>
          <tr>
            <td height="45" colspan="2" align="center" valign="middle" class="admin_button"><a href="affiliate_settings.php"><strong>Affiliate Settings</strong></a></td>
          </tr>
          <tr>
            <td height="45" colspan="2" align="center" valign="middle" class="admin_button"><a href="optin_settings.php"><strong>Optin Form Settings</strong></a></td>
          </tr>
          <tr>
            <td height="60" colspan="2" align="center" valign="middle"><img src="images/bulletaro_dn.gif" width="13" height="9" hspace="10"><span class="style1">Article Settings</span><img src="images/bulletaro_dn.gif" width="13" height="9" hspace="10"></td>
          </tr>
          <tr>
            <td height="45" colspan="2" align="center" valign="middle" class="admin_button"><a href="add_content_pages.php"><strong>Add/Remove Article Pages</strong></a></td>
          </tr>
          <tr>
            <td height="45" colspan="2" align="center" valign="middle" class="admin_button"><a href="edit_content_pages.php"><strong>Edit Article Pages</strong></a></td>
          </tr>
          <tr>
            <td height="60" colspan="2" align="center" valign="middle"><img src="images/bulletaro_dn.gif" width="13" height="9" hspace="10"><span class="style1">Other</span><img src="images/bulletaro_dn.gif" width="13" height="9" hspace="10"></td>
          </tr>

          <tr>
            <td height="45" colspan="2" align="center" valign="middle" class="admin_button"><a href="https://freemonthlywebsites2.com/legal/Copyright_Terms_and_Conditions.pdf" target="_blank"><strong>Terms and Conditions</strong></a></td>
          </tr>
          <tr>
            <td height="30" colspan="2" align="center" valign="middle">&nbsp;</td>
            </tr>
          <tr>
            <td height="45" colspan="2" align="center" valign="middle" class="admin_button"><a href="logout.php"><strong>Logout</strong></a></td>
          </tr>
          <tr>
            <td height="30" colspan="2" align="center" valign="middle">&nbsp;</td>
          </tr>
        </table>
        <td width="5" class="table_right">&nbsp;</td>
        <td width="3" class="table_left">&nbsp;</td>
        <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>

        <td width="645" align="center" valign="top"><table width="645" 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" >
            <tr>
              <td width="645" height="50" align="center" valign="middle" class="title1">Edit  Website Article Pages </td>
            </tr>
            <?php

		if(!empty( $_REQUEST['flag'] ) and $_REQUEST['flag']==2)

		  {

?>
            <tr>
              <td height="50" align="center" valign="middle" class="title1">&gt;&gt; <span class="style3">Data saved successfully</span> &lt;&lt;</td>
            </tr>
            <?php

		}

?>
            <tr>
              <td height="80"align="center" valign="middle" class="main2"><p>Article pages are pages that 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 Article 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.gif" width="21" height="21" hspace="8" border="0" align="top"></a></td>
            </tr>
            <tr>
              <td align="center" valign="middle" class="main2"><div class="userhelp_cell" id="help_sel_page">
                  <p><br>
                    Simply select an article page from the drop down menu below that you wish to edit.<br>
                    <br>
                      </div></td>
            </tr>
            <tr>
              <td height="50" align="center" valign="middle" class="main2"><div align="center">
                  <select name="edit" onChange="submit_form()">
                    <option value="" selected disabled>Please Select a Page To Edit</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>
              </div></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">Enter A Page Title As You Would Like It To Be Seen<br>
                (also used for navigation links):<a href="#" onClick="mm_showHide('help_title');return false;"><img src="images/help.gif" width="21" height="21" hspace="8" border="0" align="top"></a></td>
            </tr>
            <tr>
              <td align="center" valign="middle" class="main2"><div class="userhelp_cell" id="help_title">
                  <p><br>
                    Enter a title for your selected article page 
                  <p>This 
                    title is the title that you will see, try not to use irregular characters,<br>
                    standard letters, spaces and numbers will work fine. <br>
                    <br>
                    This is also used for frame heading and side bar navigation links.
                  <p><strong>example title:</strong> My Artilce Page 1<br>
          <br>
                                </div></td>
            </tr>
            <tr>
              <td height="50" align="center" valign="middle" class="main2"><p>
                <input name="title" type="text" id="title" style="width:280px" value="<?php $arr=explode(":::",$argument_arr['1']);
			  echo $arr['1']; ?>">
              </p></td>
            </tr>
            <tr>
              <td height="50" align="center" valign="middle" class="main2">&nbsp;</td>
            </tr>
            
            <tr>
              <td height="60" align="center" valign="middle" class="main2">Enter Content For Your Page:<a href="#" onClick="mm_showHide('help_content');return false;"><img src="images/help.gif" width="21" height="21" hspace="8" border="0" align="top"></a></td>
            </tr>
            <tr>
              <td align="center" valign="top" class="main2"><div class="userhelp_cell" id="help_content"> <br>
                      <p>Enter your content for your page here using the WYSIWYG editor.</p>
                <p>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.</p>
                <p>We also recommend that if you are pasting a block of text in here, you paste your text in a basic notepad<br>
document first, then copy from there to here, so that it
                  removes all the hidden formatting and makes it<br>
simpler for you to edit.</p>
                <p>Use the WYSIWYG editor below to easily format your text. </p>
                <p>Maximum width for images and tables is 520px.
                          <br>
                          <br>
                      </p>
                </div></td>
            </tr>
            <tr>
              <td height="60" align="center" valign="middle" class="main2">
              <table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td align="center" valign="top">
<textarea style="width:600px" name="details" rows="4" id="details" class="main2"><?php $arr=explode(":::",$argument_arr['2']);
			  echo $arr['1']; ?></textarea>
<script>
			CKEDITOR.replace( 'details' );
		</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 Article Page" onclick='form_submit_2()'>
              </p></td>
            </tr>
            <tr>
              <td height="50" align="center" valign="middle" class="main2">&nbsp;</td>
            </tr>
          </form>
        </table></td>
        <td width="5" class="table_right">&nbsp;</td>
      </tr>
      <tr>
        <td width="3" height="6" class="table_botl">&nbsp;</td>
        <td width="220" height="6" class="table_bot">&nbsp;</td>
        <td width="5" class="table_botr">&nbsp;</td>
        <td width="3" class="table_botl">&nbsp;</td>
        <td width="645" class="table_bot">&nbsp;</td>
        <td width="5" height="6" class="table_botr">&nbsp;</td>
      </tr>
    </table></td>
  </tr> 
  <tr>
    <td height="60" colspan="3" align="center" valign="middle" class="footer">    </td>
  </tr>
  <tr class="footer_bg">
    <td width="8" height="30">&nbsp;</td>
    <td width="898" height="30"><table width="898" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td align="center" valign="middle" class="copyright">Copyright &copy; <a href="https://freemonthlywebsites2.com" target="_blank">Free Monthly Websites 2.0</a>. All Rights Reserved.</td>
      </tr>
      <tr>
        <td align="center" valign="middle" class="powered">Powered By: <a href="https://freemonthlywebsites2.com" target="_blank">Free Monthly Websites 2.0</a></td>
      </tr>
    </table></td>
    <td width="8" height="30">&nbsp;</td>
  </tr>
</table>
</body>
</html>