示例#1
0
function dir_enter($entry_dir = '/', $depth = 0)
{
    $found = 0;
    # Remove the last trailing slash and void dual writing
    $entry_dir = preg_replace('/\\/$/i', '', $entry_dir);
    $skip_list = array('.', '..');
    if ($dir_handle = opendir($entry_dir)) {
        while (false !== ($filename = readdir($dir_handle))) {
            if (in_array($filename, $skip_list)) {
                continue;
            }
            $full_file_path = "{$entry_dir}/{$filename}";
            if (is_dir($full_file_path)) {
                # Need to loop here inside the directory
                fecho(str_repeat('  ', $depth));
                # depth marker
                #fecho("{$full_file_path}");
                fecho("{$filename}");
                # Recurse through the file
                $function = __FUNCTION__;
                $found += $function($full_file_path, $depth + 1);
            } else {
                #fecho(str_repeat('  ', $depth)); # depth marker
                #fecho("{$full_file_path}");
                #fecho("{$filename}");
                ++$found;
                process_file($full_file_path, $depth);
            }
        }
        closedir($dir_handle);
    }
    return $found;
}
function process_file($full_file_path = '/tmp/nothing.txt', $depth = 1)
{
    if (!is_file($full_file_path)) {
        # || basename($full_file_path)!=$filename)
        return null;
    }
    $depth = (int) $depth;
    fecho(str_repeat('  ', $depth));
    # depth marker
    #fecho("{$full_path})";
    #fecho("{$filename})";
    #$full_file_path = 'F:/htdocs/smarty-framework/public_html/.htaccess';
    $parts = pathinfo($full_file_path);
    if (!isset($parts['dirname'])) {
        $parts['dirname'] = '';
    }
    # full path name
    if (!isset($parts['basename'])) {
        $parts['basename'] = '';
    }
    # file name with extension
    if (!isset($parts['extension'])) {
        $parts['extension'] = '';
    }
    # extension only
    if (!isset($parts['filename'])) {
        $parts['filename'] = '';
    }
    # without the extension
    if (strtolower($parts['extension']) != 'mp3') {
        # accept .mp3 files only
        return null;
    }
    #	print_r($parts);
    #	die();
    /*
    Array
    (
        [dirname] => F:/SmartDraw VP/SmartDraw VP
        [basename] => CaseMapLink.dll
        [extension] => dll
        [filename] => CaseMapLink
    )*/
    $file_size = filesize($full_file_path);
    $md5 = md5_file($full_file_path);
    $sha1 = sha1_file($full_file_path);
    fecho("{$parts['basename']}, {$file_size}, {$md5}, {$sha1}");
    flush();
    $created_on = filectime($full_file_path);
    $modified_on = filemtime($full_file_path);
    $accessed_on = 0;
    # Save the information into the database
    $sql = "\r\nINSERT INTO `physical_files`(\r\n\t`file_id`,\r\n\t`file_depth`, `file_size`,\r\n\t`file_name`, `file_extension`,\r\n\t`hash_md5`, `hash_sha1`,\r\n\t`file_path`,\r\n\t`created_on`, `modified_on`, `accessed_on`\r\n) VALUES (\r\n\tNULL,\r\n\t'{$depth}', '{$file_size}',\r\n\t'{$parts['basename']}', '{$parts['extension']}',\r\n\t'{$md5}', '{$sha1}',\r\n\t'{$full_file_path}',\r\n\t'{$created_on}', '{$modified_on}', '{$accessed_on}'\r\n);";
    #die($sql);
    mysql_query($sql);
}
示例#3
0
function redirectTo($ruta, $segundos = 0)
{
    fecho("<script type='text/javascript'> setTimeout(function () {\n        window.location.href = base_url + 'index.php/{$ruta}';\n    }, {$segundos}*1000);</script>");
}
示例#4
0
	public function make_vcxproj_filters() {
		foreach($this->projects as $handle=>$info) {
			$f = fopen("{$this->project_dir}/".$info["vcxproj"].".filters", "w+");

			fecholn($f,
				"<?xml version=\"1.0\" encoding=\"utf-8\"?>".
				"<Project ToolsVersion=".quote($this->toolsversion)." xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"
			);

			/* list of filters we'll be using */
			fecho($f,
				"<ItemGroup>".
				"<Filter Include=\"Source\"></Filter>"
			);

			$seen = array();
			foreach($info["files"] as $handle) {
				foreach($this->files[$handle] as $path) {
					while (1) {
						$chop_directory = preg_replace("!^(.*)\\\\.*$!", "$1", $path);
						if ($chop_directory === $path)
							break;
						$seen[$chop_directory] = 1;
						$path = $chop_directory;
					}
				}
			}

			foreach($seen as $basepath=>$dummy)
				fecho($f, "<Filter Include=\"Source\\{$basepath}\"></Filter>");
			fecholn($f, "</ItemGroup>");
			/* list of filters we'll be using */

			/* list of files with their filters */
			foreach($info["files"] as $handle) {
				fecho($f, "<ItemGroup>");
				foreach($this->files[$handle] as $path) {
					$type = $this->fileinfo[$path]["type"];
					$folder = $this->fileinfo[$path]["basepath"];
					fecho($f, "<{$type} Include=\"..\\{$path}\"><Filter>Source\\{$folder}</Filter></{$type}>");
				}
				fecholn($f, "</ItemGroup>");
			}
			/* list of files with their filters */

			fecholn($f, "</Project>");

			fclose($f);
		}
	}