php-general Digest 19 Jun 2005 23:35:26 -0000 Issue 3521
Topics (messages 217191 through 217199):
Re: comparing two texts
217191 by: M. Sokolewicz
217193 by: Robert Cummings
217194 by: M. Sokolewicz
217196 by: Robert Cummings
SFTP problems
217192 by: Lowell Allen
217195 by: M. Sokolewicz
217197 by: Lowell Allen
217198 by: M. Sokolewicz
Permission argh!
217199 by: Andy Pieters
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 ---
jenny mathew wrote:
Untested, very crude:
<?php
$maxlen = max(strlen($text1), strlen($text2));
for ($i = 0; $i < $maxlen; $i++){
if (@$text1[$i] == @$text2[$i]) echo @$text1[$i];
else @echo "<font color=red>$text1[$i]|$text2[$i]</font>";
}
?>
donot you think you program will just bring the server to its foot ,if the
text message encountered is very large of order of 40 KB or
larger.is<http://larger.is>there any other efficient method.
40KB isn't large... now, when you're talking about hundreds of MBs of
text, then it gets large :) 40KB, with that method, is nothing...
--- End Message ---
--- Begin Message ---
On Sun, 2005-06-19 at 09:22, M. Sokolewicz wrote:
> jenny mathew wrote:
> >>Untested, very crude:
> >>
> >><?php
> >>$maxlen = max(strlen($text1), strlen($text2));
> >>for ($i = 0; $i < $maxlen; $i++){
> >>if (@$text1[$i] == @$text2[$i]) echo @$text1[$i];
> >>else @echo "<font color=red>$text1[$i]|$text2[$i]</font>";
> >>}
> >>?>
> >
> > donot you think you program will just bring the server to its foot ,if the
> > text message encountered is very large of order of 40 KB or
> > larger.is<http://larger.is>there any other efficient method.
> >
> 40KB isn't large... now, when you're talking about hundreds of MBs of
> text, then it gets large :) 40KB, with that method, is nothing...
It's a bit of a dirty hack though. If I compare a 2 character text
against a 40k text, the error handler will be invoked (39998 * 3) times
if $text1 is the 2 byte string. That's extremely inefficient. I don't
think I've ever seen error suppression abused so badly to prevent
writing an extra line or 2 using isset().
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
On Sun, 2005-06-19 at 09:22, M. Sokolewicz wrote:
jenny mathew wrote:
Untested, very crude:
<?php
$maxlen = max(strlen($text1), strlen($text2));
for ($i = 0; $i < $maxlen; $i++){
if (@$text1[$i] == @$text2[$i]) echo @$text1[$i];
else @echo "<font color=red>$text1[$i]|$text2[$i]</font>";
}
?>
donot you think you program will just bring the server to its foot ,if the
text message encountered is very large of order of 40 KB or
larger.is<http://larger.is>there any other efficient method.
40KB isn't large... now, when you're talking about hundreds of MBs of
text, then it gets large :) 40KB, with that method, is nothing...
It's a bit of a dirty hack though. If I compare a 2 character text
against a 40k text, the error handler will be invoked (39998 * 3) times
if $text1 is the 2 byte string. That's extremely inefficient. I don't
think I've ever seen error suppression abused so badly to prevent
writing an extra line or 2 using isset().
Cheers,
Rob.
I agree with what you said fully; however, even though that's the case,
and it indeed could be written a lot faster and cleaner, it would not
pose a problem on most systems. That was the point I tried to make ;)
--- End Message ---
--- Begin Message ---
On Sun, 2005-06-19 at 12:33, M. Sokolewicz wrote:
> Robert Cummings wrote:
> > On Sun, 2005-06-19 at 09:22, M. Sokolewicz wrote:
> >
> >>jenny mathew wrote:
> >>
> >>>>Untested, very crude:
> >>>>
> >>>><?php
> >>>>$maxlen = max(strlen($text1), strlen($text2));
> >>>>for ($i = 0; $i < $maxlen; $i++){
> >>>>if (@$text1[$i] == @$text2[$i]) echo @$text1[$i];
> >>>>else @echo "<font color=red>$text1[$i]|$text2[$i]</font>";
> >>>>}
> >>>>?>
> >>>
> >>> donot you think you program will just bring the server to its foot ,if
> >>> the
> >>>text message encountered is very large of order of 40 KB or
> >>>larger.is<http://larger.is>there any other efficient method.
> >>>
> >>
> >>40KB isn't large... now, when you're talking about hundreds of MBs of
> >>text, then it gets large :) 40KB, with that method, is nothing...
> >
> >
> > It's a bit of a dirty hack though. If I compare a 2 character text
> > against a 40k text, the error handler will be invoked (39998 * 3) times
> > if $text1 is the 2 byte string. That's extremely inefficient. I don't
> > think I've ever seen error suppression abused so badly to prevent
> > writing an extra line or 2 using isset().
> >
> > Cheers,
> > Rob.
> I agree with what you said fully; however, even though that's the case,
> and it indeed could be written a lot faster and cleaner, it would not
> pose a problem on most systems. That was the point I tried to make ;)
Oh absolutely, 40k is tiny :) Just never seen error suppression used for
such mundane processing. Now if we up it to 2 chars and 5 megs :) With a
custom user space error handler in the background... ugh.
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
I need to use SFTP to send text files and binary files from one server
to another, but I'm unable to use fopen on the remote server, and if I
send with ssh2_scp_send the files are truncated. I'm assuming the
libssh2-PECL/ssh2 installation isn't the problem because I'm able to
connect using ssh2_auth_password, create a directory on the remote
server with ssh2_sftp_mkdir, and copy files with ssh2_sftp_send and
ssh2_sftp_recv (even though ssh2_sftp_send truncates files).
When I try to use fopen, I get this error message:
Warning: fopen(): Unable to open ssh2.sftp://Resource id
#10/whatever.com:22/home/whatever/public_html/flamingo/test.txt on
remote host in /home/user/public_html/cms/sftp_test.php on line 79
Warning: fopen(ssh2.sftp://Resource id
#10/whatever.com:22/home/whatever/public_html/flamingo/test.txt):
failed to open stream: Resource temporarily unavailable in
/home/user/public_html/cms/sftp_test.php on line 79
Here's line 79 of sftp_test.php:
$stream =
fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/
flamingo/".$filename, "wt")
I've read "Secure Communications with PHP and SSH" in the February PHP
Architect. That's what prompted me to try PECL/ssh2, but now I'm stuck.
Anybody successfully using fopen with SFTP or anybody using
ssh2_sftp_send without getting truncated files?
--
Lowell Allen
--- End Message ---
--- Begin Message ---
Lowell Allen wrote:
I need to use SFTP to send text files and binary files from one server
to another, but I'm unable to use fopen on the remote server, and if I
send with ssh2_scp_send the files are truncated. I'm assuming the
libssh2-PECL/ssh2 installation isn't the problem because I'm able to
connect using ssh2_auth_password, create a directory on the remote
server with ssh2_sftp_mkdir, and copy files with ssh2_sftp_send and
ssh2_sftp_recv (even though ssh2_sftp_send truncates files).
When I try to use fopen, I get this error message:
Warning: fopen(): Unable to open ssh2.sftp://Resource id
#10/whatever.com:22/home/whatever/public_html/flamingo/test.txt on
remote host in /home/user/public_html/cms/sftp_test.php on line 79
Warning: fopen(ssh2.sftp://Resource id
#10/whatever.com:22/home/whatever/public_html/flamingo/test.txt): failed
to open stream: Resource temporarily unavailable in
/home/user/public_html/cms/sftp_test.php on line 79
Here's line 79 of sftp_test.php:
$stream =
fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/
flamingo/".$filename, "wt")
I've read "Secure Communications with PHP and SSH" in the February PHP
Architect. That's what prompted me to try PECL/ssh2, but now I'm stuck.
Anybody successfully using fopen with SFTP or anybody using
ssh2_sftp_send without getting truncated files?
First of all, posting this once is enough. Second of all, I think the
problem here is actually a lot easier than it would look at first glance :)
I noticed the following error:
Warning: fopen(ssh2.sftp://Resource id #10/[...]): [...]
Now, what you see here is that you suddenly have a "ssh2.sftp://Resource
id #10". This is probably not the domain name you're trying to connect
to, now is it? :) That string typically appears only when you cast a
resource to a string (eg. a mysql-connection, a stream, or whatever).
So, looking at line 79, I would guess that $sftp isn't a string which
tells fopen where to find the file to open, but instead is a resource
which should not be there at all.
- tul
--- End Message ---
--- Begin Message ---
On Jun 19, 2005, at 12:37 PM, M. Sokolewicz wrote:
Lowell Allen wrote:
I need to use SFTP to send text files and binary files from one
server to another, but I'm unable to use fopen on the remote server,
and if I send with ssh2_scp_send the files are truncated. I'm
assuming the libssh2-PECL/ssh2 installation isn't the problem because
I'm able to connect using ssh2_auth_password, create a directory on
the remote server with ssh2_sftp_mkdir, and copy files with
ssh2_sftp_send and ssh2_sftp_recv (even though ssh2_sftp_send
truncates files).
When I try to use fopen, I get this error message:
Warning: fopen(): Unable to open ssh2.sftp://Resource id
#10/whatever.com:22/home/whatever/public_html/flamingo/test.txt on
remote host in /home/user/public_html/cms/sftp_test.php on line 79
Warning: fopen(ssh2.sftp://Resource id
#10/whatever.com:22/home/whatever/public_html/flamingo/test.txt):
failed to open stream: Resource temporarily unavailable in
/home/user/public_html/cms/sftp_test.php on line 79
Here's line 79 of sftp_test.php:
$stream =
fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/
flamingo/".$filename, "wt")
I've read "Secure Communications with PHP and SSH" in the February
PHP Architect. That's what prompted me to try PECL/ssh2, but now I'm
stuck. Anybody successfully using fopen with SFTP or anybody using
ssh2_sftp_send without getting truncated files?
First of all, posting this once is enough. Second of all, I think the
problem here is actually a lot easier than it would look at first
glance :)
I noticed the following error:
Warning: fopen(ssh2.sftp://Resource id #10/[...]): [...]
Now, what you see here is that you suddenly have a
"ssh2.sftp://Resource id #10". This is probably not the domain name
you're trying to connect to, now is it? :) That string typically
appears only when you cast a resource to a string (eg. a
mysql-connection, a stream, or whatever). So, looking at line 79, I
would guess that $sftp isn't a string which tells fopen where to find
the file to open, but instead is a resource which should not be there
at all.
Thanks for your reply. I apologize for the duplication. I posted until
I saw it show up, and I've only seen it once -- probably my gmail
account marking as spam, which I don't see because I retrieve as a POP
account with Thunderbird. I unsubscribed and subscribed with a
different email address and posted again.
Here's where $sftp is coming from:
$connection = ssh2_connect("copy-design.com", 22);
$sftp = ssh2_sftp($connection);
And from the examples I've seen, the correct syntax for opening a
handle is what I use on line 79:
$stream =
fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/
flamingo/".$filename, "wt")
The info at <http://us4.php.net/manual/en/function.ssh2-sftp.php> says
that ssh_sftp() "returns an SSH2 SFTP resource", which is what I
figured "Resource id #10" is referring to. From the manual example for
ssh_sftp:
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
$sftp = ssh2_sftp($connection);
$stream = fopen("ssh2.sftp://$sftp/path/to/file", 'r');
Perhaps I'm being as inept with this code as I seem to be with my
email, but if the domain is "whatever.com", and the file is located at
"/home/whatever/public_html/flamingo/", and the file name is
"test.txt", and I want to open the file (which doesn't exist yet) for
writing, what should I use if not
'fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/
flamingo/test.txt", "wt")'?
--
Lowell Allen
--- End Message ---
--- Begin Message ---
Lowell Allen wrote:
On Jun 19, 2005, at 12:37 PM, M. Sokolewicz wrote:
Lowell Allen wrote:
I need to use SFTP to send text files and binary files from one
server to another, but I'm unable to use fopen on the remote server,
and if I send with ssh2_scp_send the files are truncated. I'm
assuming the libssh2-PECL/ssh2 installation isn't the problem
because I'm able to connect using ssh2_auth_password, create a
directory on the remote server with ssh2_sftp_mkdir, and copy files
with ssh2_sftp_send and ssh2_sftp_recv (even though ssh2_sftp_send
truncates files).
When I try to use fopen, I get this error message:
Warning: fopen(): Unable to open ssh2.sftp://Resource id
#10/whatever.com:22/home/whatever/public_html/flamingo/test.txt on
remote host in /home/user/public_html/cms/sftp_test.php on line 79
Warning: fopen(ssh2.sftp://Resource id
#10/whatever.com:22/home/whatever/public_html/flamingo/test.txt):
failed to open stream: Resource temporarily unavailable in
/home/user/public_html/cms/sftp_test.php on line 79
Here's line 79 of sftp_test.php:
$stream =
fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/
flamingo/".$filename, "wt")
I've read "Secure Communications with PHP and SSH" in the February
PHP Architect. That's what prompted me to try PECL/ssh2, but now I'm
stuck. Anybody successfully using fopen with SFTP or anybody using
ssh2_sftp_send without getting truncated files?
First of all, posting this once is enough. Second of all, I think the
problem here is actually a lot easier than it would look at first
glance :)
I noticed the following error:
Warning: fopen(ssh2.sftp://Resource id #10/[...]): [...]
Now, what you see here is that you suddenly have a
"ssh2.sftp://Resource id #10". This is probably not the domain name
you're trying to connect to, now is it? :) That string typically
appears only when you cast a resource to a string (eg. a
mysql-connection, a stream, or whatever). So, looking at line 79, I
would guess that $sftp isn't a string which tells fopen where to find
the file to open, but instead is a resource which should not be there
at all.
Thanks for your reply. I apologize for the duplication. I posted until
I saw it show up, and I've only seen it once -- probably my gmail
account marking as spam, which I don't see because I retrieve as a POP
account with Thunderbird. I unsubscribed and subscribed with a
different email address and posted again.
Here's where $sftp is coming from:
$connection = ssh2_connect("copy-design.com", 22);
$sftp = ssh2_sftp($connection);
And from the examples I've seen, the correct syntax for opening a
handle is what I use on line 79:
$stream =
fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/
flamingo/".$filename, "wt")
The info at <http://us4.php.net/manual/en/function.ssh2-sftp.php> says
that ssh_sftp() "returns an SSH2 SFTP resource", which is what I
figured "Resource id #10" is referring to. From the manual example for
ssh_sftp:
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
$sftp = ssh2_sftp($connection);
$stream = fopen("ssh2.sftp://$sftp/path/to/file", 'r');
Perhaps I'm being as inept with this code as I seem to be with my
email, but if the domain is "whatever.com", and the file is located at
"/home/whatever/public_html/flamingo/", and the file name is
"test.txt", and I want to open the file (which doesn't exist yet) for
writing, what should I use if not
'fopen("ssh2.sftp://$sftp/whatever.com:22/home/whatever/public_html/
flamingo/test.txt", "wt")'?
--
Lowell Allen
hmm... yes, I see your point, and by looking at the docs I see you were
correct. However, in that case, I think the docs would be incorrect. I
mean, why would a Resource, cast to a string, be sent as a path??? :|
--- End Message ---
--- Begin Message ---
Hi all
I am in the process of creating an installer for my php application.
During the test proces, it does this:
isdir(root)?>create dir root
ok?>chmod 0777
isdir(root/child)?>create dir root/child
ok?>chmod 0777
isdir(root/child/grandchild)?>create dir root/child/grandchild
ok?>chmod 0777
The script fails on the grandchild part:
stat failed for /root/child/grandchild (errno=13 - Permission denied)
when I try to force the hand and create it anyway:
mkdir() failed (Permission denied)
The files/directories are owned by the 'nobody' user... the same as the
apache&php user.
Anybody know how to remedy this problem?
With kind regards
Andy
--
Registered Linux User Number 379093
-- --BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT/O/>E$ d-(---)>+ s:(+)>: a--(-)>? C++++$(+++) UL++++>++++$ P-(+)>++
L+++>++++$ E---(-)@ W+++>+++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e>++++$@ h++(*) r-->++ y--()>++++
-- ---END GEEK CODE BLOCK------
--
Check out these few php utilities that I released
under the GPL2 and that are meant for use with a
php cli binary:
http://www.vlaamse-kern.com/sas/
--
--
pgpjhroANV5qp.pgp
Description: PGP signature
--- End Message ---