php-general Digest 9 Jan 2004 09:50:14 -0000 Issue 2520
Topics (messages 174065 through 174095):
open_basedir clarification
174065 by: Matt Grimm
174082 by: Matt Grimm
Re: php on linux..
174066 by: memoimyself.yahoo.com.br
Content-type vs session_start()
174067 by: Børge Strand
174068 by: Brad Pauly
174069 by: Chris Shiflett
post vars not by form
174070 by: Nabil
174073 by: Matt Matijevich
174074 by: Chris Shiflett
174078 by: Justin Patrin
upload and RENAME picture
174071 by: Matt Hedges
174072 by: Matt Matijevich
174084 by: Bossek
Help parsing text file?
174075 by: Carlton L. Whitmore
174077 by: Brad Pauly
174088 by: David Robley
Please help with mail function
174076 by: Rolf Berkenbosch
Buffalo'ed, stumped, confused...
174079 by: Robin Kopetzky
174080 by: Richard Davey
174081 by: John W. Holmes
Re: php5 overload()
174083 by: Marek Kilimajer
php_hostconnect()
174085 by: Anthony Ritter
php.ini config on 4.3.4
174086 by: Turbo
174087 by: John W. Holmes
detecting flash in php
174089 by: Louie Miranda
174090 by: Leif K-Brooks
174091 by: Paul Chvostek
Please check this program (its working)
174092 by: Ryan A
XML?
174093 by: Jake McHenry
Rsvp/invite script?
174094 by: Dustin Choe
critical case, please read and comment !!
174095 by: Nabil
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 ---
If my server has an open_basedir restriction in place for my home directory,
I understand that to mean I can only open files in the same directory as
whatever script is currently running. Is that correct?
--
Matt Grimm
Web Developer
The Health TV Channel, Inc.
(a non - profit organization)
3820 Lake Otis Parkway
Anchorage, AK 99508
907.770.6200 ext. 686
907.336.6205 (fax)
E-mail: [EMAIL PROTECTED]
Web: www.healthtvchannel.org
--- End Message ---
--- Begin Message ---
Can anyone clarify this for me? Is open_basedir recursive or restricted to
the exact paths specified?
--
Matt Grimm
"Matt Grimm" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> If my server has an open_basedir restriction in place for my home
directory,
> I understand that to mean I can only open files in the same directory as
> whatever script is currently running. Is that correct?
>
> --
> Matt Grimm
> Web Developer
> The Health TV Channel, Inc.
> (a non - profit organization)
> 3820 Lake Otis Parkway
> Anchorage, AK 99508
> 907.770.6200 ext. 686
> 907.336.6205 (fax)
> E-mail: [EMAIL PROTECTED]
> Web: www.healthtvchannel.org
--- End Message ---
--- Begin Message ---
Hello Khoa,
On 8 Jan 2004 at 0:13, khoa vo wrote:
> <--------index.html---------->
> <form action="action.php" method="POST">
> Your name: <input type="text" name="name" />
> <input type="submit">
> </form>
That's fine, but that's not what you have up on your web space. Your form is pointing
to
action.html, not action.php.
> <--------action.php---------->
> #!/lusr/bin/php
> Hi <?php echo $_POST["name"]; ?>.
Ok, you don't need the first line (#!/lusr/bin/php), because this is a script for the
web and
will be processed by the web server. But you do need to save the file action.php with
the
".php" suffix. I've just checked your online pages and your form is being sent to
"action.html", not "action.php", so the PHP code is not being processed, because your
web server doesn't look for PHP code in HTML files.
I had a look at the source of your action.html file and it's like this:
<html>
Hi. Your name is <?php phpinfo(); echo $_POST["name"]; ?>.
</html>
The phpinfo() function is going to print a long list of information about PHP on the
server, so you might want to remove that.
So, to recap, you need to change the action attribute in your index.html file to
"action.php", and then rename the file action.html to action.php (and maybe remove the
phpinfo() function while you're at it). That should do the trick.
Good luck,
Erik
--- End Message ---
--- Begin Message ---
I have a problem with html headers using sessions. I guess it has to
do with the Content-type line. My ISP uses PHP 4.3.4 with
register_globals = On (although I want this to work with Off too).
My program (test3.cgi, test3.php) simply logs the number of times I
have accessed a web site. As a php file it works as supposed to only
that there's no Content-type line.
As a .cgi file the script has to have the Content-type line in order
to be executed. With Content-type BEFORE session_start(), $_SESSION
doesn't seem to be set. Alternatively, with Content-type AFTER
session_start(), I get "Warning: session_start(): Cannot send session
cookie - headers already sent by..."
Do you have any ideas what I should do to make both .php and .cgi
versions work?
--
Børge
Here's test3.cgi:
======================================================
#! /usr/local/bin/php
<?php
print 'Content-type: text/html' . "\n\n";
session_start();
print '<html>' . "\n";
print '<body>' . "\n";
print 'This is the test3.cgi file<br>' . "\n";
if (!isset($_SESSION['count']))
{
$_SESSION['count'] = 0;
}
else
{
$_SESSION['count']++;
}
print 'This is your visit number ' . $_SESSION['count'] . "\n";
print '</body>' . "\n";
print '</html>' . "\n";
?>
======================================================
And test3.php:
======================================================
<?php
session_start();
// print 'Content-type: text/html' . "\n\n"; // only in .cgi version!
print '<html>' . "\n";
print '<body>' . "\n";
print 'This is the test3.php file<br>' . "\n";
if (!isset($_SESSION['count']))
{
$_SESSION['count'] = 0;
}
else
{
$_SESSION['count']++;
}
print 'This is your visit number ' . $_SESSION['count'] . "\n";
print '</body>' . "\n";
print '</html>' . "\n";
?>
======================================================
--- End Message ---
--- Begin Message ---
On Thu, 2004-01-08 at 14:14, BÃrge Strand wrote:
[snip]
> Do you have any ideas what I should do to make both .php and .cgi
> versions work?
> Here's test3.cgi:
> ======================================================
> #! /usr/local/bin/php
> <?php
> print 'Content-type: text/html' . "\n\n";
> session_start();
Have you tried putting session_start() before the first print?
- Brad
--- End Message ---
--- Begin Message ---
--- Børge Strand <[EMAIL PROTECTED]> wrote:
> I have a problem with html headers using sessions.
I think you mean HTTP headers.
> I guess it has to do with the Content-type line.
Yes, and you seem to have a fundamental misunderstanding between using PHP
as an Apache module versus using PHP as a CGI interpreter.
I will try to explain using your code:
> Here's test3.cgi:
> ======================================================
> #! /usr/local/bin/php
> <?php
> print 'Content-type: text/html' . "\n\n";
When you are running as a CGI, you can set the Content-Type header in this
way. However, as soon as you send two sequential newlines, you are
indicating the end of the headers and the beginning of the content.
> session_start();
So, when you have this on the next line, PHP cannot set the Set-Cookie
header that it is likely trying to set (in addition to whatever
cache-related headers it may be setting, depending on your configuration).
This is because you have already indicated the end of the headers in your
previous line. This is the danger in writing your own headers in this way;
you become responsible for adhering to the proper format of things.
> And test3.php:
> ======================================================
> <?php
> session_start();
> // print 'Content-type: text/html' . "\n\n"; // only in .cgi version!
While it's not necessary to specify Conetnt-Type here, you can do so using
the header() function:
header('Content-Type: text/html');
Anything that you print or echo is going to be considered as part of the
content, not part of the headers.
Hope that helps.
Chris
=====
Chris Shiflett - http://shiflett.org/
PHP Security Handbook
Coming mid-2004
HTTP Developer's Handbook
http://httphandbook.org/
--- End Message ---
--- Begin Message ---
HI,
Anyone can help , how to post variables from server side .. as from php page
to other without HTML form and submistion ???
i want post method , to post my vars to another php on another server , then
i have to read the body that will be printed by fopen ... so i can not use
Location:
example :
i wwant to post to www.example.com?var=1&var2=2
and then read the the body from that link .. as 1 or 0 ..
Regards
--- End Message ---
--- Begin Message ---
[snip]
Anyone can help , how to post variables from server side .. as from php
page
to other without HTML form and submistion ???
[/snip]
I have never used it but I think
http://pear.php.net/package/HTTP_Client is what you want to look at
--- End Message ---
--- Begin Message ---
--- Matt Matijevich <[EMAIL PROTECTED]> wrote:
> [snip]
> Anyone can help , how to post variables from server side .. as from php
> page to other without HTML form and submistion ???
> [/snip]
>
> I have never used it but I think http://pear.php.net/package/HTTP_Client
> is what you want to look at
You can also do it manually, if you like. Here is an example:
http://shiflett.org/hacks/php/http_post
Hope that helps.
Chris
=====
Chris Shiflett - http://shiflett.org/
PHP Security Handbook
Coming mid-2004
HTTP Developer's Handbook
http://httphandbook.org/
--- End Message ---
--- Begin Message ---
Nabil wrote:
HI,
Anyone can help , how to post variables from server side .. as from php page
to other without HTML form and submistion ???
i want post method , to post my vars to another php on another server , then
i have to read the body that will be printed by fopen ... so i can not use
Location:
example :
i wwant to post to www.example.com?var=1&var2=2
and then read the the body from that link .. as 1 or 0 ..
Regards
You can use PEAR's HTTP_Request class to post vars to a site (and a lot
more). You could also use HTTP_Client if you need things like cookie
management.
http://pear.php.net/package/HTTP_Request
http://pear.php.net/package/HTTP_Client
--
paperCrane <Justin Patrin>
--- End Message ---
--- Begin Message ---
Hello,
thanks to ya'll I've gotten a picture uploaded... but now what I can't
figure out how to do is rename it. I want to rename it something like
$id.extension... right now it is just showing up in the directory as the
original file... any ideas?
thanks
matt
--- End Message ---
--- Begin Message ---
[snip]
any ideas?
[/snip]
Have you tried move_uploaded_file?
http://www.php.net/move_uploaded_file
--- End Message ---
--- Begin Message ---
use funciton rename
http://si2.php.net/manual/en/function.rename.php
rename($old,$new) or die("can't do that!");
"Matt Hedges" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello,
>
> thanks to ya'll I've gotten a picture uploaded... but now what I can't
> figure out how to do is rename it. I want to rename it something like
> $id.extension... right now it is just showing up in the directory as the
> original file... any ideas?
>
> thanks
> matt
--- End Message ---
--- Begin Message ---
I'm very new to PHP.
I want to display /var/log/lastlog with php on a webpage, but I need
some help. How do I do that?
Looking at the docs it looks like file() would work, but I couldn't get
it to display the file.
Carlton.
--- End Message ---
--- Begin Message ---
On Thu, 2004-01-08 at 16:27, Carlton L. Whitmore wrote:
> I'm very new to PHP.
> I want to display /var/log/lastlog with php on a webpage, but I need
> some help. How do I do that?
> Looking at the docs it looks like file() would work, but I couldn't get
> it to display the file.
I would guess that this is because the user that your web server is
running as (usually www or nobody or apache; you can find out by looking
in your httpd.conf file) does not have read access to that file.
Out of curiosity, why do you want to read that file? I would suggest
creating a cron job that runs the lastlog command and writes the results
to a file that is readable by the user that the web server is running
as. If you want the information to be more up to date, you could make
that user a 'sudoer' and run the lastlog command via shell_exec(). I
would be cautious about giving that kind of privileges though.
- Brad
--- End Message ---
--- Begin Message ---
In article
<[EMAIL PROTECTED]>,
[EMAIL PROTECTED] says...
> I'm very new to PHP.
> I want to display /var/log/lastlog with php on a webpage, but I need
> some help. How do I do that?
> Looking at the docs it looks like file() would work, but I couldn't get
> it to display the file.
> Carlton.
>
>
>
lastlog isn't actually a text file. You'ld need to use the lastlog program
to parse it for you and then output the result.
Having said that, I wonder if you are really looking for the output of
last (driven from wtmp) which will give you a complete login history,
rather than the info available from lastlog?
Cheers
--
Quod subigo farinam
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet?
--- End Message ---
--- Begin Message ---
Hello all,
I have a big problem with the mail function in a php script.
If I run this script with root access, the mail function is working.
If I try to run it like http://www.i-s-u.nl/test.php it won't work.....
What is happening, what can I do???
Below the little script:
<?
mail("[EMAIL PROTECTED]", "onderwerp", "test test test",
"[EMAIL PROTECTED]");
?>
Thanks,
Rolf
--- End Message ---
--- Begin Message ---
Good evening.
I'm trying to read using $_POST, 4 radio buttons named "miles". I tried
reading the selected value with $_POST['miles[0]'], etc. with no success.
I've even tried using foreach to read the selected radio button with no
success.
Help!! I'm totally stumped with this one. I thought the value was passed
back as an array but maybe I'm wrong...
Robin 'Sparky' Kopetzky
Black Mesa Computers/Internet Service
Grants, NM 87020
--- End Message ---
--- Begin Message ---
Hello Robin,
Friday, January 9, 2004, 12:31:16 AM, you wrote:
RK> I'm trying to read using $_POST, 4 radio buttons named "miles". I tried
RK> reading the selected value with $_POST['miles[0]'], etc. with no success.
Radio buttons can only have 1 eventual outcome (hence the whole point
of them) and you can access it with:
$_POST['miles'][0]
Checkboxes are different and will require [] added to the form field
name.
--
Best regards,
Richard mailto:[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Robin Kopetzky wrote:
I'm trying to read using $_POST, 4 radio buttons named "miles". I tried
reading the selected value with $_POST['miles[0]'], etc. with no success.
I've even tried using foreach to read the selected radio button with no
success.
It's just $_POST['miles']. :)
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Alex Crivat wrote:
Hallo,
I;ve just installed php5 and found that overload() function does not
work. Actually it does not exist...I get this error :
Fatal error: Call to undefined function overload() in
/usr/share/pear/DB/DataObject.php on line 2889
Any ideas ?
10x
overload is the standard behavior in php5, there's no need to call the
function. The developers could keep the function for backward compatibility.
--- End Message ---
--- Begin Message ---
I currently have websites with two ISP's.
I am getting a lot of warnings throughout a .php script on one server - such
as:
php_hostconnect()
I have used the _same_ .php script exactly on my other ISP's server and I
don't get any warnings.
In addition, I have tested this script locally on Apache server without any
errors.
The site where I do not get warnnings has php 4.1.1 installed - wheras the
other site where I get php_hostcoonect() warnings is php 4.2.3
Any help will be greatly appreciated.
Thank you.
Tony Ritter
--- End Message ---
--- Begin Message ---
Hi....
I use windows Xp,apache,php 4.3.4.I can recieve variable from form by
$_POST[''] (Short Term).But i can not recieve variable from form by
$HTTP_POST_VARS[''] (Long Term).Include other recieve variable (
GET,SESSION,COOKIE).
How to customize config?
Matrix....
--- End Message ---
--- Begin Message ---
Turbo wrote:
I use windows Xp,apache,php 4.3.4.I can recieve variable from form by
$_POST[''] (Short Term).But i can not recieve variable from form by
$HTTP_POST_VARS[''] (Long Term).Include other recieve variable (
GET,SESSION,COOKIE).
Yes you can. Let me use my crystal ball and guess that you're using
$HTTP_POST_VARS inside of a function or class method. Because of
variable scope, it's not available there unless you pass the values to
the function/method or make it global.
If that's not it... you need to explain more.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
is there anyway of detecting flash? in php
-- -
Louie Miranda
http://www.axishift.com
--- End Message ---
--- Begin Message ---
Louie Miranda wrote:
is there anyway of detecting flash? in php
Detecting whether the user has Flash enabled, you mean? No. PHP is
server-side.
--- End Message ---
--- Begin Message ---
On Fri, Jan 09, 2004 at 01:11:38PM +0800, Louie Miranda wrote:
>
> is there anyway of detecting flash? in php
Not really. But you're not completely out in the cold.
Note that PHP runs on the server, so any test you do has to be offloaded
to the client side. Use Javascript for this. Use MING to build your
Flash content. :)
<script type="text/javascript" language="JavaScript"><!--
FlashMode = 0;
if (navigator.plugins && navigator.plugins.length > 0) {
if (navigator.plugins["Shockwave Flash"]) {
var plugin_version = 0;
var words = navigator.plugins["Shockwave Flash"].description.split(" ");
for (var i = 0; i < words.length; ++i) {
if (isNaN(parseInt(words[i])))
continue;
plugin_version = words[i];
}
if (plugin_version >= 5) {
var plugin = navigator.plugins["Shockwave Flash"];
var numTypes = plugin.length;
for (j = 0; j < numTypes; j++) {
mimetype = plugin[j];
if (mimetype) {
if (mimetype.enabledPlugin && (mimetype.suffixes.indexOf("swf") != -1))
FlashMode = 1;
// Mac wierdness
if (navigator.mimeTypes["application/x-shockwave-flash"] == null)
FlashMode = 0;
}
}
}
}
}
if (FlashMode == 1) {
// do your flash stuff... For example:
document.write(' <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,30,0">\n');
document.write(' <param name=movie
value="http://yourdomain.ca/foo.swf"><param name=quality value=high><param
name="BGCOLOR" value="#EEEEEE"><param name="salign" value="tl"><param name="menu"
value="0">\n');
document.write(' <embed src="http://yourdomain.ca/foo.swf" quality=high
pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
type="application/x-shockwave-flash"></embed>\n');
document.write(' </object>\n');
} else {
document.write("<p>Sorry, this page requires Flash.");
}
// --></script>
<noscript>Sorry, this page requires JavaScript</noscript>
--
Paul Chvostek <[EMAIL PROTECTED]>
it.canada http://www.it.ca/
Free PHP web hosting! http://www.it.ca/web/
--- End Message ---
--- Begin Message ---
Hi,
I dont know if this is the right way to do this, so please have a looksee
and tell me.
Its working perfectly well...but will I have problems if I try it on a large
email list or
will it hog resources....etc? ANY advice appreciated.
<?php
$hostt="localhost"; $userr="ryan"; $passs="pass"; $db="test";
$connected=mysql_connect ("$hostt", "$userr", "$passs") or die ('DB error: '
. mysql_error());
mysql_select_db ("$db");
$query = "SELECT * FROM testEmail";
$result = mysql_query($query) or die("Error: " . mysql_error());
if($result)
{
while($row = mysql_fetch_row($result))
{ $the_email = $row[0];
echo "Mailing: ".$the_email."<br>";
$subject = "Test subject";
$mailcontent = "blah blah blah blah blah";
$mail_from="Ryan the great <[EMAIL PROTECTED]>";
$headers="From: ".$mail_from."\n"."Return-Path:
".$mail_from."\n"."Reply-To: ".$mail_from."\n";
mail($the_email,$subject,$mailcontent,$headers); }
}else{echo "no result";}
?>
The reason I used mysql_fetch_row is I thought I might make it more
personalized a bit later...to greet each
person in my database by name.
Thanks,
-Ryan
--- End Message ---
--- Begin Message ---
Hi everyone,
Can someone point me in the right direction towards creating and
implementing XML with php? I've heard it can make things much easier
on me, and would like more info on it. Also, if anyone has any storys
from using it, might give me an idea of what I'm getting into. Is it
easy to implement? Does it make things easier on me in the future?
Etc.etc.
Thanks,
Jake McHenry
Nittany Travel MIS Coordinator
http://www.nittanytravel.com
--- End Message ---
--- Begin Message ---
I have checked hotscripts/resourceindex/etc, but to no avail. I am looking
for a script where I can have several meetings and having members rsvping
which meeting they can attend.
Thanks
--
Dustin Choe
http://www.dchoe.com
--- End Message ---
--- Begin Message ---
I have the following example case:
1- More than 1000 record in my MySQL database.
2- I have to submit those record via HTTP GET or POST method.
3- I have to read the confirmation message that will be printed on the
remote page showing me that the vars have been inserted in the remote
database.
4- of course, I have a limitation of executing time of 30 seconds and i
should not modify the php.ini
i did the following scenario :
<?php
function send_rec($var1 , $var2 ,$var3 ){
$handle =
fopen("http://anotherwebserver/url2.php?var1=$var1$var2=$var2&var3=$var3",
"r") ;
$data = fread($handle, 11);
fclose($handle);
if ($data == $var1) return true; else return false;
}
for ($i=0 ; $i<NUM OF RECORDS ; $i++)
{
send_rec( $var1 , $var2 , $var3 );
}
?>
1-the problem is that the 30 second of execution time expired before i can
send even 200 records.
2- in case of not connection of the remote page, and i did not get the $var1
printed ($data == $var1) then i have to re submit this record.
Regards
--- End Message ---