utils.php File Reference

Go to the source code of this file.

Namespaces

namespace  MythWeb

Functions

 setting ($field, $hostname=null, $new_value="old\0old")
 Get or set a database setting.
 find_in_path ($file)
 Find a particular file in the current include_path.
 smart_args ($args)
 I like how in perl, you can pass variables into functions in lists or arrays, and they all show up to the function as one giant list.
fix_crlfxy (&$array)
 Recursively fixes silly
stuff that some browsers send.
fix_magic_quotes (&$array)
 Recursively strip slashes from an array (eg.
 redirect_browser ($url)
 Strips slashes ONLY before quotes, to get around php adding slashes in preg_replace //e but not in such a way that stripslashes works properly.
 nice_filesize ($size)
 Pass in a filesize in bytes, and receive a more human-readable version JS: adapted from php.net: sponger 10-Jun-2002 12:28 /*.
 nice_length ($length)
 Convert a unix timestamp into an day/hour/minute string.
 unixtime ($sql_timestamp)
 Converts an sql timestamp into unixtime /*.
 escape ($string, $allow_null=false)
 DEPRECATED (use the Database object instead).
 html_entities ($str)
 Overloaded version of htmlentities() that requests the UTF-8 entities rather than the default ISO-9660.
 get_sorted_files ($dir= '.', $regex= '', $negate=false)
 Returns a sorted list of files in a directory, minus .
 timer ($message=null, $index=0)
 Start/display a microtime timer.
 _or ($this, $or_this, $gt=false)
 returns $this or $or_this if $gt is set to true, $this will only be returned if it's > 0 if $gt is set to a number, $this will only be returned if it's > $gt /*
 video_url ($show, $ext=false)
 Someday, we may even be able to pass in a recording and get back a specific hostname.
 utf8tolocal ($str)
 debug ($data, $file=false)
 Prints out a piece of data to the firebug console.
 fequals ($lhs, $rhs)


Function Documentation

setting ( field,
hostname = null,
new_value = "old\0old" 
)

Get or set a database setting.

Parameters:
string $field The field (settings.value) to retrieve/set.
string $hostname Hostname (or null) associated with $field.
string $new_value New value (settings.data) to set.
Returns:
string The value (settings.data) associated with $field and $hostname. /*

Definition at line 33 of file utils.php.

Referenced by Video::__construct(), DTVDeviceConfigGroup::AddNodes(), TriggeredConfigurationGroup::byName(), DoVideoDatabaseSchemaUpgrade(), get_str_option(), MainServer::HandleSetSetting(), MainServer::HandleSettingQuery(), if(), MythThemedMenuState::parseButtonDefinition(), RecorderBase::SetIntOption(), NuppelVideoRecorder::SetOptionsFromProfile(), RecorderBase::SetStrOption(), TVRec::SetupDTVSignalMonitor(), UpgradeMusicDatabaseSchema(), GlobalSetup::wireUI(), and ZMServer::ZMServer().

find_in_path ( file  ) 

Find a particular file in the current include_path.

Parameters:
string $file Name of the file to look for
Returns:
mixed Full path to the requested file, or null if it isn't found. /*

Definition at line 84 of file utils.php.

smart_args ( args  ) 

I like how in perl, you can pass variables into functions in lists or arrays, and they all show up to the function as one giant list.

This takes an array containing scalars and arrays of scalars, and returns one clean array of all values. /*

Definition at line 102 of file utils.php.

& fix_crlfxy ( &$  array  ) 

Recursively fixes silly
stuff that some browsers send.

Also adds a generic entry for fiends ending in _x or _y to better deal with image inputs. /*

Definition at line 122 of file utils.php.

& fix_magic_quotes ( &$  array  ) 

Recursively strip slashes from an array (eg.

$_GET). /*

Definition at line 141 of file utils.php.

redirect_browser ( url  ) 

Strips slashes ONLY before quotes, to get around php adding slashes in preg_replace //e but not in such a way that stripslashes works properly.

/*/ function strip_quote_slashes($str) { return preg_replace("/\\\\([\"'])/", '$1', $str); }

/** Print a redirect header and exit /*

Definition at line 162 of file utils.php.

nice_filesize ( size  ) 

Pass in a filesize in bytes, and receive a more human-readable version JS: adapted from php.net: sponger 10-Jun-2002 12:28 /*.

Definition at line 172 of file utils.php.

nice_length ( length  ) 

Convert a unix timestamp into an day/hour/minute string.

Parameters:
int $length time to convert.
Returns:
string Translated hour/minute string. /*

Definition at line 194 of file utils.php.

Referenced by Video::metadata().

unixtime ( sql_timestamp  ) 

Converts an sql timestamp into unixtime /*.

Definition at line 222 of file utils.php.

escape ( string,
allow_null = false 
)

DEPRECATED (use the Database object instead).

For lack of a function that escapes strings AND adds quotes, I wrote one myself to make the rest of my code read a bit easier. /*

Definition at line 237 of file utils.php.

Referenced by MythControls::keyPressEvent(), sajax_get_common_js(), and vc1_decode_ac_coeff().

html_entities ( str  ) 

Overloaded version of htmlentities() that requests the UTF-8 entities rather than the default ISO-9660.

Parameters:
string $str String to convert to html entities
Returns:
UTF-8 entities for $str /*

Definition at line 253 of file utils.php.

get_sorted_files ( dir = '.',
regex = '',
negate = false 
)

Returns a sorted list of files in a directory, minus .

and .. /*

Definition at line 260 of file utils.php.

timer ( message = null,
index = 0 
)

Start/display a microtime timer.

Parameters:
mixed $message The message to echo, or another value (see return)
int $index The index value of the cache to store the timer. Useful for handling multiple simultaneous timers.
Returns:
mixed If $message is ommitted or null, the current time is returned. If a string, the string is returned after being passed through sprintf() with the current time delta (float) as an argument. If anything else, the current time differential is returned. /*

Definition at line 285 of file utils.php.

Referenced by MadDecoder::calcLength(), UIAnimatedImageType::IsPaused(), AudioOutputOSS::OpenDevice(), AudioOutputJACK::OpenDevice(), NetworkControl::processJump(), NetworkControl::processPlay(), NetworkControl::processQuery(), ZMClient::readData(), BufferedSocketDevice::ReadLine(), MythSocket::readStringList(), WorkerThread::run(), AutoExpire::RunExpirer(), NetworkControl::saveScreenshot(), and MythContextPrivate::UPnPautoconf().

_or ( this,
or_this,
gt = false 
)

returns $this or $or_this if $gt is set to true, $this will only be returned if it's > 0 if $gt is set to a number, $this will only be returned if it's > $gt /*

Definition at line 313 of file utils.php.

Referenced by Channel::__construct().

video_url ( show,
ext = false 
)

Someday, we may even be able to pass in a recording and get back a specific hostname.

For now, you get either the hard-coded global video_url, or one determined based on the browser.

Returns:
string URL to access recordings /*

Definition at line 328 of file utils.php.

utf8tolocal ( str  ) 

Returns:
$str converted UTF-8 to local encoding /*

Definition at line 353 of file utils.php.

debug ( data,
file = false 
)

Prints out a piece of data to the firebug console.

/*

Definition at line 368 of file utils.php.

fequals ( lhs,
rhs 
)

Definition at line 406 of file utils.php.


Generated on Sat Dec 18 05:15:56 2010 for MythTV by  doxygen 1.5.5