Exemple #1
0
function parsePath($dir)
{
    global $switches;
    if ($dh = opendir($dir)) {
        $dirlist = array();
        $cdok = false;
        while (($file = readdir($dh)) !== false) {
            if ($file == '.svn') {
                continue;
            }
            $type = filetype($dir . '/' . $file);
            if ($type == 'dir') {
                if ($file != '.' && $file != '..') {
                    $dirlist[] = $file;
                }
            } else {
                if (preg_match("/\\.(php|xml|rng|dist|tpl|properties)\$/", $file)) {
                    $content = file_get_contents($dir . '/' . $file);
                    if (strpos($content, "\r") !== false) {
                        if (isset($switches['-n'])) {
                            echo $dir . '/' . $file . " need to be converted\n";
                        } else {
                            echo " convert " . $dir . '/' . $file . "\n";
                            $content = str_replace("\r\n", "\n", $content);
                            file_put_contents($dir . '/' . $file, $content);
                        }
                    } else {
                        //echo "  ".$dir.'/'.$file."\n";
                    }
                } else {
                    //echo "! no parsing $file\n";
                }
            }
        }
        closedir($dh);
        foreach ($dirlist as $d) {
            parsePath($dir . '/' . $d);
        }
    } else {
        echo "!!! error when reading directory {$dir} !!!\n";
        exit(1);
    }
}
Exemple #2
0
function parsePath($fullPath, $role, $fileMatch = '/^(.*)$/', $padding = 3)
{
    $fileList = '';
    $file = basename($fullPath);
    if (is_dir($fullPath) && substr(basename($fullPath), 0, 1) !== '.') {
        $fileList .= str_repeat("\t", $padding) . "<dir name=\"{$file}\">\n";
        foreach (scandir($fullPath) as $subPath) {
            if ($subPath === '.' || $subPath === '..') {
                continue;
            }
            $fileList .= parsePath($fullPath . '/' . $subPath, $role, $fileMatch, $padding + 1);
        }
        $fileList .= str_repeat("\t", $padding) . "</dir><!-- {$file} -->\n";
    } elseif (is_file($fullPath)) {
        if (preg_match($fileMatch, $file)) {
            $fileList .= str_repeat("\t", $padding) . "<file name=\"{$file}\" role=\"{$role}\" />\n";
        }
    }
    return $fileList;
}
Exemple #3
0
/**
 *		renameFile
 *
 *			Rename a file
 *
 *	@param	fullPath				Full path string (file path)
 *	@param	rootDir					Root directory
 *	@param	args						HTTP QUERY-STRING arguments decoded.
 *	@param	status					Receives the final result (200, 204 or 404).
 *
 *	@return		An array of 1 FILE_INFO object or NULL in case no match was found.
 **/
function renameFile($fullPath, $rootDir, $args, &$status)
{
    $status = HTTP_V_OK;
    if (file_exists($fullPath)) {
        $fileList = array();
        $newPath = realURL($rootDir . "/" . realURL($args->newValue));
        if (!strncmp($newPath, $rootDir, strlen($rootDir))) {
            if (!file_exists($newPath)) {
                if (rename($fullPath, $newPath)) {
                    $uri = parsePath($newPath, $rootDir);
                    $newFile = fileToStruct($uri->dirPath, $rootDir, $uri->filename, $args);
                    $newFile->oldPath = "./" . substr($fullPath, strlen($rootDir) + 1);
                    $fileList[] = $newFile;
                } else {
                    $status = HTTP_V_NOT_FOUND;
                }
            } else {
                $status = HTTP_V_CONFLICT;
            }
        } else {
            $status = HTTP_V_FORBIDDEN;
        }
        return $fileList;
    }
    return null;
}
 function parsePath($path, &$pathInfo)
 {
     $pathInfo[$path] = 1;
     $t = explode("/", $path);
     array_pop($t);
     if (count($t) != 0) {
         parsePath(implode("/", $t), $pathInfo);
     }
 }
// Can be development or production
define("ENVIRONMENT", "development");
// The development url
define("DEVELURL", "http://localhost/srv.uib.es/pointclouds/");
// The production url
define("PRODURL", "http://srv.uib.es/pointclouds/");
/*
 *---------------------------------------------------------------
 * URL PARSER
 *---------------------------------------------------------------
 *
 * Parses the url and load the correct page.
 */
// Parse the url
include 'app/helpers/url.php';
$pathInfo = parsePath();
// Load pages
if (sizeof($pathInfo['call_parts']) > 0) {
    $page = $pathInfo['call_parts'][0];
    switch ($page) {
        case 'view':
            $pcFolder = isset($_REQUEST['c']) ? $_REQUEST['c'] : null;
            include 'app/views/viewer.php';
            break;
        case '404':
            include 'app/views/404.php';
            break;
        default:
            include 'app/views/home.php';
            break;
    }
function parsePath($fullPath, $role, $padding = 4)
{
    $fileList = '';
    $file = basename($fullPath);
    if (is_dir($fullPath)) {
        $fileList .= str_repeat(' ', $padding) . "<dir name=\"{$file}\">\n";
        foreach (scandir($fullPath) as $subPath) {
            if ($subPath === '.' || $subPath === '..') {
                continue;
            }
            $fileList .= parsePath($fullPath . '/' . $subPath, $role, $padding + 2);
        }
        $fileList .= str_repeat(' ', $padding) . "</dir><!-- {$file} -->\n";
    } elseif (is_file($fullPath)) {
        $fileList .= str_repeat(' ', $padding) . "<file name=\"{$file}\" role=\"{$role}\" />\n";
    }
    return $fileList;
}