<?php  include("includes/connection.php");
 	  include("includes/function.php"); 	
	
	$file_path = 'http://'.$_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']).'/';
	
 	 
	if(isset($_GET['cat_list'])){
 		$jsonObj= array();
		
		$query="SELECT cid,category_name,category_image FROM tbl_category ORDER BY tbl_category.cid DESC";
		$sql = mysqli_query($mysqli,$query)or die(mysql_error());

		while($data = mysqli_fetch_assoc($sql))
		{
			$row['cid'] = $data['cid'];
			$row['category_name'] = $data['category_name'];
			$row['category_image'] = $file_path.'images/'.$data['category_image'];
			$row['category_image_thumb'] = $file_path.'images/thumbs/'.$data['category_image'];
 
			array_push($jsonObj,$row);
		
		}

		$set['banostudio'] = $jsonObj;
		
		header( 'Content-Type: application/json; charset=utf-8' );
	    echo $val= str_replace('\\/', '/', json_encode($set,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
		die();


 	}
	else if(isset($_GET['ringtone_upload'])){
	    
	    if($_FILES['ringtone']['name'] != ''  and $_POST['rname'] !='' and $_POST['user_id']!='' )
		    {
                 $cat_id =$_POST['cat_id'];
    		     $rname =$_POST['rname'];
    		     
    		     $user =$_POST['user_id'];
    		    
    		     
		         $file_path = 'http://'.$_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']).'/uploads/';

                $video_url1=rand(0,99999)."_".$_FILES['ringtone']['name'];
        
        	    $ringtone=$file_path.$video_url1;
                  
        		
        		$temp=$_FILES['ringtone']['tmp_name'];
        		
        		$path="uploads/".$video_url1;
        	
        	    $pic1=move_uploaded_file($temp,$path);
     
                
                $qry1="INSERT INTO tbl_ringtone (`cat_id`,title,url,mp3_type,status,user_id) VALUES ('".$cat_id."','".$rname."','".$ringtone."','local',0,'".$user."')"; 
    						
    	        $result1=mysqli_query($mysqli,$qry1);  		
    	        
    			$set['banostudio'][]=array('msg' => "ringtone uploaded successfully...",'success'=>'1');
		    }else
		    {
		        $set['banostudio'][]=array('msg' => "something went wrong...",'success'=>'0');

		    }
	 	   
	 	    
	 	    header( 'Content-Type: application/json; charset=utf-8' );
    	    echo $val= str_replace('\\/', '/', json_encode($set,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
    		die();
	}

?>