Re: [PHP] Newbie question: need to transfer directory contents fr om my local machine to my website
ghood stuff Jon Westcot wrote: Jochem: My most sincere apologies for not replying to your questions. I've been suffering with a rather dibilitating head cold the last few days and somehow glossed over your questions. 1. what is the local machine? Just my local workstation. 2. where does the DB live? (is it a different machine?) Yes, the database -- in MySQL -- lives on a different server. 3. do you need reporting/information about the local machine inspection anywhere other than the local machine? No, I only need it locally. At least, for right now. 4. will there be more than one local machine? No. The only place the data will originate FROM will be my local machine. The data are simply directory entries of PDF or CHM files. 5. why do you want to do this? For starters, I'm trying to cull out duplicates. Some are easily found by comparing file sizes and then looking at the file names. But, some of the files are damaged, so I need to actually open the files to ensure they open without error before deciding which ones to delete. It seemed to me that it would be easier to open the files from a web browser than from another, scratch-built application. not sure I understand how a browser based app will be easier to use than say WindowsExplorer. I would suggest you try to figure out a way to let php (in this case) work out if a file is corrupt automatically (files it thinks are corrupt could be dumped into a special folder) The larger question though, is, "Why use PHP for this?" Because I'm trying to learn more about how to use PHP, and because, once the data have been combed through and duplicates have been culled, I'd like to make the data available to a few friends who would like to see the list of files that I've amassed (currently around 12,600, with approximately 3000 known duplicates). Those able to view the data would not be able to update the data at all -- the form to do the update would have been password protected. What I think I'll do now is create the update routines locally, then export the data, upload the data to the server, and import it into a copy of the database. Yeah, it means more work on my part, but that's okay. The updates after I finally get the initial data clean will be somewhat infrequent. like I said before its quite easy to run you php routines locally, gathering information and have that code make a DB connection to a remote server - you should do a little reading on MySQL security though. With regard to people requesting files - the remote database could keep a list of requested files (and a relevant email addr) and your 'local' routines could query the relevant data and either mail out requested files directly OR package the requested files and upload them to the remote server (which then takes care of mailing them out) anyway good look in your project Thanks again for your input and suggestions. Sincerely, Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question: need to transfer directory contents fr om my local machine to my website
Jochem: My most sincere apologies for not replying to your questions. I've been suffering with a rather dibilitating head cold the last few days and somehow glossed over your questions. > 1. what is the local machine? Just my local workstation. > 2. where does the DB live? (is it a different machine?) Yes, the database -- in MySQL -- lives on a different server. > 3. do you need reporting/information about the local machine > inspection anywhere other than the local machine? No, I only need it locally. At least, for right now. > 4. will there be more than one local machine? No. The only place the data will originate FROM will be my local machine. The data are simply directory entries of PDF or CHM files. > 5. why do you want to do this? For starters, I'm trying to cull out duplicates. Some are easily found by comparing file sizes and then looking at the file names. But, some of the files are damaged, so I need to actually open the files to ensure they open without error before deciding which ones to delete. It seemed to me that it would be easier to open the files from a web browser than from another, scratch-built application. The larger question though, is, "Why use PHP for this?" Because I'm trying to learn more about how to use PHP, and because, once the data have been combed through and duplicates have been culled, I'd like to make the data available to a few friends who would like to see the list of files that I've amassed (currently around 12,600, with approximately 3000 known duplicates). Those able to view the data would not be able to update the data at all -- the form to do the update would have been password protected. What I think I'll do now is create the update routines locally, then export the data, upload the data to the server, and import it into a copy of the database. Yeah, it means more work on my part, but that's okay. The updates after I finally get the initial data clean will be somewhat infrequent. Thanks again for your input and suggestions. Sincerely, Jon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question: need to transfer directory contents fr om my local machine to my website
Jim Moseby wrote: ... Perhaps I misunderstand what the OP wanted. I thought he was running a webserver somewhere, and that he wanted his remote webserver to be able to grab a file listing on his local machine by just visiting a webpage there. if you ask me it wasn't very clear what the OP wanted, I was concerned that the reference to php being a 'server-side' tool/language would be confusing to the OP (or give him the wrong impression about php's capabilities). to the OP: php being serverside is only relevant in terms of using php as a webserver module; the 'client side' is the browser and php does not run inside the browser (i.e. a php website can not directly interact with anything on your own PC (unless the website lives physically on your own pc)) [actually Wez Furlong wrong a plugin for IE IIRC that allows you to use php in the same way as you might use javascript inside the browser] Of course PHP can query the local filesystem. I thought he wanted it to query a remote filesystem. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Newbie question: need to transfer directory contents fr om my local machine to my website
> > > > You will not be able to do what you propose with a purely > PHP solution. PHP > > is a server-side technology. That means all the processing > is done at the > > server, then output to your browser. PHP, to my knowledge, > has no way to > > inspect your computer's folders. You would need to look to > a client-side > > er??? stick the following in a file (localfiles.php): > > > function readDirWin($dir) { > $d = dir($dir); > while (false !== ($entry = $d->read())) { > if($entry!="." && $entry!="..") { > echo ($entry = $dir."\\".$entry), "\n"; > if(is_dir($entry)) { > readDirWin($entry); > } > } > } > $d->close(); > } > var_dump( readDirWin("C:") ); > > ?> > > and call it like so: > C:\path\to\your\CLI\php.exe C:\path\to\your\localfiles.php Perhaps I misunderstand what the OP wanted. I thought he was running a webserver somewhere, and that he wanted his remote webserver to be able to grab a file listing on his local machine by just visiting a webpage there. Of course PHP can query the local filesystem. I thought he wanted it to query a remote filesystem. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie question: need to transfer directory contents fr om my local machine to my website
Jim Moseby wrote: Hi Jon, welcome. I'm really new at PHP and will probably embarrass myself many times over asking questions that have been asked gazillions of times before, so let this serve as a blanket apology. You will get a cold response from the regulars on this list if you "ask questions that have been asked gazillions of times before". Friendly advice: always take a little time to search the archives of this list and google a bit to see if your question has already been answered. Can you imagine what this list would be like if every newbie asked the same questions every day? That said, on to your questions. amen. I'm not really asking for anyone to write the code for me, but I am looking for suggestions for PHP functions to use to accomplish the inspection of my local computer's folders. I'd also need to know what additional information I'd need to store in the database so that subsequent updates can be automated (i.e., do I need to somehow store my IP address?). You will not be able to do what you propose with a purely PHP solution. PHP is a server-side technology. That means all the processing is done at the server, then output to your browser. PHP, to my knowledge, has no way to inspect your computer's folders. You would need to look to a client-side er??? stick the following in a file (localfiles.php): read())) { if($entry!="." && $entry!="..") { echo ($entry = $dir."\\".$entry), "\n"; if(is_dir($entry)) { readDirWin($entry); } } } $d->close(); } var_dump( readDirWin("C:") ); ?> and call it like so: C:\path\to\your\CLI\php.exe C:\path\to\your\localfiles.php technology, like Java, for that. STOP RIGHT THERE - php might have been designed for spitting out webpages and the like but these days you can run it as a general purpose scripting language in all sorts of situations - including running a CLI version on your windows desktop machine. go here and install - not only will you have a CLI version of php to play with - it will try to setup a webserver SAPI for whatever webserver you have installed locally (within reason - personally i only use Apache) you can have a php script inspect your local machine by running locally and stick its results in a database that lives on a machine on the otherside of the world. QUESTIONS: 1. what is the local machine? 2. where does the DB live? (is it a different machine?) 3. do you need reporting/information about the local machine inspection anywhere other than the local machine? 4. will there be more than one local machine? 5. why do you want to do this? However, you can upload data to your website using PHP to process the uploaded file. So, at your convienience, you can have a "Browse" button on an update page that will allow you to browse and find your data to upload. After the upload you can have PHP process the uploaded file any way you wish. You can also use cron to kick off scheduled tasks with PHP CLI scripts that will, for instance, open an FTP connection to your machine and download data files to the server for processing. windows also has a task scheduler ... how good it is I don't really know Also I would suggest that it would be better for the local machine to push data to a server than for the server to pull data from the local machine. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Newbie question: need to transfer directory contents fr om my local machine to my website
Hi Jon, welcome. > I'm really new at PHP and will probably embarrass myself > many times over asking questions that have been asked > gazillions of times before, so let this serve as a blanket apology. You will get a cold response from the regulars on this list if you "ask questions that have been asked gazillions of times before". Friendly advice: always take a little time to search the archives of this list and google a bit to see if your question has already been answered. Can you imagine what this list would be like if every newbie asked the same questions every day? That said, on to your questions. > I'm not really asking for anyone to write the code for > me, but I am looking for suggestions for PHP functions to use > to accomplish the inspection of my local computer's folders. > I'd also need to know what additional information I'd need to > store in the database so that subsequent updates can be > automated (i.e., do I need to somehow store my IP address?). You will not be able to do what you propose with a purely PHP solution. PHP is a server-side technology. That means all the processing is done at the server, then output to your browser. PHP, to my knowledge, has no way to inspect your computer's folders. You would need to look to a client-side technology, like Java, for that. However, you can upload data to your website using PHP to process the uploaded file. So, at your convienience, you can have a "Browse" button on an update page that will allow you to browse and find your data to upload. After the upload you can have PHP process the uploaded file any way you wish. You can also use cron to kick off scheduled tasks with PHP CLI scripts that will, for instance, open an FTP connection to your machine and download data files to the server for processing. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php