<?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();

		function checkIfDirExists(){

		if(!file_exists('./settings/seo'))
		mkdir("./settings/seo", 0777);

		if(!file_exists('./settings/seo/content_pages'))
		mkdir("./settings/seo/content_pages", 0777);

		}



       if($_SESSION['logged_in']!=true)
	     {
			header("location:index.php?flag=2");
			exit;
	     }

		$filename="settings/seo_settings.txt";


		if(isset($_POST['page'])){

			
		
				$temp_var=explode("|",$_POST['page']);

				$seopage_select=trim($_POST['page']);

				$seopage=$temp_var['1'];
				$filename=$temp_var['1'];

				if($temp_var['0']=='c'){
					$file = basename($filename, ".html");
					$filename="./settings/seo/content_pages/$file.txt";			
					}
				else if($temp_var['0']=='o'){
				
				if($seopage=='index.php'){		
					$filename="settings/seo_settings.txt";	
				}
				else{
					$filename="settings/seo/$temp_var[1]";	
					$file = basename($filename, ".php");
					$filename="./settings/seo/$file.txt";	
				}
				}

		}
		else{ 
			$seopage='index.php';
		}




		if(isset($_POST['Submit'])){		

		$temp_var=explode("|",$_POST['seo_page']);
		$seopage=$temp_var['1'];

		$seopage_select=trim($_POST['seo_page']);

		if($temp_var['0']=='c'){
			checkIfDirExists();
			$filename=$temp_var['1'];
			$file = basename($filename, ".html");			
			$filename="./settings/seo/content_pages/$file.txt";
			if(!$handle = fopen($filename, 'w')) 
			{
			 echo "Cannot open file ($filename)";
			 exit;
			}
			$content .=stripslashes($_REQUEST['website_page_title']);
			$content .=stripslashes("#_1_#".$_REQUEST['website_description']);
			$content .=stripslashes("#_1_#".$_REQUEST['website_keywords']);
			if(fwrite($handle, $content) === FALSE) 
			{
			echo "Cannot write to file ($filename)";
			exit;
			}
			fclose($handle);
			$_REQUEST['flag']=1;
			
		}
		else if($temp_var['0']=='o'){

		if($seopage=='index.php'){	
			
			$filename="settings/seo_settings.txt";	

			$content .=stripslashes($_REQUEST['website_page_title']) ;
			$content .="#_1_#";
			$content .=stripslashes($_REQUEST['website_description']) ;
			$content .="#_1_#";
			$content .=stripslashes($_REQUEST['website_keywords']) ;
			$content .="#_1_#";
			$content .=stripslashes($_REQUEST['track']) ;

			if(!$handle = fopen($filename, 'w')) 
			{
				echo "Cannot open file ($filename)";
				exit;
			}


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

			$_REQUEST['flag']=1;
		}
		else{

			$filename="settings/seo/$temp_var[1]";	
			$file = basename($filename, ".php");
			$filename="./settings/seo/$file.txt";
			checkIfDirExists();

			if(!$handle = fopen($filename, 'w')) 
			{
			 echo "Cannot open file ($filename)";
			 exit;
			}
			$content .=stripslashes($_REQUEST['website_page_title']);
			$content .=stripslashes("#_1_#".$_REQUEST['website_description']);
			$content .=stripslashes("#_1_#".$_REQUEST['website_keywords']);
			if(fwrite($handle, $content) === FALSE) 
			{
			echo "Cannot write to file ($filename)";
			exit;
			}
			fclose($handle);
			$_REQUEST['flag']=1;
		}

		}
		
		}


	
		if($handle = @fopen($filename, 'r')) 
		  {
			 $contents = fread($handle, filesize($filename));
             fclose($handle);
		     $argument_arr=explode("#_1_#",$contents);
		  }


?>
<!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">
<style type="text/css">
<!--
#help_page_title { display:none; }
#help_desc { display:none; }
#help_key { display:none; }
#help_track { display:none; }
#help_select { 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;
}

function loadSEOSettings(page){
	document.frmhid.page.value=page;
	document.frmhid.submit();
}

</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>
        <td width="645" align="center" valign="top"><table width="645" border="0" align="center" cellpadding="0" cellspacing="0">
		          <form name="frmhid" action="seo_settings.php" method="post" >
<input type='hidden' name='page' value=''>
</form>
          <form name="frm" action="seo_settings.php" method="post" >
            <input type="hidden" name="do_type" value="seo_settings_write">
            <tr>
              <td height="50" colspan="2" align="center" valign="middle" class="title1">Search Engine Optimization Website Settings </td>
            </tr>
            <?php
		if(!empty($_REQUEST['flag']) and $_REQUEST['flag']==1)
		  {
?>
            <tr>
              <td height="50" colspan="2" align="center" valign="middle" class="title1">&gt;&gt; <span class="style3">Data saved successfully</span> &lt;&lt;</td>
            </tr>
            <?php
		}
?>

            <tr>
              <td height="100" colspan="2" align="center" valign="middle" class="main2"><br>
                  Select Which Page to Optimize:<br />
                  <select name="seo_page"    class="remove"  onchange="loadSEOSettings(this.options[this.selectedIndex].value)">
                     <?php
					//loading php pages

					$pages=file('./settings/files.txt');
					foreach($pages as $key=>$value){ 
						$value=trim($value);
						?>
                          <option value="o|<?=$value?>"  <?php if($seopage_select=="o|".$value) { echo 'selected'; }
					?>> <?=$value?></option>
<?php
					}
					{
						
					?>
						 
 					<?php
					
					}
					//loading content pages

					$file_handle = fopen("settings/order_content.txt", "rb");
						while (!feof($file_handle) ) {
							$line_of_text = fgets($file_handle);
							$files = explode(';', $line_of_text);
						}
						fclose($file_handle);
						for($j=0;$j<count($files);$j++)
						{
							if(!empty($files[$j]))
							{

?>
								 <option value="c|<?=$files[$j]?>" <?php if($seopage_select=="c|".$files[$j]) { echo 'selected'; }?>>(Article)<?=$files[$j]?></option>

<?php
							}
						}
					?>
                  </select>
                  <a href="#" onClick="mm_showHide('help_select');return false;"><img src="images/help.gif" width="21" height="21" hspace="8" border="0" align="top"></a><br></td>
            </tr>
            <tr>
              <td colspan="2" align="center" valign="middle" class="main2"><div class="userhelp_cell" id="help_select">
                  <p><br>
                    Select which page you would like to optimize, then enter details for that page below.<br>
                      <br>
                      <br>
                  </p>
                </div></td>
            </tr>
            <tr>
              <td width="300" height="50" align="center" valign="middle" class="main2">Your Website Page Title (for S.E.O purposes):</td>
              <td width="345" height="50" align="left" valign="middle" class="main2"><input name="website_page_title" type="text" id="website_page_title" value="<?php echo $argument_arr['0']; ?>" style="width:280px">
                <a href="#" onClick="mm_showHide('help_page_title');return false;"><img src="images/help.gif" width="21" height="21" hspace="8" border="0" align="top"></a></td>
            </tr>
            <tr>
              <td colspan="2" align="center" valign="middle" class="main2"><div class="userhelp_cell" id="help_page_title">
                  <p><br>
                    Enter a page title for your website, this will only be visible in your web browser title bar.</p>
                <p>This is generally quite similar to your  website header title, however, you should try to add additional key words about your website into this title as it is used by search engines in the indexing of your website.
                      <br>
                      <br>
                  </p>
                </div></td>
            </tr>
            <tr>
              <td width="300" height="100" align="center" valign="middle" class="main2">Your Website Description (for S.E.O purposes):</td>
              <td width="345" height="100" align="left" valign="middle" class="main2"><textarea name="website_description" rows="4" style="width:280px"><?php echo $argument_arr['1']; ?></textarea>
                <a href="#" onClick="mm_showHide('help_desc');return false;"><img src="images/help.gif" width="21" height="21" hspace="8" border="0" align="top"></a></td>
            </tr>
            <tr>
              <td colspan="2" align="center" valign="middle" class="main2"><div class="userhelp_cell" id="help_desc">
                  <p><br>
                    Enter a description for your website, this is purely for Search Engine Optimization purposes.</p>
                <p>Your description has no limit in length, however, we suggest you use a maximum of 250 characters  and try to make it as unique as possible.</p>
                <p>You should also try to include some important key words in your description.
                      <br>
                      <br>
                  </p>
                </div></td>
            </tr>
            <tr>
              <td width="300" height="100" align="center" valign="middle" class="main2">Your Website Key Words (for S.E.O purposes):</td>
              <td width="345" height="100" align="left" valign="middle" class="main2"><textarea name="website_keywords" rows="4" style="width:280px"><?php echo $argument_arr['2']; ?></textarea>
                <a href="#" onClick="mm_showHide('help_key');return false;"><img src="images/help.gif" width="21" height="21" hspace="8" border="0" align="top"></a></td>
            </tr>
            <tr>
              <td colspan="2" align="center" valign="middle" class="main2"><div class="userhelp_cell" id="help_key">
                  <p><br>
                    Enter some key words for your website, this is purely for Search Engine Optimization purposes.</p>
                <p>Key words are simply words or short phrases that you would associate with your website. </p>
                <p>Your key words, again, have no limit in length, however, we suggest you use a maximum of 1000 characters, but this time they do not have to be in a coherent phrase as they were in the title and description, they simply need to be listed with a comma and a space after each word.<br>
                  Place your important keywords at the beginning, and make sure that all the keywords used in the title and the description are listed again.</p>
                <p>Google has a very good tool if you require a little help with your key words. You can view it <a href="https://adwords.google.com/select/KeywordToolExternal?defaultView=3" target="_blank"><u>here</u></a>.</p>
                <p><strong>example keywords</strong>: your, key, words, here<br>
                  <br>
                  <br>
                </p>
              </div></td>
            </tr>
		
		<?php
		if($seopage=='index.php'){?>

            <tr>
              <td height="100" align="center" valign="middle" class="main2">Your Website Tracking Code (optional):</td>
              <td height="100" align="left" valign="middle" class="main2"><textarea name="track" rows="10" id="track" style="width:280px"><?php echo $argument_arr['3']; ?></textarea>
                <a href="#" onClick="mm_showHide('help_track');return false;"><img src="images/help.gif" width="21" height="21" hspace="8" border="0" align="top"></a></td>
            </tr>
            <tr>
              <td colspan="2" align="center" valign="middle" class="main2_pad"><div class="userhelp_cell" id="help_track">
                  <p><br>
                    Enter your website tracking code here if required.<br>
                  (your complete code that you are given)</p>
                  <p>We highly recommend you track your websites progress to see what is working good for you and also, to see what is not working so good for you.<a href="https://adwords.google.com/select/KeywordToolExternal?defaultView=3" target="_blank"></a></p>
                  <p>This is an essential part of 'fine tuning' your website.</p>
                  <p>We can very highly recommend <a href="https://www.google.com/analytics" target="_blank"><u>Google Analytics</u></a> for website tracking.<br>
                    You can sign up for free <a href="https://www.google.com/analytics" target="_blank"><u>here</u></a>.
                    <br>
                    <br>
                  </p>
              </div></td>
            </tr>

		<?php }
		?>

            <tr>
              <td height="50" colspan="2" align="center" valign="middle" class="main2">&nbsp;</td>
            </tr>
            <tr>
              <td height="50" colspan="2" align="center" valign="middle" class="main2"><p>
                  <input type="submit" name="Submit" value="Save SEO Website Settings">
              </p></td>
            </tr>
            <tr>
              <td height="50" colspan="2" 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>