PK

ADDRLIN : /home/anibklip/pcfcindia.com/24-25/common/
FLL :
Current File : /home/anibklip/pcfcindia.com/24-25/common/common.php

<?php	
		//-------------<Root Path>--------------------------
		function get_root()
		{
			$arrSiteRoot=explode("/",$_SERVER['PHP_SELF']);
			return ($arrSiteRoot[0]."/".$arrSiteRoot[1]);
			//return "/pratyush/pcfcindia/2019/";
		}
		 //-------------</Root Path>--------------------------
		
		//PRINT ARRAY WITH PRE TAG..
		function print_pre($array0)
		{
	        echo "<pre>";
			print_r($array0);
			echo "</pre>";
		}
		
		//Anti sql Injection Function 
		//Escape()
		function escape($string='')
		{	//echo $string;
			if(!empty($string))
			{
				if(get_magic_quotes_gpc())
					$string = stripcslashes($string);
					
				$string = mysql_real_escape_string($string);	
				return $string;
			}
		}
		
		
		//CREATE THUMBS
		function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth )
		{
  			// open the directory
  			$dir = opendir( $pathToImages );

			// loop through it, looking for any/all JPG files:
			while (false !== ($fname = readdir( $dir ))) 
			{
			    // parse path for the extension
			    $info = pathinfo($pathToImages . $fname);
			    // continue only if this is a JPEG image
			    if ( strtolower($info['extension']) == 'jpg' )
			    {
			      //echo "Creating thumbnail for {$fname} <br />";
			
			      // load image and get image size
			      $img = imagecreatefromjpeg( "{$pathToImages}{$fname}" );
			      $width = imagesx( $img );
			      $height = imagesy( $img );
			
			      // calculate thumbnail size
			      $new_width = $thumbWidth;
			      $new_height = floor( $height * ( $thumbWidth / $width ) );
			
			      // create a new temporary image
			      $tmp_img = imagecreatetruecolor( $new_width, $new_height );
			
			      // copy and resize old image into new image
			      imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
			
			      // save thumbnail into a file
			      imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" );
			    }
			  }
			  // close the directory
			  closedir( $dir );
		}
		
		//DATE Diff Function
		function dateDiff($dformat, $endDate, $beginDate)
		{
		   $date_parts1=explode($dformat, $beginDate);
		   $date_parts2=explode($dformat, $endDate);
		   $start_date=gregoriantojd( $date_parts1[1],$date_parts1[0], $date_parts1[2]);
		   $end_date=gregoriantojd( $date_parts2[1],$date_parts2[0], $date_parts2[2]);
		   return $end_date - $start_date;
		}
		
		//PHP DATE TO SQL DATE
		function sqldate($date)
		{
			$val = $date;
			$chk = explode("/", $val);
			$dat =$chk[2]."-".$chk[1]."-".$chk[0];
			return $dat;
		}
		//SQL DATE TO PHP DATE
		function phpDate($idate)
		{
			$arr=explode("-",$idate);
			return $arr[2]."/".$arr[1]."/".$arr[0]; 		
		}	
		function generatePassword($length=8,$level=2)
		{
		
		   list($usec, $sec) = explode(' ', microtime());
		   srand((float) $sec + ((float) $usec * 100000));
		
		   $validchars[1] = "0123456789abcdfghjkmnpqrstvwxyz";
		   $validchars[2] = "0123456789abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		   $validchars[3] = "0123456789_!@#$%&*()-=+/abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_!@#$%&*()-=+/";
		
		   $password  = "";
		   $counter   = 0;
		
		   while ($counter < $length) {
		     $actChar = substr($validchars[$level], rand(0, strlen($validchars[$level])-1), 1);
		
		     // All character must be different
		     if (!strstr($password, $actChar)) {
		        $password .= $actChar;
		        $counter++;
		     }
		   }
		
		   return $password;
		
		}
		
		function GetMonthString($n)
		{
	    	$timestamp = mktime(0, 0, 0, $n, 1, 2005);
	   		 return date("M", $timestamp);
		}
		function limit_words( $str, $num, $append_str='' )
		{
		  $words = preg_split( '/[\s]+/', $str, -1, PREG_SPLIT_OFFSET_CAPTURE );
		  if( isset($words[$num][1]) )
		  {
		    $str = substr( $str, 0, $words[$num][1] ) . $append_str;
		  }
		  unset( $words, $num );
		  return trim( $str );
		}
?>


PK 99