function _print_r( $thing ){ echo '
'; print_r( $thing ); echo ''; } function ntsJoinArray( $array ){ reset( $array ); foreach( $array as $k => $v ){ $returnStrings[] = ''; } } function ntsExplodeArray( $string ){ } class ntsLib{ // A generic function to create and fetch static objects function &singletonFunction( $class, $fileName = '' ) { // Declare a static variable to hold the object instance static $instances; // If the instance is not there, create one if( ! isset($instances[$class]) ){ if( ! class_exists($class) ){ echo "cannot create '$class' object!"; return null; } $instances[$class] = new $class; } return $instances[$class]; } function addErrorLog( $msg ){ $db =& dbWrapper::getInstance(); $values = array( 'description' => $msg, 'created' => 'NOW()' ); $insertSql = $db->prepareInsertStatement( $values, array('created' => 'number') ); $sql = "INSERT INTO {PRFX}errors $insertSql"; $result = $db->runQuery( $sql ); } function getUniqueID(){ static $id = 0; $id++; return $id; } function fileGetContents( $fileName ){ $content = join( '', file($fileName) ); return $content; } function fileGetFirstLine( $fileName ){ $line = array_shift( file($fileName) ); return $line; } function fileSetContents( $fileName, $content ){ $length = strlen( $content ); $return = 1; if(! $fh = fopen($fileName, 'w') ){ echo "can't open file $fileName for wrinting."; exit; } rewind( $fh ); $writeResult = fwrite($fh, $content, $length); if( $writeResult === FALSE ) $return = 0; return $return; } function numberCompare( $a, $b ){ if( $a > $b ) return 1; elseif( $a < $b ) return -1; else return 0; } function stringCompare( $a, $b ){ return strcmp( strtolower($a), strtolower($b) ); } function getParentPath( $path ){ if( substr($path, -1) == '/' ) $path = substr($path, 0, -1); if( preg_match("/^(.+)\/.+$/", $path, $ma) ) $parent = $ma[1]; else $parent = ''; return $parent; } function listSubfolders( $dirName ){ $dirs = array(); if ( file_exists($dirName) && ($handle = opendir($dirName)) ){ while ( false !== ($f = readdir($handle)) ){ if( substr($f, 0, 1) == '.' ) continue; if( is_dir( $dirName . '/' . $f ) ){ $dirs[] = $f; } } closedir($handle); } sort( $dirs ); return $dirs; } function listFiles( $dirName, $extension = '' ){ $files = array(); if ( file_exists($dirName) && ($handle = opendir($dirName)) ){ while ( false !== ($f = readdir($handle)) ){ if( substr($f, 0, 1) == '.' ) continue; if( is_file( $dirName . '/' . $f ) ){ if( (! $extension ) || ( substr($f, - strlen($extension)) == $extension ) ) $files[] = $f; } } closedir($handle); } sort( $files ); return $files; } function utime() { $time = explode( ' ', microtime() ); $usec = (double)$time[0]; $sec = (double)$time[1]; $return = $sec + $usec; return $return; } function printCurrentExecutionTime(){ global $EXECUTION_START; $currentExecutionTime = ntsLib::utime() - $EXECUTION_START; printf("