RE: [PHP] help me plz

2006-01-20 Thread Thomas

Hey Suresh,

You could use AJAX to populate your dropwdown boxes without reloading your
browser. I used something like that in a project just now.

Essentially, you will call a php script that would select your second box's
data according to the value of the first.

You can also do this with javascript (if you do not need 'fresh' data)

Thomas

-Original Message-
From: Robert Graham [mailto:[EMAIL PROTECTED] 
Sent: 19 January 2006 09:34 AM
To: suresh kumar
Cc: php-general@lists.php.net
Subject: Re: [PHP] help me plz

suresh kumar wrote:
> hi,
>i am using 2 combo box one for country & another
> one for city.when i select country name from combo box
> their corresponding city names has to be changed in
> their corresponding combo box.i dont know how 2
> implement this.pz give me some idea.its urgent.
>   A.suresh
>
> Send instant messages to your online friends http://in.messenger.yahoo.com

>
>   
Hi Suresh

Have a look at QuickForm ( PEAR Module), and make use of the HierSelect 
option.
Have a look at the following page for more info:  
http://www.thelinuxconsultancy.co.uk/quickform.php

Regards
Robert

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

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



[PHP] Re: reading variables?

2006-01-20 Thread David Dorward
William Stokes wrote:

> For each printed document there's a check box "Delete" for
> marking that document for deletion. The document info from DB is printed
> using 'while' loop. The only problem I have is that I don't know how to
> handle/read the Delete checkbox values because the checkbox name is
> different for each file. Checkboxes are printed whit this line:"echo " colspan=\"5\">Delete";"

Well, it is possible to look at all the fields which match the regular
expression /del_[0-9]+/, but you would probably be better off just doing
something like this:

   
   Delete

And then accessing the $_POST['del'][] array that PHP will represent that
as.

-- 
David Dorward      
 Home is where the ~/.bashrc is

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



Re: [PHP] Determining number of days in a selected month

2006-01-20 Thread Jesús Fernández
You could also use the well known date() function to do that.
Here's the doc http://www.php.net/manual/en/function.date.php
Look for the format character "t", it wil give you the number of days of the
month you give it as timestamp.



--
Esú - http://esu.proyectoanonimo.com
http://www.proyectoanonimo.com


[PHP] Creating protected Excel files from PHP

2006-01-20 Thread Karl-Heinz Christian Zeck
Hi,

I would like to know if any from you guys have a solution to my problem. I
use PHP and a PEAR class (PEAR::Spreadsheet_Excel_Writer) to generate some
reports as Excel files. My problem is that I want these files to be
protected with a password (because these reports will be downloaded to the
user's computer, and they must be unaccessible to someone else). I know you
can set up a password for an excel file, but I don't know if you can
accomplish this with PHP. If you know how to do this (or if this can be
done) please let me know. Thanks!


Re: [PHP] php5.0.5 include() terminates script BUGBUGBUGBUG

2006-01-20 Thread Jochem Maas

please don't mail me off list.

[EMAIL PROTECTED] wrote:

thanx jochem maas
mmm... it is still a mystery  i wrote a piece of debugging code to 
see if the file is readable or accessable via php...


//$yourInclude = include("phpinfo.php");
$yourInclude = 'phpinfo.php';
if (file_exists($yourInclude)) {


this tells you the file exists. but is it readable?
or if is it valid php (ie. does it contain syntax errors
or not).

the same goes for each file that gets included.

morew investigation to do me thinks


  echo "The file $yourInclude exists";
  exit;
} else {
  echo "The file $yourInclude does not exist";
  exit;
}

the first and second line you can alter it or just switch between 
pending if you want it to display the file or just to tell you if it 
exists or not so...applying this code just before my include 
statments all verifys ok(thats the file exists) if i use line 1 
nothing appearsit says the file exists according to line 2 yet it 
wont display??? of course i REM either line out 
accordingly.so...the register page starts with an include called 
session.php in that session.php i have another 3 includes... 
mailer.php,database.php and form.php each tested for line 2 and ok but 
not for line 1 nothing appears if i move that phpinfo.php file around 
into those directories(folders and subfolders) and test it then it ok's 
for line 1 i get a display and ok for line 2 too. but of course 
phpinfo.php when called doesnt have another include statement in it... i 
really cant explain it perhaps php 5.0.5 doesnt support multiple include 
statementsstrange???


thats just silly.

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



[PHP] date("H", $datevalue) always adds an hour?

2006-01-20 Thread Murray @ PlanetThoughtful

Hi All,

Wondering if anyone can help me work out why date("H") always adds an 
hour? I'm *assuming* it thinks it should be compensating for Daylight 
Saving Time (though I'd be just as willing to believe that it's caused 
by something else), however we don't observe DST in Queensland, Australia.


Making matters a little more complex, while my local machine shouldn't 
be compensating for DST (if that's what's happening), my remote machine 
(based in Florida somewhere, I think) should, when applicable.


So, just to explain a little better.

Let's say the clock on my computer reads 7:00pm. If I do "echo 
date("H");" it will output "20", instead of "19".


The same thing happens if I take a date value from my mysql database.

$sql = "SELECT UNIX_TIMESTAMP(datecreated) AS unx_date FROM mytable;"
$rs = mysql_query($sql);
$row = mysql_fetch_object($rs);
echo date("H", $row->unx_date);

If the above record contained the value '2006-01-10 19:00', the code 
would output "20" instead of "19".


Can anyone help me figure out how to accommodate for this?

Much warmth,

Murray

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



Re: [PHP] date("H", $datevalue) always adds an hour?

2006-01-20 Thread David Grant
Murray,

What do you get if you print date("T")?

David
-- 
David Grant
http://www.grant.org.uk/

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



Re: [PHP] date("H", $datevalue) always adds an hour?

2006-01-20 Thread Murray @ PlanetThoughtful

On 20/01/2006 8:39 PM, David Grant wrote:

Murray,

What do you get if you print date("T")?

David
  

Hi David,

I get "EST", which I assume is "Eastern Savings Time"? If that's the 
case, any idea where I change this value so that it only affects my 
local machine?


Much warmth,

Murray

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



Re: [PHP] date("H", $datevalue) always adds an hour?

2006-01-20 Thread David Grant
Murray,

As far as I know, Queensland is in EST (Eastern Standard Time), so that
is the correct value.  Are you using the same machine or is it remote?

David
-- 
David Grant
http://www.grant.org.uk/

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



Re: [PHP] date("H", $datevalue) always adds an hour?

2006-01-20 Thread Murray @ PlanetThoughtful

On 20/01/2006 8:48 PM, David Grant wrote:

Murray,

As far as I know, Queensland is in EST (Eastern Standard Time), so that
is the correct value.  Are you using the same machine or is it remote?

David
  

Hi David,

I'm currently working entirely on my local (Queensland) machine. The 
remote machine only becomes an issue when I'm finished putting the site 
together.


Thanks for giving this some thought...

Murray

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



Re: [PHP] date("H", $datevalue) always adds an hour?

2006-01-20 Thread David Grant
Murray,

I can't think what else it might be.  Sorry!

David
-- 
David Grant
http://www.grant.org.uk/

http://pear.php.net/package/File_Ogg0.2.1
http://pear.php.net/package/File_XSPF   0.1.0

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



Re: [PHP] date("H", $datevalue) always adds an hour?

2006-01-20 Thread Silvio Porcellana [tradeOver]

David Grant wrote:

Murray,

I can't think what else it might be.  Sorry!

David


What does

date("I", $datevalue)

return? (it's a capital 'i')

I guess you already checked out this page...
http://php.net/date

--
tradeOver | http://www.tradeover.net
...ready to become the King of the World?

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



Re: [PHP] URL -> stream context

2006-01-20 Thread Jochem Maas

I think you need to create a stream context resource with:

http://www.php.net/manual/en/function.stream-context-create.php

set the options you need on it with:
http://www.php.net/manual/en/function.stream-context-set-option.php

then pass the resource as the 4th arg to fopen() (rather passing in an array)


...i think

Richard Lynch wrote:

On Thu, January 19, 2006 4:08 pm, Geoff wrote:


I honestly have no idea if this would work, but maybe fopen supports
non-blocking connections?



Not as far as I can tell...

You can call stream_set_blocking after it's open, but that doesn't
help a slow connection in the first place.



Or creation of context-based connections
(for which you can use stream_set_blocking).



Unless I'm seriously mis-reading docs, stream_set_blocking can only be
called on an already-open stream, not on the soon-to-be-opened stream.

fopen() in PHP5 does take a context, and if I could figure out how to
embed the concepts of "do not block" and "timeout in $x seconds"
within a context from the docs, and if fopen() would still handle all
the details of the various protocols, I'd be all set...

That's sort of what I was asking for in the original email, but...

It seems like you have to specify the 'scheme' as the key in the
context array.

So, I guess, I could, in theory, find a listing of all the schemes
fopen() supports, which might even be in a function, iterate over all
of those, and do something like:
$schemes = function_that_returns_all_schemes_fopen_supports();
$opts = array();
foreach($schemes as $scheme){
  $opts[$scheme]['some_magic_undocumented_thing'] =
STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_CONNECT ;
}

$foo = fopen($url, 'r', false, $opts);
if ($foo == false) $errors[] = "$url timed out";

Only problem is, these constants are documented ONLY to work with:
http://www.php.net/manual/en/function.stream-socket-client.php
and that pretty clearly is working at a much lower-level than fopen
(and friends) as the very first example shows using TCP as a protocol,
and then you have to send the GET and any other headers, which is
exactly what I'm trying to avoid having to re-code in the first place.

So I'm back to square one, as far as I can see from the docs...

It's possible (still) that I'm just mis-reading docs, or am
continually skipping over the one new page in 'streams' that is making
everybody think this should be so simple, but I don't think so, since
I've read EVERY page in the new streams section several times now.

I'm not claiming 100% comprehension of every implication on every
page, mind you :-)



If so, you could take a
stamp of the current time plus a timeout value, make the fopen call
(which would return immediately) then wait politely (I mean that
from a CPU perspective) in a loop until you have data, or the
current time goes past your time stamp.



Yes -- if I could compose a stream_context doohickey that convinced
fopen() to use a time-out...



Another avenue for investigation might be to try file_get_contents
to see if it's connection timeout can be controlled. It seems to
work in a similar way to fopen, in terms of having wrappers that are
aware of multiple resource types.



file_get_contents() seems to suffer from the exact same limitations of
file()

I get the simplicity of fopen() with no control over connection timeout.

Maybe there is some underlying voodoo going on in the PHP internals
that some makes it crystal-clear why that has to be, but to this naive
user, if fsockopen can have a timeout, fopen and friends out to be
able to also, at least for schemes that support such a thing.

Obviously SOME kind of timeout is involved somewhere in fopen()
because it WILL timeout on some sites sometimes, even though
experimentation has shown that had it waited, it would have gotten
data eventually.



It might also be worth taking a look at cURL or similar libraries
that are also multi-resource aware, but give you greater control of
connections parameters and timeouts.



Maybe I've been mis-using cURL all these years, but it doesn't seem to
be anywhere near as simple as the mythical function I've described,
and really not much better than a giant switch for fsockopen to
duplicate all that code that's gotta be down in the guts of fopen (and
friends)



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



[PHP] fsockopen, openssl error

2006-01-20 Thread James Benson
Im running into the followng error when trying to use fsockopen with the 
openssl extension,




Warning: fsockopen(): php_stream_sock_ssl_activate_with_method: failed 
to create an SSL context


Warning: fsockopen(): failed to activate SSL mode 1

Socket Error: Operation now in progress




Anyone have any clues as to what this may be or why its happening?

Perhaps a compile problem, anyway, I probably will try 4.4.0 because ive 
not made any changes to the script for a few months but have upgraded to 
4.4.2 recently then get this error, very suspicious i think?




James

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



RE: [PHP] Embedded Player

2006-01-20 Thread ET Support
You may also want to consider using frames, I've found that method to work
well when I want music to play continuously while a visitor surfs through
the site and it won't get stopped by popup blockers.

As for reducing file size, I found a program called CDex v1.51 to be very
effective... you can adjust the bitrate and that can greatly reduce the file
size... the home page for that was http://cdexos.sourceforge.net/ but seems
they need a new project manager, probably if you google CDex you'll find it.

Ben

-Original Message-
From: Brady Mitchell [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 19, 2006 7:03 PM
To: php-general@lists.php.net
Cc: Jedidiah
Subject: RE: [PHP] Embedded Player


> -Original Message-
> My reason for using an embedded player was basically just for
> design purposes, but perhaps that is not a good idea.  I did
> not consider the fact of not being able to leave the site
> while listening, and since these are as long as 40 minutes,
> this might get annoying.

Perhaps keeping your current setup and adding a link that opens an
embedded player in a popup window would be a good compromise.  That way
people who just want to stream the sermons can do so, and with the
player in a popup window they could still surf the web while listening.

As far as file format, it might be worth looking into using the OGG
Vorbis format.  There are players on Windows/Mac/Linux that support the
format and it uses compression, so the file sizes should be a bit
smaller than mp3s.  Take a look at http://www.vorbis.com/ for more info.

Just some ideas..

Brady

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



[PHP] ftp_get, ftp_put problem

2006-01-20 Thread Antonis Varkas

Hi,

I am writing a php script to upload/download a file onto/from an FTP 
Server. I manage to connect to the server, login correctly, change 
directory, list all the files there but fail to get or put the file.
The documentation says that ftp_get and ftp_put return TRUE or FALSE. In 
my case nothing at all is returned.


Using the following code part, the $test variable is empty

// upload the file
$test = ftp_put($conn_id, $remote_file, $local_file, FTP_BINARY);
if ($test) {
echo "Successfully uploaded $local_file.\n";
} else {
echo "There was a problem while uploading $local_file.\n";
echo("TEST: ".$test."\n");
}
I don't get any warnings.
Does this indicate something I can't figure out ?

Thanks in advance
A.Varkas

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



[PHP] Re: fsockopen, openssl error

2006-01-20 Thread Barry

James Benson wrote:
Im running into the followng error when trying to use fsockopen with the 
openssl extension,




Warning: fsockopen(): php_stream_sock_ssl_activate_with_method: failed 
to create an SSL context


Warning: fsockopen(): failed to activate SSL mode 1

Socket Error: Operation now in progress




Anyone have any clues as to what this may be or why its happening?

Perhaps a compile problem, anyway, I probably will try 4.4.0 because ive 
not made any changes to the script for a few months but have upgraded to 
4.4.2 recently then get this error, very suspicious i think?




James


Seems like he can't start TLS.´

Have you tried a newer version of PHP than 4.4.2?

If so, i would like to know what happened.

Barry

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



Re: [PHP] php5.0.5 include() terminates script BUGBUGBUGBUG

2006-01-20 Thread David Hall

Jochem Maas wrote:



the first and second line you can alter it or just switch between 
pending if you want it to display the file or just to tell you if it 
exists or not so...applying this code just before my include 
statments all verifys ok(thats the file exists) if i use line 1 
nothing appearsit says the file exists according to line 2 yet it 
wont display??? of course i REM either line out 
accordingly.so...the register page starts with an include called 
session.php in that session.php i have another 3 includes... 
mailer.php,database.php and form.php each tested for line 2 and ok but 
not for line 1 nothing appears if i move that phpinfo.php file around 
into those directories(folders and subfolders) and test it then it 
ok's for line 1 i get a display and ok for line 2 too. but of course 
phpinfo.php when called doesnt have another include statement in it... 
i really cant explain it perhaps php 5.0.5 doesnt support multiple 
include statementsstrange???


thats just silly.


it just isn't displaying errors, doing all this nonsense with file 
exists is a waste of time, just add two lines to the top of your script 
(that includes the file):


error_reporting(E_ALL);
ini_set('display_errors','on');

(or set these values in the php.ini if you have access to that)
and look at what that tells you.  You might not understand the error at 
first, but hopefully you will.  My guess is that it will tell you it 
can't parse your included file.


David Hall

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



RE: [PHP] odd behavior SOLVED - MORE & IMPORTANT

2006-01-20 Thread Jay Blanchard
[snip]
>From the offices of "You Ain't Gonna' Beleeeve Dis, Inc."

We barked up several trees, but there were no real squirrels.

PHP 4.4.1, the version on the server in question, comes with 2 flavors of
ini file, the dist and the recommended. I had copied the recommended and
renamed it php.ini, which is the one we have been using all day. I am
standing in the data center cursing and swearing and the network admin says,
"Maybe the ini file is hosed somehow." Of course I said that that could not
be the case. What could possibly be bad in the text file to cause this kind
of behavior?

As the afternoon wore on he kept asking if I could water down the ini file
because it was the placement of that file that caused the problem. Even when
I went the route of changing the environment variable I had problems. I told
him that several of the best minds in the world were working on the problem
and that the ini file could not be at fault really. I wanted to prove to him
that this could not be the case, so I renamed the
recommend->php.ini->php.ini.old and copied the dist version which was
renamed to php.ini. I moved it to the WINNT folder. I stopped and started
IIS. Lo' and behold, the php pages loaded fine, with no 404 error. I made a
change to the ini file. It showed up properly in phpinfo(). Dammit he had a
smug look on his faced when I departed the data center.

Apparently there is something wrong with the 'recommended' version. I will
have to compare them to see the differences so that maybe the problem could
be isolated so that furture users do not encounter the several hours of
frustration that I have encountered. You're all to be praised for your
knowledge and insight. Thank you.
[/snip]

I have found that it is not just with the recommended version. After some
more wrangling this morning I have narrowed it down to the doc_root =
directive in the ini file.

When I moved the 'dist' copy yesterday I had not gone through all of the
manual setup steps, so I had not changed doc_root and the extensions
directory. I set doc_root as follows;

doc_root = E:\sitegrp1

and the behaviors that we discussed yesterday reappeared. Here is the text
surrounding the directive

; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues.  The alternate is to use the
; cgi.force_redirect configuration below
doc_root = 

Is this the mystical "security issues" mentioned above (ihaven't located the
documentation it refers to at this point)? e:\sitegrp1 has several
directories below it, so it is not empty. Anyhow, more to chew on. Thanks
again for everyone's help. My php.ini happily resides in c:\php and is
properly located and parsed since PHPRC was added to the environment
variables (shouldn't this be part of the manual installation steps?).

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



RE: [PHP] New to PHP

2006-01-20 Thread Jay Blanchard
[snip]
I use Xampp because I'm new to all of this also, and it makes setup a
breeze.
http://www.apachefriends.org/en/
This installs Apache, mysql, php, pearl, ftpzilla, all kinds of stuff,
already configured and ready to rock.
It doesn't get any easier.
[/snip]

Here is another one that works well

http://www.devside.net/

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



RE: [PHP] ftp_get, ftp_put problem

2006-01-20 Thread Jay Blanchard
[snip]
I am writing a php script to upload/download a file onto/from an FTP 
Server. I manage to connect to the server, login correctly, change 
directory, list all the files there but fail to get or put the file.
The documentation says that ftp_get and ftp_put return TRUE or FALSE. In 
my case nothing at all is returned.

Using the following code part, the $test variable is empty

// upload the file
$test = ftp_put($conn_id, $remote_file, $local_file, FTP_BINARY);
if ($test) {
echo "Successfully uploaded $local_file.\n";
} else {
echo "There was a problem while uploading $local_file.\n";
echo("TEST: ".$test."\n");
}
I don't get any warnings.
Does this indicate something I can't figure out ?
[/snip]

You may have to set the passive mode, see
http://us2.php.net/manual/en/function.ftp-pasv.php

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



Re: [PHP] ftp_get, ftp_put problem

2006-01-20 Thread Richard Davey

On 20 Jan 2006, at 13:26, Antonis Varkas wrote:

I am writing a php script to upload/download a file onto/from an  
FTP Server. I manage to connect to the server, login correctly,  
change directory, list all the files there but fail to get or put  
the file.
The documentation says that ftp_get and ftp_put return TRUE or  
FALSE. In my case nothing at all is returned.


Do you have access to the FTP server log files? They would show you  
exactly which stage it died at. My guess would be this is a PASV/port  
issue.


Cheers,

Rich
--
http://www.corephp.co.uk
Zend Certified Engineer
PHP Development Services

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



[PHP] New identification after an error...

2006-01-20 Thread David BERCOT
Hi,

I use this program to force a user to authenticate :
if (!isset($_SERVER["PHP_AUTH_USER"])) {
header("WWW-Authenticate: Basic realm=\"Intranet SDSED\"");
header("HTTP/1.1 401 Unauthorized");
}
Everything is ok except a detail : if the user makes a mistake (for
example, a bad password), the variable $_SERVER["PHP_AUTH_USER"] is
initialised.
So, if he wants to do again the above test, another identification won't
happen (because $_SERVER["PHP_AUTH_USER"] is already set).
I've tried :
$_SERVER["PHP_AUTH_USER"] = NULL;
without succes...

Do you have a clue ?

Thank you very much.

David.

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



RE: [PHP] New identification after an error...

2006-01-20 Thread Albert
David BERCOT wrote:
> I use this program to force a user to authenticate :
> if (!isset($_SERVER["PHP_AUTH_USER"])) {
> header("WWW-Authenticate: Basic realm=\"Intranet SDSED\"");
> header("HTTP/1.1 401 Unauthorized");
> }
> Everything is ok except a detail : if the user makes a mistake (for
> example, a bad password), the variable $_SERVER["PHP_AUTH_USER"] is
> initialised.
> So, if he wants to do again the above test, another identification won't
> happen (because $_SERVER["PHP_AUTH_USER"] is already set).
> I've tried :
> $_SERVER["PHP_AUTH_USER"] = NULL;
> without succes...
> 
> Do you have a clue ?



HTH

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.21/235 - Release Date: 2006/01/19
 

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



Re: [PHP] php5.0.5 include() terminates script BUGBUGBUGBUG

2006-01-20 Thread Jochem Maas

David Hall wrote:

Jochem Maas wrote:



the first and second line you can alter it or just switch between 
pending if you want it to display the file or just to tell you if it 
exists or not so...applying this code just before my include 
statments all verifys ok(thats the file exists) if i use line 1 
nothing appearsit says the file exists according to line 2 yet it 
wont display??? of course i REM either line out 
accordingly.so...the register page starts with an include called 
session.php in that session.php i have another 3 includes... 
mailer.php,database.php and form.php each tested for line 2 and ok 
but not for line 1 nothing appears if i move that phpinfo.php file 
around into those directories(folders and subfolders) and test it 
then it ok's for line 1 i get a display and ok for line 2 too. but of 
course phpinfo.php when called doesnt have another include statement 
in it... i really cant explain it perhaps php 5.0.5 doesnt support 
multiple include statementsstrange???



thats just silly.



it just isn't displaying errors, doing all this nonsense with file 
exists is a waste of time, just add two lines to the top of your script 
(that includes the file):


error_reporting(E_ALL);
ini_set('display_errors','on');

(or set these values in the php.ini if you have access to that)
and look at what that tells you.  You might not understand the error at 
first, but hopefully you will.  My guess is that it will tell you it 
can't parse your included file.


right - waste of time - not displaying errors.
I have documented a problem that has existed since php5beta3 - namely under 
certain
conditions (only ever in big codebases in seems) a failed require statement 
will NOT
GENERATE ANY ERRORS REGARDLESS OF THE RELATED INI SETTINGS AND CAUSE THE
ENGINE TO STOP PROCESSING. (you might guess that this problem is a little 
annoying!)

so the OP _may_ be a blithering idiot who hasn't turned on error reporting to
full BUT there is a very good chance that php is borking on one of his 
includes/requires
and crapping out WITHOUT any errors being reporting.

so its seems like it should be nonsense but it reality there is a real issue 
the OP
could walking into.



David Hall



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



Re: [PHP] New identification after an error...

2006-01-20 Thread David Grant
David

David BERCOT wrote:
> I've tried :
> $_SERVER["PHP_AUTH_USER"] = NULL;
> without succes...

http://www.php.net/unset

e.g. unset($_SERVER['PHP_AUTH_USER']);

It might, however, be better practice to used an authorisation state
variable, or something similar, i.e.

if (! $auth) {
// HTTP Headers
}

David
-- 
David Grant
http://www.grant.org.uk/

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



Re: [PHP] New identification after an error...

2006-01-20 Thread Jochem Maas

David BERCOT wrote:

Hi,

I use this program to force a user to authenticate :
if (!isset($_SERVER["PHP_AUTH_USER"])) {
header("WWW-Authenticate: Basic realm=\"Intranet SDSED\"");
header("HTTP/1.1 401 Unauthorized");
}
Everything is ok except a detail : if the user makes a mistake (for
example, a bad password), the variable $_SERVER["PHP_AUTH_USER"] is
initialised.
So, if he wants to do again the above test, another identification won't
happen (because $_SERVER["PHP_AUTH_USER"] is already set).
I've tried :
$_SERVER["PHP_AUTH_USER"] = NULL;
without succes...

Do you have a clue ?


there is also $_SERVER["PHP_AUTH_PWD"] which you can check.
and rather than just checking whether $_SERVER["PHP_AUTH_USER"] is set
why not also check that the contained value is something valid?

you can start by checking that $_SERVER["PHP_AUTH_USER"] is not empty:

if (!isset($_SERVER["PHP_AUTH_USER"]) || empty($_SERVER["PHP_AUTH_USER"])) {
// send headers
}

or (pseudocode):

if (!isset($_SERVER["PHP_AUTH_USER"])
|| empty($_SERVER["PHP_AUTH_USER"])
|| !isValidUserName($_SERVER["PHP_AUTH_USER"]))
{   
// send headers
}



Thank you very much.

David.



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



Re: [PHP] New identification after an error...

2006-01-20 Thread Richard Davey

On 20 Jan 2006, at 14:24, David BERCOT wrote:


I use this program to force a user to authenticate :
if (!isset($_SERVER["PHP_AUTH_USER"])) {
header("WWW-Authenticate: Basic realm=\"Intranet SDSED\"");
header("HTTP/1.1 401 Unauthorized");
}
Everything is ok except a detail : if the user makes a mistake (for
example, a bad password), the variable $_SERVER["PHP_AUTH_USER"] is
initialised.
So, if he wants to do again the above test, another identification  
won't

happen (because $_SERVER["PHP_AUTH_USER"] is already set).
I've tried :
$_SERVER["PHP_AUTH_USER"] = NULL;
without succes...


You could either insert a second check (after the PHP AUTH USER  
isset) along the lines of is_empty(), or just replace the isset with  
is_empty() entirely.


Cheers,

Rich
--
http://www.corephp.co.uk
Zend Certified Engineer
PHP Development Services

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



[PHP] problem encountered with stristr-based function

2006-01-20 Thread George Pitcher
Hi,

I'm having a problem with the following function:

function terms($term,$field){
  if(strlen($term)>0){
if(!stristr($term, $field) === FALSE) {
  $output = str_replace($term, "".$term."", $field);
} elseif(!stristr(strtolower($term), $field) === FALSE) {
  $output = str_replace(strtolower($term),
"".strtolower($term)."", $field);
} elseif(!stristr(strtoupper($term), $field) === FALSE) {
  $output = str_replace(strtoupper($term),
"".strtoupper($term)."", $field);
} elseif(!stristr(ucfirst($term), $field) === FALSE) {
  $output = str_replace(ucfirst($term), "".ucfirst($term)."",
$field);
}
  } else {
$output = $field;
  }
  return $output;
}
I'm not comfortable enough with regex etc, so tried it my way, but no joy.

For info, I am trying to highlight search terms in results.

Any suggestions?

George

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



Re: [PHP] problem encountered with stristr-based function

2006-01-20 Thread David Grant
George,

George Pitcher wrote:
> For info, I am trying to highlight search terms in results.

If you're searching and replacing within HTML, you ought to be aware of
issues if someone's search term happens to be an HTML tag or attribute.
 For example, Alice might search for "href" and get the following:

href="URL">Text

back, which is clearly fubar, which highlights the necessity for some
handy regex skills.  Following a quick google, I found this page:

http://aidanlister.com/repos/?file=function.str_highlight.php

David
-- 
David Grant
http://www.grant.org.uk/

http://pear.php.net/package/File_Ogg0.2.1
http://pear.php.net/package/File_XSPF   0.1.0

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



[PHP] Re: fsockopen, openssl error

2006-01-20 Thread James Benson

Seems like he can't start TLS.´

Have you tried a newer version of PHP than 4.4.2?

If so, i would like to know what happened.

Barry





Just compiled 5.1.2 and 4.4.1, it happended again with 4.4.1 but not 
with 5.1.2, I dont have time to try 4.4.0 but will do later.



One thing i forgot to say is I have recently switched from fedora core 4 
to ubuntu 5.1, would that make any difference?



BTW, Im using apache 2.2.0, openssl 0.9.8a



Thanks,

James

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



Re: [PHP] Determining number of days in a selected month

2006-01-20 Thread tedd

Is there a way to easily tell PHP how many days there are in a selected
month without writing the following out for each month:

if($Month == "January") {
$NumberOfDays = 31;
}
elseif($Month == "February") {
if($Year == "A Leap Year") {
$NumberOfDays = 29;
}
elseif($Year != "A Leap Year") {
$NumberOfDays = 28;
}
}
elseif($Month == "March") {
$NumberOfDays = 31;
}
and so on, and so on, and so on

I would greatly appreciate any help.  Thanks.



Ben:

Try:

$totaldays = date('t',mktime(0,0,0,$month,1,$year));

Works for me.

tedd
--

http://sperling.com/

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



[PHP] Re: fsockopen, openssl error

2006-01-20 Thread Barry

James Benson wrote:

Seems like he can't start TLS.´

Have you tried a newer version of PHP than 4.4.2?

If so, i would like to know what happened.

Barry






Just compiled 5.1.2 and 4.4.1, it happended again with 4.4.1 but not 
with 5.1.2, I dont have time to try 4.4.0 but will do later.



One thing i forgot to say is I have recently switched from fedora core 4 
to ubuntu 5.1, would that make any difference?



BTW, Im using apache 2.2.0, openssl 0.9.8a



Thanks,

James


No doesnt make any difference.

but it really seems that 4.4.2 has some bugs with ssl.
I encounter the same here.

use newer versions. should help then.

Barry

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



RE: [PHP] problem encountered with stristr-based function

2006-01-20 Thread George Pitcher
David,

No html involved. Just db results.

I've found that eregi_replace() does the job adequately, if not perfectly.
Us typesetters are hard to please when it comes to string handling.

Cheers

George

> -Original Message-
> From: David Grant [mailto:[EMAIL PROTECTED]
> Sent: 20 January 2006 2:54 pm
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] problem encountered with stristr-based function
>
>
> George,
>
> George Pitcher wrote:
> > For info, I am trying to highlight search terms in results.
>
> If you're searching and replacing within HTML, you ought to be aware of
> issues if someone's search term happens to be an HTML tag or attribute.
>  For example, Alice might search for "href" and get the following:
>
> href="URL">Text
>
> back, which is clearly fubar, which highlights the necessity for some
> handy regex skills.  Following a quick google, I found this page:
>
> http://aidanlister.com/repos/?file=function.str_highlight.php
>
> David
> --
> David Grant
> http://www.grant.org.uk/
>
> http://pear.php.net/package/File_Ogg0.2.1
> http://pear.php.net/package/File_XSPF   0.1.0
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



Re: [PHP] Email Form

2006-01-20 Thread sunaram patir
i have en experience of getting blocked by yahoo when i didn't use the
extra headers

On 1/20/06, Weber Sites LTD <[EMAIL PROTECTED]> wrote:
> Hi Richard,
>
> I'm trying to understand why this is good from a SPAM point of view.
> I'm guessing that anyone can just add this when sending his own spam no?
>
> berber
>
> -Original Message-
> From: Richard Lynch [mailto:[EMAIL PROTECTED]
> Sent: Thursday, January 19, 2006 11:37 PM
> To: Weber Sites LTD
> Cc: 'Thomas Bonham'; php-general@lists.php.net
> Subject: RE: [PHP] Email Form
>
> On Thu, January 19, 2006 3:25 pm, Weber Sites LTD wrote:
> > Check out :
> >
> > http://www.weberdev.com/get_example-336.html
> >
> > http://www.weberdev.com/get_example-1557.html
> >
> > In general you need to add the From header :
> >
> > Mail($To,$subject,$body,"From:[EMAIL PROTECTED]");
>
> In the ideal world, you also will want to upgrade and use the FIFTH
> (optional) argument to http://php.net/mail and provide a Return-path:
> header that matches your From: line with "[EMAIL PROTECTED]"
>
> Otherwise, you lose points in spam filters, and some recipients will
> probably not ever see the email.
>
> --
> 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
>
>

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



[PHP] mod_php environment

2006-01-20 Thread ms419
How do I configure which variables are passed to mod_php's environment?

I'm working on a project using Jon Praise' superb PHP SASL bindings -
http://cgi.sfu.ca/~jdbates/moin/moin.cgi/SquirrelMail&SASL

Using GSSAPI authentication requires a KRB5CCNAME environment variable
be passed from mod_auth_kerb to the SASL C library

It works great with php-cgi - the PHP environment contains all the
variables from the Apache environment - but with mod_php, the PHP
environment contains only LANG & PATH

I can still get the value of KRB5CCNAME using $_SERVER['KRB5CCNAME'],
but because $_ENV['KRB5CCNAME'] doesn't work, GSSAPI authentication
fails

Because SquirrelMail - & even the PHP SASL bindings - are designed to be
abstract from any one particular authentication mechanism, I don't think
the PHP script is the right place for $_ENV['KRB5CCNAME'] =
$_SERVER['KRB5CCNAME']

Instead, I want to configure mod_php to pass KRB5CCNAME from Apache's
environment to the PHP environment - but so far no luck figuring out how

Help much appreciated! Thanks! Jack


signature.asc
Description: Digital signature


Re: [PHP] New identification after an error...

2006-01-20 Thread David BERCOT
> David BERCOT wrote:
> > I've tried :
> > $_SERVER["PHP_AUTH_USER"] = NULL;
> > without succes...
> 
> http://www.php.net/unset
> 
> e.g. unset($_SERVER['PHP_AUTH_USER']);
> 
> It might, however, be better practice to used an authorisation state
> variable, or something similar, i.e.
> 
> if (! $auth) {
>   // HTTP Headers
> }

OK. Thank you very much.

David.

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



[PHP] adding script

2006-01-20 Thread Ross
This was a page I did ages ago

http://www.ecurry.net/menu2.php

The problem with it is when you add or subtact an item is it always button 
press behind.


This must be because of the way the page self submits or something?

The script is here

http://www.ecurry.net/calculate.phps

This is ok when I put it in an iframe it updates on every click.

http://www.ecurry.net/menu.php

thanks,


Ross 

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



RE: [PHP] Email Form

2006-01-20 Thread Weber Sites LTD
Hi Richard,

I'm trying to understand why this is good from a SPAM point of view.
I'm guessing that anyone can just add this when sending his own spam no?

berber

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 19, 2006 11:37 PM
To: Weber Sites LTD
Cc: 'Thomas Bonham'; php-general@lists.php.net
Subject: RE: [PHP] Email Form

On Thu, January 19, 2006 3:25 pm, Weber Sites LTD wrote:
> Check out :
>
> http://www.weberdev.com/get_example-336.html
>
> http://www.weberdev.com/get_example-1557.html
>
> In general you need to add the From header :
>
> Mail($To,$subject,$body,"From:[EMAIL PROTECTED]");

In the ideal world, you also will want to upgrade and use the FIFTH
(optional) argument to http://php.net/mail and provide a Return-path:
header that matches your From: line with "[EMAIL PROTECTED]"

Otherwise, you lose points in spam filters, and some recipients will
probably not ever see the email.

--
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



Re: [PHP] adding script

2006-01-20 Thread Silvio Porcellana [tradeOver]

Ross wrote:

This was a page I did ages ago

http://www.ecurry.net/menu2.php

The problem with it is when you add or subtact an item is it always button 
press behind.



This must be because of the way the page self submits or something?

The script is here

http://www.ecurry.net/calculate.phps

This is ok when I put it in an iframe it updates on every click.

http://www.ecurry.net/menu.php



This is the ideal situation for an AJAX solution:
http://en.wikipedia.org/wiki/AJAX
http://marc.theaimsgroup.com/?l=php-general&m=112198633625636&w=2

Ciao
Silvio

--
tradeOver | http://www.tradeover.net
...ready to become the King of the World?

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



Re: [PHP] Determining number of days in a selected month

2006-01-20 Thread tg-php
date("t") will give you the number of days in the current month.

Or you can do:

date("t", mktime(0, 0, 0, $month, $day, $year))


to get the number of days in a specific month in a specific year (that way you 
can get leap year accurate counts..)

-TG

= = = Original message = = =

Is there a way to easily tell PHP how many days there are in a selected
month without writing the following out for each month:

if($Month == "January") 
~$NumberOfDays = 31;

elseif($Month == "February") 
~if($Year == "A Leap Year") 
~~$NumberOfDays = 29;
~
~elseif($Year != "A Leap Year") 
~~$NumberOfDays = 28;
~

elseif($Month == "March") 
~$NumberOfDays = 31;

and so on, and so on, and so on

I would greatly appreciate any help.  Thanks.



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


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



[PHP] simple DOM/XML test fails in php

2006-01-20 Thread Larry Hughes
I have a very simple DOM test set up which is failing.  Environment is 
apacie 1.3.x, WIN xp, PHP 5.1.2 ; DOM seetings outlined in phpinfo() 
indicate various DOM/XML support is enabled.

Failing php is:
saveXML();
?>

which results in:
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then 
click the Refresh button, or try again later.


XML document must have a top level element. Error processing resource 
'http://127.0.0.1/domtest.php'.

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



[PHP] simple DOM/XML test fails in php

2006-01-20 Thread Larry Hughes
I have a very simple DOM test set up which is failing.  Environment is
apacie 1.3.x, WIN xp, PHP 5.1.2 ; DOM seetings outlined in phpinfo()
indicate various DOM/XML support is enabled.

Failing php is:
saveXML();
?>

which results in:
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then
click the Refresh button, or try again later.


XML document must have a top level element. Error processing resource
'http://127.0.0.1/domtest.php'.

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



[PHP] Managing sessions...

2006-01-20 Thread David BERCOT
Hi again,

Ok, it's probably not the first time you have a question about sessions
with PHP ;-)
I've tried to read mails, documentation, searching on Internet but,
finally, I think everything is not clear !!!

First of all, I understand that, if session.auto_start is not on '1', I
have to write session_start on each page I use !!! OK.
Before this line, I put options :
ini_set("session.use_only_cookies",1);
ini_set("session.use_trans_sid",0);
ini_set("error_reporting",E_ALL);
and then :
session_start();

I think it is very heavy to write... I read about
ini_set("session.auto_start",1) but, on my server (Debian), it doesn't
seem working...
And I also read about options which can be not set if I use
auto_start...

So, I'd like to put my options (use_trans_sid, 0, etc...) and to have
lite scripts. Is it possible ?
Isn't there, like in asp, a global.asa where I can put all my
parameters ?

Thank you very much.

David.

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



[PHP] Re: Managing sessions...

2006-01-20 Thread Barry

David BERCOT wrote:

Hi again,

Ok, it's probably not the first time you have a question about sessions
with PHP ;-)
I've tried to read mails, documentation, searching on Internet but,
finally, I think everything is not clear !!!

First of all, I understand that, if session.auto_start is not on '1', I
have to write session_start on each page I use !!! OK.
Before this line, I put options :
ini_set("session.use_only_cookies",1);
ini_set("session.use_trans_sid",0);
ini_set("error_reporting",E_ALL);
and then :
session_start();

I think it is very heavy to write... I read about
ini_set("session.auto_start",1) but, on my server (Debian), it doesn't
seem working...
And I also read about options which can be not set if I use
auto_start...

So, I'd like to put my options (use_trans_sid, 0, etc...) and to have
lite scripts. Is it possible ?
Isn't there, like in asp, a global.asa where I can put all my
parameters ?

Thank you very much.

David.


Write an include file and require it. done :)
http://de2.php.net/require

Greets
Barry

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



[PHP] Count of elements in XML

2006-01-20 Thread Jay Paulson
I was wondering if there is a way to get the number of foo elements in my
XML below?  This way I could loop through each element and print out the
attributes.  

$string = "
 1
 2
 3
 4
";

$xml = simplexml_load_string($string);
// this doesn't return the correct number of elements but instead returns
the data inbetween 
$cnt = count($xml->foo);
for($i=0; $i<$cnt; $i++) {
foreach($xml->foo[$i]->attributes() as $a => $b) {
   echo $a,'="',$b,"\"\n";
}
}

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



RE: [PHP] Count of elements in XML

2006-01-20 Thread Richard Correia
Hi Jay,

Check the example at 
http://www.weberdev.com/Manuals/PHP/function.simplexml-element-children.html

Thanks,
Richard

-Original Message-
From: Jay Paulson [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 20, 2006 11:06 PM
To: PHP LIST
Subject: [PHP] Count of elements in XML

I was wondering if there is a way to get the number of foo elements in my
XML below?  This way I could loop through each element and print out the
attributes.  

$string = "
 1
 2
 3
 4
";

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



[PHP] getting list of files included

2006-01-20 Thread Diana Castillo
does anyone know of a command in php that will give you a list of the files 
already included .  Something that would tell you whether a file is already 
included before you do the require_once  ?

-- 
Diana Castillo
Destinia.com
C/Granvia 22 dcdo 4-dcha
28013 Madrid-Spain
Tel : 00-34-913604039 Ext 216
Fax : 00-34-915228673
email: [EMAIL PROTECTED]
Web : http://www.hotelkey.com
  http://www.destinia.com

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



RE: [PHP] getting list of files included

2006-01-20 Thread Jay Blanchard
[snip]
does anyone know of a command in php that will give you a list of the files 
already included .  Something that would tell you whether a file is already 
included before you do the require_once  ?
[/snip]

There is not a command or function built in, but http://www.php.net/include
has a discussion concerning this

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



Re: [PHP] getting list of files included

2006-01-20 Thread Silvio Porcellana [tradeOver]

Diana Castillo wrote:
does anyone know of a command in php that will give you a list of the files 
already included .  Something that would tell you whether a file is already 
included before you do the require_once  ?




Try this:
http://php.net/manual/en/function.get-included-files.php

Oh, and maybe next time try to RTFM... :-)

Cheers!
Silvio

--
tradeOver | http://www.tradeover.net
...ready to become the King of the World?

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



RE: [PHP] getting list of files included

2006-01-20 Thread Richard Correia
Check the example at

http://www.weberdev.com/Manuals/PHP/function.get-included-files.html

Thanks,
Richard

-Original Message-
From: Diana Castillo [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 20, 2006 11:55 PM
To: php-general@lists.php.net
Subject: [PHP] getting list of files included

does anyone know of a command in php that will give you a list of the files 
already included .  Something that would tell you whether a file is already 
included before you do the require_once  ?

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



Re: [PHP] getting list of files included

2006-01-20 Thread John Nichel

Diana Castillo wrote:
does anyone know of a command in php that will give you a list of the files 
already included .  Something that would tell you whether a file is already 
included before you do the require_once  ?




If you're using include|require_once, why worry if it's already been 
included?


--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

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



[PHP] Re: Managing sessions...

2006-01-20 Thread David Hall

David BERCOT wrote:


I think it is very heavy to write... I read about
ini_set("session.auto_start",1) but, on my server (Debian), it doesn't


session.auto_start doesn't make sense as being set in the actual file. 
its meant to be something that's done by the server on every file, so 
setting that in every file is something that wouldn't make sense with 
its function



So, I'd like to put my options (use_trans_sid, 0, etc...) and to have
lite scripts. Is it possible ?
Isn't there, like in asp, a global.asa where I can put all my
parameters ?

I mean, there's the php.ini . . .  Otherwise use includes like the other 
poster said


Also, if you can't change the php.ini, but you're on an apache server, 
see this stuff http://us2.php.net/manual/en/configuration.changes.php


David Hall

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



Re: [PHP] Managing sessions...

2006-01-20 Thread Richard Lynch
On Fri, January 20, 2006 10:53 am, David BERCOT wrote:
> Isn't there, like in asp, a global.asa where I can put all my
> parameters ?

You could solve this with:
php.ini
.htaccess
include (or require)
auto_prepend_file

The problem with global.asa is that it implies a shared memory space
that PHP would use.

That, in turn, breaks the "shared nothing" architecture which makes
PHP scalable by simply adding more servers to your server farm and
turning them on, without a nightmare of configuration and data-sharing
issues.

So, no, there is no global.asa, and there's a reason for that.

-- 
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



Re: [PHP] simple DOM/XML test fails in php

2006-01-20 Thread Richard Lynch
On Fri, January 20, 2006 10:20 am, Larry Hughes wrote:
> I have a very simple DOM test set up which is failing.  Environment is
> apacie 1.3.x, WIN xp, PHP 5.1.2 ; DOM seetings outlined in phpinfo()
> indicate various DOM/XML support is enabled.
>
> Failing php is:
>  $dom = new DOMDocument('1.0', 'iso-8859-1');
> echo $dom->saveXML();
> ?>
>
> which results in:
> The XML page cannot be displayed
> Cannot view XML input using style sheet. Please correct the error and
> then
> click the Refresh button, or try again later.
> 
> XML document must have a top level element. Error processing resource
> 'http://127.0.0.1/domtest.php'.

Seems pretty clear.

You need to put something *IN* your DOMDocument to have it be valid.

A totally empty document is not valid XML.

Add some line between the 2 lines you have, and do something with the
$dom to add something to it.  No idea how you do that, mind you, but
it's what you need.

-- 
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



Re: [PHP] mod_php environment

2006-01-20 Thread Richard Lynch
On Fri, January 20, 2006 9:30 am, [EMAIL PROTECTED] wrote:
> How do I configure which variables are passed to mod_php's
> environment?
>
> I'm working on a project using Jon Praise' superb PHP SASL bindings -
> http://cgi.sfu.ca/~jdbates/moin/moin.cgi/SquirrelMail&SASL
>
> Using GSSAPI authentication requires a KRB5CCNAME environment variable
> be passed from mod_auth_kerb to the SASL C library
>
> It works great with php-cgi - the PHP environment contains all the
> variables from the Apache environment - but with mod_php, the PHP
> environment contains only LANG & PATH
>
> I can still get the value of KRB5CCNAME using $_SERVER['KRB5CCNAME'],
> but because $_ENV['KRB5CCNAME'] doesn't work, GSSAPI authentication
> fails
>
> Because SquirrelMail - & even the PHP SASL bindings - are designed to
> be
> abstract from any one particular authentication mechanism, I don't
> think
> the PHP script is the right place for $_ENV['KRB5CCNAME'] =
> $_SERVER['KRB5CCNAME']
>
> Instead, I want to configure mod_php to pass KRB5CCNAME from Apache's
> environment to the PHP environment - but so far no luck figuring out
> how

I *think* that you want to ask how you configure APACHE to include
that in ENV variable -- because PHP just passes on whatever Apache
gives it in ENV.

PHP doesn't go out and make any decision here.

What Apache puts in ENV, PHP puts in $_ENV.

See httpd.conf and http://apache.org/

-- 
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



Re: [PHP] problem encountered with stristr-based function

2006-01-20 Thread Richard Lynch
On Fri, January 20, 2006 8:44 am, George Pitcher wrote:
> function terms($term,$field){
>   if(strlen($term)>0){
> if(!stristr($term, $field) === FALSE) {

This is quite contorted...
And you have the arguments swapped, which is the real problem.
  if(stristr($field, $term)){

>   $output = str_replace($term, "".$term."", $field);

The rest of this is just plain silly.
stristr ignores case in both args.

> } elseif(!stristr(strtolower($term), $field) === FALSE) {
>   $output = str_replace(strtolower($term),
> "".strtolower($term)."", $field);
> } elseif(!stristr(strtoupper($term), $field) === FALSE) {
>   $output = str_replace(strtoupper($term),
> "".strtoupper($term)."", $field);
> } elseif(!stristr(ucfirst($term), $field) === FALSE) {
>   $output = str_replace(ucfirst($term),
> "".ucfirst($term)."",
> $field);
> }
>   } else {
> $output = $field;
>   }
>   return $output;
> }
> I'm not comfortable enough with regex etc, so tried it my way, but no
> joy.
>
> For info, I am trying to highlight search terms in results.
>
> Any suggestions?

http://php.net/stristr

-- 
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



[PHP] Get text from funky url?

2006-01-20 Thread lists

Hello,

I am trying to get xml from AIM's new presence API.

The url is unusual, it has quotes in it.

Anyone know a way to get the text from this?

http://api.oscar.aol.com/SOA/key=PandorasBoxGoodUntilJan2006/resource-lists/
users/*anonymous*/presence/~~/resource-lists/list[name=\"users\"]/[EMAIL 
PROTECTED]
=\"user:screenname\"]

Insert your own screen name to see what it returns

I tried include(); but the quotes in the url broke it. Tried escaping them
too, still no luck.???

TIA

-Mike

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



Re: [PHP] New identification after an error...

2006-01-20 Thread Richard Lynch
On Fri, January 20, 2006 8:24 am, David BERCOT wrote:
> I use this program to force a user to authenticate :
> if (!isset($_SERVER["PHP_AUTH_USER"])) {
> header("WWW-Authenticate: Basic realm=\"Intranet SDSED\"");
> header("HTTP/1.1 401 Unauthorized");
> }
> Everything is ok except a detail : if the user makes a mistake (for
> example, a bad password), the variable $_SERVER["PHP_AUTH_USER"] is
> initialised.
> So, if he wants to do again the above test, another identification
> won't
> happen (because $_SERVER["PHP_AUTH_USER"] is already set).

Well, yeah.

You kind of need to send the headers if:
PHP_AUTH_USER is not set
PHP_AUTH_USER is not valid user
PHP_AUTH_PW is not set
PHP_AUTH_PW is not valid

So you've only done 25% of the job, so far. :-)

Only if all four conditions are met is the user really valid.

> I've tried :
> $_SERVER["PHP_AUTH_USER"] = NULL;
> without succes...

$_SERVER should be treated as a "read-only" variable.

NEVER stuff something into it.

In this case, not only is it just a Bad Idea to stuff something in
there, it's pointless.

The *browser* sends the values for PHP_AUTH_USER and _PW on every
single request, and PHP crams whatever the browser sends into
$_SERVER.

And whatever you put in there during your last script is long long
long gone before any of this happens.

But even if it was still there, it would get over-written by the
browser->apache->php process.

-- 
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



Re: [PHP] New identification after an error...

2006-01-20 Thread Richard Lynch
On Fri, January 20, 2006 9:32 am, David BERCOT wrote:
>> David BERCOT wrote:
>> > I've tried :
>> > $_SERVER["PHP_AUTH_USER"] = NULL;
>> > without succes...
>>
>> http://www.php.net/unset
>>
>> e.g. unset($_SERVER['PHP_AUTH_USER']);
>>
>> It might, however, be better practice to used an authorisation state
>> variable, or something similar, i.e.
>>
>> if (! $auth) {
>>  // HTTP Headers
>> }

This kind of coding is EXACTLY what makes register_globals "ON" so
dangerous.

Avoid it at all costs.

If you don't understand why, start reading about register_globals at
http://php.net and keep reading until you DO understand it.

-- 
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



Re: [PHP] Get text from funky url?

2006-01-20 Thread Philip Hallstrom

I am trying to get xml from AIM's new presence API.

The url is unusual, it has quotes in it.

Anyone know a way to get the text from this?

http://api.oscar.aol.com/SOA/key=PandorasBoxGoodUntilJan2006/resource-lists/
users/*anonymous*/presence/~~/resource-lists/list[name=\"users\"]/[EMAIL 
PROTECTED]
=\"user:screenname\"]

Insert your own screen name to see what it returns

I tried include(); but the quotes in the url broke it. Tried escaping them
too, still no luck.???


Why can't you wrap it up in single quotes?

-p

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



Re: [PHP] fsockopen, openssl error

2006-01-20 Thread Richard Lynch
On Fri, January 20, 2006 7:38 am, James Benson wrote:
> Im running into the followng error when trying to use fsockopen with
> the
> openssl extension,
>
>
>
> Warning: fsockopen(): php_stream_sock_ssl_activate_with_method: failed
> to create an SSL context
>
> Warning: fsockopen(): failed to activate SSL mode 1
>
> Socket Error: Operation now in progress
>
>
>
>
> Anyone have any clues as to what this may be or why its happening?
>
> Perhaps a compile problem, anyway, I probably will try 4.4.0 because
> ive
> not made any changes to the script for a few months but have upgraded
> to
> 4.4.2 recently then get this error, very suspicious i think?

Didja remember to include OpenSSL when you compiled PHP 4.4.2???

Check your phpinfo() and see if it's in there.

If it ain't, you ain't gonna be able to build an SSL context, cuz you
ain't got SSL in your PHP to start with...

-- 
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



Re: [PHP] Get text from funky url?

2006-01-20 Thread lists
on 1/20/06 4:37 PM, Philip Hallstrom at [EMAIL PROTECTED] wrote:

>> I am trying to get xml from AIM's new presence API.
>> 
>> The url is unusual, it has quotes in it.
>> 
>> Anyone know a way to get the text from this?
>> 
>> http://api.oscar.aol.com/SOA/key=PandorasBoxGoodUntilJan2006/resource-lists/
>> users/*anonymous*/presence/~~/resource-lists/list[name=\"users\"]/[EMAIL 
>> PROTECTED]
>> =\"user:screenname\"]
>> 
>> Insert your own screen name to see what it returns
>> 
>> I tried include(); but the quotes in the url broke it. Tried escaping them
>> too, still no luck.???
> 
> Why can't you wrap it up in single quotes?
> 
> -p


Tried that too, no love. :(

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



Re: [PHP] ftp_get, ftp_put problem

2006-01-20 Thread Richard Lynch
On Fri, January 20, 2006 7:26 am, Antonis Varkas wrote:
> I am writing a php script to upload/download a file onto/from an FTP
> Server. I manage to connect to the server, login correctly, change
> directory, list all the files there but fail to get or put the file.
> The documentation says that ftp_get and ftp_put return TRUE or FALSE.
> In
> my case nothing at all is returned.
>
> Using the following code part, the $test variable is empty
>
> // upload the file
> $test = ftp_put($conn_id, $remote_file, $local_file, FTP_BINARY);
> if ($test) {
>   echo "Successfully uploaded $local_file.\n";
> } else {
>   echo "There was a problem while uploading $local_file.\n";
>   echo("TEST: ".$test."\n");
> }
> I don't get any warnings.
> Does this indicate something I can't figure out ?

FTP active/passive setting changes whether FTP tries to open up a
second connection back to your computer to put/get the actual file
contents, leaving the original connection for you to send more
commands etc.

If your firewall doesn't allow that second connection to happen, then
you may encounter this phenomenon.

Try switching active/passive around and see what you get.

-- 
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



Re: [PHP] Get text from funky url?

2006-01-20 Thread Marco Kaiser
Hi,

try to use urlencode() and urldecode() to encode url's.

-- Marco

2006/1/20, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
>
> Hello,
>
> I am trying to get xml from AIM's new presence API.
>
> The url is unusual, it has quotes in it.
>
> Anyone know a way to get the text from this?
>
>
> http://api.oscar.aol.com/SOA/key=PandorasBoxGoodUntilJan2006/resource-lists/
>
> users/*anonymous*/presence/~~/resource-lists/list[name=\"users\"]/[EMAIL 
> PROTECTED]
> =\"user:screenname\"]
>
> Insert your own screen name to see what it returns
>
> I tried include(); but the quotes in the url broke it. Tried escaping them
> too, still no luck.???
>
> TIA
>
> -Mike
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Marco Kaiser


Re: [PHP] date("H", $datevalue) always adds an hour?

2006-01-20 Thread Richard Lynch
On Fri, January 20, 2006 4:24 am, Murray @ PlanetThoughtful wrote:
> Wondering if anyone can help me work out why date("H") always adds an
> hour? I'm *assuming* it thinks it should be compensating for Daylight
> Saving Time (though I'd be just as willing to believe that it's caused
> by something else), however we don't observe DST in Queensland,
> Australia.
>
> Making matters a little more complex, while my local machine shouldn't
> be compensating for DST (if that's what's happening), my remote
> machine
> (based in Florida somewhere, I think) should, when applicable.
>
> So, just to explain a little better.
>
> Let's say the clock on my computer reads 7:00pm. If I do "echo
> date("H");" it will output "20", instead of "19".
>
> The same thing happens if I take a date value from my mysql database.
>
> $sql = "SELECT UNIX_TIMESTAMP(datecreated) AS unx_date FROM mytable;"
> $rs = mysql_query($sql);
> $row = mysql_fetch_object($rs);
> echo date("H", $row->unx_date);
>
> If the above record contained the value '2006-01-10 19:00', the code
> would output "20" instead of "19".
>
> Can anyone help me figure out how to accommodate for this?

Ah, the joys of time-zones, and daylight savings.

I'd like to kill the guy that thought up daylight savings.

Not only does it depend on the machine's location, and where the
machine thinks it's located (you could lie to your computer, you know)
but also the 'locale' settings and the BIOS UTC setting, and the
server's settings in the OS and/or NTP client and...

Oh, plus with MySQL, there are settings that can convince MySQL to not
pay attention to the OS about its locale/zone settings and to do
someting else instead.

Tracking down where the fault lies is generally "not fun"

But at least now you know where to look :-)

I usually throw my hands up in despair and just add/subtract whatever,
and then check it again when daylight savings changes over and see if
it still works -- Because I have zero control over any of the settings
on a shared server anyway.

And what's up with these countries with time-zones offset by 15
minutes?  What were they thinking?

-- 
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



RE: [PHP] Email Form

2006-01-20 Thread Richard Lynch
On Fri, January 20, 2006 9:02 am, Weber Sites LTD wrote:
> I'm trying to understand why this is good from a SPAM point of view.
> I'm guessing that anyone can just add this when sending his own spam
> no?

Hey, I'm not claiming that the spam criteria are rational, nor that
any halfway intelligent spammer could not "beat them"

I'm just telling you what *IS* happening today. :-)

Note, however, that many ISPs will not allow you to use that fifth
argument, or, more accurately, will configure sendmail to choke if you
try to use it with "-f" to set the Return-path: because you are not a
"trusted user"

-- 
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



Re: [PHP] URL -> stream context

2006-01-20 Thread Richard Lynch
On Thu, January 19, 2006 6:49 pm, Geoff wrote:
> Richard, have you seen this:
> http://bugs.php.net/bug.php?id=5153&edit=1
> This bug goes back to June 2000. And it's closed even though it is
> clearly not fixed. Doesn't seem like they'll get to it anytime soon.
> You might have to do it the long way, building your own protocol
> handlers. Or, you might want to look into a 3rd party library, or a
> command line option like "lynx -dump -connect_timeout=n " which
> is multi-resource aware.

The comment in that bug report, and similar comments all over the 'net
by PHP Dev Team, are what led me on this quest in the first place...

Alas, the reality falls far short of what I had hoped was promised.

I *CAN* control the timeout, if I'm wiling to re-invent the wheel and
duplicate a ton of code that's built into fopen.

I *THOUGHT* from the comments that the new streams would have
something like fopen, with a configurable timeout, but with the
streams library handling all the minutia of different protocols.

As far as I can find, that's not the case.

Here is a crude version of what I would like to be able to type:
$url = 'https://example.com';
$stream_context = array('connection_timeout'=>4', 'url'=$url);
$stream = new stream($stream_context);
if ($stream === false) die("Connection timed out.");
stream_set_blocking($stream, false);
$start = time();
//Never ask the user to wait more than 5 seconds for a web page:
$data = '';
while ((time() <= $start + 5) && !feof($stream)){
  $data .= fread($stream, 2048);
}
if (!feof($stream)){
  //load obsolete data from cache, rather than incomplete data we just
got:
  $data = load_cache($url);
}

Instead, I have to know the ins and outs of all the different
protocols to even begin to use the new streams stuff.

Richard "unwillling" Lynch :-^

-- 
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



[PHP] Upgrade to 4.4.2 shows as 4.4.1-pl-1 (Windows)

2006-01-20 Thread Chuck Anderson
I upgraded to 4.4.2, the Windows binary.  When I run phpinfo, the title 
says PHP Version 4.4.1-pl1 (my previous version).  However, under 
apache2handler, though, it says:

Apache/2.0.55 (Win32) mod_ssl/2.0.55 OpenSSL/0.9.8a PHP/4.4.2
(I run php as an Apache module on my home PC.)

Is there something wrong?

--
*
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*

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



[PHP] Str to Int

2006-01-20 Thread Ron Eggler (Paykiosks)
Hi,

I need to do a type cast from string to int in folllowing code:
[php]

[/php]
I need $cardID have converted to int. I thought it should work that way
but it does not!
But it's working if I'm putting
[php]

[/php]
in there. I got card ID as a var that is passed as get like:
[php]
$cardID = $HTTP_GET_VARS[cardID];
[/php]

Can anyone help me in that issue? Thank you!

__

Ron Eggler
Intern 
866-999-4179
www.paykiosks.net




Re: [PHP] URL -> stream context

2006-01-20 Thread Richard Lynch
On Fri, January 20, 2006 7:10 am, Jochem Maas wrote:
> I think you need to create a stream context resource with:
>
> http://www.php.net/manual/en/function.stream-context-create.php
>
> set the options you need on it with:
> http://www.php.net/manual/en/function.stream-context-set-option.php
>
> then pass the resource as the 4th arg to fopen() (rather passing in an
> array)
>
>
> ...i think

My whole entire point is this:

I have no idea what all the options are that I would need to duplicate
the code that is built-in to http://php.net/fopen

I really don't want to re-invent the wheel of figuring out all those
options when they are already coded in fopen.

The examples of HTTP and FTP are all very nice, but I'd have to code
for SSL and files and all manner of other protocols to come anywhere
close to the functionality of fopen.

Alas, with fopen, there is no control over connection timeout.

Everybody experienced in PHP keeps talking about the new streams stuff
as if it's a Magic Bullet that will make this all better.

It's not.

It adds layer upon layer of complication to application code, and I'm
sure it's wondeful if one wants the fine-grained control over a
zillion things I don't understand, and I don't WANT to understand --
at leat not at the expense it would take to gain an understanding
necessary to use stream-contexts.

What 99% of developers want, however, is to ignore all the gory
details of all the different schemes and protocols, and get their
data.
$file = fopen($any_url_in_any_protocol);

A large proportion of those developers also want to have a site that
does not seem "slow" if it's stuck waiting for some resource.

So they want fopen() to have a developer-configurable timeout.

Does not exist.

The only way you can get developer-configurable timeout is to use
fsockopen or the new stream-context stuff, both of which require a
Ph.D. in eleventeen different scheme/protocol technologies to get the
kind of functionality you get with fopen.

I hope I'm making sense here, and clearly laying out the issue,
because apparently it hasn't gotten through to most readers in
previous messages.

Currently in PHP you have two options:

Use fopen, keep life simple, but have an infinitely slow response when
your application depends on a dodgy remote server over which you have
no control.

Use fsockopen or streams and spend the next 4 years coding your
application to understand all the ins and outs of protocols you really
don't WANT to understand the details of that should be a black box to
your application.

Do you REALLY want to try to figure out what kind of an array you need
to build and what data you have to send/recieve/parse and act upon to
get an HTTPS feed?  With fopen() it's just taken care of.  With
stream-context, you're going to have to actually understand all that
SSL stuff before you can get your data.

-- 
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



Re: [PHP] Str to Int

2006-01-20 Thread Ray Hauge
You should be able to typecast the variable like so:

$cardID = (int)$cardID;

You can also check which type it is showing up as with the function gettype():

http://www.php.net/manual/en/function.gettype.php

Optionally you could use settype() to change the type of the variable:

http://www.php.net/manual/en/function.settype.php

HTH

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
http://www.americanstudentloan.com
1.800.575.1099

On Friday 20 January 2006 03:53 pm, Ron Eggler (Paykiosks) wrote:
> Hi,
>
> I need to do a type cast from string to int in folllowing code:
> [php]
> 
> [/php]
> I need $cardID have converted to int. I thought it should work that way
> but it does not!
> But it's working if I'm putting
> [php]
> 
> [/php]
> in there. I got card ID as a var that is passed as get like:
> [php]
> $cardID = $HTTP_GET_VARS[cardID];
> [/php]
>
> Can anyone help me in that issue? Thank you!
>
> __
>
> Ron Eggler
> Intern
> 866-999-4179
> www.paykiosks.net

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



Re: [PHP] Str to Int

2006-01-20 Thread Gerry Danen
You probably want to do an is_int() first...

After that, you know it's an int and treat it that way. Why do you need to
typecast it?

BTW, change $cardID = $HTTP_GET_VARS[cardID]; to $cardID = $_GET['cardID'];
for PHP5 compatibility... ;-)

Gerry

On 1/20/06, Ron Eggler (Paykiosks) <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I need to do a type cast from string to int in folllowing code:
> [php]
> 
> [/php]
> I need $cardID have converted to int. I thought it should work that way
> but it does not!
> But it's working if I'm putting
> [php]
> 
> [/php]
> in there. I got card ID as a var that is passed as get like:
> [php]
> $cardID = $HTTP_GET_VARS[cardID];
> [/php]
>
> Can anyone help me in that issue? Thank you!
>
> __
>
> Ron Eggler
> Intern
> 866-999-4179
> www.paykiosks.net
>
>
>
>


--
Gerry
http://portal.danen.org/


Re: [PHP] Str to Int

2006-01-20 Thread Ron Eggler (Paykiosks)
Am Freitag, den 20.01.2006, 16:08 -0700 schrieb Gerry Danen:
> You probably want to do an is_int() first...
> 
> After that, you know it's an int and treat it that way. Why do you
> need to typecast it?
> 
> BTW, change $cardID = $HTTP_GET_VARS[cardID]; to $cardID =
> $_GET['cardID']; for PHP5 compatibility... ;-) 
> 
> Gerry
Hey, it seems to be recognied by is_int() as integer. I have following
code:
[php]
  if ($HTTP_GET_VARS) // if some GET variables were passed on,...
  {
  switch ($HTTP_GET_VARS['action'])// recognize the get-var 'action'
{
case reserve:  // it says, 'reserve PINs'
  $cardID = $HTTP_GET_VARS['cardID']; // get cardID which was passed by GET 
as well
  if ($cardID=''||is_int($cardID)) // unless,
{
$cardID = intval($cardID.trim());
echo "ERROR, cardID='' or cardID is no integer!\n"; //print 
Error
exit(0); //and leave
}
  echo "reserve\n"; // Variables were okay, so go ahead with the 
reserving
  / [reserve SKU] /
  $inputdata = ''.$n.'
  
  
   
  
  ';
  / [/reserve SKU] ***/
break;
[/php]

it doesn't work that way but if I replace ['.intval(trim($cardID)).']
with [180] (everything between the []-brakets) it seems to work and
cardID was passed with the URL:
http://localhost/ewi.php?action=reserve&cardID=180
So what the hell is going wrong?
Thank you!

chEErs roN

> 
> On 1/20/06, Ron Eggler (Paykiosks) <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I need to do a type cast from string to int in folllowing
> code:
> [php]
> 
> [/php]
> I need $cardID have converted to int. I thought it should work
> that way 
> but it does not!
> But it's working if I'm putting
> [php]
> 
> [/php]
> in there. I got card ID as a var that is passed as get like:
> [php]
> $cardID = $HTTP_GET_VARS[cardID]; 
> [/php]
> 
> Can anyone help me in that issue? Thank you!
> 
> __
> 
> Ron Eggler
> Intern
> 866-999-4179
> www.paykiosks.net
> 
> 
> 
> 
> 
> 
> -- 
> Gerry
> http://portal.danen.org/

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



Re: [PHP] Str to Int

2006-01-20 Thread comex
> if ($cardID=''||is_int($cardID))

Two problems with that statement:
First of all, this statement _sets_ cardID to '', and then (I think)
returns a false value since '' doesn't evaluate to true.  You probably
wanted ==.
Second of all, now that $cardID is '', it certainly isn't an int.  It
isn't an int, and it wouldn't be an int if you fixed that statement
because is_int only tests if it is, actually, an integer. 
$HTTP_GET_VARS['cardID'] could be '123', but it can't be 123 and so
that will be false.  From the PHP manual:

Note:  To test if a variable is a number or a numeric string (such
as form input, which is always a string), you must use is_numeric().

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



Re: [PHP] Str to Int

2006-01-20 Thread adriano ghezzi
well I don't well understand the problem hope these two snippets can solve
your problem: i tested them seems fine

file 1 form.php






enter tour code




 
enter tour code

 
  
   user
   
  
  
   code
   
  
  
   
   
   
  
 
  

 







file 2
--

get_card.php





Nuova pagina 1




";

$int_id=intval(trim($_POST['txt_id']));

print "integer value:::$int_id"."";

print "type returned:".gettype($int_id)."";

?>
















2006/1/20, Ron Eggler (Paykiosks) <[EMAIL PROTECTED]>:
>
> Hi,
>
> I need to do a type cast from string to int in folllowing code:
> [php]
> 
> [/php]
> I need $cardID have converted to int. I thought it should work that way
> but it does not!
> But it's working if I'm putting
> [php]
> 
> [/php]
> in there. I got card ID as a var that is passed as get like:
> [php]
> $cardID = $HTTP_GET_VARS[cardID];
> [/php]
>
> Can anyone help me in that issue? Thank you!
>
> __
>
> Ron Eggler
> Intern
> 866-999-4179
> www.paykiosks.net
>
>
>
>


Re: [PHP] Str to Int

2006-01-20 Thread Ron Eggler (Paykiosks)
Am Freitag, den 20.01.2006, 18:28 -0500 schrieb comex:
> > if ($cardID=''||is_int($cardID))
> 
> Two problems with that statement:
> First of all, this statement _sets_ cardID to '', and then (I think)
> returns a false value since '' doesn't evaluate to true.  You probably
> wanted ==.

hOOps that's right, shit, haven't seen that..hm okay, it
works fine now, thanks again!

> Second of all, now that $cardID is '', it certainly isn't an int.  It
> isn't an int, and it wouldn't be an int if you fixed that statement
> because is_int only tests if it is, actually, an integer. 
> $HTTP_GET_VARS['cardID'] could be '123', but it can't be 123 and so
> that will be false.  From the PHP manual:
> 
> Note:  To test if a variable is a number or a numeric string (such
> as form input, which is always a string), you must use is_numeric().
> 

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



Re: [PHP] Str to Int

2006-01-20 Thread tg-php
Ok, some good points where made already, but let's pull it all together:

1. You should get in the habit of using $_GET[] instead of $HTTP_GET_VARS.. 
minor thing but worth noting (info at http://us2.php.net/reserved.variables)

2. case reserve:
   This, I believe, will treate "reserve" as a constant.  Change it to:
 case "reserve":
   to make it work properly.

3. if ($cardID = '' || is_int($cardID))
   As someone mentioned, $cardID = '' makes an assignment, doesn't test for 
true/false.  Change to $cardID == ''.  And this statement SHOULD come up "true" 
as a whole because $cardID = '' should always be true (unless the assignment 
fails). So regardless of is_int($cardID) succeeding or failing, $cardID = '' 
should be true so this statement will always be true.

4. $cardID = intval($cardID.trim())
   Mixing PHP and Javascript? (or another language?).  Try:
   $cardID = intval($cardID);
   trim() probably isn't necessary unless your variable starts with letters.
   intval("123 main street") should give you "123".
   intval("main street suite 400") should give you "0" (zero)

5. intval() returns zero if it's a bad entry, so is_int(intval($anything)) 
should always be true I believe.  Just something to keep in mind in case 
$cardID zero is actually something you want to use.  In that case you don't 
want to use $cardID = intval($whatever) because you'll end up with zero.

6. exit(0)
   Again remnants from another language.  exit() works in PHP but no need to 
return a zero return value.  exit() is fine.

7. echo "reserve" is going to output "reserve", not the value of a variable
   try echo "$reserve";


Also.. it's probably not necessary, but I usually enclose my switch statements 
in braces just to keep it clear what's part of the switch.

switch ($somevar) {
  case "val1":
echo "Value one";
break;
  case "val2":
echo "Value two";
break;
  default:
echo "No valid value";
break;
}

Good luck Ron!  You'll get ahold of this stuff soon enough.  Looks like you 
have some experience in other languages (and some of it will work fine in PHP.. 
it's very forgiving and flexible, but some of it will need to be tweaked).

Let us know if you have further questions.

-TG


= = = Original message = = =

[php]
  if ($HTTP_GET_VARS) // if some GET variables were passed on,...
  
  switch ($HTTP_GET_VARS['action'])// recognize the get-var 'action'

case reserve:  // it says, 'reserve PINs'
  $cardID = $HTTP_GET_VARS['cardID']; // get cardID which was passed by GET 
as well
  if ($cardID=''||is_int($cardID)) // unless,

$cardID = intval($cardID.trim());
echo "ERROR, cardID='' or cardID is no integer!\n"; //print 
Error
exit(0); //and leave

  echo "reserve\n"; // Variables were okay, so go ahead with the 
reserving
  / [reserve SKU] /
  $inputdata = ''.$n.'
  
  
   
  
  ';
  / [/reserve SKU] ***/
break;
[/php]


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



[PHP] difference between require and include

2006-01-20 Thread balachandar muruganantham
Can anyone tell me the exact differeneces between require and include?

--
 balachandar muruganantham
 mbchandar
  mbchandar
 http://chandar.blogspot.com
http://www.balachandar.net
 http://www.expertstalk.org
http://www.chennaishopping.com

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



[PHP] PHP 4.4.2 Update Issues?

2006-01-20 Thread [EMAIL PROTECTED]

Hello


I've started work for a client who has their own server running PHP 
4.1.1. If I upgrade them to PHP 4.4.2, will there be any issues I'd

need to look out for?

Is there a general process (or checklist) I should follow when
upgrading PHP versions to find where potential the may be potential
code problems?


Thank you for your assistance

Tim

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



Re: [PHP] date("H", $datevalue) always adds an hour?

2006-01-20 Thread Michael Hulse

Hi,

On Jan 20, 2006, at 2:24 AM, Murray @ PlanetThoughtful wrote:

Can anyone help me figure out how to accommodate for this?


Not sure if this will help, but:

# Set time zone:
putenv('TZ=US/Pacific'); // I am on west-coast, my servers are on east, 
if not for this code the timestamp used in my script will reley upon 
the server time. This line of code will over-ride server time.


Maybe look-up putenv on php.net and read-up in the comments section, I 
usually find good info that way.


Gl,
Cheers,
Micky

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



Re: [PHP] Determining number of days in a selected month

2006-01-20 Thread Jeffrey Pearson
The java mailing list I belong to recently had this same  
conversation. I didn't know php had that ability built in. Java  
doesn't (score another one for php). The cleanest solution I saw on  
the Java list that would be non-language specific (in other words,  
the same logic can be implemented in ANY language) would be to set a  
variable to the first day of the month AHEAD of the month you want.  
For example, if your looking for February, 2000, set the variable to  
be March 1st, 2000. Then subtract 1 day. I have actually archived  
this solution in my own little knowledge base as I thought it was  
quite clever.



Hope this helps other people as well.


Jeff Pearson








On Jan 20, 2006, at 8:17 AM, <[EMAIL PROTECTED]> [EMAIL PROTECTED]> wrote:



date("t") will give you the number of days in the current month.

Or you can do:

date("t", mktime(0, 0, 0, $month, $day, $year))


to get the number of days in a specific month in a specific year  
(that way you can get leap year accurate counts..)


-TG

= = = Original message = = =

Is there a way to easily tell PHP how many days there are in a  
selected

month without writing the following out for each month:

if($Month == "January")
~$NumberOfDays = 31;

elseif($Month == "February")
~if($Year == "A Leap Year")
~~$NumberOfDays = 29;
~
~elseif($Year != "A Leap Year")
~~$NumberOfDays = 28;
~

elseif($Month == "March")
~$NumberOfDays = 31;

and so on, and so on, and so on

I would greatly appreciate any help.  Thanks.



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


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



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



Re: [PHP] difference between require and include

2006-01-20 Thread Adi
http://ca.php.net/manual/en/function.include.php

On 1/20/06, balachandar muruganantham <[EMAIL PROTECTED]> wrote:
>
> Can anyone tell me the exact differeneces between require and include?
>
> --
>  balachandar muruganantham
>  mbchandar
>   mbchandar
>  http://chandar.blogspot.com
> http://www.balachandar.net
>  http://www.expertstalk.org
> http://www.chennaishopping.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Take care...
Adam


RE: [PHP] difference between require and include

2006-01-20 Thread Weber Sites LTD
Check out some info here : 

http://www.weberdev.com/ViewArticle/440 

Sincerely 
 
berber 
 
Visit the Weber Sites Today, 
To see where PHP might take you tomorrow. 
PHP code examples : http://www.weberdev.com 
PHP Web Logs : http://www.weberblog.com/ 
PHP & MySQL Forums : http://www.weberforums.com/ 
Learn PHP Playing Trivia http://www.webertrivia.com 
Web Development Index http://www.weberindex.com 
Web Templates http://www.webertemplates.com
Search for PHP Code from your browser http://toolbar.weberdev.com 



-Original Message-
From: balachandar muruganantham [mailto:[EMAIL PROTECTED] 
Sent: Saturday, January 21, 2006 3:44 AM
To: php; php-install@lists.php.net
Subject: [PHP] difference between require and include

Can anyone tell me the exact differeneces between require and include?

--
 balachandar muruganantham
 mbchandar
  mbchandar
 http://chandar.blogspot.com
http://www.balachandar.net
 http://www.expertstalk.org
http://www.chennaishopping.com

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



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



RE: [PHP] Email Form

2006-01-20 Thread Weber Sites LTD
Lucky for me I have my own server :)

Thanks for the info, I will try it and report if I see any difference.

Sincerely 
 
berber 
 
Visit the Weber Sites Today, 
To see where PHP might take you tomorrow. 
PHP code examples : http://www.weberdev.com 
PHP Web Logs : http://www.weberblogs.com/ 
PHP & MySQL Forums : http://www.weberforums.com/ 
Learn PHP Playing Trivia http://www.webertrivia.com 
Web Development Index http://www.weberindex.com 
Web Templates http://www.webertemplates.com
Search for PHP Code from your browser http://toolbar.weberdev.com 

 

-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 20, 2006 11:21 PM
To: Weber Sites LTD
Cc: 'Igal Rubinstein'; 'Thomas Bonham'; php-general@lists.php.net
Subject: RE: [PHP] Email Form

On Fri, January 20, 2006 9:02 am, Weber Sites LTD wrote:
> I'm trying to understand why this is good from a SPAM point of view.
> I'm guessing that anyone can just add this when sending his own spam 
> no?

Hey, I'm not claiming that the spam criteria are rational, nor that any
halfway intelligent spammer could not "beat them"

I'm just telling you what *IS* happening today. :-)

Note, however, that many ISPs will not allow you to use that fifth argument,
or, more accurately, will configure sendmail to choke if you try to use it
with "-f" to set the Return-path: because you are not a "trusted user"

--
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



RE: [PHP] Managing sessions...

2006-01-20 Thread Weber Sites LTD
Maybe this class can help make things simpler :  

A beginner's session handling class
http://www.weberdev.com/get_example-4175.html 

Sincerely 
 
berber 
 
Visit the Weber Sites Today, 
To see where PHP might take you tomorrow. 
PHP code examples : http://www.weberdev.com 
PHP & MySQL Forums : http://www.weberforums.com
Learn PHP & MySQL Playing Trivia : http://www.webertrivia.com
PHP Web Logs : http://www.weberblogs.com 
Web Development Index http://www.weberindex.com 
Web Templates http://www.webertemplates.com
Search for PHP Code from your browser http://toolbar.weberdev.com 
Free Uptime Monitor : http://uptime.weberdev.com
PHP content for your site : http://content.weber-sites.com


-Original Message-
From: David BERCOT [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 20, 2006 6:54 PM
To: php-general@lists.php.net
Subject: [PHP] Managing sessions...

Hi again,

Ok, it's probably not the first time you have a question about sessions with
PHP ;-) I've tried to read mails, documentation, searching on Internet but,
finally, I think everything is not clear !!!

First of all, I understand that, if session.auto_start is not on '1', I have
to write session_start on each page I use !!! OK.
Before this line, I put options :
ini_set("session.use_only_cookies",1);
ini_set("session.use_trans_sid",0);
ini_set("error_reporting",E_ALL);
and then :
session_start();

I think it is very heavy to write... I read about
ini_set("session.auto_start",1) but, on my server (Debian), it doesn't seem
working...
And I also read about options which can be not set if I use auto_start...

So, I'd like to put my options (use_trans_sid, 0, etc...) and to have lite
scripts. Is it possible ?
Isn't there, like in asp, a global.asa where I can put all my parameters ?

Thank you very much.

David.

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

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