<?php



/*

* General functions

*

* Web Traffic Genius Pro v3.5.4

* Copyright (c) 2008-2009

* Success on the Internet Pty Ltd

* PO Box 25

* Salisbury SA 5108

* Australia

* Phone: +61 422 512 549

* Fax: +61 8 8425 9657

* Web: http://www.webtrafficgenius.com

* Support: http://www.marketing-assassins.com

*

*/



if (!function_exists("stripos")) {

    function stripos($str, $needle, $offset = 0) {

        if (empty($needle)) return false;

        return strpos(strtolower($str), strtolower($needle), $offset);

    }

}



if (!function_exists('file_put_contents')) {

    function file_put_contents($n, $d, $flag = false) {

        $mode = $flag ? 'a' : 'w';

        $f = @fopen($n, $mode);

        if ($f === false) {

            return false;

        } else {

            if (is_array($d)) $d = implode($d);

            $bytes_written = fwrite($f, $d);

            fclose($f);

            return $bytes_written;

        }

    }

}



function wtg_to_array(&$v) {

    if (!isset($v)) return array();

    if (isset($v) && !is_object($v) && !isset($v[0])) {

        $v = array(0 => $v);

    }

    return $v;

}





function wtg_is_above_dir($path, $base) {

    $path = realpath($path);

    $base = realpath($base);

    return 0 !== strncmp($path, $base, strlen($base));

}



function wtg_path_is_absolute ($path) {
	// this is definitive if true but fails if $path does not exist or contains a symbolic link
	if ( realpath($path) == $path )
		return true;

	if ( strlen($path) == 0 || $path{0} == '.' )
		return false;

	// windows allows absolute paths like this
	if ( preg_match('#^[a-zA-Z]:\\\\#', $path) )
		return true;

	// a path starting with / or \ is absolute; anything else is relative
	return (bool) preg_match('#^[/\\\\]#', $path);
}



?>