Re: [PHP] Can I fopen() files in .htaccess protected directories?

2002-04-08 Thread Dalton Hunter

Hi, actually it is located at a secret URL , just using .htaccess for added
protection. Turns out the example I gave does indeed work but unlike in
Unix, the password cannot have a ? in it since it is being passed in the
URL.

Miguel Cruz [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Sat, 6 Apr 2002, Dalton Hunter wrote:
  Hi, does fopen() support the opening and reading of remote files in
  directories protected with .htaccess files like ...
 
  fopen(http://user:[EMAIL PROTECTED]/directory/file.php,r;);
 
  If not, is there an alternative way to do this? Thanks!

 If you're only going to be reading it from inside your PHP program, why
 not just put the target resource at a secret URL rather than behind
 .htaccess password protection? That's pretty much equivalent to a
 password.

 miguel




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] How do I use fopen() to overwrite a remote file via ftp?

2002-04-08 Thread Dalton Hunter

Hi, I want to use fopen to connect to a remote server via ftp and overwrite
a file like ...

fopen(ftp://username:[EMAIL PROTECTED]/system/path/to/file.php;, w)

... but after connecting I get the Warning: File already exists error
message and it fails. What is the proper way to overwrite it?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: How do I use fopen() to overwrite a remote file via ftp?

2002-04-08 Thread Dalton Hunter

Hi, the manual page for fopen indicates one can use it with ftp ...

You can open files for either reading or writing via ftp

... Just trying to figure out how one can properly overwrite files with
fopen via ftp, if at all, as I don't want to have to recompile PHP with the
FTP functions and use those.

Cc Zona [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 In article [EMAIL PROTECTED],
  [EMAIL PROTECTED] (Dalton Hunter) wrote:

  Hi, I want to use fopen to connect to a remote server via ftp and
overwrite
  a file like ...
 
  fopen(ftp://username:[EMAIL PROTECTED]/system/path/to/file.php;,
w)
 
  ... but after connecting I get the Warning: File already exists error
  message and it fails. What is the proper way to overwrite it?

 By using the FTP functions, not fopen (quote from http://php.net/fopen:
 HTTP connections are read-only; you cannot write data or copy files to an
 HTTP resource).

 The example on the FTP chapter's intro page http://php.net/ftp
 demonstrates how.

 --
 CC



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Can I fopen() files in .htaccess protected directories?

2002-04-06 Thread Dalton Hunter

Hi, does fopen() support the opening and reading of remote files in
directories protected with .htaccess files like ...

fopen(http://user:[EMAIL PROTECTED]/directory/file.php,r;);

If not, is there an alternative way to do this? Thanks!



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] What PHP commands could do this?

2002-04-01 Thread Dalton Hunter

Hi, I would like to include a version checker/update utility with a php
program I am writting. Can someone tell me what php commands would be needed
to write a script that would compare the versions or dates of a customers
php files against those from a remote server and provide a way for the
customer to upgrade the php files either individually or as a whole over the
web? Thanks!



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Can I search for a partial match in an array ?

2002-03-28 Thread Dalton Hunter

Hi, I want to search for a partial match in an array? Does in_array() or
search_array() support this or is there another way? For example if I have
30 file names in an array in the format ...

file1.txt
file2.txt
pic1.gif
pic2.gif

... how can I check to see if any values in the array start with the
partial word file?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Can I search for a partial match in an array ?

2002-03-28 Thread Dalton Hunter

Thanks, worked great!

Bvr [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 preg_grep(/^file/, $arr)

 bvr.

 Dalton Hunter wrote:

  Hi, I want to search for a partial match in an array? Does in_array() or
  search_array() support this or is there another way? For example if I
have
  30 file names in an array in the format ...
  
  file1.txt
  file2.txt
  pic1.gif
  pic2.gif
  
  ... how can I check to see if any values in the array start with the
  partial word file?
  
  
  






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] How to write file containing shell script?

2002-03-27 Thread Dalton Hunter

Hi, I am trying to write a file that contains a shell script. The file
writes to the server but when I try to execute it it fails with a command
not found error. But if I copy and paste the files contents into a new text
file using Textpad on my PC and upload it to the same directory it works?!
It is not related to permissions as both files are 777 and I am root? The
only difference I could tell is when I compare the files in Textpad although
the contents are identical, the failed file is slightly larger and has a
file type of Netscape in the File Properties while the other has a file
type of PC? Any ideas?



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.343 / Virus Database: 190 - Release Date: 3/22/02



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How to write file containing shell script?

2002-03-27 Thread Dalton Hunter

Miguel Cruz [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Wed, 27 Mar 2002, Dalton Hunter wrote:
  Hi, I am trying to write a file that contains a shell script. The file
  writes to the server but when I try to execute it it fails with a
  command not found error. But if I copy and paste the files contents into
  a new text file using Textpad on my PC and upload it to the same
  directory it works?! It is not related to permissions as both files are
  777 and I am root? The only difference I could tell is when I compare
  the files in Textpad although the contents are identical, the failed
  file is slightly larger and has a file type of Netscape in the File
  Properties while the other has a file type of PC? Any ideas?

 Make sure you use unix-style line endings (just \n and no \r).

 Textpad sort of transparently opens files with different line ending
 styles, though it does tell you in one of those little status boxes at the
 bottom - if it's showing DOS or Windows or whatever when you open it, then
 the shell probably won't execute it.

 An alternative would be to use text/ASCII (not binary) FTP to transfer it
 to the server. This will automatically fix the line endings.

 miguel


Hi, thanks for your reply. I should have been a little clearer. The file is
created as a result of a PHP script not in TextPad. I am only comparing them
in Textpad afterward. For example the script contains ...

?php

// BEGIN PHP SCRIPT THAT GENERATES SHELL SCRIPT

$sbackup = #!/bin/sh
... multiple line shell script in here ...
;

$backupfile = fopen(/path/to/shell_script,w);
fwrite($backupfile,$sbackup);
fclose($backupfile);
chmod(/path/to/shell_script, 0777);

// END PHP SCRIPT THAT GENERATES SHELL SCRIPT

?

... and it creates the file fine but when I go to execute the shell script
it returns ...

sh: ./shell_script: No such file or directory

eventhough it is there. If I copy the files contents into a new Texpad
document on my PC and upload to the server it works fine. I tried to add a
\n at the end of each line in the PHP script but no luck. I think it might
have something to do with the line endings.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.343 / Virus Database: 190 - Release Date: 3/22/02



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How to write file containing shell script?

2002-03-27 Thread Dalton Hunter

Miguel Cruz [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Thu, 28 Mar 2002, Miguel Cruz wrote:
  Right. I think the No such file or directory message is because it's
  failing to find an interpreter called /bin/bash\r.

 Sorry, I mean /bin/sh\r. Habit.

 miguel


Thanks miguel, that was the problem. The original PHP file was indeed being
saved in TextPad as PC thus adding that \r. I resaved it as Unix and the
shell script runs fine. :)


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.343 / Virus Database: 190 - Release Date: 3/22/02



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php