Re: [PHP] getting filenames from dir
And does one manage recursive sub directories for the same thing ? On Apr 1, 2005 3:38 AM, Stanislav Kuhn [EMAIL PROTECTED] wrote: HI... Do you read php manual sometimes? ;o) just replace echo $file\n; by $my_file_array[]=$file; readdir (PHP 3, PHP 4 , PHP 5) readdir -- read entry from directory handle Description string readdir ( resource dir_handle) Returns the filename of the next file from the directory. The filenames are returned in the order in which they are stored by the filesystem. Please note the fashion in which readdir()'s return value is checked in the examples below. We are explicitly testing whether the return value is identical to (equal to and of the same type as--see Comparison Operators for more information) FALSE since otherwise, any directory entry whose name evaluates to FALSE will stop the loop (e.g. a directory named 0). Example 1. List all files in a directory ?php // Note that !== did not exist until 4.0.0-RC2 if ($handle = opendir('/path/to/files')) { echo Directory handle: $handle\n; echo Files:\n; /* This is the correct way to loop over the directory. */ while (false !== ($file = readdir($handle))) { echo $file\n; } /* This is the WRONG way to loop over the directory. */ while ($file = readdir($handle)) { echo $file\n; } closedir($handle); } ? Note that readdir() will return the . and .. entries. If you don't want these, simply strip them out: Example 2. List all files in the current directory and strip out . and .. ?php if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != . $file != ..) { echo $file\n; } } closedir($handle); } ? -Original Message- From: Merlin [mailto:[EMAIL PROTECTED] Sent: 01 April 2005 12:32 To: php-general@lists.php.net Subject: [PHP] getting filenames from dir Hi there, does anybody know how to get all file names from a specified directory into an array? Thanx, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Auto logout
Hi I wanted to implement an auto-logout feature for my project so that if a terminal is left unattended for say 10 minutes, it should automatically logoff the user. Apart from this, there is another problem that I am encountering with my authentication scheme, the scene is as follows : (1) I am using a $_SESSION variable to transfer the username across pages, what happens is that I cannot login more than one user from the same machine since if i try the same the SESSION[username] variable's value gets changed to the most latest login name. How do i get around this ? (2) Secondly, What happens is, when the user logs off from the system, there are two things that happen at that time, first is that the session variable is killed manually. The second is that the logged in status of the user is updated in the database. So what happens is that when the user is logged on the system, the database shows the user logged in status as 1 otw it shows it as 0. Now the problem is that if by chance the user closes the current browser window without actually logging off, the session variable gets killed automatically but the database is not updated accordingly. Please suggest some way around this also. I would be really happy if you guys can help me with this. Thanks in advance Vaibhav -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] FTP functions
Hi I checked ou the ftp functions of PHP, what I wanted to ask was that if I connect to a remote server and issue and ftp_fget() command the file will be downloaded to the server running the PHP code and Apache webserver or the client machine from which we are calling it ? In the sense for example I have a client machine running on windows XP, I launch the mozilla firefox browser in that and call for the ftp_code.php on my server (http://server). The ftp_code.php contains a code which connects to a remote ftp server and then using the ftp_fget() function downloads a file from the remote server. Now where will this file be downloaded ? Though I have an inkling that since PHP is a server side scripting language, the file will be downloaded to the server only... But i still wanted to confirm Please confirm Thanks in advance Vaibhav Sibal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] A general question
How can I click on a link which is linked to a JPG file and instead of displaying it in the browser save it somewhere on the local machine or open in a different software ? Please help very urgent Thanks vaibhav -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Opening files....
Hello, I want to open files in a directory other than the Document root via HTTP on the client machine. How do i do it ? For example I have .JPG files in a directory /toallocate on my Server running FC2, Apache2, Mysql, PHP5. I allocated certain .JPG files to some users and moved them to a directory called /allocated and logged the absolute path in a Mysql Table with the user name. Now we know the username and the files allocated to him and their path. When the user logs into his account, he should see the file allocated to him and they should be clickable links so that when he clicks them they open in the required software. I tried just providing links to their absolute path but then it doesnt work because Apache looks for them relative to the Document Root. Please some one help me in this concern, I will wait for a quick reply. Also, Is there a way that I can force the .JPG files to open in a particular software ? thanks in advance Vaibhav Sibal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] loggin into linux account
Hi, The scenario is, I made a login interface wherein i accept usernames and passwords from users and after comparing them to a database I log them in. The server runs Linux Fedora Core 2. Now I want to know whether there can be a scenario wherein I can make the logged in user have access to files of which he/she is the owner of or the file belongs to a group whose membership he/she has. Is this possible ? because as far as my knowledge goes, its only possible to give access to users to specific files if the user logs in to a particular shell. Please provide some help on this if you can. Thanks in advance ! Thanks Vaibhav -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how to move files from one place to another ?
Hello, Can some please guide me as to how should I move files from one directory to another on the server itself using PHP ? I use PHP 5.0.3 and Apache2 and Mysql. Thanks Vaibhav -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Not able to add data to a MySQL database
Hi, I am not able to insert data into my mysql database using php even if i use a simple code as follows : ?php $link=mysql_connect(localhost,username,password); mysql_select_db(test_db); $query=INSERT INTO 'login' ('uname','access') VALUES ('try','super'); mysql_query($query,$link); ? even after running this code on the server, there was no change in the mysql database as seen by the phpmyadmin. Ive tried it with another file and another table, but its not just happening. Though earlier attempts with Mysql had worked, but those only involved reading data from the database and I havent been able to write to it even once since I have started working. Please help me out with this, in case there is some information that I should have provided here and its not there please ask for it, I will be more than happy to provide it. Thanks Vaibhav -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how to select files from a directory and transfer to a different dir ?
Hello, I need to select around 200 files at random out of a file pool of 10k-15k files from a directory and then transfer them to another directory on my linux server which runs Apache 2.0.52, PHP 5.0.3 and Mysql. I will also be requiring to add the paths of all those files into a database. If someone can please suggest the way to do it, I will be really grateful. I dont know how to select 200 files at random and then transferring the files to another directory and then adding those files to a database. thanks Vaibhav -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is there a way I can read full path names of files on the server and enter it into the database ?
Hello, I wanted to ask whether there is a way whereby a script can read filenames from a particular directory on the server and enter those filenames with the complete path into the MySQL database? I am trying to do this, because I am developing an application where a supervisor will be distributing files to different users, and those users are to work on the files allocated to them by the supervisor. There is a big pool of files containing around 10k-15k files and the supervisor will be instructed to allocate around 200 files to a user each day, and the user should be able to open that file and work on it. I am using a Linux Fedora core 2 server running Apache 2.0.53 and PHP 5.0.3 and MySQL, and my clients are Windows clients. So I wanted to ask all of you people what would be a better approach to do this, the following are the 2 options : (1)As soon as the supervisor selects say around 200 files for a user called robert, 200 files from the file pool automatically get copied to the home directory of robert. While they are copied to the home directory of Robert, the name of each file with their complete path name gets logged onto the database. Now I am doing since because I need to know where each file went and what user is working on what file. Now since robert is working on a client running on windows, we can map a drive of windows onto the home directory of robert. In this scenario can we instruct PHP to open files from a local directory (i.e. the mapped directory of windows)? Because I need to, somehow, log when a user opened the file and when he closed it. (2) The second scenario is that, I just enter the name of the files allocated to a user alongwith the complete pathnames to a database and I have another column this time where I store the user's name. Now whenever the user logs into our system using his username and password, and checks to see his work, he sees a list of files on the browser itself, but now we will have to convert this list of files into links so that the user can click on the links and directly open the file in the required software from the server itself. The issue, again, in this kind of design is that how do i open the file in the required software and even if i do it then how do i record when the user opened the file and when he finished working on it. I would request all of you to please help me in this, since I am a student and in the learning phase and this is a part of my project. If you have any doubts about whatever I have written here please write to me. I would be really grateful if you all could help me in this endeavour. Thanks in advance Vaibhav -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to open a URL directly ?
Hey ppl, I have a scenario wherein the people logging into the system have different kinds of status as in a person can either be a admin, a user, or a supervisor etc. Now I have different web interfaces for all these kind of people. What I want to know is what function do i use to go to a URL directly in a case where status of the person is something like admin or user etc. For ex. if a person Robert is the admin and his name and password correctly matches from the database and the status of Robert as stored in the database is admin then as soon as he pressed the login button he should automatically be forwarded to a page, eg. admin.php, where he can access his stuff. Please tell me what function should I use ? Thanks Vaibhav -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php