Recent versions of PHP have a cache of filenames for knowing the real path of files, and require_once() and include_once() can take advantage of it.
There's a value you can set in your php.ini to set the size of the cache, but I have no idea how to tell what the size should be. The default value is 16k, but I see no way of telling how ...
<?php
if (preg_match('/^[a-z0-9]+$/', $_GET['p'])) {
$page = realpath('pages/'.$_GET['p'].'.php');
$tpl = realpath('templates/'.$_GET['p'].'.html');
if ($page && $tpl) {
include $page;
include $tpl;
} else {
include('error.php');
}
}
?>
How safe would you say this is?
...
I'm looking for an example of how to use the realpath function in a C program. I can't seem to find one on the web or in any of my C programming books.
...
When I compile the following code:
#define _POSIX_C_SOURCE 200112L
#define _ISOC99_SOURCE
#define __EXTENSIONS__
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
int
main(int argc, char *argv[])
{
char *symlinkpath = argv[1];
char actualpath [PATH_MAX];
char *ptr;
ptr = realpath(symlinkpath, actualpath);
...
I need to get the aboslute path of a file uploaded by the user in PHP. How can I do that? Im doing this cause I need to post the information to an API via cURL
...
I am developing under wamp.
echo realpath(APPPATH);
C:\wamp\www\salsaritmo\system\application
echo realpath(APPPATH . '..');
C:\wamp\www\salsaritmo\system
echo realpath(APPPATH . '../files'); //(which is the one i want)
returns nothing
...
I need to get Perl to remove relative path components from a Linux path. I've found a couple of functions that almost do what I want, but:
File::Spec->rel2abs does too little. It does not resolve ".." into a directory properly.
Cwd::realpath does too much. It resolves all symbolic links in the path, which I do not want.
Perhaps the...
I need to get real path for file in my WebContent directory, so that framework that I use can access that file. It only takes String file as attribute, so I need to get the real path to this file in WebContent directory.
I use Spring Framework, so solution should be possible to make in Spring.
...
<?php
$server = $_SERVER["SERVER_NAME"];
$pathpath = realpath("../../files/uploaded_file.jpg");
echo "You can link to the file using the following link... $server$pathpath";
?>
Unfortunately this produces the following...
www.example.com/home/fhlinux123/g/example.com/user/htdocs/ninja/base/files/1.doc
Whereas what I am a...
Apparently, realpath is very buggy. In PHP 5.3.1, it causes random crashes.
In 5.3.0 and less, realpath randomly fails and returns false (for the same string of course), plus it always fails on realpath-ing the same string twice/more (and of course, it works the first time).
Also, it is so buggy in earlier PHP versions, that it is compl...