Location: PHPKode > projects > chillyCMS > chillyCMS/admin/content.include.php
<?php
//#################################################################################################
//	Content helper functions
//#################################################################################################
//	chillyCMS - Content Management System
//	Copyright (C) 2008
//	Stefanie Wiegand <hide@address.com> & Johannes Cox <hide@address.com>
//	
//	This program is licensed under the GPL 3.0 license. For more information see LICENSE.txt.
//#################################################################################################
//	add_menu()
//	get_order()
//	print_tree($id)
//	navigation()
//	switch_status_content($status,$id)
//	delete_content($id)
//	switch_access($id,$access)
//	create_menu($name)
//	change_startpage($id)
//#################################################################################################
defined('DOIT') or die('Restricted access');

//Show "Add Menu" Section//////////////////////////////////////////////////////////////////////////
function add_menu() {
	global $l_cont,$is_admin,$l_gen;
	$addmenu = "\t<div class='sortcontent'>\n".
	"\t\t<h1>$l_cont[lbl_manage]</h1>\n".
	//A>Z
	"\t\t<form method='post' action='content.site.php'><input type='hidden' name='order' value='alphaasc' />".
	"<input type='submit' class='linkbutton' value='A>Z' /></form>\n".
	//Z>A
	"\t\t<form method='post' action='content.site.php'><input type='hidden' name='order' value='alphdesc' />".
	"<input type='submit' class='linkbutton' value='Z>A' /></form>\n".
	//old>new
	"\t\t<form method='post' action='content.site.php'><input type='hidden' name='order' value='dateasc' />".
	"<input type='submit' class='linkbutton' value='$l_gen[lbl_old]>$l_gen[lbl_new]' /></form>\n".
	//new>old
	"\t\t<form method='post' action='content.site.php'><input type='hidden' name='order' value='datedesc' />".
	"<input type='submit' class='linkbutton' value='$l_gen[lbl_new]>$l_gen[lbl_old]' /></form>\n".
	"\t</div>\n";
	if ($is_admin) {
		$addmenu .= "\t<div class='addmenu'>\n".
		"\t\t<form action='content.site.php' method='post'>\n".
		"\t\t\t<input type='hidden' name='action' value='newmenu' />\n".
		"\t\t\t<input type=\"submit\" class='button floatright' value=\"".$l_cont["lbl_newmenu"].
		"\" title=\"".$l_cont["lbl_addmenu"]."\" />\n".
		"\t\t\t<input type='text' name='name' value='NewMenu' class='textinput floatmargin' />\n".
		"\t\t</form>\n".
		"\t</div>\n";
	}
	$addmenu .= "\t<div class='clr'></div>\n";
	return $addmenu;
}
//Find out the right order of the items////////////////////////////////////////////////////////////
function get_order() {
	global $order;
	//find out the order
	$orders=array(	'alphaasc'	=> 'order by `name` asc',
			'alphdesc'	=> 'order by `name` desc',
			'dateasc'	=> 'order by `date_new` asc',
			'datedesc'	=> 'order by `date_new` desc');
	//--look for cookie if nothing was set
	if (!isset($_POST['order'])) {
		if (isset($_COOKIE['chillyCMS']) && is_array($_COOKIE['chillyCMS'])) {
			foreach ($_COOKIE['chillyCMS'] as $cookie=>$value) {
				if ($cookie == 'contentorder' and isset($orders[$value])) {
					$orderby = $orders[$value];
				} else {
					$orderby = $orders['alphaasc'];
				}
			}
		} else {
			$orderby = $orders[$order];
		}
	} else {
		setcookie('chillyCMS[contentorder]',$order);
		$orderby = $orders[$order];
	}
	return $orderby;
}
//Print ONE menu///////////////////////////////////////////////////////////////////////////////////
function print_tree($id) {
	global $l_cont,$l_gen,$l_edit,$is_admin,$mysession,$groups,$settings,$is_user;
	$menuitems=get_tree($id);
	$tree = "";
	//generate table
	$style="odd";
	$empty=true;
	if(!empty($menuitems)) {
		foreach ($menuitems as $mi) {
			$mi->name=escape_html($mi->name);
			$sa=explode(",",$mi->specialaccess);
			$in_group=$is_mod=false;
			foreach ($sa as $s) {
				//Is the user in that group the item belongs to?
				if(in_array($s,$mysession->user->gids)) {
					if ($mysession->user->gids_assoc[$s]=="w") {
						$in_group="w";
					} else {
						if ($in_group!="w") { $in_group="r"; }
					}
				}
				//Is the user the moderator of that group?
				if (in_array($s,$mysession->user->modgids)) {
					if ($mysession->user->modgids_assoc[$s]=="w") {
						$is_mod="w";
					} else {
						if ($is_mod!="w") { $is_mod="r"; }
					}
				}
			}
			$writeright=($is_admin or $mi->access==0 or ($in_group=="w"));
			$readright=($writeright or $is_admin or $mi->access==0
			or ($mi->access==1 && $is_user) or ($in_group=="r"));
			
			//content can only be seen by admins and groupcontent by the matching groups
			if ($is_admin or $in_group or $mi->depth==0 or $mi->access<2) {
				//Status links
					$title=false;
					if ($mi->active==0) {
						$status="imageinactive";
						$value="active";
						if ($is_admin or ($in_group && $is_mod)) {
							$title=$l_gen["tip_act"];
						}
					} else {
						$status="imageactive";
						$value="inactive";
						if ($is_admin or ($in_group && $is_mod)) {
							$title=$l_gen["tip_inact"];
						}
					}
					if ($title) {
						$status="\t\t\t\t<form method='post' action='content.site.php'>\n".
						"\t\t\t\t\t<input type='hidden' name='action' value='switch' />\n".
						"\t\t\t\t\t<input type='hidden' name='status' value='$value' />\n".
						"\t\t\t\t\t<input type='hidden' name='id' value='$mi->id' />\n".
						"\t\t\t\t\t<input type='submit' value=\" \" class='$status' title='$title' />\n".
						"\t\t\t\t</form>\n";
					} else {
						$status="\t\t\t\t<a class='$status'></a>\n";
					}
				//Startpage?
				$startpage=$mi->startpage;
				if ($startpage==1) {
					$startpage="\t\t\t\t<a class='homeyes'></a>";
				} else {
					if ($is_admin) {
						$startpage="\t\t\t\t<form method='post' action='content.site.php'>\n".
						"\t\t\t\t\t<input type='hidden' name='action' value='changestartpage' />\n".
						"\t\t\t\t\t<input type='hidden' name='id' value='$mi->id' />\n".
						"\t\t\t\t\t<input type='submit' class='homeno' value=\" \" ".
						"title='$l_cont[tip_startpage]' />\n".
						"\t\t\t\t</form>\n";
					} else {
						$startpage="\t\t\t\t<a class='homeno'></a>\n";
					}	
				}
				//Padding
				$padding=$mi->depth*15;
				$padding="style='padding-left:".$padding."px;'";
				//Modtype
				$modtype=$mi->modname;
				//General Access
				if ($mi->access==0) { $access=$l_cont["lbl_everybody"]; }
				else if ($mi->access==1) { $access=$l_cont["lbl_users"]; }
				else if ($mi->access==2) { $access=$l_cont["lbl_admins"]; }
				if ($is_admin) {
					$access = "\t\t\t\t<form method='post' action='content.site.php'>\n".
					"\t\t\t\t\t<input type='hidden' name='action' value='switchaccess' />\n".
					"\t\t\t\t\t<input type='hidden' name='access' value='$mi->access' />\n".
					"\t\t\t\t\t<input type='hidden' name='id' value='$mi->id' />\n".
					"\t\t\t\t\t<input type='submit' class='linkbutton' ".
					"value='$access' title='$l_cont[tip_switchacc]' />\n".
					"\t\t\t\t</form>\n";
				}
				//Special Access
				if ($mi->specialaccess!="") {
					//get groupname of each group that has specialaccess
					$sa=explode(",",$mi->specialaccess);
					$specialgroups=array();
					foreach ($groups as $g) {
						if (in_array($g["gid"],$sa) && !in_array($g["name"],$specialgroups)) {
							$specialgroups[]=$g["name"];
						}
					}
					if (!empty($specialgroups)) {
						$specialgroups=implode(", ",$specialgroups);
					}
					//make symbol
					$access.="\t\t\t\t<a class='special floatleft' title='$specialgroups'></a>\n";
				}
				//Move actions
				$move="";
				if ($is_admin or ($in_group && $is_mod && $mi->depth>0)) {
					$direction=$filler=false;
					//--up
					if ($mi->prev>0) {
						$move.="\t\t\t\t<form method='post' action='content.site.php'>\n".
						"\t\t\t\t\t<input type='hidden' name='action' value='move' />\n".
						"\t\t\t\t\t<input type='hidden' name='direction' value='up' />\n".
						"\t\t\t\t\t<input type='hidden' name='id' value='$mi->id' />\n".
						"\t\t\t\t\t<input type='submit' value=\" \" class='up' ".
						"title='$l_gen[tip_movu]' />\n".
						"\t\t\t\t</form>\n";
					} else {
						$move.="\t\t\t\t<a class='filler'></a>\n";
					}
					//--down
					if ($mi->next>0) {
						$move.="\t\t\t\t<form method='post' action='content.site.php'>\n".
						"\t\t\t\t\t<input type='hidden' name='action' value='move' />\n".
						"\t\t\t\t\t<input type='hidden' name='direction' value='down' />\n".
						"\t\t\t\t\t<input type='hidden' name='id' value='$mi->id' />\n".
						"\t\t\t\t\t<input type='submit' value=\" \" class='down' ".
						"title='$l_gen[tip_movd]' />\n".
						"\t\t\t\t</form>\n";
					} else {
						$move.="\t\t\t\t<a class='filler'></a>\n";
					}
				}
				//edit link
				if(strlen($mi->name) > 20) {
					$printname=substr($mi->name,0,17)."...";
				} else {
					$printname=$mi->name;
				}
				if (($mi->access==0) or $readright or $writeright) {
					$editlabel=$l_gen["lbl_edit"]." \"".$mi->name."\"";
					$editlink="\t\t\t\t<form method='post' action='edit.site.php'>\n".
					"\t\t\t\t\t<input type='hidden' name='id' value='$mi->id' />\n".
					"\t\t\t\t\t<input type='submit' class='edit' value=\" \" title='$editlabel' />\n".
					"\t\t\t\t</form>\n";
					$namelink="\t\t\t\t<form method='post' action='edit.site.php'>\n".
					"\t\t\t\t\t<input type='hidden' name='id' value='$mi->id' />\n".
					"\t\t\t\t\t<input type='submit' class='linkbutton' value='$printname' title='$editlabel' />\n".
					"\t\t\t\t</form>\n";
				} else {
					$editlink="";
					$namelink=$printname;
				}
				//delete link
				if ($is_admin or ($in_group && $is_mod)) {
					$deletelabel=$l_gen["lbl_delete"]." \"".$mi->name."\"";
					$delete="\t\t\t\t<form method='post' action='content.site.php'>\n".
					"\t\t\t\t\t<input type='hidden' name='action' value='delete' />\n".
					"\t\t\t\t\t<input type='hidden' name='id' value='$mi->id' />\n".
					"\t\t\t\t\t<input type='submit' class='delete' value=\" \" ".
					js_confirm_link($mi->name.$l_gen["pop_del"]).
					"title='$deletelabel' />\n".
					"\t\t\t\t</form>\n";
				}
				//"real" print section
				$addlabel="$l_cont[tip_adda] $mi->name";
				//--the item is a menu
				if ($mi->depth==0) {
					$empty=false;
					$symbol="<a class='menumenu' title='$l_cont[tip_menu]'></a>";
					$tree .= "\t\t<table cellspacing='0' width='100%' class=\"realtable\">\n".
					"\t\t<thead>\n".
					"\t\t<tr>\n".
					"\t\t\t<th width='10%' $padding>$symbol</th>\n".
					"\t\t\t<th width='30%' class='left' $padding>\n$namelink\t\t\t</th>\n".
					"\t\t\t<th width='5%' class='center'>$l_cont[lbl_startpage]?</th>\n".
					"\t\t\t<th width='10%'>$l_edit[lbl_modid]</th>\n".
					"\t\t\t<th width='15%' class='left'>$l_gen[lbl_access]</th>\n";
					//move
					$tree .= "\t\t\t<th width='10%'>";
					if ($is_admin or $is_mod) { $tree .= $l_gen['lbl_move']; }
					$tree .= "</th>\n";
					//status
					$tree .= "\t\t\t<th width='5%' class='center'>$l_gen[lbl_status]</th>\n".
					//edit
					"\t\t\t<th class='center' width='5%'>\n$editlink\t\t\t</th>\n".
					//new
					"\t\t\t<th width='5%'>\n";
					if ($is_admin or $in_group) {
						$tree .= "\t\t\t\t<form method='post' action='edit.site.php'>\n".
						"\t\t\t\t\t<input type='hidden' name='id' value='0' />\n".
						"\t\t\t\t\t<input type='hidden' name='depth' value='1' />\n".
						"\t\t\t\t\t<input type='hidden' name='parent' value='$mi->id' />\n".
						"\t\t\t\t\t<input type='submit' value=\" \" class='newarticle' title='$addlabel' />\n".
						"\t\t\t\t</form>\n";
					}
					$tree .= "\t\t\t</th>\n";
					//delete
					$tree .= "\t\t\t<th width='5%'>\n";
					if ($is_admin or $is_mod) {
						$tree .= $delete;
					}
					$tree .= "\t\t\t</th>\n".
					"\t\t</tr>\n".
					"\t\t</thead>\n";
				} else {
					$add="";
					$symbol="<a class='menuarticle' title='$l_cont[tip_art]'></a>";
					//--the item is an article
		 			if ($is_admin or $in_group) {
		 				$newdepth=$mi->depth+1;
		 				if ($newdepth<=$settings["max_menudepth"]) {
							$add = "\t\t\t\t<form method='post' action='edit.site.php'>\n".
							"\t\t\t\t\t<input type='hidden' name='id' value='0' />\n".
							"\t\t\t\t\t<input type='hidden' name='depth' value='$newdepth' />\n".
							"\t\t\t\t\t<input type='hidden' name='parent' value='$mi->id' />\n".
							"\t\t\t\t\t<input type='submit' value=\" \" class='newarticle' title='$addlabel' />\n".
							"\t\t\t\t</form>\n";
						}
					}
					//--the item is a module
					if ($mi->modid>1) {
						$symbol="<a class='menumodule' title='$l_cont[tip_mod]'></a>";
					}
					$tree .= "\t\t<tr class='$style'>\n".
					//symbol
					"\t\t\t<td class='left' $padding>$symbol</td>\n".
					//name
					"\t\t\t<td class='left' $padding>\n$namelink\t\t\t</td>\n".
					//startpage
					"\t\t\t<td>\n$startpage\t\t\t</td>\n".
					//modtype
					"\t\t\t<td class='left'>$modtype</td>\n".
					//access
					"\t\t\t<td class='left'>\n$access\t\t\t</td>\n";
					//move
					$tree .= "\t\t\t<td>\n";
					if ($is_admin or $is_mod) { $tree .= $move; }
					$tree .= "\t\t\t</td>\n";
					//status
					$tree .= "\t\t\t<td>\n$status\t\t\t</td>\n".
					//edit
					"\t\t\t<td>\n$editlink\t\t\t</td>\n";
					//new/delete
					$tree .= "\t\t\t<td>\n";
					if ($is_admin or $in_group) { $tree .= $add; }
					$tree .= "\t\t\t</td>\n".
					"\t\t\t<td>\n";
					if ($is_admin or $is_mod) { $tree .= $delete; }
					$tree .= "\t\t\t</td>\n".
					"\t\t</tr>\n";
					if ($style=="odd") { $style="even"; } else { $style="odd"; }
				}
			}
		}
	}
	if (!$empty) {
		$tree .= "\t</table><br /><br />\n";
	}
	return $tree;
}
//Print all trees//////////////////////////////////////////////////////////////////////////////////
function navigation() {
	global $page,$orderby;
	//read all trees from db
	$page->query("select id from site_content where depth=0 and id=treeid $orderby");
	$result = $page->db->getdata_array();
	
	$navigation = '';

	if (is_array($result) && !empty($result)) {
	$navigation = "\t<div id='menutree'>\n";
		//print each tree in an own table
		foreach ($result as $row) {
			$navigation .= print_tree($row["id"]);
		}
	$navigation .= "\t</div>\n";
	}
	return $navigation;
}
//Switch the status of a menu//////////////////////////////////////////////////////////////////////
function switch_status_content($status,$id) {
	global $l_cont,$page;
	$msg=$error=false;

	if (!$page->query("start transaction")) { $error=true; }
	//get all items
	$sql="select distinct if(c2.id,1,0) as haschildren,c1.* from site_content as c1 ".
	"left join site_content c2 on (c2.parentid=c1.id or c2.treeid=c1.id) and c2.order=1";
	if (!$page->query($sql)) { $error=true; }
	$items = $page->db->getdata_array();
	
	//it the item itself the startpage?
	foreach($items as $i) {
		if ($i["id"]==$id) {
			$siblingdepth = $i['depth'];
			if ($i["startpage"]==1) {
				return array($l_cont["msg_inactsp_err"],"bad");
			}
		}
	}
	get_siblings_r($id,$items,$siblings,intval($siblingdepth));
	//do what?
	if ($status=="active") {
		$active=1;
		$msg="msg_act_";
	//you cannot inactivate certain items
	} elseif ($status=="inactive") {
		if (!empty($siblings)) {
			foreach ($siblings as $sid=>$sibling) {
				if ($sibling->startpage==1) {
					return array($l_cont["msg_inactsp_err"],"bad");
				}
			}
		}
		$active=0;
		$msg="msg_inact_";
	}
	//build query
	$sql="update site_content set active=$active where id=$id or parentid=$id or treeid=$id or id=";
	if (!empty($siblings)) {
		foreach ($siblings as $sid=>$sibling) {
			$sql.="$sid or id=";
		}
	}
	$sql=substr($sql,0,-7);
	if (!$page->query($sql)) { $error=true; }
	if (!$error) {
		$msg = array($l_cont[$msg."ok"],"good");
		$sql="commit";
	} else {
		$msg = array($l_cont[$msg."err"], "bad");
		$sql="rollback";
	}
	while(1) {
		if ($page->query($sql)) { break; }
	}
	return $msg;
}
//Delete content///////////////////////////////////////////////////////////////////////////////////
function delete_content($id) {
	global $page,$l_cont;
	$error=false;

	//get data of item we want to delete
	$sql="select `order`,parentid from site_content where id=$id limit 1";
	if (!$page->query($sql)) { $error=true; }
	$result=$page->db->getdata();
	//look at all siblings
	$sql="select distinct if(c2.id,1,0) as haschildren,c1.* from site_content as c1 ".
	"left join site_content c2 on (c2.parentid=c1.id or c2.treeid=c1.id) and c2.order=1";
	if (!$page->query($sql)) { $error=true; }
	$items=$page->db->getdata_array();
	$siblings=array();
	if (!isset($siblingdepth)) { $siblingdepth = 0; }
	get_siblings_r($id,$items,$siblings,intval($siblingdepth));
	//is one of them the startpage?
	$sql="select id from site_content where (id=$id or parentid=$id or treeid=$id or id=";
	foreach ($siblings as $sid=>$sibling) {
		$sql.="$sid or id=";
	}
	$sql=substr($sql,0,-7).") and startpage=1";
	if (!$page->query($sql)) { $error=true; }
	$startpages=$page->db->getdata_array();
	if (is_array($startpages) && !empty($startpages)) { return array($l_cont["msg_delsp_err"],"bad"); }
	
	if (!$page->query("set autocommit=0")) { $error=true; }
	if (!$page->query("start transaction")) { $error=true; }

	//update order of following elements
	if ($result["order"]>0) {
		$sql="update site_content set `order`=`order`-1 where `order`>$result[order] and parentid='$result[parentid]'";
		if (!$page->query($sql)) { $error=true; }
	}
	//delete item and children if any
	$sql="delete from site_content where id=$id or parentid=$id or treeid=$id or id=";
	foreach ($siblings as $sid=>$sibling) {
		$sql.="$sid or id=";
	}
	$sql=substr($sql,0,-7);
	if (!$page->query($sql)) { $error=true; }
	if (!$error) {
		$msg = array($l_cont["msg_del_ok"],"good");
		$sql="commit";
	} else {
		$msg = array($l_cont["msg_del_err"],"bad");
		$sql="rollback";
	}
	while(1) {
		if ($page->query($sql)) { break; }
	}
	//if it was a menu delete the matching module(s) as well:
	$page->query("select id,settings from site_modules where modid=2");
	$menumods = $page->db->getdata_array();
	if (!empty($menumods)) {	
		$modstodelete=array();
		//see if they are modules for the menu that is to delete
		foreach ($menumods as $mm) {
			$mmsettings=explode(",",$mm["settings"]);
			//if yes, delete them as well
			if ($mmsettings[0]==$id) { delete_activemodule($mm["id"]); }
		}
	}
	return $msg;
}
//Switch Standard Access///////////////////////////////////////////////////////////////////////////
function switch_access($id,$access) {
	global $l_cont,$page;
	$error=false;
	if (!$page->query("start transaction")) { $error=true; }
	
	$sql="select `startpage`,`depth` from site_content where `id`=$id";
	if (!$page->query($sql)) { $error=true; }
	$thisitem = $page->db->getdata();
	
	//$thisitem["depth"] = $siblingdepth; TODO ????
	
	if ($thisitem["startpage"]=="1") { return array($l_cont["msg_spinact_err"],"bad"); }
	if ($access<2) { $access+=1; } else { $access=0; }
	//get all items
	$sql="select distinct if(c2.id,1,0) as haschildren,c1.* from site_content as c1 ".
	"left join site_content c2 on (c2.parentid=c1.id or c2.treeid=c1.id) and c2.order=1";
	if (!$page->query($sql)) { $error=true; }
	$items=$page->db->getdata_array();
	$siblings=array();
	get_siblings_r($id,$items,$siblings,intval($thisitem["depth"]));
	$sql="update site_content set `access`=$access where (`id`=$id or `parentid`=$id or `treeid`=$id or `id`=";
	foreach ($siblings as $sid=>$sibling) {
		$sql.="$sid or `id`=";
	}
	$sql=substr($sql,0,-9).")";
	if (!$page->query($sql)) { $error=true; }
	if (!$error) {
		$msg = array($l_cont["msg_access_ok"],"good");
		$sql="commit";
	} else {
		$msg = array($l_cont["msg_access_err"],"bad");
		$sql="rollback";
	}
	while(1) {
		if ($page->query($sql)) { break; }	
	}
	return $msg;
}
//Create a new menu////////////////////////////////////////////////////////////////////////////////
function create_menu($name) {
	global $l_cont,$page;
	if ($name=="") { $name="NewMenu"; }
	$error=false;
	if (!$page->query("start transaction")) { $error=true; }

	//get next id
	$sql="show table status like 'site_content'";
	if (!$page->query($sql)) { $error=true; }
	$nextid = $page->db->getdata();
	$nextid = $nextid["Auto_increment"];
	//read uid from session
	$user = $_SESSION["user"];
	$uid = $user->uid;
	//insert new menu
	$sql="insert into site_content (id,name,treeid,depth,parentid,`order`,active,startpage,modid,uid,date_new,date_edit) ".
	"values ($nextid,'$name',$nextid,0,0,0,1,0,1,$uid,now(),now())";
	if (!$page->query($sql)) { $error=true; }

	//insert matching menu module
	$sql="insert into site_modules (name,modid,position,`order`,active,settings) values ".
	"('$name',2,'inactive',0,0,'$nextid,1,1,0')";
	if (!$page->query($sql)) { $error=true; }

	if(!$error) {
		$sql="commit";
		$msg = array("$l_cont[msg_newmenu_ok] \"$name\"","good");
	} else {
		$sql="rollback";
		$msg = array("$l_cont[msg_newmenu_err] \"$name\"","bad");
	}
	while(1) {
		if ($page->query($sql)) { break; }
	}
	return $msg;
}
//Change the startpage/////////////////////////////////////////////////////////////////////////////
function change_startpage($id) {
	global $mysession,$l_cont,$page;
	if (!in_array(1,$mysession->user->gids)) { return array($l_cont["msg_spnoright_err"],"bad"); }
	$error = false;
	$sql="select active,access from site_content where id=$id limit 1";
	if (!$page->query($sql)) { $error=true; }
	$result=$page->db->getdata();
	if ($result["active"]==0 or $result["access"]>0) {
		return array($l_cont["msg_spinact_err"],"bad");
	}
	if (!$page->query("start transaction")) { $error=true; }
	//unset old startpage
	$sql="update site_content set startpage=0 where startpage=1";
	if (!$page->query($sql)) { $error=true; }
	//set new startpage
	$sql="update site_content set startpage=1 where id=$id";
	if (!$page->query($sql)) { $error=true; }
	if (!$error) {
		$sql="commit";
		$msg = array($l_cont["msg_chspage_ok"],"good");
	} else {
		$sql="rollback";
		$msg = array($l_cont["msg_chspage_err"],"bad");
	}
	while(1) {
		if ($page->query($sql)) {  break; }
	}
	return $msg;
}
?>
Return current item: chillyCMS