###########################################################################
#	- MemHT Portal -
#	
#	Copyright (C) 2007-2008 by Miltenovik Manojlo
#	http://www.memht.com
#	
#	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; either version 2 of the License, or
#	(at your opinion) any later version.
#	
#	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, see <http://www.gnu.org/licenses/> (GPLv2)
#	or write to the Free Software Foundation, Inc., 51 Franklin Street,
#	Fifth Floor, Boston, MA02110-1301, USA.
#
###########################################################################

# =========================================================================
# Files protection
# =========================================================================
<Files .htaccess>
	order allow,deny
	deny from all
</Files>

# =========================================================================
# Error handler
# =========================================================================
# Change the site path if needed
# Example:
# ErrorDocument 404 /folder/index.php?page=error&cod=404
# -------------------------------------------------------------------------
ErrorDocument 500 /index.php?page=error&cod=500
ErrorDocument 404 /index.php?page=error&cod=404
ErrorDocument 403 /index.php?page=error&cod=403
ErrorDocument 401 /index.php?page=error&cod=401
ErrorDocument 400 /index.php?page=error&cod=400

# =========================================================================
# Security settings
# =========================================================================
<IfModule mod_php5.c>
	php_value register_globals 0
	php_value magic_quotes_gpc 0
	php_value session.auto_start 0
	php_value safe_mode 0
</IfModule>

<IfModule sapi_apache2.c>
	php_value register_globals 0
	php_value magic_quotes_gpc 0
	php_value session.auto_start 0
	php_value safe_mode 0
</IfModule>

<IfModule mod_php4.c>
	php_value register_globals 0
	php_value magic_quotes_gpc 0
	php_value session.auto_start 0
	php_value safe_mode 0
</IfModule>

# =========================================================================
# Rewrite Engine
# =========================================================================
<IfModule mod_rewrite.c>
	RewriteEngine On

	# -------------------------------------------
	# Change the site path if needed
	# Example:
	# RewriteBase  /folder/
	# -------------------------------------------
	RewriteBase /
	
	# Index -------------------------------------
	RewriteRule ^index.html*$ index.php [L]
	
	# Archive -----------------------------------
	RewriteRule ^archive.html*$ index.php?page=archive [L]
	RewriteRule ^archive_([^_]+)_([0-9]+)_([0-9]+).html*$ index.php?page=archive&arg=$1&year=$2&month=$3 [L]
	
	# Articles ----------------------------------
	RewriteRule ^articles.html*$ index.php?page=articles [L]
	RewriteRule ^articles_argument_([0-9]+)_([^_]+).html*$ index.php?page=articles&op=arg&id=$1&title=$2 [L]
	RewriteRule ^articles_([0-9]+)_([^_]+).html*$ index.php?page=articles&op=readArticle&id=$1&title=$2 [L]
	RewriteRule ^articles_([0-9]+)_([^_]+)_([0-9]+).html*$ index.php?page=articles&op=readArticle&id=$1&title=$2&pg=$3 [L]
	
	# Blog --------------------------------------
	RewriteRule ^blog.html*$ index.php?page=blog [L]
	RewriteRule ^blog_([0-9]+).html*$ index.php?page=blog&pg=$1 [L]
	RewriteRule ^blog_categories.html*$ index.php?page=blog&op=categories [L]
	RewriteRule ^blog_archive_([0-9]+)_([0-9]+).html*$ index.php?page=blog&year=$1&month=$2 [L]
	RewriteRule ^blog_archive_([0-9]+)_([0-9]+)_([0-9]+).html*$ index.php?page=blog&year=$1&month=$2&pg=$3 [L]
	RewriteRule ^blog_view_([0-9]+)_([^_]+).html*$ index.php?page=blog&id=$1&title=$2 [L]
	RewriteRule ^blog_category_([0-9]+)_([^_]+).html*$ index.php?page=blog&cid=$1&category=$2 [L]
	RewriteRule ^blog_category_([0-9]+)_([^_]+)_([0-9]+).html*$ index.php?page=blog&cid=$1&category=$2&pg=$3 [L]
	
	# Contact -----------------------------------
	RewriteRule ^contact.html*$ index.php?page=contact [L]
	
	# Download ----------------------------------
	RewriteRule ^download.html*$ index.php?page=download [L]
	RewriteRule ^download_([0-9]+)_([^_]+).html*$ index.php?page=download&op=category&id=$1&title=$2 [L]
	RewriteRule ^download_([0-9]+)_([^_]+)_([0-9]+).html*$ index.php?page=download&op=category&id=$1&title=$2&pg=$3 [L]
	RewriteRule ^download_file_([0-9]+)_([^_]+).html*$ index.php?page=download&op=getFile&id=$1&title=$2 [L]

	# Faq ---------------------------------------
	RewriteRule ^faq.html*$ index.php?page=faq [L]
	RewriteRule ^faq_([0-9]+)_([^_]+).html*$ index.php?page=faq&op=arg&id=$1&title=$2 [L]
	RewriteRule ^faq_([0-9]+)_([^_]+)_([0-9]+).html*$ index.php?page=faq&op=arg&id=$1&title=$2&pg=$3 [L]
	RewriteRule ^faq_([0-9]+).html*$ index.php?page=faq&op=read&id=$1 [L]
	
	# Forum -------------------------------------
	RewriteRule ^forum.html*$ index.php?page=forum [L]
	RewriteRule ^forum_category_([0-9]+)_([^_]+).html*$ index.php?page=forum&op=viewCategory&id=$1&title=$2 [L]
	RewriteRule ^forum_list_([0-9]+)_([^_]+).html$ index.php?page=forum&op=viewForum&id=$1&title=$2 [L]
	RewriteRule ^forum_list_([0-9]+)_([^_]+)_([0-9]+).html$ index.php?page=forum&op=viewForum&id=$1&title=$2&pg=$3 [L]
	RewriteRule ^forum_thread_([0-9]+)_([^_]+).html$ index.php?page=forum&op=viewThread&id=$1&title=$2 [L]
	RewriteRule ^forum_thread_([0-9]+)_([^_]+)_([0-9]+).html$ index.php?page=forum&op=viewThread&id=$1&title=2&pg=$3 [L]
	RewriteRule ^forum_newthread_([0-9]+).html$ index.php?page=forum&op=newThread&id=$1 [L]
	RewriteRule ^forum_reply_([0-9]+).html$ index.php?page=forum&op=reply&id=$1 [L]
	RewriteRule ^forum_quote_([0-9]+)_([0-9]+).html$ index.php?page=forum&op=reply&id=$1&quote=$2 [L]
	RewriteRule ^forum_edit_([0-9]+).html$ index.php?page=forum&op=editPost&id=$1 [L]
	RewriteRule ^forum_delete_([0-9]+).html$ index.php?page=forum&op=deletePost&id=$1 [L]
	
	# Gallery -----------------------------------
	RewriteRule ^gallery.html$ index.php?page=gallery [L]
	RewriteRule ^gallery_([0-9]+)_([^_]+).html$ index.php?page=gallery&op=showGallery&id=$1&title=$2 [L]
	RewriteRule ^gallery_([0-9]+)_([^_]+)_([0-9]+).html$ index.php?page=gallery&op=showGallery&id=$1&title=$2&pg=$3 [L]
	
	# Guide -------------------------------------
	RewriteRule ^guide.html$ index.php?page=guide [L]
	RewriteRule ^guide_argument_([0-9]+)_([^_]+).html$ index.php?page=guide&op=arg&id=$1&title=$2 [L]
	RewriteRule ^guide_argument_([0-9]+)_([^_]+)_([0-9]+).html$ index.php?page=guide&op=arg&id=$1&title=$2&pg=$3 [L]
	RewriteRule ^guide_([0-9]+)_([^_]+).html$ index.php?page=guide&op=readGuide&id=$1&title=$2 [L]
	RewriteRule ^guide_([0-9]+)_([^_]+)_([0-9]+).html$ index.php?page=guide&op=readGuide&id=$1&title=$2&pg=$3 [L]
		
	# MyLinks -----------------------------------
	RewriteRule ^mylinks.html$ index.php?page=mylinks [L]
	RewriteRule ^mylinks_([0-9]+)_([^_]+).html$ index.php?page=mylinks&op=showCategory&id=$1&title=$2 [L]
	RewriteRule ^mylinks_([0-9]+)_([^_]+)_([0-9]+).html$ index.php?page=mylinks&op=showCategory&id=$1&title=$2&pg=$3 [L]
	RewriteRule ^mylinks_add_([0-9]+).html$ index.php?page=mylinks&op=addLink&id=$1 [L]
	
	# MyPage ------------------------------------
	RewriteRule ^mypage.html$ index.php?page=mypage [L]
	RewriteRule ^mypage_([0-9]+)_([^_]+).html$ index.php?page=mypage&op=openPage&id=$1&title=$2 [L]
	RewriteRule ^mypage_([0-9]+)_([^_]+)_([0-9]+).html$ index.php?page=mypage&op=openPage&id=$1&title=$2&pg=$3 [L]
	
	# News --------------------------------------
	RewriteRule ^news.html$ index.php?page=news [L]
	RewriteRule ^news_pg_([0-9]+).html$ index.php?page=news&pg=$1 [L]
	RewriteRule ^news_([0-9]+)_([^_]+).html$ index.php?page=news&op=readNews&id=$1&title=$2 [L]
	
	# Newsletter --------------------------------
	RewriteRule ^newsletter.html$ index.php?page=newsletter [L]
	
	# Partners ----------------------------------
	RewriteRule ^partners.html$ index.php?page=partners [L]
	RewriteRule ^partners_([0-9]+).html$ index.php?page=partners&op=openPartnerLink&id=$1 [L]
	
	# Pdf ---------------------------------------
	RewriteRule ^pdf_([^_]+)_([0-9]+)\.pdf$ pages/$1/pdf.php?id=$2 [L]
	
	# Pvt Messages ------------------------------
	RewriteRule ^pvtmsg.html$ index.php?page=pvtmsg [L]
	RewriteRule ^pvtmsg_([0-9]+).html$ index.php?page=pvtmsg&pg=$1 [L]
	RewriteRule ^pvtmsg_view_([0-9]+).html$ index.php?page=pvtmsg&op=viewMessage&id=$1 [L]
	RewriteRule ^pvtmsg_new.html$ index.php?page=pvtmsg&op=newMessage [L]
	RewriteRule ^pvtmsg_new_([^_]+).html$ index.php?page=pvtmsg&op=newMessage&recipient=$1 [L]
	RewriteRule ^pvtmsg_reply_([0-9]+).html$ index.php?page=pvtmsg&op=reply&id=$1 [L]
	RewriteRule ^pvtmsg_delete_([0-9]+).html$ index.php?page=pvtmsg&op=delete&id=$1 [L]
	RewriteRule ^pvtmsg_delete_([0-9]+)_ok.html$ index.php?page=pvtmsg&op=delete&id=$1&ok=true [L]
	
	# RSS ---------------------------------------
	RewriteRule ^rss.html$ index.php?page=rss [L]
	RewriteRule ^rss\-([^-]+)\.xml$ rss.php?page=$1 [L]
	RewriteRule ^rss\-(blog|download)\-([0-9]+)\.xml$ rss.php?page=$1&cat=$2 [L]
	RewriteRule ^rss\-(articles|guide|news)\-([0-9]+)\.xml$ rss.php?page=$1&topic=$2 [L]
	RewriteRule ^rss\-(articles|guide|news)\-([0-9]+)-([0-9]+)\.xml$ rss.php?page=$1&topic=$2&items=$3 [L]
	RewriteRule ^rss\-forum\-([0-9]+)\.xml$ rss.php?page=forum&forum=$1 [L]
	RewriteRule ^sitemap\.xml$ sitemap.php [L]
	
	# Search ------------------------------------
	RewriteRule ^search.html$ index.php?page=search [L]
	
	# Send File ---------------------------------
	RewriteRule ^sendfile.html$ index.php?page=sendfile [L]
	
	# Send News ---------------------------------
	RewriteRule ^sendnews.html$ index.php?page=sendnews [L]
	
	# SiteMap -----------------------------------
	RewriteRule ^sitemap.html$ index.php?page=sitemap [L]
	
	# Staff -------------------------------------
	RewriteRule ^staff.html$ index.php?page=staff [L]
	
	# Surveys -----------------------------------
	RewriteRule ^surveys.html$ index.php?page=surveys [L]
	RewriteRule ^surveys_result_([0-9]+).html$ index.php?page=surveys&op=result&id=$1 [L]
	
	# Tags --------------------------------------
	RewriteRule ^tags.html$ index.php?page=tags [L]
	RewriteRule ^tags_([^_]+).html$ index.php?page=tags&op=list&tag=$1 [L]
	
	# Topics ------------------------------------
	RewriteRule ^topics.html$ index.php?page=topics [L]
	
	# Users -------------------------------------
	RewriteRule ^users.html$ index.php?page=users [L]
	RewriteRule ^users_edit.html$ index.php?page=users&op=editProfile [L]
	RewriteRule ^users_logout.html$ index.php?page=users&logout=1 [L]
	RewriteRule ^users_register.html$ index.php?page=users&op=register [L]
	RewriteRule ^users_lostpassword.html$ index.php?page=users&op=lostPassword [L]
	RewriteRule ^users_infoid_([0-9]+).html$ index.php?page=users&op=userInfo&uid=$1 [L]
	RewriteRule ^users_info_([^_]+).html$ index.php?page=users&op=userInfo&usert=$1 [L]
</IfModule>