php-general Digest 20 Apr 2008 03:17:00 -0000 Issue 5414

2008-04-19 Thread php-general-digest-help

php-general Digest 20 Apr 2008 03:17:00 - Issue 5414

Topics (messages 273300 through 273314):

Re: module access rights
273300 by: Ken Kixmoeller.com
273301 by: Ken Kixmoeller

Double billing problem
273302 by: tedd
273303 by: Dan Joseph
273304 by: Daniel Brown

newbie needs help with session variables
273305 by: Rod Clay
273307 by: revDAVE
273313 by: Warren Vail

Alter Table newbie help needed ...
273306 by: revDAVE
273308 by: Jason Norwood-Young
273310 by: revDAVE

Re: putting variables in a variable
273309 by: revDAVE

Re: PHP console script vs C/C++/C#
273311 by: Larry Garfield
273314 by: Nathan Nobbe

Re: OS X 10.5.2
273312 by: Lee Perry

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---


On Apr 19, 2008, at 2:37 AM, Alain Roger wrote:

Hi,

i'm very surprised... i did not get any answer to my previous post.
is it because it is good way to do it or because nobody knows ?
---

Hi,
i face now a little issue regarding how end user can access to some  
modules

of my web portal.

Let imagine we have several modules (let say: mod1, mod 2, mod3)  
and 2 users

(usr1, usr2).
i would like to use a simple way how to established access rights  
for each

user to grant/forbidden access to modules...


Or maybe the answer is as complicated as the question seems simple.

I have my master application object. On __construct, it checks the  
current user's rights from somewhere (a config file or a database,  
for example), and instantiates the application based on the rights  
profile.


Simple answer, but a lot of front-end work to implement.

Ken
---End Message---
---BeginMessage---
Right. Thanks for the links. This type of approach is the basis of my  
software architecture.


Ken

(BTW, don't forget to Reply All so your reply goes to the list, too).

On Apr 19, 2008, at 9:03 AM, Tony Marston wrote:
What you are describing is a Role Based Access Control (RBAC)  
system, and it

is not simple. Take a look at
http://www.tonymarston.net/php-mysql/role-based-access-control.html  
and

http://www.tonymarston.net/php-mysql/menuguide/index.html

Tony Marston

http://www.tonymarston.net
http://www.radicore.org




-Original Message-
From: Ken Kixmoeller.com [mailto:[EMAIL PROTECTED]
Sent: 19 April 2008 14:33
To: PHP General List
Subject: Re: [PHP] module access rights



On Apr 19, 2008, at 2:37 AM, Alain Roger wrote:

Hi,

i'm very surprised... i did not get any answer to my

previous post. is

it because it is good way to do it or because nobody knows ?
---

Hi,
i face now a little issue regarding how end user can access to some
modules
of my web portal.

Let imagine we have several modules (let say: mod1, mod 2, mod3)
and 2 users
(usr1, usr2).
i would like to use a simple way how to established access rights
for each
user to grant/forbidden access to modules...


Or maybe the answer is as complicated as the question seems simple.

I have my master application object. On __construct, it checks the
current user's rights from somewhere (a config file or a database,
for example), and instantiates the application based on the rights
profile.

Simple answer, but a lot of front-end work to implement.

Ken

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







---End Message---
---BeginMessage---

Hi gang:

I have a problem. I set up a PayPal billing for a client. It's pretty 
simple, the process sends the credit card information with payment 
required to PayPal and then PayPal clears the transaction and sends 
back a authorization. Everything works.


To stop the possibility of double billing, I did the following:

1. I check the database to see if the user has purchased the item 
before. If so, then I don't allow them to purchase again.


2. I placed a javascript routine to disable the Submit button for 
purchase after clicking once. That way, the user can only click it 
once.


3. The Submit button when clicked once will send the data gathered 
to another page (Submit the data to PayPal) that actually submits 
the data to PayPal. In that page I have a token that is assigned a 
value upon loading. If the user refreshes the page, then the non-zero 
token causes the page to destroy the sessions and redirect the user 
to another page requiring the user to enter the data again.


4. Inside the above Submit the data to PayPal I have another token 
that is assigned a value once the send the data to PayPal routine 
is triggered. Once the token is non-zero, the routine won't send 
anything to PayPal again.


However, even with all of this, 

[PHP] module access rights

2008-04-19 Thread Alain Roger
Hi,

i'm very surprised... i did not get any answer to my previous post.
is it because it is good way to do it or because nobody knows ?
thx.

Al.

---

Hi,
i face now a little issue regarding how end user can access to some modules
of my web portal.

Let imagine we have several modules (let say: mod1, mod 2, mod3) and 2 users
(usr1, usr2).
i would like to use a simple way how to established access rights for each
user to grant/forbidden access to modules.
i was thinking that a simple code like on linux could fit this need where i
could have execute/change/read access and this for each module.

for example, usr1 could have stored into DB the access rights 710 (knowing
that rights are based on mod3 | mod2 | mod1)
so usr1 :
- could execute some particular actions, change data and read data from
module 3
- could just read data for module 2
- does not have access to module 1

something similar for usr2 could be setup.

on each php pages/module, the user rights are checked and based on result,
the correct decision is taken by the web portal system.

i would like to know if such technique is a correct one, or if there is
something much more better ?

thanks a lot,

-- 
Alain

Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008



-- 
Alain

Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008


Re: [PHP] PHP console script vs C/C++/C#

2008-04-19 Thread Per Jessen
Nathan Nobbe wrote:

 On Fri, Apr 18, 2008 at 11:25 AM, Nick Stinemates
 [EMAIL PROTECTED] wrote:
 
 I don't think there was a single place where I said PHP was faster
 than C, nor did I imply it.
 
  Depends. Shitty algorithms are shitty, regardless of language
  implementation.
 
 implies that the same algorithm in different languages will not
 perform differently.  thats innacurate. 

No, that is actually a very accurate statement.  An algorithm will
perform equally well regardless of the language chosen.  How well the
actual implementation performs overall is a separate issue.  The
performance or rather efficiency of an algorithm is usually expressed
in the big-O notation, e.g.  O(n), O(log(n)) etc.  

A linear search is O(n), a quick sort is O(nlog(n)) (on average)  - both
perform equally bad or equally well regardless of which language you
choose to implement them in.

 the same algorithm w/o external dependencies, such as db calls, or
 calls to remote systems will run faster in java / c / c++ and others
 than it will in php. 

An algorithm doesn't have external dependencies - but implementations
might. 


/Per Jessen, Zürich


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



Re: [PHP] PHP console script vs C/C++/C#

2008-04-19 Thread Robert Cummings

On Sat, 2008-04-19 at 13:08 +0200, Per Jessen wrote:
 Nathan Nobbe wrote:
 
  On Fri, Apr 18, 2008 at 11:25 AM, Nick Stinemates
  [EMAIL PROTECTED] wrote:
  
  I don't think there was a single place where I said PHP was faster
  than C, nor did I imply it.
  
   Depends. Shitty algorithms are shitty, regardless of language
   implementation.
  
  implies that the same algorithm in different languages will not
  perform differently.  thats innacurate. 
 
 No, that is actually a very accurate statement.  An algorithm will
 perform equally well regardless of the language chosen.  How well the
 actual implementation performs overall is a separate issue.  The
 performance or rather efficiency of an algorithm is usually expressed
 in the big-O notation, e.g.  O(n), O(log(n)) etc.  
 
 A linear search is O(n), a quick sort is O(nlog(n)) (on average)  - both
 perform equally bad or equally well regardless of which language you
 choose to implement them in.
 
  the same algorithm w/o external dependencies, such as db calls, or
  calls to remote systems will run faster in java / c / c++ and others
  than it will in php. 
 
 An algorithm doesn't have external dependencies - but implementations
 might. 

You are correct about asymptotic bounds on algorithms; however,
languages can still have a constant multiplier affect on an algorithm.
Consider a rendering algorithm in language L.x that when given an input
I.c takes 5 days to complete... now take language L.y tha happens to
incurr a constant multiplier penalty of 4. Now giving the input I.c to
L.y we find that it takes 20 days to complete. Same algorithm, same
asymptotic bound, but a significant difference in competitiveness.
Asymptotic bounds (Big Oh) are useful, but their applicability isn't
always universal. Some algorithms that are asymptotically inferior
actually perform better on small input sets than their asymptotic
superiors... I don't recall for certain, but bubblesort might be one
such example.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] PHP console script vs C/C++/C#

2008-04-19 Thread Per Jessen
Robert Cummings wrote:

 You are correct about asymptotic bounds on algorithms; however,
 languages can still have a constant multiplier affect on an algorithm.

Absolutely.  When it comes to how long does it take to process 1000
elements, both language and hardware are critical factors.  But the
algorithm efficiency remains constant.

 Asymptotic bounds (Big Oh) are useful, but their applicability isn't
 always universal. Some algorithms that are asymptotically inferior
 actually perform better on small input sets than their asymptotic
 superiors... I don't recall for certain, but bubblesort might be one
 such example. 

Also true.  Quick sort is such an example - in general it does really
well, but for certain data sets, it doesn't.


/Per Jessen, Zürich


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



Re: [PHP] module access rights

2008-04-19 Thread Ken Kixmoeller.com


On Apr 19, 2008, at 2:37 AM, Alain Roger wrote:

Hi,

i'm very surprised... i did not get any answer to my previous post.
is it because it is good way to do it or because nobody knows ?
---

Hi,
i face now a little issue regarding how end user can access to some  
modules

of my web portal.

Let imagine we have several modules (let say: mod1, mod 2, mod3)  
and 2 users

(usr1, usr2).
i would like to use a simple way how to established access rights  
for each

user to grant/forbidden access to modules...


Or maybe the answer is as complicated as the question seems simple.

I have my master application object. On __construct, it checks the  
current user's rights from somewhere (a config file or a database,  
for example), and instantiates the application based on the rights  
profile.


Simple answer, but a lot of front-end work to implement.

Ken

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



Re: [PHP] module access rights

2008-04-19 Thread Ken Kixmoeller
Right. Thanks for the links. This type of approach is the basis of my  
software architecture.


Ken

(BTW, don't forget to Reply All so your reply goes to the list, too).

On Apr 19, 2008, at 9:03 AM, Tony Marston wrote:
What you are describing is a Role Based Access Control (RBAC)  
system, and it

is not simple. Take a look at
http://www.tonymarston.net/php-mysql/role-based-access-control.html  
and

http://www.tonymarston.net/php-mysql/menuguide/index.html

Tony Marston

http://www.tonymarston.net
http://www.radicore.org




-Original Message-
From: Ken Kixmoeller.com [mailto:[EMAIL PROTECTED]
Sent: 19 April 2008 14:33
To: PHP General List
Subject: Re: [PHP] module access rights



On Apr 19, 2008, at 2:37 AM, Alain Roger wrote:

Hi,

i'm very surprised... i did not get any answer to my

previous post. is

it because it is good way to do it or because nobody knows ?
---

Hi,
i face now a little issue regarding how end user can access to some
modules
of my web portal.

Let imagine we have several modules (let say: mod1, mod 2, mod3)
and 2 users
(usr1, usr2).
i would like to use a simple way how to established access rights
for each
user to grant/forbidden access to modules...


Or maybe the answer is as complicated as the question seems simple.

I have my master application object. On __construct, it checks the
current user's rights from somewhere (a config file or a database,
for example), and instantiates the application based on the rights
profile.

Simple answer, but a lot of front-end work to implement.

Ken

--
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] Double billing problem

2008-04-19 Thread tedd

Hi gang:

I have a problem. I set up a PayPal billing for a client. It's pretty 
simple, the process sends the credit card information with payment 
required to PayPal and then PayPal clears the transaction and sends 
back a authorization. Everything works.


To stop the possibility of double billing, I did the following:

1. I check the database to see if the user has purchased the item 
before. If so, then I don't allow them to purchase again.


2. I placed a javascript routine to disable the Submit button for 
purchase after clicking once. That way, the user can only click it 
once.


3. The Submit button when clicked once will send the data gathered 
to another page (Submit the data to PayPal) that actually submits 
the data to PayPal. In that page I have a token that is assigned a 
value upon loading. If the user refreshes the page, then the non-zero 
token causes the page to destroy the sessions and redirect the user 
to another page requiring the user to enter the data again.


4. Inside the above Submit the data to PayPal I have another token 
that is assigned a value once the send the data to PayPal routine 
is triggered. Once the token is non-zero, the routine won't send 
anything to PayPal again.


However, even with all of this, occasionally a user will be charged 
twice for the same purchase. Each charge is time-stamped and recorded 
in our database -- the times between duplicate purchases vary from 
from 3 to 23 seconds.


Now, my question is why? Is this a race issue or something similar?

And more importantly, what can I do about it?

Cheers,

tedd

PS: I have directed the question to PayPal as well.
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Double billing problem

2008-04-19 Thread Dan Joseph
On Sat, Apr 19, 2008 at 3:01 PM, tedd [EMAIL PROTECTED] wrote:

 Hi gang:

 I have a problem. I set up a PayPal billing for a client. It's pretty
 simple, the process sends the credit card information with payment required
 to PayPal and then PayPal clears the transaction and sends back a
 authorization. Everything works.

 To stop the possibility of double billing, I did the following:

 1. I check the database to see if the user has purchased the item before.
 If so, then I don't allow them to purchase again.

 2. I placed a javascript routine to disable the Submit button for
 purchase after clicking once. That way, the user can only click it once.

 3. The Submit button when clicked once will send the data gathered to
 another page (Submit the data to PayPal) that actually submits the data to
 PayPal. In that page I have a token that is assigned a value upon loading.
 If the user refreshes the page, then the non-zero token causes the page to
 destroy the sessions and redirect the user to another page requiring the
 user to enter the data again.

 4. Inside the above Submit the data to PayPal I have another token that
 is assigned a value once the send the data to PayPal routine is triggered.
 Once the token is non-zero, the routine won't send anything to PayPal again.

 However, even with all of this, occasionally a user will be charged twice
 for the same purchase. Each charge is time-stamped and recorded in our
 database -- the times between duplicate purchases vary from from 3 to 23
 seconds.

 Now, my question is why? Is this a race issue or something similar?

 And more importantly, what can I do about it?

 Cheers,

 tedd

 PS: I have directed the question to PayPal as well.
 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Does paypal offer duplicate transaction protection?  The merchant providers
I've worked with in the past has had it as part of their fraud protection
modules.  For instance, you can set it how soon after that card can be
charged again.  1 min, 5 mins, etc.  I found it a good final failsafe.

-- 
-Dan Joseph

Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life.


Re: [PHP] Double billing problem

2008-04-19 Thread Daniel Brown
On Sat, Apr 19, 2008 at 3:01 PM, tedd [EMAIL PROTECTED] wrote:
 Hi gang:

  I have a problem. I set up a PayPal billing for a client. It's pretty
 simple, the process sends the credit card information with payment required
 to PayPal and then PayPal clears the transaction and sends back a
 authorization. Everything works.

[snip!]

  PS: I have directed the question to PayPal as well.

When snipping the message like above, it sounds like you're
surprised it works and are suspicious much like when things work
out right with a Microsoft product.

As a resource, have you tried checking http://www.paypaldev.org/ ?

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



[PHP] newbie needs help with session variables

2008-04-19 Thread Rod Clay

Hi.  I'm still very new to php and still trying to learn the ropes.

I'm working on some code now trying to set up a session and use session 
variables in different scripts, but I'm getting this message:


*Warning*: Unknown: Your script possibly relies on a session side-effect 
which existed until PHP 4.2.3. Please be advised that the session 
extension does not consider global variables as a source of data, unless 
register_globals is enabled. You can disable this functionality and this 
warning by setting session.bug_compat_42 or session.bug_compat_warn to 
off, respectively. in *Unknown* on line *0


*2 questions:

1) I've turned on register_globals in all of my php.ini files and 
restarted the webserver, but I'm still getting this message.  Can anyone 
help me with this?


2) I get the idea that one should NOT turn on register_globals, but, if 
I don't do this, how do I share session variables between scripts (and 
avoid this message)?


Thanks for any help that anyone can provide.

Rod Clay
[EMAIL PROTECTED]
*


[PHP] Alter Table newbie help needed ...

2008-04-19 Thread revDAVE
Newbie - MAC - MAMP on port 8889

I have this connection to Mysql database called 'test'


Other Php stuff works ok but now I'm trying to alter the table (never did
that before...)



Connection called 'try1'...

?php
# FileName=Connection_php_mysql.htm
# Type=MYSQL
# HTTP=true
$hostname_try1 = 127.0.0.1:8889;
$database_try1 = test;
$username_try1 = test;
$password_try1 = test;
$try1 = mysql_pconnect($hostname_try1, $username_try1, $password_try1) or
trigger_error(mysql_error(),E_USER_ERROR);
?

The lines below don't error  but also don't do anything

I must be missing something here Right? Maybe it doesn't know to use
try1 connection? How do I add that?

?php
$sql = 'ALTER TABLE `ztest` ADD `myfield2` VARCHAR(10) NOT NULL;';
---or---
$sql = 'ALTER TABLE `ztest` RENAME TO `ztest2`;';

 ?





--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists]




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



Re: [PHP] newbie needs help with session variables

2008-04-19 Thread revDAVE
On 4/19/2008 2:20 PM, Rod Clay [EMAIL PROTECTED] wrote:

 Hi.  I'm still very new to php and still trying to learn the ropes.


...Blind leading the blind (I'm a newbie also but...)

Did you try...?

session_id()) 
session_start();

- - - - -
From: PHP: session_id - Manual
Location: http://us2.php.net/manual/en/function.session-id.php
- - - - -

session_id() is used to get or set the session id for the current session.

The constant SID can also be used to retrieve the current name and session
id as a string suitable for adding to URLs. See also Session handling.




- - - - -
From: PHP: session_start - Manual
Location: http://us2.php.net/manual/en/function.session-start.php
- - - - -

Description

bool session_start ( void )
session_start() creates a session or resumes the current one based on the
current session id that's being passed via a request, such as GET, POST, or
a cookie.

If you want to use a named session, you must call session_name() before
calling session_start().

session_start() will register internal output handler for URL rewriting when
trans-sid is enabled. If a user uses ob_gzhandler or like with ob_start(),
the order of output handler is important for proper output. For example,
user must register ob_gzhandler before session start.




 
 I'm working on some code now trying to set up a session and use session
 variables in different scripts, but I'm getting this message:
 
 *Warning*: Unknown: Your script possibly relies on a session side-effect
 which existed until PHP 4.2.3. Please be advised that the session
 extension does not consider global variables as a source of data, unless
 register_globals is enabled. You can disable this functionality and this
 warning by setting session.bug_compat_42 or session.bug_compat_warn to
 off, respectively. in *Unknown* on line *0
 
 *2 questions:
 
 1) I've turned on register_globals in all of my php.ini files and
 restarted the webserver, but I'm still getting this message.  Can anyone
 help me with this?
 
 2) I get the idea that one should NOT turn on register_globals, but, if
 I don't do this, how do I share session variables between scripts (and
 avoid this message)?
 
 Thanks for any help that anyone can provide.
 
 Rod Clay
 [EMAIL PROTECTED]
 *


--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists]




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



Re: [PHP] Alter Table newbie help needed ...

2008-04-19 Thread Jason Norwood-Young

On Sat, 2008-04-19 at 14:23 -0700, revDAVE wrote:
 Newbie - MAC - MAMP on port 8889
 
 I have this connection to Mysql database called 'test'
 
 
 Other Php stuff works ok but now I'm trying to alter the table (never did
 that before...)
 
 
 
 Connection called 'try1'...
 
 ?php
 # FileName=Connection_php_mysql.htm
 # Type=MYSQL
 # HTTP=true
 $hostname_try1 = 127.0.0.1:8889;
 $database_try1 = test;
 $username_try1 = test;
 $password_try1 = test;
 $try1 = mysql_pconnect($hostname_try1, $username_try1, $password_try1) or
 trigger_error(mysql_error(),E_USER_ERROR);
 ?
 
 The lines below don't error  but also don't do anything
 
 I must be missing something here Right? Maybe it doesn't know to use
 try1 connection? How do I add that?
 
 ?php
 $sql = 'ALTER TABLE `ztest` ADD `myfield2` VARCHAR(10) NOT NULL;';
 ---or---
 $sql = 'ALTER TABLE `ztest` RENAME TO `ztest2`;';
 
  ?

Might be obvious but you are doing mysql_query($sql);, right?

Also add a try catch around your mysql_query to check what's happening.


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



Re: [PHP] putting variables in a variable

2008-04-19 Thread revDAVE
On 3/28/2011 4:06 AM, Hulf [EMAIL PROTECTED] wrote:

 Hi,
 
 I am making and HTML email. I have 3 images to put in. Currently I have
 
 $body .=
 table
   tr
 tdimg src=\image1.jpg\/td
   /tr
 
   tr
 td/td
   /tr
 /table
 ;
 
 
 ideally I would like to have
 
 $myimage1 = image1.jpg;
 $myimage2 = image2.jpg;
 $myimage3 = image3.jpg;
 
 
 and put them into the HTML body variable. I have tried escaping them in
 every way i can think of, dots and slashes and the rest. Any ideas?


I'm just a newbie - but

I did something like this (non - html mail) ... If it helps...

I created this var called $thebody - then stuck it in the mail tag... And it
works

--


$thebody = 'This is a some info...

UserID#: '. $_SESSION['nowuser'].'
Company: '.$_SESSION['now_co'].'

Worker Info: '. $edit_result_row-getField('First').' '.
$edit_result_row-getField('Last').'

Thanks,

';

---
--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists]




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



Re: [PHP] Alter Table newbie help needed ...

2008-04-19 Thread revDAVE
On 4/19/2008 2:37 PM, Jason Norwood-Young [EMAIL PROTECTED]
wrote:

 Might be obvious but you are doing mysql_query($sql);, right?

Not so obvious to THIS newbie - now it works fine!

Thanks AGAIN!

 
 Also add a try catch around your mysql_query to check what's happening.


--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists]




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



Re: [PHP] PHP console script vs C/C++/C#

2008-04-19 Thread Larry Garfield
On Saturday 19 April 2008, Per Jessen wrote:
 Robert Cummings wrote:
  You are correct about asymptotic bounds on algorithms; however,
  languages can still have a constant multiplier affect on an algorithm.

 Absolutely.  When it comes to how long does it take to process 1000
 elements, both language and hardware are critical factors.  But the
 algorithm efficiency remains constant.

Certain languages are also well-suited to certain types of algorithms, 
particularly when you're talking about languages with a runtime environment.  
A recursion-heavy algorithm will perform far better in a functional language 
than in a procedural language like PHP, because the runtime environment is 
designed to make sub-routine calls, especially recursive ones, cheap.  PHP's 
sub-routine calls are relatively expensive compared to a functional language.  
However, it's lookup capabilities on small to medium datasets are strong, 
thanks to its solid array/hash implementation, so it is well suited to 
algorithms that require array-able lookups.

The abstract algorithm assumes that each primitive operation is equal cost, 
and then counts the operations.  (An over-simplification, but that's the 
general idea.)  In practice, each operation does not have equal cost, and the 
cost of different primitive operations varies widely between languages and 
even versions of languages.

-- 
Larry Garfield  AIM: LOLG42
[EMAIL PROTECTED]   ICQ: 6817012

If nature has made any one thing less susceptible than all others of 
exclusive property, it is the action of the thinking power called an idea, 
which an individual may exclusively possess as long as he keeps it to 
himself; but the moment it is divulged, it forces itself into the possession 
of every one, and the receiver cannot dispossess himself of it.  -- Thomas 
Jefferson

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



[PHP] Re: OS X 10.5.2

2008-04-19 Thread Lee Perry
First let me say thank you for your help, I do appreciate you taking  
the time to read my post.


I did come across the entropy.ch forum while searching on google but  
(and I could be wrong here so sorry in advance) it seems that this  
would lead to me having multiple versions of php and or apache. Also I  
don't really want to be reliant on someone else for my stack. I would  
prefer to get the bundled install working or learn how to build my own.


I have been trying to get the pdo_mysql driver from pear and have had  
some success but still no banana !


I have installed pear and linked to the mysql_config file but I get  
errors, I will post the output and hope one of you guys can see what  
I'm missing. And thanks again in advance.


lee. ; )


Macintosh:pear lperry65$ sudo /usr/lib/php/pear/bin/pecl install  
pdo_mysql

downloading PDO_MYSQL-1.0.2.tgz ...
Starting to download PDO_MYSQL-1.0.2.tgz (14,778 bytes)
.done: 14,778 bytes
downloading PDO-1.0.3.tgz ...
Starting to download PDO-1.0.3.tgz (52,613 bytes)
...done: 52,613 bytes
12 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No:  20060613
Zend Extension Api No:   220060519
building in /var/tmp/pear-build-root/PDO-1.0.3
running: /usr/lib/php/pear/temp/PDO/configure
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc and cc understand -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i686-apple-darwin9.2.2
checking host system type... i686-apple-darwin9.2.2
checking target system type... i686-apple-darwin9.2.2
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/ 
main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/ 
php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib/php/extensions/no- 
debug-non-zts-20060613

checking for PHP installed headers prefix... /usr/include/php
checking for re2c... no
configure: WARNING: You will need re2c 0.12.0 or later if you want to  
regenerate PHP parsers.

checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking whether to enable PDO support... yes, shared
checking for ld used by gcc... /usr/libexec/gcc/i686-apple- 
darwin9/4.0.1/ld
checking if the linker (/usr/libexec/gcc/i686-apple-darwin9/4.0.1/ld)  
is GNU ld... no
checking for /usr/libexec/gcc/i686-apple-darwin9/4.0.1/ld option to  
reload object files... -r

checking for BSD-compatible nm... /usr/bin/nm -p
checking whether ln -s works... yes
checking how to recognise dependent libraries... pass_all
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 196608
checking command to parse /usr/bin/nm -p output from gcc object... rm:  
conftest.dSYM: is a directory

rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
rm: conftest.dSYM: is a directory
rm: conftest.dSYM: is a directory
checking if gcc static flag  works... rm: conftest.dSYM: is a directory
yes
checking if gcc supports -fno-rtti -fno-exceptions... rm:  
conftest.dSYM: is a directory

no
checking for gcc option to produce PIC... -fno-common
checking if gcc PIC flag -fno-common works... rm: conftest.dSYM: is a  
directory

yes
checking if gcc supports -c -o file.o... rm: conftest.dSYM: is a  
directory

yes
checking whether the gcc linker (/usr/libexec/gcc/i686-apple- 
darwin9/4.0.1/ld) supports shared libraries... yes

checking dynamic linker characteristics... darwin9.2.2 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared 

RE: [PHP] newbie needs help with session variables

2008-04-19 Thread Warren Vail
As I understand it, the register variables operation occurred before
execution began on your script.  It involved copying data items from your
form ($_POST), from the request URL ($_GET) and from your session
($_SESSION) so that you could simply refer to them by name in your programs.
The drawback was that someone could simply modify the URL to reference one
of your pages adding a variable to the request, and overlay variables in
your session, thereby modifying the execution of your programs, and driving
a truck thru any security you may have assumed was there.

The reason you want to keep register globals off becomes more obvious, and
when you look for variables in the $_POST array or the $_GET array or the
$_SESSION array, you can be reasonably sure it is coming from where you
expected it.  This still doesn't protect you from cross-site posting, but
certainly enhances your ability to control the source of data coming into
your programs.

HTH,

Warren Vail 

 -Original Message-
 From: Rod Clay [mailto:[EMAIL PROTECTED] 
 Sent: Saturday, April 19, 2008 2:20 PM
 To: php-general@lists.php.net
 Subject: [PHP] newbie needs help with session variables
 
 Hi.  I'm still very new to php and still trying to learn the ropes.
 
 I'm working on some code now trying to set up a session and 
 use session variables in different scripts, but I'm getting 
 this message:
 
 *Warning*: Unknown: Your script possibly relies on a session 
 side-effect which existed until PHP 4.2.3. Please be advised 
 that the session extension does not consider global variables 
 as a source of data, unless register_globals is enabled. You 
 can disable this functionality and this warning by setting 
 session.bug_compat_42 or session.bug_compat_warn to off, 
 respectively. in *Unknown* on line *0
 
 *2 questions:
 
 1) I've turned on register_globals in all of my php.ini files 
 and restarted the webserver, but I'm still getting this 
 message.  Can anyone help me with this?
 
 2) I get the idea that one should NOT turn on 
 register_globals, but, if I don't do this, how do I share 
 session variables between scripts (and avoid this message)?
 
 Thanks for any help that anyone can provide.
 
 Rod Clay
 [EMAIL PROTECTED]
 *
 


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



Re: [PHP] PHP console script vs C/C++/C#

2008-04-19 Thread Nathan Nobbe
On Sat, Apr 19, 2008 at 7:08 AM, Per Jessen [EMAIL PROTECTED] wrote:

 Nathan Nobbe wrote:

  On Fri, Apr 18, 2008 at 11:25 AM, Nick Stinemates
  [EMAIL PROTECTED] wrote:
 
  I don't think there was a single place where I said PHP was faster
  than C, nor did I imply it.
 
   Depends. Shitty algorithms are shitty, regardless of language
   implementation.
 
  implies that the same algorithm in different languages will not
  perform differently.  thats innacurate.

 No, that is actually a very accurate statement.


umm, so whats going on here is the implicit component of the statement that
incorporates relative or absolute performance.  in terms of relative
performance the statement is accurate; in terms of absolute performance, its
quite inaccurate.


  An algorithm will
 perform equally well regardless of the language chosen.  How well the
 actual implementation performs overall is a separate issue.  The
 performance or rather efficiency of an algorithm is usually expressed
 in the big-O notation, e.g.  O(n), O(log(n)) etc.

 A linear search is O(n), a quick sort is O(nlog(n)) (on average)  - both
 perform equally bad or equally well regardless of which language you
 choose to implement them in.


right, relative to the performance of said language.

 the same algorithm w/o external dependencies, such as db calls, or
  calls to remote systems will run faster in java / c / c++ and others
  than it will in php.

 An algorithm doesn't have external dependencies - but implementations
 might.


algorithms can have external dependencies.  imagine a soap call in php.
imagine the call running on a windows / bsd / linux system.  imagine the
call running on different networks.  imagine the algorithm running on a
machine w/ lots of other apps running on it concurrently leaving resources
at a minimum and again it running on a powerful system dedicated to the
php-enabled web server. although the algorithm will run unaltered on all
these platforms the performance may, and likely will vary due to the
underlying network stack, OS, bandwidth of the Internet connection from and
to the service provider, etc.

so anyway; what you are talking about here is relative performance.  the
same algorithm will  have the same complexity (relative bounds) despite the
language its implemented in.  however, in terms of absolute performance
languages will have different performances.  the main reason php is slower
than c is because its interpreted, duh.  thats why a O(n) algorithm in php
will run slower than the same O(n) algorithm in c.  thats what the great
computer language shootout is all about.  maybe you should take a look ;)
for example heres c vs. php;
http://shootout.alioth.debian.org/gp4/benchmark.php?test=alllang=gcclang2=php
its quite clear that c outperforms php on every algorithm.  you can click
the links on each test to see the implementation of each algorithm in a
given language.  and if you think you can improve the performance of a given
algorithm in a given language, then you can submit your code and see if it
actually runs faster.  thats what the game part is :D  and actually as a
complete side note c++ is actually topping c these days.

-nathan