<?php

if(stristr(htmlentities($_SERVER['PHP_SELF']), "console.php")){
	die("You cannot access this file directly!");
}

# Copyright (C) 2010 - onwards. The Napata CMS Project.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# http://www.gnu.org/copyleft/gpl.html

if($_SESSION['logged'] != true)
{
	echo '<script type="text/javascript">
	<!--
	window.location.replace("index.php?page=Login");
	//-->
	</script>>';
}

require_once("./npt-file-cms.php");

$cms = new NapataFileCMS;
$cms->ChangePassword ($_POST['password1'],$_POST['password2']);
//$cms->Console();


function Console(){
require_once("./npt-file-cms.php");

$cms = new NapataFileCMS;
$cms->title = 'Console';
$cms->SpecHeader();

if(isset($_GET['success']) && $_GET['success'] == '1')
{

	echo "<p style='padding: 10px; background-color: #f2f5a9; border: 1px solid #0000ff;'>Your password has been saved successfully.</p>";
	
}

if(isset($_POST['change_password']) && $cms->PasswordsMatch($_POST['password1'],$_POST['password2']) == false)
{
		
	echo "<p style='padding: 10px; background-color: #ffe4e1; border: 1px solid #0000ff;'>Passwords do not match. Please <a href='index.php?page=console'>try again</a></p>";
			
}

$cms->HandleArticleUploads();

?>
	<h2>Change your Password</h2>
	<form method="post" action="index.php?page=console">
	<p>Please fill in your new password.</p>
	<label>New Password</label><br>
	<input type="password" name="password1" value="" size="80"/><br>
	<label>Confirm password</label><br>
	<input type="password" name="password2" value="" size="80"/>
	<br>
	<input type="submit" name="change_password" value="Change Password" />
	</form>
	
	<h2>Upload your Articles</h2>
	<p>Here are some quick guidelines on the formatting of your articles for upload:
	<ul>
	<li>For the Headings hierarchy, start with the &lt;h2&gt;&lt;/h2&gt; (this is optional) section heading at the very top. The page's title uses the &lt;h1&gt; tags.</li>
	<li>All files should be saved in <strong>plain text</strong> format.</li>
	<li>You can use full HTML tags in your article. All &lt;script&gt; tags will be stripped off from your content.</li>
	<li>Name your files <strong>descriptively</strong>. All file names are printed on the menu bar as article titles.</li>
	<li>You can use FTP to move your files to the server. FTP your articles to the <strong>articles</strong> directory.</li>
	</ul>
	</p>
	<strong>Please note that all files should be text files only</strong>
	<?php if(file_exists('./articles') && !is_writeable('./articles')) {echo "<div style='padding: 10px; background-color: #f2f5a9; border: 1px solid #0000ff;'>The content folder is not writeable. Please change its file permssions top ensure successful uploading of your articles.</div>";}else{ echo "<div style='padding: 10px; background-color: #f2f5a9; border: 1px solid #0000ff;'>The articles folder is writeable.</div><br />"; }?>
	
	<form action="index.php?page=console" method="post" enctype="multipart/form-data">
	<input type="hidden" name="MAX_FILE_SIZE" value="80000" />
	<input type="file" name="articles" size="80" />
	<br>
	<input type="submit" value="Upload_Article">
	</form>
	</div>
	<div id="footer"><?php include_once("./footer.php"); echo footer($copyright);?></div>
	</body>
	</html>
	
<?php

}

Console();
?>