PHP

Convert XML to array


/**
* Converts XML to array
*
* @param unknown_type $url
* @param unknown_type $get_attributes
* @param unknown_type $priority
* @return unknown
*/
function xml2array($url, $get_attributes = 1, $priority = 'tag')
{
$contents = "";
if (!function_exists('xml_parser_create'))
{
return array ();
}
$parser = xml_parser_create('');
if (!($fp = @ fopen($url, 'rb')))
{
return array ();
}
while (!feof($fp))
{
$contents .= fread($fp, 8192);
}
fclose($fp);
xml_parser_set_option($pars

Check if URL exist

This function checks if a given URL is valid by using fsockopen.


function is_valid_url ($url){
$url = @parse_url($url);
if ( ! $url) {
return false;
}

$url = array_map('trim', $url);
$url['port'] = (!isset($url['port'])) ? 80 : (int)$url['port'];
$path = (isset($url['path'])) ? $url['path'] : '';

if ($path == ''){
$path = '/';
}

$path .= ( isset ( $url['query'] ) ) ?

Human readable password function


/**
* Creates human readable passwords
* TODO: filter not desired phrases
* @param unknown_type $length
* @return unknown
*/

function com_dir_create_password($length = 10){
global $strength;

$conso = array("b","c","d","f","g","h","j","k","m","n","p","r","s","t","v","w","x","y","z");
$numeric = array(2,3,4,5,6,7,8,9);
$vocal = array("a","e","i","o","u");
$password = "";
srand ((double)microtime()*1000000);

$templength = ($length % 2) ? $length -1 : $length -2;
$max = $templength/2;

for($i=1; $i<=$max; $i++)

Pages