<?
 
/**
 
This function takes a left and right parameter, then returns the path
 
that is the combination of these two parameters.
 
 
@param $left Left side of path to build
 
 
@param $right Right side of path to build
 
 
@return The path that is the result of combining the <code>$left</code>
 
and <code>$right</code> parameters
 
 
@access private
 
*/
 
function BuildPath($left, $right) {
 
    $tmpLeft = trim($left);
 
    $tmpRight = trim($right);
 
 
    if (strrpos($tmpLeft, "/") == strlen($tmpLeft) - 1) {
 
        if (strpos2($tmpRight, "/") == 0) {
 
            $tmpResult = $tmpLeft . substr($tmpRight, 1);
 
        } else {
 
            $tmpResult = $tmpLeft . "/" . $tmpRight;
 
        }
 
    } else {
 
        if (strpos2($tmpRight, "/") == 0) {
 
            $tmpResult = $tmpLeft . $tmpRight;
 
        } else {
 
            $tmpResult = $tmpLeft . "/" . $tmpRight;
 
        }
 
    }
 
 
    return $tmpResult;
 
}
 
 
 
/**
 
This function is a replacement for the strpos built-in function.  If the
 
string <code>$ident</code> is not found in <code>$str</code>, <code>-1</code>
 
is returned, otherwise, the position that <code>$ident</code> is found
 
in <code>$str</code> is returned
 
 
@param $str The string in which to search for <code>$ident</code>
 
 
@param $ident The substring that we are looking for in <code>$str</code>
 
 
@return integer The position in <code>$str</code> that <code>$ident</code> is
 
found.  If <code>$ident</code> is not found, <code>-1</code> is returned.
 
*/
 
function strpos2($str, $ident) {
 
    $pos = strpos($str, $ident);
 
 
    if (is_string($pos) && !$pos) {
 
        return -1;
 
    } else {
 
        return $pos;
 
    }
 
}
 
 
 
/**
 
This function deletes a file from the server
 
 
@param $file Full path to the file to delete
 
 
@return boolean True if the delete was successful, false otherwise
 
 
@access private
 
*/
 
function deleteFile($file) {
 
    clearstatcache();
 
    if (file_exists($file)) {
 
        unlink($file);
 
        return true;
 
    }
 
 
    return false;
 
}
 
?>
 
 |