<?php

if(stristr(htmlentities($_SERVER['PHP_SELF']), "all.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
	
	$d = scandir("./articles");
	
	unset($d[0], $d[1]);#Remove '.' and '..' from the printed articles
	
	$cms = new NapataFileCMS;
	$cms->title = 'All Articles';
	$cms->SpecHeader();
	
	echo '<h3>All Articles</h3>';
	
	if($d[2] == '.htaccess') unset($d[2]); #Remove .htaccess from the array of text file articles. Indexing starts form 2 not 0.
	
	$count_all = count($d);
	
	echo '<p style="font-size: 15px; color: #aaa;">'. $count_all .' articles in total.</p>';
	
	echo '<ol>';
		
		foreach($d as $article) {
				
				if(substr($article, -4, 4) == '.txt')
				{
				
					echo '<li><a href="index.php?post='.basename($article, '.txt').'">'.ucwords(basename($article, '.txt')).'</a></li>';
					
				}
			
		}
	echo '</ol></div>';
	
	?>
	
	<div id="footer"><?php include_once("./footer.php"); echo footer($copyright);?></div>
	</body>
	</html>	