<?php 
function post($con,$var){
	$var=mysqli_real_escape_string($con,$var);
	return $var;
	
	}
	
	 
function go($page)
{
 

?><META HTTP-EQUIV=Refresh CONTENT="0; URL=<?php echo($page); ?>">

<?php exit(); }  
	
	
	 
	
	 
	function landing($id,$con){
		 
		$sel=mysqli_query($con,"select * from landingpage where landingPage_id='".$id."'");
		$row=mysqli_fetch_array($sel);
		 return $row;
		 
		}
	
	
	
	
	
	
	
	
	
	
	
	
	function Select($id,$con,$title,$query,$match,$function=""){
		
		
		?><div id="<?php  echo($id); ?>Border" style="padding:1px; border:0px solid   #FFF"><select name="<?php  echo($id); ?>" id="<?php  echo($id); ?>" class="required form-control" data-rel="chosen"
         requirValue="" validateValue='0' 
        <?php  if($function!=''){ ?> onChange="<?php echo($function); ?>"
        <?php }  ?>
          >
<option value="0"><?php  echo($title); ?></option>
<?php $sel=mysqli_query($con,$query);


while($row=mysqli_fetch_array($sel)){
	?>
	<option value="<?php echo($row[0]); ?>" <?php if($match==$row[0]){?> selected<?php } ?>><?php echo($row[1]); ?></option>
	<?php
	
	}
 ?>
</select></div><?php 
		
		
		
		
		}
	
	
	
	
	
	 
function Selectmultiple($id,$con,$title,$query,$PID){
		
		
		?><div id="<?php  echo($id); ?>Border" style="padding:1px; border:0px solid   #FFF"><select name="<?php  echo($id); ?>[]" id="<?php  echo($id); ?>[]" class="form-control" data-rel="chosen"
       
       multiple
          >
<option value="0"><?php  echo($title); ?></option>
<?php $sel=mysqli_query($con,$query);


while($row=mysqli_fetch_array($sel)){
	
	$selTeeable=mysqli_query($con,"SELECT * FROM `project_Comunity` 
	 where `project_Comunity_comID`='".$row[0]."'	
	 and project_Comunity_projid='".$PID."'
	");
	
	?>
	<option value="<?php echo($row[0]); ?>" <?php if(mysqli_num_rows($selTeeable)!=0 ){?> selected<?php } ?>><?php echo($row[1]); ?></option>
	<?php
	
	
	
	
	}
 ?>
</select></div><?php 
		
		
		
		
		}


	 




function Get_Extension_From_File($file){
	$explode=explode(".",$file);
	return $explode[1];
	
	}
	



function upload($dirname,$ffname,$ff){



if(Get_Extension_From_File($ffname)=="jpg" || Get_Extension_From_File($ffname)=="gif" || Get_Extension_From_File($ffname)=="png" ||  Get_Extension_From_File($ffname)=="pdf" || Get_Extension_From_File($ffname)=="zip"   || Get_Extension_From_File($ffname)=="swf" ||  Get_Extension_From_File($ffname)=="rar" || Get_Extension_From_File($ffname)=="JPG" || Get_Extension_From_File($ffname)=="GIF" || Get_Extension_From_File($ffname)=="PNG" ||  Get_Extension_From_File($ffname)=="PDF" || Get_Extension_From_File($ffname)=="ZIP"   || Get_Extension_From_File($ffname)=="SWF" ||  Get_Extension_From_File($ffname)=="RAR" ||  Get_Extension_From_File($ffname)=="flv" ||  Get_Extension_From_File($ffname)=="flv" ||  Get_Extension_From_File($ffname)=="mp3" ||  Get_Extension_From_File($ffname)=="mp3"
|| 1==1
){

if(move_uploaded_file($ff, $dirname.$ffname)){
 
 //rename($dirname.$ffname, strtotime(date("y-m-d G:i:s").".".Get_Extension_From_File($ffname)));
 
chmod($dirname.$ffname,0644);





return 1;





}else{



return 0;



}



}else{

/* ?><script>alert('the extintion should be jpg , gif , png, pdf, zip , swf , rar ,flv , mp3');</script><?php */

}









}


 function priv($rolid,$fun,$section,$connection){
$sql="select u_p_".$fun." from users_priv 
	inner join priv_section on p_s_id=u_p_sectionid
	
	
	 where u_p_roleid=".$rolid."
	
	and p_s_name='".$section."'
	
	
	";
//echo($sql);

	$selectPriv=mysqli_query($connection,$sql)  ;
	
	 //exit(mysqli_num_rows($selectPriv));
	$row=mysqli_fetch_assoc($selectPriv);
	 
	return $row["u_p_".$fun];
	
	
	
	} 

function Role($uid,$con){
	
	
		$sel=mysqli_query($con,"select * from users
inner join roles on roles_id=Users_roleid where Users_id='".$uid."'");
		$row=mysqli_fetch_array($sel);
		
		 return $row['roles_id'];
	}


function Table($table,$tableIDFeilds,$id,$con){
	
	
		$sel=mysqli_query($con,"select * from ".$table."
  where ".$tableIDFeilds."='".$id."'");
  
		$row=mysqli_fetch_array($sel);
		
		 return $row;
	}


function youtubeId($url){
	
parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars );
return $my_array_of_vars['v'];    
  // Output: C4kxS1ksqtw
	
	}
	function getCompnay($con,$uid){
		$sel=mysqli_query($con,"select * from users
where  Users_id='".$uid."'");
		$row=mysqli_fetch_array($sel);
		
		 return $row['users_companyID'];
		
		}
	
	
 ?>