Re: [PHP] New Date/Time Functionality and Setting Timezones

2006-04-17 Thread Lester Caine

Chris wrote:

In more than one place in the PHP documentation it refers to the  order 
in which the new Date/Time functionality determines the  appropriate 
time zone.


That order is:

1) the value set by date_default_timezone_set(), if any
2) the TZ environmental variable
3) the date.timezone php.ini option
4) magical guess
5) UTC

Is this indeed the actual order?

Would it not make more sense to prioritize the date.timezone php.ini  
setting over the TZ environmental variable?


That way users who don't have control over their TZ environmental  
variable (such as might be the case with some shared hosting  
environments) could set the timezone in an htaccess file rather than  
having to ensure they call date_timezone_default_set() in every script.


Of cause this still does nothing for the vast majority of hosting, where 
it's the timezone/daylight saving of the client that you need, not the 
server :(


--
Lester Caine - G8HFL
-
L.S.Caine Electronic Services
Treasurer - Firebird Foundation Inc.

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



Re: [PHP] 2 questions: Search in array and detect JS

2006-04-17 Thread Jochem Maas

1. I'm not the original poster (I wasn't asking a question)
2. don't post me or anyone else 'offlist' unless asked
3. WTF are you talking about?
4. if you say 'First' then that assumes there is a 'Second'
coming. (that's sounds kinda funny given it was just Easter)

suresh kumar wrote:

First,
 If u want to search work richard hassed .first
split the word as richard and hassed by using
split() and store it in array.and use select like
command to search individual word stored in array.this
 type of searching is followed in google.


   A.suresh 


--- Jochem Maas [EMAIL PROTECTED] wrote:



don't know if someone mentioned it already but i was
digging around in the docs
for something completely different and bumped into
this:

preg_grep() [http://php.net/preg_grep]

and I thought of your question, might be just what
your looking for.

I can't remember having come across this func before
- learn something new every day :-)


Ryan A wrote:


Hi,
Like the subject says; I have two questions:

1) Is it possible to detect JavaScript via php...


and yes I do know that JS


is client side while PHP is server...but how else


to do it?


The reason I ask is before serving an AJAX page I


would like to make sure JS


is enabled, if not, serve the other normal


page... I am sure I am not the


first person to come accross this little problem,


how did you solve it?


I have seen some suggestions on google like having


a hidden form field  and


using  js to put a value in it, if it exists when


the form is sent then JS


is on..if not, its not... but that method is not


the best in an AJAX


situation...right?


2) How can I search in an array for a particular


word?


eg: in an array movie I have this kind of data:
movie_name= some movie
cast= Jim Carrey, Richard Pryor, Eddie Murphy

I want to search on either Richard or Richard


Pryor (must be case


insensitive too)
something like a SELECT with a LIKE %% statement

I have been fooling around with in_array() but not


getting anywhere


fast. am I on the right track?
Links, code examples or advise would be as


alwaysappreciated.


Thanks,
Ryan



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








__ 
Yahoo! India Matrimony: Find your partner now. Go to http://yahoo.shaadi.com


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



Re: [PHP] Table formation...

2006-04-17 Thread Jochem Maas

Jay Blanchard wrote:

[snip]
Pardon my asking on the eve of your launch, but is a table the most 
sensible markup for this data?  It looks to me like a one-dimensional 
list that just happens to be presented two to a row.


If so, I'd use an unordered list, float each item left, and limit the 
list width to two item widths.

[/snip]

Thanks, but I just used what I showed as an example. It is a table
products including pictures, features, etc.


time limits always dictate the 'get it working' solution, that said
Paul's suggestion is rather better than using a table for a couple of
reasons (imho):

1. it saves you having to pre-order/split/etc the original data so that
you can then loop them/it in order to dump out a table.

2. it means that when the customer changes the layout your not stuck
with re-hacking output code - you just change the display style. non-rigid
markup :-)

3. the output you describe sounds like a list of info rather than a
table - which for [us] semantics freaks (hi guys ;-) mean an OL or a UL
is so much more satifying.





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



Re: [PHP] New Date/Time Functionality and Setting Timezones

2006-04-17 Thread Jochem Maas

Lester Caine wrote:

Chris wrote:

In more than one place in the PHP documentation it refers to the  
order in which the new Date/Time functionality determines the  
appropriate time zone.


That order is:

1) the value set by date_default_timezone_set(), if any
2) the TZ environmental variable
3) the date.timezone php.ini option
4) magical guess
5) UTC

Is this indeed the actual order?

Would it not make more sense to prioritize the date.timezone php.ini  
setting over the TZ environmental variable?


assuming that date.timezone can be set at the .htaccess level,
which hopefully it can be, I thoroughly agree with you.

especially given that the new date extension was originally plugged
with the helpful feature of not being bound to the system settings... IIRC.



That way users who don't have control over their TZ environmental  
variable (such as might be the case with some shared hosting  
environments) could set the timezone in an htaccess file rather than  
having to ensure they call date_timezone_default_set() in every script.



Of cause this still does nothing for the vast majority of hosting, where 
it's the timezone/daylight saving of the client that you need, not the 
server :(


maybe I'm missing your point completely but the whole point of
date_default_timezone_set() is that you can set the TZ specifically for
each request.





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



[PHP] OT - PHP Code Contest

2006-04-17 Thread Weber Sites LTD
Just wanted to refresh the memory of the veterans here and also let the new
people here know
that there is a monthly code contest going on since April 2004 with pretty
cool prizes from
relevant sponsors (Zend, NuSphere, TemplateMonster, php|architect, PHP
magazine and others).

The contest is held at : http://contest.weberdev.com. It's really simple and
is more an
incentive for everyone to contribute their code snippets, than a contest.

I hope to see more people contributing code examples.

Make sure you read the rules at : http://contest.weberdev.com/about.html

Thanks

berber

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



[PHP] Including files from another site

2006-04-17 Thread Shaun
Hi,

I have created a CMS where all sites on our server are administrated from 
one central site, and HTML content is stored in the CMS database.

I want users to all control their sites database functions from the CMS 
site, but I want to keep the database and database admin scripts in the 
individual website account to keep things simple. So I need want to be able 
to include these scripts within the CMS site but keep them secure. I have 
tried using frames but I can't keep a session going in the database admin 
scripts, is there a better way to do this?

Any advice would be greatly appreciated. 

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



RE: [PHP] Including files from another site

2006-04-17 Thread Weber Sites LTD
I'm not sure I understand what you are trying to do.
What is the connection between frames and security?

In general, assuming that all users have access to 
The same scripts, you need to include in all of your
Scripts some kind of security logic that tells the
Script which user can do what.

Usually you would want to also allow group access
Rather then user access for easier maintenance.

You should keep a user table with user, password
And privileges. There are endless ways to do this
And you need to choose what is best for your site.

Have a look at some relevant code examples:
http://www.weberdev.com/AdvancedSearch.php?searchtype=titlesearch=auth 

berber 

-Original Message-
From: Shaun [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 17, 2006 12:46 PM
To: php-general@lists.php.net
Subject: [PHP] Including files from another site

Hi,

I have created a CMS where all sites on our server are administrated from
one central site, and HTML content is stored in the CMS database.

I want users to all control their sites database functions from the CMS
site, but I want to keep the database and database admin scripts in the
individual website account to keep things simple. So I need want to be able
to include these scripts within the CMS site but keep them secure. I have
tried using frames but I can't keep a session going in the database admin
scripts, is there a better way to do this?

Any advice would be greatly appreciated. 

--
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] Table formation...

2006-04-17 Thread Jay Blanchard
[snip]
time limits always dictate the 'get it working' solution, that said
Paul's suggestion is rather better than using a table for a couple of
reasons (imho):

1. it saves you having to pre-order/split/etc the original data so that
you can then loop them/it in order to dump out a table.

2. it means that when the customer changes the layout your not stuck
with re-hacking output code - you just change the display style.
non-rigid
markup :-)

3. the output you describe sounds like a list of info rather than a
table - which for [us] semantics freaks (hi guys ;-) mean an OL or a UL
is so much more satifying.
[/snip]

With a simple loop I can create the data in columns in a table. It is a
table of products, each product's features, etc. I am not too worried
about the client changing the layout at a later date as that would
likely be driven by me...maybe. :)  The code which makes the multiple
columns of data is right simple and could easily be replaced.

if(0 == $columnCount){
   echo tr;
}

...do table stuff...

if(0 == $columnCount){
   $columnCount++; // increment to 1
else {
   echo /tr\n;
   $columnCount--; // decrement to 0
}

/* and yes, I could have done it with a mod as well, just had this done
before the responses came back. To return the table to one product per
row all that has to be done is to remove the conditionals, leaving only
the table row mark-up */

So, semantics freaks ;), the entire site is a CSS thing of beauty with a
LAMP back-end, and there is only one spot where I have used a small
table that I need to get rid of. This product table is justified as a
table.

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



[PHP] Re: [PHP-WIN] Re: php editors

2006-04-17 Thread Alain Roger
Hi,

personally i use Zend studio for its variables on-live debugging
possibility.
However, i'm sad that for debugging you need to install the Zend debugging
server features.

Alain

On 4/15/06, pfancy [EMAIL PROTECTED] wrote:

 Thanks for all the php editor idea.  I have been going through them.




 Stephen Lake [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Try http://www.php-editors.com  they list many different editors that
 you
  can useit lists freebies, commercialware and shareware
 
  pfancy [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
   I've been reading over php. I have bought php and mysql for dummies
 but
 my
   question is what kind of php editors can a person get  where they can
 view
   what it looks like?  or where do you find your php.ini file. i've been
   reading i need to work on that. and when that is fixed up to where i
 need
   it
   would i be able to view a php file like i would an html file? thanks.

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




Re: [PHP] Including files from another site

2006-04-17 Thread Shaun
Hi,

Thanks for your reply, sorry I should have been a little clearer in my 
explanation. Here goes...

I have a dedicated UNIX server with many websites on it. On this server I 
have also created a Content Management System which has a database which I 
use to store HTML content for all the other websites. Each website has a 
database connection to the CMS database to retrieve the HTML for its pages.

Each website that uses its own database has a folder called /cms and in here 
I keep all the database admin scripts for that website. I want these pages 
to only be accessible from within the CMS website and nothing else. So when 
the user is in the CMS they can click on database admin and it will include 
the pages in that websites /cms folder.

My Question is how can I ensure that the CMS is the only website that can 
access these scripts securely?

Thanks for your advice.


Weber Sites LTD [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 I'm not sure I understand what you are trying to do.
 What is the connection between frames and security?

 In general, assuming that all users have access to
 The same scripts, you need to include in all of your
 Scripts some kind of security logic that tells the
 Script which user can do what.

 Usually you would want to also allow group access
 Rather then user access for easier maintenance.

 You should keep a user table with user, password
 And privileges. There are endless ways to do this
 And you need to choose what is best for your site.

 Have a look at some relevant code examples:
 http://www.weberdev.com/AdvancedSearch.php?searchtype=titlesearch=auth

 berber

 -Original Message-
 From: Shaun [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 17, 2006 12:46 PM
 To: php-general@lists.php.net
 Subject: [PHP] Including files from another site

 Hi,

 I have created a CMS where all sites on our server are administrated from
 one central site, and HTML content is stored in the CMS database.

 I want users to all control their sites database functions from the CMS
 site, but I want to keep the database and database admin scripts in the
 individual website account to keep things simple. So I need want to be 
 able
 to include these scripts within the CMS site but keep them secure. I have
 tried using frames but I can't keep a session going in the database admin
 scripts, is there a better way to do this?

 Any advice would be greatly appreciated.

 --
 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] Table formation...

2006-04-17 Thread tedd

Jay said:


With a simple loop I can create the data in columns in a table. It is a
table of products, each product's features, etc. I am not too worried
about the client changing the layout at a later date as that would
likely be driven by me...maybe. :)  The code which makes the multiple
columns of data is right simple and could easily be replaced.

if(0 == $columnCount){
   echo tr;
}

...do table stuff...

if(0 == $columnCount){
   $columnCount++; // increment to 1
else {
   echo /tr\n;
   $columnCount--; // decrement to 0
}

The following is just another way (not using mod):

?php
echo(tabletr);
for ($i = 0; $i = 9; $i++)
{
echo(td$i/td);
if($i  1)
{
echo(tr/tr);
}
}
echo(/trtable);
?

Whenever I need a 1 or 0, I use ($i  1).


So, semantics freaks ;), the entire site is a CSS thing of beauty with a
LAMP back-end, and there is only one spot where I have used a small
table that I need to get rid of. This product table is justified as a
table.


Yep, nothing wrong with using tables to show column data -- that's 
what tables are for.


tedd
--

http://sperling.com

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



Re: [PHP] Table formation...

2006-04-17 Thread Jochem Maas

tedd wrote:

Jay said:


...




Yep, nothing wrong with using tables to show column data -- that's what 
tables are for.


that's my point - columns have nothing to do with the data structure, it's
a presentation issue - technically it's a list of products. ergo: UL iso TABLE.
personally I think the only 2 really strong reason for using a table to display
stuff are:

1. a datagrid type of control for doing CRUD stuff.
2. HTML email newsletter (evil in their own right :-), but if a client demands 
it
TABLEs are often the only way to reliably control layout :-( ).

but tedd there is no need to go defending Jay. I was merely chatting with him 
on a
theoretical level, not telling nwhat he should/must be doing (because a, he's 
been
doing this stuff longer than I have been alive ;-) and b, I know that he knows
the difference between doing it 'right' and doing it on time and within budget 
:-)

'right' being in quotes because that's more often than not just another form of
opinion. :-)



tedd


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



[PHP] real time output from log file?

2006-04-17 Thread Jason Gerfen
Anyone use php to tail a log file for patterns and perhaps updating a 
iframe or something similar?  If so do you have a link to some resources 
on it?


--
Jason Gerfen

You will never be ready for me.
~ Me

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



Re: [PHP] Table formation...

2006-04-17 Thread tedd
but tedd there is no need to go defending Jay. I was merely chatting 
with him on a
theoretical level, not telling nwhat he should/must be doing 
(because a, he's been

doing this stuff longer than I have been alive ;-) and b, I know that he knows
the difference between doing it 'right' and doing it on time and 
within budget :-)


'right' being in quotes because that's more often than not just 
another form of

opinion. :-)




Jochem:

Oh, I wasn't defending Jay -- I didn't even know anything was in 
dispute. I'm clueless as usual -- just putting in my $0.02 as I can.


Hell, I have enough problems trying to remember to remove your email 
address when I reply to all. :-)


As for tables, I agree that tables are for column data and sometimes 
for a quick and dirty fix to get things to work (i.e., client 
pressure) -- but, after the dust settles, go back and fix it right.


As for reliable control -- however -- reliable is what works and 
while css can be confusing (hacks and all), it does work reliably.


tedd
--

http://sperling.com

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



RE: [PHP] Including files from another site

2006-04-17 Thread Weber Sites LTD
I think that you are looking at this from the wrong angle.
What you should do, is password protect all CMS directories
And then, anyone that needs access has to punch in a valid
Username and password. 

Have a look at : http://sourceforge.net/projects/modauthmysql/

Sincerely 
 
berber 
 
Visit the Weber Sites Today, 
To see where PHP might take you tomorrow. 
PHP code examples : http://www.weberdev.com 
PHP  MySQL Forums : http://www.weberforums.com



-Original Message-
From: Shaun [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 17, 2006 2:52 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Including files from another site

Hi,

Thanks for your reply, sorry I should have been a little clearer in my
explanation. Here goes...

I have a dedicated UNIX server with many websites on it. On this server I
have also created a Content Management System which has a database which I
use to store HTML content for all the other websites. Each website has a
database connection to the CMS database to retrieve the HTML for its pages.

Each website that uses its own database has a folder called /cms and in here
I keep all the database admin scripts for that website. I want these pages
to only be accessible from within the CMS website and nothing else. So when
the user is in the CMS they can click on database admin and it will include
the pages in that websites /cms folder.

My Question is how can I ensure that the CMS is the only website that can
access these scripts securely?

Thanks for your advice.


Weber Sites LTD [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I'm not sure I understand what you are trying to do.
 What is the connection between frames and security?

 In general, assuming that all users have access to The same scripts, 
 you need to include in all of your Scripts some kind of security logic 
 that tells the Script which user can do what.

 Usually you would want to also allow group access Rather then user 
 access for easier maintenance.

 You should keep a user table with user, password And privileges. There 
 are endless ways to do this And you need to choose what is best for 
 your site.

 Have a look at some relevant code examples:
 http://www.weberdev.com/AdvancedSearch.php?searchtype=titlesearch=aut
 h

 berber

 -Original Message-
 From: Shaun [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 17, 2006 12:46 PM
 To: php-general@lists.php.net
 Subject: [PHP] Including files from another site

 Hi,

 I have created a CMS where all sites on our server are administrated 
 from one central site, and HTML content is stored in the CMS database.

 I want users to all control their sites database functions from the 
 CMS site, but I want to keep the database and database admin scripts 
 in the individual website account to keep things simple. So I need 
 want to be able to include these scripts within the CMS site but keep 
 them secure. I have tried using frames but I can't keep a session 
 going in the database admin scripts, is there a better way to do this?

 Any advice would be greatly appreciated.

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

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



Re: [PHP] Including files from another site

2006-04-17 Thread Shaun
I see your point, the only problem is that the user will have already logged 
once into the CMS, logging in again would be a little frustrating and not 
very user friendly...


Weber Sites LTD [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
I think that you are looking at this from the wrong angle.
 What you should do, is password protect all CMS directories
 And then, anyone that needs access has to punch in a valid
 Username and password.

 Have a look at : http://sourceforge.net/projects/modauthmysql/

 Sincerely

 berber

 Visit the Weber Sites Today,
 To see where PHP might take you tomorrow.
 PHP code examples : http://www.weberdev.com
 PHP  MySQL Forums : http://www.weberforums.com



 -Original Message-
 From: Shaun [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 17, 2006 2:52 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] Including files from another site

 Hi,

 Thanks for your reply, sorry I should have been a little clearer in my
 explanation. Here goes...

 I have a dedicated UNIX server with many websites on it. On this server I
 have also created a Content Management System which has a database which I
 use to store HTML content for all the other websites. Each website has a
 database connection to the CMS database to retrieve the HTML for its 
 pages.

 Each website that uses its own database has a folder called /cms and in 
 here
 I keep all the database admin scripts for that website. I want these pages
 to only be accessible from within the CMS website and nothing else. So 
 when
 the user is in the CMS they can click on database admin and it will 
 include
 the pages in that websites /cms folder.

 My Question is how can I ensure that the CMS is the only website that can
 access these scripts securely?

 Thanks for your advice.


 Weber Sites LTD [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 I'm not sure I understand what you are trying to do.
 What is the connection between frames and security?

 In general, assuming that all users have access to The same scripts,
 you need to include in all of your Scripts some kind of security logic
 that tells the Script which user can do what.

 Usually you would want to also allow group access Rather then user
 access for easier maintenance.

 You should keep a user table with user, password And privileges. There
 are endless ways to do this And you need to choose what is best for
 your site.

 Have a look at some relevant code examples:
 http://www.weberdev.com/AdvancedSearch.php?searchtype=titlesearch=aut
 h

 berber

 -Original Message-
 From: Shaun [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 17, 2006 12:46 PM
 To: php-general@lists.php.net
 Subject: [PHP] Including files from another site

 Hi,

 I have created a CMS where all sites on our server are administrated
 from one central site, and HTML content is stored in the CMS database.

 I want users to all control their sites database functions from the
 CMS site, but I want to keep the database and database admin scripts
 in the individual website account to keep things simple. So I need
 want to be able to include these scripts within the CMS site but keep
 them secure. I have tried using frames but I can't keep a session
 going in the database admin scripts, is there a better way to do this?

 Any advice would be greatly appreciated.

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

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



Re: [PHP] Including files from another site

2006-04-17 Thread Wolf
So, swap your CMS logins to use the same access code for the user, then
use sessions to swap the mysql stuff in where needed.

Or make it use a mysql call from the CMS login to access their mysql
information from another table and do it that way.

1 login, 1 password, very user friendly.

And only 1 place to have to worry about changing files.

HTH,

Wolf


Shaun wrote:
 I see your point, the only problem is that the user will have already logged 
 once into the CMS, logging in again would be a little frustrating and not 
 very user friendly...
 
 
 Weber Sites LTD [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 I think that you are looking at this from the wrong angle.
 What you should do, is password protect all CMS directories
 And then, anyone that needs access has to punch in a valid
 Username and password.

 Have a look at : http://sourceforge.net/projects/modauthmysql/

 Sincerely

 berber

 Visit the Weber Sites Today,
 To see where PHP might take you tomorrow.
 PHP code examples : http://www.weberdev.com
 PHP  MySQL Forums : http://www.weberforums.com



 -Original Message-
 From: Shaun [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 17, 2006 2:52 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] Including files from another site

 Hi,

 Thanks for your reply, sorry I should have been a little clearer in my
 explanation. Here goes...

 I have a dedicated UNIX server with many websites on it. On this server I
 have also created a Content Management System which has a database which I
 use to store HTML content for all the other websites. Each website has a
 database connection to the CMS database to retrieve the HTML for its 
 pages.

 Each website that uses its own database has a folder called /cms and in 
 here
 I keep all the database admin scripts for that website. I want these pages
 to only be accessible from within the CMS website and nothing else. So 
 when
 the user is in the CMS they can click on database admin and it will 
 include
 the pages in that websites /cms folder.

 My Question is how can I ensure that the CMS is the only website that can
 access these scripts securely?

 Thanks for your advice.


 Weber Sites LTD [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 I'm not sure I understand what you are trying to do.
 What is the connection between frames and security?

 In general, assuming that all users have access to The same scripts,
 you need to include in all of your Scripts some kind of security logic
 that tells the Script which user can do what.

 Usually you would want to also allow group access Rather then user
 access for easier maintenance.

 You should keep a user table with user, password And privileges. There
 are endless ways to do this And you need to choose what is best for
 your site.

 Have a look at some relevant code examples:
 http://www.weberdev.com/AdvancedSearch.php?searchtype=titlesearch=aut
 h

 berber

 -Original Message-
 From: Shaun [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 17, 2006 12:46 PM
 To: php-general@lists.php.net
 Subject: [PHP] Including files from another site

 Hi,

 I have created a CMS where all sites on our server are administrated
 from one central site, and HTML content is stored in the CMS database.

 I want users to all control their sites database functions from the
 CMS site, but I want to keep the database and database admin scripts
 in the individual website account to keep things simple. So I need
 want to be able to include these scripts within the CMS site but keep
 them secure. I have tried using frames but I can't keep a session
 going in the database admin scripts, is there a better way to do this?

 Any advice would be greatly appreciated.

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

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



[PHP] How can I see where my script wasting time?

2006-04-17 Thread afan
Hi to all!

I was developing one site with fake records in DB. Now, I put it live whit
real records. The site is running ok, but it's painfully slow. Even for
grabbing an order from DB and showing it on screen, from 1-2 sec (while
developing) went to almost 10-15 sec?!? No, of records for orders is a
little bit over 200,000 - what is not so much.

I'm assuming that the problem is not in the script than in the way I built
queries.

My question is how can I check what's taking so long in execution of the
script/query?
Where to start with improving the script?

Thanks for any help.

-afan

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



RE: [PHP] How can I see where my script wasting time?

2006-04-17 Thread Jay Blanchard
[snip]
I was developing one site with fake records in DB. Now, I put it live
whit
real records. The site is running ok, but it's painfully slow. Even for
grabbing an order from DB and showing it on screen, from 1-2 sec (while
developing) went to almost 10-15 sec?!? No, of records for orders is a
little bit over 200,000 - what is not so much.

I'm assuming that the problem is not in the script than in the way I
built
queries.

My question is how can I check what's taking so long in execution of the
script/query?
Where to start with improving the script?
[/snip]

Probably not the script. Do you have indexes on your tables?

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



Re: [PHP] Including files from another site

2006-04-17 Thread Shaun
Hi,

Thanks for your reply, just had a thought: How secure would it be if I made 
sure that the URL of the browser was www.mycms.com and only allow access to 
pages in the /cms folder if true?

Is this safe or an easy hack?


Wolf [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 So, swap your CMS logins to use the same access code for the user, then
 use sessions to swap the mysql stuff in where needed.

 Or make it use a mysql call from the CMS login to access their mysql
 information from another table and do it that way.

 1 login, 1 password, very user friendly.

 And only 1 place to have to worry about changing files.

 HTH,

 Wolf


 Shaun wrote:
 I see your point, the only problem is that the user will have already 
 logged
 once into the CMS, logging in again would be a little frustrating and not
 very user friendly...


 Weber Sites LTD [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 I think that you are looking at this from the wrong angle.
 What you should do, is password protect all CMS directories
 And then, anyone that needs access has to punch in a valid
 Username and password.

 Have a look at : http://sourceforge.net/projects/modauthmysql/

 Sincerely

 berber

 Visit the Weber Sites Today,
 To see where PHP might take you tomorrow.
 PHP code examples : http://www.weberdev.com
 PHP  MySQL Forums : http://www.weberforums.com



 -Original Message-
 From: Shaun [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 17, 2006 2:52 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] Including files from another site

 Hi,

 Thanks for your reply, sorry I should have been a little clearer in my
 explanation. Here goes...

 I have a dedicated UNIX server with many websites on it. On this server 
 I
 have also created a Content Management System which has a database which 
 I
 use to store HTML content for all the other websites. Each website has a
 database connection to the CMS database to retrieve the HTML for its
 pages.

 Each website that uses its own database has a folder called /cms and in
 here
 I keep all the database admin scripts for that website. I want these 
 pages
 to only be accessible from within the CMS website and nothing else. So
 when
 the user is in the CMS they can click on database admin and it will
 include
 the pages in that websites /cms folder.

 My Question is how can I ensure that the CMS is the only website that 
 can
 access these scripts securely?

 Thanks for your advice.


 Weber Sites LTD [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 I'm not sure I understand what you are trying to do.
 What is the connection between frames and security?

 In general, assuming that all users have access to The same scripts,
 you need to include in all of your Scripts some kind of security logic
 that tells the Script which user can do what.

 Usually you would want to also allow group access Rather then user
 access for easier maintenance.

 You should keep a user table with user, password And privileges. There
 are endless ways to do this And you need to choose what is best for
 your site.

 Have a look at some relevant code examples:
 http://www.weberdev.com/AdvancedSearch.php?searchtype=titlesearch=aut
 h

 berber

 -Original Message-
 From: Shaun [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 17, 2006 12:46 PM
 To: php-general@lists.php.net
 Subject: [PHP] Including files from another site

 Hi,

 I have created a CMS where all sites on our server are administrated
 from one central site, and HTML content is stored in the CMS database.

 I want users to all control their sites database functions from the
 CMS site, but I want to keep the database and database admin scripts
 in the individual website account to keep things simple. So I need
 want to be able to include these scripts within the CMS site but keep
 them secure. I have tried using frames but I can't keep a session
 going in the database admin scripts, is there a better way to do this?

 Any advice would be greatly appreciated.

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

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



Re: [PHP] How can I see where my script wasting time?

2006-04-17 Thread chris smith
On 4/18/06, Jay Blanchard [EMAIL PROTECTED] wrote:
 [snip]
 I was developing one site with fake records in DB. Now, I put it live
 whit
 real records. The site is running ok, but it's painfully slow. Even for
 grabbing an order from DB and showing it on screen, from 1-2 sec (while
 developing) went to almost 10-15 sec?!? No, of records for orders is a
 little bit over 200,000 - what is not so much.

 I'm assuming that the problem is not in the script than in the way I
 built
 queries.

 My question is how can I check what's taking so long in execution of the
 script/query?
 Where to start with improving the script?
 [/snip]

 Probably not the script. Do you have indexes on your tables?

If you're using mysql, you can enable slow logs and that will help you:

http://dev.mysql.com/doc/refman/5.0/en/slow-query-log.html

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] How can I see where my script wasting time?

2006-04-17 Thread Martin Alterisio \El Hombre Gris\
Use the EXPLAIN sql command to check what your queries are really doing, 
you'll have to read the manual for the database you're using to figure 
out the information returned by this command.


[EMAIL PROTECTED] wrote:


Hi to all!

I was developing one site with fake records in DB. Now, I put it live whit
real records. The site is running ok, but it's painfully slow. Even for
grabbing an order from DB and showing it on screen, from 1-2 sec (while
developing) went to almost 10-15 sec?!? No, of records for orders is a
little bit over 200,000 - what is not so much.

I'm assuming that the problem is not in the script than in the way I built
queries.

My question is how can I check what's taking so long in execution of the
script/query?
Where to start with improving the script?

Thanks for any help.

-afan

 



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



Re: [PHP] Including files from another site

2006-04-17 Thread Wolf
Personally I would use it as part of the session and verify it that way...

ie: check to see if the $PHP_SELF is www.mycms.com, if not refresh the
page to that URL automatically and then make them do the login.  Only
after logging in does the session key get the mysite=true key or
whatever you want to check for.

That SHOULD keep it from getting hacked, as your basically verifying at
the beginning that you are only allowing entry from your location.

You should also be making sure that your server does not allow others to
host primary images so that nobody could phish your site.  Paypal and
chase are really lamely set up which is making phishing easier for
people who use them.

My $.02

Wolf

Shaun wrote:
 Hi,
 
 Thanks for your reply, just had a thought: How secure would it be if I made 
 sure that the URL of the browser was www.mycms.com and only allow access to 
 pages in the /cms folder if true?
 
 Is this safe or an easy hack?
 
 
 Wolf [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 So, swap your CMS logins to use the same access code for the user, then
 use sessions to swap the mysql stuff in where needed.

 Or make it use a mysql call from the CMS login to access their mysql
 information from another table and do it that way.

 1 login, 1 password, very user friendly.

 And only 1 place to have to worry about changing files.

 HTH,

 Wolf


 Shaun wrote:
 I see your point, the only problem is that the user will have already 
 logged
 once into the CMS, logging in again would be a little frustrating and not
 very user friendly...


 Weber Sites LTD [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 I think that you are looking at this from the wrong angle.
 What you should do, is password protect all CMS directories
 And then, anyone that needs access has to punch in a valid
 Username and password.

 Have a look at : http://sourceforge.net/projects/modauthmysql/

 Sincerely

 berber

 Visit the Weber Sites Today,
 To see where PHP might take you tomorrow.
 PHP code examples : http://www.weberdev.com
 PHP  MySQL Forums : http://www.weberforums.com



 -Original Message-
 From: Shaun [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 17, 2006 2:52 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] Including files from another site

 Hi,

 Thanks for your reply, sorry I should have been a little clearer in my
 explanation. Here goes...

 I have a dedicated UNIX server with many websites on it. On this server 
 I
 have also created a Content Management System which has a database which 
 I
 use to store HTML content for all the other websites. Each website has a
 database connection to the CMS database to retrieve the HTML for its
 pages.

 Each website that uses its own database has a folder called /cms and in
 here
 I keep all the database admin scripts for that website. I want these 
 pages
 to only be accessible from within the CMS website and nothing else. So
 when
 the user is in the CMS they can click on database admin and it will
 include
 the pages in that websites /cms folder.

 My Question is how can I ensure that the CMS is the only website that 
 can
 access these scripts securely?

 Thanks for your advice.


 Weber Sites LTD [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 I'm not sure I understand what you are trying to do.
 What is the connection between frames and security?

 In general, assuming that all users have access to The same scripts,
 you need to include in all of your Scripts some kind of security logic
 that tells the Script which user can do what.

 Usually you would want to also allow group access Rather then user
 access for easier maintenance.

 You should keep a user table with user, password And privileges. There
 are endless ways to do this And you need to choose what is best for
 your site.

 Have a look at some relevant code examples:
 http://www.weberdev.com/AdvancedSearch.php?searchtype=titlesearch=aut
 h

 berber

 -Original Message-
 From: Shaun [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 17, 2006 12:46 PM
 To: php-general@lists.php.net
 Subject: [PHP] Including files from another site

 Hi,

 I have created a CMS where all sites on our server are administrated
 from one central site, and HTML content is stored in the CMS database.

 I want users to all control their sites database functions from the
 CMS site, but I want to keep the database and database admin scripts
 in the individual website account to keep things simple. So I need
 want to be able to include these scripts within the CMS site but keep
 them secure. I have tried using frames but I can't keep a session
 going in the database admin scripts, is there a better way to do this?

 Any advice would be greatly appreciated.

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

-- 
PHP General 

Re: [PHP] Including files from another site

2006-04-17 Thread Shaun
Thanks Wolf,

Will there be a problem keeping 2 sessions from 2 websites running in one 
browser?

I will need one to validate the CMS login and one running in the other 
website to ensure that $_SESSION['my_site'] is set?

BTW I'm sure you know, but image phising can be resolved with  mod_rewrite.


Wolf [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Personally I would use it as part of the session and verify it that way...

 ie: check to see if the $PHP_SELF is www.mycms.com, if not refresh the
 page to that URL automatically and then make them do the login.  Only
 after logging in does the session key get the mysite=true key or
 whatever you want to check for.

 That SHOULD keep it from getting hacked, as your basically verifying at
 the beginning that you are only allowing entry from your location.

 You should also be making sure that your server does not allow others to
 host primary images so that nobody could phish your site.  Paypal and
 chase are really lamely set up which is making phishing easier for
 people who use them.

 My $.02

 Wolf

 Shaun wrote:
 Hi,

 Thanks for your reply, just had a thought: How secure would it be if I 
 made
 sure that the URL of the browser was www.mycms.com and only allow access 
 to
 pages in the /cms folder if true?

 Is this safe or an easy hack?


 Wolf [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 So, swap your CMS logins to use the same access code for the user, then
 use sessions to swap the mysql stuff in where needed.

 Or make it use a mysql call from the CMS login to access their mysql
 information from another table and do it that way.

 1 login, 1 password, very user friendly.

 And only 1 place to have to worry about changing files.

 HTH,

 Wolf


 Shaun wrote:
 I see your point, the only problem is that the user will have already
 logged
 once into the CMS, logging in again would be a little frustrating and 
 not
 very user friendly...


 Weber Sites LTD [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 I think that you are looking at this from the wrong angle.
 What you should do, is password protect all CMS directories
 And then, anyone that needs access has to punch in a valid
 Username and password.

 Have a look at : http://sourceforge.net/projects/modauthmysql/

 Sincerely

 berber

 Visit the Weber Sites Today,
 To see where PHP might take you tomorrow.
 PHP code examples : http://www.weberdev.com
 PHP  MySQL Forums : http://www.weberforums.com



 -Original Message-
 From: Shaun [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 17, 2006 2:52 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] Including files from another site

 Hi,

 Thanks for your reply, sorry I should have been a little clearer in my
 explanation. Here goes...

 I have a dedicated UNIX server with many websites on it. On this 
 server
 I
 have also created a Content Management System which has a database 
 which
 I
 use to store HTML content for all the other websites. Each website has 
 a
 database connection to the CMS database to retrieve the HTML for its
 pages.

 Each website that uses its own database has a folder called /cms and 
 in
 here
 I keep all the database admin scripts for that website. I want these
 pages
 to only be accessible from within the CMS website and nothing else. So
 when
 the user is in the CMS they can click on database admin and it will
 include
 the pages in that websites /cms folder.

 My Question is how can I ensure that the CMS is the only website that
 can
 access these scripts securely?

 Thanks for your advice.


 Weber Sites LTD [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 I'm not sure I understand what you are trying to do.
 What is the connection between frames and security?

 In general, assuming that all users have access to The same scripts,
 you need to include in all of your Scripts some kind of security 
 logic
 that tells the Script which user can do what.

 Usually you would want to also allow group access Rather then user
 access for easier maintenance.

 You should keep a user table with user, password And privileges. 
 There
 are endless ways to do this And you need to choose what is best for
 your site.

 Have a look at some relevant code examples:
 http://www.weberdev.com/AdvancedSearch.php?searchtype=titlesearch=aut
 h

 berber

 -Original Message-
 From: Shaun [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 17, 2006 12:46 PM
 To: php-general@lists.php.net
 Subject: [PHP] Including files from another site

 Hi,

 I have created a CMS where all sites on our server are administrated
 from one central site, and HTML content is stored in the CMS 
 database.

 I want users to all control their sites database functions from the
 CMS site, but I want to keep the database and database admin scripts
 in the individual website account to keep things simple. So I need
 want to be able to include these scripts within the CMS site but keep
 them secure. I have 

Re: [PHP] Table formation...

2006-04-17 Thread Jochem Maas

..



Jochem:

Oh, I wasn't defending Jay -- I didn't even know anything was in 
dispute. I'm clueless as usual -- just putting in my $0.02 as I can.


I'm luckyh if I have .01 to throw around ;-)



Hell, I have enough problems trying to remember to remove your email 
address when I reply to all. :-)


I thought the 'rule' around here was do a 'reply to all' - someone
put me right if I've been an idiot all this time!

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



Re: [PHP] Table formation...

2006-04-17 Thread Ray Hauge
On Monday 17 April 2006 14:04, Jochem Maas wrote:
 I thought the 'rule' around here was do a 'reply to all' - someone
 put me right if I've been an idiot all this time!

I use Kmail, and it has a feature to just reply to the mailing list, so I 
generally use that.  Reply to all is definitely easier than taking out the 
person's email address.  Probably a good rule to make sure posts are posted 
to the list, and not just the person who you're replying to ;)

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Including files from another site

2006-04-17 Thread Wolf
2 websites, or 2 web servers?  Depends on the setup.  Since you are
leaving and going then it normally is a problem, in my experience,
with them.  What I do in cases of that is to pass a session value along
via posting the data.  Not always pretty, but it works.  I guess the
real determining factor is how the data is being passed, the flow of the
bits so to speak.

IE: if the users are on their site logged in and it pulls information
from yours, then you will need to access their own sessions, not yours.
 however if they are logged into your site and accessing data on theirs,
you need your session and to pass it over to theirs.  The information
path is the only way to really get a good picture, most of the time in
cases where I had this happen, I had them log into one location and
copied the files they would need to their server.  I could always rsync
their files from my server via a cron job or set php command script when
needed.

One thing you might also look at is a cookie.  Not sure if you can write
a cookie that both sites will be able to use or not, but that might be a
way to hide their information for the pass through.  IE: set the cookie
from one site with access information for the other site...
?php
 setcookie(uname, $name, time()+36);
?

?php
if (!isset($_COOKIE[uname]))
 { go login }
else
 {
  give new cookie, or move data to session only
  setcookie(uname, $name, time()-36);
 }
?

It might work that way as well, never tried it in practice, but
logically it just might.


And yeah, mod_rewrite works for it, but like I said, just something to
keep an eye out for, depending on how concerned you are with someone
phishing.

Shaun wrote:
 Thanks Wolf,
 
 Will there be a problem keeping 2 sessions from 2 websites running in one 
 browser?
 
 I will need one to validate the CMS login and one running in the other 
 website to ensure that $_SESSION['my_site'] is set?
 
 BTW I'm sure you know, but image phising can be resolved with  mod_rewrite.
 
 
 Wolf [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 Personally I would use it as part of the session and verify it that way...

 ie: check to see if the $PHP_SELF is www.mycms.com, if not refresh the
 page to that URL automatically and then make them do the login.  Only
 after logging in does the session key get the mysite=true key or
 whatever you want to check for.

 That SHOULD keep it from getting hacked, as your basically verifying at
 the beginning that you are only allowing entry from your location.

 You should also be making sure that your server does not allow others to
 host primary images so that nobody could phish your site.  Paypal and
 chase are really lamely set up which is making phishing easier for
 people who use them.

 My $.02

 Wolf

 Shaun wrote:
 Hi,

 Thanks for your reply, just had a thought: How secure would it be if I 
 made
 sure that the URL of the browser was www.mycms.com and only allow access 
 to
 pages in the /cms folder if true?

 Is this safe or an easy hack?


 Wolf [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 So, swap your CMS logins to use the same access code for the user, then
 use sessions to swap the mysql stuff in where needed.

 Or make it use a mysql call from the CMS login to access their mysql
 information from another table and do it that way.

 1 login, 1 password, very user friendly.

 And only 1 place to have to worry about changing files.

 HTH,

 Wolf


 Shaun wrote:
 I see your point, the only problem is that the user will have already
 logged
 once into the CMS, logging in again would be a little frustrating and 
 not
 very user friendly...


 Weber Sites LTD [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 I think that you are looking at this from the wrong angle.
 What you should do, is password protect all CMS directories
 And then, anyone that needs access has to punch in a valid
 Username and password.

 Have a look at : http://sourceforge.net/projects/modauthmysql/

 Sincerely

 berber

 Visit the Weber Sites Today,
 To see where PHP might take you tomorrow.
 PHP code examples : http://www.weberdev.com
 PHP  MySQL Forums : http://www.weberforums.com



 -Original Message-
 From: Shaun [mailto:[EMAIL PROTECTED]
 Sent: Monday, April 17, 2006 2:52 PM
 To: php-general@lists.php.net
 Subject: Re: [PHP] Including files from another site

 Hi,

 Thanks for your reply, sorry I should have been a little clearer in my
 explanation. Here goes...

 I have a dedicated UNIX server with many websites on it. On this 
 server
 I
 have also created a Content Management System which has a database 
 which
 I
 use to store HTML content for all the other websites. Each website has 
 a
 database connection to the CMS database to retrieve the HTML for its
 pages.

 Each website that uses its own database has a folder called /cms and 
 in
 here
 I keep all the database admin scripts for that website. I want these
 pages
 to only be accessible from within the CMS website 

RE: [PHP] How can I see where my script wasting time?

2006-04-17 Thread afan
Yes, I have indexes but can't say they are done perfectly though.
:)


-afan

 [snip]
 I was developing one site with fake records in DB. Now, I put it live
 whit
 real records. The site is running ok, but it's painfully slow. Even for
 grabbing an order from DB and showing it on screen, from 1-2 sec (while
 developing) went to almost 10-15 sec?!? No, of records for orders is a
 little bit over 200,000 - what is not so much.

 I'm assuming that the problem is not in the script than in the way I
 built
 queries.

 My question is how can I check what's taking so long in execution of the
 script/query?
 Where to start with improving the script?
 [/snip]

 Probably not the script. Do you have indexes on your tables?


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



RE: [PHP] How can I see where my script wasting time?

2006-04-17 Thread Richard Lynch
On Mon, April 17, 2006 4:17 pm, [EMAIL PROTECTED] wrote:
 Yes, I have indexes but can't say they are done perfectly though.
 :)

Did you test on your test server with the same number of records as
real and the same kind of load?...

If not, you really need to think about doing that before you deploy to
a live server, eh? :-) :-) :-)

The simplest/crudest way for a small script/application is to just
sprinkle in a bunch of calls to microtime.

In PHP5, microtime(true) is particularly simple/useful.

?php
  $run_id = uniqid(); //To distinguish this HTTP response from others
  $benchmark['start'] = microtime(true);
  sleep(30);
  $benchmark['yawn'] = microtime(true);

  //at end of script:
  //debug or not:
  if (1){
//to screen:
if (1) echo table border=\1\\n;
$start_time = $benchmark['start'];
$previous = $start_time;
foreach($benchmark as $event = $time){
  $delta = $time - $previous;
  $total = $time - $start_time;
  if (1) echo  
trtd$event/tdtd$delta/tdtd$total/td/tr\n;
  //to error log:
  if (1) error_log($run_id- $event: $delta $totla);
  $previous = $time;
}
if (1) echo /table\n;
  }
?

It usually is as simple as that, because you'll find one MONSTER thing
taking up all the CPU time, and the rest taking up micro-seconds and
not worth worrying about.

You can change some of the 1 to 0 to turn them on/off.

You'd have to call microtime() and fill up $benchmark with a hell of a
lot of entries for this to impact your script in any meaningful way.

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

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



Re: [PHP] real time output from log file?

2006-04-17 Thread Richard Lynch
On Mon, April 17, 2006 11:45 am, Jason Gerfen wrote:
 Anyone use php to tail a log file for patterns and perhaps updating a
 iframe or something similar?  If so do you have a link to some
 resources
 on it?

No, but I don't see how you could make this much more complicated than:

html
  headmeta http-equiv=refresh url=0;httpd_error_log_tail.php
//head
  body bgcolor=#ff
?php
  exec(tail /var/log/httpd/error_log, $output, $error);
  echo nl2br(htmlentities(implode(, $output)));
  if ($error) echo hr /bOS Error: $error/b\n;
?
  /body
/html

But maybe I'm just too much a K.I.S.S. kind of guy...

Though why one wouldn't juse use SSH to do this in the first place is
beyond me...

But they had guys at an old job that did this, after I turned OFF
display_output on their production server...  [shudder]

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

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



Re: [PHP] Including files from another site

2006-04-17 Thread Richard Lynch
On Mon, April 17, 2006 5:45 am, Shaun wrote:
 I have created a CMS where all sites on our server are administrated
 from
 one central site, and HTML content is stored in the CMS database.

 I want users to all control their sites database functions from the
 CMS
 site, but I want to keep the database and database admin scripts in
 the
 individual website account to keep things simple. So I need want to be
 able
 to include these scripts within the CMS site but keep them secure. I
 have
 tried using frames but I can't keep a session going in the database
 admin
 scripts, is there a better way to do this?

 Any advice would be greatly appreciated.

If you trust the source, you could just do:

?php
  include 'http://example.com/central_core_files_shared_by_all.inc';
?

Or, if all these sites are on the same box, you don't even need to use
HTTP for the include...

Exactly what are you trying to secure against?

You make it sound like keep them secure is an absolute. It's not. 
It's relative.

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

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



Re: [PHP] New Date/Time Functionality and Setting Timezones

2006-04-17 Thread Richard Lynch
On Mon, April 17, 2006 1:15 am, Lester Caine wrote:
 Of cause this still does nothing for the vast majority of hosting,
 where
 it's the timezone/daylight saving of the client that you need, not the
 server :(

The timezone/ds of the client is way beyond the scope of PHP...

I *would* like to be able to set up my hosted sites in Portland so
that they seem to be in Chicago, though, without jumping through
hoops.

Or, in some cases, just telling clients why their time seems off
from what their website thinks it is.

I'm not sure what it would break to change this, but if the default in
php.ini is not set, then I'd probably vote +1 on changing the order,
personally.

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

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



Re: [PHP] Fatal error: Unsupported operand types

2006-04-17 Thread Richard Lynch


Odds are really good that you are trying to add (+) something that
ain't a number...

Just print_r() each variable within that function and see what you did.

On Sun, April 16, 2006 5:35 am, kmh496 wrote:

 can somebody explain why

 $this-param = $this-SYSTEM-db-answer + $this-param;

 is causing the error


 Fatal error: Unsupported operand types
 in /var/www/current/mjguest/modules/settings.php on line 52



 context is


 function settings($SYSTEM)
 {
 $this-SYSTEM = $SYSTEM;
 $this-SYSTEM-db-ask(1, 'settings_load');
 $this-SYSTEM-db-get_row();

 $this-param = $this-SYSTEM-db-answer + $this-param;
 }




 --
 my site a href=http://www.myowndictionary.com;myowndictionary/a
 was
 made to help students of many languages learn them faster.

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




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

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



Re: [PHP] phpMyAdmin--resetting auto increments to 0

2006-04-17 Thread Richard Lynch
You can, but it has nothing to do with PHP, and you shouldn't anyway.

If you *CARE* about the ID numbers, then you're doing something wrong
in the first place.

On Sun, April 16, 2006 1:46 am, alex wrote:
 hi everyone

 i have delete a few entries in my database as they were entered for
 testing
 purposes and are no longer need (actually 102 entries)... and even
 thought
 that db is empty i noticed that when the next entry went in the id
 number
 went to 103
 not 0 so i was wondering is it possible to somehow reset the value to
 zero...

 it is of int type and auto_increment

 i have a few db's which id like to reset to zero i have tried placing
 a zero
 enrty after deleting the lot but it only jumps to  its next increment.
 does anyone know what i mean...?
 any help will be grateful
 regards alex

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




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

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



Re: [PHP] soapmapper error

2006-04-17 Thread Richard Lynch
On Sat, April 15, 2006 2:48 pm, Alex Duggan wrote:
 I am trying to connect to a webservice with a wsdl.  After creating a
 new SoapClient, I tried calling one of the methods.  It returned this
 exception.

 Uncaught SoapFault exception: [SOAP-ENV:Server] SoapMapper:Converting
 data for SoapMapper failed inside the typemapper
 in /home/aldug/soap_test.php

 Other methods on this webservice work fine.  How do I go about
 debugging
 this problem?

Some suggestions:

Set up the simplest shortest script you can to create something of the
type that causes the problem, and see if you can still break it.

Examine the WSDL *very* carefully, watching for indicators that you
were supposed to supply an array of Widget instead of a Widget and
that sort of thing.

Google for the website URL, vendor, error message, service name,
and/or data type in question.

[After the above]
Contact the vendor of that SOAP service -- they may have had another
PHP user with the same problem before, if it's something funky on
their end.

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

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



Re: [PHP] Including files from another site

2006-04-17 Thread Shaun

Richard Lynch [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On Mon, April 17, 2006 5:45 am, Shaun wrote:
 I have created a CMS where all sites on our server are administrated
 from
 one central site, and HTML content is stored in the CMS database.

 I want users to all control their sites database functions from the
 CMS
 site, but I want to keep the database and database admin scripts in
 the
 individual website account to keep things simple. So I need want to be
 able
 to include these scripts within the CMS site but keep them secure. I
 have
 tried using frames but I can't keep a session going in the database
 admin
 scripts, is there a better way to do this?

 Any advice would be greatly appreciated.

 If you trust the source, you could just do:

 ?php
  include 'http://example.com/central_core_files_shared_by_all.inc';
 ?

 Or, if all these sites are on the same box, you don't even need to use
 HTTP for the include...

 Exactly what are you trying to secure against?

 You make it sound like keep them secure is an absolute. It's not.
 It's relative.

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

Hi Richard,

The security issue is important because I don't want anyone to be able to 
use the websites database admin scripts without logging into the CMS first. 
Otherwise anyone who happened to type in www.oneofmywebsites.com/cms would 
be able to make unwanted changes to that particular sites database.

In answer to your second question both sites will be on the same box... 

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



Re: [PHP] Table formation...

2006-04-17 Thread tedd

Jochem:

Hell, I have enough problems trying to remember to remove your 
email address when I reply to all. :-)


I thought the 'rule' around here was do a 'reply to all' - someone
put me right if I've been an idiot all this time!


Nooo, I wouldn't use the term... idiot. :-)

What I typically do in replying to a post (via Eudora for the Mac) is 
to select the Reply to All menu item. This takes everyone who's 
been involved in the thread and places their email addresses along 
with the main list address, in an email from me.


Then I type what I want; click Send; and everyone in the thread 
gets a copy PLUS the list gets a copy. Now, I don't know if this IS 
the thing to do, or not.


However, I do know that if I simply click Reply, then only the 
current poster is listed in my email. But, that sucks, because then I 
have to remove them and cut/paste the php-general list address -- and 
that's both time consuming and error-prone.


Now, add on to that, your request to receive NO direct email and then 
I have to:


1. Click Reply to All
2. Look to see if your involved in the thread.
3. If you are, then find and delete your email address and hope not 
to leave out a , or screw something else up.
4. If I do screw something up, then the error(s) comes back to me and 
I have to figure out a way to fix it, which sometimes means I have to 
re-post and start again.


SO -- would someone please enlighten me as to what is the proper way 
to work replies on this list?


Thanks.

tedd

PS: You're getting two copies of this Jochem because I can't figure 
out which not to send. :-)


--

http://sperling.com

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



Re: [PHP] return a formatted difference between two dates

2006-04-17 Thread Richard Lynch
On Fri, April 14, 2006 1:24 pm, jonathan wrote:
 is there a function to take a second count and return it as a
 formatted difference?

 like a date_diff('H hours i',6133)

 that uses date()'s formatting.

I think he means something not unlike:

function human_time($seconds){
  $result =  and  . ($seconds % 60) .  seconds;
  $seconds = floor($seconds/60);

  $result = ($seconds % 60)  minutes $result;
  $seconds = floor($seconds/60);

  $result = ($seconds % 24)  hours $result;
  $seconds = floor($seconds/24);

  $result = ($seconds % 30)  days $result;
  $seconds = floor($seconds/365);

  $result = ($seconds % 12)  months $result;
  $seconds = floor($seconds/12);

  $result = $seconds years $result;

  return $result;
}

That, however, is probably not precisely what he wants, as it's WAY
off in the months/years thing... :-)

This WOULD be a nice function to have built-in, but, unfortunately, a
big ol' can of worms is opened up for the months and at 365+ days --
namely that without a start-time, you can't tell how many years have
passed because you won't know if it was a leap year or not...

One has to wonder WHAT our ancestors where thinking when they decided
to make months have different lengths days and this whole leap year
thing...  I mean, the cure is worse than the disease, no?  Don't even
get me started on daylight savings and 15 minute time-zones. :-)

So maybe it could take an optional start-time and assuming dates in
the Unix-time range of 1/1/1970 to MAX_INT do a credible job of it.

Then you'd need directives sort of like date() has for whether to
print out, say, XX seconds if the number is evenly divisible by 60,
or whether to use 0, space, or no prefix for numbers  10, plus...

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

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



Re: [PHP] real time output from log file?

2006-04-17 Thread Jochem Maas

Richard Lynch wrote:

On Mon, April 17, 2006 11:45 am, Jason Gerfen wrote:


Anyone use php to tail a log file for patterns and perhaps updating a
iframe or something similar?  If so do you have a link to some
resources
on it?



No, but I don't see how you could make this much more complicated than:

html
  headmeta http-equiv=refresh url=0;httpd_error_log_tail.php
//head
  body bgcolor=#ff
?php
  exec(tail /var/log/httpd/error_log, $output, $error);
  echo nl2br(htmlentities(implode(, $output)));
  if ($error) echo hr /bOS Error: $error/b\n;
?
  /body
/html

But maybe I'm just too much a K.I.S.S. kind of guy...


which has nothing to do with the Oprah show about sex-addicts I
just half-watched. :-)



Though why one wouldn't juse use SSH to do this in the first place is
beyond me...


I second that.



But they had guys at an old job that did this, after I turned OFF
display_output on their production server...  [shudder]


I guess Richard's had another long day ... display_output? maybe
display_errors? or was the stuff those guys produced so bad that a
blank page was preferable? ;-)





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



Re: [PHP] Table formation...

2006-04-17 Thread tedd

Hey:

Didn't anyone like my --

Whenever I need a 1 or 0, I use ($i  1).

-- comment?

I though that was pretty clever, but no one even said How's your Mum?.

tedd

--

http://sperling.com

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



[PHP] make test on new extension

2006-04-17 Thread Richard Lynch
If you write a new extension and have:

 ~/php-src
  /ext
  /MYEXT
/tests
  /MYEXT00.phpt

then when you run make test in ~/php-src, it should just run the new
test, right???

run-test.php ext/MYEXT/tests/MYEXT00.phpt works fine...

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

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



Re: [PHP] Sessions Issues With 2 Instances On Same Server

2006-04-17 Thread Richard Lynch
On Thu, April 13, 2006 9:10 pm, Mark Sargent wrote:
 I'm looking at OSCommerce, and have been asked if running 2 instances
 on
 the same server would be doable. I only foresee perhaps issues with
 sessions. Has anyone got any thoughts on this? I'd be very
 appreciative
 of any help with this. I have installed already 2 instances on a test
 machine here at work. Cheers.

To know for sure, you'd have to ask an OSCommerce list...

Assuming they used standard PHP sessions, the number of installs is
irrelevant -- each session ID is unique because it is generated on the
first request.

The uniqueness isn't GUARANTEED, though.

Depending on your OS and what arguments you pass in to the uniqid
function, you're looking at the odds in your favor being AT LEAST 2
billion to 1.  Them's pretty good odds.

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

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



Re: [PHP] Including files from another site

2006-04-17 Thread tedd

The security issue is important because I don't want anyone to be able to
use the websites database admin scripts without logging into the CMS first.
Otherwise anyone who happened to type in www.oneofmywebsites.com/cms would
be able to make unwanted changes to that particular sites database.


From previous reply, I know you believe two log-in's are not user 
friendly, but (from my reading) that's what the big boys do (i.e., 
eBay, Amazon) for a more secure log-in.


I don't filly understand it, but from what I've read it's a 
combination of both your log-on/password and a session ID -- but 
then, a second log-in changes the session id which makes it more 
difficult to hack.


HTH's

tedd

--

http://sperling.com

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



Re: [PHP] real time output from log file?

2006-04-17 Thread Richard Lynch
On Mon, April 17, 2006 6:19 pm, Jochem Maas wrote:
 But they had guys at an old job that did this, after I turned OFF
 display_output on their production server...  [shudder]

 I guess Richard's had another long day ... display_output? maybe
 display_errors? or was the stuff those guys produced so bad that a
 blank page was preferable? ;-)

Actually, now that I think about it...

Maybe we need a new directive in php.ini :-)

;Turns off all output to browser
;Useful when somebody realizes how bad their software really is
;Or when they get sued for same
;display_output = On

:-) :-) :-)

The REALLY scary thing was their application was all about people's
medical records and insurance -- so they were HIPPA compliant.

Don't even ask me how display_errors on production boxes seemed OK
with HIPPA compliant software in ANYBODY's brain, cuz I just don't
get it...

PS
In retrospect, I turned off display_errors on all servers, production
and dev, because they had no way to detect production versus dev in
the first place, in a meaningful way to have them behave differently.

I think I fixed that problem next, and would have turned
display_errors back on, but they already had their tail.php script,
and it avoided a lot of questions from programmers too naive to do
View Source

I also turned on E_NOTICE in the same time frame, so they had a LOT of
bugs to fix :-)

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

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



Re: [PHP] Dates before 1970

2006-04-17 Thread Richard Lynch
Call me crazy, but I think that:

$time = 0x; //largest INT possible
echo date('m/d/Y h:i:s a', $time);

would be very revealing.

On Thu, April 13, 2006 10:26 pm, Suhas wrote:
 This will definitely solve one way but still other is there,
 How to get that -ve number which starts at 1/1/1900 at 00:00 AM = 0

 I need to be able to convert back and forth as there are some
 calculations to be done on date field,

 But this is very interesting..
 Thx
 SP

 On 4/13/06, Rasmus Lerdorf [EMAIL PROTECTED] wrote:
 Suhas wrote:
  Hello,
 
  I have a project that deals with the date time stamps since 1900
 (and
  past), any suggestions about a good class that handles Date Time
  Format before 1970. I really like date() function and want
 something
  similar.

 date() uses Unix timestamps which on most Unix platforms goes from
 -MAX_INT to MAX_INT which means the date range is actually
 12:45:52 12/13/1901 to 07:14:07 01/18/2038.  So you might be able to
 get
 away with it.

 You can check it with:

 echo date(h:i:s m/d/Y,-2147483648);
 echo date(h:i:s m/d/Y, 2147483647);

 Windows, not being Unix, doesn't understand that the timestamp can
 be
 negative, although I think someone fixed that in PHP 5.  In my 11+
 years
 of PHP I have yet to run PHP on Windows, so I wouldn't know.

 -Rasmus



 --
 Contact @
 Suhas Pharkute.
 208 830 8915 (C)
 208 429 6943 (H)

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




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

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



Re: [PHP] httpd: PHP Notice: Undefined index: autoplay

2006-04-17 Thread Richard Lynch
On Thu, April 13, 2006 1:44 am, Noah wrote:
 I just upgraded to apache2.2.0 and reinstalled php4-4.4.2_1 on a
 FreeBSD 4.11
 machine.  I am trying to make sure that my PHP is properly installed
 and
 configured.

 I am seeing the following PHP Notice about 10 entries a day in my
 /var/log/messages in regards to:

 --- snip --

 httpd: PHP Notice:  Undefined index:  autoplay in
 /a/www/data/filname/garbled/radio.blog/index.php on line 9

 --- snip ---

 I am not quite sure what to do to make sure things are operating
 properly.
 Might someone lend a hand here?

This E_NOTICE has always been there -- But your old php.ini was
probably using E_ALL  ~E_NOTICE and your new php.ini is probably
using E_ALL, so you are now *seeing* this error (of error-level
E_NOTICE) for the first time.

What it means is that you are looking in some array for an index of
'autoplay' and that index has never been set, and that's a sign of Bad
Programming.

It's in this file:
/a/www/data/filname/garbled/radio.blog/index.php

It's on line 9.

It looks something like one of these:
... $some_array['autoplay']...
... ...$some_array[autoplay]...

In fact, based on what I now about radio blogs, and the concept of
autoplay, I'm put odds on $some_array being one of:
$_GET
$_POST
$_REQUEST
$_COOKIE

But that's just a guess.

The way to fix it is to do something like:

if (isset($some_array['autoplay'])){
  //your old line 9 goes here, for sure, with maybe some more lines
}

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

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



Re: [PHP] real time output from log file?

2006-04-17 Thread Jochem Maas

Richard Lynch wrote:

On Mon, April 17, 2006 6:19 pm, Jochem Maas wrote:


But they had guys at an old job that did this, after I turned OFF
display_output on their production server...  [shudder]


I guess Richard's had another long day ... display_output? maybe
display_errors? or was the stuff those guys produced so bad that a
blank page was preferable? ;-)



Actually, now that I think about it...

Maybe we need a new directive in php.ini :-)


I dare you to ask on php-internals ;-)



;Turns off all output to browser
;Useful when somebody realizes how bad their software really is
;Or when they get sued for same
;display_output = On

:-) :-) :-)

The REALLY scary thing was their application was all about people's
medical records and insurance -- so they were HIPPA compliant.

Don't even ask me how display_errors on production boxes seemed OK
with HIPPA compliant software in ANYBODY's brain, cuz I just don't
get it...

PS
In retrospect, I turned off display_errors on all servers, production
and dev, because they had no way to detect production versus dev in
the first place, in a meaningful way to have them behave differently.

I think I fixed that problem next, and would have turned
display_errors back on, but they already had their tail.php script,
and it avoided a lot of questions from programmers too naive to do
View Source


the only thing that annoys me is that these numpties probably earn twice
what I do, pay a third the price for their cars and drive from one end
of the american continent to the other for the same price as I pay in petrol
(gas) to sit in traffic for 5 minutes. (teach me to be european I guess ;-)

and boy do I need (read want) a new car :-P



I also turned on E_NOTICE in the same time frame, so they had a LOT of
bugs to fix :-)


thanks for another great story from the trenches Richard :-)

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



Re: [PHP] Table formation...

2006-04-17 Thread Jochem Maas

tedd wrote:

Jochem:



...



Thanks.

tedd

PS: You're getting two copies of this Jochem because I can't figure out 
which not to send. :-)


I get double copies of most replies to stuff I've written on this list,
it doesn't bother me at all  - the only annoyance is the ID10Ts that have been
here 5 seconds and then start mailing you offlist consistently (as I have a sign
on my head saying I'll do _your_ work for nothing - and even if I do how do
they know that? I don't have a cam you can hijack ;-)

actually thinking about it - given that all posts marked '[PHP]' end up in the
same folder - the double posts act like a heads-up that someone is 'talking' to
me :-).

heck everyone forgets to reply to the list once in a while! niether you nor
I are at the top of the php foodchain but we generally get let off occasional
f*** ups because other _seem_ to recognize we are fairly active in offering
what help we can. (with exception of Jasper, who is thoroughly convinced of
my complete lack of knowledge regarding php - from which one can conclude that
he probably doesn't consider anything I have to say helpful ;-)





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



Re: [PHP] Table formation...

2006-04-17 Thread Jochem Maas

How's your Mum?

tedd wrote:

Hey:

Didn't anyone like my --

Whenever I need a 1 or 0, I use ($i  1).

-- comment?

I though that was pretty clever, but no one even said How's your Mum?.


well it's a basic bitwise operation, anyone who has been doing for a while
wouldn't think much of it and people who are not yet aware of bitwise operations
will probably gloss over it.

that said how often do you _really_ need a 1 or a 0, let's assume that your
code has an $i and the code can be certain it's an integer then converting it
to 1 or 0 is not that different to casting to a boolean, I'm assuming that the
1 or 0 are used to detemine an on/off state. is my assumption correct?
if so then take another good look at the way php autocasts variables,
for instance tyr running this:

$zero = 0; $one = 1;
var_dump(

(false == $zero),
(true == $one),

((bool)$zero),
($zero  1),
((bool)($zero  1)),

((bool)$one),
($one  1),
((bool)($one  1))

);



tedd



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



Re: [PHP] Table formation...

2006-04-17 Thread Richard Lynch
On Mon, April 17, 2006 7:14 pm, Jochem Maas wrote:
 tedd wrote:
 Hey:

 Didn't anyone like my --

 Whenever I need a 1 or 0, I use ($i  1).

 -- comment?

 I though that was pretty clever, but no one even said How's your
 Mum?.

I don't like it for 2-column display or alternating row color, because
it's not easily extended to 3-column or tri-color in an obvious way.

But I missed your original post, so shouldn't comment. :-)

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

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



[PHP] [SOLVED] RE: [PHP] How can I see where my script wasting time?

2006-04-17 Thread afan
Yes, it was problem with indexing and with help of explain select I got
really decent speed.

tanks to all for big help!

-afan


 [snip]
 I was developing one site with fake records in DB. Now, I put it live
 whit
 real records. The site is running ok, but it's painfully slow. Even for
 grabbing an order from DB and showing it on screen, from 1-2 sec (while
 developing) went to almost 10-15 sec?!? No, of records for orders is a
 little bit over 200,000 - what is not so much.

 I'm assuming that the problem is not in the script than in the way I
 built
 queries.

 My question is how can I check what's taking so long in execution of the
 script/query?
 Where to start with improving the script?
 [/snip]

 Probably not the script. Do you have indexes on your tables?


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



Re: [PHP] return a formatted difference between two dates

2006-04-17 Thread tedd

At 6:17 PM -0500 4/17/06, Richard Lynch wrote:

On Fri, April 14, 2006 1:24 pm, jonathan wrote:

 is there a function to take a second count and return it as a

  formatted difference?



That, however, is probably not precisely what he wants, as it's WAY
off in the months/years thing... :-)

This WOULD be a nice function to have built-in, but, unfortunately, a
big ol' can of worms is opened up for the months and at 365+ days --
namely that without a start-time, you can't tell how many years have
passed because you won't know if it was a leap year or not...


As I understand it, it won't make any difference if you use strtotime()

See: http://www.weberdev.com/strtotime

That's a neat function because it's usually smarter (with respect to 
date) than the person who is using it. For example, you can add 60 
days to Jan 1 and it will give you March 1 unless it's a leap year 
where it gives you February 29 -- neat huh? (I hope my math is right).



One has to wonder WHAT our ancestors where thinking when they decided
to make months have different lengths days and this whole leap year
thing...  I mean, the cure is worse than the disease, no?  Don't even
get me started on daylight savings and 15 minute time-zones. :-)


Oh, now you got me started. :-)

NOTE: Nothing below is PHP related -- so stop reading NOW -- unless 
you have the time, or want to learn about it.


tedd's rant

You wonder about our ancestors?

Our ancestors were pretty smart with respect to time. As far back as 
15,000 years ago, they were detecting and predicting the Equinox 
(i.e., Stonehenge). 10,000 years ago, they computed the age of the 
universe (get this) to be 15 billion years old (way to go Buddhist 
monks). 5000 years ago, they detected the Precession of the Earth, 
which takes 26,000 years to revolve (way to go American Indian). 4000 
years ago, an Egyptian figured the circumstance of the Earth within 
less than a 5% error and his culture built Pyramids that were square 
within 1/4 inch (sorry not time related). Back to point, the Incas 
had calendars that accurately predicted solar and lunar eclipses far 
into the future (some say they still work).


As for the Western calendar, I agree it's has been a bit hard to 
compute -- but there are reasons why. Our ancestors were faced with 
something that isn't easily resolved as one becomes more and more 
accurate measuring time passing -- like the day of the week for 
example.


First of all, we ought to stop at year 1583. Prior to that, the day 
of the week cannot be calculated (it can -- but the algorithm is very 
complex).


In order to understand why we can't calculate the week day, we need 
to look at the calendar history.


Prior to Julius Caesar (100-44 B.C) ruling Rome the Roman year was 
354 days long. When Julius came to power (49-45 B.C.), one of his 
first challenge was to appease the farmers who complained big time 
because according to their calendar it was spring time and time to 
sow/plant but actually it was mid winter.


Julius hired Sosigenes of Alexandria (a mathematician) to figure out 
what went wrong. A tub of wine and a couple of girls later, Sosigenes 
suggested that the length of the year was wrong. It should have been 
365.25 days. The extra .25 day after four years became the extra day 
added in February.


Julius made a mess of 46 B.C. by adding a couple of months (he made 
money on taxes --BIG time) making 46 B.C. 445 days long!


Of course, Sosigenes, not having a calculator, didn't realize that a 
solar year is really 365.2428935 -- his calculations were too large 
by 10 minutes and some seconds for a year (not bad for manual 
computation back in 46 B.C.!)


This error after 1600 years, added up to about 11 days. This was 
detected by astronomers who noticed that the vernal equinox (when 
light and dark periods are equal in length) occurring on March 21 was 
becoming earlier and earlier and in 1582 it was on March 10.


Christopher Clarius, an astronomer, went to Pope Gregory XIII and 
addressed the concern. After seeing all the calculations for 7 
months, pope Gregory knocked off 11 days on October 4, 1582.


The next day, he decreed to be October 15 (so October 5-14 in the 
year 1582 didn't exist), but to not upset the Jews with their 
Sabbath, the day of the week was NOT changed. To avoid this error 
again after 1500 years, Pope Gregory, decreed that every 4 years a 
day will be added. However, on a turn of the century, it will only be 
added if it's divisible by 400. Hence, although year 2000 was a leap 
year -- year 1900 was not. SO, the proper test for a leap year:


A leap year is IF the year is evenly divisible by 4 AND is not the 
turn of the century. IF it is, it must be evenly divisible by 400 -- 
neat huh?


Did you know that this year (2006) we even added a leap second -- you 
don't want to know the computations for that.


It's difficult for anyone to do anything with 365.2428935(more to 
follow) days a year.


So, even now, we couldn't do 

Re: [PHP] Dates before 1970

2006-04-17 Thread tedd

At 6:43 PM -0500 4/17/06, Richard Lynch wrote:
Call me crazy, but I think that:

$time = 0x; //largest INT possible
echo date('m/d/Y h:i:s a', $time);

would be very revealing.


H.

Is: 12/31/1969 06:59:59 pm

Yes, it is -- I remember what I was doing then. It was six months 
after I got out of the US Army.


And,

$time = -0x; //smallest INT possible
echo date('m/d/Y h:i:s a', $time);

Is: 12/13/1901 03:45:52 pm

Close to when I was born. :-)

Whereas,

$time = 0;
echo date('m/d/Y h:i:s a', $time);

Is: 12/31/1969 07:00:00 pm

But, what point is there in all this?

tedd


--

http://sperling.com

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



[PHP] possible bug in date()

2006-04-17 Thread Mark Slater
I'm trying to create a date with the DATE_W3C or DATE_ATOM format (they are the same format 
according to the examples), but the output of date doesn't match the example in the documentation.


The http://us3.php.net/manual/en/ref.datetime.php page says the formats are as 
follows:

DATE_ATOM (string)
Atom (example: 2005-08-15T15:52:01+00:00)

DATE_W3C (string)
World Wide Web Consortium (example: 2005-08-15T15:52:01+00:00)

DATE_ISO8601 (string)
ISO-8601 (example: 2005-08-15T15:52:01+)


If I create a date with this code:

$this-dateCreated = date( DATE_ATOM, mktime( 0, 0, 0, 23, 2, 2006 ) );
echo $this-dateCreated;

I expect to see:

2006-02-23T00:00:00-08:00

The output I actually get is the ISO-8601 format:

2006-02-23T00:00:00-0800

The only difference is the colon in the GMT offset at the end.

Is the example output in the web page wrong? Or is this a bug in PHP?

Thanks,

Mark

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



[PHP] PDO on Win2000Server

2006-04-17 Thread Steve

Hi

I'm having trouble getting PDO to work on Windows 2000 Server with PHP
5.1.2.

I've enabled the extensions in php.ini, which was all I thought I had
to do. Is there anything else? I thought PDO would show up in phpinfo(), 
but it doesn't.


In my code, when I call:
new PDO(...);

I get an error:
Fatal error: Class 'PDO' not found in C:\...\pdo_query.php on line 15

This is whats recorded in my errors log:

[15-Apr-2006 10:38:15] PHP Warning:  PHP Startup: Unable to load
dynamic library 'C:\php\ext\php_pdo.dll' - %1 is not a valid Win32
application. in Unknown on line 0
[15-Apr-2006 10:38:15] PHP Warning:  PHP Startup: Unable to load
dynamic library 'C:\php\ext\php_pdo_firebird.dll' - The specified
module could not be found. in Unknown on line 0

Do you have any suggestions that could help me out?

Thanks

S.

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