|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
[suspicious - maybe spam] php-general Digest 7 Mar 2005 04:32:36 -0000 Issue 3323
php-general-digest-help
lists.php.net
Date: Sun Mar 06 2005 - 22:32:36 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 7 Mar 2005 04:32:36 -0000 Issue 3323
Topics (messages 210098 through 210135):
[suspicious - maybe spam] Re: [PHP] 'Insulate' db connection
210098 by: Mattias Thorslund
[suspicious - maybe spam] Re: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] Re: [PHP] 'Insulate' db connection
210099 by: Andre Dubuc
Newbie question: qutoes?
210100 by: rory walsh
210102 by: James Williams
210103 by: Jochem Maas
210104 by: Matt Harnaga
210105 by: rory walsh
210106 by: Matt Harnaga
Re: How can i calculate total process time?
210101 by: James Williams
error from 4.3.10: The specified procedure could not be found.
210107 by: Javier Muniz
210125 by: Tom Rogers
Opening files....
210108 by: Vaibhav Sibal
210109 by: Guillermo Rauch
Undefined Variable Problems...
210110 by: Nick Zukin
210111 by: Jason Barnett
210114 by: Jason Barnett
210115 by: Nick Zukin
210116 by: Guillermo Rauch
Can't figure mail & post out
210112 by: Robert
210129 by: Zareef Ahmed
210133 by: Robert
210135 by: anirudh dutt
Re: Help with dates
210113 by: Jason Barnett
210117 by: Kevin
210118 by: M. Sokolewicz
210124 by: Jason Wong
210127 by: Kevin
Re: stream_set_timeout & get_headers (PHP5)
210119 by: Marek Kilimajer
Re: Document root, preferred way to find it???
210120 by: Marek Kilimajer
210121 by: Leif Gregory
210122 by: Leif Gregory
210123 by: Tom Rogers
210126 by: Marek Kilimajer
210128 by: Leif Gregory
210130 by: Leif Gregory
[suspicious - maybe spam] Re: [PHP] Re: Help with dates
210131 by: Mattias Thorslund
210134 by: Kevin
Re: which class it is?
210132 by: yangshiqi
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Since you can use fopen, I don't think open_basedir is the problem.
Read about open_basedir here: http://us3.php.net/features.safe-mode
Maybe the path that you use in the include is wrong?
/Mattias
Andre Dubuc wrote:
>Hi,
>
>I am trying to 'insulate' my database connection from prying eyes by moving
>the db connection code to a directory above docroot and then calling it by an
>include. However, my IP has an open_basedir restriction in effect that
>defeats what I'm trying to do.
>
>Perhaps I'm unclear what what the open_basedir does, and perhaps IP is
>protecting me from an even worse security risk. However, I can call, using
>fopen, many counter code pages that reside in the directory above docroot -
>so I'm confused here. Perhaps it's the use of include - is there another way
>to do this?
>
>
>*******************************************************************************************
>
>The code so far:
>
>On any page that needs a db connection (in docroot path):
><?php
>....
>include("db-conn.php");
>...
>?>
>
>Db code page (located in directory above docroot):
><?php
>$db = pg_connect("dbname=site user=confused password=toughone");
>?>
>
>Tia,
>Andre
>
>
>
--
More views at http://www.thorslund.us
attached mail follows:
On Sunday 06 March 2005 11:47 am, Mattias Thorslund wrote:
> Since you can use fopen, I don't think open_basedir is the problem.
> Read about open_basedir here: http://us3.php.net/features.safe-mode
>
> Maybe the path that you use in the include is wrong?
>
> /Mattias
>
> Andre Dubuc wrote:
> >Hi,
> >
> >I am trying to 'insulate' my database connection from prying eyes by
> > moving the db connection code to a directory above docroot and then
> > calling it by an include. However, my IP has an open_basedir restriction
> > in effect that defeats what I'm trying to do.
> >
> >Perhaps I'm unclear what what the open_basedir does, and perhaps IP is
> >protecting me from an even worse security risk. However, I can call, using
> >fopen, many counter code pages that reside in the directory above docroot
> > - so I'm confused here. Perhaps it's the use of include - is there
> > another way to do this?
> >
> >
> >**************************************************************************
> >*****************
> >
> >The code so far:
> >
> >On any page that needs a db connection (in docroot path):
> ><?php
> >....
> >include("db-conn.php");
> >...
> >?>
> >
> >Db code page (located in directory above docroot):
> ><?php
> >$db = pg_connect("dbname=site user=confused password=toughone");
> >?>
> >
> >Tia,
> >Andre
>
> --
> More views at http://www.thorslund.us
Thanks Mattias,
I should have read my code a bit better -- forgot to set the absolute path for
the directory above docroot.
Works great now!
Regards,
Andre
attached mail follows:
Can anyone tell me if there is a difference between double quotes and
single quotes? Cheers,
Rory.
attached mail follows:
rory walsh wrote:
> Can anyone tell me if there is a difference between double quotes and
> single quotes? Cheers,
> Rory.
What's up Rory... actually there *is* a difference. Double quotes are
parsed by the php engine, meaning it goes through and finds variables
and stuff which it can parse, ex. print("Here is a variable:
$variable!"); will print "Here is a variable: The value of the variable!"
Single quotes are not parsed by the php engine, so the same code with
single quotes (print('Here is a variable: $variable!'); will return
"Here is a variable: $variable!" I hope that answeres your question
attached mail follows:
rory walsh wrote:
> Can anyone tell me if there is a difference between double quotes and
> single quotes? Cheers,
> Rory.
>
apart from the visual difference :-)... yes.
with double quotes string interpolation is done. whats that?
run this code to see the difference:
<?php
$varA = 123;
echo ' this is $varA';
echo " this is $varA";
?>
basically use double quotes only when you need it... needing it includes times
when using double quotes saves you having to escape _lots_ of single quotes,
i.e. when it makes code easier to read (JMHO) e.g.:
$str = '\'this\' \'is\' a \'stupidly\' \'quoted\' string';
$str = "'this' 'is' a 'stupidly' 'quoted' string";
---
so now you have at least 2 things to google:
1. string interpolation (+ PHP)
2. string/char escaping (+ PHP)
have fun :-)
attached mail follows:
Double quotes expand variables, that is, if $a = 2, then
echo "The value is $a2";
will print "The value is 2".
Single quotes return strings literally. So, echo 'The value is $a2'
would print The value is $a2
Cheers
rory walsh wrote:
> Can anyone tell me if there is a difference between double quotes and
> single quotes? Cheers,
> Rory.
>
attached mail follows:
Thanks guys, that clears up a lot! Cheers, actually I have to say
goodbye to broadband for a while so I hope that I can make it on my own!
That's why I have been asking all these obvious little questions! Cheers,
Rory.
Jochem Maas wrote:
> rory walsh wrote:
>
>> Can anyone tell me if there is a difference between double quotes and
>> single quotes? Cheers,
>> Rory.
>>
>
> apart from the visual difference :-)... yes.
>
> with double quotes string interpolation is done. whats that?
> run this code to see the difference:
>
> <?php
>
> $varA = 123;
>
> echo ' this is $varA';
> echo " this is $varA";
>
> ?>
>
> basically use double quotes only when you need it... needing it includes
> times
> when using double quotes saves you having to escape _lots_ of single
> quotes,
> i.e. when it makes code easier to read (JMHO) e.g.:
>
> $str = '\'this\' \'is\' a \'stupidly\' \'quoted\' string';
> $str = "'this' 'is' a 'stupidly' 'quoted' string";
>
> ---
>
> so now you have at least 2 things to google:
>
> 1. string interpolation (+ PHP)
> 2. string/char escaping (+ PHP)
>
>
> have fun :-)
attached mail follows:
You might want to check this out as well:
http://www.zend.com/zend/tut/using-strings.php
rory walsh wrote:
> Can anyone tell me if there is a difference between double quotes and
> single quotes? Cheers,
> Rory.
>
attached mail follows:
Eli wrote:
> On top use this:
> <?php
> $mtime = explode(" ",microtime());
> $starttime = $mtime[1] + $mtime[0];
> ?>
>
> On the end use this:
> <?php
> $mtime = explode(" ",microtime());
> $endtime = $mtime[1] + $mtime[0];
> echo "\n\n\n<hr><b>".round($endtime-$starttime,3)." sec</b>";
> ?>
If you want a nice object oriented solution that's easy to use over and
over again which does pretty much the same thing, give this class a whirl.
class page_gen {
//
// PRIVATE - DO NOT MODIFY
//
var $cls_start_time;
var $cls_stop_time;
var $cls_gen_time;
//
// FIGURE OUT THE TIME AT THE BEGINNING OF THE PAGE
//
function start() {
$microstart = explode(' ',microtime());
$this->cls_start_time = $microstart[0] + $microstart[1];
}
//
// FIGURE OUT THE TIME AT THE END OF THE PAGE
//
function stop() {
$microstop = explode(' ',microtime());
$this->cls_stop_time = $microstop[0] + $microstop[1];
}
//
// CALCULATE THE DIFFERENCE BETWEEN THE BEGINNNG AND THE END AND COLOR
CODE THE RESULT
//
function gen() {
$this->cls_gen_time = round($this->cls_stop_time -
$this->cls_start_time,5);
return $this->cls_gen_time;
}
}
then, on the page you want to time, just put at the top:
require('class.pagegen.php') // OR WHATEVE YOU NAMED IT
$pagegen = new page_gen();
$pagegen->start(); // START TIMING
then at the end...
$pagegen->stop(); // STOP TIMING
$pagegen->gen(); // RETURN GENERATION TIME
attached mail follows:
Forgive me if this has been answered before, but all I was able to find
was a "bogus" bug report on this issue that did not contain any useful
information. When installing php 4.3.10 on a Win2k3 machine I'm getting
the "The specified procedure could not be found." Error from any php
page I attempt to execute. I don't have any extensions enabled and this
is a completely vanilla install of 4.3.10. Followed the installation
procedure to a tee. It works with 4.3.6 but 4.3.6 has other
show-stopper bugs. It looks like other people are having this problem
as well, though it doesn't appear (at least, not to Google) that anyone
has been able to solve it.
Any information is greatly appreciated, including links to any FAQs that
might be helpful since I haven't found any that contain *any* useful
information on this problem.
Thanks,
-Javier
attached mail follows:
Hi,
Monday, March 7, 2005, 4:55:01 AM, you wrote:
JM> Forgive me if this has been answered before, but all I was able to find
JM> was a "bogus" bug report on this issue that did not contain any useful
JM> information. When installing php 4.3.10 on a Win2k3 machine I'm getting
JM> the "The specified procedure could not be found." Error from any php
JM> page I attempt to execute. I don't have any extensions enabled and this
JM> is a completely vanilla install of 4.3.10. Followed the installation
JM> procedure to a tee. It works with 4.3.6 but 4.3.6 has other
JM> show-stopper bugs. It looks like other people are having this problem
JM> as well, though it doesn't appear (at least, not to Google) that anyone
JM> has been able to solve it.
JM> Any information is greatly appreciated, including links to any FAQs that
JM> might be helpful since I haven't found any that contain *any* useful
JM> information on this problem.
JM> Thanks,
JM> -Javier
JM> --
JM> PHP General Mailing List (http://www.php.net/)
JM> To unsubscribe, visit: http://www.php.net/unsub.php
Make sure php4ts.dll is where windows can find it, put it in the same
directory as apache or in the windows directory.
(If your not using apache .. you should be :)
--
regards,
Tom
attached mail follows:
Hello,
I want to open files in a directory other than the Document root via
HTTP on the client machine. How do i do it ?
For example I have .JPG files in a directory /toallocate on my Server
running FC2, Apache2, Mysql, PHP5. I allocated certain .JPG files to
some users and moved them to a directory called /allocated and logged
the absolute path in a Mysql Table with the user name. Now we know the
username and the files allocated to him and their path. When the user
logs into his account, he should see the file allocated to him and
they should be clickable links so that when he clicks them they open
in the required software. I tried just providing links to their
absolute path but then it doesnt work because Apache looks for them
relative to the Document Root. Please some one help me in this
concern, I will wait for a quick reply.
Also, Is there a way that I can force the .JPG files to open in a
particular software ?
thanks in advance
Vaibhav Sibal
attached mail follows:
> Hello,
> I want to open files in a directory other than the Document root via
> HTTP on the client machine. How do i do it ?
Yes, it's possible
Just supose you have the images under /var/images/. This won't be
acceded by apache since it's out of documentroot.
You can set up some alias to /var/images
For example
alias /images/ /var/images/
The problem is, that most servers don't let users access
directories outside the DocumentRoot of the customers VirtualHost.
Also, if you can read that directory, you can create a path images in
your documentroot, and create a .htaccess file like this:
ErrorDocument 404 image.php
In image.php you catch the referrer with $_SERVER['http_referrer'] and
display the image sending the header img/jpeg
> Also, Is there a way that I can force the .JPG files to open in a
> particular software ?
No.
Best,
Guillermo Rauch.
attached mail follows:
Sorry if this has been covered before. I just joined this list.
My host just upgraded PHP to 4.3.10 from 4.1.2. A couple of my clients are
using systems such as PHP-NUKE or various message boards. I hadn't been
paying attention to my log files, but all of a sudden they got huge,
especially the error logs. They're filled mostly with undefined variable
errors, but also a couple others, for example:
[Sun Mar 6 00:35:50 2005] [error] PHP Notice: Undefined variable:
forum_admin in /home/scott/XXXX.org/html/mainfile.php on line 79
[Sun Mar 6 00:35:51 2005] [error] PHP Notice: Undefined offset: 1 in
/home/scott/XXXX.org/html/mainfile.php on line 486
[Sun Mar 6 00:35:51 2005] [error] PHP Notice: Undefined index: 2 in
/home/scott/XXXX.org/html/mainfile.php on line 216
line 79, if ($forum_admin == 1) {
line 486, $uname = $cookie[1];
line 216, $pwd = "$user[2]";
Line 79 is not part of a function or class. It is the first reference to
$forum_admin in the script. The other two are within functions and the
first call within those functions. What's being assigned to both of them
are either in the function call itself or globals.
I do have globals turned on.
Should I worry about any of this? The pages seem to be working fine? Is
this going to slow things down? Should I just turn off the logging of such
errors, if I can?
Thanks for any help. My log files are in the gigabytes with 90% of that
over the last month.
Nick
attached mail follows:
Nick Zukin wrote:
...
> line 79, if ($forum_admin == 1) {
> line 486, $uname = $cookie[1];
> line 216, $pwd = "$user[2]";
>
> Line 79 is not part of a function or class. It is the first reference to
> $forum_admin in the script. The other two are within functions and the
> first call within those functions. What's being assigned to both of them
> are either in the function call itself or globals.
>
> I do have globals turned on.
you mean register_globals? Turn it off unless this breaks things in a
major way... even then you should consider recoding if that's feasible.
>
> Should I worry about any of this? The pages seem to be working fine? Is
> this going to slow things down? Should I just turn off the logging of such
> errors, if I can?
uninitialized variables + register_globals is usually a bad
combination... especially when we're talking about a varaible like
$forum_admin.
http://XXXX.com/forums/post.php?forum_admin=1&user=whoever
In a simple case the above can happen and someone gains admin rights...
in worse cases you end up with SQL code dropping databases...
>
> Thanks for any help. My log files are in the gigabytes with 90% of that
> over the last month.
ignoring the E_NOTICE errors is a good idea on a production site anyway.
That being said... I would try to fix the code so that the notice
doesn't get produced in the first place.
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins
attached mail follows:
Please keep responses on the mailing list / newsgroup...
Nick Zukin wrote:
> Thanks for the quick response.
>
> Yes, had to turn register_globals on because it broke things. Many of
these
> sites aren't mine and I have no idea what's involved in trying to fix them
> all. If you saw a full 1.2 GB error log (per domain) that built up to
that
> size in less than a month, though, you'd see that it would take a lot of
> re-coding.
>
> Assuming I can fix the pages that break when register_globals turned off,
> how big a deal are the undefined variables?
If you can manage to turn register_globals off that would be the most
important thing. Undefined variables aren't necessarily bad, but they
can lead to obscure bugs (for example, if a variable is set inside of an
included file instead of a main script where you thought it was unset).
attached mail follows:
Sorry, as I said, I just joined and I didn't notice that it's set to
reply-to the original sender rather than the list. A bit annoying.
Thanks again.
Nick
-----Original Message-----
From: Jason Barnett [mailto:jason.barnett
telesuite.com]
Sent: Sunday, March 06, 2005 1:10 PM
To: php-general
lists.php.net
Subject: [PHP] Re: Undefined Variable Problems...
Please keep responses on the mailing list / newsgroup...
Nick Zukin wrote:
> Thanks for the quick response.
>
> Yes, had to turn register_globals on because it broke things. Many of
these
> sites aren't mine and I have no idea what's involved in trying to fix them
> all. If you saw a full 1.2 GB error log (per domain) that built up to
that
> size in less than a month, though, you'd see that it would take a lot of
> re-coding.
>
> Assuming I can fix the pages that break when register_globals turned off,
> how big a deal are the undefined variables?
If you can manage to turn register_globals off that would be the most
important thing. Undefined variables aren't necessarily bad, but they
can lead to obscure bugs (for example, if a variable is set inside of an
included file instead of a main script where you thought it was unset).
attached mail follows:
Also, since this is a very massive list with high traffic, quote when necessary.
For example, consider this message:
> Can i draw something ?
Yes you can
> Thanks
You're welcome
In that case quote is quite useful :D
attached mail follows:
Hi -
I am very new to php and can't get this to work right. It keeps telling me
there is no send header. I have tried multiple variations? Any ideas? I
am simply trying to query the database and send out an email to each person
in my database.
Thanks,
Robert
$query = "SELECT first_name, email FROM offer";
$result =
mysql_query ($query);
if ($result) {
echo 'Mailing List...';
while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {
$fname = "$row[0]";
$body = "<html><body>Hi {$_POST['fname']},</body></html>";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: ";
$sendto = "$row[1]";
echo "<br>Row one output = $sendto<br>";
mail ($_POST['sendto'],'Testing', $body, $headers);
echo "Sent to $row[1]<br>";}
mysql_free_result ($result);
attached mail follows:
Hi Robert,
Please take a look at php manual and try to know something about
$_POST, $_GET etc.
Your code is full of errors.
On Sun, 6 Mar 2005 15:33:30 -0500, Robert <sigler
cox.net> wrote:
> Hi -
>
> I am very new to php and can't get this to work right. It keeps telling me
> there is no send header. I have tried multiple variations? Any ideas? I
> am simply trying to query the database and send out an email to each person
> in my database.
>
> Thanks,
> Robert
>
> $query = "SELECT first_name, email FROM offer";
> $result =
mysql_query ($query);
>
> if ($result) {
> echo 'Mailing List...';
> while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {
mysql_fetch_row can be an alternative.
> $fname = "$row[0]";
> $body = "<html><body>Hi {$_POST['fname']},</body></html>";
You are sendting the email to users who are in the database, but
greeting them with $_POST['fname']
> $headers = "MIME-Version: 1.0\r\n";
> $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
> $headers .= "From: ";
From is not set, value is not here.
> $sendto = "$row[1]";
> echo "<br>Row one output = $sendto<br>";
> mail ($_POST['sendto'],'Testing', $body, $headers);
Again you are sending the mail to same person very time.
> echo "Sent to $row[1]<br>";}
Again problem.
> mysql_free_result ($result);
>
> --
PHP manual is good thing to start .
http://www.php.net
zareef ahmed
--
Zareef Ahmed :: A PHP Developer in India ( Delhi )
Homepage :: http://www.zareef.net
attached mail follows:
Thanks, I fixed the problem and it's working great. Didn't need the $_POST
in the email and needed double quotes around the sender header variable.
"Zareef Ahmed" <zareef.ahmed
gmail.com> wrote in message
news:ad1635c3050306190766154972
mail.gmail.com...
> Hi Robert,
>
> Please take a look at php manual and try to know something about
> $_POST, $_GET etc.
> Your code is full of errors.
>
>
> On Sun, 6 Mar 2005 15:33:30 -0500, Robert <sigler
cox.net> wrote:
>> Hi -
>>
>> I am very new to php and can't get this to work right. It keeps telling
>> me
>> there is no send header. I have tried multiple variations? Any ideas?
>> I
>> am simply trying to query the database and send out an email to each
>> person
>> in my database.
>>
>> Thanks,
>> Robert
>>
>> $query = "SELECT first_name, email FROM offer";
>> $result =
mysql_query ($query);
>>
>> if ($result) {
>> echo 'Mailing List...';
>> while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {
> mysql_fetch_row can be an alternative.
>> $fname = "$row[0]";
>> $body = "<html><body>Hi {$_POST['fname']},</body></html>";
> You are sendting the email to users who are in the database, but
> greeting them with $_POST['fname']
>> $headers = "MIME-Version: 1.0\r\n";
>> $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
>> $headers .= "From: ";
> From is not set, value is not here.
>
>> $sendto = "$row[1]";
>> echo "<br>Row one output = $sendto<br>";
>> mail ($_POST['sendto'],'Testing', $body, $headers);
> Again you are sending the mail to same person very time.
>
>> echo "Sent to $row[1]<br>";}
> Again problem.
>> mysql_free_result ($result);
>>
>> --
>
> PHP manual is good thing to start .
> http://www.php.net
>
>
> zareef ahmed
>
> --
> Zareef Ahmed :: A PHP Developer in India ( Delhi )
> Homepage :: http://www.zareef.net
attached mail follows:
On Mon, 7 Mar 2005 08:37:52 +0530, Zareef Ahmed <zareef.ahmed
gmail.com> wrote:
> Hi Robert,
>
> Please take a look at php manual and try to know something about
> $_POST, $_GET etc.
> Your code is full of errors.
>
>
> On Sun, 6 Mar 2005 15:33:30 -0500, Robert <sigler
cox.net> wrote:
> > $sendto = "$row[1]";
> > echo "<br>Row one output = $sendto<br>";
> > mail ($_POST['sendto'],'Testing', $body, $headers);
> Again you are sending the mail to same person very time.
no, that part is correct.
while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {
...
mail ($_POST['sendto'],'Testing', $body, $headers);
echo "Sent to $row[1]<br>";} // <--*
mysql_free_result ($result);
* the values are retrieved and used in the loop, the mail IS going to
the right person.
> > $headers = "MIME-Version: 1.0\r\n";
> > $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
> > $headers .= "From: ";
> From is not set, value is not here.
this is the part that's causing the problem. u can leave it empty and
let the system put the admin's email id. don't leave it incomplete
though.
i agree that there are logical errors regarding the data he's used,
but that's not why it didn't work.
Robert: u may want to print/echo all the vars for mail() before using
it, helps to debug. check all $POST vars too. this is how i generally
set the headers:
$headers = "From: $fname <$from_email>\n"."Return-Path: $ret"."\n";
i use return path so that bounce messages/delivery failures go to another id.
if u want to add the X-Mailer header:
$headers.= 'X-Mailer: PHP/' . phpversion()."\n";
(note ^^^ the dot)
if still doesn't work, replace ur \r\n with \n. check manual page for details.
considering that u're possibly mass mailing...
http://us2.php.net/manual/en/function.mail.php
[quote]
Note: It is worth noting that the mail() function is not suitable
for larger volumes of email in a loop. This function opens and closes
an SMTP socket for each email, which is not very efficient.
For the sending of large amounts of email, see the PEAR::Mail, and
PEAR::Mail_Queue packages.
[/quote]
u could also open a pipe to the mail program...
http://www.devarticles.com/c/a/PHP/Getting-Intimate-With-PHPs-Mail-Function/2/
hth
--
]#
Anirudh Dutt
...pilot of the storm who leaves no trace
like thoughts inside a dream
attached mail follows:
Kevin wrote:
> Hi there,
>
> I seem to be in a bit of a pickle.
>
> Right now I'm working on a script that would calculate dates from one
> calendar to another. The normal calendar we use and a newly invented one.
>
> In order to do that I need to find the exact days since the year 0 BC/AD.
Do you really need this? I.e. is this a linear / quadratic / etc.
fucntion... one where you can start with one known value (Jan. 1 1970)
and build all dates relative to this date instead?
If you just want days since 0 BC / AD you can recreate all of the PHP
date functions yourself... but use a "daystamp" from 0 BC/AD instead of
a "timestamp" from 1970. Or fudge things a little and use 365.25 days
per year...
--
Teach a man to fish...
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY |
http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins
attached mail follows:
Hey mr. Barnett,
Unfortunately, I do need an accurate calculation, because the calculation
will run 2 ways. From and to our calendar.
I have no problem creating my own datefunctions if I have some idea on how
PHP handles the current ones as a template. Then I can figure out the rest
for myself.
Would you know where I might find more info regarding this in stead?
Yours,
Kevin
Well
"Jason Barnett" <jason.barnett
telesuite.com> wrote in message
news:20050306204451.52181.qmail
lists.php.net...
attached mail follows:
well, you can simply use the unix timestamp, since the amount of days /
seconds since 0 AD/BC will be a constant (it won't change, trust me),
you can simply add it to that, and add a wrapper function to php's
time(). You'll be working with VERY big numbers in that case, so you can
also do it the other way around; store the amount of DAYS since 0 AD/BC
till Jan 1st 1970, add time()/86400, and you'll have the amount of days
since 0 AD/BC in an integer (or float, depending on how many days that
really are).
You'll just need to find that constant somewhere :)
Kevin wrote:
> Hey mr. Barnett,
>
>
> Unfortunately, I do need an accurate calculation, because the calculation
> will run 2 ways. From and to our calendar.
>
> I have no problem creating my own datefunctions if I have some idea on how
> PHP handles the current ones as a template. Then I can figure out the rest
> for myself.
>
> Would you know where I might find more info regarding this in stead?
>
> Yours,
>
> Kevin
> Well
> "Jason Barnett" <jason.barnett
telesuite.com> wrote in message
> news:20050306204451.52181.qmail
lists.php.net...
attached mail follows:
On Sunday 06 March 2005 22:11, Kevin wrote:
> Right now I'm working on a script that would calculate dates from one
> calendar to another. The normal calendar we use and a newly invented
> one.
>
> In order to do that I need to find the exact days since the year 0
> BC/AD. However, the functions php provides only allow up to the unix
> epoch.
manual > Calendar Functions
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
New Year Resolution: Ignore top posted posts
attached mail follows:
Thank you.. duh...
quite useful... not...
Where do you think I check first?
Yours,
Kevin
"Jason Wong" <php-general
gremlins.biz> wrote in message
news:200503070931.35992.php-general
gremlins.biz...
> On Sunday 06 March 2005 22:11, Kevin wrote:
>
> > Right now I'm working on a script that would calculate dates from one
> > calendar to another. The normal calendar we use and a newly invented
> > one.
> >
> > In order to do that I need to find the exact days since the year 0
> > BC/AD. However, the functions php provides only allow up to the unix
> > epoch.
>
> manual > Calendar Functions
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> ------------------------------------------
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> ------------------------------------------
> New Year Resolution: Ignore top posted posts
attached mail follows:
Chris wrote:
> I'm requesting some remote files to cache on my own server and
> performing a get_headers() first to find out the file type, since I
> don't always know what it is. I've discovered some timeout problems
> with the remote server sometimes and my own script would end up with a
> fatal error because the script took longer to process than 30 seconds.
> Being able to set a timeout would allow me to gracefully recover,
> rather than displaying an ugly error.
>
> I know I can use stream_set_timeout() on fsockopen() if I want to write
> my own get_headers function for < PHP5... but is it possible to set
> the timeout on PHP5's built in get_headers()?
>
ini_set('default_socket_timeout', .... );
attached mail follows:
dirname(__FILE__)
and then get rid of the subpath where the check is made ('/include' for
example)
Leif Gregory wrote:
> Hello Richard,
>
> Friday, March 4, 2005, 11:41:29 AM, you wrote:
> R> http://php.net/set_include_path
>
>
> Ok... Maybe I should put all this together in one e-mail so that all
> the issues can be looked at...
>
> The problem:
>
> Finding a reliable method to include files, keeping in mind the
> following:
>
> 1. The site could be moved to a completely new host which could be of
> a different OS, and/or web server software, and could either be the
> one and only site on that host (dedicated server), or could be a
> virtual host (shared server).
>
> 2. The site could remain on the same host but is required to move to a
> new path. i.e. from htdocs/mysite to htdocs/mynewsite
>
> 3. The web host may or may not allow the use of .htaccess (Some Sambar
> configurations for example).
>
> 4. The method used would not affect any other virtual hosts. Meaning,
> the method used must be independent for each virtual host.
>
> 5. The method used would not utilize a folder where other virtual
> hosts could gain access to the included file (php.ini
> include_path).
>
> 6. The method (and this is the important one IMHO) would not require
> editing "x" number of pages in a site to change some static path
> that was set on each page.
>
> 7. The method used would not require a dedicated "include" file in
> every single folder of the site that could be included because it's
> in the same folder as the page needing it, because those would all
> have to be edited to fix the path if condition 1 or 2 was met.
>
>
> Previously proposed solutions:
>
> 1. PHP.ini include_path
> This affects all virtual hosts and would require administrative
> overhead to prevent the owners of each virtual host from gaining
> access to other virtual host's include files. I suppose you could
> set it to something like: include_path="/php/includes" and have a
> separate subfolder under that for each virtual host. But since that
> folder is outside the web folder, there would have to be some
> mechanism (additional FTP account) for each person to gain access
> to their own include folder to add/edit/delete files in that
> folder. Then if the site is moved and they aren't using an
> include_path, you have to fix all your pages.
>
> 2. set_include_path
> This means if your site moves, you must edit "x" number of pages in
> the site to correct the path.
>
> 3. An include file in every directory to set the include path.
> You'd have to edit "x" number of these files to correct the path if
> the site moves. This would be much less work than the previous
> item, but it could be a lot of work on very big sites where you
> don't have shell accounts to do some scripted find/replace with.
>
> 4. Use the full URL to the file in the include statement.
> See item 2.
>
> 5. $_SERVER["DOCUMENT_ROOT"] and $_SERVER['PATH_TRANSLATED']
> Not always available or incorrect see
> mid:1778675148.20050303102623
kwikin.com
>
>
> I may have missed some things, and if I've misunderstood how something
> should work, then please let me know. I'm just looking for a more or
> less foolproof method which doesn't require fixing code if the site is
> moved. The closest I can come to it is the function I wrote but is a
> pain because you have to put it in every page where you need an
> included file. Granted, you only have to do it once, and then you're
> done and a site move wont affect it, but it's still kludgy if you ask
> me.
>
> *******************
> <?php
> function dynRoot()
> {
> $levels = substr_count($_SERVER['PHP_SELF'],"/");
>
> for ($i=0; $i < $levels - 1; $i++)
> {
> $relativeDir .= "../";
> }
>
> return $relativeDir;
> }
> ?>
> *******************
>
> and then calling it as such:
>
> include(dynRoot() . 'includes/db_connect.php');
>
>
> I've had to move client sites between Sambar, Apache, IIS and Windows,
> Linux. Most times I've had to go in and fix include paths because one
> of the above solutions were originally used and wasn't viable on the
> new host.
>
> Thanks.
>
>
attached mail follows:
Hello Tom,
Friday, March 4, 2005, 9:13:41 PM, you wrote:
TR> This will set the include path just before the document root:
Hmmmm. Not quite what I'm looking for. I set up some test folders and
files on a development machine to play with your script.
Here's how it was laid out:
The document root for the test site:
"c:\sambar\docs\test"
A subfolder of the doc root
"folder1"
A subfolder of the above folder1
"folder2"
Placing a file called test.php (containing your script) in all three
places (doc root, folder1, folder1/folder2) gives you the following
respectively.
Root: c:\sambar\docs\test\test.php
Document root: c:\sambar\docs\test\test.php
Base: test.php
Include: c:\cambar\docs\test\include
OS: winnt
Include: c:\cambar\docs\test\include;.;C:\php5\pear
Ultimately, this would be the correct folder I would want, but see the
below two tests.
Root: c:\sambar\docs\test\folder1\test.php
Document root: c:\sambar\docs\test\folder1\test.php
Base: test.php
Include: c:\sambar\docs\test\folder1\include
OS: winnt
Include: c:\sambar\docs\test\folder1\include;.;C:\php5\pear
Root: c:\sambar\docs\test\folder1\folder2\test.php
Document root: c:\sambar\docs\test\folder1\folder2\test.php
Base: test.php
Include: c:\sambar\docs\test\folder1\folder2\include
OS: winnt
Include: c:\sambar\docs\test\folder1\folder2\include;.;C:\php5\pear
I don't see where your script is giving me the include folder I want.
Thanks though.
Cheers,
Leif Gregory
--
TB Lists Moderator (and fellow registered end-user)
PCWize Editor / ICQ 216395 / PGP Key ID 0x7CD4926F
Web Site <http://www.PCWize.com>
attached mail follows:
Hello Marek,
Sunday, March 6, 2005, 4:23:51 PM, you wrote:
MK> dirname(__FILE__)
MK> and then get rid of the subpath where the check is made
MK> ('/include' for example)
I'm not sure I'm completely following you. Let's say I had the
following:
Site root"
"c:\apache\htdocs\test"
A subfolder of site root
"folder1"
A subfolder of the above folder1
"folder2"
If I call dirname(__FILE__) from a page in each folder I'll get the
following respectively:
"c:\apache\htdocs\test"
"c:\apache\htdocs\test\folder1"
"c:\apache\htdocs\test\folder1\folder2"
I don't see where that tells me where the include folder would be.
Cheers,
Leif Gregory
--
TB Lists Moderator (and fellow registered end-user)
PCWize Editor / ICQ 216395 / PGP Key ID 0x7CD4926F
Web Site <http://www.PCWize.com>
attached mail follows:
Hi Leif,
Monday, March 7, 2005, 10:03:48 AM, you wrote:
LG> Hello Tom,
LG> Friday, March 4, 2005, 9:13:41 PM, you wrote:
TR>> This will set the include path just before the document root:
LG> Hmmmm. Not quite what I'm looking for. I set up some test folders and
LG> files on a development machine to play with your script.
LG> Here's how it was laid out:
LG> The document root for the test site:
LG> "c:\sambar\docs\test"
LG> A subfolder of the doc root
LG> "folder1"
LG> A subfolder of the above folder1
LG> "folder2"
LG> Placing a file called test.php (containing your script) in all three
LG> places (doc root, folder1, folder1/folder2) gives you the following
LG> respectively.
LG> Root: c:\sambar\docs\test\test.php
LG> Document root: c:\sambar\docs\test\test.php <<<this is wrong
LG> Base: test.php
LG> Include: c:\cambar\docs\test\include
LG> OS: winnt
LG> Include: c:\cambar\docs\test\include;.;C:\php5\pear
Try running this one:
<?php
if(isset($_SERVER["SCRIPT_FILENAME"])){
$file_name = $_SERVER['SCRIPT_FILENAME'];
echo "File name: $file_name<br>";
$script = $_SERVER['SCRIPT_NAME'];
echo "Script: $script<br>";
$document_root = str_replace($script,'',$file_name);
echo "Document root: $document_root<br>";
$base = basename($document_root);
echo "Base: $base<br>";
$include = str_replace($base,'include',$document_root);
echo "Include: $include<br>";
$os = strtolower(PHP_OS);
echo "OS: $os<br>";
$lk = ':';
$org_include = ini_get("include_path");
if(preg_match('/^win/i',$os)) $lk = ';';
ini_set("include_path",$include.$lk.$org_include);
echo "Include: ".ini_get("include_path")."<br>";
}
and let me see what it prints
--
regards,
Tom
attached mail follows:
Leif Gregory wrote:
> I'm not sure I'm completely following you. Let's say I had the
> following:
>
> Site root"
> "c:\apache\htdocs\test"
>
> A subfolder of site root
> "folder1"
>
> A subfolder of the above folder1
> "folder2"
>
> If I call dirname(__FILE__) from a page in each folder I'll get the
> following respectively:
>
> "c:\apache\htdocs\test"
> "c:\apache\htdocs\test\folder1"
> "c:\apache\htdocs\test\folder1\folder2"
>
> I don't see where that tells me where the include folder would be.
If you know how the files are layed out in your application, you do.
attached mail follows:
Hello Marek,
Sunday, March 6, 2005, 7:08:24 PM, you wrote:
>> I don't see where that tells me where the include folder would be.
MK> If you know how the files are layed out in your application, you do.
No... You missed the point of this whole thread which was explained in
point 1 and point 2 of the "Problem" section.
Restated in different words is how do you write some code which is
dynamic enough to withstand reorganization of folders either on the
same host, a different host (maybe with a different OS too), or a
mixture of any.
In HTML, a css declaration as follows:
<link rel="stylesheet" type="text/css" title="Site CSS" href="includes/site.css" />
works regardless of where the page is, where it's moved to, and
regardless of how many folders down it is as long as there is indeed a
folder off the site root called "includes" and as long as there is a
file in that folder called "site.css".
How do we mimic that capability in PHP so pages don't have to be
re-written if point 1 or point 2 of the "Problem" are met?
Cheers,
Leif Gregory
--
TB Lists Moderator (and fellow registered end-user)
PCWize Editor / ICQ 216395 / PGP Key ID 0x7CD4926F
Web Site <http://www.PCWize.com>
attached mail follows:
Hello Tom,
Sunday, March 6, 2005, 6:18:54 PM, you wrote:
TR> and let me see what it prints
Still not quite there.
Site root
**************
File name: C:\Sambar\docs\test\test.php
Script: /test.php
Document root: C:\Sambar\docs\test\test.php
Base: test.php
Include: C:\Sambar\docs\test\include
OS: winnt
Include: C:\Sambar\docs\test\include;.;C:\php5\pear
**************
Site root/folder1
***************
File name: C:\Sambar\docs\test\folder1\test.php
Script: /folder1/test.php
Document root: C:\Sambar\docs\test\folder1\test.php
Base: test.php
Include: C:\Sambar\docs\test\folder1\include
OS: winnt
Include: C:\Sambar\docs\test\folder1\include;.;C:\php5\pear
***************
Site root/folder1/folder2
***************
File name: C:\Sambar\docs\test\folder1\folder2\test.php
Script: /folder1/folder2/test.php
Document root: C:\Sambar\docs\test\folder1\folder2\test.php
Base: test.php
Include: C:\Sambar\docs\test\folder1\folder2\include
OS: winnt
Include: C:\Sambar\docs\test\folder1\folder2\include;.;C:\php5\pear
***************
Thanks.
Cheers,
Leif Gregory
--
TB Lists Moderator (and fellow registered end-user)
PCWize Editor / ICQ 216395 / PGP Key ID 0x7CD4926F
Web Site <http://www.PCWize.com>
attached mail follows:
M. Sokolewicz wrote:
> well, you can simply use the unix timestamp, since the amount of days
> / seconds since 0 AD/BC will be a constant (it won't change, trust
> me), you can simply add it to that, and add a wrapper function to
> php's time(). You'll be working with VERY big numbers in that case, so
> you can also do it the other way around; store the amount of DAYS
> since 0 AD/BC till Jan 1st 1970, add time()/86400, and you'll have the
> amount of days since 0 AD/BC in an integer (or float, depending on how
> many days that really are).
>
> You'll just need to find that constant somewhere :)
>
Can't be too hard to calculate it:
1970 * 365 + 1 day for each leap year. Note the rules for leap year, of
course.
/Mattias
--
More views at http://www.thorslund.us
attached mail follows:
Greetings Mr Mattias,
I wish it was so simple. Because the dates that may need calculating can be
before 1970.
THis function I have.. and it's semi-working, but I've noticed
irregularities during the conversion.
Thanks for your suggestion!!
Yours,
Kevin
"Mattias Thorslund" <mattias
inreach.com> wrote in message
news:422BCBDA.1090309
inreach.com...
> M. Sokolewicz wrote:
>
> > well, you can simply use the unix timestamp, since the amount of days
> > / seconds since 0 AD/BC will be a constant (it won't change, trust
> > me), you can simply add it to that, and add a wrapper function to
> > php's time(). You'll be working with VERY big numbers in that case, so
> > you can also do it the other way around; store the amount of DAYS
> > since 0 AD/BC till Jan 1st 1970, add time()/86400, and you'll have the
> > amount of days since 0 AD/BC in an integer (or float, depending on how
> > many days that really are).
> >
> > You'll just need to find that constant somewhere :)
> >
>
> Can't be too hard to calculate it:
>
> 1970 * 365 + 1 day for each leap year. Note the rules for leap year, of
> course.
>
> /Mattias
>
> --
> More views at http://www.thorslund.us
attached mail follows:
Sorry for that all my friends, I just came from a vocation during the
weekend, so I can't read your threads. Thanks for all your help.
The debug_backtrace() is powerful to debug, but when I construct my classes
with simpleTest or other opensource applications, it contains lots of info
that I don't concern on in my application. So I decide to write or find
something a little bit simpler.
I just want to trace my application with the debughelper, when I want to see
what happened in it. Then I can get sth like this:
2005-03-07 11:41:15.355297 soapclient: SOAP message length: 455 contents
2005-03-07 11:41:15.355583 soapclient: transporting via HTTP
2005-03-07 11:41:15.356393 soapclient: sending message, length: 455
2005-03-07 11:41:15.355823 soap_transport_http: scheme = http
2005-03-07 11:41:15.355961 soap_transport_http: host = 172.24.107.244
2005-03-07 11:41:15.356092 soap_transport_http: path =
/BSSRemoteWebService/CustomerService.asmx
The style is $this->getMicroTime().' '.get_class($this).": $string \n<br>";
When I inheritlize my new class from debughelper.
Well, I use php4. Sorry I forgot to declare it. If I use v5, exception is a
good choice.
Best regards,
Yang Shiqi
-----Original Message-----
From: Jochem Maas [mailto:jochem
iamjochem.com]
Sent: Friday, March 04, 2005 11:10 PM
To: Jason Barnett
Cc: php-general
lists.php.net
Subject: Re: [PHP] which class it is?
Jason Barnett wrote:
> Yangshiqi wrote:
>
>>And I do not want all my classes to inherit the debughelper.
>>
>>
>>Best regards,
>>Yang Shiqi
>>
>
>
> Yikes! I swear, some of these mailreader programs that people use... I
> thought this was an actual answer to someone's question... anywho...
>
> Have you checked out debug_backtrace() and set_error_handler()
> http://php.net/manual/en/function.debug-backtrace.php
> http://php.net/manual/en/function.set-error-handler.php
I have given up on this thread - the logic is all of a sudden lost on me!
I think we gave Yang some good stuff to chew on - last I read he was going
to
dig into exceptions! :-)
hey Yang, if you get stuck with Exceptions somewhere please post to a new
thread :-)
>
> Exceptions in PHP5
> http://php.net/exceptions
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
- application/pgp-signature attachment: OpenPGP digital signature
- application/pgp-signature attachment: OpenPGP digital signature
- application/pgp-signature attachment: OpenPGP digital signature
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]