satishgaudo.com

Understanding technology

Archive for the 'PHP' Category

glob — Find pathnames matching a pattern

$aDir = glob(”/clt20/uploads/videos/*.flv”); The glob() function searches for all the pathnames matching pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells.

27 October 2009 at 11:54 - Comments

memcached: high-performance, distributed memory object caching system

memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.memcached drop the database load to almost nothing, yielding faster page load times for users, better resource utilization, and faster access to the databases on a memcache miss.For more details [...]

25 June 2009 at 20:30 - Comments
satish_gaude at 20:33 on 25 June 2009
td2n8pf at 11:05 on 11 July 2009
Thanks . thats a great post

wrapper class for curl

/** *cURL class * This is a wrapper class for curl * $c = new curl; * // enable cache * $c = new curl(array(’cache’=>true)); * // enable cookie * $c = new curl(array(’cookie’=>true)); * // enable proxy * $c = new curl(array(’proxy’=>true)); * * // HTTP GET Method * $html = $c->get(’http://example.com’); * // [...]

16 June 2009 at 13:56 - Comments

function to submit data via socket

/** * sendDataOnSocket * function to submit data via socket * @param string $sContent content to send * @param string $sHost Host name * @param string $sFilePath  file to post data * @param string $sMethod method name * @return string aig response * @access public */ public static function sendDataOnSocket($sContent,$sHost,$sFilePath,$sMethod) { if(strlen($sHost)==0) { return array(1, "Empty Host name"); }else if (strlen($sMethod)==0) { return array(1, "Empty Method"); } $fp = fsockopen($sHost, "80", [...]

16 June 2009 at 13:54 - Comments
pidxfgop at 23:49 on 14 July 2009
thanks . i was searching for this code
lmn_nihez at 13:48 on 14 August 2009
Nice site.

validate xml against xsd file provided

/** * validateXmlAgainstXsd * function to validate xml against xsd file provided * @param string $error error * @return string api response * @access public */ public static function validateXmlAgainstXsd($sXmlPath,$sXsdPath) { // Enable user error handling libxml_use_internal_errors(true); $xml = new DOMDocument(); $xml->load($sXmlPath); if (!$xml->schemaValidate($sXsdPath)) { $aError =self::libxml_display_errors(); $iError=1; } else { $iError=0; } return array($iError,$aError); }   Example of XSD file: <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:annotation> <xs:documentation xml:lang="en"> Job specification schema for scheduler.vubites.com Copyright 2010 satishgaudo.com. All rights reserved. </xs:documentation> </xs:annotation> <xs:element name="response" type="responseType"/> <xs:complexType name="responseType"> <xs:sequence> <xs:element name="status" [...]

16 June 2009 at 13:53 - Comments
TifyWheef at 17:10 on 8 July 2009
http://extjs.com/forum/member.php?u=79374 guitar lessons
Debt Settlement Program at 14:23 on 18 August 2009
complex post. due one detail where I contest with it. I am emailing you in detail.

Function to get the mime type of the file

/** * getFileMimeType * returns the mime type of the file * @param string $sFilePath File path * @return string mime type of the file * @access public */ public function getFileMimeType($sFilePath) { exec(’/usr/bin/file -i -b ‘ . realpath($sFilePath), $aOutput); $sType = $aOutput[0]; $aMimeTypeDet = explode(’;', $sType); return trim($aMimeTypeDet[0]); }

16 June 2009 at 13:49 - Comments
Sdanektir at 02:15 on 7 August 2009
OMG…totally!
Vivalkakira at 21:37 on 7 August 2009
Amazing news, thank you!

Function to get the recursive folder structure of the destionation folder

/** * getDirStructure * get the recursive folder structure of the destionation folder * @param string $path folder path * @param array array resultant folders and files * @access public */ public function getDirStructure($path, &$a, $sOriginalZipFilepath){ $aDir=array(); $aFiles=array(); $nd=0; $nf=0; $hndl=opendir($path); while($file=readdir($hndl)){ if ($file ==’.’ || $file==’..’) continue; if (is_dir($path.’/’.$file)){ $aDir[$nd++]=$file; } else{ $aFiles[$nf++]=$file; } } closedir($hndl); $n=1; for ($i=0;$i<count($aDir);$i++){ $this->getDirStructure($path.’/’.$aDir[$i].’/', $a[$n]); $a[$n++][0]=str_replace("//","/",$path.$aDir[$i]); } for ($i=0;$i<count($aFiles);$i++){ $a[$n++]=str_replace("//","/",$path.$aFiles[$i]); } }

15 June 2009 at 20:24 - Comments
twmujczf at 23:50 on 14 July 2009
thanks . i was searching for this code
Vaibhav at 11:20 on 29 January 2010
Hi Satish, Good work dude ...

Example script for exexuting an mssql stored procedure in php

$package_code = ‘AUS03B’; $client_id = 499; $conn = odbc_connect(DSN,USER,PASS,SQL_CUR_USE_ODBC); //SQL_CUR_USE_IF_NEEDED,SQL_CUR_USE_ODBC ,SQL_CUR_USE_DRIVER SQL_CUR_DEFAULT $sql_result = odbc_prepare($conn, "EXEC usp_packagesearch_xml ‘$package_code’,'$client_id’"); $result = odbc_execute($sql_result); //$string = odbc_result($sql_result,1); $string = odbc_result_all($sql_result,"border=1");

15 June 2009 at 20:22 - Comments