PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a server that a site domain and 2 subdomains, the PHP code plus the rest of the files used to "make" sits in a single directory called Core.
The problem is that: a script that reads and outputs images from Core doesn' t work in the subdomains. None of the error messages put in the file appear when I call for the file. I read about how the subdomains consider the absolute paths as starting from their directories, only links to other domains or subdomains work but I can use that.
The script is a simple one:
trace(__FILE__);
if(!isset($_GET['file'])) {echo ( 'missing param file');}
$path=$_SERVER['DOCUMENT_ROOT']'/img/'.$_GET['file'];
// the onlyext is a function that extracts the extension from a given path
header ("Content-Type:image/".onlyext($path));
$msg='Canget. File not found:'.$path;
if (!is_file($path)) echo ( "$path file not found in canget." );
$file_extension = onlyext($path);
switch( $file_extension ) {
case "php":
case "py":
echo ("Try to get a file of $file_extension type is not permitted");
break;
}
readfile($path);
Well the current working directory changes depending on where a script is called from. Would it be possible for you to use a full path? ie /home/username/public_html/core/file.php?
I tried working with a full path, the path is this: /scripts/img/backg.jpg, but it's not working.
Off topic: Sorry about the double post, please delete the post, but yesterday the server blocked when I posted and it didn' t load for time to verify if the post has been put on the forum. I had over the last month a hard time accessing the forum, it didn' t load because too slow and sometimes FF reported it can' t reach the site.