[PHP] Running PHP from inside another application!

2005-02-15 Thread Mikael Andersson
Hi,

I've a case where I have to run a lots of php-scrips, in a short time, from 
inside a delphi-application. Every script connects to the same databas.
Today I use CreateProcess to start php.exe and then I'm using pipes to get 
the php-result. I'm doing this for each php-script I want to run, and it's 
timeexpensive because every script has to establish a database-connection.

I'm new in the PHP-world, but I'm sure that there is a better way to solve 
this case.

I would prefer NOT to run php.exe all the time and of course I want to use 
the same databasconnectio, but I don't know how.

It's not an option to put all the scripts into one big script.

Thanks in advance

Best Regards
Mike 

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



[PHP] mediator between PHP and Perl (with sessions)

2005-02-15 Thread Eli
Hi...
I got a shared lib API written in PHP, that depends on sessions for its 
operation.
I took a prepared system in Perl that I want integrate with the shared 
lib API in PHP.

What I thought about is, to write a mediator class in Perl that will 
define the same API functions as I got in the shared lib API in PHP. I 
do not want to imitate the API functions workflow in Perl, but instead 
call the shared lib API in PHP from Perl (this way I don't have to 
maintain 2 class APIs in different languages).

I thought of making a PHP script that can run on shell and return 
serialized output of any API function in the shared lib. Then call that 
script from Perl and process the returned output in Perl.
Problem in this way is, that the shared lib in PHP uses sessions which 
are un-accessable from a shell script. And I cannot put that script on 
the web, since it returns sensitive data.
Is there a way to use sessions variables in PHP shell script (without 
reading the session file and parse it in the script)?

If anyone is familiar with any other implementation of such a mediator, 
please tell.

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


[PHP] mediator between PHP and Perl (with sessions)

2005-02-15 Thread Eli
Hi...
I got a shared lib API written in PHP, that depends on sessions for its 
operation.
I took a prepared system in Perl that I want integrate with the shared 
lib API in PHP.

What I thought about is, to write a mediator class in Perl that will 
define the same API functions as I got in the shared lib API in PHP. I 
do not want to imitate the API functions workflow in Perl, but instead 
call the shared lib API in PHP from Perl (this way I don't have to 
maintain 2 class APIs in different languages).

I thought of making a PHP script that can run on shell and return 
serialized output of any API function in the shared lib. Then call that 
script from Perl and process the returned output in Perl.
Problem in this way is, that the shared lib in PHP uses sessions which 
are un-accessable from a shell script. And I cannot put that script on 
the web, since it returns sensitive data.
Is there a way to use sessions variables in PHP shell script (without 
reading the session file and parse it in the script)?

If anyone is familiar with any other implementation of such a mediator, 
please tell.

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


Re: [PHP] User Passwords: checking for unique chars

2005-02-15 Thread Burhan Khalid
[ snipped ]

Oh!  You're so mean!!  ;)
A lot of people are making some great points.  I feel I must strighten
this out a little.  While I may not be the best coder in the world I
do have my reasons.  I originally made the passwords automatically
generated and emailed to the user.  Nice complicated ones!  I was
immediately shot down for doing this because no one here liked the
idea of having complicated passwords!  I was told to allow the user to
chose their own so I merely wanted to make sure no one could have
stupid passwords like aaa.  So I just added a few limitations. 
Besides, my small website doesn't hold any sensitive information about
anyone so it wouldn't be the end of the world if some cracked it!
Try something like http://sourceforge.net/projects/pwgen/ which 
generates passwords that are easy for humans to remember, yet not that 
dumb.

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


[PHP] Image Creation

2005-02-15 Thread Aaron Todd
I just wrote a little script to play around with the GD library but I am 
having a problem displaying it in the browser.  I have not problem at all 
when I just run the script.  But I was trying to make the image in a custom 
function which will return the image when its called.  All I end up getting 
is a bunch of weird characters.

Here's my code:
function makepie($slice, $total){
$height = 150;
$width = 150;
$im = ImageCreate($width, $height);
$bck = ImageColorAllocate($im, 255,255,255);
$black = ImageColorAllocate($im, 0, 0, 0);
$red = ImageColorAllocate($im, 255, 0, 0);
imagefilledellipse($im, 75, 75, 125, 125, $red);
imageellipse($im, 75, 75, 125, 125, $black);

//Making the Slice
$pieslice = (($slice / $total) * 360) + 315;
imagefilledarc($im, 75, 75, 125, 125, 315, $pieslice, $black, 
IMG_ARC_PIE);

//Return
header(Content-type: image/png);
echo ImagePNG($im);
  }

Anyone have any idea why I cant return the image?

Thanks 

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



[PHP] test

2005-02-15 Thread Giulio
only a test.
sorry
Cantoberon Multimedia srl
http://www.cantoberon.it
Tel. 06 39737052
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Many forms in one php file

2005-02-15 Thread James Taylor
Nsk wrote:
Hi
I want to create a single php file which will be able to display multiple html 
forms.

Like this: Form1 - Form2 - Form3.
After the user completes and submits Form1, the script will process it and 
display a different form. etc...

I am new to php, I would need some detailed instructions, or point me to an 
opensource php script which already does that so that I can analyse it.

In a single script it could be a little nasty if you want more then one 
or two phases - its common to have a submit and view result on the same 
script, but multiple stages can become a maintaince nightmare, but you 
can do it like this:

You could use a mode indicator and a session settings. Look for 
start_session() in the manual.

Something like:
?php
start_session();
if(!isset($_SESSION['mode'])){
 $_SESSION['mode'] = 0;  // first time round, on first screen
}
// function to test if mode is 0 AND button pressed (ie a submission,
// deal (store) the information and increment mode
if($_SESSION['mode'] == 0){
?
 form 1 /form 1
?php
} else if ($_SESSION['mode'] == 1) {
?
form 2 /form2
?php
 }
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: who's on-line application - php

2005-02-15 Thread Stefan Dengscherz
Hello,

usually you can not determine clearly who is online on your website at the
moment because http is a session-less protocol (thus php implements a session
mechanism through cookies or session id). However you can use the following
approach:

- add a 'last_seen' field to the users table of your website
- update that field for the user everytime he calls a page on your site
  (e.g. include(updatels.php); on every page)
- to get the number of (probably still) online users do a 'select from
  user_table where now()-lastseen  3 minutes'

another method would be changing the session handler to store session data in
the database and query the sessiontable appropriately.


best regards,

Stefan Dengscherz


On Mon, Feb 14, 2005 at 04:30:32PM +0200, Jacques wrote:
 I would like to indicate the particulars (from a MySQL database) of all
 those users that are currently on-line (those whom have successfully signed
 in). How should I go about achieving this? Does it have something to do with
 Sessions?
 
 I am developing in PHP.
 
 Regards
 
 Jacques
 
 -- 
 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] php products licensing system

2005-02-15 Thread Jad Madi
as I said, we are willing to have our product open source, but No
free. and that fair enough, thats why I'm asking about a good method
to protect our products from being used illegaly and keeping it open
source


On Tue, 15 Feb 2005 13:05:52 +0200, Jad Madi [EMAIL PROTECTED] wrote:
 as I said, we are willing to have our product open source, but No
 free. and that fair enough, thats why I'm asking about a good method
 to protect our products from being used illegaly and keeping it open
 source
 
 
 On Tue, 15 Feb 2005 10:11:59 +, timothy johnson
 [EMAIL PROTECTED] wrote:
  So you want to use open source to make it so people cant use your
  code. Does just doesnt sound right, but whatever
 
 
  On Tue, 15 Feb 2005 09:48:44 +0200, Jad Madi [EMAIL PROTECTED] wrote:
   Hi folks
I hardly convince my company to have their PHP products open source,
   now the challenge is to protect their products from being stolen and
   used illegally so we may Encode only one or two files to keep the use
   of our products on Certain domain or IP address. Any idea how to
   accomplish this ?
  
   if its a must to encode some files to achive our goal then we prefer
   to stick with opensource/free encoder, our choice now is mmCache
   Encoder, but since dl() gonna be depracted in the mean of removed in
   php5, we will not be able to offer our products for shared hosting
   clients
  
   any idea how to protect our products, keeping it open souce as much as
   possible ?
  
   --
   Web standards Planet
   http://www.w3planet.info/
   Personal Blogger
   http://www.EasyHTTP.com/jad/
   EasyHTTP Network
   http://www.EasyHTTP.com
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 
 --
 Web standards Planet
 http://www.w3planet.info/
 Personal Blogger
 http://www.EasyHTTP.com/jad/
 EasyHTTP Network
 http://www.EasyHTTP.com
 


-- 
Web standards Planet 
http://www.w3planet.info/
Personal Blogger
http://www.EasyHTTP.com/jad/
EasyHTTP Network
http://www.EasyHTTP.com

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



Re: [PHP] test

2005-02-15 Thread NSK
On Tuesday 15 February 2005 14:54, Giulio wrote:
 only a test.

Your test was successful

-- 
NSK
http://portal.wikinerds.org

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



Re: [PHP] base32/62 mcrypted data

2005-02-15 Thread Marek Kilimajer
Gary C. New wrote:
I am currently storing mcrypted data as a base64 encoded string.
I now need to store the mcrypted data as a base32 or base62 string, 
because of problems occurring due to the '+', '/', and '=' characters.

It seems that there is only the base64_en/decode default function.
Does anyone know of a method or a sample piece of code that can achieve 
the desired effect?
http://sk2.php.net/manual/en/function.base-convert.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP 5 with Apache 2.0

2005-02-15 Thread Lester Caine
Lars B. Jensen wrote:
So from here, go for it mate
Same here. The more of us running it the sooner it will become the norm ;)
--
Lester Caine
-
L.S.Caine Electronic Services
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] php products licensing system

2005-02-15 Thread Jason Barnett
Jad Madi wrote:
as I said, we are willing to have our product open source, but No
free. and that fair enough, thats why I'm asking about a good method
to protect our products from being used illegaly and keeping it open
source
It's a tough balancing act.  Encoding / closing the source with one of
the packages out there is an option.  The license that you use is
important and always be certain that LICENSE is included in every code
distribution.
Without knowing a little more about the exact product you sell it's
tough to give good advice, but some things that I have seen:
- Open up part of the source, but keep the valuable code closed
- Different licenses for different parts of the code
- Open source it all and charge for 24/7 support services
- Open source it all and charge for consulting / specialty services
- Open source it all, but only for a client application.  Then you have
the client connect to a server side app on your site and you charge per
usage.
My advice: look at some of the *successful* and more importantly
*profitable* open source companies out there.
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


Re: [PHP] mediator between PHP and Perl (with sessions)

2005-02-15 Thread Matt M.
 Is there a way to use sessions variables in PHP shell script (without
 reading the session file and parse it in the script)?

Do you have a database available?  You could put the session info in a database.

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



Re: [PHP] Fancy Form processing Ideas

2005-02-15 Thread Burhan Khalid
Chris W. Parker wrote:
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
on Monday, February 14, 2005 6:29 AM said:

I am looking for interesting approaches to form submissions and error
checking in the forms.

One time, at PHP Summer Camp, I made this one form that, when submitted,
would open the CD tray on my server which would tip over a hammer that
would slam down on the enter key which would say yes to the question
Do you want to validate the form that was just submitted? [yes].
It wasn't very efficient considering I always had to push the CD tray
back in and rebalance the hammer every time. But boy was it ever a
Fancy Form processing idea.
LOL Chris.  You rock.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Delete a file immediately after download

2005-02-15 Thread Shaun
Hi,

I have a database that contains encrypted data using Mysql function 
ENCODE(). Certain users will be allowed to view this data and I will allow 
them to download a CSV file contain the decrypted data using the Mysql 
DECODE() function. However I don't want this file to be left on the server, 
is there a way to ensure that the file is deleted immediately after it has 
been downloaded?

Thanks for your help. 

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



[PHP] Re: Running PHP from inside another application!

2005-02-15 Thread Jason Barnett
Mikael Andersson wrote:
Hi,
I've a case where I have to run a lots of php-scrips, in a short time, from
inside a delphi-application. Every script connects to the same databas.
Today I use CreateProcess to start php.exe and then I'm using pipes to get
the php-result. I'm doing this for each php-script I want to run, and it's
timeexpensive because every script has to establish a database-connection.
I'm new in the PHP-world, but I'm sure that there is a better way to solve
this case.
There is.  :)  From what you say I think the Embed SAPI will be a good
way for you to go - it allows you to embed a PHP parser within another
application.  *NOTE* This is not for the faint of heart!
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


[PHP] How to make use of the billing token the right way???

2005-02-15 Thread Scott Fletcher
I created the token via Javascript where the billing can be controlled
better and to prevent the mixed up of the billing such as incorrect
statements or calculation.  I use the billing lock file for that purpose.  I
found that it doesn't alway work that way when the browser is refreshed or
submitted, so I customized the Javascript to make it work better.  That
solve my problem but I found that some browsers acted too soon or too late
with it's use of Javascript coding to unlocking the file, so the billing
lock doesn't get released.  So, I decided to do it all in PHP so the
browsers' issues can be removed.  I haven't decided how to best make use of
the token via PHP, so I'm wondering if anyone of you can come up with one
that is better than what I can come up with.

1) A token is a file with machine's IP address and time-stamp.
2) The machine's IP address is in charge of hte token until released.
3) If the machine with the same IP address opened another browser window,
that 2nd browser window can't have the token because the 1st browser window
are using it.  Even though it is the same webpage regardless of what part of
billing it's in.  (This one I have trouble with).

Thanks,
 Scott

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



[PHP] Handling email bouncebacks

2005-02-15 Thread Chris Bruce
Hi,
I am looking for a way to manage email bouncebacks on my Linux server 
for one of my client's email marketing system. What I would like to do 
is have a way of capturing the email address from the header of each 
bounce and insert it into a MySQL table. At that point I can do the 
requisite scrubbing of the lists. I believe that I saw a PHP class a 
while back that handled this. Does anyone have any experience with 
this?

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


[PHP] Re: How to make use of the billing token the right way???

2005-02-15 Thread Jason Barnett
Scott Fletcher wrote:
I created the token via Javascript where the billing can be controlled
better and to prevent the mixed up of the billing such as incorrect
statements or calculation.  I use the billing lock file for that purpose.  I
found that it doesn't alway work that way when the browser is refreshed or
submitted, so I customized the Javascript to make it work better.  That
solve my problem but I found that some browsers acted too soon or too late
with it's use of Javascript coding to unlocking the file, so the billing
lock doesn't get released.  So, I decided to do it all in PHP so the
browsers' issues can be removed.  I haven't decided how to best make use of
the token via PHP, so I'm wondering if anyone of you can come up with one
that is better than what I can come up with.
Call me crazy... but what about just using a cookie / session mechanism
for this?  One browser, one cookie, your site.  Heck they even generate
tokens for you.  :)
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


Re: [PHP] Delete a file immediately after download

2005-02-15 Thread Matt M.
 I have a database that contains encrypted data using Mysql function
 ENCODE(). Certain users will be allowed to view this data and I will allow
 them to download a CSV file contain the decrypted data using the Mysql
 DECODE() function. However I don't want this file to be left on the server,
 is there a way to ensure that the file is deleted immediately after it has
 been downloaded?

http://us4.php.net/unlink

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



Re: [PHP] Delete a file immediately after download

2005-02-15 Thread Shaun
Hi Matt,

Thanks for the reply, I know how to delete a file I just wanted to know if 
its possible to ensure that its deleted automatically as soon as the user 
has downloaded it.

Thanks...

Matt M. [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 I have a database that contains encrypted data using Mysql function
 ENCODE(). Certain users will be allowed to view this data and I will 
 allow
 them to download a CSV file contain the decrypted data using the Mysql
 DECODE() function. However I don't want this file to be left on the 
 server,
 is there a way to ensure that the file is deleted immediately after it 
 has
 been downloaded?

 http://us4.php.net/unlink 

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



[PHP] Re: mediator between PHP and Perl (with sessions)

2005-02-15 Thread Eli
It's quite easy to pass the session variables to the script. The problem 
with sessions and shell PHP scripts, is that PHP doesn't support 
sessions on that mode (CLI mode it is called). So, I would have to 
manualy read the session file and parse it. If anyone knows what is the 
exact function that is used to unserialize the session file, please 
tell.. and it's not the unserialize() function in PHP.

I guess that using a shell PHP script with sessions is not the solution. 
Is anybody familiar with another way to use sessions??? but not through 
web, since the script returns sensitive data.

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


[PHP] fopen problem using ftp

2005-02-15 Thread Giulio
HI all,
I have a script that uses fopen to acces for read a file using ftp:
$filepointer = fopen($address,'r');
having $address string formed this way:
$address =  
ftp:/ 
/.$FTPuser.:.$FTPpassword.@.$FTPserver./.$FileFolder./.$FileNa 
me;

This script always worked for me, it has now stopped working trying it  
on the server of a different provider, returning an error 'failed to  
open stream...'

I have the suspect that the funcion is failing due to the particular  
account name ( used also as FTP username ) this italian provider gived  
me when I sibscribed: It contains a @ symbol ( I.E., [EMAIL PROTECTED] ),  
 and I believe that this confuses the parsing of the  
ftp://User:[EMAIL PROTECTED]/filepath string.

Can you confirm this, or do you believe that the problem could be  
caused by other factors ( like server settings ) ?

Could you suggest me e workaround?
 Thank you,
  Giulio
Cantoberon Multimedia srl
http://www.cantoberon.it
Tel. 06 39737052

[PHP] Re: PHP 5 with Apache 2.0

2005-02-15 Thread Matthew Weier O'Phinney
* Neal Schilling [EMAIL PROTECTED]:
 I know this question probably gets asked a lot, but I'm setting up a Web 
 Server shortly and am debating going with PHP 5 on Apache 2.0 or 1.3. In 
 short, is PHP 5, when combined with either Apache 1.3 or 2.0 on Linux or 
 FreeBSD, ready for a production environment? This is, of course, an 
 opinion, but back your opinion with as much fact as possible.

I read a blog entry by a PHP/PEAR developer that stated the following:

Serving PHP via Apache 2 is 27 percent slower then via Apache 1 DSO and
31 percent slower then Apache 1 static.

(http://ilia.ws/archives/32-Apache-1-vs-Apache-2-Performance.html)

The flip side is that apache2 is faster at serving static content, both
in compressed an uncompressed form. Make your own conclusions.

Basically, the big benefit of using apache2 is threading support -- but
PHP4/PHP5 are not considered threadsafe -- not because PHP isn't
threadsafe, but because a number of the libraries against which it *may*
link may not be threadsafe. So, when you run PHP in the apache2 prefork
mode, you lose all the threading benefits.

 Also, if PHP 5 is NOT ready, do you feel PHP 4.3 is ready for production 
 with Apache 2.0?

As far as I know, the same issues are present for PHP4 as PHP5 when
using apache2.

-- 
Matthew Weier O'Phinney   | WEBSITES:
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org

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



[PHP] [NEWBIE] Trying to combine array into one string

2005-02-15 Thread Dave
PHP General,
   The Situation:
   I'm retrieving some email addresses from a database. I want to be 
able assemble all the addresses into one string that I can use in the 
mail() command. At no time should there ever be more than about 5 email 
addresses collected from the database. I want all addresses to appear in 
the To: field so everyone receiving the email will know who else has a 
copy.

   The Problem:
   I can't quite figure out how to take the results of the 
mysql_query() and assemble them into a string. In my experiments so far, 
I either get a mysql_data_seek(): Offset 0 is invalid for MySQL result 
index error, or my mail function sends to a blank address.

   What I've Tried So Far:
   My own code is obviously flawed in syntax in logic, so I searched 
the manual and this list's archives under the terms array, 
concatenate, convert, append and string in various combinations. 
However, while I learned some interesting tips on a variety of topics, I 
suspect I'm missing some essential description that will lead me to the 
command I need.

   The Question:
   How do I take the contents of an array and turn them into a single 
string?

   For Reference:
   Here is the code I have. I know it's flawed, but hopefully it will 
give an indication of what I'm trying to achieve:
--code--
   $tantoQuery = SELECT forum_members.emailAddress AS email FROM 
forum_members, event_tanto WHERE forum_members.ID_MEMBER = 
event_tanto.tanto AND event_tanto.event =' . $show . ';

   $tantoResult = mysql_query($tantoQuery);
   while ($tantoData = mysql_fetch_array($tantoResult))
   {
   $tantoEmail = $tantoEmail . , . $tantoData;
   }
   mail($tantoEmail, $subject, $mailcontent, $addHeaders);
--code--
   Any help would be much appreciated.
--
Dave Gutteridge
[EMAIL PROTECTED]
Tokyo Comedy Store
http://www.tokyocomedy.com/english/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] isset

2005-02-15 Thread D_C
I often use this type of construct 

$cmd = $_POST['cmd'];
if ($cmd == null) { // do default

but this throws a notice if the ['cmd'] index is not defined. ugly.
using 

if (isset($_POST['cmd'] ) {
  $cmd = $_POST['cmd'];
} 

seems lengthy. is there a way around this?

i tried using 
$cmd = @ $_POST['cmd'];

to suppress errors but didnt seem to have ay effect. 

tx.


-- 
___
   David DC Collier
mobile business creator 
   [EMAIL PROTECTED]
   skype: d3ntaku
   http://www.pikkle.com
   +81 (0)90-7414-6107

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



RE: [PHP] [NEWBIE] Trying to combine array into one string

2005-02-15 Thread Warren Vail
Try loading he email address to an array from your query;

$addressarray[] = $address;

and when done extracting the rows from your database, parse them into a comma 
separated string using

$listofaddresses = implode(, ,$addressarray);

HTH,

Warren Vail

 -Original Message-
 From: Dave [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, February 15, 2005 7:37 AM
 To: php-general
 Subject: [PHP] [NEWBIE] Trying to combine array into one string
 
 
 PHP General,
 
 The Situation:
 I'm retrieving some email addresses from a database. I want to be 
 able assemble all the addresses into one string that I can use in the 
 mail() command. At no time should there ever be more than about 5 email 
 addresses collected from the database. I want all addresses to appear in 
 the To: field so everyone receiving the email will know who else has a 
 copy.
 
 The Problem:
 I can't quite figure out how to take the results of the 
 mysql_query() and assemble them into a string. In my experiments so far, 
 I either get a mysql_data_seek(): Offset 0 is invalid for MySQL result 
 index error, or my mail function sends to a blank address.
 
 What I've Tried So Far:
 My own code is obviously flawed in syntax in logic, so I searched 
 the manual and this list's archives under the terms array, 
 concatenate, convert, append and string in various combinations. 
 However, while I learned some interesting tips on a variety of topics, I 
 suspect I'm missing some essential description that will lead me to the 
 command I need.
 
 The Question:
 How do I take the contents of an array and turn them into a single 
 string?
 
 For Reference:
 Here is the code I have. I know it's flawed, but hopefully it will 
 give an indication of what I'm trying to achieve:
 --code--
 $tantoQuery = SELECT forum_members.emailAddress AS email FROM 
 forum_members, event_tanto WHERE forum_members.ID_MEMBER = 
 event_tanto.tanto AND event_tanto.event =' . $show . ';
 
 $tantoResult = mysql_query($tantoQuery);
 
 while ($tantoData = mysql_fetch_array($tantoResult))
 {
 $tantoEmail = $tantoEmail . , . $tantoData;
 }
 
 mail($tantoEmail, $subject, $mailcontent, $addHeaders);
 --code--
 
 Any help would be much appreciated.
 
 -- 
 Dave Gutteridge
 [EMAIL PROTECTED]
 Tokyo Comedy Store
 http://www.tokyocomedy.com/english/
 
 -- 
 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] [NEWBIE] Trying to combine array into one string

2005-02-15 Thread Matt M.
 The Problem:
 I can't quite figure out how to take the results of the
 mysql_query() and assemble them into a string. In my experiments so far,
 I either get a mysql_data_seek(): Offset 0 is invalid for MySQL result
 index error, or my mail function sends to a blank address.

no guarantee it works:

$tantoQuery = SELECT forum_members.emailAddress AS email FROM
forum_members, event_tanto WHERE forum_members.ID_MEMBER =
event_tanto.tanto AND event_tanto.event =' . $show . ';

$tantoResult = mysql_query($tantoQuery) or die('Query failed: ' .
mysql_error());

while ($tantoData = mysql_fetch_array($tantoResult, MYSQL_ASSOC))
{
$tantoEmail[] = $tantoData['email'];
}

if (count($tantoEmail)  0) {
mail(implode(',',$tantoEmail), $subject, $mailcontent, $addHeaders);
}


mysql_free_result($tantoResult);

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



Re: [PHP] [NEWBIE] Trying to combine array into one string

2005-02-15 Thread Gareth Williams
Use implode:
http://nl2.php.net/manual/en/function.implode.php

On 15 Feb 2005, at 16:37, Dave wrote:
PHP General,
   The Situation:
   I'm retrieving some email addresses from a database. I want to be 
able assemble all the addresses into one string that I can use in the 
mail() command. At no time should there ever be more than about 5 
email addresses collected from the database. I want all addresses to 
appear in the To: field so everyone receiving the email will know 
who else has a copy.

   The Problem:
   I can't quite figure out how to take the results of the 
mysql_query() and assemble them into a string. In my experiments so 
far, I either get a mysql_data_seek(): Offset 0 is invalid for MySQL 
result index error, or my mail function sends to a blank address.

   What I've Tried So Far:
   My own code is obviously flawed in syntax in logic, so I searched 
the manual and this list's archives under the terms array, 
concatenate, convert, append and string in various 
combinations. However, while I learned some interesting tips on a 
variety of topics, I suspect I'm missing some essential description 
that will lead me to the command I need.

   The Question:
   How do I take the contents of an array and turn them into a single 
string?

   For Reference:
   Here is the code I have. I know it's flawed, but hopefully it will 
give an indication of what I'm trying to achieve:
--code--
   $tantoQuery = SELECT forum_members.emailAddress AS email FROM 
forum_members, event_tanto WHERE forum_members.ID_MEMBER = 
event_tanto.tanto AND event_tanto.event =' . $show . ';

   $tantoResult = mysql_query($tantoQuery);
   while ($tantoData = mysql_fetch_array($tantoResult))
   {
   $tantoEmail = $tantoEmail . , . $tantoData;
   }
   mail($tantoEmail, $subject, $mailcontent, $addHeaders);
--code--
   Any help would be much appreciated.
--
Dave Gutteridge
[EMAIL PROTECTED]
Tokyo Comedy Store
http://www.tokyocomedy.com/english/
--
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] [NEWBIE] Trying to combine array into one string

2005-02-15 Thread Chris W. Parker
Dave mailto:[EMAIL PROTECTED]
on Tuesday, February 15, 2005 7:37 AM said:

 The Problem:
 I can't quite figure out how to take the results of the
 mysql_query() and assemble them into a string. In my experiments so
 far, I either get a mysql_data_seek(): Offset 0 is invalid for MySQL
 result index error, or my mail function sends to a blank address.

http://php.net/implode


There's also the .= operator which concatenates.


HTH,
Chris.

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



[PHP] Re: Image Creation

2005-02-15 Thread Aaron Todd
Thanks for the compliment on my function.  I have since improved upon 
it...see below.

I can do the exact same thing as you and get results, but what I can't do is 
show the image within an HTML table.  I think it is something to do with the 
header line, but I dont know how to get around it.  I've tried just calling 
the function like I have in the code below.  I've also tried calling the 
function inside of img command.  Both ways dont work.

Check out the code if you can and let me know if you seen anything that I am 
doing wrong.  Thanks

?php
  function makepie($slice, $total){
$height = 150;
$width = 150;
$im = ImageCreate($width, $height);
$bck = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
$white = ImageColorAllocate($im, 255, 255, 255);
$red = ImageColorAllocate($im, 255, 0, 0);
$blue = ImageColorAllocate($im, 0, 0, 255);
//imagefilledellipse($im, 75, 75, 125, 125, $red);
//imageellipse($im, 75, 75, 125, 125, $black);

//Making the Slice
$pieslice = (($slice / $total) * 360) + 315;
imagefilledarc($im, 75, 75, 125, 125, 315, $pieslice, $blue, 
IMG_ARC_PIE);
imagefilledarc($im, 75, 75, 125, 125, 315, $pieslice, $black, 
IMG_ARC_NOFILL);
imagefilledarc($im, 75, 75, 125, 125, $pieslice, 315, $red, 
IMG_ARC_PIE);
imagefilledarc($im, 75, 75, 125, 125, $pieslice, 315, $black, 
IMG_ARC_NOFILL);

//Return
Header(Content-type: image/png);
ImagePNG($im);
  }
   echo table border='1' cellpadding='0' cellspacing='0' 
style='border-collapse: collapse' bordercolor='#11' width='200' 
bgcolor='#FFD1A4'
  tr
td width='100%' colspan='2' align='center'This is a 
testbr.makepie(20,200)./td
  /tr
/table;
?




James Taylor [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Dude - that works fine!

 can you check your code - make sure you havnt got any white space at all 
 before the php starts in ANY file, and then check that you've got ALL 
 erros being reported (because you might have the error cant send headers, 
 output allready sent at line x)  which will prenvent the header being sent 
 and then you dump the image to the screen which is the random wierd 
 characters (that means the image create functions are all ok and 
 installed, and you have an image object or similar).

 my code was simple ?php {your function} makepie(10,100); ? NO WHITESPACE 
 NO BLANK LINES NOTHING.

 (ps you might even have a php include in the php file (php prepend or 
 something?) which might be inserting a space or a newline or ending 
 headers or something. Look at error_reporting() or similar in the manual 
 to turn error reporting on for your script.

 Hope you find the bug, thats quite a nice function you have there.
 J

 Aaron Todd wrote:
 I just wrote a little script to play around with the GD library but I am 
 having a problem displaying it in the browser.  I have not problem at all 
 when I just run the script.  But I was trying to make the image in a 
 custom function which will return the image when its called.  All I end 
 up getting is a bunch of weird characters.

 Here's my code:
 function makepie($slice, $total){
 $height = 150;
 $width = 150;
 $im = ImageCreate($width, $height);
 $bck = ImageColorAllocate($im, 255,255,255);
 $black = ImageColorAllocate($im, 0, 0, 0);
 $red = ImageColorAllocate($im, 255, 0, 0);
 imagefilledellipse($im, 75, 75, 125, 125, $red);
 imageellipse($im, 75, 75, 125, 125, $black);

 //Making the Slice
 $pieslice = (($slice / $total) * 360) + 315;
 imagefilledarc($im, 75, 75, 125, 125, 315, $pieslice, $black, 
 IMG_ARC_PIE);

 //Return
 header(Content-type: image/png);
 echo ImagePNG($im);
   }

 Anyone have any idea why I cant return the image?

 Thanks 

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



[PHP] Re: isset

2005-02-15 Thread M. Sokolewicz
D_c wrote:
I often use this type of construct 

$cmd = $_POST['cmd'];
if ($cmd == null) { // do default
but this throws a notice if the ['cmd'] index is not defined. ugly.
using 

if (isset($_POST['cmd'] ) {
  $cmd = $_POST['cmd'];
} 

seems lengthy. is there a way around this?
i tried using 
$cmd = @ $_POST['cmd'];

to suppress errors but didnt seem to have ay effect. 

tx.

still
if(isset($_POST['cmd'])) {
   $cmd = $_POST['cmd'];
}
is the only (really) correct way. All others throw notices of undefined 
indices, which you *should not* ignore! You can't shorten it, you can't 
even wrap it in a function... it's simply tough luck

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


[PHP] Re: How to make use of the billing token the right way???

2005-02-15 Thread Scott Fletcher
I can do the Session Token but problem is two browser windows can have the
same Session Token via File -- New Window or Browser Tab.  I have thought
about using the Database Table instead but it all go back to the original
problem with 2 same browser windows that use the same Session.

I'm thinking of a random number or brower's window serial number of some
sort but I don't see how.

Scott

Jason Barnett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

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



[PHP] Many forms in one php file

2005-02-15 Thread NSK
Hi

I want to create a single php file which will be able to display multiple html 
forms.

Like this: Form1 - Form2 - Form3.

After the user completes and submits Form1, the script will process it and 
display a different form. etc...

I am new to php, I would need some detailed instructions, or point me to an 
opensource php script which already does that so that I can analyse it.

-- 
NSK
http://portal.wikinerds.org

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



Re: [PHP] [NEWBIE] Trying to combine array into one string

2005-02-15 Thread Leif Gregory
Hello Dave,

Tuesday, February 15, 2005, 8:37:02 AM, you wrote:
D while ($tantoData = mysql_fetch_array($tantoResult))
D {
D $tantoEmail = $tantoEmail . , . $tantoData;
D }

D mail($tantoEmail, $subject, $mailcontent, $addHeaders);


Everything looked good up to here.


$tantoEmail = $tantoEmail . , . $tantoData['email'];

I'm not that great at SQL syntax, but this should work. That'll at
least get your e-mail addresses in there. The next problem is that,
and for purposes of demonstration we'll say you pulled out three
addresses, you're going to have a comma before the first e-mail
address.

i.e.

,address1,address2,address3

because the first time through the while, $tantoEmail is empty, then
you put a comma and the first address.

So, you'd need to $tantoEmail = ltrim($tantoEmail, ,); that.

You can further shorten that to:
$tantoEmail .=  , . $tantoData['email'];

but you'd still need to ltrim that to get rid of the first comma.

Another way to do this to avoid having to worry about that pesky
comma. 

while ($tantoData = mysql_fetch_array($tantoResult))
{
if ($tantoEmail != )
   $tantoEmail .=  , . $tantoData['email'];
else
   $tantoEmail = $tantoData['email'];
}


--
Leif (TB lists moderator and fellow end user).

Using The Bat! 3.0.2.3 Rush under Windows XP 5.1
Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB

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



[PHP] Re: Set a timeout on file_get_contents?

2005-02-15 Thread Jason Barnett
Brian Dunning wrote:
Is there any way to specify a timeout on a file_get_contents()? I'm
trying to verify a URL but I don't want to spend more than a few seconds
on it.
- Brian
Note that using file_get_contents to do this is only going to work if
your php.ini has allow_url_fopen = 1.  Actually I think we just
discussed a solution last week that would work for you.
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


[PHP] php_serializer

2005-02-15 Thread Catalin Trifu
Hi,
Is the php5 session serializer php_binary faster than the php one ?
Or it's purpose is just to obscure the saved datas ?
thanks,
catalin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Image Creation

2005-02-15 Thread Matt M.
get rid of :

   echo table border='1' cellpadding='0' cellspacing='0'
style='border-collapse: collapse' bordercolor='#11' width='200'
bgcolor='#FFD1A4'
 tr
   td width='100%' colspan='2' align='center'This is a
testbr.makepie(20,200)./td
 /tr
   /table;

and only have this :

makepie(20,200);

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



Re: [PHP] [NEWBIE] Trying to combine array into one string

2005-02-15 Thread Jochem Maas
Dave wrote:
PHP General,
   The Situation:
   I'm retrieving some email addresses from a database. I want to be 
able assemble all the addresses into one string that I can use in the 
mail() command. At no time should there ever be more than about 5 email 
addresses collected from the database. I want all addresses to appear in 
the To: field so everyone receiving the email will know who else has a 
copy.

   The Problem:
   I can't quite figure out how to take the results of the mysql_query() 
and assemble them into a string. In my experiments so far, I either get 
a mysql_data_seek(): Offset 0 is invalid for MySQL result index error, 
or my mail function sends to a blank address.

   What I've Tried So Far:
   My own code is obviously flawed in syntax in logic, so I searched the 
manual and this list's archives under the terms array, concatenate, 
convert, append and string in various combinations. However, while 
I learned some interesting tips on a variety of topics, I suspect I'm 
missing some essential description that will lead me to the command I need.

   The Question:
   How do I take the contents of an array and turn them into a single 
string?

   For Reference:
   Here is the code I have. I know it's flawed, but hopefully it will 
give an indication of what I'm trying to achieve:
--code--
   $tantoQuery = SELECT forum_members.emailAddress AS email FROM 
forum_members, event_tanto WHERE forum_members.ID_MEMBER = 
event_tanto.tanto AND event_tanto.event =' . $show . ';

   $tantoResult = mysql_query($tantoQuery);
   while ($tantoData = mysql_fetch_array($tantoResult))
   {
   $tantoEmail = $tantoEmail . , . $tantoData;
   }
$tantoData is an array so you can't just concat it into a string.
change the body of the while loop to something like:
if (!isset($tantoEmail)) {
$tantoEmail = $tantoData['email'];
} else {
$tantoEmail .= , . $tantoData['email'];
}
or do something like
$tantoEmail = array();
while ($tantoData = mysql_fetch_array($tantoResult)) {
$tantoEmail[] = $tantoData['email'];
}
if ($tantoEmail = join(',',$tantoEmail)) {
mail($tantoEmail, $subject, $mailcontent, $addHeaders);
}
   mail($tantoEmail, $subject, $mailcontent, $addHeaders);
--code--
   Any help would be much appreciated.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP book recommendations

2005-02-15 Thread Chris Shiflett
--- Bosky, Dave [EMAIL PROTECTED] wrote:
 I'm looking for an easy to read PHP book that will help me learn a
 solid foundation in PHP.

If you need a strong foundation:

http://www.oreilly.com/catalog/learnphp5/

If you already have a strong foundation:

http://www.amazon.com/exec/obidos/ASIN/0672325616

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly HTTP Developer's Handbook - Sams
Coming Soon http://httphandbook.org/

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



[PHP] Set a timeout on file_get_contents?

2005-02-15 Thread Brian Dunning
Is there any way to specify a timeout on a file_get_contents()? I'm 
trying to verify a URL but I don't want to spend more than a few 
seconds on it.

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


[PHP] Re: [NEWBIE] Trying to combine array into one string

2005-02-15 Thread Ospinto
while ($tantoData = mysql_fetch_array($tantoResult))
 {
 $tantoEmailArray[] = $tantoData;
 }

now all the values are stored into an array ($tantoEmailArray). to convert
an array to a string and join the elements together by a delimiter, use
implode.
hence: implode(,,$tantoEmailArray);
so final email command could be:

mail(implode(,,$tantoEmailArray), $subject, $mailcontent, $addHeaders);

cheers


Dave [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 PHP General,

 The Situation:
 I'm retrieving some email addresses from a database. I want to be
 able assemble all the addresses into one string that I can use in the
 mail() command. At no time should there ever be more than about 5 email
 addresses collected from the database. I want all addresses to appear in
 the To: field so everyone receiving the email will know who else has a
 copy.

 The Problem:
 I can't quite figure out how to take the results of the
 mysql_query() and assemble them into a string. In my experiments so far,
 I either get a mysql_data_seek(): Offset 0 is invalid for MySQL result
 index error, or my mail function sends to a blank address.

 What I've Tried So Far:
 My own code is obviously flawed in syntax in logic, so I searched
 the manual and this list's archives under the terms array,
 concatenate, convert, append and string in various combinations.
 However, while I learned some interesting tips on a variety of topics, I
 suspect I'm missing some essential description that will lead me to the
 command I need.

 The Question:
 How do I take the contents of an array and turn them into a single
 string?

 For Reference:
 Here is the code I have. I know it's flawed, but hopefully it will
 give an indication of what I'm trying to achieve:
 --code--
 $tantoQuery = SELECT forum_members.emailAddress AS email FROM
 forum_members, event_tanto WHERE forum_members.ID_MEMBER =
 event_tanto.tanto AND event_tanto.event =' . $show . ';

 $tantoResult = mysql_query($tantoQuery);

 while ($tantoData = mysql_fetch_array($tantoResult))
 {
 $tantoEmail = $tantoEmail . , . $tantoData;
 }

 mail($tantoEmail, $subject, $mailcontent, $addHeaders);
 --code--

 Any help would be much appreciated.

 --
 Dave Gutteridge
 [EMAIL PROTECTED]
 Tokyo Comedy Store
 http://www.tokyocomedy.com/english/

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



[PHP] Re: How to make use of the billing token the right way???

2005-02-15 Thread Jason Barnett
Scott Fletcher wrote:
I can do the Session Token but problem is two browser windows can have the
same Session Token via File -- New Window or Browser Tab.  I have thought
about using the Database Table instead but it all go back to the original
problem with 2 same browser windows that use the same Session.
OK, I get your concern.  In that case why not pass a uniqid() as a
hidden form field in a POST form?  (GET would work also, but not I would
go POST).  If it's a multipage form you can keep passing this uniqid
from one page on to the next.
I'm thinking of a random number or brower's window serial number of some
sort but I don't see how.
Scott
Jason Barnett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


Re: [PHP] Many forms in one php file

2005-02-15 Thread Leif Gregory
Hello NSK,

Tuesday, February 15, 2005, 8:21:43 AM, you wrote:
N After the user completes and submits Form1, the script will process
N it and display a different form. etc...


There's a boatload of ways to do this, but here's a real simple one to
get you rolling. I'll leave it up to you to make it better.


?php
if ($_POST['form3Complete'] == 1)
{
  echo You're done! Thanks.;
  exit;
}

if ($_POST['form2Complete'] == 1) { ?

form name=form3 method=post action=? echo $_SERVER['PHP_SELF'];?
  //Your form stuff
  input type=hidden name=form3Complete value=1
/form

?php } elseif ($_POST['form1Complete'] == 1) { ?

form name=form2 method=post action=? echo $_SERVER['PHP_SELF'];?
  //Your form stuff
  input type=hidden name=form2Complete value=1
/form

?php } else { ?

form name=form1 method=post action=? echo $_SERVER['PHP_SELF'];?
  //Your form stuff
  input type=hidden name=form1Complete value=1
/form
?php } ?


-- 
Leif (TB lists moderator and fellow end user).

Using The Bat! 3.0.2.3 Rush under Windows XP 5.1
Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB

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



[PHP] Re: Image Creation

2005-02-15 Thread Aaron Todd
Hey Guys,

I think I fixed my own problem.  I tried calling the PHP script from a 
different page like this:

img border='0' src='include/pie.php?slice=100total=200'

This gave me the results I wanted.

Thanks for all your help.

Aaron


Aaron Todd [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
I just wrote a little script to play around with the GD library but I am 
having a problem displaying it in the browser.  I have not problem at all 
when I just run the script.  But I was trying to make the image in a custom 
function which will return the image when its called.  All I end up getting 
is a bunch of weird characters.

 Here's my code:
 function makepie($slice, $total){
$height = 150;
$width = 150;
$im = ImageCreate($width, $height);
$bck = ImageColorAllocate($im, 255,255,255);
$black = ImageColorAllocate($im, 0, 0, 0);
$red = ImageColorAllocate($im, 255, 0, 0);
imagefilledellipse($im, 75, 75, 125, 125, $red);
imageellipse($im, 75, 75, 125, 125, $black);

//Making the Slice
$pieslice = (($slice / $total) * 360) + 315;
imagefilledarc($im, 75, 75, 125, 125, 315, $pieslice, $black, 
 IMG_ARC_PIE);

//Return
header(Content-type: image/png);
echo ImagePNG($im);
  }

 Anyone have any idea why I cant return the image?

 Thanks 

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



[PHP] Re: Image Creation

2005-02-15 Thread James Taylor
Dude - that works fine!
can you check your code - make sure you havnt got any white space at all 
before the php starts in ANY file, and then check that you've got ALL 
erros being reported (because you might have the error cant send 
headers, output allready sent at line x)  which will prenvent the header 
being sent and then you dump the image to the screen which is the random 
wierd characters (that means the image create functions are all ok and 
installed, and you have an image object or similar).

my code was simple ?php {your function} makepie(10,100); ? NO 
WHITESPACE NO BLANK LINES NOTHING.

(ps you might even have a php include in the php file (php prepend or 
something?) which might be inserting a space or a newline or ending 
headers or something. Look at error_reporting() or similar in the manual 
to turn error reporting on for your script.

Hope you find the bug, thats quite a nice function you have there.
J
Aaron Todd wrote:
I just wrote a little script to play around with the GD library but I am 
having a problem displaying it in the browser.  I have not problem at all 
when I just run the script.  But I was trying to make the image in a custom 
function which will return the image when its called.  All I end up getting 
is a bunch of weird characters.

Here's my code:
function makepie($slice, $total){
$height = 150;
$width = 150;
$im = ImageCreate($width, $height);
$bck = ImageColorAllocate($im, 255,255,255);
$black = ImageColorAllocate($im, 0, 0, 0);
$red = ImageColorAllocate($im, 255, 0, 0);
imagefilledellipse($im, 75, 75, 125, 125, $red);
imageellipse($im, 75, 75, 125, 125, $black);
//Making the Slice
$pieslice = (($slice / $total) * 360) + 315;
imagefilledarc($im, 75, 75, 125, 125, 315, $pieslice, $black, 
IMG_ARC_PIE);

//Return
header(Content-type: image/png);
echo ImagePNG($im);
  }
Anyone have any idea why I cant return the image?
Thanks 
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Re: isset

2005-02-15 Thread Chris W. Parker
M. Sokolewicz mailto:[EMAIL PROTECTED]
on Tuesday, February 15, 2005 8:25 AM said:

 seems lengthy. is there a way around this?
 
 i tried using
 $cmd = @ $_POST['cmd'];
 
 to suppress errors but didnt seem to have ay effect.
 
 still
 if(isset($_POST['cmd'])) {
 $cmd = $_POST['cmd'];
 }
 
 is the only (really) correct way. All others throw notices of
 undefined indices, which you *should not* ignore! You can't shorten
 it, you can't even wrap it in a function... it's simply tough luck

Please correct me if I'm wrong (and maybe this is what you mean by
(really)) but I think even Rasmus recommends:

?php

  if(!empty($_POST['cmd']))
  {
// stuff
  }

?

I'm using the following code to test this:

?php

error_reporting(E_ALL);

if(!empty($_POST['cmd']))
{
echo set and not emptybr /;
}
else
{
echo empty and/or not setbr /;
}

?




Chris.

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



Re: [PHP] isset

2005-02-15 Thread Richard Lynch
D_C wrote:
 I often use this type of construct

 $cmd = $_POST['cmd'];
 if ($cmd == null) { // do default

 but this throws a notice if the ['cmd'] index is not defined. ugly.
 using

 if (isset($_POST['cmd'] ) {
   $cmd = $_POST['cmd'];
 }

 seems lengthy. is there a way around this?

 i tried using
 $cmd = @ $_POST['cmd'];

 to suppress errors but didnt seem to have ay effect.

You could maybe put the @ in front of the $cmd:
@$cmd = $_POST['cmd'];

However, I think it would be most clear to do:
$cmd = isset($_POST['cmd']) ? $_POST['cmd'] : NULL;

You can then rest assured that $cmd *IS* set in the rest of your script.

It's a bit lengthy, but at least it's all on one concise line, and you can
easily copy/paste and comment in/out the line.

-- 
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] PHP book recommendations

2005-02-15 Thread Joe Harman
personally, I like Julie Meloni's books... PHP essentials.. and fast
and easy web development... these were some of the first books that i
bought and got started with... they are pretty easy to use, especially
if you are not into reading technical manuals

http://www.thickbook.com



On Tue, 15 Feb 2005 14:20:05 -0500, Joe Harman [EMAIL PROTECTED] wrote:
 sorry... wrong address
 
 
 On Tue, 15 Feb 2005 14:19:46 -0500, Joe Harman [EMAIL PROTECTED] wrote:
  personally, I like Julie Meloni's books... PHP essentials.. and fast
  and easy web development... these were some of the first books that i
  bought and got started with... they are pretty easy to use, especially
  if you are not into reading technical manuals
 
 
  On Tue, 15 Feb 2005 08:54:14 -0800 (PST), Chris Shiflett
  [EMAIL PROTECTED] wrote:
   --- Bosky, Dave [EMAIL PROTECTED] wrote:
I'm looking for an easy to read PHP book that will help me learn a
solid foundation in PHP.
  
   If you need a strong foundation:
  
   http://www.oreilly.com/catalog/learnphp5/
  
   If you already have a strong foundation:
  
   http://www.amazon.com/exec/obidos/ASIN/0672325616
  
   Hope that helps.
  
   Chris
  
   =
   Chris Shiflett - http://shiflett.org/
  
   PHP Security - O'Reilly HTTP Developer's Handbook - Sams
   Coming Soon http://httphandbook.org/
  
   --
   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] [NEWBIE] Trying to combine array into one string

2005-02-15 Thread Richard Lynch
Dave wrote:
 The Situation:
 I'm retrieving some email addresses from a database. I want to be
 able assemble all the addresses into one string that I can use in the
 mail() command. At no time should there ever be more than about 5 email
 addresses collected from the database. I want all addresses to appear in
 the To: field so everyone receiving the email will know who else has a
 copy.

I believe some mailers may have trouble with more than one address in To:

You may want to put the first address in To:  and the rest in Cc: 

Or you can put an address in the To:  field to keep a log of all
outgoing emails, or send it to some account that just deletes all email.

Only Bcc:  will hide email addresses.

 The Problem:
 I can't quite figure out how to take the results of the
 mysql_query() and assemble them into a string. In my experiments so far,
 I either get a mysql_data_seek(): Offset 0 is invalid for MySQL result
 index error, or my mail function sends to a blank address.

The data_seek error is telling you that there were NO results at all in
that data set, I do believe...

 What I've Tried So Far:
 My own code is obviously flawed in syntax in logic, so I searched
 the manual and this list's archives under the terms array,
 concatenate, convert, append and string in various combinations.
 However, while I learned some interesting tips on a variety of topics, I
 suspect I'm missing some essential description that will lead me to the
 command I need.

 The Question:
 How do I take the contents of an array and turn them into a single
 string?

http://php.net/implode

will take a bunch of stuff in one array and turn them into a string.

 For Reference:
 Here is the code I have. I know it's flawed, but hopefully it will
 give an indication of what I'm trying to achieve:
 --code--
 $tantoQuery = SELECT forum_members.emailAddress AS email FROM
 forum_members, event_tanto WHERE forum_members.ID_MEMBER =
 event_tanto.tanto AND event_tanto.event =' . $show . ';

 $tantoResult = mysql_query($tantoQuery);

For debugging purposes, print out $tantoResult:

echo tantoResult: '$tantoResult'hr /\n;

It will either be Resource #1 (or #2, #3, ...) if the query succeeded,
or false -- which will appear as nothing when you print it which is why
I've got that label and the apostrophes there.

 while ($tantoData = mysql_fetch_array($tantoResult))
 {
 $tantoEmail = $tantoEmail . , . $tantoData;

Also print out $tantoData:

echo tantoData: '$tantoData'hr /\n;

You will quickly find out that it's an Array -- which is the ARRAY
returned from mysql_fetch_array.  [Fancy that, a function that ends in
'array' returning an array :-)]

All you'll see, however is 'Array' which is not real useful.

So use var_dump($tantoData) to see what's *IN* the array:

echo pre;
var_dump($tantoData);
echo /prehr /\n;

Now you'll see that it is a one-element array with an index of
'emailAddress' to it.

So what you need in your code is something like:
$tantoResult .= $tantoData['emailAddress'];

Except that you'd need a comma separator like this:
$tantoResult .= ,  . $tantoData['emailAddress'];

But then you've got a bogus extra comma on the front of the whole result,
and that's no good.

You could strip it off with http://php.net/substr, but it's probably more
clean to do like this:

$tantoResult = array();
while ($tantoData = mysql_fetch_array($tantoResult))
{
  $tantoResult[] = $tantoData['emailAddress'];
}

So now you've built up this array of the email addresses, and you can use
that implode function:

$tantoEmails = implode(, , $tantoResult);

Note that implode only puts commas BETWEEN the elements it splices
together, so you won't have the extra comma at the end.

 }

 mail($tantoEmail, $subject, $mailcontent, $addHeaders);
 --code--

 Any help would be much appreciated.

You're on the right track, but when your script isn't doing what you
think, add in some print statements to see what your data actually looks
like.

Often you can then figure out where you went wrong.

Be sure to print out the data early and often -- Sometimes the problem
you see is really caused every early on in the script.

-- 
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] fopen problem using ftp

2005-02-15 Thread Richard Lynch
Giulio wrote:
 HI all,

 I have a script that uses fopen to acces for read a file using ftp:

 $filepointer = fopen($address,'r');

 having $address string formed this way:

 $address =
 ftp:/
 /.$FTPuser.:.$FTPpassword.@.$FTPserver./.$FileFolder./.$FileNa
 me;

You really don't need all those '.' in there:P

$address = ftp://$FTPuser:[EMAIL PROTECTED]/$FileFolder/$FileName;

will work just fine.

Not any faster or anything, just more readable.

 This script always worked for me, it has now stopped working trying it
 on the server of a different provider, returning an error 'failed to
 open stream...'

 I have the suspect that the funcion is failing due to the particular
 account name ( used also as FTP username ) this italian provider gived
 me when I sibscribed: It contains a @ symbol ( I.E., [EMAIL PROTECTED] ),
   and I believe that this confuses the parsing of the
 ftp://User:[EMAIL PROTECTED]/filepath string.

 Can you confirm this, or do you believe that the problem could be
 caused by other factors ( like server settings ) ?

 Could you suggest me e workaround?

Try using just the 123456 of the username...  Probably won't work, but
worth a shot.

Or do this:
$FTPuserURL = urlencode($FTPuser);
before you compose the $address, and use $FTPuserURL instead of $FTPuser.

That will replace the @ with %40 which will almost for sure be the kosher
way have @ in an FTP username in a URL.

Technically, you could/should also urlencode() the password and FilePath
and FileName, I think.

-- 
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] Many forms in one php file

2005-02-15 Thread Jay Blanchard
[snip]
I want to create a single php file which will be able to display
multiple html 
forms.

Like this: Form1 - Form2 - Form3.

After the user completes and submits Form1, the script will process it
and 
display a different form. etc...

I am new to php, I would need some detailed instructions, or point me to
an 
opensource php script which already does that so that I can analyse it.
[/snip]

Google is your friend for tutorials and there are several examples of
what you want to do web wide. Basically your form action(s) will be
$PHP_SELF and you should use the POST method. Each form could be a case
in a switch statement http://www.php.net/switch with each form button
having an action. There are several good examples there

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



[PHP] PHP Array question

2005-02-15 Thread R. Van Tassel
I have an array with image names like:

 

$arrayone = array(1.jpg, 2.jpg);

$arraytwo = array(a.jpg, b.jpg);

 

 

Then I have a variable for each to count the number of elements:

 

$arrayoneElements = count($arrayone);

$arraytwoElements = count($arraytwo);

 

 

I'm using the element variables to control the loop to display all the array
elements.

 

This is it:

 

for($ctr=1; $ctr  $elemcount; $ctr++){

   if($ctr%5){

  echo td width=\20%\a
href=\javascript:popup_pic('.$gallerypath./$arr[$ctr]')\img
src=\.$gallerypath.thumbs/$arr[$ctr]\ alt=\no image\ //a/td;

   }else{

  echo td width=\20%\a
href=\javascript:popup_pic('.$gallerypath./$arr[$ctr]')\img
src=\.$gallerypath.thumbs/$arr[$ctr]\ alt=\no image\
//a/td/tr\ntr;

   }

}

 

 

What I want to do is to only show 20 pictures at a time with a Next link
and a Previous link. For the first 20 only the Next link would show and
whenever the last set would show only the Previous link would. Every other
time both would show.

 

Can someone point me in the right direction on how to count through the
elements until the end and back to display them? I just can't figure it out.

 

Thanks,

-Roy

 



Re: [PHP] Re: mediator between PHP and Perl (with sessions)

2005-02-15 Thread Richard Lynch
Eli wrote:
 It's quite easy to pass the session variables to the script. The problem
 with sessions and shell PHP scripts, is that PHP doesn't support
 sessions on that mode (CLI mode it is called). So, I would have to
 manualy read the session file and parse it. If anyone knows what is the
 exact function that is used to unserialize the session file, please
 tell.. and it's not the unserialize() function in PHP.

 I guess that using a shell PHP script with sessions is not the solution.
 Is anybody familiar with another way to use sessions??? but not through
 web, since the script returns sensitive data.

I THINK you MIGHT be able to use some session functions to set the session
name and session file when you do session_start() and get PHP to do all
the work of the reading/writing the files.  You just need to pass in the
session ID to session_name() or session_start() or something like that.  I
forget how to do this, but I did it once when I couldn't get trans-sid to
work, and it was a one-line solution.  Try to find it.  Maybe session_id()
takes an optional argument.

If that fails, then here's option 2:

There is sample code for storing your session data in MySQL on the
web-site in the manual.

You could easily take that code and swap out the MySQL bits to just
read/write your own session files, or go ahead and use MySQL if it's okay
security-wise, or put the data anywhere you feel appropriate for your
application.


If that's not auitable, to answer your original question :-) is Option 3:

I think the session files consist of a series of variable names and
serialized values separated by semi-colons or something like that.

So to read/write the session files would be something not unlike:
$data = file($session_file);
$elements = explode(';', $data);
while (list(, $element) = each($elements)){
  list($var, $serialized) = explode(':', $element);
  $$var = unserialize($serialized);
}

-- 
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] Re: mediator between PHP and Perl (with sessions)

2005-02-15 Thread Warren Vail
Eli,

Sessions work just fine with CLI (Command Line Interpreter), although there is 
little need for them as a CLI script, since once started the script does not 
wait on user clicks of a browser for it's next set of input, therefore no need 
to use sessions for passing information.  Most CLI scripts are started via a 
cron process, and if started from a webpage, the items passed to the script can 
be passed via command line parameters, or if passed as session variables, the 
session key needs to be passed to the CLI script, since CLI scripts don't have 
access to cookies.  One advantage of using session variables when starting a 
CLI script, is that the session may be able to pass bigger values than can be 
contained in a command line. (Command line variables can be accessed in the 
argc/argv array like in c) and once passed this way the sessions are no 
longer needed since your CLI script will run to completion.

If your server is a NIX box, you may have access to the  character after the 
command name that will cause it to run as a separate shell script, but you will 
need to set the timeout to allow it to run long enough, and if you do not use 
the  separate shell character, the script will be interruptible by the user 
who started it by clicking a button like stop on his browser.

The unserialize function is indeed used for sessions, but with most newer 
releases of PHP register variables is turned off, which means the variables 
are not restored automatically (you will find them in the $_SESSION array).  
Sections of the manual you may want to reread are as follows;

http://www.php.net/manual/en/ref.session.php
http://www.php.net/manual/en/function.session-set-save-handler.php (good 
illustrations of what happens in sessions)
http://www.php.net/manual/en/function.session-register.php (notice the notes on 
register variables).
http://www.php.net/manual/en/function.session-id.php
http://us3.php.net/manual/en/function.set-time-limit.php to allow script to run 
longer.
http://us3.php.net/manual/en/function.shell-exec.php for starting a cli script 
(don't forget to start php).

hope this helps,

Warren Vail

 -Original Message-
 From: Eli [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, February 15, 2005 7:07 AM
 To: php-general@lists.php.net
 Subject: [PHP] Re: mediator between PHP and Perl (with sessions)
 
 
 It's quite easy to pass the session variables to the script. The problem 
 with sessions and shell PHP scripts, is that PHP doesn't support 
 sessions on that mode (CLI mode it is called). So, I would have to 
 manualy read the session file and parse it. If anyone knows what is the 
 exact function that is used to unserialize the session file, please 
 tell.. and it's not the unserialize() function in PHP.
 
 I guess that using a shell PHP script with sessions is not the solution. 
 Is anybody familiar with another way to use sessions??? but not through 
 web, since the script returns sensitive data.
 
 
 -thanks, Eli
 
 -- 
 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] Delete a file immediately after download

2005-02-15 Thread Richard Lynch
Shaun wrote:
 Thanks for the reply, I know how to delete a file I just wanted to know if
 its possible to ensure that its deleted automatically as soon as the user
 has downloaded it.

Yes.

You don't even put the file into your web tree DocumentRoot directory, and
you write a PHP script that allows the user to view it.

Something like this:

?php
  $path = /path/to/some/directory/not/in/the/web/tree/;
  $filename = isset($_REQUEST['filename']) ? $_REQUEST['filename'] : die();
  //Use this to be damn sure they don't go after /etc/passwd or ../secret
or...
  $filename = preg_replace('/[^A-Za-z0-9_-]/', '', $filename);
  //Allow for the possibility of the file not being read correctly, and
  //only delete it if your hardware behaves.
  if (readfile($path$filename)){
unlink($path$filename);
  }
?

The only thing is, though, that if the user aborts halfway through their
download, or their network connection flakes out, or, for that matter,
*YOUR* network connection dies on the server, or...

There are a lot of reasons why the file could end up not ACTUALLY being
delivered to the browser, but you'd still delete it.

If the user can just do over whatever they did to get the file, that's
no big deal.

If this is something where they paid money for it, but you delete the file
before they REALLY successfully get it, that's a bit more of a problem.

In that case, you might be better off to warn the user the file will be
available for download only for 72 hours, and record a time-stamp in the
db with each filename when it gets created, and then run a cron job that
unlink's anything from the db older than 72 hours.

Which you might want to do ANYWAY to get rid of files that some goofball
user never bothers to download, or the readfile actually does fail (rare,
but possible) or they cancel the connection and your script quits halfway
through the readfile or...

-- 
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] Set a timeout on file_get_contents?

2005-02-15 Thread Torsten Rosenberger
Am Di, den 15.02.2005 schrieb Brian Dunning um 16:48:
 Is there any way to specify a timeout on a file_get_contents()? I'm 
 trying to verify a URL but I don't want to spend more than a few 
 seconds on it.

http://de.php.net/manual/de/function.fsockopen.php

not so easy a file_get_contents but with a timeout

BR/Torsten

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



[PHP] Re: mediator between PHP and Perl (with sessions)

2005-02-15 Thread Eli
Hi..
Thanks for your help. I searched a bit more, combined with your data, 
tested, and found a solution. :-)

#!/usr/local/bin/php -q
?php
//initialize parameters:
if ($argc2)
   exit(ERROR: session id must be provide as parameter.\n);
$sid=$argv[1];
//initialize session:
ini_set(session.use_cookies,0);  //use no session cookies
session_cache_limiter(null);  //use no session cache limiter
session_id($sid);  //set the session id as got from parameter 1
//read the session variables:
echo $_SESSION[name];
?
-thanks, Eli
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: mediator between PHP and Perl (with sessions)

2005-02-15 Thread Eli
Eli wrote:
Hi..
Thanks for your help. I searched a bit more, combined with your data, 
tested, and found a solution. :-)
Oops.. forgot the most important line..

#!/usr/local/bin/php -q
?php
//initialize parameters:
if ($argc2)
   exit(ERROR: session id must be provide as parameter.\n);
$sid=$argv[1];
//initialize session:
ini_set(session.use_cookies,0);  //use no session cookies
session_cache_limiter(null);  //use no session cache limiter
session_id($sid);  //set the session id as got from parameter 1
session_start();  //start the session
//read the session variables:
echo $_SESSION[name];
?
-thanks, Eli
-thanks, Eli
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Delete a file immediately after download

2005-02-15 Thread Richard Lynch
Matt M. wrote:
 I have a database that contains encrypted data using Mysql function
 ENCODE(). Certain users will be allowed to view this data and I will
 allow
 them to download a CSV file contain the decrypted data using the Mysql
 DECODE() function. However I don't want this file to be left on the
 server,
 is there a way to ensure that the file is deleted immediately after it
 has
 been downloaded?

 http://us4.php.net/unlink

PS If the data is REALLY sensitive, you may want to look into command line
tools to actually ERASE the data instead of just doing unlink.

'unlink' only nukes the directory information to find the file.  The file
contents still exist, intact, and there are tools to mine un-linked files
to find content.

Hard Drive forensics experts can even manage to retrieve over-written
files based on some very very very expensive/hard analysis of the magentic
fields -- Sort of like reading through scratched out stuff on paper by
holding it up to the light, only a lot more technical and a lot more
expensive...  It's unlikely you need to worry about *THAT* though, as I
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] Image Creation

2005-02-15 Thread Richard Lynch
Aaron Todd wrote:
 I just wrote a little script to play around with the GD library but I am
 having a problem displaying it in the browser.  I have not problem at all
 when I just run the script.  But I was trying to make the image in a
 custom
 function which will return the image when its called.  All I end up
 getting
 is a bunch of weird characters.

Those weird characters ARE the image.

Most likely, you finally got it right, and got rid of all the error
messages, and now your image is PERFECT.

However, when you have the errors in it, PHP sent out a Cotnent-type:
text/html header before the error messages -- so you could see them as
text error messages, which they were.

At that time, Internet Explorer *CACHED* those headers, and is now
thoroughly  convinced that the URL *is* text/html, even though you are no
longer sending that header.  So IE is going to keep showing you the
document as text/html, because IE is really stupid.

If you quit IE, and start up again, and surf to the image, it should all
just work.

Oh, and don't do:
echo ImagePNG($im);

Just to:
ImagePNG($im);

The imageXYZ functions print out the image already, and then return 0 or
-1 or something based on their success/failure to print the image.

The way it works out, you're actually dumping out the image and then some
bogus data at the end -- because the ImagePNG gets called FIRST, which
prints out the image, and then your echo prints out the return value after
all the image data went out.

Most browsers probably gonna ignore that bogus extra data at the end of
the image.

You might want to add some error checking to your code.

And use imagecreatetruecolor() to make a cleaner pie internally, even
though you are converting to PNG in the end.

 Here's my code:
 function makepie($slice, $total){
 $height = 150;
 $width = 150;
 $im = ImageCreate($width, $height);
 $bck = ImageColorAllocate($im, 255,255,255);
 $black = ImageColorAllocate($im, 0, 0, 0);
 $red = ImageColorAllocate($im, 255, 0, 0);
 imagefilledellipse($im, 75, 75, 125, 125, $red);
 imageellipse($im, 75, 75, 125, 125, $black);

 //Making the Slice
 $pieslice = (($slice / $total) * 360) + 315;
 imagefilledarc($im, 75, 75, 125, 125, 315, $pieslice, $black,
 IMG_ARC_PIE);

 //Return
 header(Content-type: image/png);
 echo ImagePNG($im);
   }

 Anyone have any idea why I cant return the image?

 Thanks

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




-- 
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] Running PHP from inside another application!

2005-02-15 Thread Richard Lynch
Mikael Andersson wrote:
 I've a case where I have to run a lots of php-scrips, in a short time,
 from
 inside a delphi-application. Every script connects to the same databas.
 Today I use CreateProcess to start php.exe and then I'm using pipes to get
 the php-result. I'm doing this for each php-script I want to run, and it's
 timeexpensive because every script has to establish a database-connection.

Perhaps you can use something that would essentially load in the
database-connecting script, and then each other script individually, one
after the other.

If all the scripts use _pconnect, then you'd probably see the performance
gain.

Another possibility is to use the Delphi application to choose *WHICH*
scripts to run, but call a single PHP script that:
connects to database
gets the list of scripts from Delphi (on command line or whatever)
runs each script

You'd need to modify something somewhere to get the results separated from
script to script, so I dunno if that's viable.

 I'm new in the PHP-world, but I'm sure that there is a better way to solve
 this case.

 I would prefer NOT to run php.exe all the time and of course I want to use
 the same databasconnectio, but I don't know how.

 It's not an option to put all the scripts into one big script.

I don't suppose not using Delphi at all is an option either? ... :-)

-- 
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] php products licensing system

2005-02-15 Thread Richard Lynch
Jad Madi wrote:
  I hardly convince my company to have their PHP products open source,
 now the challenge is to protect their products from being stolen and
 used illegally so we may Encode only one or two files to keep the use
 of our products on Certain domain or IP address. Any idea how to
 accomplish this ?

Here's the thing:

Software piracy is a social problem.

It's really not solved well by a technical response.

Your best bet is to have a CLEAR and FAIR licensing deal, that anybody
running the software will simply pay up.

No matter what you do, there will ALWAYS be somebody who will find way to
steal your software.

If you make it simple and easy and inexpensive to just BUY it legally,
you'll minimize the losses, without losing customers who will refuse to
use software with encrypted source, or the hassle of dongles or hardware
dependencies or any of that other solutions to this problem.

 if its a must to encode some files to achive our goal then we prefer
 to stick with opensource/free encoder, our choice now is mmCache
 Encoder, but since dl() gonna be depracted in the mean of removed in
 php5, we will not be able to offer our products for shared hosting
 clients

Again, just license it cheaply enough and simply enough that they'll pay
up rather than try to fight you and steal it.

 any idea how to protect our products, keeping it open souce as much as
 possible ?

If your software is worth buying and is priced fairly and clearly
licensed, and if you provide an easy way for the customer to pay up when
the license is due, you'll have a lot less headaches than trying to encode
it.

If your software is NOT fairly/clearly priced, or it's too difficult to
pay and renew the license, you'll end up losing far more money than the
encryption will save you.

-- 
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] Many forms in one php file

2005-02-15 Thread Richard Lynch
NSK wrote:
 I want to create a single php file which will be able to display multiple
 html
 forms.

 Like this: Form1 - Form2 - Form3.

 After the user completes and submits Form1, the script will process it and
 display a different form. etc...

 I am new to php, I would need some detailed instructions, or point me to
 an
 opensource php script which already does that so that I can analyse it.

One crucial question to ask yourself:

Is this something the user will fill out ONCE in their life (like a
survey) or will the have to come back and update some of the content once
in a while (like a user profile).

If it's a one-time thing, then what you describe is fine.

If it's *NOT* (and it usually isn't) you're better off keeping each form
separate with some kind of navigation (like folder tabs) and letting the
user choose which forms to update when.

You can track the last_update on each form and notate the ones that are
out of date in the interface (make the out-dated tabs RED or something) or
even prompt the user at login to update their XYZ content.

Think about how this data and the forms will be used long-term, and how it
will be maintained, not just how to get the information in the first time.

Even if it's a one-time deal, keeping the forms separately provides some
benefits.  If their browser crashes or whatever you can more easily direct
them to the form where they left off if they are all separate.

Nothing annoys a user more than filling out 90% of the screens and getting
logged out after they get distracted by lunch, bathroom break, the boss
asking them to actually do some work, the browser crashing, etc and then
finding out all their entries are *GONE*

Be nice to users -- Plan for that kind of [bleep] to happen.

-- 
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] PHP 5 with Apache 2.0

2005-02-15 Thread Richard Lynch
Neal Schilling wrote:
 I know this question probably gets asked a lot, but I'm setting up a Web
 Server shortly and am debating going with PHP 5 on Apache 2.0 or 1.3. In
 short, is PHP 5, when combined with either Apache 1.3 or 2.0 on Linux or
 FreeBSD, ready for a production environment? This is, of course, an
 opinion, but back your opinion with as much fact as possible.

 Also, if PHP 5 is NOT ready, do you feel PHP 4.3 is ready for production
 with Apache 2.0?

What features in Apache 2.0 do you NEED?
What features in PHP 5 do you NEED?
Which modules of PHP do you NEED?

The answers to these questions, and some testing on a development server
(with stress-load testing!) will answer your question for YOU, which has
very little to do with anybody else's answer to the question. :-)

-- 
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] Removing non-numbers

2005-02-15 Thread Richard Lynch
Ben Miller wrote:
 OK - easy one here, I know.  Having troubles removing anything that is not
 a
 number from user input.  According to manual, [!] is supposed to mean set
 of
 non-matching optional characters.  Tried

! means that, but only in a completely different context from what you are
using...

   $var = ereg_replace([!0-9],,$var);

$var = ereg_replace([^0-9], , $var);

 and it removes the numbers, but so does

   $var = ereg_replace([0-9],,$var);

What you had was stripping OUT the digits.  Plus taking out ! in the
first one.

-- 
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] PHP Array question

2005-02-15 Thread Matt M.
 What I want to do is to only show 20 pictures at a time with a Next link
 and a Previous link. For the first 20 only the Next link would show and
 whenever the last set would show only the Previous link would. Every other
 time both would show.
 
 Can someone point me in the right direction on how to count through the
 elements until the end and back to display them? I just can't figure it out.


sounds like you just might need some paging functions

http://pear.php.net/package/Pager
http://pear.php.net/manual/en/package.html.pager.php

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



Re: [PHP] User Passwords: checking for unique chars

2005-02-15 Thread Richard Lynch
Jochem Maas wrote:
 Alex Gemmell wrote:
 On Mon, 14 Feb 2005 22:51:42 +0100, Jochem Maas [EMAIL PROTECTED]
 wrote:

Alex Gemmell wrote:
  #Contain at least one number
  if ( !preg_match ('/\\d/', $password) ) return false;

Im pretty sure the double backslash is a typo.

No, it's *NOT* a typo.

Inside of apostrophes, \ *IS* a special character.

It's also special inside of quotes, but let's stick with apostrophes for now.

\ is used to escape an apostrophe inside of apostrophes.

So you can do:

$var = 'Don\'t forget to escape apostrophes!';

Because \ is used to escape the apostrophe, you also use it to escape the
backslash itself:

$var = 'Backslash \\ should also be escaped';

Inside apostrophes, those are the ONLY two special cases:
\' turns into apostrophe:   '
\\ turns into backslash:\

Inside quotes, you've got a bunch more like \n, \r, \t as well as variable
substitution going on.

Now, because ONLY those two special cases exist, you *CAN* type:

$var = '\d';

and PHP will store internally:   \d

because the backslash wasn't followed by ' or \, so it must be just a
literal backslash.

But that doesn't make it Good Style.

In my *opinion* one should use:

$var = '\\d';

so that it is completely clear that the backslash is being escpaed, and
you're not trying to get a control-D (end of file) or whatever.

Or, put it this way:

It's incredibly unlikely that PHP will ever change '\d' to mean control-D.

But it'e even MORE unlikely that PHP would change '\\d' to mean anything
other than:\d

The same sort of paradigm is true for quote marks -- You *CAN* get away
with a single \ inside of quotes, so long as it's not followed by:
n
r
t
$

x[0-9A-Fa-f]{1,2} (a Hex number with \x in front)
[0-7]{1,3} (an Octal number with \ in front)

But with *THAT* many possible following characters, people have gotten
more in the habit of using \\ inside quotes.

But PHP is consistent with *BOTH* apostrophes and quotes about the \
character:  There are always a limited number of character combinations
that can follow \ to give it special meaning.  Any other character
combination following \ just uses \ literally.

\d always turns into \d inside quotes or apostrophes.
\a always turns into \a
\b turns into \b
.
.
.

ONLY \, \n, \r, \t, etc (see above) turn into something else inside quotes.
ONLY \' and \\ turn into something else inside apostrophes.

To be CLEAR in your code, however, I highly recommend using \\ in ALL
strings when you want a literal backslash -- so that there is no question
whether you are trying to escape the next character as something special,
or you just want a backslash.

\\ *always* means a single backslash

\ sometimes means a single backslash, and sometimes means something
entirely different depending on what follows it.

Use \\, so you *always* know what is going on.

 well you have to escape the bslash if your using double quotes.
 there is a reason sane people (normally) write regexps in php
 using single quotes :-)

Unless your regex contains apostrophes a lot, and then quotes are easier. :-)

//Bad Example: (strstr would be better choice here)
$contraction = ereg(', $word);

I'm sure others will disagree with me, but this is my opinion on writing
clear code with \ inside of apostrophes and quotes:

Always use \\ to get a literal backslash, and you'll never get confused,
because \\ always means one (1) backslash.

-- 
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] Session Vars and Performance

2005-02-15 Thread Richard Lynch
Greg Donald wrote:
 On Mon, 14 Feb 2005 16:03:10 -0500, [EMAIL PROTECTED]
 [EMAIL PROTECTED] wrote:
 I have a multi-page form which I build up and store in session
 variables.  The data saved includes all an internal list of items on
 the form (derived from a database table), all the form field specs
 (derived from the internal item list), the data for the fields (from
 another table), default data for restting the form (from yet another
 table), and a data structure for my forms class.

 It adds up to about 250KB in the actual session file -- that is, the
 serialized data.

 I'm not clear of the impact this will have in performance when it's in
 a multi-user environment, and I'm not sure at what point the overhead

Throw an ab (Apache Benchmark) test at it and find out.

Don't just guess or sit there wondering.

You could run test in about the time it took to compose this email --
certainly as fast as the total man-hours put in by all of us
reading/discussing it on the list :-)

 of serializing and unserializing gets to be more than the overhead of
 sticking this stuff in a temporary database table and then retrieving
 it.  Serializing is simpler but my git says there has to be a point at
 which it gets inefficient.  Testing is complex since I would have to
 write all the database code in order to do any performance measurement.

Actually...

All the database code is already written for you on the PHP web-site, and
it's about one 8.5x11 page of five (5) functions.

Doesn't really sound like a complex test to me.

Even if it *IS* a lot to do...

The database connection is going to dwarf the rest of it, almost for sure,
so just time how long it takes to open up a database connection, compared
to loading your existing file-based sessions.

Sending the actual query and getting/storing the results will be
chump-change compared to opening the db connection, almost for sure.

*UNLESS* every page that needs session data already *HAS* a db connection.

At which point you are comparing:
Hard drive access, with hard drive cache and page faults
Database access, with database buffers

These two will be neck-and-neck on performance, and will depend more on
your hardware than on somebody else's experience with their hardware.

Particularly if you've got a 2-tier setup with database on one box and PHP
on another, where your network hardware and cabling gets involved.

 Anyone have relevant experience in this area, and/or some educated
 guesses?

 You can minimize the data storage requirements by using short variable
 names and casting your numeric values to integers when possible.

 PHP sessions store everything as strings unless you specify otherwise.
  For example, here is the integer 123 stored in a session both ways,
 as a string and cast to an integer:

 v|s:3:123;

 v|i:123;

 There are other things too.. like converting IP addresses to longs
 with ip2long().  Storing a long int is more efficient than storing
 7-15 bytes of character data.

 Just look at your session data and see what can be stored smaller,
 variable names included.

[shudder]

If you have to choose between a meaningful variable name and performance
considerations, buy more hardware! :-)

The cost you'll save in the long run for code maintenance will make it
worth 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] Delete a file immediately after download

2005-02-15 Thread Bret Hughes
On Tue, 2005-02-15 at 14:00, Richard Lynch wrote:
 Matt M. wrote:
  I have a database that contains encrypted data using Mysql function
  ENCODE(). Certain users will be allowed to view this data and I will
  allow
  them to download a CSV file contain the decrypted data using the Mysql
  DECODE() function. However I don't want this file to be left on the
  server,
  is there a way to ensure that the file is deleted immediately after it
  has
  been downloaded?
 
  http://us4.php.net/unlink
 
 PS If the data is REALLY sensitive, you may want to look into command line
 tools to actually ERASE the data instead of just doing unlink.
 
 'unlink' only nukes the directory information to find the file.  The file
 contents still exist, intact, and there are tools to mine un-linked files
 to find content.
 
 Hard Drive forensics experts can even manage to retrieve over-written
 files based on some very very very expensive/hard analysis of the magentic
 fields -- Sort of like reading through scratched out stuff on paper by
 holding it up to the light, only a lot more technical and a lot more
 expensive...  It's unlikely you need to worry about *THAT* though, as I
 understand it...
 

As Richard pointed out the unlink will leave the data on the disk but
simply remove the directory pointers to it.  If physical security of the
box is an issue then overwriting the file with random data and then
unlinking it might be a decent solution.  If a file is opened for
writing I suspect it depends on the operating system as to whether the
same disk blocks are used so overwriting a file might not actually over
write the data on the disk.  It should, however at least change the
directory entry enough that someone with access to the box will not be
able to use a simple undelete utility to retrieve the file.

Bret

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



[PHP] issue with accents and mysql

2005-02-15 Thread mario
Hello,

please help me on the following issue.
please reply to [EMAIL PROTECTED] too.
(I asked for help on the php-db ml, but nobody replied)

I have hacked the following function:
function accents($text) {
   global $export;
   $search  = array ( 'à', 'è', 'ì', 'ò' , 'ù');
   $replace = array ( '\\`{a}', '\\`{e}', '\\`{i}', '\\`{o}', '\\`{u}');
   $export= str_replace($search, $replace, $text);
   return $export;
}

It works fine, as long as I feed it with a string: 
accents('à') -- \`{a} 

The issue is when I get 'à' from a mysql table. 
I.e., for some record of a mysql table Table, let à the value of the
field Field, and say
$result =  mysql_fetch_array($answer, MYSQL_BOTH), 
where $answer= mysql_query(SELECT * FROM Table).


Now accents($result['Field']) returns à (instead of \`{a}).
Why? I have no idea. 

Any hint is welcome.
Thanks a lot
mario

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



Re: [PHP] issue with accents and mysql

2005-02-15 Thread Guillermo Rauch
Try
SHOW VARIABLES LIKE 'character_set%'

and verify your character set is latin1.

If not, see http://dev.mysql.com/doc/mysql/en/charset-database.html

On Tue, 15 Feb 2005 22:04:30 +, mario [EMAIL PROTECTED] wrote:
 Hello,
 
 please help me on the following issue.
 please reply to [EMAIL PROTECTED] too.
 (I asked for help on the php-db ml, but nobody replied)
 
 I have hacked the following function:
 function accents($text) {
   global $export;
   $search  = array ( 'à', 'è', 'ì', 'ò' , 'ù');
   $replace = array ( '\\`{a}', '\\`{e}', '\\`{i}', '\\`{o}', '\\`{u}');
   $export= str_replace($search, $replace, $text);
   return $export;
 }
 
 It works fine, as long as I feed it with a string:
 accents('à') -- \`{a}
 
 The issue is when I get 'à' from a mysql table.
 I.e., for some record of a mysql table Table, let à the value of the
 field Field, and say
 $result =  mysql_fetch_array($answer, MYSQL_BOTH),
 where $answer= mysql_query(SELECT * FROM Table).
 
 Now accents($result['Field']) returns à (instead of \`{a}).
 Why? I have no idea.
 
 Any hint is welcome.
 Thanks a lot
 mario
 
 --
 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: How to make use of the billing token the right way???

2005-02-15 Thread Scott Fletcher
Never heard of the uniqid() before and looked it up on the php.net.  It look
very promising.  I can do that.  That leave me with 2 questions.  How do I
do (or how does it work) this with a token if

1) The webpage is submitted (goes from page 1 to page 2) with the uniqid().
2) The 2nd browser window appear with the uniqid().

An example or something would help if you can.

Thanks,
 Scott

Jason Barnett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

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



Re: [PHP] Handling email bouncebacks

2005-02-15 Thread Ligaya Turmelle
I am doing something similar and was told to look at the IMAP, POP3, 
NNTP extension.  I think I have a way of doing it using that extension 
(still in planning stage) but I would also be very interested in any 
other ideas.

Respectfully,
Ligaya Turmelle
Computer Programmer
Guam International Country Club
495 Battulo Street
Dededo, Guam 96929
Reservations: 671.632.4422
Office: 671.632.4445
Fax: 671.632.4440
Japanese website: www.giccguam.com
English website: www.giccguam.com/English
Korean website: www.giccguam.com/korea
Chris Bruce wrote:
Hi,
I am looking for a way to manage email bouncebacks on my Linux server 
for one of my client's email marketing system. What I would like to do 
is have a way of capturing the email address from the header of each 
bounce and insert it into a MySQL table. At that point I can do the 
requisite scrubbing of the lists. I believe that I saw a PHP class a 
while back that handled this. Does anyone have any experience with this?

Thanks
Chris

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

[PHP] Intelligent Forms and Form Processing

2005-02-15 Thread dan
Hello, all -
I am working on a few small projects to try and teach myself how to 
build intelligent forms.  I have come as far as making a few simple ones 
that are created when their parent function is called.  Something like 
the following:

function displayMyForm($username='',$password='',$account='') {
// do some stuff for the vars that were passed
// create form
}
Nothing much, but it gives me a good footing on the use of displaying 
forms dynamically even when some data is missing - making use of default 
values.

The problem that I am faced with now, as simple as it seems, is a 
situation such as the following:

User goes to index.php, enters in some information.  ACTION='? echo 
$_SERVER['PHP_SELF'] ?' is the action.  Some data is carried in the 
form of variables that were entered in on a form.

I want that same page to catch that data and process it.  If the data 
is complete and valid, pass to another section of the form.  If it is 
not, prompt the user to re-enter some data.

I don't really know what I'm asking here.  I guess ultimately I'm 
curious as to how people make intelligent forms such as this.  How do 
you deal with missing/incomplete values?  What about multiple steps of 
a form?  How do you verify that, if a user is on step 2, they came 
from step 1?  Do you mix $_GET and $_POST to verify the process?

Not coming from a big programming background, some people might think 
that these questions are pretty lame, and I'll go ahead and tell you 
that you are absolutely correct.  However, as I start, I would like to 
develope and work on good programming habits, so I don't learn bad 
habits to begin with.

Any feedback will be appreciated.
Thanks
-dant
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Session Vars and Performance

2005-02-15 Thread Greg Donald
On Tue, 15 Feb 2005 13:01:45 -0800 (PST), Richard Lynch [EMAIL PROTECTED] 
wrote:
 If you have to choose between a meaningful variable name and performance
 considerations, buy more hardware! :-)
 
 The cost you'll save in the long run for code maintenance will make it
 worth it.

Comments in the code make using short session variable names a non-issue.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

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



Re: [PHP] Re: isset

2005-02-15 Thread M. Sokolewicz
Chris W. Parker wrote:
M. Sokolewicz mailto:[EMAIL PROTECTED]
on Tuesday, February 15, 2005 8:25 AM said:

seems lengthy. is there a way around this?
i tried using
$cmd = @ $_POST['cmd'];
to suppress errors but didnt seem to have ay effect.
still
if(isset($_POST['cmd'])) {
   $cmd = $_POST['cmd'];
}
is the only (really) correct way. All others throw notices of
undefined indices, which you *should not* ignore! You can't shorten
it, you can't even wrap it in a function... it's simply tough luck

Please correct me if I'm wrong (and maybe this is what you mean by
(really)) but I think even Rasmus recommends:
?php
  if(!empty($_POST['cmd']))
  {
// stuff
  }
?
I'm using the following code to test this:
?php
error_reporting(E_ALL);
if(!empty($_POST['cmd']))
{
echo set and not emptybr /;
}
else
{
echo empty and/or not setbr /;
}
?

Chris.
that's a different issue.
There are always at least 2 things you should do with your (expected) input:
1 - check if it *exists* (isset)
2 - check the validity (input-validation)
for step #2 empty is very commonly used, and also a very useful 
function. However, you should never do #2 without #1, since that again 
raises issues (of security, problems, unexpected input, etc)

Also note that empty($non_existent_var) will always throw an E_NOTICE 
error when the variable in question is not set. isset() is the only 
function/language-construct that can check for the existence of 
variables without throwing an E_NOTICE.

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


Re: [PHP] issue with accents and mysql

2005-02-15 Thread mario
Hi,

thanks, but that seems to be ok:
SQL result
Host: 127.0.0.1
Database : 
Generation Time: Feb 15, 2005 at 11:36 PM
Generated by: phpMyAdmin 2.5.7-pl1 / MySQL 3.23.58
SQL-query: SHOW VARIABLES LIKE 'character_set%'; 
Rows: 2 

   Variable_name 
   Value 
character_set
latin1
character_sets
latin1 big5 cp1251 cp1257 croat
czech danish dec8 ...

any further idea?
thanks
mario

ps of course, I could 
On Tue, 2005-02-15 at 21:42, Guillermo Rauch wrote:
 Try
 SHOW VARIABLES LIKE 'character_set%'
 
 and verify your character set is latin1.
 
 If not, see http://dev.mysql.com/doc/mysql/en/charset-database.html
 
 On Tue, 15 Feb 2005 22:04:30 +, mario [EMAIL PROTECTED] wrote:
  Hello,
  
  please help me on the following issue.
  please reply to [EMAIL PROTECTED] too.
  (I asked for help on the php-db ml, but nobody replied)
  
  I have hacked the following function:
  function accents($text) {
global $export;
$search  = array ( 'à', 'è', 'ì', 'ò' , 'ù');
$replace = array ( '\\`{a}', '\\`{e}', '\\`{i}', '\\`{o}', '\\`{u}');
$export= str_replace($search, $replace, $text);
return $export;
  }
  
  It works fine, as long as I feed it with a string:
  accents('à') -- \`{a}
  
  The issue is when I get 'à' from a mysql table.
  I.e., for some record of a mysql table Table, let à the value of the
  field Field, and say
  $result =  mysql_fetch_array($answer, MYSQL_BOTH),
  where $answer= mysql_query(SELECT * FROM Table).
  
  Now accents($result['Field']) returns à (instead of \`{a}).
  Why? I have no idea.
  
  Any hint is welcome.
  Thanks a lot
  mario
  
  --
  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] Delete a file immediately after download

2005-02-15 Thread Marek Kilimajer
Shaun wrote:
Hi,
I have a database that contains encrypted data using Mysql function 
ENCODE(). Certain users will be allowed to view this data and I will allow 
them to download a CSV file contain the decrypted data using the Mysql 
DECODE() function. However I don't want this file to be left on the server, 
is there a way to ensure that the file is deleted immediately after it has 
been downloaded?
Don't put the file to a file at all, simply output the right header and 
echo the content.

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


Re: [PHP] Intelligent Forms and Form Processing

2005-02-15 Thread Matt M.
 Any feedback will be appreciated.


why reinvent the wheel?

take a look at:
http://pear.php.net/package/Html_quickform

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



Re: [PHP] Intelligent Forms and Form Processing

2005-02-15 Thread dan
Matt M. wrote:
Any feedback will be appreciated.

why reinvent the wheel?
take a look at:
http://pear.php.net/package/Html_quickform
To the people who want to truly understand how the system works, the 
wheel, as it stands, is wothless :)

I know I can use a drop-in solution, and I might consider it in the 
future.  However, if I understood in more detail the entire process, I 
would be able to troubleshoot and add advanced features to the wheel.

That's how I look at it, anyway.
Thanks
-dant
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Set a timeout on file_get_contents?

2005-02-15 Thread Marek Kilimajer
Brian Dunning wrote:
Is there any way to specify a timeout on a file_get_contents()? I'm 
trying to verify a URL but I don't want to spend more than a few seconds 
on it.

- Brian
ini_set('default_socket_timeout', $seconds);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Delete a file immediately after download

2005-02-15 Thread Shaun
Hi Marek,

Thanks for your reply, could you tell me how I would go about this please?


Marek Kilimajer [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Shaun wrote:
 Hi,

 I have a database that contains encrypted data using Mysql function 
 ENCODE(). Certain users will be allowed to view this data and I will 
 allow them to download a CSV file contain the decrypted data using the 
 Mysql DECODE() function. However I don't want this file to be left on the 
 server, is there a way to ensure that the file is deleted immediately 
 after it has been downloaded?

 Don't put the file to a file at all, simply output the right header and 
 echo the content. 

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



[PHP] Re: How to make use of the billing token the right way???

2005-02-15 Thread Jason Barnett
Scott Fletcher wrote:
Never heard of the uniqid() before and looked it up on the php.net.  It look
very promising.  I can do that.  That leave me with 2 questions.  How do I
do (or how does it work) this with a token if
1) The webpage is submitted (goes from page 1 to page 2) with the uniqid().
2) The 2nd browser window appear with the uniqid().
An example or something would help if you can.
?php
/** Page 1 of the form (uniqid.php) */
$id = uniqid(rand(), true);
?
html
  form action=uniqid2.php method=POST
input type=hidden value=?php echo $id; ? /
input type=submit /
  /form
/html

?php
/** Page 2 of the form (uniqid2.php) */
if(!$_POST['id']) {
  header('Location: http://yourdomain/uniqid.php');
  exit;
}
?
html
  form action=uniqid2.php method=POST
input type=hidden value=?php $_POST['id']; ? /
h3Your id is ?php echo $_POST['id']; ?/h3
input type=submit /
  /form
/html
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


Re: [PHP] Delete a file immediately after download

2005-02-15 Thread Marek Kilimajer
Shaun wrote:
Hi Marek,
Thanks for your reply, could you tell me how I would go about this please?
Marek Kilimajer [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

Shaun wrote:
Hi,
I have a database that contains encrypted data using Mysql function 
ENCODE(). Certain users will be allowed to view this data and I will 
allow them to download a CSV file contain the decrypted data using the 
Mysql DECODE() function. However I don't want this file to be left on the 
server, is there a way to ensure that the file is deleted immediately 
after it has been downloaded?
Don't put the file to a file at all, simply output the right header and 
echo the content. 

$csv contains the result of the mysql decode() function, then:
header('Content-Type: text/x-csv');
echo $csv;
That's it :)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Delete a file immediately after download

2005-02-15 Thread Jason Barnett
Shaun wrote:
Hi Marek,
Thanks for your reply, could you tell me how I would go about this please?
?php
header('Content-type: text/csv');
header('Content-Disposition: attachment; filename=download.csv');
/** Now you perform the MySQL query, DECODE the information and echo it
to the screen.  Hopefully this is actually in CSV format :) */
?
Marek Kilimajer [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Shaun wrote:
Hi,
I have a database that contains encrypted data using Mysql function
ENCODE(). Certain users will be allowed to view this data and I will
allow them to download a CSV file contain the decrypted data using the
Mysql DECODE() function. However I don't want this file to be left on the
server, is there a way to ensure that the file is deleted immediately
after it has been downloaded?
Don't put the file to a file at all, simply output the right header and
echo the content.

--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


Re: [PHP] Delete a file immediately after download

2005-02-15 Thread Richard Lynch
Shaun wrote:
 Hi Marek,

 Thanks for your reply, could you tell me how I would go about this please?

?php
  require 'connect.inc';

  $query = select * from whatever;
  $data = mysql_query($query);
  while ($row = mysql_fetch_row($data)){
echo implode(\t, $data), \n;
  }
?

You can muck around with CSV if you prefer, but tab-delimited is way
easier, assuming no tabs in your content.

This also assumes no newlines in your content.

If there are tabs and/or newlines in your content, you can use MySQL's
replace function (not the REPLACE INTO, but the string function 'replace')
to change tab to, err, \\t or something, and newline to Mac
carriage-return or something.

You'd have to do this (and more) to get CSV working right.

The on-line manual has example code for CSV at http://php.net/fputcsv

Maybe you should have googled before posting, eh?

-- 
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] Re: isset

2005-02-15 Thread Marek Kilimajer
M. Sokolewicz wrote:
Also note that empty($non_existent_var) will always throw an E_NOTICE 
error when the variable in question is not set.
No, it does not.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Intelligent Forms and Form Processing

2005-02-15 Thread Bret Hughes
On Tue, 2005-02-15 at 17:00, dan wrote:
 Matt M. wrote:
 Any feedback will be appreciated.
  
  
  
  why reinvent the wheel?
  
  take a look at:
  http://pear.php.net/package/Html_quickform
  
 
 To the people who want to truly understand how the system works, the 
 wheel, as it stands, is wothless :)
 
 I know I can use a drop-in solution, and I might consider it in the 
 future.  However, if I understood in more detail the entire process, I 
 would be able to troubleshoot and add advanced features to the wheel.
 
 That's how I look at it, anyway.
 

I like the attitude from a learning standpoint but since you asked for
feedback you could have at least acknowledged the guys effort in offerin
one solution.

This thread is very similar to another one today.  and the answer is the
same. use some sort of conditional construct to determine how you are
being requested and process accordingly.

I usually set a hidden variable that can be checked to let me know what
to do.

if (isset($_POST[myvar]  $_POST[myvar] = expected value){
 #   perform second phase form
}
else {

#do  form phase one stuff.

print input type=hidden name=myvar value='expected value'\n;

}

one of many ways to do it.  I have to say I have done quite a bit of
this sort of thing and it gets really confusing to maintain if there is
a lot of logic involved.

One one hand it is nice to know you only have to change one file if a
change is needed ( especially if there are changes to the parameters
being passed from the entry side to the processing side.  I have yet to
feel strongly one way or the other whether it is better to use a single
file or multiples.  

Bret

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



Re: [PHP] issue with accents and mysql

2005-02-15 Thread Bret Hughes
On Tue, 2005-02-15 at 17:40, mario wrote:
 Hi,
 
 thanks, but that seems to be ok:
 SQL result
 Host: 127.0.0.1
 Database : 
 Generation Time: Feb 15, 2005 at 11:36 PM
 Generated by: phpMyAdmin 2.5.7-pl1 / MySQL 3.23.58
 SQL-query: SHOW VARIABLES LIKE 'character_set%'; 
 Rows: 2 
 
Variable_name 
Value 
 character_set
 latin1
 character_sets
 latin1 big5 cp1251 cp1257 croat
 czech danish dec8 ...
 
 any further idea?
 thanks
 mario
 
 ps of course, I could 
 On Tue, 2005-02-15 at 21:42, Guillermo Rauch wrote:
  Try
  SHOW VARIABLES LIKE 'character_set%'
  
  and verify your character set is latin1.
  
  If not, see http://dev.mysql.com/doc/mysql/en/charset-database.html
  
  On Tue, 15 Feb 2005 22:04:30 +, mario [EMAIL PROTECTED] wrote:
   Hello,
   
   please help me on the following issue.
   please reply to [EMAIL PROTECTED] too.
   (I asked for help on the php-db ml, but nobody replied)
   
   I have hacked the following function:
   function accents($text) {
 global $export;
 $search  = array ( 'à', 'è', 'ì', 'ò' , 'ù');
 $replace = array ( '\\`{a}', '\\`{e}', '\\`{i}', '\\`{o}', '\\`{u}');
 $export= str_replace($search, $replace, $text);
 return $export;
   }
   
   It works fine, as long as I feed it with a string:
   accents('à') -- \`{a}
   
   The issue is when I get 'à' from a mysql table.
   I.e., for some record of a mysql table Table, let à the value of the
   field Field, and say
   $result =  mysql_fetch_array($answer, MYSQL_BOTH),
   where $answer= mysql_query(SELECT * FROM Table).
   
   Now accents($result['Field']) returns à (instead of \`{a}).
   Why? I have no idea.
   
   Any hint is welcome.
   Thanks a lot


I have no idea what might be the problem but I would probably start by
seeing what the difference is at the ascii level.

preg_split the strings and run ord on each one

foreach ( preg_split(//,this is a string) as $char ) {
echo The ascii value for $char is . ord($char) . \n;
}

post the results from both sources and lets see what can be found.

Bret

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



[PHP] function to remove all \ from a variable

2005-02-15 Thread Tim Burgan
Hello,
I'm using FCKeditor to edit content on my site.
But the content it produces escapes all the   (double quote) characters 
from my HTML, and replaces it with \ (backslash-double quote).

Is the a function that I can use to change it back?
Does str_replace() do it.. if so is this how I use it:
str_replace('\', '', $_POST['FCKeditor1']);
Tim
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] function to remove all \ from a variable

2005-02-15 Thread Lars B. Jensen
The manual to the rescue
http://jp2.php.net/stripslashes
--
Lars B. Jensen, Internet Architect
CareerCross Japan
Japan's premier online career resource for english speaking professionals
http://www.careercross.com
- Original Message - 
From: Tim Burgan [EMAIL PROTECTED]
To: [php] PHP General List php-general@lists.php.net
Sent: Wednesday, February 16, 2005 11:22 AM
Subject: [PHP] function to remove all \ from a variable


Hello,
I'm using FCKeditor to edit content on my site.
But the content it produces escapes all the   (double quote) characters 
from my HTML, and replaces it with \ (backslash-double quote).

Is the a function that I can use to change it back?
Does str_replace() do it.. if so is this how I use it:
str_replace('\', '', $_POST['FCKeditor1']);
Tim
--
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] function to remove all \ from a variable

2005-02-15 Thread Tim Burgan
Sorry for clogging up you mail box.
Yes.. str_replace('\', '', $_POST['FCKeditor1']) works.
I must've needed to think through my thoughts by typing it out.
Tim
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] mediator between PHP and Perl (with sessions)

2005-02-15 Thread YaronKh
Hi

What you can do is change the php.ini file
In the [session] section like this:

session.use_cookies = 0

session.use_only_cookies = 0

session.auto_start = 0

and now make sure that all script are running under the same session id
at the beginning of each php script you should add the following lines :

session_id(0f516a62cf2bab6f867dda9320358b6d);
session_start();


hope I've helped 
Yaron Khazai

-Original Message-
From: Eli [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 15, 2005 10:09 AM
To: php-general@lists.php.net
Subject: [PHP] mediator between PHP and Perl (with sessions)

Hi...

I got a shared lib API written in PHP, that depends on sessions for its 
operation.
I took a prepared system in Perl that I want integrate with the shared 
lib API in PHP.

What I thought about is, to write a mediator class in Perl that will 
define the same API functions as I got in the shared lib API in PHP. I 
do not want to imitate the API functions workflow in Perl, but instead 
call the shared lib API in PHP from Perl (this way I don't have to 
maintain 2 class APIs in different languages).

I thought of making a PHP script that can run on shell and return 
serialized output of any API function in the shared lib. Then call that 
script from Perl and process the returned output in Perl.
Problem in this way is, that the shared lib in PHP uses sessions which 
are un-accessable from a shell script. And I cannot put that script on 
the web, since it returns sensitive data.
Is there a way to use sessions variables in PHP shell script (without 
reading the session file and parse it in the script)?

If anyone is familiar with any other implementation of such a mediator, 
please tell.

-thanks, Eli.

-- 
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] Re: isset

2005-02-15 Thread Bret Hughes
On Tue, 2005-02-15 at 16:22, M. Sokolewicz wrote:

  Chris.
 that's a different issue.
 There are always at least 2 things you should do with your (expected) input:
 1 - check if it *exists* (isset)
 2 - check the validity (input-validation)
 
 for step #2 empty is very commonly used, and also a very useful 
 function. However, you should never do #2 without #1, since that again 
 raises issues (of security, problems, unexpected input, etc)
 
 Also note that empty($non_existent_var) will always throw an E_NOTICE 
 error when the variable in question is not set. isset() is the only 
 function/language-construct that can check for the existence of 
 variables without throwing an E_NOTICE.


This is not true and explicitly states so in the doc.  I had to reread
it to remember why I stopped using it.  empty will return true if the
value is one of several things , 0, 0 to name a few.  Since I do not
consider these empty I stick with isset and then test for a valid value
depending on the circumstance.

Personally, I think people piss and moan too much about what I consider
proper coding practices.  Input validation is to important to skimp on.
Again it is my opinion.

I have been revisiting some php code that I wrote a couple of years ago
and have been pleasantly surprised at the job I did on input validation.

A similar complaint occurs when installing a new version of or moving
code to another box where register_globals is not on.  I pissed and
moaned and wailed for about 10 minutes until I thought about it and can
now see the value in not having unknown variables pollute the namespace.

Of course, since most of my code was already validating the variables, a
few :s/\$\(var\)/\$_GET[\1]/ iterations and I was good to go.  Yes it
took some time but I feel better having done it.

I just wish there was a use strict; sort of deal so I would not have to
hunt down logic errors due to mistyping a variable name.

Bret

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



Re: [PHP] fopen problem using ftp

2005-02-15 Thread The Disguised Jedi
Why not use the built in FTP functions instead of fopen?

us2.php.net/ftp

Those should be able to handle any of the address problems you have,
seeing as they don't use the ftp://username:[EMAIL PROTECTED] syntax,
they open a connection and work with the FTP system.


-- 
The Disguised Jedi
[EMAIL PROTECTED]

Now you have my $0.02.  Or .01 Pounds, .014 Euros, or $0.025 CAN.  I'm
already internationally compatible!
PHP rocks!
Knowledge is Power.  Power Corrupts.  Go to school, become evil

Disclaimer: Any disclaimer attached to this message may be ignored. 
However, I must say that the ENTIRE contents of this message are
subject to other's criticism, corrections, and speculations.

This message is Certified Virus Free

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



Re: [PHP] Session Vars and Performance

2005-02-15 Thread trlists
On 15 Feb 2005 Richard Lynch wrote:

 Throw an ab (Apache Benchmark) test at it and find out.
 
 Don't just guess or sit there wondering.
 
 You could run test in about the time it took to compose this email --

Perhaps if you are already familiar with ab, which I'm not ... and if 
the server supports it, which it does not at this moment, development 
is on Windows, later testing and deployment on Linux.

 All the database code is already written for you on the PHP
 web-site, and it's about one 8.5x11 page of five (5) functions. 
 
 Doesn't really sound like a complex test to me.

The data is an internal list of items on the form, all the form field 
specs, the data for the fields, default data for resetting the form, 
and a data structure for the forms class.  Most of these are in 
associative arrays, sometimes nested a couple of levels deep.  If I'm 
going to build a database structure that mirrors the array structure, 
and update it every time the array changes during development, that's 
hardly straightforward.  Without that, I'll have to serialize and 
unserialize the data -- and if I'm going to do that, I'd guess that I 
might as well use the session vars.  So maybe that answers the 
question, and the remainder (below) is theoretical.

 Sending the actual query and getting/storing the results will be
 chump-change compared to opening the db connection, almost for sure.

I do actually need a DB connection on every page anyway, so there's no 
benefit to avoiding one for this purpose.  But to me the likely 
consumer of cycles here with a database structure matching the data 
structure would be the conversion of MySQL data into an associative 
array, and I'd be comparing that to serializing and unserializing.  I 
don't think either is going to be trivial.

 These two will be neck-and-neck on performance, and will depend more
 on your hardware than on somebody else's experience with their
 hardware. 

Fair point.

 Particularly if you've got a 2-tier setup with database on one box
 and PHP on another, where your network hardware and cabling gets
 involved. 

Not in this case.

 If you have to choose between a meaningful variable name and
 performance considerations, buy more hardware! :-) 

Agreed!

Thanks,

--
Tom

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



Re: [PHP] Session Vars and Performance

2005-02-15 Thread trlists
On 15 Feb 2005 Greg Donald wrote:

  If you have to choose between a meaningful variable name and performance
  considerations, buy more hardware! :-)
  
  The cost you'll save in the long run for code maintenance will make it
  worth it.
 
 Comments in the code make using short session variable names a non-issue.

Most of what's in my session file is data, not variable names, and my 
variable names are not particularly long.  Descriptive, but not overly 
so (actually in this case most of the 'names' are associative array 
indices).  If I shortened the variable names I might go down from 250K 
to 200K -- if that -- at a large cost in time for code modifications.  
I'm not at all keen on that approach, though I'm sure it might work for 
some.

--
Tom

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



[PHP] other mhash hashes

2005-02-15 Thread David Norman
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
I thought some other people would be interested in the other hashes
that you can do with mhash that aren't on the php.net docs after the
recent news that SHA-1 might be weaker than previously thought:
http://www.schneier.com/blog/archives/2005/02/sha1_broken.html
The built in constants that the mhash docs have listed are simply
integers that tell mhash what to use. So I found the integers in
mhash's mhash.h:
http://cvs.sourceforge.net/viewcvs.py/mhash/mhash/lib/mhash.h?rev=1.25view=auto
The following works for alternate hashes in the Win32 PHP 5.0.3
release of libmhash.h. For anyone wanting a step up from SHA-1, SHA256
works.
$hashes = array('CRC32' = 0,
~  'CRC32B' = 9,
~  'ADLER32' = 18,
~  'MD4' = 16,
~  'MD5' = 1,
~  'RIPEMD160' = 5,
~  'SHA1' = 2,
~  'SHA256' = 17,
~  'HAVAL128' = 13,
~  'HAVAL160' = 12,
~  'HAVAL192' = 11,
~  'HAVAL224' = 10,
~  'HAVAL256' = 3,
~  'TIGER128' = 14,
~  'TIGER160' = 15,
~  'TIGER192' = 7,
~  'GOST' = 8);
foreach($hashes as $name = $number) {
~echo 'br /';
~echo $name, ': ', bin2hex(mhash($number, 'this is a test'));
}
or as PHP constants:
$hashes = array('CRC32' = MHASH_CRC32,
~  'CRC32B' = MHASH_CRC32B,
~  'ADLER32' = MHASH_ADLER32,
~  'MD4' = MHASH_MD4,
~  'MD5' = MHASH_MD5,
~  'RIPEMD160' = MHASH_RIPEMD160,
~  'SHA1' = MHASH_SHA1,
~  'SHA256' = MHASH_SHA256,
~  'HAVAL128' = MHASH_HAVAL128,
~  'HAVAL160' = MHASH_HAVAL160,
~  'HAVAL192' = MHASH_HAVAL192,
~  'HAVAL224' = MHASH_HAVAL224,
~  'HAVAL256' = MHASH_HAVAL256,
~  'TIGER128' = MHASH_TIGER128,
~  'TIGER160' = MHASH_TIGER160,
~  'TIGER192' = MHASH_HAVAL192,
~  'GOST' = MHASH_GOST);
foreach($hashes as $name = $number) {
~echo 'br /';
~echo $name, ': ', bin2hex(mhash($number, 'this is a test'));
}
I suspect if you were able to compile a more recent version of mhash,
the following complete list of mhash's hashes would work, including
SHA512 and WHIRLPOOL.
$hashes = array('CRC32' = 0,
~  'CRC32B' = 9,
~  'ADLER32' = 18,
~  'MD2' = 27,
~  'MD4' = 16,
~  'MD5' = 1,
~  'RIPEMD160' = 5,
~  'RIPEMD128' = 22,
~  'RIPEMD256' = 23,
~  'RIPEMD320' = 24,
~  'SHA1' = 2,
~  'SHA224' = 19,
~  'SHA256' = 17,
~  'SHA384' = 21,
~  'SHA512' = 20,
~  'HAVAL128' = 13,
~  'HAVAL160' = 12,
~  'HAVAL192' = 11,
~  'HAVAL224' = 10,
~  'HAVAL256' = 3,
~  'TIGER128' = 14,
~  'TIGER160' = 15,
~  'TIGER192' = 7,
~  'GOST' = 8,
~  'WHIRLPOOL' = 21,
~  'SNEFRU128' = 25,
~  'SNEFRU256' = 26);
foreach($hashes as $name = $number) {
~echo 'br /';
~echo $name, ': ', bin2hex(mhash($number, 'this is a test'));
}
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.0 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCEtHtqLBH+DmBuAIRAhN1AJ9YjaYRNP7d1FVp9zLXNDlBAeWvUQCgutlh
7d+AAPjv1Kh3rWiqld654DE=
=dhyN
-END PGP SIGNATURE-
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


  1   2   >