[PHP] php session variables limited to 1 character -- please help

2005-10-25 Thread Zac Smith
Hi!

I've got a very strange issue that is basically cutting off session variable 
data after 1 character.  When I set the session variable as 50 it comes 
back as 5.  When I set it to XYZ it comes back as X.  I have a script 
that is taking $_GET['State'] variable and setting it to a session variable 
named $USER['State'].  This worked fine until a few days ago, but now it's 
persistent!  Any ideas what might be causing this??  I've searched the 
web/lists and can't find any reference.

http://www.triptrivia.com/step2-debug.php?State=abc

Thanks,
Zac 

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



[PHP] SMTP PHP: Spam Tagging Problem

2005-10-25 Thread Cabbar Duzayak
Hi,

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

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

For the second domain, I tried sending e-mail for that domain from
another hosting service, and that one got into the INBOX, not Bulk...

Both first.com and second.com have proper A records and MX records.
host.mydomain.com has an A record setup, and mydomain.com has an MX
record setup (pointing to some other mail server)...

Now, this is very confusing because:

1. If my hosts IP address (x.x.x.x) was blocked, then both
[EMAIL PROTECTED] and [EMAIL PROTECTED] should be blocked, but one of
them is reaching its destination, while the second one is tagged as
SPAM.

2. If there was a problem with the way SMTP is configured, again both
should not have been dispatched. In fact, EHLO domain
(host.mydomain.com) is resolving to source IP (x.x.x.x) and source IP
(x.x.x.x) is resolving to the EHLO domain (again host.mydomain.com)...
And, two headers are almost same (other than return-path, etc. of
course)

3. If [EMAIL PROTECTED] (or the whole domain second.com for that
matter) e-mail address(es) was/were blocked, then both mail sent from
x.x.x.x and other hosting service should have been blocked. But, as I
mentioned, other hosting services e-mail goes thru fine!

Can someone please shead a light onto this before I lost my sanity

E-MAIL HEADER AS RECEIVED BY YAHOO: [IT IS ALMOST THE SAME FOR
SECOND.COM, just replace FIRST.COM with SECOND.COM]


X-Apparently-To: [EMAIL PROTECTED] via 68.142.228.52; Mon, 24 Oct
2005 09:54:48 -0700
X-YahooFilteredBulk: x.x.x.x
X-Originating-IP: [x.x.x.x]
Return-Path: [EMAIL PROTECTED]
Authentication-Results: mta295.mail.scd.yahoo.com from=first.com;
domainkeys=neutral (no sig)
Received: from x.x.x.x (EHLO host.mydomain.com) (x.x.x.x) by
mta295.mail.scd.yahoo.com with SMTP; Mon, 24 Oct 2005 09:54:47 -0700
Received: from nobody by host.mydomain.com with local (Exim 4.52) id
XXX for [EMAIL PROTECTED]; Mon, 24 Oct 2005 19:54:44 +0300
To: [EMAIL PROTECTED]
Subject: TESTING
MIME-Version: 1.0
Content-type: text/plain; charset=iso-8859-9
From: [EMAIL PROTECTED]
Message-Id: [EMAIL PROTECTED]
Date: Mon, 24 Oct 2005 19:54:44 +0300
X-AntiAbuse: This header was added to track abuse, please include it
with any abuse report
X-AntiAbuse: Primary Hostname - host.mydomain.com
X-AntiAbuse: Original Domain - yahoo.com
X-AntiAbuse: Originator/Caller UID/GID - [99 99] / [47 12]
X-AntiAbuse: Sender Address Domain - first.com
X-Source:
X-Source-Args:
X-Source-Dir:
Content-Length: 12


PHP CODE USED FOR SENDING E-MAIL:

?php
$fromMail = [EMAIL PROTECTED];

$to = [EMAIL PROTECTED];
$subject = TESTING;
$msg = TEST MESSAGE;

$headers = MIME-Version: 1.0\r\n;
$headers .= Return-Path: $fromMail\r\n;
$headers .= Content-type: text/plain; charset=iso-8859-9\r\n;
$headers .= From: $fromMail\r\n;

print h1TEST:  . mail($to, $subject, $msg, $headers,
-f$fromMail) . /h1;
?

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



Re: [PHP] GUID or any other unique IDs

2005-10-25 Thread Richard Davey
Hi Denis,

Tuesday, October 25, 2005, 10:01:48 AM, you wrote:

 I am in a need of GUID generator but it seems that PHP doesn't have
 this as a built-in feature.

uniqid() ?

Bearing in mind of course that no unique ID generator can ever be 100%
unique unless it keeps a record of previously generated IDs. So you
may wish to add this check.

Cheers,

Rich
-- 
Zend Certified Engineer
http://www.launchcode.co.uk

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



Re: [PHP] GUID or any other unique IDs

2005-10-25 Thread Jasper Bryant-Greene
On Tue, 2005-10-25 at 13:01 +0400, 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.
 
 I looked at http://pear.php.net http://pear.php.net/  and
 http://pecl.php.net http://pecl.php.net/  but found nothing suitable
 there.
 
 I really need true unique identifiers - md5() hash is not OK because of
 the birthday paradox.
  
 Can anyone recommend a way for solving this trouble?

I use:

$unique_id = sha1( uniqid( mt_rand(), true ) );

which should be very unique and suitable for most purposes.

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

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



RE: [PHP] GUID or any other unique IDs

2005-10-25 Thread Denis Gerasimov
Hello Jasper,

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

Is there a PHP extension or an external library for generating GUIDs?

Have a great day,

Denis S Gerasimov 
Web Developer
Team Force LLC

Web:   www.team-force.org
RU  Int'l:   +7 8362-468693
email:[EMAIL PROTECTED]

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



Re: [PHP] Re: cleanly written shop-system (php5, object-oriented)?

2005-10-25 Thread Jochem Maas

James Benson wrote:

Bad choice of words.


I was comparing PHP4 to PHP5 and how long PHP4 has been around compared 
to PHP5, it's bound to be more stable aint it?


is it. probably , yes, but not by definition. you can say that php4 has
had more coverage which probably means it contains less bugs that nobody
has encountered.



I was not trying to say PHP5 is not stable because im sure it is very 
much so.


how sure ;-)



Or am I not allowed to say anything like that in this forum?


thankfully you are allowed to say what you want, although some of
the more sensitive types (and those work for large fearful corporations)
may block your posts due to 'rude' language ;-)


Ill just silently exit through the back door then :)


lol







Jochem Maas wrote:


James Benson wrote:

PHP5 has yet to see the maturity and stability PHP4 offers which is 
why most applications use it.


Worst thing you can do is design a website in entirely flash :)




no the worst thing you can do is spread FUD.
which you have just done, unless you are capable of backing up your 
off the cuff
remarks (about the stability of php5) with hard imperical data, which 
I doubt.


actually 'the worst thing you can do' is more likely to be something like
'invading a sovereign state in order to be able to subsidise your own 
oil-addicted,
brainwashed, selfrighteous society' than something that's anything to 
do with

php or the web. but then again maybe not ;-)








Phillip Oertel wrote:


hi,

i want to create a shop server application. the shop client interface
will be in flash (communication with php over xml, soap or amfphp), the
administration interface will be html. most likely it will probably 
be a

long-running application that will be extended in several steps, so we
need a solid foundation. we also need to get started quickly (who
doesn't), otherwise i would consider starting from scratch.

i have already looked around quite a lot for a nicely adaptable
shop/ecommerce implementation, but haven't been very successful so far.
everything i found was conceived in php4 times, where OO wasn't as
wide-spread in the php community as it is today. some of the packages
are poorly documented (both in-code and separate documentation), 
have an

inconsistent coding style, are dead, are copies of oscommerce with a
worse interface, ...

feature-wise the best i found was xtcommerce (oscommerce fork)
admin interface wise: zencart (oscommerce fork)
code-wise: randshop
non of them use php5's features, though, none are written 
object-oriented.


i have no info on the performance of these shops, although that
shouldn't be a prob as long as it's not desastrous (to some extend, you
can always scale hardware-wise).

so i am looking for a cleanly layered application where i could swap 
out

the presentation layer. and all important shop data (products, product
categories, cart, etc.) should be represented as objects, so i could
extend them to implement required customizations.
it would be a big plus if the admin interface was well thought-out.

we need quite some features like multiple languages, multiple
categories, discounts on certain products, payment provider 
integration,

customer newsletters, possibly administration of several slightly
different shops in one installation, etc.

is there such an application or am i stuck with oscommerce and its 
forks?

i don't need it to be feature complete, as long as there is a way to
adapt the code without hacking the whole thing (and loosing the
possibility of upgrading).

as long as the code was open, i would be happy to pay a certain amount
for the application.

anyone?

phil









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



[PHP] selected index

2005-10-25 Thread Ross
Hi,

I have an array

$people= array (ross, bob, chris)
I have a variable

$selected_person = chris



I want to do the find out the index of the $selected_person in the $people 
array. Is there a function that can do this??

ta,



Ross

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



Re: [PHP] how to display GD graphic in web page

2005-10-25 Thread Chris
Thanks for the detailed explanation.

I should have expanded further on my design goals though. I initiated my 
examination of this problem when I tried to generate my on-the-fly images 
with a class method like:

// on_the_fly.php
script language=php
class on_the_fly {
function on_the_fly() {
}
function a_graphic() {
 $image = imagecreatefrompng(my_graphic.png);
 imagepng($image);
 }
}
/script

then call the method as needed as in:

// my_page.php
html
head
titleUntitled Document/title
/head
body
script language=php
include ('on_the_fly.php');
$otf_graphic = new on_the_fly();
echo img src=$otf_graphic-a_graphic();
/script
/body
/html

This resulted in a page filled with random characters.

So I interpret from your response that I'm still unable to reference img 
src=$otf_graphic-a_graphic() and MUST create my on-the-fly graphic in a 
*.php file or *.png as you suggest.

Thanks
Chris

Richard Lynch [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On Mon, October 24, 2005 7:14 pm, Chris wrote:
 I don't understand what is going on with a simple example I created to
 understand how GD graphics are presented in a web page.

 Basically, you were right the first time.

 Think of it this way:

 HTML pages generally have, well, HTML in them.

 Sometimes that HTML has an IMG tag, and that provides a URL to an image.

 But, with static images, you don't copy/paste the image itself right
 into your HTML.

 It's just another URL that the browser gets after it gets the HTML.

 PHP doesn't change any of this, really, except that now the URL for
 the image just *happens* to be an image that is composed on the fly.

 Now if I treat graphic.php as an image, and reference in another page

 graphic.php *is* an image, just like, any other image.

 So you should treat it like an image.

 my_graphic.png is no longer displayed and the web page gets filled
 with
 random characters.

 If you had a PNG, and if you opened up that file in Notepad/BBEdit/vi
 and you copied all the stuff out of it and pasted it into your HTML,
 that's pretty much what you would get, right?

 Just like you just did with PHP doing the paste

 Now, one little caveat:

 Microsoft, in its infinite wisdom, frequently IGNORES the
 Content-type: head from the HTTP specification in various versions
 of Internet Explorer.

 Instead, MS IE will examine the URL and see: graphic.php and say, Oh,
 never mind that silly HTTP specification and Content-type, *this* must
 be a .php file because it ends in .php, and everybody uses 8.3,
 right?

 Then, of course, MS IE says, Oh my goodness! I don't know how to
 handle a '.php' file! Woe is me! and then pops up a Window telling
 the user it has encountered a file of type .php and doesn't know what
 to do with it.
 [I'll tell 'em what to do with it... :-)]

 Anyway, if you're going to do much with dynamic images, you might as
 well start getting them to have .png filenames now.

 There are lots of techniques for this, but the whole ignoring
 Content-type mess of MS IE, and because of their similar idiocy with
 GET parameters for .pdf and .swf files, I recommend this:

 Make your HTML and your URL indistinguishable from static HTML/URL, so
 that MS IE can't *possibly* [bleep] up.

 Put this in an .htaccess file next to the graphic.php script:

 Files graphic.png
  ForceType application/x-httpd-php
 /Files

 Now, rename graphic.php to graphic.png

 Voila.

 MS IE sees graphic.png and knows it's a PNG.

 Apache was told that graphic.png is *really* a PHP script, so Apache
 fires up PHP and PHP/GD make the image and spit it out.

 Your HTML and PNG are indistinguishable by the browser from a static
 image, and they'd have to break every PNG out there to make yours not
 work.  Which, knowing MS, is not *impossible* but it's a lot less
 likely than their various versions of IE that will break on
 http://example.com/graphic.php as a PNG image URL.

 -- 
 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] selected index

2005-10-25 Thread Adrian Bruce


dont know of a function but this should work

$size = count($array);
for($i=0;$i$size;$i++){
   if($selected_person == $array[$i]){
  echoindex: $i;
   }
}

Adrian

Ross wrote:


Hi,

I have an array

$people= array (ross, bob, chris)
I have a variable

$selected_person = chris



I want to do the find out the index of the $selected_person in the $people 
array. Is there a function that can do this??


ta,



Ross

 



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



RE: [PHP] Ugh, w32 anything is making me want to drink!

2005-10-25 Thread Jay Blanchard
[snip]
This before or after you switched to Apache?...
[/snip]

Before...the switch to Apache solved many, many problems.

[snip - for informational purposes]
Can you surf to a static page?

Can you surf to a static page in the same directory as the PHP page?

PHP CGI or Service/Module?

Anything in the log files?

Do all browsers say 404, or is that just the badly-broken MS IE
generalized message?
[/snip]

I could surf to static pages, including ones in the PHP directory. PHP was
running as ISAPI. The log files showed 404 errors regardless of browser. The
PHP was working fine until I rebooted the server, which was done to see if I
could solve the extensions problem. With Apache installed the only thing I
have to worry about will be some PERL stuff and I will probably install
Apache::ASP to handle some legacy stuff until I can convert it to PHP.

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



Re: [PHP] Re: Email Validation built-in? RFC

2005-10-25 Thread Robin Vickery
On 10/24/05, Manuel Lemos [EMAIL PROTECTED] wrote:
 on 10/23/2005 07:21 PM Robin Vickery said the following:
 
  ... would it not make sense for there to be a BUILT-IN PHP function of
  a TRUE email syntactic validation?
  I don't see that being much better than passing a good regular
  expression to preg_match.
 
  1.  Technically you can't write a regular expression that matches
  *all* valid email addresses as part of the address specification is
  recursive.
 
   ccontent   = ctext / quoted-pair / comment
   comment  = ( *([FWS] ccontent) [FWS] )
 
  Admittedly 99.99% of people don't even know you *can* comment email
  addresses so it's not a huge problem...

 If I am not mistaken, PCRE supports recursive regular expressions.

I'm afraid not. You can hack recursion in Perl with the (??{ }) 
postponed expression construct. But PCRE doesn't support it.

Without recursion, the best you can do is decide on a reasonable depth
of nested comments and hardcode that.

 Anyway, the way I got the RFC that is not quite the form of an address
 but the way it may be presented in message header. Meaning, you can add
 comments in To: or other e-mail header but in reality the comments are
 not part of the address.

I'm not sure exactly what you mean here. It's true that comments don't
affect how mail gets delivered, but they're very definitely part of
the address and may well have a meaning to the recipient that you
can't predict. They could be using it for anti-spam or to disinguish
between users of a mailbox or... well, anything really.

Which is the reason that RFC-2821 recommends that they be passed to
the recipient unchanged.

  2. Very few people seem to be capable of recognising a *good* regular
  expression, let alone writing one. It seems clear that validating an
  address is a task that many people want to do, but few can do
  properly. I'd say that's a good reason for making it a built-in
  function.

 Yes. What I meant is that just copying a good enough regular expression
 would be sufficient to use it. There is no need to understand it.

I had a quick look through my email last night and found 14 different
email validation regular expressions posted to this list in the last
few months. All of them would falsely reject valid addresses even
without taking comments into account. 6 of them wouldn't even allow
judy.o'[EMAIL PROTECTED] and another 3 would reject mail from the
entire .museum TLD.

What that would indicate to me, is that many people can't even
recognise what a good enough regular expression looks like.

 What I meant is that despite I use that regular expression for many
 years without complaints, it could be improved to reject only invalid
 characters, but of course that is not what that expression does.

Possibly because those whose email addresses it rejected couldn't
contact you to complain? :-)

Actually, I have very little problem with your regexp - I'd like it to
handle domain literals, as they can be useful in communicating with
people with broken DNS. But that's about it.

  -robin

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



RE: [PHP] Problem reading SimpleXML array NOT SOLVED but NO LONGER A PROBLEM

2005-10-25 Thread George Pitcher
Hi,

Got round the problem by doing this instead:

$param = array(
'country1' = 'uk',
'country2' = 'usa'
);
$wsdl=http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl;;
$curr_client = new nusoapclient($wsdl, 'wsdl');
$rate = $curr_client-call('getRate' ,$param);

The ends justified the means, though I am still using SimpleXML to parse my
Copyright Clearance Center processes.

Cheers

George

 -Original Message-
 From: Jochem Maas [mailto:[EMAIL PROTECTED]
 Sent: 24 October 2005 8:50 pm
 To: [EMAIL PROTECTED]
 Cc: George Pitcher; php-general@lists.php.net
 Subject: Re: [PHP] Problem reading SimpleXML array


 Richard,

 I'm guessing you haven't played with simpleXML ...

 (apologies inadvance for any/all mistakes :-)

 chances are the var_dump() pointer you gave (which under
 normal circumstances would be spot on) will probably
 lead to more confusion. to put it lightly SimpleXML
 doesn't lend itself to introspection (ATM?) because of the
 very #%^$ (for the totally naive: that was masking the word 'nice')
 string casting magic. at least it drove me absolutely nuts.

 anyway copious and experimental use of explicit casting to
 strings [i.e. using '(string)'] was the order of the day for me.

 as far as I understand it the problem lies in the fact that the object
 you get back has properties which behave as strings and objects which
 for good measure can (all) can be iterated [foreach] like arrays.

 all very simple, well ... you decide. :-)

 Richard Lynch wrote:
  On Mon, October 24, 2005 3:50 am, George Pitcher wrote:
 
 Hi,
 
 I'm having a problem reading an xml feed. This is my object:
 
 SimpleXMLElement Object (
 [Header] = SimpleXMLElement Object (
 [ID] = FX12GB
 [Test] = false
 [Name] = Foreign Exchange United Kingdom Pound Noon Rates
 [Prepared] = 2005-10-24
 [Sender] = SimpleXMLElement Object (
 [Name] = Federal Reserve Bank of New York
 [Contact] = SimpleXMLElement Object (
 [Name] = George Matthes
 [Email] = [EMAIL PROTECTED] ) )
 [ReportingBegin] = 1994-01-06 )
 [DataSet] = SimpleXMLElement Object (
 [Series] = SimpleXMLElement Object (
 [Key] = SimpleXMLElement Object (
 [FREQ] = D
 [CURR] = GBP
 [FX_TIME] = 12
 [FX_TYPE] = S )
 [Obs] = SimpleXMLElement Object (
 [TIME_PERIOD] = 2005-10-21
 [OBS_VALUE] = 1.7692 ) ) ) )
 
 I'm trying to get those last two lines: TIME_PERIOD and OBS_VALUE.
 
 I can get the ID (third line) using $s-Header-ID (where $s is my
 object).
 $s-DataSet-Series-Obs-TIME_PERIOD;   // 'Trying to get property of
 non-object'
 
 
 
  echo PRE;
  var_dump($s);
  echo hr /\n;
  var_dump($s-DataSet);
  echo hr /\n;
  var_dump($s-DataSet-Series);
  echo hr /\n;
  .
  .
  .
 



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



Re: [PHP] Re: Email Validation built-in? RFC

2005-10-25 Thread Robin Vickery
On 10/25/05, Mark Charette [EMAIL PROTECTED] wrote:
 Ben Litton wrote:

  You could certainly write an extension to do so. That's what I did
  (mostly  I was writing one for another purpose and added a function I
  stole from  O'Reilly.

 As you stated in your article, it isn't rfc822 compliant (it isn't even
 close). Richard was pretty specific in  his needs.

Just in case anyone's inspired to read through the specs; It's
RFC-2822 these days. RFC-822 is obsolete.

  -robin

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



[PHP] Re: selected index

2005-10-25 Thread Rosty Kerei
try array_search()

Sincerely,
Rosty Kerei
[EMAIL PROTECTED]

Ross [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi,

 I have an array

 $people= array (ross, bob, chris)
 I have a variable

 $selected_person = chris



 I want to do the find out the index of the $selected_person in the $people 
 array. Is there a function that can do this??

 ta,



 Ross 

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



Re: [PHP] php 5.0.5 segfaults apache2 on ubuntu, 5.0.4 ok

2005-10-25 Thread Petr Smith

I just found this is known bug and was already fixed in CVS.

http://bugs.php.net/bug.php?id=34450edit=2

thanks to all!

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



[PHP] Re: selected index

2005-10-25 Thread Al

Ross wrote:

Hi,

I have an array

$people= array (ross, bob, chris)
I have a variable

$selected_person = chris



I want to do the find out the index of the $selected_person in the $people 
array. Is there a function that can do this??


ta,



Ross


It appears you are learning php.

I suggest that you will find it very rewarding to learn the array functions.  I certainly did when I first started work 
with php.


There is an array function that does exactly what you want.

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



[PHP] Re: GUID or any other unique IDs

2005-10-25 Thread Rosty Kerei
I would use simple auto_increment DB's feature..

Sincerely,
Rosty Kerei [EMAIL PROTECTED]

Denis Gerasimov [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hello list,



 I am in a need of GUID generator but it seems that PHP doesn't have this 
 as
 a built-in feature.

 I looked at http://pear.php.net http://pear.php.net/  and
 http://pecl.php.net http://pecl.php.net/  but found nothing suitable
 there.



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



 Can anyone recommend a way for solving this trouble?



 Have a great day,



 Denis S Gerasimov
 Web Developer
 Team Force LLC

 Web:http://www.team-force.org/ www.team-force.org

 RU  Int'l:   +7 8362-468693

 email:[EMAIL PROTECTED]



 

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



Re: [PHP] GUID or any other unique IDs

2005-10-25 Thread Ben Litton
While not ideal, you could do a select on a db. MS SQL and MySQL both have  
functions to generate unique id's and I imagine the other databases do as  
well. While running a SELECT uuid() and hitting the database for each  
one of these things is annoying, it is one possible pseudo-solution.


On Tue, 25 Oct 2005 06:47:26 -0400, Denis Gerasimov  
[EMAIL PROTECTED] wrote:



Hello Jasper,


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

Is there a PHP extension or an external library for generating GUIDs?

Have a great day,

Denis S Gerasimov
Web Developer
Team Force LLC

Web:   www.team-force.org
RU  Int'l:   +7 8362-468693
email:[EMAIL PROTECTED]




--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

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



Re: [PHP] selected index

2005-10-25 Thread Sascha Braun

Hi,

just take a look at this function:

http://www.php.net/manual/en/function.array-keys.php
__
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193

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



[PHP] cURL to re-post form iinformation

2005-10-25 Thread Jay Blanchard
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 curlas 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!

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



Re: [PHP] PDF printing under windows.

2005-10-25 Thread Dave Lists

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.

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



[PHP] How to read word document by php script

2005-10-25 Thread Roman Duriancik

How can I  read data from word document (*.doc)  use by php script ?
I konw only how to write and how to open word document.

Thanks

roman

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



[PHP] Re: How to read word document by php script

2005-10-25 Thread Oliver Grätz
Roman Duriancik schrieb:
 How can I  read data from word document (*.doc)  use by php script ?
 I konw only how to write and how to open word document.

Convert the .doc to a .txt document before opening it with PHP.
There are external tools available to do this but I won't do the
searching for you ;-)

OLLi

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



RE: [PHP] How to read word document by php script

2005-10-25 Thread Jay Blanchard
[snip]
How can I  read data from word document (*.doc)  use by php script ?
I konw only how to write and how to open word document.
[/snip]

http://www.php.net/com

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



Re: [PHP] How to protect a php script that sends variables to itself

2005-10-25 Thread Graham Anderson

thanks, Richard :)

The simplest solution is usually the best
As you suggested, I used php to  created a 'log in' movie which upon  
authentication loads the playlist of movies
Also, as you suggested, I think I'll create a session id  with a  
master password, can see everything,  and a 'movie specific' password


head spinning slowing.
g

On Oct 24, 2005, at 7:20 PM, Richard Lynch wrote:


The script , makeMoviePlaylist.php, is calling itself on the server
with
makeMoviePlaylist.php?cmd=getmoviepath=encrypted_path_to_the_movie
The script, makeMoviePlaylist.php,  accepts the request because it
originated from ITSELF on the server...



How do you *KNOW* it originated from ITSELF?

Can't I just fake it out by copying the URL you are using?



This request was sent from OUTSIDE the server. The main script,
makeMoviePlaylist.php, realizes the this request did not originate
from itself on the server



Again, how you do *KNOW* that to be true?



What's the big picture again?

They need to login to see the movies, right?

Or is it something else?

If just need login, use http://php.net/session_start and friends as I
just posted.

If it's something else, session_start() may not help.

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

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



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



Re: [PHP] PDF printing under windows.

2005-10-25 Thread tg-php
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 

[PHP] create HTML page on the fly

2005-10-25 Thread Angelo Zanetti

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

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



Re: [PHP] php Slow with Mac OS X 10.4

2005-10-25 Thread Nicolas Ross

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 preemptions7 context switches1 thread
08:45:51
 0 faults90 system calls
0:00:11

TYPENUMBERCPU_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_hit22   0:00.000

read829(2)0:00.018   0:04.821( 0:01.096)
W
getdirentries  5214   0:02.260   0:00.416
getattrlist6689   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
select4(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
fstatfs5212   0:00.075   0:00.000
readlink280   0:00.006   0:00.000
write50(9)0:00.005   0:00.000
chdir 2   0:00.000
accept1   0:00.000
getsockname   1   0:00.000
access   44   0:00.001
sigaction21(14)   0:00.000
sigprocmask  23   0:00.000
umask 3   0:00.000
setitimer 3   0:00.000
socket1   0:00.000
connect   1   0:00.000
setsockopt4   0:00.000
gettimeofday  2   0:00.000
getsockopt1   0:00.000
writev1   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: php-general@lists.php.net; 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 

Re: [PHP] create HTML page on the fly

2005-10-25 Thread Adrian Bruce
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+)){
   echoopened; 
} 
   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



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



RE: [PHP] PDF printing under windows.

2005-10-25 Thread Finner, Doug
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: php-general@lists.php.net; php-windows@lists.php.net
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 

Re: [PHP] create HTML page on the fly

2005-10-25 Thread Angelo Zanetti

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



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



Re: [PHP] create HTML page on the fly

2005-10-25 Thread David Tulloh
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

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



Re: [PHP] PDF printing under windows.

2005-10-25 Thread Dave Lists

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

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



Re: [PHP] create HTML page on the fly

2005-10-25 Thread Miles Thompson

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 


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



Re: [PHP] cURL to re-post form iinformation

2005-10-25 Thread Richard Lynch
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 curlas 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

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



RE: [PHP] cURL to re-post form iinformation

2005-10-25 Thread Jay Blanchard
[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

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



[PHP] Re: ICQ

2005-10-25 Thread Michelle Konzack
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/8845235667100 Strasbourg/France   IRC #Debian (irc.icq.com)

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



RE: [PHP] cURL to re-post form iinformation

2005-10-25 Thread Richard Lynch
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

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



RE: [PHP] cURL to re-post form iinformation

2005-10-25 Thread Jay Blanchard
[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

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



Re: [PHP] GUID or any other unique IDs

2005-10-25 Thread Richard Lynch
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

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



Re: [PHP] SMTP PHP: Spam Tagging Problem

2005-10-25 Thread Richard Lynch
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

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



[PHP] Re: Help with a regular expression for 0,1 or 2 decimal places

2005-10-25 Thread Phillip Oertel
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

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



[PHP] Re: cURL to re-post form iinformation

2005-10-25 Thread Al

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



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



Re: [PHP] Re: Help with a regular expression for 0,1 or 2 decimal places

2005-10-25 Thread Florent Monnier
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

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



Re: [PHP] Re: Help with a regular expression for 0,1 or 2 decimal places

2005-10-25 Thread John Nichel

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]

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



RE: [PHP] GUID or any other unique IDs

2005-10-25 Thread Jasper Bryant-Greene
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

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



RE: [PHP] Re: cURL to re-post form iinformation - SOLVED SORTA

2005-10-25 Thread Jay Blanchard
[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 reallyit 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
browserbut 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. 

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



Re: [PHP] PDF printing under windows.

2005-10-25 Thread tg-php
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.

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



[PHP] Strange array access problem

2005-10-25 Thread Ken Tozier
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

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



Re: [PHP] Strange array access problem

2005-10-25 Thread Robert Cummings
On Wed, 2005-10-26 at 00:28, Ken Tozier wrote:
 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 }

I did the following as a test:

?php
$unpacked_data = array
(
'handler' = array
(
'0' = 'databases', 
),
);
?

var_dump( $unpacked_data );

and I did...

?php
$unpacked_data = array
(
'handler' = array
(
0 = 'databases', 
),
);

var_dump( $unpacked_data );
?

I also tried:

?php
$unpacked_data = array
(
'handler' = array
(
'0' = 'databases', 
),
);

var_dump( $unpacked_data );
?

But no matter what I did I could NOT get var_dump to dump my 0 key for
the 'databases' as you have in your output. So methinks therein may lie
your problem. Perhaps during the serialization in javascript check if
the key is an integer-like string and if so then convert to an integer
for the key serialization.

Let us know if it works :)

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] fopen

2005-10-25 Thread Stephen Leaf
if all you want to do is read the entire file try
$contents = file_get_contents($filename);

On Tuesday 25 October 2005 11:54 pm, John Taylor-Johnston wrote:
 It does what I want, but I worry 4096 may not be big enough. Possible?
 Is there a way to detect the filesize and insert a value for 4096?
 $buffer = fgets($dataFile, $filesize);
 Is this what it is for?
 John


 ?php
 #http://ca3.php.net/fopen
 $filename = /var/www/html2/assets/about.htm ;
 $dataFile = fopen( $filename, r ) ;
while (!feof($dataFile))
{
$buffer = fgets($dataFile, 4096);
echo $buffer;
}
 $sql = insert into table ... $buffer;
 ?

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



Re: [PHP] create HTML page on the fly

2005-10-25 Thread Angelo Zanetti

Hi Miles.

Well the system that I wrote generates HTML newsletters using templates 
etc... and before the newsletter is sent out it has to go to moderators 
for approval.So a moderator will have a link in his email received and 
it will point to the newsletter in HTML format, also it is needed so 
that people who cant read HTML emails get a link to the newsletter and 
can go to that page to see it. Does it make sense??


thanks for your input, much appreciated.



Angelo Zanetti
Z Logic
www.zlogic.co.za
[c] +27 72 441 3355
[t] +27 21 469 1052


Miles Thompson wrote:

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


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



Re: [PHP] fopen

2005-10-25 Thread Joe Wollard


On Oct 26, 2005, at 12:54 AM, John Taylor-Johnston wrote:

It does what I want, but I worry 4096 may not be big enough.  
Possible? Is there a way to detect the filesize and insert a value  
for 4096?

$buffer = fgets($dataFile, $filesize);
Is this what it is for?
John


?php
#http://ca3.php.net/fopen
$filename = /var/www/html2/assets/about.htm ;
$dataFile = fopen( $filename, r ) ;
  while (!feof($dataFile))
  {
  $buffer = fgets($dataFile, 4096);
  echo $buffer;
  }
$sql = insert into table ... $buffer;
?

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




fgets

(PHP 3, PHP 4, PHP 5)

fgets -- Gets line from file pointer
Description

string fgets ( resource handle [, int length] )

Returns a string of up to length - 1 bytes read from the file pointed  
to by handle. Reading ends when length - 1 bytes have been read, on a  
newline (which is included in the return value), or on EOF (whichever  
comes first). If no length is specified, the length defaults to 1k,  
or 1024 bytes.


If an error occurs, returns FALSE.

Re: [PHP] Strange array access problem

2005-10-25 Thread Robert Cummings
On Wed, 2005-10-26 at 01:06, Robert Cummings wrote:

 I did some more investigating. Your problem appears to be PHP5 specific.
 I manually created the serialize string I assumed you had, but PHP4 was
 smarter than me and auto converted the string key to an integer once
 again; however, PHP5 for some reason during unserialization maintained
 the string type for the key, however it was not able to access the value
 because upon attempting to access the value I'm assuming it did a type
 conversion to integer... additionally I got the following error notice
 when trying to access the value:
 
 bNotice/b:  Undefined index:  0 in b/home/suds/foo.php/b on line
 b25/bbr /
 NULL
 
 The following can duplicated the error:
 
 $ser = 'a:1:{s:1:0;s:3:foo;}';
 $unser = unserialize( $ser );
 var_dump( $unser );
 var_dump( $unser['0'] );

FYI this is not considered a bug in PHP since PHP will not produce
serialized output in that form (IMHO it is a bug since it deviates from
an expected functionality with respect to how serialized data should be
encoded-- but then maybe there's a doc somewhere that states you have to
convert integer strings to real integers for keys *shrug*):

http://bugs.php.net/bug.php?id=27712

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



[PHP] fopen

2005-10-25 Thread John Taylor-Johnston
It does what I want, but I worry 4096 may not be big enough. Possible? 
Is there a way to detect the filesize and insert a value for 4096?

$buffer = fgets($dataFile, $filesize);
Is this what it is for?
John


?php
#http://ca3.php.net/fopen
$filename = /var/www/html2/assets/about.htm ;
$dataFile = fopen( $filename, r ) ;
  while (!feof($dataFile))
  {
  $buffer = fgets($dataFile, 4096);
  echo $buffer;
  }
$sql = insert into table ... $buffer;
?

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



Re: [PHP] Strange array access problem

2005-10-25 Thread Ken Tozier

Rob ,

Very helpful, Thanks!

I'll try to rewrite the serializer on the javascript end to encode  
integer keys as integers.


Ken


On Oct 26, 2005, at 1:23 AM, Robert Cummings wrote:


On Wed, 2005-10-26 at 01:06, Robert Cummings wrote:



I did some more investigating. Your problem appears to be PHP5  
specific.
I manually created the serialize string I assumed you had, but  
PHP4 was

smarter than me and auto converted the string key to an integer once
again; however, PHP5 for some reason during unserialization  
maintained
the string type for the key, however it was not able to access the  
value
because upon attempting to access the value I'm assuming it did a  
type
conversion to integer... additionally I got the following error  
notice

when trying to access the value:

bNotice/b:  Undefined index:  0 in b/home/suds/foo.php/b  
on line

b25/bbr /
NULL

The following can duplicated the error:

$ser = 'a:1:{s:1:0;s:3:foo;}';
$unser = unserialize( $ser );
var_dump( $unser );
var_dump( $unser['0'] );



FYI this is not considered a bug in PHP since PHP will not produce
serialized output in that form (IMHO it is a bug since it deviates  
from
an expected functionality with respect to how serialized data  
should be
encoded-- but then maybe there's a doc somewhere that states you  
have to

convert integer strings to real integers for keys *shrug*):

http://bugs.php.net/bug.php?id=27712

Cheers,
Rob.
--
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

--
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] Java editor

2005-10-25 Thread Angelo Zanetti

also check out solmetra.com I think, not sure if its open source...

HTH


John Taylor-Johnston wrote:
Is there a OS java (or other) html editor I can implement on a Web page. 
I want a user to type text, use bold, italics, etc.
I would then store the html in a MySQl record and then use php to insert 
the edited text.

I've seen some packaged, in Moodle for example.
John



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



Re: [PHP] Strange array access problem

2005-10-25 Thread Robert Cummings
 On Wed, 2005-10-26 at 00:28, Ken Tozier wrote:
  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 }

Then later that day I wrote:
 But no matter what I did I could NOT get var_dump to dump my 0 key for
 the 'databases' as you have in your output. So methinks therein may lie
 your problem. Perhaps during the serialization in javascript check if
 the key is an integer-like string and if so then convert to an integer
 for the key serialization.

I did some more investigating. Your problem appears to be PHP5 specific.
I manually created the serialize string I assumed you had, but PHP4 was
smarter than me and auto converted the string key to an integer once
again; however, PHP5 for some reason during unserialization maintained
the string type for the key, however it was not able to access the value
because upon attempting to access the value I'm assuming it did a type
conversion to integer... additionally I got the following error notice
when trying to access the value:

bNotice/b:  Undefined index:  0 in b/home/suds/foo.php/b on line
b25/bbr /
NULL

The following can duplicated the error:

$ser = 'a:1:{s:1:0;s:3:foo;}';
$unser = unserialize( $ser );
var_dump( $unser );
var_dump( $unser['0'] );

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Strange array access problem

2005-10-25 Thread Ken Tozier

Got it working.

Thanks for all your help Rob.

Ken

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