php-general Digest 11 Nov 2005 13:20:15 -0000 Issue 3788
Topics (messages 225586 through 225607):
Re: a code question..??
225586 by: bruce
225591 by: comex
225592 by: bruce
225596 by: comex
Re: mod_rewrite, apache2, php5RC1 and osx bsd
225587 by: Dan Rossi
225593 by: Curt Zirzow
225594 by: Dan Rossi
225595 by: Curt Zirzow
225605 by: Marcus Bointon
Re: Inserting a NULL value into MySQL via PHP
225588 by: Jasper Bryant-Greene
225597 by: Curt Zirzow
Array_merge, safety and race condition?
225589 by: Ezra Nugroho
xml-rpc and xml-rpci
225590 by: Alex Duggan
wanting to get host name instead of ip
225598 by: matt VanDeWalle
225599 by: Curt Zirzow
225600 by: matt VanDeWalle
sending/notifying a server process
225601 by: tony yau
php session in ie
225602 by: sunaram patir
225603 by: sunaram patir
225604 by: sunaram patir
225606 by: Marcus Bointon
225607 by: M
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 ---
richard...
in your example, wouldn't app A, essentially download the code from app B,
and run the source on app A? or would the code be run on app B, with the
resulting html/content/page being transferred to app A?
would this be better if it were perhaps done as a soap client/server
process... of course, the fact that the user's php would have to have the
soap extensions installed would be an issue...
-bruce
-----Original Message-----
From: Richard Lynch [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 10, 2005 3:02 PM
To: [EMAIL PROTECTED]
Cc: 'Ben'; [email protected]
Subject: RE: [PHP] a code question..??
On Thu, November 10, 2005 4:30 pm, bruce wrote:
> as i understand curl functions (and correct me if i'm wrong). the
> functions
> simply allow the user/app to download/copy the file from the remote
> server,
> where the existing app could do whatever with the content...
>
> this isn't what i want.. i'm trying to figure out if there's a way to
> run a
> chunk of code on a remote server... i'd rather not put the source on
> the
> intial client-app A machine...
The trick, then, is for app B to make its SOURCE CODE available for
curl on server A to snatch.
http://b.example.com/source_code.php?filename=login.php
<?php
//really BAD INSECURE code for illustration:
$filename = $_GET['filename'];
header("Content-type: text/plain");
readfile($filename);
?>
On server A:
<?php
include "http://b.example.com/source_code.php?filename=login.php";
?>
Or you could use curl to get the code and eval it, or you could use
file_get_contents and eval it, or you could get the code, save it to a
temp file, and then include the temp file, or you could...
It's not that it can't be done. It's that there are so many ways to
do it, we don't know where to start.
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
> in your example, wouldn't app A, essentially download the code from app B,
> and run the source on app A? or would the code be run on app B, with the
> resulting html/content/page being transferred to app A?
If the PHP file has a .php extension, it will be run on the webserver
like any PHP page. If it is .txt or you set Apache directives, etc.,
it will be transferred to the client app.
--- End Message ---
--- Begin Message ---
ok...
so can i do something like...
+-------------------------------+
| |
| user |
| 'sub_btn' |
| |
| |
| |
| |
| blah |
| blah |
| blah |
| |
| |
| |
+-------------------------------+
in this example, the user/sub_btn is generated from the app B server/system.
the user would then fill in the 'user' and hit the 'sub_btn', causing the
information to be sent back to the app B server.
the app B server would then return a result, based on the user input... i'm
trying to figure out how to essentially allocate a section of the page, to a
remote application. after i've finished with the remote stuff, the user
could go ahead and select other items/buttons on the page that are in the
current environment
+-------------------------------+
| |
| +-------------+ |
| | remote | |
| | app | |
| | area | |
| +-------------+ |
| |
| |
| local app space.... |
| |
| blah |
| blah |
| blah |
| |
| |
| |
+-------------------------------+
i'm not sure what's the best approach to this...
thanks
bruce
-----Original Message-----
From: comex [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 10, 2005 5:28 PM
To: [email protected]
Subject: Re: [PHP] a code question..??
> in your example, wouldn't app A, essentially download the code from app B,
> and run the source on app A? or would the code be run on app B, with the
> resulting html/content/page being transferred to app A?
If the PHP file has a .php extension, it will be run on the webserver
like any PHP page. If it is .txt or you set Apache directives, etc.,
it will be transferred to the client app.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
> the app B server would then return a result, based on the user input... i'm
> trying to figure out how to essentially allocate a section of the page, to a
> remote application. after i've finished with the remote stuff, the user
> could go ahead and select other items/buttons on the page that are in the
> current environment
You could just use an iframe...
--- End Message ---
--- Begin Message ---
On 11/11/2005, at 8:53 AM, Max Belushkin wrote:
I've been having a problem with PHP 4.4.1 and mod_rewrite, which, as
Geert
Booster kindly pointed out, has been reported on
http://lists.freebsd.org/pipermail/freebsd-ports/2005-November/
027038.html,
which also has a link to the PHP bug report in the thread. Not sure if
this
is relevant to PHP5, but thought I'd mention that something similar
exist(ed?) in the 4.4.1 version.
There is also a bug report which is now closed for my problem !! This
bug still exists in the latest PHP 5.1 in snaps.php.net. Mind you my
apache is a fink binary, not bsd ports. There is huge issues compiling
apache under osx bsd, hence why i had to go with the binary. Mind you
osx is my dev environment coz its also my laptop,it is not production
lol, our production machine however is also BSD. To prove it wasnt thee
rewrite rule, i made it [L] to a standard html file and it was fine, so
there is something up with it in php obviouslly in the module.
--- End Message ---
--- Begin Message ---
On Thu, Nov 10, 2005 at 06:10:50PM +1100, Dan Rossi wrote:
>
> On 10/11/2005, at 4:18 PM, Curt Zirzow wrote:
>
> >On Thu, Nov 10, 2005 at 03:36:07PM +1100, Dan Rossi wrote:
> >>Hi there, ive been having issues with mod_rewrite and apache2 with PHP
> >>5.1RC1. I have googled the php bugs and people have been experiencing
> >>the same issue however the php people cant see to reproduce the bug.
> >>Its most definately doing it for me, here is a rewrite rule i have
> >>setup, if i [L] to a php script, it either tries to download the faked
> >>url file or hangs. I reverted back to 5.1.0b2 and it works fine ??
> >>What do i do ?
> >>
> >>RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.+\.(video))$
> >>../../phpscript.php
> >
> >Well this is a really ugly Rewrite, i must say.
>
> Say what you like however it had been working, and for the application
> it works, i dont think you get what its trying to do but anyway , im
> faking a url with session id's and ecrypted keys and sending the
> matches to the get request of that file so its hidden.
Of course i dont get what your trying to do, the rewriterule
doesn't match your description of what you said.
>
> >
> >One thing to note is well 5.1RC4 has been available in Oct:
> > http://downloads.php.net/ilia/
> >
>
> Thats not available from the main site downloads. I also forgot to
> meantion i had downloaded the latest from php snaps and still the same
> problem, so obviouslly it has been overlooked.
>From your other discusions it is kind of unclear exactly what
version of apache you are using, as well as are you using perfork,
perchild, worker, etc..
Also You mention fink but then you mention bsd, does it happen on
both systems?
As far it trying to download the faked url, what exactly is it
trying to download and what are the headers for the request as
well.
The hanging could be a loop of some sort, have you looked at the
output of the rewrite log to see exactly what is going on?
Curt
--
--- End Message ---
--- Begin Message ---
On 11/11/2005, at 1:21 PM, Curt Zirzow wrote:
Of course i dont get what your trying to do, the rewriterule
doesn't match your description of what you said.
Ok i am vague at most times, i wasnt going to give an exact example as
it will give away some of the systems secret and not so good when it
goes into the archive :\
From your other discusions it is kind of unclear exactly what
version of apache you are using, as well as are you using perfork,
perchild, worker, etc..
Its a prefork setup, worker would be nice though :D
Also You mention fink but then you mention bsd, does it happen on
both systems?
Errm live system is running php 4.4.1 / Apache 1.3 and its ok. Im
looking at upgrading it to php 5.1 when its out.
As far it trying to download the faked url, what exactly is it
trying to download and what are the headers for the request as
well.
The hanging could be a loop of some sort, have you looked at the
output of the rewrite log to see exactly what is going on?
Where can i find the log for that, i get a heap of errors like this
though
[Thu Nov 10 15:26:06 2005] [error] Optional hook test said: GET
/videos/dir/42288faa3649e8a66b28871ba9d7e77b/457867517/
713ced53f69d16f48072c2d13705e91b/95/180/video.stream HTTP/1.0
--- End Message ---
--- Begin Message ---
On Fri, Nov 11, 2005 at 01:27:32PM +1100, Dan Rossi wrote:
>
> On 11/11/2005, at 1:21 PM, Curt Zirzow wrote:
>
> >>
> >
> >Of course i dont get what your trying to do, the rewriterule
> >doesn't match your description of what you said.
>
> Ok i am vague at most times, i wasnt going to give an exact example as
> it will give away some of the systems secret and not so good when it
> goes into the archive :\
Could you come up with a simplified example that causes the error,
so it could be tested on other systems. I was able to have
something like:
RewriteRule ^(.*)/(.*)/$ /index.php?f=$1&b=$2 [L]
And accessing /foo/bar/ It worked like a charm with:
$_GET['f'] == '/foo' and $_GET['b'] == 'bar'
When I used the ../../index.php it would cause a 400 Bad Request,
i'm not clear on how your are doing your relative paths.
> >Also You mention fink but then you mention bsd, does it happen on
> >both systems?
>
> Errm live system is running php 4.4.1 / Apache 1.3 and its ok. Im
> looking at upgrading it to php 5.1 when its out.
yeah, this makes me wonder if there are issues with the fink binary
you are using. Is the web server going to get upgraded to 2.x as
well? I know that php has a completely different way to talk with
the 1.x vs 2.x which can complicate the issue a bit.
> >The hanging could be a loop of some sort, have you looked at the
> >output of the rewrite log to see exactly what is going on?
>
> Where can i find the log for that, i get a heap of errors like this
> though
You can set:
RewriteLog /path/to/writable/file
RewriteLogLevel 9 #where 9 is the most verbose
>
> [Thu Nov 10 15:26:06 2005] [error] Optional hook test said: GET
> /videos/dir/42288faa3649e8a66b28871ba9d7e77b/457867517/
> 713ced53f69d16f48072c2d13705e91b/95/180/video.stream HTTP/1.0
I'm not really sure what this means, it is related to the
./configure options for apache --enable-optional-hook*, i have no
clue what that does.
Curt.
--- End Message ---
--- Begin Message ---
On 10 Nov 2005, at 21:36, Richard Lynch wrote:
On Wed, November 9, 2005 10:36 pm, Dan Rossi wrote:
RewriteRule ^(.*)/(.*)/(.*)/(.*)/(.*)/(.+\.(video))$
../../phpscript.php
I should think all those .* should be .+ instead...
I mean, if somebody surfs to this URL:
http://example.com//////example.video
There's nothing really wrong with a URL like that, and I used to do
the same thing until I discovered another fly in this particular
ointment. Should source URLs like these ever appear in Microsoft
Outlook, they are likely to get 'corrected', for example a URL that
goes in as:
http://example.com//////example.video
When you click it, you're quite likely to have it go to:
http://example.com/example.video
thus completely missing all your mod_rewrite patterns. This is why we
love MS so. I've taken up using _ as a pattern separator as a
workaround.
There's also a very nasty bug in current mod_rewrite (at least in
Apache 2.0.54) where mod_rewrite url decodes submatches between input
and output URLs, so for example:
RewriteRule ^(.*) blah.php?x$1
if you feed that a URL that contains a URL encoded value like 'Hello%
20there', your resulting URL will be: 'blah.php?x=Hello there', which
is obviously broken.
Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
Is there a way when making a MySQL database entry through a PHP script and
there is no data to make the db treat it as NULL?
Wouldn't this just work:
INSERT INTO myTable (myField) VALUES (NULL)
Jasper
--- End Message ---
--- Begin Message ---
On Fri, Nov 11, 2005 at 01:09:39PM +1300, Jasper Bryant-Greene wrote:
> [EMAIL PROTECTED] wrote:
> >Is there a way when making a MySQL database entry through a PHP script and
> >there is no data to make the db treat it as NULL?
>
> Wouldn't this just work:
>
> INSERT INTO myTable (myField) VALUES (NULL)
yeah, the final result would need to look like that. Without an
example i would guess the question would be more how do i get my
statement to send NULL instead of ''.
<?php
$sql_quoted = array(); // shiflett' -- style
$myFieldValue = isset($POST['myFieldValue'])? $_POST['myFieldValue']: '';
if (strlen(trim($myFieldValue)) {
$sql_quoted['myField'] = "'" . mysql_real_escape_string($myFieldValue) . "'";
} else {
$sql_quoted['myField'] = 'NULL';
}
$query = "INSERT INTO myTable(myField) VALUES({$sql_quoted['myField']})";
echo $query;
?>
And if the field posted was empty, it will be indentical to
Jasper's sql, other wise it will be a properly quoted string.
Curt.
--
--- End Message ---
--- Begin Message ---
Php experts everywhere,
I want to merge two arrays, and I want to store the result as the first
array. Something like the following:
$array1 = array_merge ($array1, $array2);
So far the code gives me what I want. However, suppose if $array1 is
extremely huge, am I introducing a bug here because of possible race
condition? It's possible that array_merge has two write something to
$array1 (left hand side) before it even finishes reading it (argument)
in the first place. Let alone merging the two.
Should I just go conservative and do:
$tmp = array_merge($array1, $array2);
$array1 = $tmp;
Thank you,
Ezra
--- End Message ---
--- Begin Message ---
Hello,
What is the future of the xml-rpc client and server functions in php
5.x? I see the old xml-rpc extension is still marked as expirimental
and the newer xml-rpci extention in pecl has not been worked on in 8
months and doesn't have server functionality. I am in the process of
porting a large web app to php and I want to use the most updated and
maintained xml-rpc implimentation.
Thanks,
Alex
--- End Message ---
--- Begin Message ---
hello,
I was wondering, is there a way to get a connection's name(host's name
instead of just ip),
i am using the cli version of php and am now using the function
getpeername() but for example, i would like to be able to have it say
something like "connection: localhost ...." instead of "connection:
127.0.0.1"
is this possible with the command line interface?
I am using php 4.3.10 on linux
matt
--- End Message ---
--- Begin Message ---
On Thu, Nov 10, 2005 at 11:35:06PM -0600, matt VanDeWalle wrote:
> hello,
> I was wondering, is there a way to get a connection's name(host's name
> instead of just ip),
> i am using the cli version of php and am now using the function
> getpeername() but for example, i would like to be able to have it say
> something like "connection: localhost ...." instead of "connection:
> 127.0.0.1"
> is this possible with the command line interface?
I assume you really mean socket_getpeername().
You just have to do a reverse lookup using gethostbyaddr(), pending
your host and named settings you will get back either localhost or
the hostname you have (hopefully it is localhost), if it can't be
resolved it will be the IP.
if it is the IP instead of a localhost/hostname you'll have to fix
your systems configuration.
Curt.
--
--- End Message ---
--- Begin Message ---
yes, you assume right, I really did mean socket_getpeername()
its about midnight here and my brain shuts down at about 10:30 :p
thanks for the reply
matt
On Thu, 10 Nov 2005, Curt Zirzow wrote:
On Thu, Nov 10, 2005 at 11:35:06PM -0600, matt VanDeWalle wrote:
hello,
I was wondering, is there a way to get a connection's name(host's name
instead of just ip),
i am using the cli version of php and am now using the function
getpeername() but for example, i would like to be able to have it say
something like "connection: localhost ...." instead of "connection:
127.0.0.1"
is this possible with the command line interface?
I assume you really mean socket_getpeername().
You just have to do a reverse lookup using gethostbyaddr(), pending
your host and named settings you will get back either localhost or
the hostname you have (hopefully it is localhost), if it can't be
resolved it will be the IP.
if it is the IP instead of a localhost/hostname you'll have to fix
your systems configuration.
Curt.
--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi All,
I have a server process that sends fax,print, etc (both in C# and in Java).
Currently it polls says the fax table in the database for any fax jobs.
How can I get my PHP script to call or notify these services directly so not
having to wait for the next poll.
I can't open a socket to the server vai the PHP so what mechanism do I use?
Any hints will be grateful
--
Tony Yau
--- End Message ---
--- Begin Message ---
Hi, i am having problem with internet explorer. i am working on a
project on building a website where i need to keep track of the users
i.e. i use a login system in there in short. with the following code i
check whether the user is logged in or not.
<?php
session_start();
$_SESSION['myurl']=$_SERVER['PHP_SELF'];
if(!isset($_SESSION['student_username']) &&
!isset($_SESSION['student_password']))
header("Location: login.php");
?>
if the user is not logged in, it redirects to the login page login.php
as is shown in the above code. now the user is allowed to log in
through the following code:
<?php
session_cache_limiter('private_no_expire');
session_set_cookie_params(0,"/","schools.zenrays.com");
session_start();
if(isset($_POST['submit'])){
include("../database.inc");
$login=trim($_POST['login']);
$pass=trim($_POST['pass']);
$Effectivelogin=strtoupper($login);
$auth=false;
$connection=mysql_connect($host,$user,$password);
mysql_select_db($database,$connection);
$query="SELECT password FROM students WHERE userID='$Effectivelogin'";
$result=mysql_query($query);
if(mysql_num_rows($result)){
while($row=mysql_fetch_array($result))
{
if($row[0]!=$pass)
echo ("Wrong Username/Password!");
else
$auth=true;
}
}
if($auth){
$_SESSION["student_username"]=$Effectivelogin;
$_SESSION["student_password"]=$pass;
if(isset($_SESSION['myurl']))
header("Location: http://schools.zenrays.com".$_SESSION['myurl']);
else
header("Location: http://schools.zenrays.com/students");
}
}
?>
<html>
<head>
<title>User Authentication</title>
</head>
<body>
<form method="post">
LoginID:
<input type="text" name="login"><br>
Password:
<input type="password" name="pass"><br>
<input type="submit" name="submit" value="Login">
</form>
</body>
</html>
then the user is redirected back to the page he visited. it workd fine
in firefox and msn explorer. in internet explorer, when i visit to a
link in any page it asks for the login details again. could anyone
please help me out?!
--- End Message ---
--- Begin Message ---
Hi, i am having problem with internet explorer. i am working on a
project on building a website where i need to keep track of the users
i.e. i use a login system in there in short. with the following code i
check whether the user is logged in or not.
<?php
session_start();
$_SESSION['myurl']=$_SERVER['PHP_SELF'];
if(!isset($_SESSION['student_username']) &&
!isset($_SESSION['student_password']))
header("Location: login.php");
?>
if the user is not logged in, it redirects to the login page login.php
as is shown in the above code. now the user is allowed to log in
through the following code:
<?php
session_cache_limiter('private_no_expire');
session_set_cookie_params(0,"/","schools.zenrays.com");
session_start();
if(isset($_POST['submit'])){
include("../database.inc");
$login=trim($_POST['login']);
$pass=trim($_POST['pass']);
$Effectivelogin=strtoupper($login);
$auth=false;
$connection=mysql_connect($host,$user,$password);
mysql_select_db($database,$connection);
$query="SELECT password FROM students WHERE userID='$Effectivelogin'";
$result=mysql_query($query);
if(mysql_num_rows($result)){
while($row=mysql_fetch_array($result))
{
if($row[0]!=$pass)
echo ("Wrong Username/Password!");
else
$auth=true;
}
}
if($auth){
$_SESSION["student_username"]=$Effectivelogin;
$_SESSION["student_password"]=$pass;
if(isset($_SESSION['myurl']))
header("Location: http://schools.zenrays.com".$_SESSION['myurl']);
else
header("Location: http://schools.zenrays.com/students");
}
}
?>
<html>
<head>
<title>User Authentication</title>
</head>
<body>
<form method="post">
LoginID:
<input type="text" name="login"><br>
Password:
<input type="password" name="pass"><br>
<input type="submit" name="submit" value="Login">
</form>
</body>
</html>
then the user is redirected back to the page he visited. it workd fine
in firefox and msn explorer. in internet explorer, when i visit to a
link in any page it asks for the login details again. could anyone
please help me out?!
--- End Message ---
--- Begin Message ---
Hi, i am having problem with internet explorer. i am working on a
project on building a website where i need to keep track of the users
i.e. i use a login system in there in short. with the following code i
check whether the user is logged in or not.
<?php
session_start();
$_SESSION['myurl']=$_SERVER['PHP_SELF'];
if(!isset($_SESSION['student_username']) &&
!isset($_SESSION['student_password']))
header("Location: login.php");
?>
if the user is not logged in, it redirects to the login page login.php
as is shown in the above code. now the user is allowed to log in
through the following code:
<?php
session_cache_limiter('private_no_expire');
session_set_cookie_params(0,"/","schools.zenrays.com");
session_start();
$auth=false;
................
................
................
if($auth){
$_SESSION["student_username"]=$Effectivelogin;
$_SESSION["student_password"]=$pass;
if(isset($_SESSION['myurl']))
header("Location: http://schools.zenrays.com".$_SESSION['myurl']);
else
header("Location: http://schools.zenrays.com/students");
}
it works fine in firefox and msn explorer. in internet explorer, when
i visit to a
link in any page it asks for the login details again. could anyone
please help me out?!
regards,
sunaram
--- End Message ---
--- Begin Message ---
On 11 Nov 2005, at 11:43, sunaram patir wrote:
it works fine in firefox and msn explorer. in internet explorer, when
i visit to a
link in any page it asks for the login details again. could anyone
please help me out?!
It just sounds like you have cookies disabled or not allowed for this
site in IE.
Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
[EMAIL PROTECTED] | http://www.synchromedia.co.uk
--- End Message ---
--- Begin Message ---
sunaram patir wrote:
Hi, i am having problem with internet explorer. i am working on a
project on building a website where i need to keep track of the users
i.e. i use a login system in there in short. with the following code i
check whether the user is logged in or not.
<?php
session_start();
$_SESSION['myurl']=$_SERVER['PHP_SELF'];
if(!isset($_SESSION['student_username']) &&
!isset($_SESSION['student_password']))
header("Location: login.php");
It might not fix your problem but you should exit after location header.
--- End Message ---