php-general Digest 4 Jan 2006 18:20:07 -0000 Issue 3887
Topics (messages 228139 through 228157):
Newbie question: need to transfer directory contents from my local machine to
my website
228139 by: Jon Westcot
228150 by: Jim Moseby
228151 by: Miles Thompson
228152 by: Jason Pappin
Comparing of string
228140 by: janbro
228141 by: Jon Westcot
228142 by: janbro
228143 by: Jeremy Privett
228144 by: janbro
228145 by: janbro
228146 by: janbro
228147 by: Jeremy Privett
228148 by: Raz
Re: fread problem
228149 by: Haydar Ciftci
Graphically displayed number to confirm user is a human
228153 by: Dave M G
228154 by: David Grant
228155 by: Jim Moseby
228156 by: Duncan Hill
228157 by: John Meyer
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Hi all:
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.
Now, to my question. Here's what I'm trying to do. I have a simple
database on my website that I wish to populate with information from various
directories on my local computer. The website is running Linux; my computer is
running Windows XP. Once the data are stored, I want to be able to update the
information as things change on my local computer (not in real time, mind you,
but at my request).
I can set up the database access easily enough, and I know how to both
populate and query it. What I don't know is how to obtain the information from
my local computer via the website. Initially, I'd like to be able to specify
the folder on my local computer to access and whether or not to process any
subfolders that are found. After the data have been added, I'd like the web
application to be able to access the individual folders without having to
specify them again (although I'd still be able to identify new folders to
include in subsequent updates).
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?).
Any help you can send my way will be greatly appreciated! Thanks in
advance.
Sincerely,
Jon
--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
At 02:18 AM 1/4/2006, Jon Westcot wrote:
Hi all:
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.
Now, to my question. Here's what I'm trying to do. I have a simple
database on my website that I wish to populate with information from
various directories on my local computer. The website is running Linux;
my computer is running Windows XP. Once the data are stored, I want to
be able to update the information as things change on my local computer
(not in real time, mind you, but at my request).
I can set up the database access easily enough, and I know how to
both populate and query it. What I don't know is how to obtain the
information from my local computer via the website. Initially, I'd like
to be able to specify the folder on my local computer to access and
whether or not to process any subfolders that are found. After the data
have been added, I'd like the web application to be able to access the
individual folders without having to specify them again (although I'd
still be able to identify new folders to include in subsequent updates).
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?).
Any help you can send my way will be greatly appreciated! Thanks in
advance.
Sincerely,
Jon
Jon,
I don't know how to do this, but it's a bad idea. Can it be done? Probably,
but it is still a bad idea.
Why do you want to:
Expose the contents of your machine to the world?
Make your machine vulnerable to attack via your web application?
Enable a path into the file system on your computer?
I would suggest approaching it the other way - if it's something the world
should see, upload it to the web server. PHP has lots of tools for reading
and traversing directories.
If the uploading task becomes onerous, write a script to run on your local
machine, using whatever language you are comfortable with, to upload all of
the desired content to the web server.
Read some articles on cross site scripting to discover why your original
approach is not a good idea. Here's one:
http://www.cgisecurity.com/articles/xss-faq.shtml
and see the links at the end.
Regards - Miles Thompson
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.371 / Virus Database: 267.14.12/220 - Release Date: 1/3/2006
--- End Message ---
--- Begin Message ---
Hi,
You should perhaps look at setting up a web server on your computer. PHP
as stated works server-side and if those folders/files you wish to
transfer reside in the web root, then PHP can process those files.
Perhaps look at how a web based FTP client written in PHP works for how
to copy/move/delete files in PHP. If you can't set up Apache with PHP on
Windows, try something like phpdev5 for a click and use solution.
As for your IP, it won't really matter unless you want the server to
send data back to your computer. If a static IP or hostname is in order,
then they are easy enough to set up even if you are on a dial up
connection.
Regards
Jason
Jon Westcot wrote:
> Hi all:
>
> 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.
>
> Now, to my question. Here's what I'm trying to do. I have a simple
> database on my website that I wish to populate with information from
> various directories on my local computer. The website is running
> Linux; my computer is running Windows XP. Once the data are stored,
> I want to be able to update the information as things change on my
> local computer (not in real time, mind you, but at my request).
>
> I can set up the database access easily enough, and I know how to
> both populate and query it. What I don't know is how to obtain the
> information from my local computer via the website. Initially, I'd
> like to be able to specify the folder on my local computer to access
> and whether or not to process any subfolders that are found. After
> the data have been added, I'd like the web application to be able to
> access the individual folders without having to specify them again
> (although I'd still be able to identify new folders to include in
> subsequent updates).
>
> 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?).
>
> Any help you can send my way will be greatly appreciated! Thanks in
> advance.
>
> Sincerely,
>
> Jon
>
--- End Message ---
--- Begin Message ---
Hello List
I've got the following little code:
$formCheck= $_GET['formCheck'];
$SollKombination = $_SESSION['zufall'];
echo "$SollKombination<br>$formCheck";
print gettype($formCheck);
echo "---";
print gettype($SollKombination);
if ($SollKombination == $formCheck){
echo "test";
}
To give you some background: This code is supposed to check if a user has tried
to login via my form.
Which gives me the following output:
ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
string---string
Everything the way it's supposed to be....
What I don't get is, why isn't the if statement true? Shouldn't it show test as
well? Where is my mistake?
I run PHP 5.1.1 on Windows. On my Win PHP 5.0 this code works proper, but not
here ?!?
thx JanBro
--- End Message ---
--- Begin Message ---
Hi JanBro:
Quick guess: are the strings the same length? I've been bitten many
times by string comparisons that appear to be identical but which fail due
to trailing spaces, other "invisible" (i.e., non-printing) characters, and
the like.
Hope this helps.
Jon
----- Original Message -----
From: "janbro" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, January 03, 2006 11:22 PM
Subject: [PHP] Comparing of string
> Hello List
>
> I've got the following little code:
>
> $formCheck= $_GET['formCheck'];
> $SollKombination = $_SESSION['zufall'];
>
> echo "$SollKombination<br>$formCheck";
> print gettype($formCheck);
> echo "---";
> print gettype($SollKombination);
>
>
> if ($SollKombination == $formCheck){
> echo "test";
> }
>
> To give you some background: This code is supposed to check if a user has
tried to login via my form.
>
> Which gives me the following output:
>
> ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
> ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
> string---string
>
> Everything the way it's supposed to be....
>
> What I don't get is, why isn't the if statement true? Shouldn't it show
test as well? Where is my mistake?
> I run PHP 5.1.1 on Windows. On my Win PHP 5.0 this code works proper, but
not here ?!?
>
> thx JanBro
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Yep, they are of the same length.
here they are:
$SollKombination
ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
$formCheck
ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
When creating the string on the form page only visible characters were allowed.
thanks but that's not it.
Jon Westcot schrieb:
> Hi JanBro:
>
> Quick guess: are the strings the same length? I've been bitten many
> times by string comparisons that appear to be identical but which fail due
> to trailing spaces, other "invisible" (i.e., non-printing) characters, and
> the like.
>
> Hope this helps.
>
> Jon
>
>
> ----- Original Message -----
> From: "janbro" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Tuesday, January 03, 2006 11:22 PM
> Subject: [PHP] Comparing of string
>
>
>> Hello List
>>
>> I've got the following little code:
>>
>> $formCheck= $_GET['formCheck'];
>> $SollKombination = $_SESSION['zufall'];
>>
>> echo "$SollKombination<br>$formCheck";
>> print gettype($formCheck);
>> echo "---";
>> print gettype($SollKombination);
>>
>>
>> if ($SollKombination == $formCheck){
>> echo "test";
>> }
>>
>> To give you some background: This code is supposed to check if a user has
> tried to login via my form.
>> Which gives me the following output:
>>
>> ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
>> ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
>> string---string
>>
>> Everything the way it's supposed to be....
>>
>> What I don't get is, why isn't the if statement true? Shouldn't it show
> test as well? Where is my mistake?
>> I run PHP 5.1.1 on Windows. On my Win PHP 5.0 this code works proper, but
> not here ?!?
>> thx JanBro
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
--- End Message ---
--- Begin Message ---
janbro wrote:
Hello List
I've got the following little code:
$formCheck= $_GET['formCheck'];
$SollKombination = $_SESSION['zufall'];
echo "$SollKombination<br>$formCheck";
print gettype($formCheck);
echo "---";
print gettype($SollKombination);
if ($SollKombination == $formCheck){
echo "test";
}
To give you some background: This code is supposed to check if a user has tried
to login via my form.
Which gives me the following output:
ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
string---string
Everything the way it's supposed to be....
What I don't get is, why isn't the if statement true? Shouldn't it show test as
well? Where is my mistake?
I run PHP 5.1.1 on Windows. On my Win PHP 5.0 this code works proper, but not
here ?!?
thx JanBro
Hey JanBro,
Try replacing the if statement you have with this:
if ( strcmp( trim($SollKombination), trim($formCheck) ) ) {
echo "test";
}
---
Jeremy Privett [ http://www.jeremyprivett.com ]
Founder - Lead Software Developer - Hosting Systems Administrator
Omega Vortex
(http://www.omegavortex.com)
--- End Message ---
--- Begin Message ---
Hi Jeremy,
I tried if ( strcmp( trim($SollKombination), trim($formCheck) ) )
same negativ result. For some reason both strings are not considered to be the
same.
They have the same length, are of the same type and have the same content. Why
PHP
doesn't recognize them as beeing equal.... I don't get it.
thanks for your help so far
janbro
Jeremy Privett schrieb:
> janbro wrote:
>
>> Hello List
>>
>> I've got the following little code:
>>
>> $formCheck= $_GET['formCheck'];
>> $SollKombination = $_SESSION['zufall'];
>>
>> echo "$SollKombination<br>$formCheck";
>> print gettype($formCheck);
>> echo "---";
>> print gettype($SollKombination);
>>
>>
>> if ($SollKombination == $formCheck){
>> echo "test";
>> }
>>
>> To give you some background: This code is supposed to check if a user
>> has tried to login via my form.
>>
>> Which gives me the following output:
>>
>> ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
>> ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
>> string---string
>>
>> Everything the way it's supposed to be....
>>
>> What I don't get is, why isn't the if statement true? Shouldn't it
>> show test as well? Where is my mistake?
>> I run PHP 5.1.1 on Windows. On my Win PHP 5.0 this code works proper,
>> but not here ?!?
>>
>> thx JanBro
>>
>>
>>
> Hey JanBro,
>
> Try replacing the if statement you have with this:
>
> if ( strcmp( trim($SollKombination), trim($formCheck) ) ) {
> echo "test";
> }
>
> ---
> Jeremy Privett [ http://www.jeremyprivett.com ]
> Founder - Lead Software Developer - Hosting Systems Administrator
> Omega Vortex
> (http://www.omegavortex.com)
--- End Message ---
--- Begin Message ---
Hi Jeremy,
I tried if ( strcmp( trim($SollKombination), trim($formCheck) ) )
same negativ result. For some reason both strings are not considered to be the
same.
They have the same length, are of the same type and have the same content. Why
PHP
doesn't recognize them as beeing equal.... I don't get it.
thanks for your help so far
janbro
Jeremy Privett schrieb:
> janbro wrote:
>
>> Hello List
>>
>> I've got the following little code:
>>
>> $formCheck= $_GET['formCheck'];
>> $SollKombination = $_SESSION['zufall'];
>>
>> echo "$SollKombination<br>$formCheck";
>> print gettype($formCheck);
>> echo "---";
>> print gettype($SollKombination);
>>
>>
>> if ($SollKombination == $formCheck){
>> echo "test";
>> }
>>
>> To give you some background: This code is supposed to check if a user
>> has tried to login via my form.
>>
>> Which gives me the following output:
>>
>> ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
>> ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
>> string---string
>>
>> Everything the way it's supposed to be....
>>
>> What I don't get is, why isn't the if statement true? Shouldn't it
>> show test as well? Where is my mistake?
>> I run PHP 5.1.1 on Windows. On my Win PHP 5.0 this code works proper,
>> but not here ?!?
>>
>> thx JanBro
>>
>>
>>
> Hey JanBro,
>
> Try replacing the if statement you have with this:
>
> if ( strcmp( trim($SollKombination), trim($formCheck) ) ) {
> echo "test";
> }
>
> ---
> Jeremy Privett [ http://www.jeremyprivett.com ]
> Founder - Lead Software Developer - Hosting Systems Administrator
> Omega Vortex
> (http://www.omegavortex.com)
--- End Message ---
--- Begin Message ---
Hi Jeremy,
I tried if ( strcmp( trim($SollKombination), trim($formCheck) ) )
same negativ result. For some reason both strings are not considered to be the
same.
They have the same length, are of the same type and have the same content. Why
PHP
doesn't recognize them as beeing equal.... I don't get it.
thanks for your help so far
janbro
Jeremy Privett schrieb:
> janbro wrote:
>
>> Hello List
>>
>> I've got the following little code:
>>
>> $formCheck= $_GET['formCheck'];
>> $SollKombination = $_SESSION['zufall'];
>>
>> echo "$SollKombination<br>$formCheck";
>> print gettype($formCheck);
>> echo "---";
>> print gettype($SollKombination);
>>
>>
>> if ($SollKombination == $formCheck){
>> echo "test";
>> }
>>
>> To give you some background: This code is supposed to check if a user
>> has tried to login via my form.
>>
>> Which gives me the following output:
>>
>> ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
>> ZL0X~TT4PQ%0~R0OXPRUHY7E&!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S
>> string---string
>>
>> Everything the way it's supposed to be....
>>
>> What I don't get is, why isn't the if statement true? Shouldn't it
>> show test as well? Where is my mistake?
>> I run PHP 5.1.1 on Windows. On my Win PHP 5.0 this code works proper,
>> but not here ?!?
>>
>> thx JanBro
>>
>>
>>
> Hey JanBro,
>
> Try replacing the if statement you have with this:
>
> if ( strcmp( trim($SollKombination), trim($formCheck) ) ) {
> echo "test";
> }
>
> ---
> Jeremy Privett [ http://www.jeremyprivett.com ]
> Founder - Lead Software Developer - Hosting Systems Administrator
> Omega Vortex
> (http://www.omegavortex.com)
--- End Message ---
--- Begin Message ---
janbro wrote:
Hi Jeremy,
I tried if ( strcmp( trim($SollKombination), trim($formCheck) ) )
same negativ result. For some reason both strings are not considered to be the
same.
They have the same length, are of the same type and have the same content. Why
PHP
doesn't recognize them as beeing equal.... I don't get it.
thanks for your help so far
janbro
This is just a shot in the dark, but have you checked the HTML source of
your test to make sure that some of the characters aren't been parsed as
HTML entities? That would technically make the strings different, but
you wouldn't be able to tell with just echoing alone.
--- End Message ---
--- Begin Message ---
I would guess that the '&' in $_GET['formCheck'] will cause problems...
Trying your code without the ampersand as in:
$_GET['formCheck'] =
'ZL0X~TT4PQ%0~R0OXPRUHY7E!4~W337J71V4WDDI6$GS9480XP0TNP2I$1YX75S'
It works just fine.
--- End Message ---
--- Begin Message ---
How looks your characterData function?
--- End Message ---
--- Begin Message ---
PHP General List,
This is something I tried to find on Google, but I'm hindered by not
knowing the proper terminology.
On many sites that have contact or registration forms, they have a
small image file with a randomly generated number shown in a distorted
graphical fashion that is hard for a computer to scan and read.
The purpose is that the site visitor has to type in the numbers into a
field, in order to verify that it is, in fact, a human filling out the
form.
First, is there a term for these kinds of images, or that kind of
verification system? What would be the best search terms to look for
source scripts?
Second, can anyone recommend a resource for that kind of PHP script. If
I really worked at it, I could probably write the script to generate a
small PNG image with a random number in it. But I haven't the faintest
clue how to distort it so it's only legible to humans, nor how to
correlate the image with a number that a user inputs into a form field.
Any advice would be much appreciated.
--
Dave M G
--- End Message ---
--- Begin Message ---
Dave M G wrote:
> First, is there a term for these kinds of images, or that kind of
> verification system? What would be the best search terms to look for
> source scripts?
CAPTCHA
> Second, can anyone recommend a resource for that kind of PHP script. If
> I really worked at it, I could probably write the script to generate a
> small PNG image with a random number in it. But I haven't the faintest
> clue how to distort it so it's only legible to humans, nor how to
> correlate the image with a number that a user inputs into a form field.
http://pear.php.net/package/Text_CAPTCHA
Cheers,
David
--
David Grant
http://www.grant.org.uk/
--- End Message ---
--- Begin Message ---
> PHP General List,
>
> This is something I tried to find on Google, but I'm
> hindered by not
> knowing the proper terminology.
> On many sites that have contact or registration forms,
> they have a
> small image file with a randomly generated number shown in a distorted
> graphical fashion that is hard for a computer to scan and read.
> The purpose is that the site visitor has to type in the
> numbers into a
> field, in order to verify that it is, in fact, a human filling out the
> form.
> First, is there a term for these kinds of images, or
> that kind of
> verification system? What would be the best search terms to look for
> source scripts?
> Second, can anyone recommend a resource for that kind
> of PHP script. If
> I really worked at it, I could probably write the script to generate a
> small PNG image with a random number in it. But I haven't the faintest
> clue how to distort it so it's only legible to humans, nor how to
> correlate the image with a number that a user inputs into a
> form field.
Google for "CAPTCHA", and you'll be amazed at the number of hits!
JM
--- End Message ---
--- Begin Message ---
On Wednesday 04 January 2006 16:56, Dave M G wrote:
> First, is there a term for these kinds of images, or that kind of
> verification system? What would be the best search terms to look for
> source scripts?
captcha
--- End Message ---
--- Begin Message ---
Duncan Hill wrote:
On Wednesday 04 January 2006 16:56, Dave M G wrote:
First, is there a term for these kinds of images, or that kind of
verification system? What would be the best search terms to look for
source scripts?
captcha
I've been looking for this term for a while as well.
--- End Message ---