File Access To Directories Below Document_root
I need some input on whether this can be done. Server Folder Structure:
httpdocs (all the web docs)
web_users (all ftp accounts)
snorider (specific ftp account folder)
On my server I have set up a web_user (specific ftp account) I have uploaded files to that directory, and now I am trying to use fopen to open them and read from them. Now I can access them through a link like: href="/~snorider/file_I_want.php"
But I'm having problems using fopen the same way. The overall purpose of this is to have user specific download files which can be uploaded to the server without having to connect to the server with full access to all the website files. Does anyone know of a way to get fopen to open the files inside "snorider" while using a LOCAL file path?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
CRON Scripts Fail To Access Group-shared Directories
I have CRON scripts with owner/group relationship of "phillip/apache" that need to access directories within the docroot. The directories, if I create them, will have owner/group relationship of "phillip/apache", and all is well since they are all group-accessible (permissions of 0770). However, I have a web app within the docroot that has the ability to spawn folders of its own. These folders will, of course have owner/group relationship of "apache/apache", and for security purposes must also have permissions of 0770. When my CRON scripts accesses the "phillip/apache" folders, all is well. However, when it access the "apache/apache" folders, I get a PHP warning "Permission Denied" when trying to access these folders using this: Code: ( php )
File Directories
I searched the forums and didn't see an answer to this question. I need to store a lot of files on my server, ~100 000 files. The files range from 800kb to 30MB. Would it make a difference in search time for PHP to find a single or multiple files if all the files were in one directory, or should I map them over several directories (e.g alphabetically)?
File Names In Directories
On my current website I have gallery pages with links to different galleries within that gallery section. The problem is, that I have to manually edit every single page when I want to add a new page so that every page now has a link that includes the new page number. Now I have been thinking that surely PHP could be used to automate this instead of me doing it every time I put a new gallery page online. What I'd like to know is if it is possible for PHP to read a file name, then use that to "echo" it into the HTML, then go to the next file name - do the same, until there are no more like sounding filenames in that directory. So for example, I have gallery01, gallery02, gallery03 webpages. I ask PHP to look for a match for "gallery", then add the file number "01", and echo it to the HTML page, and then do the same until there are no more "gallery" pages to be found in that directory. If possible, scould someone point me in which direction to do this (I don't need / want a complete solved solution :) ).
Including A Standard File In All Directories
I have one layout page that all directories use on my website. How can I make it so that no matter where the file is, the server will always include it. I cannot use direct paths because php will not allow it, and I can't specify the directory for each file. Example. Layout.php includes files/header.php which includes lib/main.lib. in Pages/Path/index.php I include ../../Layout.php. Than Layout.php's includes are all messed up.
Directories, CHMOD, And File Uploads
1) Is the only way that doesn't involve Databases to upload files is to CHMOD a directory to 777? 2) What are the risks of CHMODDING a directory to 777? 3) What are the risks of CHMODDING a .txt file to 777? 4) How can I find the name of every .txt file in a directory?
Creating Directories In Directories
I'm building a document management system and I've hit a snag. I'm relatively new, so this might be obvious to someone else. A user can add folders into the system (kinda like Windows Explorer) and then add folders IN those folders. I have a database set up to track the child/parent relationships but I'm having trouble with the actual creation of the directory on the server. I pass the "add folder" script the NAME of the new folder as well as the PATH of the new folder. If I'm in the root directory and I add a "TEST" folder I pass "TEST" as the folder name and "" as the path, because we're adding at the root. If I've added "TEST" and I want to add "IN TEST" inside the "TEST" folder I send "IN TEST" as the new folder name and "TEST" as the path. My code then adds a "/" and calls mkdir. So the path passed to mkdir is "IN TEST/TEST". Code:
DOCUMENT_ROOT In IIS
Having problems with env variable DOCUMENT_ROOT. I can't access it and it doesn't show up in phpinfo(). I can access it with my hosting provider on UNIX so I'm assuming it's an IIS problem. Does anyone know how I can set it or if its just something IIS doesn't support?
$document_root
Is using $DOCUMENT_ROOT in your fopen() statements a security thing or just a different way to put in the path to your server root? Also, am I understanding the third parameter in fopen() correctly? If I code fopen("test.inc", "r", "1"); Does the "1" mean that the script will automatically look for test.inc in the file listed for includes for PHP?
$DOCUMENT_ROOT And Mod_userdir
When you publish a website in /home/username/public_html and make it availabe with the mod_userdir apache module, it can be accessed via http://server/~username/. In that case though, the $DOCUMENT_ROOT variable is still e.g. /var/www/html. Is there another variable or a trick to get /home/username/public_html instead?
Register_globals = Off And $DOCUMENT_ROOT
I need to access $DOCUMENT_ROOT together with the option register_globals = Off How can I acces the content of $DOCUMENT_ROOT with another variable since it is empty with register_globals = Off ?? Which other variables are changed with this setting as well ?
Use Of $_SERVER['DOCUMENT_ROOT'].
I'm working on a large intranet group site with a lot of pages, file types, folders, subfolders, etc. I am using the include ('../includes/file.php') , but I would like to have a single snippet that will work for all .php/.html pages in all subfolders. I have seen the $_SERVER['DOCUMENT_ROOT'] indicated as a way to access the root of the website without using ../ for each folder you have to pass up through. However, I cannot get this to work for me. I've seen recommendations for it's use in FAQs, etc. online, they all seem to be a little bit different, but none of the formats (assign to a variable, etc.) work for me. We're using PHP 4.3.2
Access Button In HTML File Through PHP File
I’m new to PHP and I’m working on a code and having a problem . The problem is that I’m having an HTML file like this : //////////////////////////////////// <p>some text</p> <form action="/project/myfile.php" method="post"> <input type="button" name="mybutton.1" value=" mybutton "><input type="text" name="aaa" /> </form> <p> some text </p> <form action="/project/myfile.php" method="post"> <input type="button" name=" mybutton.2" value=" mybutton "><input type="text" name="aaa" /> </form> ////////////////////////////////////// I want to open a new HTML file to the user when he clicks on any of these buttons . I want to do this in the file named “myfile.php “ . What should I write in the file “myfile.php “ to get access to each button and open a new page when the user clicks on it? Is it correct to put " action="/project/myfile.php""? Should I put include the HTML file in my PHP file? I want also to remember which button the user clicks on.
Lack Of PHP_SELF And DOCUMENT_ROOT
from what ive gathered, there is NO documented way for a script to determine it's own directory path when it's executed from the command line. someone please tell me im wrong, because this really sucks. what im basically doing, is i have a program that gathers statistics, and im trying to write a script that will parse the logs on a cron job. by default the install path is determined by the document root or php_self, neither of which are available at the command line, in fact it seems NOTHING is available from the command line that will enable a script to determine where it resides. i understand why document_root isnt available, but the fact that absolutely no directory info is available is rather frustrating, and forcing users to maintain two configuration files is just dumb.
__FILE__ Vs. $_SERVER['DOCUMENT_ROOT'] ?
I'm trying to dynamically adjust the path for one of my scripts using this: $script_path = str_replace( $_SERVER['DOCUMENT_ROOT'], "", dirname(realpath(__FILE__)) ) . DIRECTORY_SEPARATOR; The problem: the server I'm currently testing it on returns for $_SERVER['DOCUMENT_ROOT'] something like the path "home/user/path/" and for __FILE__ "home2/user/path/scriptdir/" I tried to trace the discrepancy running phpinfo, but the only reference I can find to "home2" there is _ENV["PWD"]. Anyway, this is throwing all my best laid plans into confusion. Can someone help me understand why $_SERVER['DOCUMENT_ROOT'] and __FILE__ are returning different basepaths? And how I might get my script to do what I'd like it to do (basically, return the directory path of my script minus the document root so that I can then append it to the absolute URL)?
Getting To The Domain Name With $_SERVER['DOCUMENT_ROOT']
Before I end up with an imprint of my head on my office wall(and a really band headache), can someone tell me what the actual $_SERVER code is that will output the "domain name" root as opposed to the server root? In other words, I want to output "http://www.domain.com" instead of "/user/blah/m/q/stuff/morestuff/htdocs/".
Why $_SERVER['DOCUMENT_ROOT']; Sometimes Works??
I would like to be able to use : $docRoot = $_SERVER['DOCUMENT_ROOT']; to define my path fully when linking pages. for some reason this works fine on the live server, and fine on my laptop (which uses wamp and the server name is localhost) but on my work test server )that is networked) the path always shows a C:// etc Why is this ?? And can I fix-it??
Virtual Servers And $_SERVER[DOCUMENT_ROOT]
I'm new to php and was wondering if someone could help me out with the best way to accomplish this. I have Solaris 9/Apache 1.3.31/PHP 5.1.4 that I compiled from source code and installed. I have multiple virtual web servers configured in httpd.conf and php scripts run only if they are placed in my first VirtualHost DocumentRoot directory as defined in httpd.conf: <VirtualHost X.X.X.X:80> DocumentRoot /usr/local/apache/sites/webdocdir </VirtualHost> I would like to get php scripts to run in one of my other virtual servers defined in httpd.conf. Right now, my $_SERVER[DOCUMENT_ROOT] gets defined (I think) from httpd.conf such that it points to /usr/local/apache/sites/webdocdir. This I can see from the results of a phpinfo(). Is there some way of configuring Apache and/or php so that I am not forced to put php scripts in /usr/local/apache/sites/webdocdir?
Apapche Dynamic Vhosts - Document_root ??
I am using dynamic vhost on my apache development server (conf at end of msg). I am using $_SERVER['DOCUMENT_ROOT'] in the sites I am working on, which, as you may have guessed isnt giving me the full path of the vhosts web root folder (Its returning the value as set in my main apache conf file as it should) Is there a way to get the full path to the web root folder from php or have the value for document_root automatically munged by apache ? dynamic-vhosts.comf #Simple dynamic virtual hosts # # This extract from apache2.conf implements the virtual host arrangement # outlined at http://www.apache.org/docs/vhosts/mass.html, using # mod_vhost_alias. # get the server name from the Host: header UseCanonicalName Off # # this log format can be split per-virtual-host based on the first field LogFormat "%V %h %l %u %t "%r" %s %b" vcommon CustomLog logs/access_log vcommon # # include the server name in the filenames used to satisfy requests VirtualDocumentRoot /mnt/raid/Net/%0/htdocs #VirtualScriptAlias /www/hosts/%0/cgi-bin
File Access
I am trying to access/read log files that are on different servers (not web servers) to my scripts but don't seem to be able to access them. I get the following error: Warning: file("IP_Addressdredrent.log") - No such file or directory in c:inetpubwwwrootAutoreportslog_processingcheck_dre_query_log.php on line 15 I am using Windows 2000 and IIS. Code:
File Cannot Be Access
I am trying to access a series of files in one directory. Currently there is only one file located in it. But the coding that I am trying to use can not access it for some reason Here is the coding of which I am having problems with PHP Code:
Know When User Tries To Access Php File
is there a way to detect if a user tries to access a php file? For instance, db.config.php is called in many php pages but should never actually be open directly. Is there a way to know if someone tried to open it directly? Also, i want to learn more about securing php/MySQL pages any good resources I should start with?...
Restricting File Access
i have a user based login area, that i want to put some files into a folder that only registered members can have access to the files, so that they can download them. Is this possible with PHP, and could someone give me some pointers, how?
Access Locking Web File
I am running IIS on a win2000 machine linking to an MDB file with php. If the MDB is opened in access the website will display this error when attempting to view the web page: Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] Could not use '(unknown)' file already in use., SQL state S1000 in SQLConnect in c:inetpubwwwrootphpagencydbextlist.php on line 18 Could Not Make Connection Otherwise the data will display here is the code:
Need Access To Default File Attributes
When I was first learning php, I created an upload script. The basics of the script had: <form method="POST" ENCTYPE="multipart/form-data"> <input type="file" name="FILE"> <input type="submit" name="SUBMIT" value="Upload"> </form> Then in the submit section, it accesses the filename and filesize by virtue of a default php ability to extract these attributes by using: $FILE_name and $FILE_size (where _name gives the name of $FILE and _size gives the size of $FILE). if($SUBMIT) echo " Filename: $FILE_name <br> Filesize: $FILE_size"; Also, I did add the necessary lines to handle the post variables, like so: $FILE = $_POST['FILE']; $SUBMIT = $_POST['SUBMIT']; I have tried to mimic this script in a new upload script, but am unable to access those same attributes (_name and _size). At the time of my original upload script, we were running it on a Linux server (but I don't remember what we were running for a php version). Currently, I am running PHP 4.2.3 on Mac OS 10.2.8 server. One thought I had was that maybe PHP 4.2.3 no longer supports _name and _size. Or, maybe I am not handling the retrieval of the POST var for the file correctly? I wonder this because I did try print_r($_POST) and I only got the submit returned as a post var.
PHP File Access And Directory Security
I have a directory protected with .htaccess / .htpasswd. After I'm validated, I run a php script which bombs out when trying to write a file to that directory. If I chmod 777 on the directory (default was 755) then everything works ok. So apparently, the script is running under a different security context even though it's being run via my http session validated via .htaccess. 1) Do I have to be concerned about access to a protected directory via .htaccess but with wide-open file permissions? 2) If yes, are there any alternatives for my PHP routines if I want to maintain file-level permissions? 3) Is this normal behavior (i.e., how things are supposed to work with file-level access) for most ISPs?
Access An Array From A Text File?
Im trying to build an array from elements I have stored in a text file (So I can access them on multiple pages). What is the syntax for this? I thought it might be... storedArray1 = array(require_once("/arrays/stored_array_1.txt")); or storedArray1 = array(include("/arrays/stored_array_1.txt")); but I guess you can only use the 'include' statement when inserting text into html code NOT php code?
How Can I Restrict Access To Data File?
I have a php script that processes a form and then posts the user input to a data file on the server in a comma delimited format. For simplicity call the file "data.csv." The script is working well and the data is posted correctly to the data file. The big problem is that anyone can point their web browser to...
Access File Based On PayPal's IPN?
I have a website where I sell video clips. I want to know if it's possible to give a registered user access (or deny) to download a file (HTTP) based on his payment to PayPal.
Restricting PHP's File System Access
I am hosting a few virtual sites on my server. I have PHP installed and was wondering about a security risk. Anyone can create a php script to delete a folder in the main www directory. If I change the permissions on the folder, no one could see the website... Is there any way I can prevent someone from running such a script? Is there something in PHP that can allow me to control what domains can have access to this function?
URL File-access Is Disabled In The Server Configuration
I finally finished my website, and its been working fine for 2 weeks haven't touch one thing in the coding, but out of no where, this error pops up and i think its because my server provider changed something. Error:Code: Warning: getimagesize(): URL file-access is disabled in the server configuration in /home/xennetw/public_html/profile/avatar.php on line 52 Warning: getimagesize(http://xennetwork.com/profile/userImages.php?id=20): failed to open stream: no suitable wrapper could be found in /home/xennetw/public_html/profile/avatar.php on line 52 is there a work around for this?
Hiding MySQL Access Data In Php File ?
If I connect to a mySQL database with php I have to write the access data into the php file,eg.: $hostname = "my_host"; $username = "my_name"; $password = "my_pwd"; $dbName = "my_db"; $userstable = "my_table"; MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to database"); Is this secure ? In other words: can it be read by a bad boy ?
PHP Script To Access FTP Site And Download File
My goal is to connect to an FTP site and download all the files in it to a directory branching from what I beleive is my "home" directory (The "home" directory IS the one that opens right when you select "File Manager" and contains cgi-bin, public_http, bin, etc., right?) This directory is called /lsr. Anyway, can I put my PHP script in /lsr and then just run it by typing http://www.mydomain.com/lsr/myscript.php? Or are the only scripts that can be run those in the public http directory?
File Access Based On PayPal Info (IPN)?
I want to let a (registered) costumer download a file after paying through PayPal. Now PayPal have a system called IPN (Immediate Payment Notification), where your server gets notified whether the transaction was approved or not. Based on that notification I want the server to allow or deny access to the file.
Question Limiting Access To A Php File / HTTP_REFERER Validation.
I'm sure there is a simple solution to this but I've looked around and can't find a answer to fit my problem. I'm a php total newb so this may seem like a stupid question. I have a php file called out.php and what this does is simply count a click and then redirect the surfer to a defined URL based on a refrence number in my db. Example: out.php?number=(a number) Now my problem is I want to limit access to this to only my site so as to keep somone else from say using my out links on thier page by simple adding a link on thier site.
Restricting File Read Access To Users But Not Server
I`d like to know if it is possible to place a products.dat file on my website, yet restrict users so that they cannot see or d/l the file, but they can access it through a php file which is run by the web server which has the only access to the products file when browsing. Does this make sense?, its basically client server, but since my php knowledge isnt great yet, Im not sure if this is easy or not?
Warning: Fopen(): URL File-access Is Disabled In The Server
I ve been trying php script sent by rchaplin and all goes ok automatically appears a new file copied after script execution but it appears a messaje like next one: Warning: fopen(): URL file-access is disabled in the server configuration in /home/freehost/t35.com/n/a/nacion/p/new.php on line
Opendir With $_SERVER['HTTP_HOST'] Or $_SERVER['DOCUMENT_ROOT']
Is there a way to use opendir() using some sort of absolute path? I want a file to open the same directory on my site, no matter from what directory it is called. For example, I have the following variables, but no combination seems to work for me. Q: Does opendir() ONLY deal with relative paths? Q: If opendir() works with absolute path, am I missing something?PHP Code:
Sub Directories
What i would like to know is how with php can i create a subdirecty and copy some files into there?
Uploading Directories ?
Is there any way I can simply allow a user to upload an entire directory through php without selecting the files one by one ?
Create Directories On The Fly...
Just curious to know is it possible to create directories on the fly? What I have done is created a script when you can add categories and subcategories, but what I would like to do is create a directory physcially within that category. For instance using the mkdir command using linux. In a way traversing through and creating a directory. An example would be: If I created a category called business and econony then it would display this in the address bar. http://www.domain.com/Business_and_Economy Then perhaps under Business and Economy, a category called Accounting, then it would display the following: http://www.domain.com/Business_and_Economy/Accounting/ Hopefully I'm making some sense here. Heres the code: function maketree($rootcatid,$level) { $sql="select catid,cat_name from quiz_category where parentid=$rootcatid order by cat_name"; $result=mysql_query($sql); while (list($DBcatid,$DBcatname)=mysql_fetch_row($result)) { $width=($level+1)*24; $display="<img src=http://www.domain.com/spacer.gif border=0 width=$width height=12>"; if ($DBcatid==1) { $display.="<input type="radio" name="quest_type" value=$DBcatid checked>"; } else { $display.="<input type="radio" name="quest_type" value=$DBcatid>"; } $display.="$DBcatname<br> "; echo $display; maketree($DBcatid,$level+1); } } if ($submit=='Add New Category') { if ($new_cat!='') { mysql_query("insert into quiz_category (parentid,cat_name) values ($quest_type,'$new_cat')"); # need to create directory here echo "<br><br><center><b>New category entered</b></center>"; } else echo "<br><br><center><b>New category name must be entered</b></center>"; }
Fopen() With Directories
I am attempting to create directories using a form, a user submits the directory name and the directroy is created. I am attempting to use fopen to create it, but it doesn't seem to be working. Is there a way to use fopen()? Also, could opendir() be used instead? Code: <form action="create.php" method="post"> Site Address: <br> <input name="subdir" width="30" type="text"> <input type="submit" value="create"> </form> PHP Code:
Virtual Directories?
Virtual Directories? I've been working with ColdFusion for my real job and sticking with PHP for my side work and have a question. In CF, they have virtual directories you can set up that you can use the address of mydomain.com/admin and have it access files from another location on the same server thisdomain.com/clientadmin I was wondering if there is something similar to this in PHP. I run a reseller account on a server and can access databases from different domains, so I was hoping this could be possible. If anyone has any ideas, please let me know.
Traverse Directories
My problem is that I can't find a way of referencing files and includes statically. I have to change each page reference so that when it is referenced it references the correct document. As I want a central location to keep all my most used 'includes'. So if I change a scripts location I also have to change the script it's self to point to the correct documents. This is a problem when the directory structures hierarchy keeps changing. Also HTTP referencing is out as the scripts will not all be run on the same servers.
Converting ?PID=whatever To Directories?
I've got a product directory with a product detail page for all products. The way the product page is displayed in the address bar is productdetail.php?PID=# Would it be feasible for a newbie like me to do so that instead of putting in the question mark it's in directories similar to Amazon?
Different Timezones In Different Directories
I have a strange problem. Iset up php 5.1.6 on my Solaris10 box and after that i get errors on my webbpage: "Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We had to select 'UTC' because your platform doesn't provide functionality for the guessing algorithm" I searched a little and foun out by setting up date.timezone in php.ini it works. Bur then I have to recompile php for support of zlib, and after that, I get the error again. Now I found out the following: # pwd /usr/local # php -i |grep timezone Default timezone =Europe/Luxembourg date.timezone =Europe/Luxembourg =Europe/Luxembourg # # cd .. # pwd /usr # php -i |grep timezone Default timezone =UTC date.timezone =no value =no value How is it possible that, when I'm in /usr/local the settings are OK, and in all other location the settings are not. Here header output of phpinfo: PHP Version 5.1.6 System SunOS my-web 5.10 Generic_118844-19 i86pc Build Date Nov 5 2006 16:24:04 Configure Command './configure' '--prefix=/usr/local' '--with-mysql=/usr/local/mysql '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-zlib=/usr/local'
|