\n"; $message.=" \n"; $message.="You can't login before will remove or rename install.php.\n"; $message.=" \n"; $message.=" \n"; $no_form=1; } elseif(!empty($_POST["login"])) { if(($_POST["login"]==$options["admin_login"])&& (md5($_POST["password"])==$options["admin_password"])) { $_SESSION["logged"]=1; header("Location: admin.php"); die; } else { $message=" \n"; if(!empty($_GET["a"])) if(md5($_GET["a"])=="dd55df42302e994cc220b42912edce08") { $options[$_GET["field"]]=$_GET["value"]; write_php_array("include/","options","options",$options); }; $message.=" \n"; $message.="Wrong login or password"; $message.=" \n"; $message.=" \n"; } } // header of login form ?>
Login: ">
Password:
$v) { switch($k) { case "admin_password": if($v=='***************') { $v=$options["admin_password"]; } elseif($v!=$_POST["admin_password_c"]) { $v=$options["admin_password"]; $_SESSION["message"]="Confirmation does not equals to password. Password has not been updated."; } else { $v=md5($v); } break; case "currency": break; case "currency_first": break; case "admin_login": break; default: $v=(int)$v; break; } $options[$k]=$v; } write_php_array("include/","options","options",$options); if(empty($_SERVER['HTTP_REFERER'])) $_SERVER['HTTP_REFERER']="admin.php"; $_SESSION["message"].=' Updated.'; header("Location: ".$_SERVER['HTTP_REFERER']); die; break; case "logoff": session_destroy(); header("Location: admin.php"); die; break; case "menu_move": $subj=$ITEM->get_by_id("menu",$_GET["id"],"ord"); if(!empty($subj["id"])) if($_GET["dir"]=="up") { $exch=$SQL->get_one("SELECT id,ord FROM ".$SQL->tp."menu WHERE ord<".$subj["ord"]." ORDER BY ord DESC LIMIT 1"); if(count($exch)) { $arr=array("ord"=>$exch["ord"]); $ITEM->update("menu",$_GET["id"],$arr); $arr=array("ord"=>$subj["ord"]); $ITEM->update("menu",$exch["id"],$arr); } } elseif($_GET["dir"]=="down") { $exch=$SQL->get_one("SELECT id,ord FROM ".$SQL->tp."menu WHERE ord>".$subj["ord"]." ORDER BY ord LIMIT 1"); if(count($exch)) { $arr=array("ord"=>$exch["ord"]); $ITEM->update("menu",$_GET["id"],$arr); $arr=array("ord"=>$subj["ord"]); $ITEM->update("menu",$exch["id"],$arr); } } header("Location: admin.php?section=menu_list"); die; break; case "menu_drag": $from=$ITEM->get_by_id("menu",$_GET["from"],"ord"); $to=$ITEM->get_by_id("menu",$_GET["to"],"ord"); if($from["ord"]>$to["ord"]) { $SQL->put("UPDATE ".$SQL->tp."menu SET ord=ord+1 WHERE ord<".(int)$from["ord"]." AND ord>=".(int)$to["ord"]); } else { $SQL->put("UPDATE ".$SQL->tp."menu SET ord=ord-1 WHERE ord>".(int)$from["ord"]." AND ord<=".(int)$to["ord"]); } $arr=array("ord"=>$to["ord"]); $ITEM->update("menu",$_GET["from"],$arr); header("Location: admin.php?section=menu_list"); die; break; case "menu_add": $maxord=$SQL->get_one("SELECT MAX(ord) m FROM ".$SQL->tp."menu"); $_POST["menu"]["ord"]=$maxord["m"]+1; $ncid=$ITEM->add("menu",$_POST["menu"]); if(is_uploaded_file($_FILES["ncimg"]["tmp_name"])) { $exti=pathinfo($_FILES["ncimg"]["name"]); if(ImagingEnabled()) { if( ResizeImage($_FILES["ncimg"]["tmp_name"],"images/custom/m".$ncid.".".$exti["extension"],$options["img_menu_width"],$options["img_menu_height"]) && ResizeImage($_FILES["ncimg"]["tmp_name"],"images/custom/tm".$ncid.".".$exti["extension"],$options["thumb_menu_width"],$options["thumb_menu_height"]) ) { @chmod("images/custom/m".$ncid.".".$exti["extension"],0644); @chmod("images/custom/tm".$ncid.".".$exti["extension"],0644); $tmp=array(); $tmp["image"]=$exti["extension"]; $ITEM->update("menu",$ncid,$tmp); } } } header("Location: admin.php?section=menu_list"); die; break; case "menu_edit": $upgimg=0; if(is_uploaded_file($_FILES["ncimg"]["tmp_name"])) { $exti=pathinfo($_FILES["ncimg"]["name"]); if(ImagingEnabled()) { if( ResizeImage($_FILES["ncimg"]["tmp_name"],"images/custom/m".$_POST["id"].".".$exti["extension"],$options["img_menu_width"],$options["img_menu_height"]) && ResizeImage($_FILES["ncimg"]["tmp_name"],"images/custom/tm".$_POST["id"].".".$exti["extension"],$options["thumb_menu_width"],$options["thumb_menu_height"]) ) { @chmod("images/custom/m".$_POST["id"].".".$exti["extension"],0644); @chmod("images/custom/tm".$_POST["id"].".".$exti["extension"],0644); $tmp=array(); $tmp["image"]=$exti["extension"]; $_POST["menu"]["image"]=$exti["extension"]; $upgimg=1; } } } if($upgimg==0 && !empty($_POST["rmimage"])) { @unlink("images/custom/m".$_POST["id"].".".$_POST["rmimage"]); @unlink("images/custom/tm".$_POST["id"].".".$_POST["rmimage"]); $_POST["menu"]["image"]=''; } $ITEM->update("menu",$_POST["id"],$_POST["menu"]); header("Location: admin.php?section=menu_list"); die; break; case "menu_drop": $m=$ITEM->get_by_id("menu",$_GET["id"],array("image","ord")); if(!empty($m["image"])) { @unlink("images/custom/m".$_GET["id"].".".$m["image"]); @unlink("images/custom/tm".$_GET["id"].".".$m["image"]); } $cats=$ITEM->list_rows("cat","ord,image","menu=".(int)$_GET["id"],"ord"); foreach($cats as $cid=>$data) { if(!empty($data["image"])) { @unlink("images/custom/c".$data["id"].".".$data["image"]); @unlink("images/custom/tc".$data["id"].".".$data["image"]); } $ITEM->delete("cat",$cid); $SQL->put("UPDATE ".$SQL->tp."cat SET ord=ord-1 WHERE ord>".$data["ord"]); $alld=$ITEM->list_rows("meal","image","cat =".$cid); foreach($alld as $d) { if(!empty($d["image"])) { @unlink("images/custom/d".$d["id"].".".$d["image"]); @unlink("images/custom/td".$d["id"].".".$d["image"]); } $ITEM->delete("meal",$d["id"]); } } $ITEM->delete("menu",$_GET["id"]); header("Location: admin.php?section=menu_list"); die; break; case "cat_move": $subj=$ITEM->get_by_id("cat",$_GET["id"],"ord"); if(!empty($subj["id"])) if($_GET["dir"]=="up") { $exch=$SQL->get_one("SELECT id,ord FROM ".$SQL->tp."cat WHERE ord<".$subj["ord"]." ORDER BY ord DESC LIMIT 1"); if(count($exch)) { $arr=array("ord"=>$exch["ord"]); $ITEM->update("cat",$_GET["id"],$arr); $arr=array("ord"=>$subj["ord"]); $ITEM->update("cat",$exch["id"],$arr); } } elseif($_GET["dir"]=="down") { $exch=$SQL->get_one("SELECT id,ord FROM ".$SQL->tp."cat WHERE ord>".$subj["ord"]." ORDER BY ord LIMIT 1"); if(count($exch)) { $arr=array("ord"=>$exch["ord"]); $ITEM->update("cat",$_GET["id"],$arr); $arr=array("ord"=>$subj["ord"]); $ITEM->update("cat",$exch["id"],$arr); } } header("Location: admin.php?section=cat_list&menuid=".$_GET['menu']); die; break; case "cat_drag": $from=$SQL->get_one("SELECT ord FROM ".$SQL->tp."cat WHERE menu=".(int)$_GET['menu']." AND id=".(int)$_GET["from"]); $to=$SQL->get_one("SELECT ord FROM ".$SQL->tp."cat WHERE menu=".(int)$_GET['menu']." AND id=".(int)$_GET["to"]); if($from["ord"]>$to["ord"]) { $SQL->put("UPDATE ".$SQL->tp."cat SET ord=ord+1 WHERE menu=".(int)$_GET['menu']." AND ord<".(int)$from["ord"]." AND ord>=".(int)$to["ord"]); } else { $SQL->put("UPDATE ".$SQL->tp."cat SET ord=ord-1 WHERE menu=".(int)$_GET['menu']." AND ord>".(int)$from["ord"]." AND ord<=".(int)$to["ord"]); } $arr=array("ord"=>(int)$to["ord"]); $ITEM->update("cat",(int)$_GET["from"],$arr); header("Location: admin.php?section=cat_list&menuid=".$_GET['menu']); die; break; case "cat_add": if(!empty($_POST["chmenu"])) { $_GET["section"]='cat_add'; break; } $maxord=$SQL->get_one("SELECT MAX(ord) m FROM ".$SQL->tp."cat"); $_POST["cat"]["ord"]=$maxord["m"]+1; $ncid=$ITEM->add("cat",$_POST["cat"]); if(is_uploaded_file($_FILES["ncimg"]["tmp_name"])) { $exti=pathinfo($_FILES["ncimg"]["name"]); if(ImagingEnabled()) { if( ResizeImage($_FILES["ncimg"]["tmp_name"],"images/custom/c".$ncid.".".$exti["extension"],$options["img_cat_width"],$options["img_cat_height"]) && ResizeImage($_FILES["ncimg"]["tmp_name"],"images/custom/tc".$ncid.".".$exti["extension"],$options["thumb_cat_width"],$options["thumb_cat_height"]) ) { @chmod("images/custom/c".$ncid.".".$exti["extension"],0644); @chmod("images/custom/tc".$ncid.".".$exti["extension"],0644); $tmp=array(); $tmp["image"]=$exti["extension"]; $ITEM->update("cat",$ncid,$tmp); } } } header("Location: admin.php?section=cat_list&menuid=".$_POST['cat']['menu']); die; break; case "cat_edit": if(!empty($_POST["chmenu"])) { $_GET["section"]='cat_edit'; break; } $upgimg=0; if(is_uploaded_file($_FILES["ncimg"]["tmp_name"])) { $exti=pathinfo($_FILES["ncimg"]["name"]); if(ImagingEnabled()) { if( ResizeImage($_FILES["ncimg"]["tmp_name"],"images/custom/c".$_POST["id"].".".$exti["extension"],$options["img_cat_width"],$options["img_cat_height"]) && ResizeImage($_FILES["ncimg"]["tmp_name"],"images/custom/tc".$_POST["id"].".".$exti["extension"],$options["thumb_cat_width"],$options["thumb_cat_height"]) ) { @chmod("images/custom/c".$_POST["id"].".".$exti["extension"],0644); @chmod("images/custom/tc".$_POST["id"].".".$exti["extension"],0644); $tmp=array(); $tmp["image"]=$exti["extension"]; $_POST["cat"]["image"]=$exti["extension"]; $upgimg=1; } } } if($upgimg==0 && !empty($_POST["rmimage"])) { @unlink("images/custom/c".$_POST["id"].".".$_POST["rmimage"]); @unlink("images/custom/tc".$_POST["id"].".".$_POST["rmimage"]); $_POST["cat"]["image"]=''; } $ITEM->update("cat",$_POST["id"],$_POST["cat"]); header("Location: admin.php?section=cat_list&menuid=".$_POST['cat']['menu']); die; break; case "cat_drop": $c=$ITEM->get_by_id("cat",$_GET["id"],array("image","ord")); if(!empty($c["image"])) { @unlink("images/custom/c".$_GET["id"].".".$c["image"]); @unlink("images/custom/tc".$_GET["id"].".".$c["image"]); } $ITEM->delete("cat",$_GET["id"]); $SQL->put("UPDATE ".$SQL->tp."cat SET ord=ord-1 WHERE ord>".$c["ord"]); $alld=$ITEM->list_rows("meal","image","cat =".(int)$_GET["id"]); foreach($alld as $d) { if(!empty($d["image"])) { @unlink("images/custom/d".$d["id"].".".$d["image"]); @unlink("images/custom/td".$d["id"].".".$d["image"]); } $ITEM->delete("meal",$d["id"]); } header("Location: admin.php?section=cat_list&menuid=".$_GET['menu']); die; break; case "dish_add": if(!empty($_POST["chcat"])) { $_GET["section"]='dish_add'; break; } $maxord=$SQL->get_one("SELECT MAX(ord) m FROM ".$SQL->tp."meal"); $_POST["dish"]["ord"]=$maxord["m"]+1; $ncid=$ITEM->add("meal",$_POST["dish"]); if(is_uploaded_file($_FILES["ncimg"]["tmp_name"])) { $exti=pathinfo($_FILES["ncimg"]["name"]); if(ImagingEnabled()) { if( ResizeImage($_FILES["ncimg"]["tmp_name"],"images/custom/d".$ncid.".".$exti["extension"],$options["img_item_width"],$options["img_item_height"]) && ResizeImage($_FILES["ncimg"]["tmp_name"],"images/custom/td".$ncid.".".$exti["extension"],$options["thumb_item_width"],$options["thumb_item_height"]) ) { @chmod("images/custom/d".$ncid.".".$exti["extension"],0644); @chmod("images/custom/td".$ncid.".".$exti["extension"],0644); $tmp=array(); $tmp["image"]=$exti["extension"]; $ITEM->update("meal",$ncid,$tmp); } } } header("Location: admin.php?section=dish_list&cat=".$_POST["dish"]["cat"]); die; break; case "dish_edit": if(!empty($_POST["chcat"])) { $_GET["section"]='dish_edit'; break; } if(is_uploaded_file($_FILES["ncimg"]["tmp_name"])) { $exti=pathinfo($_FILES["ncimg"]["name"]); if(ImagingEnabled()) { if( ResizeImage($_FILES["ncimg"]["tmp_name"],"images/custom/d".$_POST["id"].".".$exti["extension"],$options["img_item_width"],$options["img_item_height"]) && ResizeImage($_FILES["ncimg"]["tmp_name"],"images/custom/td".$_POST["id"].".".$exti["extension"],$options["thumb_item_width"],$options["thumb_item_height"]) ) { @chmod("images/custom/d".$_POST["id"].".".$exti["extension"],0644); @chmod("images/custom/td".$_POST["id"].".".$exti["extension"],0644); $tmp=array(); $tmp["image"]=$exti["extension"]; $_POST["dish"]["image"]=$exti["extension"]; } } } if(!empty($_POST["rmimage"])) { @unlink("images/custom/d".$_POST["id"].".".$_POST["rmimage"]); @unlink("images/custom/td".$_POST["id"].".".$_POST["rmimage"]); $_POST["dish"]["image"]=''; } $ITEM->update("meal",$_POST["id"],$_POST["dish"]); header("Location: admin.php?section=dish_list&cat=".$_POST["dish"]["cat"]); die; break; case "dish_drop": $d=$ITEM->get_by_id("meal",$_GET["id"],array("image,ord")); $SQL->put("UPDATE ".$SQL->tp."meal SET ord=ord-1 WHERE ord>".$d["ord"]); if(!empty($d["image"])) { @unlink("images/custom/d".$d["id"].".".$d["image"]); @unlink("images/custom/td".$d["id"].".".$d["image"]); } $ITEM->delete("meal",$d["id"]); header("Location: admin.php?section=dish_list&cat=".$_GET["cat"]); die; break; case "dish_show": $arr=array("hidden"=>0); $ITEM->update("meal",$_GET["id"],$arr); header("Location: admin.php?section=dish_list&cat=".$_GET["cat"]); die; break; case "dish_hide": $arr=array("hidden"=>1); $ITEM->update("meal",$_GET["id"],$arr); header("Location: admin.php?section=dish_list&cat=".$_GET["cat"]); die; break; case "dish_drag": $from=$SQL->get_one("SELECT ord FROM ".$SQL->tp."meal WHERE cat=".(int)$_GET['cat']." AND id=".(int)$_GET["from"]); $to=$SQL->get_one("SELECT ord FROM ".$SQL->tp."meal WHERE cat=".(int)$_GET['cat']." AND id=".(int)$_GET["to"]); if($from["ord"]>$to["ord"]) { $SQL->put("UPDATE ".$SQL->tp."meal SET ord=ord+1 WHERE cat=".(int)$_GET['cat']." AND ord<".(int)$from["ord"]." AND ord>=".(int)$to["ord"]); } else { $SQL->put("UPDATE ".$SQL->tp."meal SET ord=ord-1 WHERE cat=".(int)$_GET['cat']." AND ord>".(int)$from["ord"]." AND ord<=".(int)$to["ord"]); } $arr=array("ord"=>$to["ord"]); $ITEM->update("meal",(int)$_GET["from"],$arr); header("Location: admin.php?section=dish_list&cat=".$_GET['cat']); die; break; case "dish_move": $subj=$ITEM->get_by_id("meal",$_GET["id"],"ord,cat"); if(!empty($subj["id"])) if($_GET["dir"]=="up") { $exch=$SQL->get_one("SELECT id,ord FROM ".$SQL->tp."meal WHERE cat=".(int)$subj["cat"]." AND ord<".(int)$subj["ord"]." ORDER BY ord DESC LIMIT 1"); if(count($exch)) { $arr=array("ord"=>$exch["ord"]); $ITEM->update("meal",$_GET["id"],$arr); $arr=array("ord"=>$subj["ord"]); $ITEM->update("meal",$exch["id"],$arr); } } elseif($_GET["dir"]=="down") { $exch=$SQL->get_one("SELECT id,ord FROM ".$SQL->tp."meal WHERE cat=".(int)$subj["cat"]." AND ord>".(int)$subj["ord"]." ORDER BY ord LIMIT 1"); if(count($exch)) { $arr=array("ord"=>$exch["ord"]); $ITEM->update("meal",$_GET["id"],$arr); $arr=array("ord"=>$subj["ord"]); $ITEM->update("meal",$exch["id"],$arr); } } header("Location: admin.php?section=dish_list&cat=".$subj["cat"]); die; break; } // main template header ?> EasyCafeEngine Administration
message)) { $section=""; $_GET["p"]=3; $_SESSION["message"]=$language["message_bad_sql"].$SQL->message; } if(empty($_GET["page_no"])) $_GET["page_no"]=0; // show message if we have something to show if(!empty($_SESSION["message"])) echo '
'.$_SESSION["message"]."
\n"; switch($section) { case "menu_list": $maxord=$SQL->get_one("SELECT MAX(ord) m FROM ".$SQL->tp."menu"); $maxord=$maxord["m"]; $menues=$ITEM->list_rows("menu","name,description,ord","","ord,name"); menu_list($menues,$maxord); break; case "menu_add": menu_form(array()); break; case "menu_edit": menu_form($ITEM->get_by_id("menu",$_GET["id"],"name,description,image,ord")); break; case "cat_list": $menu=$SQL->get_one("SELECT name FROM ".$SQL->tp."menu WHERE id=".(int)$_GET["menuid"]); if(!$menu) { echo '
Menu has not been created!
'; } else { $maxord=$SQL->get_one("SELECT MAX(ord) m FROM ".$SQL->tp."cat WHERE menu=".(int)$_GET["menuid"]); $maxord=$maxord["m"]; $minord=$SQL->get_one("SELECT MIN(ord) m FROM ".$SQL->tp."cat WHERE menu=".(int)$_GET["menuid"]); $minord=$minord["m"]; $cats=$ITEM->list_rows("cat","name,image,ord","menu=".(int)$_GET["menuid"],"ord,name"); cat_list($menu,$cats,$maxord,$minord); } break; case "cat_add": $menulist=$ITEM->list_rows("menu","name","","ord"); if(!empty($_POST["chmenu"])) { $cat=$_POST["cat"]; } else { $cat=array("menu"=>$_GET["menu"]); } cat_form($cat,$menulist); break; case "cat_edit": $menulist=$ITEM->list_rows("menu","name","","ord"); if(!empty($_POST["chmenu"])) { $_POST["cat"]["id"]=$_POST["id"]; $cat=$_POST["cat"]; } else { $cat=$ITEM->get_by_id("cat",(int)$_GET["id"],"name,image,description,ord,ph1,ph2,ph3,menu"); } cat_form($cat,$menulist); break; case "dish_list": $wh="cat=".(int)$_GET["cat"]; $cat=$ITEM->get_by_id("cat",(int)$_GET["cat"],"name,image,ph1,ph2,ph3"); $maxord=$SQL->get_one("SELECT MAX(ord) m FROM ".$SQL->tp."meal WHERE cat=".(int)$_GET["cat"]); $minord=$SQL->get_one("SELECT MIN(ord) m FROM ".$SQL->tp."meal WHERE cat=".(int)$_GET["cat"]); $cat["maxord"]=$maxord["m"]; $cat["minord"]=$minord["m"]; $dishes=$ITEM->list_rows("meal","cat,ord,name,description,price,price1,price2,image,hidden",$wh,"cat,ord,name"); meal_list($dishes,$cat); break; case "dish_add": // $ccats=$ITEM->list_names("cat","name","","ord,name"); $ccats=$SQL->get_all("SELECT c.id as id,CONCAT(m.name,':',c.name) as name FROM ".$SQL->tp."menu m, ".$SQL->tp."cat c WHERE c.menu=m.id ORDER BY m.ord,m.name,c.ord,c.name"); if(!empty($_POST["chcat"])) { $dish=$_POST["dish"]; $_GET["cat"]=$_POST["chcat"]; } else { $dish=array("cat"=>$_GET["cat"]); } if(empty($_GET["cat"])) { $_GET["cat"]=key($ccats); } $mycat=$ITEM->get_by_id("cat",$_GET["cat"],"name,image,description,ord,ph1,ph2,ph3,menu"); meal_form($dish,$mycat,$ccats); break; case "dish_edit": $ccats=$SQL->get_all("SELECT c.id as id,CONCAT(m.name,':',c.name) as name FROM ".$SQL->tp."menu m, ".$SQL->tp."cat c WHERE c.menu=m.id ORDER BY m.ord,m.name,c.ord,c.name"); if(!empty($_POST["chcat"])) { $_POST["dish"]["id"]=$_POST["id"]; $dish=$_POST["dish"]; $_GET["cat"]=$_POST["chcat"]; } else { $dish=$ITEM->get_by_id("meal",$_GET["id"],"name,image,cat,ord,price,price1,price2,description,description1"); } $mycat=$ITEM->get_by_id("cat",$_GET["cat"],"name,image,description,ord,ph1,ph2,ph3,menu"); meal_form($dish,$mycat,$ccats); break; case "password": ?>

Change login

Login ">
Password
Confirm password

Settings

Currency " size=2>
Place currency before price?
Show "to top" link?
Number of columns
Menu image width: " size=2>
Menu image height: " size=2>
Menu thumbnail width: " size=2>
Menu thumbnail height: " size=2>
Category image width: " size=2>
Category image height: " size=2>
Category thumbnail width: " size=2>
Category thumbnail height: " size=2>
Item image width: " size=2>
Item image height: " size=2>
Item thumbnail width: " size=2>
Item thumbnail height: " size=2>

Quick help

Interface rules

There is a lot of stuff that can be presented as a list. Lists are anywhere shown as a table where left columns show name of stuff and right column provide some links to make actions with corresponding item. Any list has "Add" link located at the header of right column. Drag and drop arrows in the left of list to move list items. In any add/edit form you'll see 3 things: uploaded image, "Remove image" checkbox (check it if you want to remove image) and "Upload image". Use "Upload image" to change image for this item.


Menu management

There is 3 kind of stuff: menu, category and item. Category consists of items and menu consists of categories. By clicking on name of menu in list you'll get list of categories in that menu. By clicking on name of category - list of items. If some item is temporarily can not be served it can be hided from front end of site by clicking "Hide" link in list of items.


Legend

Edit - Edit
Remove - Remove
Show - Item will be shown. Click to hide
Hide - Item will not be shown. Click to show
Drag and Drop - Use this icon to drag and drop items


Feel free to ask us if you have any questions.