Location: PHPKode > projects > MembersGear > membersgear/admin/admin_pages_m.php
<?php
 require_once "../config/config.php"; 
 require_once INCLUDE_DIR."/pages_class.php";
 $objpage=new pages_class();
 //$smarty->assign(weburllen,strlen(WEB_URL));
 //define('WEB_URL_LENGTH',strlen(WEB_URL));
 $smarty->assign('WEB_URL_LENGTH', strlen(WEB_URL)); 
 switch($_action)
{
    case 'insert': 
                    $lsValues=array(); 
                    $lsValues[]=WEB_URL."/".$_POST['pgurl2']; 
                    $query="select url from ".TABLE_PREFIX."pages where url=?";
                    $lsurlavailable=$objpage->view($query,$lsValues,null);
                    if(is_array($lsurlavailable) && sizeof($lsurlavailable))
                    {
                        $iaPostdata = array();
                        $i=0;           
                        foreach($_POST as $key=>$value)
                        {   
                                $iaPostdata[$key]=$value;
                                $i++;
                        }
                           
                        $smarty->assign('post',$iaPostdata);
                        $smarty->assign('msg','Page Url is Already exist ');              
                        $smarty->display('admin_pages_m.tpl'); 
                        break;
                        
                    }  
                    $lsValues=array();   
                    $lsValues[]=$_POST['pgname'];
                    $lsValues[]=$_POST['pgurl2'];
                    $lsValues[]=$_POST['pgtitle'];
                    $lsValues[]=$_POST['pgmetakeyword'];
                    $lsValues[]=$_POST['pgmetadesc'];
                    $lsValues[]=' ';
                    $lsValues[]=$_SESSION[SESSION_PREFIX.'Admin_UserID']; 
                    $lsValues[]=mktime();
                    $lsValues[]=$_SERVER['REMOTE_ADDR'];
                    $query="insert into ".TABLE_PREFIX."pages (name, url, title, metakeywords, metadescription, content, createdby, createdon, createdipaddress)
                                                 values (?,?,?,?,?,?,?,?,?)";
                                                 
                   $liinsetcnt=$objpage->Insert($query,$lsValues,null);
                   if($liinsetcnt>0)
                   {
                           $message->SetMessage('Page is Successfully Inserted');        
                            Redirect('./admin_pages_v.php',true);   
                       
                   }    
    
                    break;
    case 'update':
                    $lsValues=array(); 
                    $lsValues[]=WEB_URL."/".$_POST['pgurl2']; 
                    $lsValues[]=$_POST['pgid'];
                    $query="select url from ".TABLE_PREFIX."pages where url=? and id!=?";
                    $lsurlavailable=$objpage->view($query,$lsValues,null);
                    if(is_array($lsurlavailable) && sizeof($lsurlavailable))
                    {
                        $iaPostdata = array();
                        $i=0;           
                        foreach($_POST as $key=>$value)
                        {   
                                $iaPostdata[$key]=$value;
                                $i++;
                        }
                           
                        $smarty->assign('post',$iaPostdata);
                        $smarty->assign('msg','Page Url is Already exist ');              
                        $smarty->display('admin_pages_m.tpl'); 
                        break;
                        
                    }    
                   $lsValues=array();
                   $lsValues[]=$_POST['pgname'];
                   $lsValues[]=$_POST['pgurl2'];
                   $lsValues[]=$_POST['pgtitle'];
                   $lsValues[]=$_POST['pgmetakeyword'];
                   $lsValues[]=$_POST['pgmetadesc'];
                   $lsValues[]=' ';
                   $lsValues[]=$_SESSION[SESSION_PREFIX.'Admin_UserID']; 
                   $lsValues[]=mktime();
                   $lsValues[]=$_SERVER['REMOTE_ADDR'];;
                   $lsValues[]=$_POST['pgid'];
                   $query="update ".TABLE_PREFIX."pages set  name=?, url=?, title=?, metakeywords=?, metadescription=?, content=?,modifiedby=?, modifiedon=?, modifiedipaddress=? where id=?";
                   $lsUpdatedrows=$objpage->View($query,$lsValues,null);
                   $message->SetMessage('Page is Successfully Updated');
                   Redirect('./admin_pages_v.php'); 
                    break;
    case 'delete':
               $lspageid=$_GET['id'];
                 $lsValues=array();
                 $lsValues[]=$lspageid;
                 $query="delete from ".TABLE_PREFIX."pages where id=?";
                 $result=$objpage->Delete($query,$lsValues,null);
                 $message->SetMessage('Page is Successfully Deleted');
                 Redirect('./admin_pages_v.php');    
                   break;
                   
    case  'edit': 
                 $lspageid=$_GET['id'];
                 $lsValues=array();
                 $lsValues[]=$lspageid;
                 $query="select * from ".TABLE_PREFIX."pages where id=?";
                 $result=$objpage->View($query,$lsValues,null);
                 $lapageinfo=array();
                 if(is_array($result) && sizeof($result))
                 {
                     $lapageinfo=$result;
                     $lapageinfo[0]['pageurl2']=str_replace(WEB_URL."/",'',$result[0]['url']);
                 }
                
                 $smarty->assign('pageinfo',$lapageinfo);
                 $smarty->assign('IsEdit','yes');  
                                                            
    default:
           $smarty->display('admin_pages_m.tpl');    
} 
      
?>
Return current item: MembersGear