php-general Digest 7 Sep 2004 07:58:47 -0000 Issue 2981
Topics (messages 195990 through 196019):
Force the download of .pdf or image files
195990 by: Ricardo Cezar
195994 by: Jim Grill
Re: Multi-User Text-Editing
195991 by: M. Sokolewicz
195992 by: Michal Migurski
195995 by: Daniel Schierbeck
195996 by: Daniel Schierbeck
195999 by: Michal Migurski
196001 by: raditha dissanayake
196008 by: zareef ahmed
Re: Dinamic generate PDF : which way ? (classes, docbook)
195993 by: Jim Grill
Instant private messenger
195997 by: Phpu
195998 by: Greg Donald
196002 by: raditha dissanayake
196003 by: ceg
Problem with SSH output when called from apache
196000 by: Chandu Nannapaneni
196004 by: Rasmus Lerdorf
unable to use pear
196005 by: Auditour
196009 by: zareef ahmed
Re: Adding a realtime monitoring console
196006 by: Eric Emminger
Re: Web Fetch & Process
196007 by: Zoran
More on the credit card fraud
196010 by: Brian Dunning
converting seconds since unix epoc to date array
196011 by: Jason FB
196012 by: zareef ahmed
196013 by: John Holmes
196014 by: Justin French
196015 by: Jason Davidson
196016 by: Jason Davidson
Downloading a part of a file
196017 by: Octavian Rasnita
Convert Smart Quotes to Sraight Quotes - Need Help!
196018 by: Monty
Re: Regex for Validating URL
196019 by: Burhan Khalid
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 ---
How can I force the download of .pdf, .doc and image files? I have some
links to downloadable docs in my website, but when we click the links, IE
opens the file directly in the window. I wish when the user click a download
start, even if it is a .jpg, .gif, .pdf or .doc file.
There is a way to make that in PHP?
I have the idea do ZIP the files automaticly when my PHP script upload it to
the server, but can�t figure out how to make that.
Thanks,
Rics
--- End Message ---
--- Begin Message ---
> How can I force the download of .pdf, .doc and image files? I have some
> links to downloadable docs in my website, but when we click the links, IE
> opens the file directly in the window. I wish when the user click a
download
> start, even if it is a .jpg, .gif, .pdf or .doc file.
>
> There is a way to make that in PHP?
>
> I have the idea do ZIP the files automaticly when my PHP script upload it
to
> the server, but can�t figure out how to make that.
>
> Thanks,
> Rics
>
Very common problem... very easy solution.
http://www.google.com/search?hl=en&lr=&ie=UTF-8&q=php+header+force+download
Jim Grill
--- End Message ---
--- Begin Message ---
Daniel Schierbeck wrote:
I'm developing a site with information about songs, albums and artists.
I would like to have the song lyrics as well, but i don't know how i
should approach it.
What i want is basically a way for many users to update, add or delete
parts of a text (the lyric). It will probably only be 'trusted' users
that'll be able to do it (users that has added more than x
artists/albums/songs). How can i make a CVS-like system, where you can
see the changes people made, maybe roll back to an earlier version etc.
etc.?
I think i'll use MySQL, but if you think it's easier to use XML or
something else, that'll be fine with me (as long as it's generally
available).
Thank you in advance guys :)
if you really want to, you can use CVS to do that... =)
It can be made to use a web-interface and to correctly add/do whatever
everything...
--- End Message ---
--- Begin Message ---
> What i want is basically a way for many users to update, add or delete
> parts of a text (the lyric). It will probably only be 'trusted' users
> that'll be able to do it (users that has added more than x
> artists/albums/songs). How can i make a CVS-like system, where you can
> see the changes people made, maybe roll back to an earlier version etc.
> etc.?
You've just described a wiki - one example of a wiki that is written in
PHP and MySQL is http://tavi.sourceforge.net. The code is a little
spaghetti-like, but you should be able to look through the database schema
to understand how they implement the multi-user text editing, and how to
handle the related problems of locking and revision control.
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html
--- End Message ---
--- Begin Message ---
Michal Migurski wrote:
What i want is basically a way for many users to update, add or delete
parts of a text (the lyric). It will probably only be 'trusted' users
that'll be able to do it (users that has added more than x
artists/albums/songs). How can i make a CVS-like system, where you can
see the changes people made, maybe roll back to an earlier version etc.
etc.?
You've just described a wiki - one example of a wiki that is written in
PHP and MySQL is http://tavi.sourceforge.net. The code is a little
spaghetti-like, but you should be able to look through the database schema
to understand how they implement the multi-user text editing, and how to
handle the related problems of locking and revision control.
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html
Thanks, I'll look into it. Also the CVS-in-PHP thing.
--
Daniel Schierbeck
--- End Message ---
--- Begin Message ---
Michal Migurski wrote:
What i want is basically a way for many users to update, add or delete
parts of a text (the lyric). It will probably only be 'trusted' users
that'll be able to do it (users that has added more than x
artists/albums/songs). How can i make a CVS-like system, where you can
see the changes people made, maybe roll back to an earlier version etc.
etc.?
You've just described a wiki - one example of a wiki that is written in
PHP and MySQL is http://tavi.sourceforge.net. The code is a little
spaghetti-like, but you should be able to look through the database schema
to understand how they implement the multi-user text editing, and how to
handle the related problems of locking and revision control.
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html
Wow, confusing code - but i think i got the idea. Just one thing: After
reading the code, it seems to me that every time someone makes a change
to a record, a new row is inserted into the DB with the full text of the
edited record - not just the changes. I saw that there was an automatic
expiration function, but still, wouldn't it be a drag for the server?
--
Daniel Schierbeck
--- End Message ---
--- Begin Message ---
> > You've just described a wiki - one example of a wiki that is written in
> > PHP and MySQL is http://tavi.sourceforge.net. The code is a little
> > spaghetti-like, but you should be able to look through the database schema
> > to understand how they implement the multi-user text editing, and how to
> > handle the related problems of locking and revision control.
>
> Wow, confusing code - but i think i got the idea. Just one thing: After
> reading the code, it seems to me that every time someone makes a change
> to a record, a new row is inserted into the DB with the full text of the
> edited record - not just the changes. I saw that there was an automatic
> expiration function, but still, wouldn't it be a drag for the server?
Yeah, that's what happens.
I think it's only a problem if you're storing truly stupendous amounts of
text, and then it's just a storage problem - drives are cheap.
If anything, storing the changes only would probably be a bigger processor
load, since viewing any one page would mean having to reconstruct the
content from all previous versions. This way, the overhead of a diff is
only incurred when you want to view changes to a file between two given
versions.
I think the rationale behind CVS storing just diffs is that it has
branches and merges, while wiki text generally does not. Also (conjecture)
it may be a historical legacy of RCS, from a time when storage was not
quite so cheap.
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html
--- End Message ---
--- Begin Message ---
Daniel Schierbeck wrote:
Michal Migurski wrote:
What i want is basically a way for many users to update, add or delete
parts of a text (the lyric). It will probably only be 'trusted' users
that'll be able to do it (users that has added more than x
artists/albums/songs). How can i make a CVS-like system, where you can
see the changes people made, maybe roll back to an earlier version etc.
etc.?
You've just described a wiki - one example of a wiki that is written in
PHP and MySQL is http://tavi.sourceforge.net.
Wow, confusing code - but i think i got the idea. Just one thing:
After reading the code, it seems to me that every time someone makes a
change to a record, a new row is inserted into the DB with the full
text of the edited record - not just the changes. I saw that there was
an automatic expiration function, but still, wouldn't it be a drag for
the server?
Another wiki is the mediawiki projec the one that powers
http://www.wikipedia.org/ this is probabl more complex than the one that
you have already been referred to. BTW according to theory the time to
retrieve a single record from a properly index database does not
increase with the number of records in the table. Inserts on the other
hand do get slowed down often significantly.
--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--- End Message ---
--- Begin Message ---
Hi,
look at it
http://www.freebsd.org/projects/cvsweb.html
may be usefull.
zareef ahmed
--- raditha dissanayake <[EMAIL PROTECTED]> wrote:
> Daniel Schierbeck wrote:
>
> > Michal Migurski wrote:
> >
> >>> What i want is basically a way for many users to
> update, add or delete
> >>> parts of a text (the lyric). It will probably
> only be 'trusted' users
> >>> that'll be able to do it (users that has added
> more than x
> >>> artists/albums/songs). How can i make a CVS-like
> system, where you can
> >>> see the changes people made, maybe roll back to
> an earlier version etc.
> >>> etc.?
> >>
> >>
> >>
> >> You've just described a wiki - one example of a
> wiki that is written in
> >> PHP and MySQL is http://tavi.sourceforge.net.
> >
> > Wow, confusing code - but i think i got the idea.
> Just one thing:
> > After reading the code, it seems to me that every
> time someone makes a
> > change to a record, a new row is inserted into the
> DB with the full
> > text of the edited record - not just the changes.
> I saw that there was
> > an automatic expiration function, but still,
> wouldn't it be a drag for
> > the server?
> >
>
> Another wiki is the mediawiki projec the one that
> powers
> http://www.wikipedia.org/ this is probabl more
> complex than the one that
> you have already been referred to. BTW according to
> theory the time to
> retrieve a single record from a properly index
> database does not
> increase with the number of records in the table.
> Inserts on the other
> hand do get slowed down often significantly.
>
> --
> Raditha Dissanayake.
>
------------------------------------------------------------------------
> http://www.radinks.com/sftp/ |
> http://www.raditha.com/megaupload
> Lean and mean Secure FTP applet with | Mega Upload -
> PHP file uploader
> Graphical User Inteface. Just 128 KB | with progress
> bar.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
=====
Zareef Ahmed :: A PHP Developer in Delhi(India).
Homepage :: http://www.zasaifi.com
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
--- End Message ---
--- Begin Message ---
> Hi,
>
> I am evaluating the http://www.ros.co.nz/pdf/, www.fpdf.org and php
> classes that generate pdf and as another option use docbook to
> convert.
>
> I am not sure which way is better.
>
> >From my point of view:
> a) Both classes seem to be fine but in order to generate (static)
> tables and other elements I will need a lot of programming
> calls/variables. So I'd have a manual and perhaps tedious/error
> procedure to convert the document into the "programable-version" of
> it.
>
> b) I do not have experience with DocBook (even tough I can code html
> and latex) but I could use an editor to generate the document with
> the tables, place images etc. Identify the template variables and
> call docbook to generate the pdf. I'd still have to manually convert
> the file but would not need a lot of calls to generate a table or even
> use a php programmer. I am assuming the the tags needed are more
> easly understanded than $pdf->addCell($data,width..)
>
> Any ideias ?
There is a fairly new project called pdml (
http://pdml.sourceforge.net/index.php ) that extends fpdf that converts html
(sort of) into pdf. I have used it some. It's new and a little buggy, but it
is usable. You could easily use Smarty, XiTemplate, or some other template
engine to manage the markup templates to use with pdml.
There are also several scripts and classes on the fpdf.org site that cover
all sorts of common tasks ( http://fpdf.org/en/script/index.php ).
IMHO DocBook may be a little over-kill and possibly overly burdensome for
this task since it requires your markup be written in DocBook XML format. I
suppose it could be worth while if you plan to create your documents in
several different formats on the fly.
Jim Grill
--- End Message ---
--- Begin Message ---
Hi,
I wanna create an instant private messenger for users who are online on my site.
Foe example: I have a list with online users. I select the user which i wanna send an
message. A popup window will apear, i write the message and click send. To that user
it will appear a popup window with my message.
How can i do that? I've googled but all i found was expensive.
I need a tutorial or something. Could someone help me please !!!
Thank you
--- End Message ---
--- Begin Message ---
On Tue, 7 Sep 2004 00:31:33 +0300, Phpu <[EMAIL PROTECTED]> wrote:
> Hi,
> I wanna create an instant private messenger for users who are online on my site.
> Foe example: I have a list with online users. I select the user which i wanna send
> an message. A popup window will apear, i write the message and click send. To that
> user it will appear a popup window with my message.
>
> How can i do that? I've googled but all i found was expensive.
> I need a tutorial or something. Could someone help me please !!!
http://php.net is a great site for learning PHP, I mean if that's what
you want to code it in and stuff. I haven't ever seen any private
messenger tutorials though, probably a little too specific, I dunno..
--
Greg Donald
http://destiney.com/
--- End Message ---
--- Begin Message ---
Phpu wrote:
Hi,
I wanna create an instant private messenger for users who are online on my site.
Foe example: I have a list with online users. I select the user which i wanna send an
message. A popup window will apear, i write the message and click send. To that user
it will appear a popup window with my message.
How can i do that? I've googled but all i found was expensive.
I need a tutorial or something. Could someone help me please !!!
Thank you
there is a PHP class for jabber at jabberstudio.org
--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--- End Message ---
--- Begin Message ---
Did you check at http://www.hotscripts.com ?
"Phpu" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hi,
I wanna create an instant private messenger for users who are online on my
site.
Foe example: I have a list with online users. I select the user which i
wanna send an message. A popup window will apear, i write the message and
click send. To that user it will appear a popup window with my message.
How can i do that? I've googled but all i found was expensive.
I need a tutorial or something. Could someone help me please !!!
Thank you
--- End Message ---
--- Begin Message ---
Hi everyone !!
I want to capture the output of a certain remote command ( issued
thru a SSH session to a remote server) in PHP.
The following code is working well when ran from the console
Ex: php -q test.php
<?
passthru("/usr/bin/ssh -v -i /var/wwwhtml/sshtest/id_rsa
[EMAIL PROTECTED] uptime");
?>
But when called from apache .. It's not giving any ouput.
[EMAIL PROTECTED] is well configured for ssh without passphrase
I've checked the file permissions of /var/wwwhtml/sshtest/id_rsa
It's given read permissions for the user 'apache' ( apache is running
as apache:apache )
Any hints ???
/Chandu
--- End Message ---
--- Begin Message ---
On Mon, 6 Sep 2004, Chandu Nannapaneni wrote:
> I want to capture the output of a certain remote command ( issued
> thru a SSH session to a remote server) in PHP.
>
> The following code is working well when ran from the console
> Ex: php -q test.php
>
> <?
> passthru("/usr/bin/ssh -v -i /var/wwwhtml/sshtest/id_rsa
> [EMAIL PROTECTED] uptime");
> ?>
>
> But when called from apache .. It's not giving any ouput.
>
> [EMAIL PROTECTED] is well configured for ssh without passphrase
> I've checked the file permissions of /var/wwwhtml/sshtest/id_rsa
> It's given read permissions for the user 'apache' ( apache is running
> as apache:apache )
>
> Any hints ???
But have you tested this as user apache from the command line?
su - apache
/usr/bin/ssh -v -i /var/wwwhtml/sshtest/id_rsa [EMAIL PROTECTED] uptime
Chances are you will also need to add -o "BatchMode yes" to that ssh
command.
-Rasmus
--- End Message ---
--- Begin Message ---
Dear sirs,
I have recently installed the FoxServ package 3.0 on my windows xp
platform.
But when I use the following instruction::
require_once "HTML/Template/ITX.php";
I get this message;
Fatal error: Failed opening required 'HTML/Template/ITX.php'
(include_path='.;c:\php4\pear') in C:\FoxServ\www\example.8-2.php on line 14
Can you help me?
--- End Message ---
--- Begin Message ---
Hi,
Make sure you have installed the pear and double check
your included path in your php.ini .
As per your message it seems that your pear should be
in c:\php4\pear .
Check for it and revert back.
Zareef Ahmed
--- Auditour <[EMAIL PROTECTED]> wrote:
> Dear sirs,
> I have recently installed the FoxServ
> package 3.0 on my windows xp platform.
>
> But when I use the following instruction::
> require_once "HTML/Template/ITX.php";
>
> I get this message;
> Fatal error: Failed opening required
> 'HTML/Template/ITX.php'
> (include_path='.;c:\php4\pear') in
> C:\FoxServ\www\example.8-2.php on line 14
>
> Can you help me?
>
=====
Zareef Ahmed :: A PHP Developer in Delhi(India).
Homepage :: http://www.zasaifi.com
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush
--- End Message ---
--- Begin Message ---
Hi Kelly,
> Assuming the app always attempts communication with registered listeners,
> and then must timeout and unregister a dead listener...at that point
> aren't we just at my preferred solution: socket communication?
I don't know much about sockets, so I couldn't say. If the console
will connect via ssh, isn't that a stateful TCP connection? Can you
keep that connection open with a "keep-alive" or "heartbeat"? Can the
ssh server notify the application when the ssh session dies? How
expensive is it for the application to discover a dead listener?
> A log can be generated from the history table I have implemented. I'm
> developing an application framework and performance is my primary concern.
> The file I/O overhead concerns me unless I were able to leverage it.
Unless you're confident that performance problems will occur, I would
encourage you to completely ignore performance, develop the simplest
implementation and test, measuring actual performance.
> Do you have any links where I might find the pattern described in more
> detail? If nothing else, maybe the article contains ideas that can help
> kick-start another idea....Thanks...!
http://www.dofactory.com/Patterns/PatternObserver.aspx
Just google "event listener pattern" or "observer pattern".
Also, you may find Extreme Programming to be useful.
http://www.extremeprogramming.org/
Eric
--- End Message ---
--- Begin Message ---
Hi
How can I parse HTML page which I fetched by PHP so some part of text would
be replaced by other text.
Also, I managed to delete all HTML code from page (with this code
$data[0] = preg_replace("/([<])+([^>])+([.])*([>])+/i","", $data[0]);
but also would like to delete all chars except numbers from page, can this
be done?
Regards.
Zoran
Your first question:
To replace certain elements take a look at preg_replace()
http://us4.php.net/manual/en/function.preg-replace.php
Example:
$foo = 'stuff <b>silly stuff</b> more stuff';
echo preg_replace('/\<b\>(.*)\<\/b\>/', "<h1>$1 lookie now</h1>", $foo);
Your second question:
You could just use strip_tags()
http://us4.php.net/manual/en/function.strip-tags.php
Your last question:
To delete everything but numbers you could $content =
preg_replace('/[^\d]/','', $content);
Hope that helps
Jim Grill
Hi
This works great. One more question about preg_replace. Is it possible that for every
match other text is replaced?
By this I mean when some text between <b></b> has been found that text is replaced
with some Text, on second match, text between <b></b> is replaced by some other
different text etc.
Btw, where I can find patterns that are valid?
(something like (\w+), (\d+)+i etc.
Thanks.
Regards.
--- End Message ---
--- Begin Message ---
The fraudulent orders that I receive on my site come with email
addresses of eight random alphanumerics @yahoo.com.
Is anyone handy enough with regex or can show me a quick way to test
for that, so I can at least refuse all orders with that pattern? (it
will work for a little while, until they get wise and change patterns
again.)
Many thanks,
- Brian
PS - If anyone wants an update: the orders stopped for a while but
started up this weekend with a vengeance. Now they are coming with
valid address verification AND card validation numbers! Pretty darn
good, whoever's doing it. One of the cops I've spoken with says that
they're making a large number of small charges (like mine) to these
cards and then, in one case, placing a large $2000 order from QVC. In
that case the large charge was declined, thankfully.
--- End Message ---
--- Begin Message ---
Can anyone tell me how to convert a date stored in the format
"YYYY-MM-DD" to an integer of seconds since unix epoc,
then add $daysToAdd days to this value (I suppose if the integer was
a number of seconds it would have to be $daysToAdd*60*60*24 to get
the number of seconds to add)
then convert the new value to a timestamp which I can output using the function
string date ( string format [, int timestamp])
I tried doing this with mktime() and couple different ways using
strtotime() and also with strftime() but I kept getting -1 as the
result for strtotime() indicating the function couldn't interpret the
given date.
I've been through all the date-related functions in the manual I can
think of, but I'm stumpped on this one...
--- End Message ---
--- Begin Message ---
Hi,
Try
$date="YYYY-MM_DD";
$da=explode("-",$date);
Now
$Y=$da['0'];
$M=$da['1'];
$D=$da['2'];
then use mktime();
Hope you will get the results.
zareef ahmed
--- Jason FB <[EMAIL PROTECTED]> wrote:
> Can anyone tell me how to convert a date stored in
> the format
> "YYYY-MM-DD" to an integer of seconds since unix
> epoc,
>
> then add $daysToAdd days to this value (I suppose if
> the integer was
> a number of seconds it would have to be
> $daysToAdd*60*60*24 to get
> the number of seconds to add)
>
> then convert the new value to a timestamp which I
> can output using the function
>
> string date ( string format [, int timestamp])
>
> I tried doing this with mktime() and couple
> different ways using
> strtotime() and also with strftime() but I kept
> getting -1 as the
> result for strtotime() indicating the function
> couldn't interpret the
> given date.
>
> I've been through all the date-related functions in
> the manual I can
> think of, but I'm stumpped on this one...
=====
Homepage :: http://www.zasaifi.com
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo
--- End Message ---
--- Begin Message ---
Jason FB wrote:
Can anyone tell me how to convert a date stored in the format
"YYYY-MM-DD" to an integer of seconds since unix epoc,
then add $daysToAdd days to this value (I suppose if the integer was a
number of seconds it would have to be $daysToAdd*60*60*24 to get the
number of seconds to add)
then convert the new value to a timestamp which I can output using the
function
string date ( string format [, int timestamp])
Is this a MySQL timestamp? If so, you can use TO_UNIXTIME() in your
query to return a Unix timestamp instead of a MySQL one. You can use
DATE_ADD() to add days to the timestamp. You can also use DATE_FORMAT()
to format the timestamp before it's returned also.
If you don't want to do that, what's wrong with strtotime('YYYY-MM-DD')
to get the unix timestamp?
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
Jason,
This seems to work fine for me:
<?
$daysToAdd = 5;
$secondsToAdd = $daysToAdd * 86400;
$dateIn = "2004-07-24";
$dateInStamp = strtotime($dateIn);
echo date('m/d/Y h:i:s',$dateInStamp+$secondsToAdd);
?>
... as does the more condensed version:
<? echo date('m/d/Y h:i:s',strtotime("2004-07-24")+(5*86400)); ?>
If strtotime() is returning -1, that means that it's having trouble
converting your YYYY-MM-DD date to a timestamp. The common pitfall is
that you've got the month and day mixed up (YYYY-DD-MM), or that you're
not using 2 digit numbers on the day and month (and 4 digit on the
year).
If you're having trouble with strtotime(), ech out the date you're
trying to convert, to make sure it's what you're expecting.
It's also worth pointing out that we've made no considerations for
timezones, daylight savings, etc.
UNIX timestamps are all GMT, so if the times you're seeing are not as
expected (and the dates you're collecting aren't GMT dates, then you'll
need to dig a lot deeper -- it's depends how much accuracy you want.
Justin French
On 07/09/2004, at 1:59 PM, Jason FB wrote:
Can anyone tell me how to convert a date stored in the format
"YYYY-MM-DD" to an integer of seconds since unix epoc,
then add $daysToAdd days to this value (I suppose if the integer was a
number of seconds it would have to be $daysToAdd*60*60*24 to get the
number of seconds to add)
then convert the new value to a timestamp which I can output using the
function
string date ( string format [, int timestamp])
I tried doing this with mktime() and couple different ways using
strtotime() and also with strftime() but I kept getting -1 as the
result for strtotime() indicating the function couldn't interpret the
given date.
I've been through all the date-related functions in the manual I can
think of, but I'm stumpped on this one...
---
Justin French
http://indent.com.au
--- End Message ---
--- Begin Message ---
How is the date stored, MySQL db??? if so, you can select dates out as
unix timestamps. Otherwise i would use mktime or strtotime...
Jason
Jason FB <[EMAIL PROTECTED]> wrote:
>
> Can anyone tell me how to convert a date stored in the format
> "YYYY-MM-DD" to an integer of seconds since unix epoc,
>
> then add $daysToAdd days to this value (I suppose if the integer was
> a number of seconds it would have to be $daysToAdd*60*60*24 to get
> the number of seconds to add)
>
> then convert the new value to a timestamp which I can output using the function
>
> string date ( string format [, int timestamp])
>
> I tried doing this with mktime() and couple different ways using
> strtotime() and also with strftime() but I kept getting -1 as the
> result for strtotime() indicating the function couldn't interpret the
> given date.
>
> I've been through all the date-related functions in the manual I can
> think of, but I'm stumpped on this one...
--- End Message ---
--- Begin Message ---
beware of dates before 1969.
Justin French <[EMAIL PROTECTED]> wrote:
>
> Jason,
>
> This seems to work fine for me:
>
> <?
> $daysToAdd = 5;
> $secondsToAdd = $daysToAdd * 86400;
> $dateIn = "2004-07-24";
> $dateInStamp = strtotime($dateIn);
> echo date('m/d/Y h:i:s',$dateInStamp+$secondsToAdd);
> ?>
>
> ... as does the more condensed version:
>
> <? echo date('m/d/Y h:i:s',strtotime("2004-07-24")+(5*86400)); ?>
>
> If strtotime() is returning -1, that means that it's having trouble
> converting your YYYY-MM-DD date to a timestamp. The common pitfall is
> that you've got the month and day mixed up (YYYY-DD-MM), or that you're
> not using 2 digit numbers on the day and month (and 4 digit on the
> year).
>
> If you're having trouble with strtotime(), ech out the date you're
> trying to convert, to make sure it's what you're expecting.
>
>
> It's also worth pointing out that we've made no considerations for
> timezones, daylight savings, etc.
>
> UNIX timestamps are all GMT, so if the times you're seeing are not as
> expected (and the dates you're collecting aren't GMT dates, then you'll
> need to dig a lot deeper -- it's depends how much accuracy you want.
>
> Justin French
>
> On 07/09/2004, at 1:59 PM, Jason FB wrote:
>
> > Can anyone tell me how to convert a date stored in the format
> > "YYYY-MM-DD" to an integer of seconds since unix epoc,
> >
> > then add $daysToAdd days to this value (I suppose if the integer was a
> > number of seconds it would have to be $daysToAdd*60*60*24 to get the
> > number of seconds to add)
> >
> > then convert the new value to a timestamp which I can output using the
> > function
> >
> > string date ( string format [, int timestamp])
> >
> > I tried doing this with mktime() and couple different ways using
> > strtotime() and also with strftime() but I kept getting -1 as the
> > result for strtotime() indicating the function couldn't interpret the
> > given date.
> >
> > I've been through all the date-related functions in the manual I can
> > think of, but I'm stumpped on this one...
>
> ---
> Justin French
> http://indent.com.au
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Hi all,
Please tell me how can I fetch an html document from a web page, let's say
starting from the character 1000, and get the text until the caracter 5000.
In fact, I want to use the GET or POST method, and to also send to the
server the HTTP header:
Range: bytes=1000-5000
Thanks.
Teddy
--- End Message ---
--- Begin Message ---
I've been reading for the last three days about character encodings and
such, but, have still been unable to figure out what I think should be a
simple solution.
All I want to do is take curly or "smart" quotes that have been pasted or
entered into a form field and convert those into straight quotes (") before
I store the text in my database.
It appears the data passed from the form to my PHP script is encoded as
Unicode. My version of MySQL does not support Unicode character encoding,
so, I need to convert that into Latin1 (or ISO-8859-1).
When I use iconv() to translate the data that contains curly quotes, the
string gets chopped off at the very first curly quote and the rest of the
string is lost. This is the command I am using:
$var = iconv("UTF-8", "ISO-8859-1", $var);
When I use utf8_decode(), I at least get the whole string back, but, all the
curly quotes and apostrophes are turned into ? question marks.
So, I presume there must be some way to convert those curly quotes into
straight ASCII quotes while the text is still in Unicode format, before I
run this through either iconv() or utf8_decode(). But, I've searched all
over for two days and can't figure out how to accomplish this.
I'd really appreciate someone's help with this! It's driving me nuts!!
Thanks,
Monty
--- End Message ---
--- Begin Message ---
-----Original Message-----
From: Nick Wilson [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 02, 2004 11:59 AM
Hi all,
yeah, i know, i did do quite a bit of searching but I just cant find it...
Does anyone have the regex to make sure an http address is full and without
error? like http://www.example.com
http://www.php.net/parse_url should do what you require. If all you want to
do is filter out the different parts of the url and check if they exist or
not.
[ ignoring the rather OT discussion that this thread has lead to ]
--- End Message ---