Location: PHPKode > projects > Simple PHP Shopping cart - asaancart > asaancart v-0.9/admin/manage_content.php
<?php
session_start();
/*
asaancart - easy shopping cart solution
---------------------------------------

Copyright 2009 Nasir Ahmad Khan
Email: hide@address.com

This file is part of asaancart - open source easy shopping cart solution.

asaancart 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 3 of the License, or
(at your option) any later version.

asaancart 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 asaancart.  If not, see <http://www.gnu.org/licenses/>.

*/

include("../config/config.php");
include("includes/chk_login_status_inc.php");

$smarty->assign('title','Manage Content Page');
$smarty->assign('msg', "");

if($_POST['btn_submit']=="Create"){

	$page_name = $_POST['page_name'];
	$page_name = str_replace("'","\'",$page_name);
	$page_name = str_replace("&","&amp;",$page_name);
	
	$page_title = $_POST['page_title'];
	$page_title = str_replace("'","\'",$page_title);
	$page_title = str_replace("&","&amp;",$page_title);
	
	$page_text = $_POST['page_text'];
	$page_text = str_replace('"','\"',$page_text);
	$page_text = str_replace("'","\'",$page_text);
	$page_text = str_replace("&","&amp;",$page_text);
	

	$sql = "SELECT * FROM content_page WHERE page_name='".$page_name."'";
	$results = mysql_query($sql);
	$total_page = mysql_num_rows($results);
	if($total_page>0){
		$smarty->assign('msg', "<span style='color:red'>Sorry, this page has already been created</span>");
	}else{
		$sql = "INSERT INTO content_page (page_name, page_title, page_text) VALUES ('$page_name', '$page_title', '$page_text')";
		$results = mysql_query($sql);
		$smarty->assign('msg', "<span>Done, page successfully created</span>");
	}//page cnt	
}

if($_POST['btn_submit']=="Save"){

	$page_id = $_POST['page_id'];
	
	
	$page_name = $_POST['page_name'];
	$page_name = str_replace("'","\'",$page_name);
	$page_name = str_replace("&","&amp;",$page_name);
	
	$page_title = $_POST['page_title'];
	$page_title = str_replace("'","\'",$page_title);
	$page_title = str_replace("&","&amp;",$page_title);
	
	$page_text = $_POST['page_text'];
	$page_text = str_replace('"','\"',$page_text);
	$page_text = str_replace("'","\'",$page_text);
	$page_text = str_replace("&","&amp;",$page_text);
	
	

	$sql = "UPDATE content_page SET page_name='$page_name', page_title='$page_title', page_text='$page_text' WHERE page_id='".$page_id."'";
	$results = mysql_query($sql);
	$smarty->assign('msg', "<span>Done, page successfully saved</span>");
}

if($_GET['action']=="showPageContent"){
	$sql = "SELECT * FROM content_page WHERE page_id=".$_GET['page_id'];
	$results = mysql_query($sql);
	$total_page = mysql_num_rows($results);
	if($total_page>0){
		while($row = mysql_fetch_assoc($results) )
		{
			$page_content[] = $row;		
		}
	}else{
	$total_page = 0;
	}//page cnt	
	$smarty->assign('total_page', $total_page);	
	$smarty->assign('page_content', $page_content);
	$smarty->display('show_page_content.tpl');
	
}elseif($_GET['action']=="deletePage"){
	$sql = "DELETE FROM content_page WHERE page_id=".$_GET['page_id'];
	$results = mysql_query($sql);
	
		//manage
	$sql = "SELECT * FROM content_page ORDER BY page_name";
	$results = mysql_query($sql);
	$total_page = mysql_num_rows($results);
	$smarty->assign('total_page', $total_page);
	
	while($row = mysql_fetch_assoc($results) )
	{
		$page_list[] = $row;	
	}
	
	$smarty->assign('page_list', $page_list);
	//end manage
	$smarty->display('list_all_contents.tpl');
}elseif($_GET['action']=="updateSelectList"){
			//manage
	$sql = "SELECT * FROM content_page ORDER BY page_name";
	$results = mysql_query($sql);
	
	while($row = mysql_fetch_assoc($results) )
	{
		$page_list[] = $row;	
	}
	
	$smarty->assign('page_list', $page_list);
	//end manage
	$smarty->display('select_list_content.tpl');

}else{

	//manage
	$sql = "SELECT * FROM content_page ORDER BY page_name";
	$results = mysql_query($sql);
	$total_page = mysql_num_rows($results);
	$smarty->assign('total_page', $total_page);
	
	while($row = mysql_fetch_assoc($results) )
	{
		$page_list[] = $row;	
	}
	
	$smarty->assign('page_list', $page_list);
	//end manage
	
	$smarty->display('manage_content.tpl');
}
?>
Return current item: Simple PHP Shopping cart - asaancart