Re: [PHP] unexplainable - page generation time class

2005-03-06 Thread Ian Firla

I think the problem is how, when and where you're calling things.

Basically, your code is fine. I modified it slightly and get the correct
output. This could still be cleaned up and optimised significantly;
however, I think you can take it from here:

Your Class:

?php
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];
return $this-cls_start_time;
}

//
// FIGURE OUT THE TIME AT THE END OF THE PAGE
//
function stop() {
$microstop = explode(' ',microtime());
$this-cls_stop_time = $microstop[0] + $microstop[1];
return $this-cls_stop_time;
}

//
// CALCULATE THE DIFFERENCE BETWEEN THE BEGINNNG AND THE END AND
COLOR CODE THE RESULT
//
function gen($start, $stop) {
$this-cls_gen_time = $stop - $start;
return $this-cls_gen_time;
}
}
?

index php that calls it:

?PHP

require_once(timer.php);

$page_gen = new page_gen;

$start=$page_gen-start();
sleep(2);
$stop=$page_gen-stop();

echo(start/stop: $start $stopbrbr);

$gentime=$page_gen-gen($start, $stop);

echo generation time: . $gentime;

?

Output:

start/stop: 1110096261.12 1110096263.13

generation time: 2.00168681145

All the best,

Ian

---
Ian Firla Consulting
http://ianfirla.com

On Sat, 2005-03-05 at 22:04 -0700, James Williams wrote:
 Howdy!  I've made a class which simply determines the page generation 
 time of a php script... After pretty much an hour of straight examining 
 the code and trying tons of different things, no good has come of it, 
 however I can't find an error... anywhere.
 
 ?php
 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 = $this-cls_stop_time - 
 $this-cls_start_time;
 return $this-cls_gen_time;
 }
 }
 ?
 
 What happens is it simply returns the $this-cls_start_time variable.  
 
 Both the start() and stop() functions work fine because to test them I 
 put print commands at the end and they both returned proper results, the 
 error appears to be in the line where I minus the start time from the 
 end time.  It simply returns a negative start time instead of minusing 
 the two.
 
 I tried changing the minus to a plus for testing sake and it just took 
 out the negative.  Does anybody have any idea what is going on here?  
 Thanks-you
 

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



[PHP] Passwords?

2005-03-06 Thread rory walsh
I want to create a simple as possible password script, how secure is it 
to have the password actually appear in the script? I only need one 
password so I thought that this would be more straightforward than 
having a file which contains the password. I am not using any database. 
Actually this leads me to another question, is there anyway people can 
view your script without having access to your server that is? Cheers,
Rory.

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


RE: [PHP] Passwords?

2005-03-06 Thread YaronKh
Hi Rory
  You can use crypt to encode a password, let say you want the password to be 
my password, create a new php file :
 echo crypt(my password);

then you get a unique encoded string something like 'ABC12Fdfi654sdfkfpr67UPL'
copy it and delete the php file 


in your password validation file write : 

$enc_pass = 'ABC12Fdfi654sdfkfpr67UPL';

  if (@crypt($_POST['pass'], $enc_pass) == $enc_pass) 
/* password is o.k. */



Now even if someone will see the php script he won't knew your password


Hope I've helped
yaron

-Original Message-
From: rory walsh [mailto:[EMAIL PROTECTED] 
Sent: Sunday, March 06, 2005 1:35 PM
To: php-general@lists.php.net
Subject: [PHP] Passwords?

I want to create a simple as possible password script, how secure is it 
to have the password actually appear in the script? I only need one 
password so I thought that this would be more straightforward than 
having a file which contains the password. I am not using any database. 
Actually this leads me to another question, is there anyway people can 
view your script without having access to your server that is? Cheers,
Rory.

-- 
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] Passwords?

2005-03-06 Thread AdamT
On Sun, 06 Mar 2005 11:34:39 +, rory walsh [EMAIL PROTECTED] wrote:
 I want to create a simple as possible password script, how secure is it
 to have the password actually appear in the script? I only need one
 password so I thought that this would be more straightforward than
 having a file which contains the password. I am not using any database.
 Actually this leads me to another question, is there anyway people can
 view your script without having access to your server that is? Cheers,
 Rory.
 
If the password is stored in between the ? and ? tags, then it
shouldn't get sent to the browser unless you specifically send it
there.  However, there are sometimes security problems in web servers,
which would mean that attackers were able to see the source of your
script, and therefore the password.  For example: files called .php
might get processed properly, but if the attacker requests
filename.PHP, it might just send him the file in plain text.
Best thing is to use 'include' or 'require' to get the password from
another file which doesn't sit on a part of the filesystem that's
accessible over the web.  Or, you could password-protect the script
you're including with .htpasswd / .htaccess protection.

-- 
AdamT
Justify my text?  I'm sorry, but it has no excuse.

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



Re: [PHP] Passwords?

2005-03-06 Thread Jochem Maas
[EMAIL PROTECTED] wrote:
Hi Rory
  You can use crypt to encode a password, let say you want the password to be my 
password, create a new php file :
 echo crypt(my password);
then you get a unique encoded string something like 'ABC12Fdfi654sdfkfpr67UPL'
copy it and delete the php file 

in your password validation file write : 

$enc_pass = 'ABC12Fdfi654sdfkfpr67UPL';
  if (@crypt($_POST['pass'], $enc_pass) == $enc_pass) 
/* password is o.k. */

I use the same technique to provide a 'superuser' login to intranets/cms -
a login which nobody can change/break (+ it works even if lots of stuff is 
broken because it
only relies on a hardcoded string).
personally I use sha1() iso of crypt() - no idea which is better.
that said you still don't want this file or this string to get into the hands 
of evilhaxors
- best to keep this file (one with the encrypted pwd in it) outside of the 
docroot.

Now even if someone will see the php script he won't knew your password
Hope I've helped
yaron
-Original Message-
From: rory walsh [mailto:[EMAIL PROTECTED] 
Sent: Sunday, March 06, 2005 1:35 PM
To: php-general@lists.php.net
Subject: [PHP] Passwords?

I want to create a simple as possible password script, how secure is it 
to have the password actually appear in the script? I only need one 
password so I thought that this would be more straightforward than 
having a file which contains the password. I am not using any database. 
Actually this leads me to another question, is there anyway people can 
view your script without having access to your server that is? Cheers,
Rory.

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


[PHP] check to see if a string contains sudden elements

2005-03-06 Thread Reinhart Viane
I have a page which gets the id of a user from the url.

$_GET[id]

 

Now this id can have two forms:

Normal: page.php?id=1

Not so normal: page.php?id=whatever|1

 

I can explode the second string so I only have the number (1). Explode (|,
$_GET(id))

But this command fails my query in case we have a normal value

 

Is there a way to check the $_GET(id) to see if there is a | in it and in
that case explode it?

 

Thx in advance.

Reinhart



[PHP] Re: check to see if a string contains sudden elements

2005-03-06 Thread M. Sokolewicz
Reinhart Viane wrote:
I have a page which gets the id of a user from the url.
$_GET[id]
 

Now this id can have two forms:
Normal: page.php?id=1
Not so normal: page.php?id=whatever|1
 

I can explode the second string so I only have the number (1). Explode (|,
$_GET(id))
But this command fails my query in case we have a normal value
 

Is there a way to check the $_GET(id) to see if there is a | in it and in
that case explode it?
 

Thx in advance.
Reinhart

$ret = explode('|', $_GET['id']);
if(count($ret)  1) {
$id = $ret[1];
} else {
$id = $ret[0];
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Passwords?

2005-03-06 Thread rory walsh
Cheers, I'll give your suggestions a go.
Jochem Maas wrote:
[EMAIL PROTECTED] wrote:
Hi Rory
  You can use crypt to encode a password, let say you want the 
password to be my password, create a new php file :
 echo crypt(my password);

then you get a unique encoded string something like 
'ABC12Fdfi654sdfkfpr67UPL'
copy it and delete the php file

in your password validation file write :
$enc_pass = 'ABC12Fdfi654sdfkfpr67UPL';
  if (@crypt($_POST['pass'], $enc_pass) == $enc_pass) 
/* password is o.k. */

I use the same technique to provide a 'superuser' login to intranets/cms -
a login which nobody can change/break (+ it works even if lots of stuff 
is broken because it
only relies on a hardcoded string).

personally I use sha1() iso of crypt() - no idea which is better.
that said you still don't want this file or this string to get into the 
hands of evilhaxors
- best to keep this file (one with the encrypted pwd in it) outside of 
the docroot.


Now even if someone will see the php script he won't knew your password
Hope I've helped
yaron
-Original Message-
From: rory walsh [mailto:[EMAIL PROTECTED] Sent: Sunday, March 06, 
2005 1:35 PM
To: php-general@lists.php.net
Subject: [PHP] Passwords?

I want to create a simple as possible password script, how secure is 
it to have the password actually appear in the script? I only need one 
password so I thought that this would be more straightforward than 
having a file which contains the password. I am not using any 
database. Actually this leads me to another question, is there anyway 
people can view your script without having access to your server that 
is? Cheers,
Rory.

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


Re: [PHP] Passwords?

2005-03-06 Thread Jason Wong
On Sunday 06 March 2005 21:03, AdamT wrote:

 If the password is stored in between the ? and ? tags, then it
 shouldn't get sent to the browser unless you specifically send it
 there.

For *any* php code it is best to use ?php ? tags. These tags will work 
on *all* php enabled webservers. The short tags ? ? is an optional 
setting on the webserver and hence may not be enabled in which case your 
code *will* be displayed as-is.

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

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



[PHP] Re: How can i calculate total process time?

2005-03-06 Thread Eli
M. Sokolewicz wrote:
fetch the microtime() at the top of the script, and at the bottom of the 
script you fetch it again. Subtract the first from the later, and you're 
left with the time it took. Then change it to a human-readable form, and 
you're done. You can't get closer without hacking the ZE
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\nhrb.round($endtime-$starttime,3). sec/b;
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Re: check to see if a string contains sudden elements

2005-03-06 Thread Reinhart Viane


$ret = explode('|', $_GET['id']);
if(count($ret)  1) {
$id = $ret[1];
} else {
$id = $ret[0];
}

Suberb,
This indeed did the trick. Aargh I hate when things are this simple and I
just can't seem to find them...
Thx!

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



[PHP] 'Insulate' db connection

2005-03-06 Thread Andre Dubuc
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

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



[PHP] Help with dates

2005-03-06 Thread Kevin
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.
However, the functions php provides only allow up to the unix epoch.

Could you guys give me some pointers on how to accomplish this, accurately?

Thanks a million!

Kevin

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



Re: [PHP] warning question about mysql sessions concurrency

2005-03-06 Thread Chris Smith
Josh Whiting wrote:
I've been trying to switch to MySQL-based session storage instead of the 
native PHP session storage.  In doing so, I've run into a lot of code on 
the web that exhibits a serious flaw regarding concurrent requests from 
the same client. All the code I've seen has glossed over the need to 
lock the session for the duration of the request, e.g. not allow 
concurrent requests to use it until it has finished.  PHP's native 
session handler correctly does this, but lots of MySQL-driven session 
code does not.
Neither do.
Example timeline:
1. client sends a request
2. session data is loaded from the db 
3. same client sends a request before the first one is finished (e.g. 
frames, tabbed browsing, slow server response times, etc)
4. session data is again loaded from the db
5. the first request changes some values in $_SESSION
6. the second request changes some values in $_SESSION
7. the first request writes the data to the db and exits
8. the second request writes it's data (over that written by the first 
request) and exits

PHP's native handler solves this problem by forcing concurrent requests
to wait for each other. The same thing needs to happen in a
database-driven session handler.
No request should be blocking (i.e. wait for concurrent processes to 
execute).  This implies a poor understanding of transactional processing 
from both yourself and PHP!

SO, does anyone have some code that uses MySQL to replace PHP's native
session storage that also correctly handles this concurrency problem? 
Ideally I'd like to see just a set of functions that can be used with 
sessions_set_save_handler() to transparently shift PHP's sessions to a 
database, but I'm not going to use the stuff I've found on the web or 
even in books (appendix D of O'Reilly's Web Database Applications with 
PHP  MySQL publishes code with this problem).
Forget it - rethink how your application is architected.
Folks using database sessions who do not deal with this scenario be
warned! I'm surprised so much bad code is going around for this task...
Agree.
Some guidelines, from my experience of developing time-critical 
transactional systems in .Net (100 transactions/second type load).

- You usually only store some kind of identification for a user in the 
session - no other data.  doing otherwise is dangerous as there are 
multiple copies of data floating around uncontrolled.  A session-id is 
enough information to store.  Don't use the session for storing data 
willy nilly - it is for identifying the session only - nothing else. 
Can't say that enough.  Don't use it for shortcutting code.

- If you want a proper transactional system, there are two ways to 
handle concurrency:

1. Block until the transaction is committed - no good for performance 
and scalability as you spend more time waiting than doing.

2. Fail commit on change.  A sample solution: For each row, add an INT 
which is incremented every time the data is updated (or use TIMESTAMP in 
MySQL if you have to use it).  Read the value with the data and send it 
every time the data is saved.  If the value is the same when it is 
recieved, then consistency can be guaranteed so update the row, else 
rollback the transaction (and tell the user someone else changed it 
before them - reload the view and give them an opportunity to update it 
again).  This requires a good understanding of the DBMS you are using 
and the principles around ACID compliant databases.

I'd personally recomment PostgreSQL over MySQL as MySQL is not truly 
atomic and can't do transactions database-side (no server-side 
programming) which makes it about as scalable as a brick.  Small 
updates/reads yeah but nothing much more complicated.

Personally, no-one in the PHP/MySQL arena tends to understand these 
concepts as the two technologies are rarely used for pushing data around 
on big systems (this is generally Java/Postgres' domain).

I ONLY use PHP/MySQL for knocking up quick web apps to fart out content 
- nothing serious because it's simply not suited.

Cheers,
Chris Smith
Ninja Labs
http://www.ninjalabs.co.uk/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] cache engine

2005-03-06 Thread Chris Smith
Evert - Rooftop Solutions wrote:
Mark Charette wrote:
Evert - Rooftop Solutions wrote:
I heard that shared memory is actually slower than writing and 
reading a file and it is not available on windows systems.

Hmmm ... that's an interesting thing you heard concerning shared 
memory. Care to share _who_ told you that?

I'd like to make sure I don't hire him/her in the future.
http://www.onlamp.com/pub/a/php/2001/10/11/pearcache.html
Check it out, is in old article, but it says |shm| -- The |shm| 
container stores the cached data in the shared memory. Benchmarks 
indicate that the current implementation of this container is much 
slower than the |file| container.

It is a bit outdated, but I haven't seen any recent benchmarks.
They both scale differently - shm linearly considering it's IO bandwidth 
and latency is considerably higher and lower respectively.  The shm 
doesn't require a disk head to move around to get and save data to cache 
(majority writes if it's caching to disk as reads get done from kernel 
cache) which takes time.

shm will hold out a lot longer than files (I know from experience with 
SVR4 many eons ago).

Cheers,
Chris Smith
Ninja Labs
http://www.ninjalabs.co.uk/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] warning question about mysql sessions concurrency

2005-03-06 Thread Josh Whiting
On Sun, Mar 06, 2005 at 02:27:53PM +, Chris Smith wrote:
 Josh Whiting wrote:
 I've been trying to switch to MySQL-based session storage instead of the
 native PHP session storage.  In doing so, I've run into a lot of code on
 the web that exhibits a serious flaw regarding concurrent requests from
 the same client. All the code I've seen has glossed over the need to
 lock the session for the duration of the request, e.g. not allow
 concurrent requests to use it until it has finished.  PHP's native
 session handler correctly does this, but lots of MySQL-driven session
 code does not.

 Neither do.

PHP absolutely does.  Take the following code:
?
session_start();
if (!isset($_SESSION['count'])) $_SESSION['count'] = 0;
$_SESSION['count'] = $_SESSION['count'] + 1;
sleep(5);
echo htmlbodyh1Current count:;
echo $_SESSION['count'];
echo /h1/body/html;
?

Open up two browser windows/tabs and load this page in both, try to make
both pages load at the same time.  Notice the second request takes 10
seconds while the first takes 5.  That's because the second one is
really, actually, indeed WAITING for the first one to finish.  (You may
have to do a first initial request before trying this to get the cookie
set.)  This also is not a side effect of web server processes,
threading, etc., it's really waiting until the session lock is released.

 No request should be blocking (i.e. wait for concurrent processes to
 execute).  This implies a poor understanding of transactional processing
 from both yourself and PHP!

On the contrary, when dealing with a session store (in PHP, which AFAIK
always writes the session and the end of the request), it's very
important for serial access instead of concurrent.

Take the following sql from two MySQL clients:

client 1: start transaction;
client 2: start transaction;
client 1: select * from mytable where id=1 FOR UPDATE;
# i.e. give me the data from the row with a write lock
client 2: select * from mytable where id=1 FOR UPDATE;
...

client 2 is going to have to sit there and wait until client 1 commits
or rolls back.  that's how it should work with the session store.  each
PHP request should acquire a write lock on the session so no other
request can even *read* the data until the original request is done.

 - You usually only store some kind of identification for a user in the
 session - no other data.  doing otherwise is dangerous as there are
 multiple copies of data floating around uncontrolled.  A session-id is
 enough information to store.  Don't use the session for storing data
 willy nilly - it is for identifying the session only - nothing else.
 Can't say that enough.  Don't use it for shortcutting code.

there is no point to storing only a session id in a session store. the
session id is already in the cookie or querystring.  what's the point of
a session, then?  tell me how you store a user's login status, a user's
shopping cart contents, etc. - that is the place i call the session
store and that is the thing that needs to block concurrent
(write) requests, whatever you want to call it...

 - If you want a proper transactional system, there are two ways to
 handle concurrency:
[snip]
 Personally, no-one in the PHP/MySQL arena tends to understand these
 concepts as the two technologies are rarely used for pushing data around
 on big systems (this is generally Java/Postgres' domain).

i understand your explanations.  in the case of session concurrency, if
you're using a fail commit on change and are also using frames with
PHP's session design, you're site just isn't going to work.
one frame will appear and the rest will say sorry, some other process
got to the data first.  instead, each frame request has to wait for
each other to finish, which is how PHP's native session handler does it.

 I ONLY use PHP/MySQL for knocking up quick web apps to fart out content
 - nothing serious because it's simply not suited.

Have you checked out InnoDB?  Row level locking, transactions, etc etc.
Not as fully featured, agreed, but all the critical stuff is there.
MySQL isn't the same as it was a few years ago.

/jw

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



[suspicious - maybe spam] [PHP] [suspicious - maybe spam] Re: [PHP] 'Insulate' db connection

2005-03-06 Thread Mattias Thorslund
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[suspicious - maybe spam] [PHP] [suspicious - maybe spam] Re: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] Re: [PHP] 'Insulate' db connection

2005-03-06 Thread Andre Dubuc
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

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



[PHP] Newbie question: qutoes?

2005-03-06 Thread rory walsh
Can anyone tell me if there is a difference between double quotes and 
single quotes? Cheers,
Rory.

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


Re: [PHP] Re: How can i calculate total process time?

2005-03-06 Thread James Williams
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\nhrb.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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie question: qutoes?

2005-03-06 Thread James Williams
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

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


Re: [PHP] Newbie question: qutoes?

2005-03-06 Thread Jochem Maas
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 :-)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie question: qutoes?

2005-03-06 Thread Matt Harnaga
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.

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


Re: [PHP] Newbie question: qutoes?

2005-03-06 Thread rory walsh
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 :-)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Newbie question: qutoes?

2005-03-06 Thread Matt Harnaga
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.

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


[PHP] error from 4.3.10: The specified procedure could not be found.

2005-03-06 Thread Javier Muniz
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

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



[PHP] Opening files....

2005-03-06 Thread Vaibhav Sibal
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

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



Re: [PHP] Opening files....

2005-03-06 Thread Guillermo Rauch
 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.

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



[PHP] Undefined Variable Problems...

2005-03-06 Thread Nick Zukin
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/.org/html/mainfile.php on line 79
[Sun Mar  6 00:35:51 2005] [error] PHP Notice:  Undefined offset:  1 in
/home/scott/.org/html/mainfile.php on line 486
[Sun Mar  6 00:35:51 2005] [error] PHP Notice:  Undefined index:  2 in
/home/scott/.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

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



[PHP] Re: Undefined Variable Problems...

2005-03-06 Thread Jason Barnett
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://.com/forums/post.php?forum_admin=1user=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-generalw=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=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


[PHP] Can't figure mail post out

2005-03-06 Thread Robert
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 = htmlbodyHi {$_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 brRow one output = $sendtobr;
  mail ($_POST['sendto'],'Testing', $body, $headers);
  echo Sent to $row[1]br;}
  mysql_free_result ($result); 

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



[PHP] Re: Help with dates

2005-03-06 Thread Jason Barnett
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-generalw=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=PHPsubmitform=Find+search+plugins


signature.asc
Description: OpenPGP digital signature


[PHP] Re: Undefined Variable Problems...

2005-03-06 Thread Jason Barnett
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).


signature.asc
Description: OpenPGP digital signature


RE: [PHP] Re: Undefined Variable Problems...

2005-03-06 Thread Nick Zukin

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:[EMAIL PROTECTED]
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).

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



Re: [PHP] Re: Undefined Variable Problems...

2005-03-06 Thread Guillermo Rauch
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

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



[PHP] Re: Help with dates

2005-03-06 Thread Kevin
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 [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

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



[PHP] Re: Help with dates

2005-03-06 Thread M. Sokolewicz
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 [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] stream_set_timeout get_headers (PHP5)

2005-03-06 Thread Marek Kilimajer
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',  );
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Document root, preferred way to find it???

2005-03-06 Thread Marek Kilimajer
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:[EMAIL PROTECTED]
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.
   

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


Re: [PHP] Document root, preferred way to find it???

2005-03-06 Thread Leif Gregory
Hello Tom,

Friday, March 4, 2005, 9:13:41 PM, you wrote:
TR This will set the include path just before the document root:

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

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



Re: [PHP] Document root, preferred way to find it???

2005-03-06 Thread Leif Gregory
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

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



Re[2]: [PHP] Document root, preferred way to find it???

2005-03-06 Thread Tom Rogers
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 H. 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_namebr;

$script = $_SERVER['SCRIPT_NAME'];
echo Script: $scriptbr;

$document_root = str_replace($script,'',$file_name);
echo Document root: $document_rootbr;

$base = basename($document_root);
echo Base: $basebr;

$include = str_replace($base,'include',$document_root);
echo Include: $includebr;

$os = strtolower(PHP_OS);
echo OS: $osbr;

$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

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



Re: [PHP] Help with dates

2005-03-06 Thread Jason Wong
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

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



Re: [PHP] error from 4.3.10: The specified procedure could not be found.

2005-03-06 Thread Tom Rogers
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

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



Re: [PHP] Document root, preferred way to find it???

2005-03-06 Thread Marek Kilimajer
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.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Help with dates

2005-03-06 Thread Kevin
Thank you.. duh...
quite useful... not...

Where do you think I check first?

Yours,

Kevin

Jason Wong [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 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

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



Re: [PHP] Document root, preferred way to find it???

2005-03-06 Thread Leif Gregory
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

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



Re: [PHP] Can't figure mail post out

2005-03-06 Thread Zareef Ahmed
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 [EMAIL PROTECTED] 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 = htmlbodyHi {$_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 brRow one output = $sendtobr;
   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

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



Re: [PHP] Document root, preferred way to find it???

2005-03-06 Thread Leif Gregory
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

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



[suspicious - maybe spam] [PHP] [suspicious - maybe spam] Re: [PHP] Re: Help with dates

2005-03-06 Thread Mattias Thorslund
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] which class it is?

2005-03-06 Thread yangshiqi
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 \nbr;
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:[EMAIL PROTECTED] 
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

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



Re: [PHP] Can't figure mail post out

2005-03-06 Thread Robert
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 [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 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 [EMAIL PROTECTED] 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 = htmlbodyHi {$_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 brRow one output = $sendtobr;
   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 

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



[suspicious - maybe spam] [PHP] Re: [suspicious - maybe spam] Re: [PHP] Re: Help with dates

2005-03-06 Thread Kevin
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 [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 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

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



Re: [PHP] Can't figure mail post out

2005-03-06 Thread anirudh dutt
On Mon, 7 Mar 2005 08:37:52 +0530, Zareef Ahmed [EMAIL PROTECTED] 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 [EMAIL PROTECTED] wrote:
   $sendto = $row[1];
echo brRow one output = $sendtobr;
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

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



Re[2]: [PHP] Document root, preferred way to find it???

2005-03-06 Thread Tom Rogers
Hi,

Monday, March 7, 2005, 1:08:27 PM, you wrote:
LG Hello Tom,

LG Sunday, March 6, 2005, 6:18:54 PM, you wrote:
TR and let me see what it prints

LG Still not quite there.

LG Site root
LG **
LG File name: C:\Sambar\docs\test\test.php
LG Script: /test.php
LG Document root: C:\Sambar\docs\test\test.php
LG Base: test.php
LG Include: C:\Sambar\docs\test\include
LG OS: winnt
LG Include: C:\Sambar\docs\test\include;.;C:\php5\pear

LG **

LG Site root/folder1
LG ***
LG File name: C:\Sambar\docs\test\folder1\test.php
LG Script: /folder1/test.php
LG Document root: C:\Sambar\docs\test\folder1\test.php
LG Base: test.php
LG Include: C:\Sambar\docs\test\folder1\include
LG OS: winnt
LG Include: C:\Sambar\docs\test\folder1\include;.;C:\php5\pear

LG ***

LG Site root/folder1/folder2
LG ***
LG File name: C:\Sambar\docs\test\folder1\folder2\test.php
LG Script: /folder1/folder2/test.php
LG Document root: C:\Sambar\docs\test\folder1\folder2\test.php
LG Base: test.php
LG Include: C:\Sambar\docs\test\folder1\folder2\include
LG OS: winnt
LG Include:
LG C:\Sambar\docs\test\folder1\folder2\include;.;C:\php5\pear

LG ***

LG Thanks.

LG Cheers,
LG Leif Gregory 

LG -- 
LG TB Lists Moderator (and fellow registered end-user)
LG PCWize Editor  /  ICQ 216395  /  PGP Key ID 0x7CD4926F
LG Web Site http://www.PCWize.com


Ok I see where is is going wrong, try this:

?php
if(isset($_SERVER[SCRIPT_FILENAME])){
$file_name = str_replace('\\','/',$_SERVER['SCRIPT_FILENAME']);
echo File name: $file_namebr;

$script = str_replace('\\','/',$_SERVER['SCRIPT_NAME']);
echo Script: $scriptbr;

$document_root = str_replace($script,'',$file_name);
echo Document root: $document_rootbr;

$base = basename($document_root);
echo Base: $basebr;

$include = str_replace($base,'include',$document_root);
echo Include: $includebr;

$os = strtolower(PHP_OS);
echo OS: $osbr;

$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;
}

-- 
regards,
Tom

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



[suspicious - maybe spam] [PHP] [suspicious - maybe spam] Re: Help with dates

2005-03-06 Thread Mattias Thorslund
Check out:
http://pear.php.net/package/Date
According to the description, it lets you compare dates that date pre 
1970 and post 2038.

/Mattias
(If I could only get off ezmlm's suspicious user list. I think there 
isn't much I can do, it's my ISP rejecting some PHP list postings.)

Kevin wrote:
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 [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 

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
   

 

--
More views at http://www.thorslund.us
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] mac os x - not getting headers already sent error

2005-03-06 Thread Jonathan Haddad
I do all my development on mac os x.  sometimes, to debut a script, i 
output the query to the page.  quite often the page sends headers to go 
to another page.  When i do this, i comment out the header() function 
and read the results.  When i'm done i remove the comment

Sometimes I've forgotten to take out the debugging output.  Now, on my 
server here, the page redirects and loads fine.  But in the live 
environment, it craps out and people are left staring at a blank page.

The test server is the same computer i'm developing on.
Anyone know why this happens, and how i can fix it?
Jon Haddad
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] SOLVED: Re: [PHP] Document root, preferred way to find it???

2005-03-06 Thread Leif Gregory
Hello Tom,

Sunday, March 6, 2005, 10:00:17 PM, you wrote:
TR Ok I see where is is going wrong, try this:

Oh, very close. Although you have it at $document_root and all
that needs to be added is '/include' like below:

$include = $document_root . '/include';

Otherwise it's one directory too far up because you're replacing the
site root 'test' (in this case) with 'include'.

We wanted: 'C:/Sambar/docs/test/include'

Here's from your script.

Site root:
**

File name: C:/Sambar/docs/test/test.php
Script: /test.php
Document root: C:/Sambar/docs/test
Base: test
Include: C:/Sambar/docs/include
OS: winnt
Include: C:/Sambar/docs/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
Base: test
Include: C:/Sambar/docs/include
OS: winnt
Include: C:/Sambar/docs/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
Base: test
Include: C:/Sambar/docs/include
OS: winnt
Include: C:/Sambar/docs/include;.;C:\php5\pear

**



After my change:

File name: C:/Sambar/docs/test/folder1/folder2/test.php
Script: /folder1/folder2/test.php
Document root: C:/Sambar/docs/test
Base: test
Include: C:/Sambar/docs/test/include
OS: winnt
Include: C:/Sambar/docs/test/include;.;C:\php5\pear

The other two folders moving back up the tree are the same result.

So the final looks like:


if(isset($_SERVER[SCRIPT_FILENAME])){
$file_name = str_replace('\\','/',$_SERVER['SCRIPT_FILENAME']);
echo File name: $file_namebr;

$script = str_replace('\\','/',$_SERVER['SCRIPT_NAME']);
echo Script: $scriptbr;

$document_root = str_replace($script,'',$file_name);
echo Document root: $document_rootbr;

$base = basename($document_root);
echo Base: $basebr;

//$include = str_replace($base,'include',$document_root);
$include = $document_root . '/include';
echo Include: $includebr;

$os = strtolower(PHP_OS);
echo OS: $osbr;

$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;
}



It's a great effort and looks bulletproof. Can you shoot any holes in
mine? A full explanation at:
http://www.devtek.org/tutorials/dynamic_document_root.php

I only throw mine back out there because it's shorter. I think it's
solid, but only because I haven't broken it yet. :-)

Both our solutions suffer the same problem. They have to be on every
page that requires an include, because we can't rely on a new host
having our code in their auto_prepend file

**

function dynRoot()
{
  $levels = substr_count($_SERVER['PHP_SELF'],/);

  for ($i=0; $i  $levels - 1; $i++)
  {
$relativeDir .= ../;
  }

  return $relativeDir;
}

include(dynRoot() . 'includes/somefile.php')

**

Thanks again!


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

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



Re: [PHP] SOLVED: Re: [PHP] Document root, preferred way to find it???

2005-03-06 Thread Tom Rogers
Hi,

Monday, March 7, 2005, 3:57:50 PM, you wrote:
LG Hello Tom,

LG Sunday, March 6, 2005, 10:00:17 PM, you wrote:
TR Ok I see where is is going wrong, try this:

LG Oh, very close. Although you have it at $document_root and all
LG that needs to be added is '/include' like below:

LG $include = $document_root . '/include';

LG Otherwise it's one directory too far up because you're replacing the
LG site root 'test' (in this case) with 'include'.

LG We wanted: 'C:/Sambar/docs/test/include'

LG Here's from your script.

LG Site root:
LG **

LG File name: C:/Sambar/docs/test/test.php
LG Script: /test.php
LG Document root: C:/Sambar/docs/test
LG Base: test
LG Include: C:/Sambar/docs/include
LG OS: winnt
LG Include: C:/Sambar/docs/include;.;C:\php5\pear

LG **

LG Site root/folder1
LG **

LG File name: C:/Sambar/docs/test/folder1/test.php
LG Script: /folder1/test.php
LG Document root: C:/Sambar/docs/test
LG Base: test
LG Include: C:/Sambar/docs/include
LG OS: winnt
LG Include: C:/Sambar/docs/include;.;C:\php5\pear

LG **

LG Site root/folder1/folder2
LG **

LG File name: C:/Sambar/docs/test/folder1/folder2/test.php
LG Script: /folder1/folder2/test.php
LG Document root: C:/Sambar/docs/test
LG Base: test
LG Include: C:/Sambar/docs/include
LG OS: winnt
LG Include: C:/Sambar/docs/include;.;C:\php5\pear

LG **



LG After my change:

LG File name: C:/Sambar/docs/test/folder1/folder2/test.php
LG Script: /folder1/folder2/test.php
LG Document root: C:/Sambar/docs/test
LG Base: test
LG Include: C:/Sambar/docs/test/include
LG OS: winnt
LG Include: C:/Sambar/docs/test/include;.;C:\php5\pear

LG The other two folders moving back up the tree are the same result.

LG So the final looks like:
LG 

LG if(isset($_SERVER[SCRIPT_FILENAME])){
LG $file_name =
LG str_replace('\\','/',$_SERVER['SCRIPT_FILENAME']);
LG echo File name: $file_namebr;

LG $script = str_replace('\\','/',$_SERVER['SCRIPT_NAME']);
LG echo Script: $scriptbr;

LG $document_root = str_replace($script,'',$file_name);
LG echo Document root: $document_rootbr;

LG $base = basename($document_root);
LG echo Base: $basebr;

LG //$include = str_replace($base,'include',$document_root);
LG $include = $document_root . '/include';
LG echo Include: $includebr;

LG $os = strtolower(PHP_OS);
LG echo OS: $osbr;

LG $lk = ':';
LG $org_include = ini_get(include_path);
LG if(preg_match('/^win/i',$os))   $lk = ';';

LG ini_set(include_path,$include.$lk.$org_include);
LG echo Include: .ini_get(include_path).br;
LG }

LG 

LG It's a great effort and looks bulletproof. Can you shoot any holes in
LG mine? A full explanation at:
LG http://www.devtek.org/tutorials/dynamic_document_root.php

LG I only throw mine back out there because it's shorter. I think it's
LG solid, but only because I haven't broken it yet. :-)

LG Both our solutions suffer the same problem. They have to be on every
LG page that requires an include, because we can't rely on a new host
LG having our code in their auto_prepend file

LG **

LG function dynRoot()
LG {
LG   $levels = substr_count($_SERVER['PHP_SELF'],/);

LG   for ($i=0; $i  $levels - 1; $i++)
LG   {
LG $relativeDir .= ../;
LG   }

LG   return $relativeDir;
LG }

LG include(dynRoot() . 'includes/somefile.php')

LG **

LG Thanks again!


LG Cheers,
LG Leif Gregory 

LG -- 
LG TB Lists Moderator (and fellow registered end-user)
LG PCWize Editor  /  ICQ 216395  /  PGP Key ID 0x7CD4926F
LG Web Site http://www.PCWize.com

I do this for security as I have things in include that I don't want
to be avaiable directly to the browser Also you don't need a path for include
files you can just do:

include('somefile.php');

and it will be found regardless of where the script is located.


-- 
regards,
Tom

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



Re: [PHP] mac os x - not getting headers already sent error

2005-03-06 Thread Burhan Khalid
Jonathan Haddad wrote:
I do all my development on mac os x.  sometimes, to debut a script, i 
output the query to the page.  quite often the page sends headers to go 
to another page.  When i do this, i comment out the header() function 
and read the results.  When i'm done i remove the comment

Sometimes I've forgotten to take out the debugging output.  Now, on my 
server here, the page redirects and loads fine.  But in the live 
environment, it craps out and people are left staring at a blank page.
This means that on the live server, error_reporting is at such a level 
that the Warning that is generated by php -- the Cannot modify header 
information output started at  line isn't displayed, and since 
there is output to the client, the header() call fails, which is why you 
are left with a white screen.

You can use output buffering to avoid such a problem; there is also the 
header_sent() function.

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