php-general Digest 26 Oct 2005 04:28:51 -0000 Issue 3758

Topics (messages 224637 through 224658):

Re: php Slow with Mac OS X 10.4
        224637 by: Nicolas Ross

Re: create HTML page on the fly
        224638 by: Adrian Bruce
        224640 by: Angelo Zanetti
        224641 by: David Tulloh
        224643 by: Miles Thompson

Re: PDF printing under windows.
        224639 by: Finner, Doug
        224642 by: Dave Lists
        224656 by: tg-php.gryffyndevelopment.com

Re: cURL to re-post form iinformation
        224644 by: Richard Lynch
        224645 by: Jay Blanchard
        224647 by: Richard Lynch
        224648 by: Jay Blanchard
        224652 by: Al

Re: ICQ
        224646 by: Michelle Konzack

Re: GUID or any other unique IDs
        224649 by: Richard Lynch
        224655 by: Jasper Bryant-Greene

Re: SMTP & PHP: Spam Tagging Problem
        224650 by: Richard Lynch

Re: Help with a regular expression for 0,1 or 2 decimal places
        224651 by: Phillip Oertel
        224653 by: Florent Monnier
        224654 by: John Nichel

Re: cURL to re-post form iinformation - SOLVED SORTA
        224657 by: Jay Blanchard

Strange array access problem
        224658 by: Ken Tozier

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Still, with fs_usage PID, I get more the 57k lines of stuff... I've found
another tool that is more appropriate to monitor system calls : sc_usage.
This tool gave me this :



=================
httpd             5 preemptions    7 context switches    1 thread
08:45:51
                 0 faults        90 system calls
0:00:11

TYPE                            NUMBER        CPU_TIME   WAIT_TIME
------------------------------------------------------------------------------
System         Idle                                      0:03.867( 0:00.798)
System         Busy                                      0:02.221( 0:00.300)
httpd          Usermode                       0:01.156

zero_fill                       929           0:00.032   0:00.163
copy_on_write                     1           0:00.000
cache_hit                        22           0:00.000

read                            829(2)        0:00.018   0:04.821( 0:01.096)
W
getdirentries                  5214           0:02.260   0:00.416
getattrlist                    6689           0:00.207   0:00.132
poll                              1           0:00.000   0:00.016
close                          5268(7)        0:00.106   0:00.016
fstat                         10518           0:00.088   0:00.016
select                            4(2)        0:00.000   0:00.010
fcntl                          5293           0:00.014   0:00.010
lstat                          6253           0:00.279   0:00.007
open                           5312(49)       0:00.187   0:00.003
stat                           6430(7)        0:00.181   0:00.001
mach_msg_trap                   547           0:00.008   0:00.000
fstatfs                        5212           0:00.075   0:00.000
readlink                        280           0:00.006   0:00.000
write                            50(9)        0:00.005   0:00.000
chdir                             2           0:00.000
accept                            1           0:00.000
getsockname                       1           0:00.000
access                           44           0:00.001
sigaction                        21(14)       0:00.000
sigprocmask                      23           0:00.000
umask                             3           0:00.000
setitimer                         3           0:00.000
socket                            1           0:00.000
connect                           1           0:00.000
setsockopt                        4           0:00.000
gettimeofday                      2           0:00.000
getsockopt                        1           0:00.000
writev                            1           0:00.000
shutdown                          1           0:00.000
lseek                          5308           0:00.026
vm_allocate                     283           0:00.012
vm_deallocate                   250           0:00.010
vm_copy                           1           0:00.000


Which tells my that my last asumption is right, it's file-system related.
The process passes it's time at :

- System busy and idle tasks for 6 seconds
- read for 4.8 seconds
- getdirentries for 2.2 seconds
- httpd usermod (I assume that is php processing time, nothing wrong here)



Since I am a registered Apple developper I will log an incident with apple
for this. I'll let you all know



And Richard, I must rule out the mysql problem. As stated before, on two
hardware identical machine, one with 10.3, and one with 10.4. The mysql
database is on a third different machine. So connection time should be
identical. Besides, with the trace i've done with micro-seconds timestamps,
the majority of the time mysql_connect takes less than 0.01 seconds.

As for includes, again as stated before, all is the same, including config
files, thus include_path, wich only contains /usr/local/lib/php, and this
directory contains the base PEAR installed over time plus one or two other
file.

Nicolas

----- Original Message ----- From: "Brent Baisley" <[EMAIL PROTECTED]>
To: "Nicolas Ross" <[EMAIL PROTECTED]>
Cc: <[email protected]>; "Shawn Moore" <[EMAIL PROTECTED]>;
"Atelier Fabien" <[EMAIL PROTECTED]>
Sent: Monday, October 24, 2005 5:03 PM
Subject: Re: [PHP] php Slow with Mac OS X 10.4


You certainly wouldn't want to do just fs_usage. Typing something  like
"fs_usage httpd" will show you just what the httpd process is  accessing.
Read the man pages for other options that may be helpful.

I've got a few things running on OSX 10.4, although none that handle  lots
of traffic. Public sites:
dutchessfootball.com - a football pool, the picks page is the slowest  to
load. That's on a single cpu 1.25 G4 512MB RAM
heardthroughthegrapevine.com - wine tasting site, nothing fancy or  that
complicated. That's on a 400Mhz G4 384MB RAM.

The big application is internal to my company and has about 285 "web"
files total, and about 45 mysql tables (contacts, companies, resumes
invoices, jobs, emails, journal,etc). They all have lots of includes
since I use a custom templating system to separate php from html. I  do
not use PEAR or any content management system, I found them too  slow. I
know a few people who have looked at Mambo and rejected it  because of
it's CPU load, although they were all using Windows  servers. I've never
looked into why Mambo has high CPU requirements.

Is it just the Mambo parts you are having problems with or is it php  in
general?

With 100% CPU, we've narrowed it down to something there. Now we need  to
figure out why the CPU is the bottleneck.

On Oct 24, 2005, at 4:21 PM, Nicolas Ross wrote:


--- End Message ---
--- Begin Message --- I think you can use a different handle when using fwrite() which will make php create a file if one is not already there: something like

if ($fp = fopen($file,"x+")){
echo"opened"; } fwrite($fp,$content);
   fclose($fp);

Ade

Angelo Zanetti wrote:

Hi guys.

I've created a small newsletter application and the content of the newsletter is stored in a DB (the HTML).

However once the newsletter is complete and the user clicks a button I want the newsletter/html file to be created on the server. How do I go about this?

I assume that I will use fwrite() to add the HTML to the file, I need to know how to actually create the file before adding the content to it.

thanks in advance.
Angelo


--- End Message ---
--- Begin Message ---
thanks guys, bruce's answer was what I was looking for.

regards

Angelo

David Tulloh wrote:
Angelo Zanetti wrote:

...

I assume that I will use fwrite() to add the HTML to the file, I need to
know how to actually create the file before adding the content to it.



You need to open the file before you can write to it, you do that using
fopen().  You can choose to create a file or modify an existing on by
using the fopen mode flags.  The different flags are outlined in the
documentation, I think you will be wanting to use 'w'.


David


--- End Message ---
--- Begin Message ---
Angelo Zanetti wrote:
> ...
> 
> I assume that I will use fwrite() to add the HTML to the file, I need to
> know how to actually create the file before adding the content to it.
> 

You need to open the file before you can write to it, you do that using
fopen().  You can choose to create a file or modify an existing on by
using the fopen mode flags.  The different flags are outlined in the
documentation, I think you will be wanting to use 'w'.


David

--- End Message ---
--- Begin Message ---
At 10:26 PM 10/25/2005, Angelo Zanetti wrote:
Hi guys.

I've created a small newsletter application and the content of the newsletter is stored in a DB (the HTML).

However once the newsletter is complete and the user clicks a button I want the newsletter/html file to be created on the server. How do I go about this?

I assume that I will use fwrite() to add the HTML to the file, I need to know how to actually create the file before adding the content to it.

thanks in advance.
Angelo

Angelo,

Does the content in the db contain HTML tags? If so you may need use addslashes(), stripslashes(), htmlentities() and the like as you save and retrieve content.

All you really have to do is generate any HTML to start the page, add your content, and then closing tags and echo() or print() the whole shooting match.

You could do this with a function called CurrentIssue(). Within the function, as you build the HTML, concatenate it to the function's internal return variable.

Then you could simply echo CurrentIssue ;

Why do you have to generate an HTML file?

Regards - MIles Thompson
--- End Message ---
--- Begin Message ---
Not sure how this might work in PHP, but there is something called WSH
(go to MS and poke around) that gives you access to a ton of really
interesting Windows bits and pieces.  The following is a script I run in
Lotus Notes (LotusScript is rather like VBA) and it allows you to set
the default printer to something which you then just print to and reset
the default to whatever it was.  PDFCreator is a 'printer' that
generates PDF files (you probably don't want this since use of
PDFCreator includes it's own set of user interactions but the WSH
concept may still work).

Warning - I'm not a WSH expert and I never figured out how to properly
reset the printer to the user's default so I don't actually use this
script.  Still, someone smarter than me may have the magic touch - give
it a whirl.


Sub Initialize
     Dim net
     pName$ = "PDFCreator"
     Set net = CreateObject("WScript.Network")    
     net.SetDefaultPrinter pName$
     
End Sub 

Doug

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 25, 2005 10:50 AM
To: [email protected]; [email protected]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] PDF printing under windows.

Two (and a half) things:

1. Even though DOS/Windows machines don't have, specifically,
/dev/printer or /dev/lpr or whatever the *nix specific is, it does have
a LPTx: device

According to the page listed below, it may be possible to do:
copy /b filename LPTx

The /b indicates it's a binary file.  How it'd handle PDF fonts and
such, I'm not sure, but I know that some printers can decode PDF's
internally so that'd work out great.

2. Second point... If all you need is a simple print function and you
have exec() privs, why not try to find a DOS based printing solution.
The copy command above was mentioned on this page:
http://www.lerup.com/printfile/

It says it works with Windows 3.1 to XP.  And it even works with command
line options:

"PrintFile also works well with command line (DOS) programs. It has
several command line options and can read data from command line
standard input, e.g. a command line pipe. A command like:
dir | prfile32"

So I guess it sets up it's own print device that you can pipe to.

And finally... the half a point.  All of this may not be necessary
because you can configure Windows printers to support DOS (although I
havn't done this in ages, I assume you still can in XP) so in theory the
normal DOS "print" command would pipe through Windows drivers and print
handling to the printer of choice.


So in general, there's probably zero need to use COM to print.  One of
these options should pipe the file through Windows which in turn, could
possibly send it through the proper printing method.   If not, you might
be able to look in your registry and find the right-click "Print..."
option and see if it's something you can execute from command line.

Ok, I know this email's too long already, but I know someone's going to
say "How do you do that?"  So here's the 50 cent tour:

1. Pull up "regedit"
2. Search for the file extension ".pdf"
3. Make note of the "(Default)" value, in this case "AcroExch.Document"
(I think this is specific to having the full Acrobat installed) 3. Below
the area where all the file extensions are in HKEY_CLASSES_ROOT there
are the actual named app section (that way, ".gif" and ".jpg" can both
point to Photoshop.document" or something.. get it?)  So search for
"AcroExch.Document" in this case 4. Expand that tree and look for
"shell". These are all the things that show up on your right-click menu.
In this case, we have a "print" section. Under each of these entries,
there should be (but sometimes not) a "command" branch.  This is what's
run when you select that option from the right-click menu.  And voila!
We find that the command to use Acrobat to print (which can be executed
from command line on a Windows machine) is:
"C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe" /p /h "%1"

Substituting the %1 for the filename.


Using that command line in a php exec() call should exactly simulate
selecting right-click PRINT on a PDF file.


Crossposting this to PHP-Win for their benefit too since this is more
Windows related than PHP General.

I see lots of ways to potentially solve this problem without using COM.

I loved messing with COM (with or without PHP) for a while, but it's not
a great general solution to things unless you absolutely HAVE to control
the app (which is very cool and slick sometimes, but not for something
as simple as printing).

Hope this gives you some new avenues to persue.  Best of luck!

-TG

= = = Original message = = =

Richard Lynch wrote:

>On Mon, October 24, 2005 1:48 pm, Dave Lists wrote:
>  
>
>>I'm generating PDFs under windows using PDFlib and all is easy. What I

>>am wondering though, and google reveals nothing usefull, can I print 
>>the PDF to a network printer from windows? I'm presuming to print the 
>>file I would ahve to use COM and open it under Acrobat? Anyone done 
>>this before and have any pointers? I'm printing out invoices and what 
>>to automate the task.
>>    
>>
>
>If, for some weird reason, you want to allow the user (authenticated, 
>logged in, trusted) to print to a networked computer on the WEB SERVER,

>then your best bet is probably to figure out how to print that PDF from

>MS-DOS and then to use http://php.net/exec to print it, I would 
>guess...
>  
>
 It's from a cli PHP install on a local machine :-)

>You might be able to use PHP to open up a COM object to convince 
>Adobe/Windows/whatever to print...
>  
>
 COM makes me want to cry ;-) At the moment I'm trying to convince
OpenOffiice it wants to play with PHP and COM.
 I have tried to exec print on the windows box but that just hung.

>If it was a Un*x server, you'd just send the document to lpr or CUPS or

>something, and be done with it, probably in a half-hour of work, even 
>allowing for a protracted battle with file/exec permissions.
>
>  
>
I'm not sure I could just fire a PDF at lpr, but no doubt it would be
much easier under Unix :-)

Dave.


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
_______________________________________________________________________
This e-mail message has been sent by Kollsman, Inc. and is for the use
of the intended recipients only. The message may contain privileged
or confidential information. If you are not the intended recipient
you are hereby notified that any use, distribution or copying of
this communication is strictly prohibited, and you are requested to
delete the e-mail and any attachments and notify the sender immediately.

--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:

Two (and a half) things:

1. Even though DOS/Windows machines don't have, specifically, /dev/printer or 
/dev/lpr or whatever the *nix specific is, it does have a LPTx: device

According to the page listed below, it may be possible to do:
copy /b filename LPTx

The /b indicates it's a binary file.  How it'd handle PDF fonts and such, I'm 
not sure, but I know that some printers can decode PDF's internally so that'd 
work out great.

2. Second point... If all you need is a simple print function and you have 
exec() privs, why not try to find a DOS based printing solution.  The copy 
command above was mentioned on this page:
http://www.lerup.com/printfile/

It says it works with Windows 3.1 to XP.  And it even works with command line 
options:

"PrintFile also works well with command line (DOS) programs. It has several 
command line options and can read data from command line standard input, e.g. a 
command line pipe. A command like:
dir | prfile32"

So I guess it sets up it's own print device that you can pipe to.

And finally... the half a point.  All of this may not be necessary because you can 
configure Windows printers to support DOS (although I havn't done this in ages, I assume 
you still can in XP) so in theory the normal DOS "print" command would pipe 
through Windows drivers and print handling to the printer of choice.


So in general, there's probably zero need to use COM to print.  One of these options 
should pipe the file through Windows which in turn, could possibly send it through the 
proper printing method.   If not, you might be able to look in your registry and find the 
right-click "Print..." option and see if it's something you can execute from 
command line.

Ok, I know this email's too long already, but I know someone's going to say "How do 
you do that?"  So here's the 50 cent tour:

1. Pull up "regedit"
2. Search for the file extension ".pdf"
3. Make note of the "(Default)" value, in this case "AcroExch.Document" (I 
think this is specific to having the full Acrobat installed)
3. Below the area where all the file extensions are in HKEY_CLASSES_ROOT there are the actual named app section 
(that way, ".gif" and ".jpg" can both point to Photoshop.document" or something.. get 
it?)  So search for "AcroExch.Document" in this case
4. Expand that tree and look for "shell". These are all the things that show up on your right-click 
menu.  In this case, we have a "print" section. Under each of these entries, there should be (but 
sometimes not) a "command" branch.  This is what's run when you select that option from the 
right-click menu.  And voila! We find that the command to use Acrobat to print (which can be executed from 
command line on a Windows machine) is:
"C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe" /p /h "%1"

Substituting the %1 for the filename.


Using that command line in a php exec() call should exactly simulate selecting right-click PRINT on
The problem there is that you end up having a load of acrobat.exe's
open. It will print, but it won't shutdown the app afterwards. So
automate printing of invoices maynot be a good idea :-)
I think I'll just install a linux box and use CUPS :-)

Dave.

--- End Message ---
--- Begin Message ---
This is really dumb and overly simple, which is probably why it was missed/not 
brought up, but it just occurred to me that, assuming you have a browser-based 
interface to your app, why don't you just send the PDF to the browser for 
printing?  Then it should use the Acrobat Reader plugin to open the app then 
just have the user (you?) click the print button?  Or do you want it totally 
one-button click and that's it?

Just a thought. 

-TG

= = = Original message = = =

Richard Lynch wrote:

>On Mon, October 24, 2005 1:48 pm, Dave Lists wrote:
>  
>
>>I'm generating PDFs under windows using PDFlib and all is easy. What I
>>am wondering though, and google reveals nothing usefull, can I print
>>the
>>PDF to a network printer from windows? I'm presuming to print the file
>>I
>>would ahve to use COM and open it under Acrobat? Anyone done this
>>before
>>and have any pointers? I'm printing out invoices and what to automate
>>the task.
>>    
>>
>
>If, for some weird reason, you want to allow the user (authenticated,
>logged in, trusted) to print to a networked computer on the WEB
>SERVER, then your best bet is probably to figure out how to print that
>PDF from MS-DOS and then to use http://php.net/exec to print it, I
>would guess...
>  
>
 It's from a cli PHP install on a local machine :-)

>You might be able to use PHP to open up a COM object to convince
>Adobe/Windows/whatever to print...
>  
>
 COM makes me want to cry ;-) At the moment I'm trying to convince 
OpenOffiice it wants to play with PHP and COM.
 I have tried to exec print on the windows box but that just hung.

>If it was a Un*x server, you'd just send the document to lpr or CUPS
>or something, and be done with it, probably in a half-hour of work,
>even allowing for a protracted battle with file/exec permissions.
>
>  
>
I'm not sure I could just fire a PDF at lpr, but no doubt it would be 
much easier under Unix :-)

Dave.


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

--- End Message ---
--- Begin Message ---
On Tue, October 25, 2005 8:36 am, Jay Blanchard wrote:
> I am trying a new technique, for me, when processing a form. The form
> is
> filled out and submitted, during processing it is determined that
> there is
> an error with the posted data...such as a blank or mismatched
> password,
> I want to return the form with the data filled out using curl....as a
> test I
> did this....
>
> /* curl post test */
>
>    $post_data['username'] = $_POST['username'];
>    $post_data['password'] = $_POST['password'];
>    $url = "http://TEST20051010/FMSRegister.php";;
>
>    /* assemble POST data in string */
>       $pd="";
>       foreach ($post_data as $k=>$v){
>                       $pd.= "$k=".$v."&";
>       }
>   $post_data=substr($pd,0,-1);
>
> $ch = curl_init();
>    curl_setopt($ch, CURLOPT_POST, 1);
>    curl_setopt($ch, CURLOPT_HEADER, 0);
>    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
>    curl_setopt($ch, CURLOPT_URL, $url);
>       curl_exec($ch);
>
> curl_close($ch);
>
> Now, this works OK...save for one little problem that I cannot seem to
> figure out. The URL now reads
>
>    http://TEST20051010/NameOfProcessingScript.php instead of
> FMSRegister.php.
>
> I am searching the curl options http://www.php.net/curl_setopt but
> have not
> found what I am looking for. Can someone clue me in?

cURL doesn't really interact with the browser directly here...

Your script is the "middle-man" between their form and FMSRegister.php

But they didn't surf to FMSRegister.php

Your script surfed there, but their browser didn't.

If you want their browser to surf there, you have to send "Location: "
headers, and you'd need to include whatever GET parameters you could
to make the request come out like you want, but, at that point,
there's not much reason for cURL to be involved...

I suspect you've over-estimated what cURL can do and what it's for...

All it does is let a program pretend to be a browser.

It doesn't let your program take over control of the user's browser.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
[snip]
If you want their browser to surf there, you have to send "Location: "
headers, and you'd need to include whatever GET parameters you could
to make the request come out like you want, but, at that point,
there's not much reason for cURL to be involved...
[/snip]

I wanted to avoid using GET as I did not want the information to be in the
URL. I figured that if my processing script (curltest.php in this example)
determined that the data submitted in the form FMSRegister was faulty,
according to my rules for processing the form, that I could have the
processing script invoke curl to post the current data back to the form for
display to the user. I am half-way there. Perhaps the file name change is
moot, but I thought that it would be a nifty technique as it allowed me to
keep processing seperate from the form itself.

Ah well....

--- End Message ---
--- Begin Message ---
On Tue, October 25, 2005 11:40 am, Jay Blanchard wrote:
> [snip]
> If you want their browser to surf there, you have to send "Location: "
> headers, and you'd need to include whatever GET parameters you could
> to make the request come out like you want, but, at that point,
> there's not much reason for cURL to be involved...
> [/snip]
>
> I wanted to avoid using GET as I did not want the information to be in
> the
> URL. I figured that if my processing script (curltest.php in this
> example)
> determined that the data submitted in the form FMSRegister was faulty,
> according to my rules for processing the form, that I could have the
> processing script invoke curl to post the current data back to the
> form for
> display to the user. I am half-way there. Perhaps the file name change
> is
> moot, but I thought that it would be a nifty technique as it allowed
> me to
> keep processing seperate from the form itself.

I don't think cURL is the right weapon to keep form/content separate
from processing...

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
[snip]
I don't think cURL is the right weapon to keep form/content separate
from processing...
[/snip]

It may not be, but it was a thought. As they say, there is more than one way
to skin a cat. In this case I was hoping to save a trip to a database or
flat file so that the URL wouldn't have to be mungled. C'est la' vie

--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:
Howdy all,

I am trying a new technique, for me, when processing a form. The form is
filled out and submitted, during processing it is determined that there is
an error with the posted data...such as a blank or mismatched password,
I want to return the form with the data filled out using curl....as a test I
did this....

/* curl post test */

   $post_data['username'] = $_POST['username'];
   $post_data['password'] = $_POST['password'];
   $url = "http://TEST20051010/FMSRegister.php";;

   /* assemble POST data in string */
        $pd="";
        foreach ($post_data as $k=>$v){
                        $pd.= "$k=".$v."&";
        }
  $post_data=substr($pd,0,-1);

$ch = curl_init();
   curl_setopt($ch, CURLOPT_POST, 1);
   curl_setopt($ch, CURLOPT_HEADER, 0);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
   curl_setopt($ch, CURLOPT_URL, $url);
        curl_exec($ch);

curl_close($ch);

Now, this works OK...save for one little problem that I cannot seem to
figure out. The URL now reads

   http://TEST20051010/NameOfProcessingScript.php instead of
FMSRegister.php.
I am searching the curl options http://www.php.net/curl_setopt but have not
found what I am looking for. Can someone clue me in?
Thanks!


Here is how I do what it sounds like you want to do.

Simply serialize your POST array, i.e., $saved_post= serialize($_post)and save it [a file or session buffer, whatever] if you are instigating a new page; if not, you have the post array saved.

Then when you want to repopulate the form, simply unserialize($saved_post) and fill in your <inputs..> etc. from the array.


--- End Message ---
--- Begin Message ---
Hello John,

Am 2005-10-12 13:13:49, schrieb John Hinton:
> Al Hafoudh wrote:
> 
> >is it possible to connect to icq,  send messages and etc? thanx
> >
> I looked all over that place for such a function some time back. I did 
> find several, but all were very old. The problem was they were all based 
> on the ICQ account number. Thinking about allowing such through the ICQ 

Sorry, I do not know, what you mean be using "ICQ account numbers"
because it works like this, but since some time ICQ limit the
number of messages sended by an account.

> network was an invitation to easy spamming. Just write a script rolling 
> through numbers and sending a message. I believe ICQ disabled this feature.

It limit the number of messages send in ONE minute.

AFAIK it is limited to 16.

> If you find out differently, please post your findings back to this list 
> as I have a client with this very request which I was unable to fulfill.
> 
> Best,
> John Hinton

Greetings
Michelle

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
Michelle Konzack   Apt. 917                  ICQ #328449886
                   50, rue de Soultz         MSM LinuxMichi
0033/3/88452356    67100 Strasbourg/France   IRC #Debian (irc.icq.com)

--- End Message ---
--- Begin Message ---
On Tue, October 25, 2005 4:01 am, Denis Gerasimov wrote:
> I am in a need of GUID generator but it seems that PHP doesn't have
> this as
> a built-in feature.

There is some discussion here you may find useful:

http://www.php.net/uniqid

> I really need "true" unique identifiers - md5() hash is not OK because
> of
> the "birthday paradox".

If you already have a database connection you can simply use a
sequence (or auto_increment in MySQL)

But that assumes you are willing to have predictable IDs, which you
might not.

> Can anyone recommend a way for solving this trouble?

You could use md5() and track every ID you hand out in a UNIQUE column
in a db, and simply generate another random md5() if you happen to run
into a duplicate.

The probability that you'd generate too many duplicate random md5()s
in a row for performance to be an issue is pretty small, if you
already have database activity going on.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Tue, 2005-10-25 at 14:47 +0400, Denis Gerasimov wrote:
> > $unique_id = sha1( uniqid( mt_rand(), true ) );
> > 
> > which should be very unique and suitable for most purposes.
> 
> I really need millions of unique IDs - hashing is not suitable for this task
> (I think so) :-(. Any more ideas?

The above function could generate much more than millions of unique IDs.

You have 1.46 x 10^48 possible hashes, and with an input of the current
time in microseconds prefixed by a Mersenne Twister random number and
suffixed by additional entropy from the combined linear congruential
generator, collisions should be *very* improbable, even when generating
IDs on multiple hosts all at the same time.

-- 
Jasper Bryant-Greene
General Manager
Album Limited

e: [EMAIL PROTECTED]
w: http://www.album.co.nz/
p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303
a: PO Box 579, Christchurch 8015, New Zealand

--- End Message ---
--- Begin Message ---
On Tue, October 25, 2005 3:27 am, Cabbar Duzayak wrote:
> I am having a problem with my system when sending e-mails to yahoo
> accounts, and it has been baffling me for the last couple of days,
> actually I should say it is driving me crazy...
>
> As I mentioned, I have a cpanel and have 2 domains/sites with
> dedicated IP addresses on my system. The base account has domain name:
> host.mydomain.com with IP address, let's say is x.x.x.x, the first
> domain first.com is x.x.x.[x+1], the second domain second.com is
> x.x.x.[x+2]. And, as you know, all e-mails for both domains are sent
> from host.mydomain.com with source IP as x.x.x.x

Something to consider:

What if, in Yahoo, the SECOND exact same email is tagged as spam
BECAUSE it is a duplicate.

Change up the email subject and body significantly to test this.

> Now, I wrote a php script, and placed it on both sites. It is exactly
> the same script, with only one difference, from address, reply-to
> address, etc. are set to [EMAIL PROTECTED] for the first domain and
> [EMAIL PROTECTED] for the second domain.
>
> When I execute this script, it sends an e-mail to a yahoo address. The
> problem is: the e-mail sent from first.com is sent fine meaning it
> reaches the recipient Yahoo INBOX, but the one sent from second.com is
> dropping into Yahoo's Bulk Folder...

You'll never truly know what Yahoo's spam-filtering algorithm is.

You have to live with the fact that some percentage of "real" email
will end up in Bulk, and some percentage of junk will get through into
INBOX.

Unless the user is allowed to whitelist specific addresses or domains,
that's just how it is.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
hi,

i'm not a regex guru myself, but the following regex should work - tabke
a look at my regex test setup ...

<?php

$test = array(
    "1",
    "1.",
    "1.2",
    "1.23",
    "1.234",

    "1234",
    "1234.",
    "1234.5",
    "1234.56",
    "1234.567"
);


// if there's a dot, we want at least one number after it.
$regex = '/^\d+(.\d{1,2})?$/';

// test all or numbers ...
foreach ($test as $number) {
   if (preg_match($regex, $number)) {
      echo "ok ";
   }  else {
      echo "no ";
   }
   echo $number . "<br />\n";
}

?>

i don't think there's a difference between \d and [0-9], but again, i am
no expert ...

regards,
phillip

--- End Message ---
--- Begin Message ---
Phillip Oertel a écrit :
> hi,
>
> i'm not a regex guru myself, but the following regex should work - tabke
> a look at my regex test setup ...
>
> <?php
>
> $test = array(
>     "1",
>     "1.",
>     "1.2",
>     "1.23",
>     "1.234",
>
>     "1234",
>     "1234.",
>     "1234.5",
>     "1234.56",
>     "1234.567"
> );
>
>
> // if there's a dot, we want at least one number after it.
> $regex = '/^\d+(.\d{1,2})?$/';

It would be better to escape the point, cause the point greps for everything.
$regex = '/^\d+(\.\d{1,2})?$/';
Without escaping the point, it could match for '1234:567' or something else.


> // test all or numbers ...
> foreach ($test as $number) {
>    if (preg_match($regex, $number)) {
>       echo "ok ";
>    }  else {
>       echo "no ";
>    }
>    echo $number . "<br />\n";
> }
>
> ?>
>
> i don't think there's a difference between \d and [0-9], but again, i am
> no expert ...
>
> regards,
> phillip

--- End Message ---
--- Begin Message ---
Phillip Oertel wrote:
hi,

i'm not a regex guru myself, but the following regex should work - tabke
a look at my regex test setup ...

<?php

$test = array(
    "1",
    "1.",
    "1.2",
    "1.23",
    "1.234",

    "1234",
    "1234.",
    "1234.5",
    "1234.56",
    "1234.567"
);


// if there's a dot, we want at least one number after it.
$regex = '/^\d+(.\d{1,2})?$/';

Escape the decimal point.
$regex = '/^\d+(\.\d{1,2})?$/';

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
[snip]
> Now, this works OK...save for one little problem that I cannot seem to
> figure out. The URL now reads
> 
>    http://TEST20051010/NameOfProcessingScript.php instead of
> FMSRegister.php. 
[/snip]

I kinda' solved this, but not really....it was more of a mental adjustment. 

FMSRegister.php <---- registration form
FMSProc.php     <---- central processing script

If the registration form is incomplete I use cURL to post the data and form
to the user even if the name of the file is not the same. I could call the
central processing script (which acts on application items in a switch
statement) something clever since it is being presented back to the user,
but since this is for an internal application I probably will not bother. It
would be neat if cURL could essentially post an interface back to the
browser....but I do understand the complications. A search has yielded
several who have basically asked the same question as I have though.

Now, I know that this may have some to do with laziness on my part, but it
was mostly an experiment. 

--- End Message ---
--- Begin Message --- I'm having a major problem with what seems, on it's face, to be a really basic array function.

What happens is on the browser end, I've written some javascript code that packages up javascript variables in native PHP format and sends the packed variables to a PHP script on the server via a POST and XMLHTTP. On the server end, the PHP script grabs the packed variables out of the $_POST, strips slashes and uses the "unserialize" command.

Here's the function that gets the post data
$unpacked_data    = GetDataFromPOST();

And here's a var_dump of $unpacked_data as it appears in the browser
array(1) { ["handler"]=> array(1) { ["0"]=> string(9) "databases" } }

I'm able to get the "handler with no problem like so:
$parts    = $unpacked_data['handler'];

Which yields the following var_dump
array(1) { ["0"]=>  string(9) "databases" }

Here's where the problem starts. I've had no luck whatsoever trying to get items of $parts. I've tried all of the following and each of them return NULL

$part_1 = $parts[0];
$part_1 = $parts['0'];
$part_1 = $parts["0"];
$part_1 = $parts[48]; <- ASCII character for zero

In desperation, I also tried this

foreach($parts as $key => $value)
{
        var_dump($key);
        // => string(1) "0"
        var_dump($value);
        // => string(9) "databases"

        $parts_1 = $parts[$key];
        // => NULL;
}

But no luck

I also checked the type and size of the key like so
foreach($parts as $key => $value)
{
       echo gettype($key);
        // => string

        echo sizeof($key);
        // => 1
}

Anyone have any insights as to what the heck is going on here? This should be a piece of cake but It's stopped me cold for a full day and a half

Thanks for any help

Ken

--- End Message ---

Reply via email to