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?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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:
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.
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'
Copy In 2 Directories
I've got a simple question. Is it possible with the command "copy" upload a file via browser on two different directories? I use copy copy("$file", "/directory1/$superdat_name")
Sync Directories
I have a php script on a cron job running every half an hour that FTPs to a given server and downloads files, heres a list of everything it does: 1. Checks file names in the FTP directory with a database table 2. Downloads any new files and imports the file information into that table 3. Uploads all the information inside that file into a different database table 4. Deletes file on the local machine that was downloaded, as to not take up space Now, the FTP directory keeps a full 60 days worth of files which is about 8640 files, everything so far works perfectly, efficiently and doesn't need to be changed. However I want to add a function, in everything it does I want it to check if any of the files in the database have been deleted on the FTP server. As to have only the 60 days worth of file records in the table.
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)?
Trying To Get All Directories In A Site Into Array
Thanks for reading. I'm trying to get an array of all the directories in my website. So, it reads the first level, then goes through each first level to find the second, and so on. I'm hoping to get all the first level in one array, all the second level in another and so on. I'm working with this code which does fine for the first level, but can't seem to get it to work for multiple levels without hardcoding everything in: PHP Code:
Protecting Files And Directories With Php
I've got a situation where i have a directory called "example". In this area i have three files, an index page that has a form on it in to which user's can authenticate, a page displaying either success or failure and if success redirects to a downloadable file. I don't want this downloadable file to be had by a direct url access, user's should have to authenticate to get it. I want to use php4 for this and if possible since this is a lightweight requirement i don't want to implement a database solution.
Safe Mode / Directories
I created a directory with PHP mkdir (mode 0777). Then I try to move_ulpoaded_file() to move a file into this directory. I get an error: Warning: move_uploaded_file(): SAFE MODE Restriction in effect. The script whose uid is 1999 is not allowed to access /home/www/ww4592/html/fs/PHP/Dateien/Bereich_1/NEUER_ORDNER owned by uid 33 in /home/www/ww4592/html/fs/PHP/File.php on line 57 The webspace is at a webhost-company, not on my own server. I think I understand the restrictions of SAFE MODE, but I do not understand why a script has another uid than a directory created by the very same script! Is the error above the "normal" bevaviour if SAFE MODE is on? If it is: That is a drastic limitation. If I say to a client "I need webspace with PHP" and I get that SAFE MODE-stuff would it not be right to say that that is no fully working PHP-Webspace? I mean a webspace that does not allow a directory to be created and a file moved into it does not really support PHP -- it's a joke! Any opinions?
Copying Entire Directories
I need to copy all of the files from one directory to another. This has to happen on the fly. The files that are being copied are actually templates for another site that will be created. I have seen the example on php.net under the fopen section but it doesnt work.
Problems With Changing Directories
im trying to make a script that will check two files from inside a directory. The directory is located two folders above where the main script is located. I have tried to change the directory, and load the files into an array, but it doesnt seem to change the directory at all... i have found this out by displaying the directory after i "change it". PHP Code:
Making Directories AND Accessing Them
Does anyone know if it's possible AT ALL to do the following: - make a directory X - create a subdirectory Y in it. - and then put a file in X (or Y) and it should run with SAFE MODE on. After surfing some forum, my conclusion is that is is not possible with PHP. I hope that somebody can prove me wrong.
Creating Multiple Directories
I'm trying to simultaneously create two directories. From a form, the user will be prompt to name a directory and from there the PHP code will create the directory that the user named. When that direcotry is named I am trying to create another directory with the directory that was just created. Is this possible? Here is my code:
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 :) ).
Blogs And 'virtual Directories'
Throughout the past few years, I've been working on a personal blog that I've written using PHP. I recently noticed that a lot of blogs support the following URL syntax: /archives/2004/04/03/ /archives/2004/03/ /archives/2004/ and so on and so forth. The thing is, they obviously don't have an actual HTML or PHP page in that directory; I doubt even that those directories actually exist. My guess is that they are doing some sort of URL re-writing using .htaccess in combination with perhaps a single PHP page that takes in parameters as a GET query. It's just a guess, of course. The thing is: I really have no idea how they are doing this. So, how would I implement something like this on my site using Apache and PHP? What is the technical term for this style of 'URL re-writing' even called? I don't mind doing a little research on my own, but I can't seem to nail down exactly what keywords I need to search for in the first place!
Including Files In Other Directories
I have some code running on windows on my local machine that uses the jpgraph image library. I include the jpgraph libs using include ("C:Programmingphpjpgraph-1.14srcjpgraph.php"); I am trying to get this code to run on my web host's unix server, with no luck. I put the folder (jpgraph) containing all the jpgraph libs in the same directory as my php code. I have tried all of the following: include ("/jpgraph/jpgraph-1.14/src/jpgraph.php"); //(relative path) include ("jpgraph/jpgraph-1.14/src/jpgraph.php"); //(relative path without leading slash) include ("/usr/www/users/mysite/jpgraph/jpgraph-1.14/src/jpgraph.php"); //(absolute path) include("http://www.mysite.com/jpgraph/jpgraph1.14/src/jpgraph.php"); //(url) include ("http://" . $_SERVER['HTTP_HOST'] . "/" . dirname($_SERVER['PHP_SELF']) . "/" . "jpgraph/jpgraph-1.14/src/jpgraph.php"); None of these have worked. Does anyone know the proper technique to include files in other directories when using Unix or Linux? Keeping all php files in the same directory is not feasible.
Sorting List Of Directories
If I have a list of directories in the format of month year date, like Jan0213, Dec0215 and so on, then I how do I sort them.
New Directories Have Incorrect Permissions
I'm building an FTP site. I am manually creating my root folder via an FTP programme and setting the permissions to 777 (which I believe is required). When I check who the owner of this folder is, its 32414 (As far as I'm aware, I don't need to take any notice of what this means). I have a form on the site which people can fill out to create new directories, which will result in the following code being run: if ($result_folder = mkdir($path.$id, 0777)) { # if the new folder was created, do this: $file = 'index.php'; $file_copy = $path.$id.'/index.php'; copy($file, $file_copy); echo '<p>Thank you '.$creater.', the folder ''.$name.'' has been created.</p>'; echo '<p>Would you like to <a href="add_a_folder.php">add another folder</a>?</p>'; } When this is done, I notice that the actual permissions of the new subdirectory are not 777, but instead are 755, the owner is 99. This means that I can't manually delete the folder via my ftp programme and my domain will become untidy and crowded. Do you know how to get the correct permissions to be setup, and if I need to specify who the owner is?
Reading Directories, Populating Select Box
Can anybody tell me how to read through a directory, get the file names and populate a select box(pulldown menu) with these names? I know how to loop through a directory using something like this: while ($files = readdir($handle)) { $ext=substr($file,-4); if ($files != "." && $files != ".." && $ext == ".php") { do some wild and crazy stuff here; } } It's the populating the select box (pulldown menu) while doing this that I need the help on.
How To Read Files From Directoiries/sub Directories
I am new to PHP and doing a project. I want to read all files from all directories/sub directories starting from the root of the web site. ie. I want to get the root directory programmatically. I am using linux. The purpose of the file reading is to do an internal searching. Could u give me a sample code.
Project, Files And Directories Organisation
I am searching a kind of software engineering document about PHP. This document should give advices about PHP project organisation (structure of files, directories, names). Shall I organize hierachically and how (a main directory, a directory for php files, for html files ...)? How to use "base" request in HTML under PHP and that sort of things.
Pass Word Protected Directories
I don't know if this question should be ask here or directed at my website server. Part of my web site is behind a user name, pass word protected directory made with the hosts routine. EV-one in this case. When I enter my name password to enter the directory and then leave to go to other parts of the website, I do not have to enter my name password when I come back. When I go to other websites and come back to this protected directory, I do not have to enter my name password. The only time I have to enter my name, pass word is after I have closed the browser. Is this normal. Is there code I can add to close that particular path? Is this a cookie issue and can I control that cookie? I do remember when I set this up it ask 'ssl' or 'non-ssl' and both were checked. I unchecked one and don't remember which and have not gone to look since I started this message.
Open Directories Read Into Array
how to open directories that are array elements and extract an html file out of each?? The script below opens a certain directory, variables passed from another script, checks if this (day) directory exists and reads its content, which are subdirectories, into an array. My problem is that I don't know how to access the files within those subdirectories. The subdirectories contain images and html page and I would like to extract the html page. I certainly need ereg to match the html file, but I cannot access the files within the subdirectories. The result should be a link subdirectory/html page. Code:
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?
Creating Directories From MySQL Query
I'm trying to create a subdirectory within a directory. The directory uses $rows['link'] from the category table, and the subdirectory uses $subcategory2 from the subcategory table. The directory that gets created is always based on the last record in the table, rather than the parent. I have tried using another query, but only the subdirectory gets created then......
Setting Cookies For Multiple Directories
I'm having a little trouble getting 'sitewide' cookies to work. Code: setcookie ("facilityidcookie",$facilityid,time()+14400,"/"); This is supposed to set a cookie from the root level and have the cookie available for all directories below root. For some reason it does not work as intended. The cookie works great for root level docs, but all sub directories do not see the cookie.
Private And Public Document Directories
I will be building an application using PHP & MySQL where recognised users (controlled using PHP4 sessions) are able to upload documents to the web server through a form. Users will be able to indicate whether the document they are uploading is for private (ie. intranet) or public availability. Obviously making a document public is the easy part. What I trying to decide right now is the best way 'protect' documents that have been marked as 'private' from public view/access. I could use .htaccess/.htpasswd as a simple restriction over the entire intranet directory, and have the private documents copied into this directory of a sub-directory. BUT since I've got mutliple users who want to be able to login with their own usernames and passwords (AND be able to change their own passwords as one of their member functions), then this solution is not sufficient - UNLESS I am able to manage the .htpasswd file at the same time as a registered user manages their password/profile on the MySQL database... So using PHP4 sessions I can quite happily control who gets to view the Intranet/private web pages (which will have links to the URLs of the private documents), but this won't protect access to the private documents if someone who is not logged in simply enters the correct URL for one of these documents. The apache module mod_auth_mysql would do the job nicely, but my hosting service will not install it for me.
Recursive Walk Trough Directories
I've a directory structure where I store images. 0-999: images/0/ then images/0/0/ then images/0/0/0-1.jpg images/0/0/0-2.jpg images/0/0/0-3.jpg 1000-1999: images/1/ then images/1/0/ then images/1/0/1000-1.jpg images/1/0/1000-2.jpg images/1/0/1000-3.jpg I've quite 1500 levels like this I must list all X-1.jpg in the three.
Multiple Uploads To Differect Directories
I've been pulling my hair out on this. Every time I think I have the solution and don't - just adds to the frustration. Here's what I'm trying to do... I have a number of files that need to be uploaded to different directories. Example : filetype1 >>> dir1 filetype2 >>> dir2 filetype3 >>> dir3 I need to do this from a single form plus capture the paths to the files and store them in a database along with some other data. I have tried a variety of things and think that my frustration is causing a serious mental block.
Mkdir Seems To Create Invisible Directories....
I've got my script which checks if a directory exists, if not creates it. It seems to be working fine. I create the directory and upload a file to it and can then view the file on the server through my browser. Now the problem starts when I look at it with any ftp client. For some reason I can't see the created directories or files. In my directory I should have something such as: root/images/products/clothing/tops/myfile.gif But I can only view up to products (which looks empty). Products is a directory created at the same time as the invisible directories/files, so it's confusing me... anyway, here's my code:
Correct Permissions For Directories On FTP Site?
I am making an FTP site for users to add files and folders to. Does anyone know what the correct permissions should be so that people logged in to the site can do this? I know that 0777 allows this, but I didn't know if this left the folders/files open to people outside the site?
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?
List Files In Directory Excluding Directories
I have the following code which I require to get the list of files in a given directory. However in that given directory I have other directories as well. I thought the second if condition was taking care of excluding the directories, but its not. I get a bunch of directories listed along with the files. PHP Code:
Include Chain Spanning Multiple Directories...
I've written a custom HTML library using many PHP scripts as seperate files (just like I'd do a java project) and I'm having some problems where I'm including scripts in different directories from already included scripts... basically where there'a an include chain spanning multiple directories. I've reduced the problem to its core: Imagine you have a website consisting of 4 PHP files: /top_site.php /inlcudes/top_lib.php /includes/lib/lib1/lib1.php /includes/lib/lib2/lib2.php the contents of which are: top_site.php = <? include_once("includes/top_lib.php"); ?> top_lib.php = <? include_once("lib/lib1/lib1.php"); ?> lib1.php = <? include_once("../lib2/lib2.php"); ?> lib2.php = <? echo "Hello World!"; ?> now when I go to http://YOUR_WEBSITE_ROOT/top_site.php I get an error saying that the include within lib1.php can't find lib2.php... ....BUT if I go directly to http://YOUR_WEBSITE_ROOT/includes/lib1/lib1.php then you'll see that it includes lib2.php fine!!! Try it for yourself; it won't take a minute to set up. I've checked my include path and it looks fine (having '.' in it), so I'm basically stuck there. Oh, and I'm running PHP version 4.2.2 on Linux RH9/Apache 2. Has anyone else seen this before? Have any ideas? Cos I don't really want to have to convert everything over to absolute (not sure if this'll work either) and I've written LOTS of code! D'OH!
PHP Http Authentication - Cannot Secure Entire Directories?
I've been trying out HTTP authentication with PHP (yes I've read the Zend tutorial, searched the forum, and read the manual). Things seem to work great. However I have noticed that is does not work like a .htaccess file would. Only the PHP script which sends the headers will check for anything. No very useful for blocking out a whole directory tree. I wanted to move away from just using a .htaccess so that I could authenticate the passwords over a MySQL database. The current setup has an index.php in the directory that is to be protected. It checks for password, then initializes a session and forwards the user to the protected section. Each script in the protected section checks if valid session exists, and if not, forwards back to the main index.php to HTTP authenticate again. This seems to work fine except I'm afraid of one day forgetting to check for the session or people accessing non PHP files that are in the protected directory. My question is, is there a way to combine PHP based http authentication with a .htaccess file? Or somehow have an entire directory be authenticated through one script. And the other concern is that if I do have the entire directory protected and go through that one PHP script somehow, wouldn't it have to check the l/p with MySQL every time they accessed any file?
Fasttemplate Files Stored In Multiple Directories
If I declare in the script $tpl = new FastTemplate("/tmpl"); then I can use only template files in tmpl directory. What if I want to use template files in another directory in the same script? such as header.tpl and footer.tpl that are in another directory?
|