<?php
/****************************************** دوال متخصصة فى ازالة الحقن من النصوص والمتغيرات ***************************************/ 
function injection($value) {
$value=htmlspecialchars_decode($value);
$value = str_replace( '$', '', $value );	
$value = str_replace( '#', '', $value );	
$value = str_replace( '!', '', $value );	
$value = str_replace( '%', '', $value );	
$value = str_replace( '+', '', $value );	
$value = str_replace( '-', '', $value );
$value = str_replace( '*', '', $value );
$value = str_replace( '/', '', $value );
$value = str_replace( '<', '', $value );
$value = str_replace( '>', '', $value );
$value = str_replace( '"', '', $value );
$value = str_replace( "'", '', $value );
$value = str_replace( "=", '', $value );
$value = str_replace( "or", '', $value );
$value = str_replace( "and", '', $value );
$value = str_replace( "&", '', $value );
$value = str_replace( ";", '', $value );
$value = str_replace( ":", '', $value );
$value = str_replace( "|", '', $value );
$value = str_replace( "^", '', $value );
$value = str_replace( "select", '', $value );
$value = str_replace( "insert", '', $value );
$value = str_replace( "update", '', $value );
$value = str_replace( "delete", '', $value );
$value = str_replace( "<div>", '', $value );
$value = str_replace( "</div>", '', $value );
$value=htmlentities(($value),ENT_QUOTES);
//$value=mysqli_real_escape_string($conn,$value);
$value=htmlspecialchars($value);
$value=nl2br($value);
$value=trim($value);
$value=strip_tags($value);
return $value;
}



function is_num($value){
if (!is_numeric($value)) die("<div class='page_error' ><span class='error_img'></span><span>حدث خطأ</span></div>")	; 
return $value;		
}

function is_empty($value){
if ($value=='') die("<div class='page_error' ><span class='error_img'></span><span>حدث خطأ</span></div>")	; 
return $value;		
}


function from_time($time_diff) {
$secs = time() - strtotime($time_diff);			
		$second = 1;
		$minute = 60;
		$hour = 60*60;
		$day = 60*60*24;
		$week = 60*60*24*7;
		$month = 60*60*24*7*30;
		$year = 60*60*24*7*30*365;
 
		if ($secs <= 0) { $output = "Now";
		}elseif ($secs > $second && $secs < $minute) { $output = round($secs/$second)." Seconds ";
		}elseif ($secs >= $minute && $secs < $hour) { $output = round($secs/$minute)." muinits";
		}elseif ($secs >= $hour && $secs < $day) { $output = round($secs/$hour)." Hours";
		}elseif ($secs >= $day && $secs < $week) { $output = round($secs/$day)." Days";
		}elseif ($secs >= $week && $secs < $month) { $output = round($secs/$week)." Weeks";
		}elseif ($secs >= $month && $secs < $year) { $output = round($secs/$month)." Months";
		}elseif ($secs >= $year && $secs < $year*10) { $output = round($secs/$year)." Years";
		}else{ $output = " more than a decade ago"; }
 
		/*if ($output <> "now"){
			$output = (substr($output,0,2)<>"1 ") ? $output."s" : $output;
		}*/
		return $output;
	}



function date_fix($value) {
	
$fixed_date=explode("-",$value);	
return $fixed_date[2]."/".$fixed_date[1]."/".$fixed_date[0];	
	
}





?>