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/indicator/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //home/pathumthani_integration/integration/application/indicator/function.inc.php
<?php
	function getUniqueId()
	{
		$rd = uniqid(rand(1000000,9999999),true);
		$rd2 = explode(".",$rd);
		$rd = $rd2[0].$rd2[1];
		$r = rand(0,4);
		$rd = substr($rd,$r,25); 
		return $rd;	
	}
	
	/* ฟังก์ชั่นคำนวณร้อยละ Modified By : Aussy [2552-10-02 19:04] */
	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