[PHP] Re: how to retrieve a dom from innerHTML......

2010-01-20 Thread Pete Ford

I am on the top of the world! Borlange University wrote:

hello, i can obnot retrieve a select ject from div innerHTML.
what i want to do is that when a page is loaded, first selector,say #1,
would be shown in the first div by sending a request.then i choose one
option from #1, fire change event of #1, the second selector #2 will be
shown in div two, then choose option from #2 .blabla..

but the problem is when selector #1 was loaded, the object #1 could not be
obtained.
codes:

window.addEvent('domready', function() {

 var option=1;

 var result = new Request({
  
url:'getInfo_gx.php'
,
  method:'get',
  onSuccess:function(response)
  {
   if(option==1) $('list_sch').innerHTML = response; //response =
"

You probably ought to ask a Javascript forum about javascript problems...

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



Re: [PHP] How do I remove unused GET parameters from the URL?

2010-01-20 Thread Rene Veerman
Michael, while i respect your choices, i think you should know that
jquery.com is pretty good at minimizing browser-incompatibility
headaches (and keeping js apps small), and the quircks that are left
are easy enough to learn about.

for things whereby
- the server needs to generate tons of HTML for a small(ish) dataset, or
- the client generates data (also to be translated to html) that the
server doesnt really need to know about (yet)

js can really take some stress off the server.


On Wed, Jan 20, 2010 at 9:31 AM, Michael A. Peters  wrote:
> Rene Veerman wrote:
>>>
>>> That's how I would do it personally (opposed to js).
>>
>> wtf??!  js = less server stress :)
>>
>
> Many (myself included) surf with script blockers due to XSS and js is more
> difficult to thoroughly test because the implementation is done by browsers
> without a good standards body for validating the the code.
>
> I've run into a couple situations where scripts worked perfectly for me in
> Firefox, Opera, and Konq only to find out they failed in IE either because
> IE did things differently (like attaching events) or something as stupid as
> IE not liking a space that the other browsers worked fine with.
>
> window.open(url,'Download
> Media','width=620,height=200,toolbar=0,location=0,directories=0,menubar=0,resizable=0');
>
> failed in IE because of the space between Download and Media, yet worked in
> all other browsers I tried, and didn't even give a warning in Firefox with
> the firebug plugin.
>
> Thus for me to implement a solution in JavaScript, the testing time goes way
> up because I have to test it in several versions of several different
> browsers.
>
> If I can do it server side, the only issues are CSS and appropriate
> fallbacks for bleeding edge tags (like the html5 tags), but I have to test
> for those anyway so doing it server side doesn't cost me any extra testing
> time and doesn't end up with failures because I didn't test a particular
> version of a particular browser.
>
> Also, by minimizing the JavaScript, I minimize the amount of fallback
> testing I need to still keep viewers who have scripting disabled.
>
> Until there is some kind of a proper standard that the major browser vendors
> adhere to with a validator I can check my JS against that will pretty much
> guarantee any validating JS works in the various browsers, I will continue
> to do stuff server side as much as possible.
>
> I do use JavaScript for things like form validation (validated server side
> as well), upload progress, dynamic select menus where the content of one
> depends upon what was selected in another, etc. - but if I can do it server
> side I do, that's my philosophy. I understand it is a minority philosophy,
> but I get less headaches that way.
>

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



[PHP] could use some suggestions to speed this short piece of code up

2010-01-20 Thread Rene Veerman
Hi, for http://mediabeez.ws/htmlMicroscope/ (lgpl) i need to make
large & complex but _randomly filled_ test-arrays.

The code i wrote (hastily) for this is taking over 2 hours to generate
65k array values.
I wonder if any of you see a way to improve it's speed.

global $hmGenKeys;
$hmGenKeys = 0;
function htmlMicroscope_generateRandomArray ($maxKeys, $maxDepth,
$maxDuration=-1) {
  global $hmGenKeys;
  $r = array();
  if ($maxKeys!==null) {
$hmGenKeys = $maxKeys;
  }

  $hmGenKeys--;
  if ($hmGenKeys<=0) return false;
  if ($maxDepth==0) return false;
  srand(htmlMicroscope_randMakeSeed());
  while ($hmGenKeys > 0) {
  $range = rand(0,40);
  file_put_contents('countdown.txt', $hmGenKeys);
  for ($i=0; $i<$range && $hmGenKeys>=0; $i++) {
  $hmGenKeys--;
if ($maxDuration!=-1 && $maxDuration < getDuration()) {
  $r = array();
} else {
switch (rand(1,2)) {
  case 1 :
$next = htmlMicroscope_generateRandomArray (null,
$maxDepth-1, $maxDuration);
if ($next!==false)
  $r = array_merge ($r, array(
htmlMicroscope_randomValue(3) => $next
  ));
break;
  case 2 :
$r = array_merge ($r, array(
  htmlMicroscope_randomValue(3) => 
htmlMicroscope_randomValue(20)
));
break;
}
}
  }
 // echo $hmGenKeys.'';
  }
  return $r;
}

function htmlMicroscope_randomValue($maxLength) {
  $r = '';
  switch (rand(0,9)) {
case 0 : $r = rand (0,1); break;
case 1 : $r = rand (0,1) / rand(1,100) / 3; break;
default:
  for ($i = 0; $i < $maxLength; $i++) {
switch (rand(0,1)) {
  case 0:
$r.= unichr(rand(0,hexdec('')));
break;
  case 1:
$r.=chr(rand(ord('a'),ord('z')));;
break;
}
  }
  break;
  }
  //echo $r.''.$maxLength.'';
  return $r;
}

function unichr($u) {
return mb_convert_encoding('&#' . intval($u) . ';', 'UTF-8',
'HTML-ENTITIES');
}

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



RE: [PHP] Object Oriented Programming question

2010-01-20 Thread Jay Blanchard
[snip]
> Another advantage of OOP that is difficult to
> provide via the procedural paradigm is polymorphism.

Agreed. Though the advantages of polymorphism are questionable,
depending on your viewpoint.
[/snip]

In a loosely typed language like PHP that advantages of polymorphism far
outweigh any potential disadvantages, especially where virtual functions
are concerned. 

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



Re: [PHP] Cookies & sessions

2010-01-20 Thread Ashley Sheridan
On Wed, 2010-01-20 at 15:45 +1100, clanc...@cybec.com.au wrote:

> On Tue, 19 Jan 2010 22:45:14 -0500, phps...@gmail.com (Phpster) wrote:
> 
> >The first setcookie call is empty which produces the errors that cause  
> >the second cookie to fail.
> 
> I'm afraid not. I modified the program started to read:
> 
>  
> session_start ();
> 
> setcookie ('Try_1', 'Works', time()+3600);
> echo ' ';
> setcookie ('Try_2', 'Doesnt', time()+3600);
> 
> With the result
> 
> Warning: Cannot modify header information - headers already sent by (output 
> started at
> D:\Websites\cypalda.com\index.php:6) in D:\Websites\cypalda.com\index.php on 
> line 7
> 
> And cookie 'Try_2' is not set.
> 
> I suspect you have been running with output buffering on, but I had left it 
> in the default
> state, which is off.
> 
> 


Well the problem here is obvious, you just changed the line that was
causing the error to another line that causes another error! Why do you
need to echo a space character? Remove that line and you will get rid of
this new error.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] How do I remove unused GET parameters from the URL?

2010-01-20 Thread Ashley Sheridan
On Tue, 2010-01-19 at 20:55 -0800, Daevid Vincent wrote:

> I have an HTML form with a hundred or so elements on it, used for searching
> a database.
>  
> When the user submits the form (via GET) the URL is loaded with ALL of
> these fields, and many of them are not even actually used in the search
> criteria.
>  
> https://mypse/dart2/ps_search.php?enter_date=2009-11-30&id_incident=&incide
> nt_date=&incident_hh=0&incident_mm=0&id_urgency_level=0&problem_description
> =&immediate_action=&unit_opened=&unit_authorized=&customer=&customer_contac
> t=&customer_address=&customer_country=&id_location=0&passengers_onboard=&su
> bmit=Search&part_number=&serial_number=&nomenclature=&manufacture_date=&mod
> _level=&id_lru_condition=&repair_history=&ac_type=&tail_number=&id_system_t
> ype=&id_lru_location=0&circuit_breaker=&circuit_breaker_amps=&seat_number=&
> seat_vendor=&seat_column_zone=&seat_zone=&tc_holder=&stc_holder=&asr_mor=&i
> mpounded=&id_authority=&id_region=&reported_by=&prepared_by=&preparer_locat
> ion=&field_engineer=&id_attach_pictures=&id_attach_mlr=&id_attach_lopa=&cab
> in_log=&parts_inspect=&id_organization=0&id_quality_engineer=0&car_number=&
> close_date=&closed_by=&qa_comment=&id_priority=&id_action=0&id_incident_sta
> tus=3&id_failure_type=&detail_status=&investigation_result=&osaka_action=&o
> saka_request=&newvsrepeat=&related_incident=&unit_received_date=&unit_retur
> ned_date=&tdr_to_pso_date=&tdr_date=&dcr_date=&dcr_reference_number=&ecr_da
> te=&ecr_reference_number=&eco_date=&eco_reference_number=&service_bulletin_
> date=&sb_reference_number=&sil_issue_date=&sil_reference_number=&til_issue_
> date=&til_reference_number=&customer_letter_issue_date=&subassembly=&rdm=&p
> svector=&oemmanuf=&defective_part_1=&defective_part_2=&defective_part_3=&de
> fective_part_4=
>  
> Is there some way via PHP/Apache Mod/Javascript to remove all the keys that
> don't have any value in them and just distill this down to the
> elements/keys that the user actually entered some input for? ie. defaulting
> all the rest to 'blank'.
>  
> In PHP, this would look something like this:
>  
> foreach ($_GET as $k => $v) if ($v == '') unset($_GET[$k]);
>  
> The problem as I see it, is that this "magic" happens when the user hits
> "Submit", so not sure PHP has any way to intercept at that point.
> Javascript might be able to do something on the "onClick" event or
> "onSubmit" I suspect. But this seems like something that someone should
> have solved before and common enough that I would think Apache could handle
> it transparently with a directive or module enabled so I don't have to code
> some hack on every page.
>  
> I guess I could always redirect to some 'scrubber' page that strips them
> out and redirects on to the refering page again, but that seems klunky.
>  
> BTW, I want to use GET so that the page can be bookmarked for future
> searches of the same data (or modified easily with different dates, etc.),
> so that's why I don't use POST.


You can't remove the empty fields server-side, as they never reach the
server. GET has a limit on the amount of data it may carry, which is
reduced the longer the base URL is. If you need to send large amounts of
data like that, you need to send it via POST. You can make minimal
changes to your PHP code to allow for this. If you use $_GET in your
PHP, swap it for $_REQUEST which contains both GET and POST data.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] could use some suggestions to speed this short piece of code up

2010-01-20 Thread tedd

At 12:42 PM +0100 1/20/10, Rene Veerman wrote:

Hi, for http://mediabeez.ws/htmlMicroscope/ (lgpl) i need to make
large & complex but _randomly filled_ test-arrays.


Sometimes it's good to look at some of php's built in functions, like 
shuffle() and array_rand().


Cheers,

tedd

--
---
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] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-20 Thread Edward S.P. Leong
Richard Quadling wrote:

>2010/1/19 Edward S.P. Leong :
>  
>
>>Richard Quadling wrote:
>>
>>
>>
>>>But having said all of that, the php_mssql.dll uses a very old library
>>>which may give you issues.
>>>
>>>For the time being, using ODBC (php_odbc is built in for PHP on
>>>Windows) is a much safer solution. You can also use the latest SQL
>>>Native Client driver so you can talk to SQL7, 2000, 2005, 2008.
>>>
>>>If you are used to using a DNS-less connection, then ...
>>>
>>>$Conn = odbc_pconnect("Driver={SQL Server Native Client
>>>10.0};Server={$Server};Database={$Database};MARS_Connection=Yes;",
>>>$User, $Password, SQL_CUR_USE_DRIVER);
>>>
>>>will give you the connection without the need to have a DNS entry.
>>>
>>>
>>>  
>>>
>>Hello to you,
>>
>>Where can we download the SQL Native Client driver for talking to MS-SQL
>>( eg : 2000 ) ?
>>
>>Thanks !
>>
>>--
>>PHP General Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>>
>
>http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>  
>
Sorry,

Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?

Thanks !

Edward.


Re: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-20 Thread Richard Quadling
2010/1/20 Edward S.P. Leong :
> Richard Quadling wrote:
>
> 2010/1/19 Edward S.P. Leong :
>
>
> Richard Quadling wrote:
>
>
>
> But having said all of that, the php_mssql.dll uses a very old library
> which may give you issues.
>
> For the time being, using ODBC (php_odbc is built in for PHP on
> Windows) is a much safer solution. You can also use the latest SQL
> Native Client driver so you can talk to SQL7, 2000, 2005, 2008.
>
> If you are used to using a DNS-less connection, then ...
>
> $Conn = odbc_pconnect("Driver={SQL Server Native Client
> 10.0};Server={$Server};Database={$Database};MARS_Connection=Yes;",
> $User, $Password, SQL_CUR_USE_DRIVER);
>
> will give you the connection without the need to have a DNS entry.
>
>
>
>
> Hello to you,
>
> Where can we download the SQL Native Client driver for talking to MS-SQL
> ( eg : 2000 ) ?
>
> Thanks !
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>
>
> Sorry,
>
> Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>
> Thanks !
>
> Edward.
>

Either ODBC or the MS SQL driver for PHP. Which ever suits you.

Both require the MS SQL Native Client (go for the latest).

That's it really.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-20 Thread Richard Quadling
2010/1/20 Richard Quadling :
> 2010/1/20 Edward S.P. Leong :
>> Richard Quadling wrote:
>>
>> 2010/1/19 Edward S.P. Leong :
>>
>>
>> Richard Quadling wrote:
>>
>>
>>
>> But having said all of that, the php_mssql.dll uses a very old library
>> which may give you issues.
>>
>> For the time being, using ODBC (php_odbc is built in for PHP on
>> Windows) is a much safer solution. You can also use the latest SQL
>> Native Client driver so you can talk to SQL7, 2000, 2005, 2008.
>>
>> If you are used to using a DNS-less connection, then ...
>>
>> $Conn = odbc_pconnect("Driver={SQL Server Native Client
>> 10.0};Server={$Server};Database={$Database};MARS_Connection=Yes;",
>> $User, $Password, SQL_CUR_USE_DRIVER);
>>
>> will give you the connection without the need to have a DNS entry.
>>
>>
>>
>>
>> Hello to you,
>>
>> Where can we download the SQL Native Client driver for talking to MS-SQL
>> ( eg : 2000 ) ?
>>
>> Thanks !
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
>>
>> http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>>
>>
>> Sorry,
>>
>> Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>>
>> Thanks !
>>
>> Edward.
>>
>
> Either ODBC or the MS SQL driver for PHP. Which ever suits you.
>
> Both require the MS SQL Native Client (go for the latest).
>
> That's it really.
>
> --
> -
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>
Microsoft SQL Server 2008 Native Client
Microsoft SQL Server 2008 Native Client (SQL Native Client) is a
single dynamic-link library (DLL) containing both the SQL OLE DB
provider and SQL ODBC driver. It contains run-time support for
applications using native-code APIs (ODBC, OLE DB and ADO) to connect
to Microsoft SQL Server 2000, 2005, or 2008. SQL Native Client should
be used to create new applications or enhance existing applications
that need to take advantage of new SQL Server 2008 features. This
redistributable installer for SQL Native Client installs the client
components needed during run time to take advantage of new SQL Server
2008 features, and optionally installs the header files needed to
develop an application that uses the SQL Native Client API.

Audience(s): Customer, Partner, Developer

X86 Package (sqlncli.msi) - 4549 KB -
http://go.microsoft.com/fwlink/?LinkId=123717&clcid=0x409
X64 Package (sqlncli.msi) - 7963 KB -
http://go.microsoft.com/fwlink/?LinkId=123718&clcid=0x409
IA64 Package (sqlncli.msi) - 2 KB -
http://go.microsoft.com/fwlink/?LinkId=123719&clcid=0x409


Microsoft SQL Server 2005 Driver for PHP
The SQL Server 2005 Driver for PHP is a PHP 5 extension that allows
for accessing data in all Editions of SQL Server 2005 and SQL Server
2008 (including Express Editions) from within PHP scripts. The driver
provides a procedural interface for accessing data and makes use of
PHP features, including PHP streams to read and write large objects.
With this release, the source code for the driver is available here:
http://go.microsoft.com/fwlink/?LinkID=123842&clcid=0x409 . The SQL
Server 2005 Driver for PHP relies on the Microsoft SQL Server Native
Client to communicate with SQL Server. For more information about SQL
Server Native Client, visit the SQL Server Native Client page on MSDN.

Audience(s): Developer, DBA

Download site - http://go.microsoft.com/fwlink/?LinkID=123470


-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-20 Thread Edward S.P. Leong
Richard Quadling wrote:

>>http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>>
>>
>>Sorry,
>>
>>Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>>
>>Thanks !
>>
>>Edward.
>>
>>
>>
>
>Either ODBC or the MS SQL driver for PHP. Which ever suits you.
>
>Both require the MS SQL Native Client (go for the latest).
>
>That's it really.
>
Sorry,

My means is which package support for connecting MS-SQL 2000 from php ?
Due to I don't know which package ( file name ) I download it on the
download site is suitable for me to use...

Thanks !

Edward.


Re: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-20 Thread Richard Quadling
2010/1/20 Edward S.P. Leong :
> Richard Quadling wrote:
>
> http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>
>
> Sorry,
>
> Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>
> Thanks !
>
> Edward.
>
>
>
> Either ODBC or the MS SQL driver for PHP. Which ever suits you.
>
> Both require the MS SQL Native Client (go for the latest).
>
> That's it really.
>
> Sorry,
>
> My means is which package support for connecting MS-SQL 2000 from php ?
> Due to I don't know which package ( file name ) I download it on the
> download site is suitable for me to use...
>
> Thanks !
>
> Edward.
>

As you are running IIS + PHP in 32bit mode, I'd stick with the x86 packages.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



RE: [PHP] Object Oriented Programming question

2010-01-20 Thread tedd

At 10:26 AM -0500 1/19/10, Bob McConnell wrote:

Some problems will fit into it, some don't.


I teach OOP thinking at the local college and haven't run into a 
problem that doesn't fit. For example, in my last class I had a woman 
who wanted to pick out a blue dress for her upcoming wedding 
anniversary. The class worked out the problem with a OOP solution.





Some people can look at problems and see objects and some can't.


That's for certain -- but in time just about everyone can understand 
the basic concepts of OOP.





But in most cases, it is not easy to take an
existing procedural program and re-map it into objects. It would be
easier to start over from the specification and write it from scratch in
the object model.


I agree with that because part of OOP is understanding/defining the 
problem through an object oriented perspective -- it's a paradigm 
shift in thinking.


However, a programmer who is good in procedural also understands 
problem solving. OOP and Procedural are just two different approaches 
and each brings it's own set of tools/problems to the table.


---


If you have been doing procedural programming, don't worry if you don't
figure it out right away. It is not an easy transition to make. Many of
us with decades of programming behind us will never be able to make that
switch. Our brains are too tightly locked into the previous thought
patterns.

Bob McConnell


While I teach OOP, I don't write any OOP for clients. My charge is to 
do things quickly and OOP requires a considerable amount of analysis 
before creating a solution. In most cases, I don't have the time. 
Besides, I'm more of an agile programmer and that doesn't lend itself 
well to OOP, IMO.


Also IMO, one can argue the advantages that OOP and Design Patterns 
bring to the table over procedural, but after all is said and done, 
if you know your stuff in procedural, OOP is not going to provide you 
with much that you don't already have.


Cheers,

tedd

--
---
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] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-20 Thread Edward S.P. Leong
Richard Quadling wrote:

>2010/1/20 Edward S.P. Leong :
>  
>
>>Richard Quadling wrote:
>>
>>http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>>
>>
>>Sorry,
>>
>>Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>>
>>Thanks !
>>
>>Edward.
>>
>>
>>
>>Either ODBC or the MS SQL driver for PHP. Which ever suits you.
>>
>>Both require the MS SQL Native Client (go for the latest).
>>
>>That's it really.
>>
>>Sorry,
>>
>>My means is which package support for connecting MS-SQL 2000 from php ?
>>Due to I don't know which package ( file name ) I download it on the
>>download site is suitable for me to use...
>>
>>Thanks !
>>
>>Edward.
>>
>>
>>
>
>As you are running IIS + PHP in 32bit mode, I'd stick with the x86 packages.
>
>  
>
Hello,

Do you means the x86 is suitable for me now ?

Thanks !

Edward.


Re: [PHP] Object Oriented Programming question

2010-01-20 Thread Paul M Foster
On Wed, Jan 20, 2010 at 06:47:04AM -0600, Jay Blanchard wrote:

> [snip]
> > Another advantage of OOP that is difficult to
> > provide via the procedural paradigm is polymorphism.
> 
> Agreed. Though the advantages of polymorphism are questionable,
> depending on your viewpoint.
> [/snip]
> 
> In a loosely typed language like PHP that advantages of polymorphism far
> outweigh any potential disadvantages, especially where virtual functions
> are concerned. 

My viewpoint may be jaundiced from having programmed in C++, but the
polymorphism of PHP seems a little crippled by comparison.

Paul

-- 
Paul M. Foster

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



RE: [PHP] integrating shipping with shopping cart site - OT

2010-01-20 Thread Angelo Zanetti
Thanks guys, yes in general we will go with a lookup for each country, it
wont be accurate but in future we can build rates for each province / state
for each country which an admin would have to complete for each product
(time consuming) but for now the solution will work.

Thanks for the responses and thoughts, they are much appreciated.

I see the UPS class is also quite interesting but its only if you using them
:)

Cheers
Angelo


-Original Message-
From: Jochem Maas [mailto:joc...@iamjochem.com] 
Sent: 19 January 2010 04:53 AM
To: Angelo Zanetti
Cc: 'php-general'
Subject: Re: [PHP] integrating shipping with shopping cart site - OT

Op 1/18/10 10:47 AM, Angelo Zanetti schreef:
> Hi all, 
> 
> We are about to start a new project. Custom written shopping cart - quite
> simple actually. However we have a concern when it comes to calculating
the
> shipping cost for an order.
> 
> For each product we can determine the base cost based on weight, therefore
> we can determine the total weight of an order. 
> 
> However we are struggling to determine how to calculate the shipping based
> on where the delivery is going.
> 
> In terms of DB and PHP would the best way to calculate it be done by
having
> a list of countries to ship to and a rate for each? Then you can apply the
> rate to the current order (calculate according to the order weight).
> 
> Problems arise when shipping to different parts of a country EG: 
> 
> New York vs California (quite far apart). Perhaps we should have a list of
> cities but that could be massive?
> 
> I know there is a PHP class / system that integrates with UPS but I don't
> think the client is going to use UPS.
> 
> Perhaps you can tell me how you have handled this issue in the past.
> 
> Apologies if it is slightly off topic but it does still relate to PHP
> indirectly.

I'd start with defining shippingcost 'sets', each defining a number of
costs by weight bands, some 'table defs':

set:
-
id  name

set_bands:
--
set_id  upper_weightcost


then it would be a case of linking (many-to-many relation) 'regions' to
sets,
if you approach this with a tree of regions you can effectively set values
at
a continent, country, state/province level ... as such you would only need
to
relate a 'shippingcostset' to a state if the shippingcosts are different to
the given country's shippingcosts.

world
 - north america
   - california
 - south america
 - europe
   - france
   - UK

then your left with the problem of determining the smallest defined region a
given
address physically falls into .. using geo-spatial magic in the DB would be
one
way to do it.

this is a hard problem (unless, maybe, the client is willing to sacrifice
precision
and instead using highly averaged shipping cost definitions to cover the
real differences
in costs - i.e. a fixed fee for all of europe, whereby such fee is just
above the
average real cost the client pays for shipping).

my guess would be that building such a thing is hard, and would take lots of
time ... best bet is to hook into the webservice of whatever shipping
company the
client intends to use ... even if you have to build your end of the
webservice from
scratch it will be many factors less hard that building a user-manageable,
shipping cost
algorythm.

- sorry it's all a bit vague, I'm very tired :) my eyes are starting to
bleed.


> 
> Thanks in advance.
> Angelo
> 
> 
> http://www.wapit.co.za
> http://www.elemental.co.za 
> 
> 
> 


-- 
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] Object Oriented Programming question

2010-01-20 Thread Jay Blanchard
[snip]
My viewpoint may be jaundiced from having programmed in C++, but the
polymorphism of PHP seems a little crippled by comparison.
[/snip]

I wholeheartedly agree, but I figured out how to work with it in PHP to
my advantage and the advantage of my team. It'll get better... 

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



Re: [PHP] 64 Bit IIS 6 ( 32 Bit mode ) + 32Bit php connect with MS-SQL Server

2010-01-20 Thread Richard Quadling
2010/1/20 Edward S.P. Leong :
> Richard Quadling wrote:
>
> 2010/1/20 Edward S.P. Leong :
>
>
> Richard Quadling wrote:
>
> http://www.microsoft.com/downloads/details.aspx?FamilyId=C6C3E9EF-BA29-4A43-8D69-A2BED18FE73C&displaylang=en
>
>
> Sorry,
>
> Would you mind to tell me which for connecting MS-SQL 2000 and PHP ?
>
> Thanks !
>
> Edward.
>
>
>
> Either ODBC or the MS SQL driver for PHP. Which ever suits you.
>
> Both require the MS SQL Native Client (go for the latest).
>
> That's it really.
>
> Sorry,
>
> My means is which package support for connecting MS-SQL 2000 from php ?
> Due to I don't know which package ( file name ) I download it on the
> download site is suitable for me to use...
>
> Thanks !
>
> Edward.
>
>
>
> As you are running IIS + PHP in 32bit mode, I'd stick with the x86 packages.
>
>
>
> Hello,
>
> Do you means the x86 is suitable for me now ?
>
> Thanks !
>
> Edward.
>

If you were running 64 bit everything, then obviously, you would use
the 64 bit packages.

But you are running IIS and PHP in 32bit mode, so, for ease of
compatibility, the 32bit packages (x86 rather than x64) are what I
would be using.

In terms of which one you want to use, well, you have to get the Native Client.

>From there you can either use odbc (built into PHP for Windows) or use
the MS SQL Driver for PHP.

Both of them use the Native Client.

As the MS SQL driver is fairly new, you may want to stick with the
ODBC route within PHP.

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Object Oriented Programming question

2010-01-20 Thread Robert Cummings

Jay Blanchard wrote:

[snip]
My viewpoint may be jaundiced from having programmed in C++, but the
polymorphism of PHP seems a little crippled by comparison.
[/snip]

I wholeheartedly agree, but I figured out how to work with it in PHP to
my advantage and the advantage of my team. It'll get better... 


Certainly it is lacking compared to C++, but it's difficult to get that 
kind of functionality from a loosely typed language.


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] Object Oriented Programming question

2010-01-20 Thread Richard Quadling
2010/1/20 tedd :
> Also IMO, one can argue the advantages that OOP and Design Patterns bring to
> the table over procedural, but after all is said and done, if you know your
> stuff in procedural, OOP is not going to provide you with much that you
> don't already have.

You also have to consider that whilst PHP provides all the fancy
clever OOP facilities, it is written in C, not C++. So, as you say, if
you know your stuff ...

-- 
-
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] Object Oriented Programming question

2010-01-20 Thread Kim Madsen

tedd wrote on 20/01/2010 16:11:

At 10:26 AM -0500 1/19/10, Bob McConnell wrote:

Some problems will fit into it, some don't.


I teach OOP thinking at the local college and haven't run into a problem 
that doesn't fit. For example, in my last class I had a woman who wanted 
to pick out a blue dress for her upcoming wedding anniversary. The class 
worked out the problem with a OOP solution.


Don't forget to throw an exception if another woman shows up in the same 
dress and color at the wedding! That would make you OOPD crash totally! ;-)


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Object Oriented Programming question

2010-01-20 Thread Paul M Foster
On Wed, Jan 20, 2010 at 10:11:18AM -0500, tedd wrote:



>
> While I teach OOP, I don't write any OOP for clients. My charge is to
> do things quickly and OOP requires a considerable amount of analysis
> before creating a solution. In most cases, I don't have the time.
> Besides, I'm more of an agile programmer and that doesn't lend itself
> well to OOP, IMO.

This is a fascinating viewpoint. It's almost a sideways condemnation of
OOP: "It takes too long to write OOP for customers". (I know that's not
how you meant it.) But I have to agree, with one proviso. I tend to
write mostly procedural for clients because of time constraints. But I
believe part of the reason I do this is because I haven't built generic
OO components ahead of time which lend themselves to being used on
client sites. If I had spent the considerable time to build OO
components which were usable in this context, I'd be happy to use them.
OTOH, MVC (OOP on steroids) is just beyond reasonable in most cases for
client sites.

I will also echo that it takes a lot of time/work to correctly build OO
components, compared to straight functions or function libraries.

Paul

-- 
Paul M. Foster

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



RE: [PHP] Object Oriented Programming question

2010-01-20 Thread Bob McConnell
From: tedd

> At 10:26 AM -0500 1/19/10, Bob McConnell wrote:
>> Some problems will fit into it, some don't.
> 
> I teach OOP thinking at the local college and haven't run into a 
> problem that doesn't fit. For example, in my last class I had a woman 
> who wanted to pick out a blue dress for her upcoming wedding 
> anniversary. The class worked out the problem with a OOP solution.

Hi Tedd,

Here's one you can think about. I have a box, purchased off the shelf,
with multiple serial ports and an Ethernet port. It contains a 68EN383
CPU with expandable flash and RAM. The firmware includes a simple driver
application to create extended serial ports for MS-Windows, but allows
it to be replaced with a custom application. The included SDK consists
of the gcc cross-compiler and libraries with a Xinu kernel and default
drivers for a variety of standard protocols.

I need to build a communications node replacing the default drivers with
custom handlers for a variety of devices. It must connect to a server
which will send it configuration messages telling it what hardware and
protocols will be connected to each port. The Xinu package includes
Posix threads.

In the past 23 years I have solved this problem six times with five
different pieces of hardware. But I still don't see how to apply OOP to
it.

> 
> 
>> Some people can look at problems and see objects and some can't.
> 
> That's for certain -- but in time just about everyone can understand 
> the basic concepts of OOP.

Understanding basic concepts and understanding how to map them on to
real problems are two entirely different skill sets. I understand the
concepts, they just don't make any sense to me. All of the definitions
are backwards from the way I learned to evaluate problems. I feel like a
carpenter trying to figure out how to use a plumber's toolbox. There are
some things in there I think I recognize, but most of it is entirely
foreign to me.

Cheers,

Bob McConnell

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



Re: [PHP] integrating shipping with shopping cart site - OT

2010-01-20 Thread Ryan Sun
Just use the shipping rate web service of your client's shipping carrier
why border building a custom shipping rate calculator

On Wed, Jan 20, 2010 at 10:24 AM, Angelo Zanetti wrote:

> Thanks guys, yes in general we will go with a lookup for each country, it
> wont be accurate but in future we can build rates for each province / state
> for each country which an admin would have to complete for each product
> (time consuming) but for now the solution will work.
>
> Thanks for the responses and thoughts, they are much appreciated.
>
> I see the UPS class is also quite interesting but its only if you using
> them
> :)
>
> Cheers
> Angelo
>
>
> -Original Message-
> From: Jochem Maas [mailto:joc...@iamjochem.com]
> Sent: 19 January 2010 04:53 AM
> To: Angelo Zanetti
> Cc: 'php-general'
> Subject: Re: [PHP] integrating shipping with shopping cart site - OT
>
> Op 1/18/10 10:47 AM, Angelo Zanetti schreef:
> > Hi all,
> >
> > We are about to start a new project. Custom written shopping cart - quite
> > simple actually. However we have a concern when it comes to calculating
> the
> > shipping cost for an order.
> >
> > For each product we can determine the base cost based on weight,
> therefore
> > we can determine the total weight of an order.
> >
> > However we are struggling to determine how to calculate the shipping
> based
> > on where the delivery is going.
> >
> > In terms of DB and PHP would the best way to calculate it be done by
> having
> > a list of countries to ship to and a rate for each? Then you can apply
> the
> > rate to the current order (calculate according to the order weight).
> >
> > Problems arise when shipping to different parts of a country EG:
> >
> > New York vs California (quite far apart). Perhaps we should have a list
> of
> > cities but that could be massive?
> >
> > I know there is a PHP class / system that integrates with UPS but I don't
> > think the client is going to use UPS.
> >
> > Perhaps you can tell me how you have handled this issue in the past.
> >
> > Apologies if it is slightly off topic but it does still relate to PHP
> > indirectly.
>
> I'd start with defining shippingcost 'sets', each defining a number of
> costs by weight bands, some 'table defs':
>
> set:
> -
> id  name
>
> set_bands:
> --
> set_id  upper_weightcost
>
>
> then it would be a case of linking (many-to-many relation) 'regions' to
> sets,
> if you approach this with a tree of regions you can effectively set values
> at
> a continent, country, state/province level ... as such you would only need
> to
> relate a 'shippingcostset' to a state if the shippingcosts are different to
> the given country's shippingcosts.
>
> world
>  - north america
>   - california
>  - south america
>  - europe
>   - france
>   - UK
>
> then your left with the problem of determining the smallest defined region
> a
> given
> address physically falls into .. using geo-spatial magic in the DB would be
> one
> way to do it.
>
> this is a hard problem (unless, maybe, the client is willing to sacrifice
> precision
> and instead using highly averaged shipping cost definitions to cover the
> real differences
> in costs - i.e. a fixed fee for all of europe, whereby such fee is just
> above the
> average real cost the client pays for shipping).
>
> my guess would be that building such a thing is hard, and would take lots
> of
> time ... best bet is to hook into the webservice of whatever shipping
> company the
> client intends to use ... even if you have to build your end of the
> webservice from
> scratch it will be many factors less hard that building a user-manageable,
> shipping cost
> algorythm.
>
> - sorry it's all a bit vague, I'm very tired :) my eyes are starting to
> bleed.
>
>
> >
> > Thanks in advance.
> > Angelo
> >
> >
> > http://www.wapit.co.za
> > http://www.elemental.co.za
> >
> >
> >
>
>
> --
> 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] could use some suggestions to speed this short piece of code up

2010-01-20 Thread Rene Veerman
this is at least 1000% faster

the crux is that array()+=array() is way faster than any array_merge()
operations.

global $hmGenKeys;
$hmGenKeys = 0;
function htmlMicroscope_generateRandomArray ($maxKeys, $maxDepth,
$maxDuration=-1) {
  global $hmGenKeys;
  if ($maxKeys!==null) {
$hmGenKeys = $maxKeys;
  }

  $hmGenKeys--;
  if ($hmGenKeys<=0) return false;
  if ($maxDepth==0) return false;
  srand(htmlMicroscope_randMakeSeed());
  while ($hmGenKeys > 0) {
  $range = rand(0,40);
  file_put_contents('countdown.txt', $hmGenKeys);
  for ($i=0; $i<$range && $hmGenKeys>=0; $i++) {
$hmGenKeys--;
if ($maxDuration!=-1 && $maxDuration < getDuration()) {
  return false;
} else {
$r = array();
switch (rand(1,2)) {
  case 1 :
$next = htmlMicroscope_generateRandomArray (null,
$maxDepth-1, $maxDuration);
if ($next!==false)
  $r +=  array(
htmlMicroscope_randomValue(3) => $next
  );
break;
  case 2 :
$r += array(
  htmlMicroscope_randomValue(3) => 
htmlMicroscope_randomValue(20)
);
break;
}
}
  }
  }
  return $r;
}

function htmlMicroscope_randomValue($maxLength) {
  $r = '';
  switch (rand(0,9)) {
case 0 : $r = rand (0,1); break;
case 1 : $r = rand (0,1) / rand(1,100) / 3; break;
default:
switch (rand(0,1)) {
  case 0:
for ($i = 0; $i < $maxLength; $i++) {
  $r.= unichr(rand(0,hexdec('')));
}
break;
  case 1:
for ($i = 0; $i < $maxLength; $i++) {
  $r.=chr(rand(ord('a'),ord('z')));;
}
break;
}
break;
  }
  //echo $r.''.$maxLength.'';
  return $r;
}

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



Re: [PHP] How do I remove unused GET parameters from the URL?

2010-01-20 Thread Michael A. Peters

Rene Veerman wrote:

Michael, while i respect your choices, i think you should know that
jquery.com is pretty good at minimizing browser-incompatibility
headaches (and keeping js apps small), and the quircks that are left
are easy enough to learn about.

for things whereby
- the server needs to generate tons of HTML for a small(ish) dataset, or
- the client generates data (also to be translated to html) that the
server doesnt really need to know about (yet)

js can really take some stress off the server.


I also like to run any content that has user contributed data through a 
server side filter that enforces Content Security Policy -


http://www.clfsrpm.net/xss/

That filter makes sure the content sent to the browser does not include 
stuff that violates the defined CSP, and thus greatly reduces the risk 
of malicious content that input filtering missed from reaching the end user.


Furthermore, when it does catch a violation, it reports the violating to 
a log file notifying me of the problem.


The only way that works for content generated client side would be if 
the user was running a browser that is CSP aware, and right now, they 
just don't exist. Firefox has an experimental add-on for CSP but 
virtually no one uses it.


Doing dynamic content server side allows me to run that content through 
the enforcement filter server side thus catching policy violating 
content before it is ever sent to the user.


That itself, btw, is probably the biggest stress on the server.

I understand prototype etc. is the "web 2.0" way but I really don't have 
a high opinion of "Web 2.0". JavaScript, flash, etc. all have been used 
far too often to do bad things.


Right now, if I don't block except for white listed web sites, I end up 
with advertisements I don't care about expanding and covering the 
content I do care about. Unfortunately the web is full of jerks who do 
rude things with scripts, and people who do malicious things with scripts.


You wouldn't execute code that someone you don't know sent you an 
e-mail, would you? I wouldn't, nor do I execute code someone I don't 
know embeds in a web page.


I surf with script blockers (NoScript to be specific) and when I come 
upon web sites that don't properly function, I'm a lot liklier to head 
elsewhere than to enable scripting for that site. Since I surf that way, 
I expect others do as well, doing things server side that can be done 
server side allows users like me who block scripting to access the 
content without compromising the security of our systems.


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



Re: [PHP] How do I remove unused GET parameters from the URL?

2010-01-20 Thread Ashley Sheridan
On Wed, 2010-01-20 at 10:30 -0800, Michael A. Peters wrote:

> Rene Veerman wrote:
> > Michael, while i respect your choices, i think you should know that
> > jquery.com is pretty good at minimizing browser-incompatibility
> > headaches (and keeping js apps small), and the quircks that are left
> > are easy enough to learn about.
> > 
> > for things whereby
> > - the server needs to generate tons of HTML for a small(ish) dataset, or
> > - the client generates data (also to be translated to html) that the
> > server doesnt really need to know about (yet)
> > 
> > js can really take some stress off the server.
> 
> I also like to run any content that has user contributed data through a 
> server side filter that enforces Content Security Policy -
> 
> http://www.clfsrpm.net/xss/
> 
> That filter makes sure the content sent to the browser does not include 
> stuff that violates the defined CSP, and thus greatly reduces the risk 
> of malicious content that input filtering missed from reaching the end user.
> 
> Furthermore, when it does catch a violation, it reports the violating to 
> a log file notifying me of the problem.
> 
> The only way that works for content generated client side would be if 
> the user was running a browser that is CSP aware, and right now, they 
> just don't exist. Firefox has an experimental add-on for CSP but 
> virtually no one uses it.
> 
> Doing dynamic content server side allows me to run that content through 
> the enforcement filter server side thus catching policy violating 
> content before it is ever sent to the user.
> 
> That itself, btw, is probably the biggest stress on the server.
> 
> I understand prototype etc. is the "web 2.0" way but I really don't have 
> a high opinion of "Web 2.0". JavaScript, flash, etc. all have been used 
> far too often to do bad things.
> 
> Right now, if I don't block except for white listed web sites, I end up 
> with advertisements I don't care about expanding and covering the 
> content I do care about. Unfortunately the web is full of jerks who do 
> rude things with scripts, and people who do malicious things with scripts.
> 
> You wouldn't execute code that someone you don't know sent you an 
> e-mail, would you? I wouldn't, nor do I execute code someone I don't 
> know embeds in a web page.
> 
> I surf with script blockers (NoScript to be specific) and when I come 
> upon web sites that don't properly function, I'm a lot liklier to head 
> elsewhere than to enable scripting for that site. Since I surf that way, 
> I expect others do as well, doing things server side that can be done 
> server side allows users like me who block scripting to access the 
> content without compromising the security of our systems.
> 


It's for users like you that I keep saying to people that Javascript
shouldn't define functionality but enhance it. People will turn their
noses up at that attitude, but, like you said, some people get downright
nasty with the things they do online with their scripts.

I've not used that CSP thing you linked to before, it looks like it's
not for validating user input going *to* your server, but to sanitise
the downstream content from your server to the users browser. Validating
user input should prevent this as best as possible, as it shouldn't lead
to output from your script being used as part of an XSS attack. However,
the real worry is with ISP's that modify your pages before they are
output to the browser, as Canadian ISP Rogers has been found doing:

http://www.mattcutts.com/blog/confirmed-isp-modifies-google-home-page/

No PHP class will be able to prevent that, as the ISP is modifying the
content en route to its destination.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Object Oriented Programming question

2010-01-20 Thread J Ravi Menon
Hi Bob,

[Couldn't resist jumping into this topic :)]

Even if you look at traditional unix (or similar) kernel internals,
although they tend to use functional paradigms, they do have a
OOP-like flavor. Example:

Everything in a unix system is a 'file' (well not really with
networking logic, but it is one of the most important abstractions).
There is a notion of a 'abstract' base class 'file', and then there
are different 'types' of files - regular, directory, devices etc... So
you 'instantiate' a specific 'concrete' object when dealing with a
specific file. What are the methods that apply to all files? There is
open(), close(), read(), write(), ioctl() etc...  Not all methods are
valid for certain kinds of files - e.g. usually you don't write() to a
keyboard device.

In unix and C, the OOP is modeled using structs (to store various
attributes, or data members), and each struct tends to have
'pointer-to-functions' (listed above in case of files) to actual
implementation on how to deal with such objects in the system.

In fact the device-driver framework in unix can be thought of as an
excellent example of polymorphism where a table stores all the
specific functions that operate on the device.

Grouping data and its associated operations is one of the hallmarks of
OOP. In C, there is no *direct* support to express such groupings
where as in C++ (and other OOP languages), there is direct support via
notion of 'classes'  to express such relationships.

I would recommend this book: 'The design and evolution of C++' by
Bjarne Stroustrup where such topics are discussed more in depth.

Hope this helps.

Ravi




On Wed, Jan 20, 2010 at 8:31 AM, Bob McConnell  wrote:
> From: tedd
>
>> At 10:26 AM -0500 1/19/10, Bob McConnell wrote:
>>> Some problems will fit into it, some don't.
>>
>> I teach OOP thinking at the local college and haven't run into a
>> problem that doesn't fit. For example, in my last class I had a woman
>> who wanted to pick out a blue dress for her upcoming wedding
>> anniversary. The class worked out the problem with a OOP solution.
>
> Hi Tedd,
>
> Here's one you can think about. I have a box, purchased off the shelf,
> with multiple serial ports and an Ethernet port. It contains a 68EN383
> CPU with expandable flash and RAM. The firmware includes a simple driver
> application to create extended serial ports for MS-Windows, but allows
> it to be replaced with a custom application. The included SDK consists
> of the gcc cross-compiler and libraries with a Xinu kernel and default
> drivers for a variety of standard protocols.
>
> I need to build a communications node replacing the default drivers with
> custom handlers for a variety of devices. It must connect to a server
> which will send it configuration messages telling it what hardware and
> protocols will be connected to each port. The Xinu package includes
> Posix threads.
>
> In the past 23 years I have solved this problem six times with five
> different pieces of hardware. But I still don't see how to apply OOP to
> it.
>
>> 
>>
>>> Some people can look at problems and see objects and some can't.
>>
>> That's for certain -- but in time just about everyone can understand
>> the basic concepts of OOP.
>
> Understanding basic concepts and understanding how to map them on to
> real problems are two entirely different skill sets. I understand the
> concepts, they just don't make any sense to me. All of the definitions
> are backwards from the way I learned to evaluate problems. I feel like a
> carpenter trying to figure out how to use a plumber's toolbox. There are
> some things in there I think I recognize, but most of it is entirely
> foreign to me.
>
> Cheers,
>
> Bob McConnell
>
> --
> 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] Object Oriented Programming question

2010-01-20 Thread tedd

At 11:31 AM -0500 1/20/10, Bob McConnell wrote:

From: tedd


 At 10:26 AM -0500 1/19/10, Bob McConnell wrote:

 Some problems will fit into it, some don't.


 I teach OOP thinking at the local college and haven't run into a
 problem that doesn't fit. For example, in my last class I had a woman
 who wanted to pick out a blue dress for her upcoming wedding
 anniversary. The class worked out the problem with a OOP solution.


Hi Tedd,

Here's one you can think about. I have a box, purchased off the shelf,
with multiple serial ports and an Ethernet port. It contains a 68EN383
CPU with expandable flash and RAM. The firmware includes a simple driver
application to create extended serial ports for MS-Windows, but allows
it to be replaced with a custom application. The included SDK consists
of the gcc cross-compiler and libraries with a Xinu kernel and default
drivers for a variety of standard protocols.

I need to build a communications node replacing the default drivers with
custom handlers for a variety of devices. It must connect to a server
which will send it configuration messages telling it what hardware and
protocols will be connected to each port. The Xinu package includes
Posix threads.

In the past 23 years I have solved this problem six times with five
different pieces of hardware. But I still don't see how to apply OOP to
it.


 


 Some people can look at problems and see objects and some can't.


 That's for certain -- but in time just about everyone can understand
 the basic concepts of OOP.


Understanding basic concepts and understanding how to map them on to
real problems are two entirely different skill sets. I understand the
concepts, they just don't make any sense to me. All of the definitions
are backwards from the way I learned to evaluate problems. I feel like a
carpenter trying to figure out how to use a plumber's toolbox. There are
some things in there I think I recognize, but most of it is entirely
foreign to me.

Cheers,

Bob McConnell


Bob:

I am sure that you have all the tools and you solve problems in 
similar fashion -- it's only the jargon just hasn't made sense to you 
yet -- but it will. Six months from now , or a year, or whenever -- 
you'll have your "Is that what you're talking about? Hell, I've been 
doing that for years- -- but not quite that way" moment.


The problem is to break the problem into smaller and smaller parts 
that can be solved without requiring any alteration by the outside 
world. In other words, make the communication between the parts as 
simple and as independent as possible. They call encapsulation (data 
hiding) and loose coupling. From that, you can assemble the parts as 
you like.


I don't know your specific problem, but it reminds of a problem I had 
several years ago when I was writing software for plotters (Apple, 
HP, IT, Houston, etc.). Each plotter had it's own internal commands 
for pen-up/down, move x,y, and so on. While this was before OOP, the 
solution was to create a universal plotter language and then write 
translators for each specific plotter. That way, I could use my 
universal plotter language to do plotter things without ever thinking 
about any specific plotter.


That way when another plotter came along, I would simply write a 
routine that would control that plotter's basic pen-up/down and move 
x,y commands in my plotter language. The technique worked very well. 
IMO, it was that type of abstraction that launched OOP.


The problem you present is one where I would try to find the 
commonality between all the components and reduce those down to the 
simplest aspects of communication and responsibility.


I know that sounds like a bunch of OOP-speak, but problems well 
defined will expose their solutions.


Leonardo da Vinci was once asked about his marble carvings -- he 
replied (not a direct quote) that he just carved away everything that 
wasn't part of the statue. He was liberating the statue from the 
marble. Similarly, we liberate the solution from the problem.


Cheers,

tedd

--
---
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] Object Oriented Programming question

2010-01-20 Thread tedd

At 11:18 AM -0500 1/20/10, Paul M Foster wrote:

On Wed, Jan 20, 2010 at 10:11:18AM -0500, tedd wrote:





 While I teach OOP, I don't write any OOP for clients. My charge is to
 do things quickly and OOP requires a considerable amount of analysis
 before creating a solution. In most cases, I don't have the time.
 Besides, I'm more of an agile programmer and that doesn't lend itself
 well to OOP, IMO.


This is a fascinating viewpoint. It's almost a sideways condemnation of
OOP: "It takes too long to write OOP for customers". (I know that's not
how you meant it.) But I have to agree, with one proviso. I tend to
write mostly procedural for clients because of time constraints. But I
believe part of the reason I do this is because I haven't built generic
OO components ahead of time which lend themselves to being used on
client sites. If I had spent the considerable time to build OO
components which were usable in this context, I'd be happy to use them.
OTOH, MVC (OOP on steroids) is just beyond reasonable in most cases for
client sites.

I will also echo that it takes a lot of time/work to correctly build OO
components, compared to straight functions or function libraries.

Paul


Paul :

My view of the world is limited to what I do, but to me it's almost a 
philosophical issue -- what constitutes reusable code and what 
doesn't?


I've looked over many OOP routines that provided no useful purpose to 
me because their application was so specific that I could not use it 
for the problem I was solving. Programmers put these things together 
to be totally self contained, but failed to see that their solution 
only fits their problem. As such, for me to use their code I would 
have to disassemble it and then reassemble it for my own use -- in 
many cases taking it back to procedural.


OOP makes sense if you and your client can agree on a final solution 
before any code is written. My experience with clients is that first 
I usually have to educate them as to what a web page is and then work 
to solve their specific problem, which in many cases they can't even 
identify. They can only say what they want.


It's not their fault that they don't know what their problem is for 
they haven't been trained in problem identification. In fact, I would 
prefer an ignorant client over one who thinks they know how to solve 
the problem. I often tell clients to just tell me what you want and 
I'll work out the solution.


I remember a sign that hung in an old gas station when I was a kid, which read:

Labor:

$10.00 per hour
$15.00 per hour, if you watch.
$20.00 per hour, if you help.

In any event, when dealing with clients who don't fully realize what 
their problems are NOR fully appreciate what their needs are, I don't 
have the time to work out every detail beforehand so that I can 
create an OOP solution before writing the code.


I might also add that writing an OOP solution before identifying the 
problem is an effort that will need to be redone later. Not all 
solutions should be written in OOP.


Also, just because you can write OOP does not mean that what you 
write is better than what the procedural counterpart would be. It 
just means that you used OOP to solve the problem.


So, to get back to your statement that I don't have time to write in 
OOP for clients, you are correct -- I can't spend the time necessary 
to do it.


Cheers,

tedd

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



[PHP] Re: How do I remove unused GET parameters from the URL?

2010-01-20 Thread Nathan Rixham
Daevid Vincent wrote:
> BTW, I want to use GET so that the page can be bookmarked for future
> searches of the same data (or modified easily with different dates, etc.),
> so that's why I don't use POST.
> 

to do as you say on the clientside you'd probably be best to write a
short js script to build the get url from the form data; and on the
serverside just take the klunky approach you mentioned.

worth thinking about scenarios where a field is empty on the initial
search though; but a user may want to modify it by entering in a value
to a previously blank field (which would at this point be stripped); so
maybe removal isn't the best option.

possibly worth considering having a GET url which (p)re-populates the
form (rather than direct to the search results) so the search can be
easily modified before submitting it..?

also you could just pass the url through to an url shrinker; if you use
the api of bit.ly or suchlike you could do this serverside; and reap the
benefits of stats for each search too.

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



RE: [PHP] How do I remove unused GET parameters from the URL?

2010-01-20 Thread Daevid Vincent
Comments inline below...

> -Original Message-
> From: Ashley Sheridan 
> 
> GET has a limit on the amount of data it may carry, which is
> reduced the longer the base URL is. 

True, but for search parameters, it's IMHO best to use GET rather than POST
so the page can be bookmarked.

This used to be a concern "back in the day" with 255 bytes.

http://classicasp.aspfaq.com/forms/what-is-the-limit-on-querystring/get/url
-parameters.html

Not so much anymore with most browsers supporting > 2000 characters:

http://www.boutell.com/newfaq/misc/urllength.html
http://support.microsoft.com/kb/208427
http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-an-
url

Re-writing it to handle $_REQUEST doesn't seem to solve much as the user
would still need to know the form element names and the actual form would
be either POST/GET. GET is the problem I have now. POST is a whole other
problem of not being able to bookmark.

> -Original Message-
> From: Nathan Rixham 
> 
> to do as you say on the clientside you'd probably be best to write a
> short js script to build the get url from the form data; and on the
> serverside just take the klunky approach you mentioned.
> 
> worth thinking about scenarios where a field is empty on the initial
> search though; but a user may want to modify it by entering in a value
> to a previously blank field (which would at this point be 
> stripped); so maybe removal isn't the best option.

Also a very valid point that I hadn't fully considered.

> also you could just pass the url through to an url shrinker; 
> if you use
> the api of bit.ly or suchlike you could do this serverside; 
> and reap the benefits of stats for each search too.

This is for an internal intranet site so I can't use an outside shrinker,
however I suspect the code to create my own shrinker isn't so difficult and
this is a pretty interesting idea. Given your above observation, perhaps
this *is* the solution to persue further...

Way to think outside the box Nathan! :)

ÐÆ5ÏÐ 
http://daevid.com


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



[PHP] Close MySQL Result

2010-01-20 Thread Slack-Moehrle
I think I am a dork.

How do I close a MySQL result set to free memory?

Given something like this:

$gsql = "Select * from resources where queryName = 'Production';";

$myresult = mysql_query($gsql) or die('Cannot execute Query: ' . mysql_error());

$Row = mysql_fetch_assoc($myresult);

if ($Row == true) { $_SESSION['PRODUCTION'] = $Row['queryValue']; }
else { $_SESSION['PRODUCTION'] = "TRUE"; }

How do I free up $myresult and $Row?

-ML

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



RE: [PHP] Close MySQL Result

2010-01-20 Thread Daevid Vincent
http://www.php.net/manual/en/function.mysql-free-result.php

mysql_free_result($myresult); 

NOTE: mysql_free_result() only needs to be called if you are concerned
about how much memory is being used for queries that return large result
sets. All associated result memory is automatically freed at the end of the
script's execution. 

http://us2.php.net/manual/en/function.unset.php

unset($Row);

> -Original Message-
> From: Slack-Moehrle [mailto:mailingli...@mailnewsrss.com] 
> Sent: Wednesday, January 20, 2010 1:21 PM
> To: php-general@lists.php.net
> Subject: [PHP] Close MySQL Result
> 
> I think I am a dork.
> 
> How do I close a MySQL result set to free memory?
> 
> Given something like this:
> 
> $gsql = "Select * from resources where queryName = 'Production';";
> 
> $myresult = mysql_query($gsql) or die('Cannot execute Query: 
> ' . mysql_error());
> 
> $Row = mysql_fetch_assoc($myresult);
>   
> if ($Row == true) { $_SESSION['PRODUCTION'] = $Row['queryValue']; }
> else { $_SESSION['PRODUCTION'] = "TRUE"; }
> 
> How do I free up $myresult and $Row?
> 
> -ML
> 
> -- 
> 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] Close MySQL Result

2010-01-20 Thread Slack-Moehrle

Daevid,

Thanks for the links so I can read up!

-ML

- Original Message -
From: "Daevid Vincent" 
To: php-general@lists.php.net
Cc: "Slack-Moehrle" 
Sent: Wednesday, January 20, 2010 1:24:16 PM
Subject: RE: [PHP] Close MySQL Result

http://www.php.net/manual/en/function.mysql-free-result.php

mysql_free_result($myresult); 

NOTE: mysql_free_result() only needs to be called if you are concerned
about how much memory is being used for queries that return large result
sets. All associated result memory is automatically freed at the end of the
script's execution. 

http://us2.php.net/manual/en/function.unset.php

unset($Row);

> -Original Message-
> From: Slack-Moehrle [mailto:mailingli...@mailnewsrss.com] 
> Sent: Wednesday, January 20, 2010 1:21 PM
> To: php-general@lists.php.net
> Subject: [PHP] Close MySQL Result
> 
> I think I am a dork.
> 
> How do I close a MySQL result set to free memory?
> 
> Given something like this:
> 
> $gsql = "Select * from resources where queryName = 'Production';";
> 
> $myresult = mysql_query($gsql) or die('Cannot execute Query: 
> ' . mysql_error());
> 
> $Row = mysql_fetch_assoc($myresult);
>   
> if ($Row == true) { $_SESSION['PRODUCTION'] = $Row['queryValue']; }
> else { $_SESSION['PRODUCTION'] = "TRUE"; }
> 
> How do I free up $myresult and $Row?
> 
> -ML
> 
> -- 
> 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] Cookies & sessions

2010-01-20 Thread clancy_1
On Wed, 20 Jan 2010 13:19:03 +, a...@ashleysheridan.co.uk (Ashley Sheridan) 
wrote:

>On Wed, 2010-01-20 at 15:45 +1100, clanc...@cybec.com.au wrote:
>
>> On Tue, 19 Jan 2010 22:45:14 -0500, phps...@gmail.com (Phpster) wrote:
>> 
>> >The first setcookie call is empty which produces the errors that cause  
>> >the second cookie to fail.
>> 
>> I'm afraid not. I modified the program started to read:
>> 
>> > 21/3/09
>> 
>> session_start ();
>> 
>> setcookie ('Try_1', 'Works', time()+3600);
>> echo ' ';
>> setcookie ('Try_2', 'Doesnt', time()+3600);
>> 
>> With the result
>> 
>> Warning: Cannot modify header information - headers already sent by (output 
>> started at
>> D:\Websites\cypalda.com\index.php:6) in D:\Websites\cypalda.com\index.php on 
>> line 7
>> 
>> And cookie 'Try_2' is not set.
>> 
>> I suspect you have been running with output buffering on, but I had left it 
>> in the default
>> state, which is off.
>> 
>> 
>
>
>Well the problem here is obvious, you just changed the line that was
>causing the error to another line that causes another error! Why do you
>need to echo a space character? Remove that line and you will get rid of
>this new error.

When you are working with sessions, provided you start your program with 
session_id(), you
can then do anything you like with session variables at any point in your 
program. In my
original question I asked if there was a cookie equivalent. 

Someone said there was, but the above is simply demonstrating that their 
suggested
solution doesn't work. It appears there is no solution, but that the workaround 
is to turn
on output buffering, at least until you finish setting cookies, so that you can 
be certain
that no output is generated before this point.

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



[PHP] php-general-unsubscr...@lists.php.net

2010-01-20 Thread Dasn




--
Dasn


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



RE: [PHP] How do I remove unused GET parameters from the URL?

2010-01-20 Thread Ashley Sheridan
On Wed, 2010-01-20 at 13:06 -0800, Daevid Vincent wrote:

> Comments inline below...
> 
> > -Original Message-
> > From: Ashley Sheridan 
> > 
> > GET has a limit on the amount of data it may carry, which is
> > reduced the longer the base URL is. 
> 
> True, but for search parameters, it's IMHO best to use GET rather than POST
> so the page can be bookmarked.
> 
> This used to be a concern "back in the day" with 255 bytes.
> 
> http://classicasp.aspfaq.com/forms/what-is-the-limit-on-querystring/get/url
> -parameters.html
> 
> Not so much anymore with most browsers supporting > 2000 characters:
> 
> http://www.boutell.com/newfaq/misc/urllength.html
> http://support.microsoft.com/kb/208427
> http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-an-
> url
> 
> Re-writing it to handle $_REQUEST doesn't seem to solve much as the user
> would still need to know the form element names and the actual form would
> be either POST/GET. GET is the problem I have now. POST is a whole other
> problem of not being able to bookmark.
> 
> > -Original Message-
> > From: Nathan Rixham 
> > 
> > to do as you say on the clientside you'd probably be best to write a
> > short js script to build the get url from the form data; and on the
> > serverside just take the klunky approach you mentioned.
> > 
> > worth thinking about scenarios where a field is empty on the initial
> > search though; but a user may want to modify it by entering in a value
> > to a previously blank field (which would at this point be 
> > stripped); so maybe removal isn't the best option.
> 
> Also a very valid point that I hadn't fully considered.
> 
> > also you could just pass the url through to an url shrinker; 
> > if you use
> > the api of bit.ly or suchlike you could do this serverside; 
> > and reap the benefits of stats for each search too.
> 
> This is for an internal intranet site so I can't use an outside shrinker,
> however I suspect the code to create my own shrinker isn't so difficult and
> this is a pretty interesting idea. Given your above observation, perhaps
> this *is* the solution to persue further...
> 
> Way to think outside the box Nathan! :)
> 
> ÐÆ5ÏÐ 
> http://daevid.com
> 


What about sending the form via POST, but to a URL that includes some
sort of session in the URL the form is sent to, for example:



Then your server script can reproduce the search from saved parameters
stored under the sid value.

This way, you retain the ability to bookmark the search, and use as many
search parameters as you need, without worrying about going over the GET
data limit no matter what browser the user has.



Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Close MySQL Result

2010-01-20 Thread Ashley Sheridan
On Wed, 2010-01-20 at 13:24 -0800, Daevid Vincent wrote:

> http://www.php.net/manual/en/function.mysql-free-result.php
> 
> mysql_free_result($myresult); 
> 
> NOTE: mysql_free_result() only needs to be called if you are concerned
> about how much memory is being used for queries that return large result
> sets. All associated result memory is automatically freed at the end of the
> script's execution. 
> 
> http://us2.php.net/manual/en/function.unset.php
> 
> unset($Row);
> 
> > -Original Message-
> > From: Slack-Moehrle [mailto:mailingli...@mailnewsrss.com] 
> > Sent: Wednesday, January 20, 2010 1:21 PM
> > To: php-general@lists.php.net
> > Subject: [PHP] Close MySQL Result
> > 
> > I think I am a dork.
> > 
> > How do I close a MySQL result set to free memory?
> > 
> > Given something like this:
> > 
> > $gsql = "Select * from resources where queryName = 'Production';";
> > 
> > $myresult = mysql_query($gsql) or die('Cannot execute Query: 
> > ' . mysql_error());
> > 
> > $Row = mysql_fetch_assoc($myresult);
> > 
> > if ($Row == true) { $_SESSION['PRODUCTION'] = $Row['queryValue']; }
> > else { $_SESSION['PRODUCTION'] = "TRUE"; }
> > 
> > How do I free up $myresult and $Row?
> > 
> > -ML
> > 
> > -- 
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> > 
> 
> 


And you can unset() $row if you want to free memory used by that
variable, although it should be noted that once unset, it's up to PHP's
garbage collection to free the memory, but using unset() on the variable
tells PHP that it can free it if necessary.

If you're that worried about memory as well, try to optimise your
queries a little bit. For example, instead of retrieving all the results
in a table and using PHP to output only what you need, use the WHERE and
LIMIT clauses in MySQL to narrow down the results to only those that you
actually need.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Cookies & sessions

2010-01-20 Thread Ashley Sheridan
On Thu, 2010-01-21 at 08:43 +1100, clanc...@cybec.com.au wrote:

> On Wed, 20 Jan 2010 13:19:03 +, a...@ashleysheridan.co.uk (Ashley 
> Sheridan) wrote:
> 
> >On Wed, 2010-01-20 at 15:45 +1100, clanc...@cybec.com.au wrote:
> >
> >> On Tue, 19 Jan 2010 22:45:14 -0500, phps...@gmail.com (Phpster) wrote:
> >> 
> >> >The first setcookie call is empty which produces the errors that cause  
> >> >the second cookie to fail.
> >> 
> >> I'm afraid not. I modified the program started to read:
> >> 
> >>  >> 21/3/09
> >> 
> >> session_start ();
> >> 
> >> setcookie ('Try_1', 'Works', time()+3600);
> >> echo ' ';
> >> setcookie ('Try_2', 'Doesnt', time()+3600);
> >> 
> >> With the result
> >> 
> >> Warning: Cannot modify header information - headers already sent by 
> >> (output started at
> >> D:\Websites\cypalda.com\index.php:6) in D:\Websites\cypalda.com\index.php 
> >> on line 7
> >> 
> >> And cookie 'Try_2' is not set.
> >> 
> >> I suspect you have been running with output buffering on, but I had left 
> >> it in the default
> >> state, which is off.
> >> 
> >> 
> >
> >
> >Well the problem here is obvious, you just changed the line that was
> >causing the error to another line that causes another error! Why do you
> >need to echo a space character? Remove that line and you will get rid of
> >this new error.
> 
> When you are working with sessions, provided you start your program with 
> session_id(), you
> can then do anything you like with session variables at any point in your 
> program. In my
> original question I asked if there was a cookie equivalent. 
> 
> Someone said there was, but the above is simply demonstrating that their 
> suggested
> solution doesn't work. It appears there is no solution, but that the 
> workaround is to turn
> on output buffering, at least until you finish setting cookies, so that you 
> can be certain
> that no output is generated before this point.
> 


Cookies behave very differently from sessions. With sessions, you can
modify and use the values immediately, but with cookies, the values you
save are only then usable the next time the browser sends them back with
the header request. This basically means that the cookie information is
only available to your scripts if it existed in the client-side cookie
when the user made the request for the page your script is on.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Cookies & sessions

2010-01-20 Thread Bruno Fajardo
2010/1/20  :
> When you are working with sessions, provided you start your program with 
> session_id(), you
> can then do anything you like with session variables at any point in your 
> program.

Hi,

You meant session_start() instead of session_id(), right? But yes,
once you started a session (before any output is sent to the browser,
that includes echo and print statements, empty space chars, etc) you
can do anything you like with the $_SESSION array, being able to read
the stored values in other requests / scripts of your app, as long as
the session is started.

> In my
> original question I asked if there was a cookie equivalent.

As far as I know, yes, there is. You set a cookie using the
setcookie() function. This function, in the same way as
session_start(), must be called before any output is sent to the
browser. Once a cookie is set in the client, you can read the $_COOKIE
array in any subsequent request of your client, in any point of your
app, just like session.

>
> Someone said there was, but the above is simply demonstrating that their 
> suggested
> solution doesn't work. It appears there is no solution, but that the 
> workaround is to turn
> on output buffering, at least until you finish setting cookies, so that you 
> can be certain
> that no output is generated before this point.

You don't need to use output buffering at all. You only need this
mechanism if your script needs to output stuff before the
session_start() or setcookie() functions get executed.

Well, I hope this information is helpful.

Cheers,
Bruno.

>
> --
> 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] Cookies & sessions

2010-01-20 Thread Joseph Thayne

Bruno Fajardo wrote:

You don't need to use output buffering at all. You only need this
mechanism if your script needs to output stuff before the
session_start() or setcookie() functions get executed.
Output buffering is also used if you need to "output" something before 
the headers are sent either by the header() function or simply using 
echo or print().


Joseph

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



Re: [PHP] 304 Not Modified header not working within a class

2010-01-20 Thread Camilo Sperberg
On Wed, Jan 20, 2010 at 04:34, richard gray  wrote:

>
> Camilo Sperberg wrote:
>
>> Hi list, my first message here :)
>>
>> To the point: I'm programming a class that takes several CSS files,
>> parses,
>> compresses and saves into a cache file. However, I would like to go a step
>> further and also use the browser cache, handling the 304 and 200 header
>> types myself.
>>
>> Now, what is the problem? If I do it within a function, there is
>> absolutely
>> no problem, everything works like a charm. However, when I implement that
>> same concept into my class, there is no way I can send a 304 Not Modified
>> header, when the data is *over* ~100 bytes.
>>
>>
>>
> Hi Camilo
>
> For what it is worth I have implemented cacheing in a class and for me the
> 304 not modified header gets sent fine ... some example headers output is
> below together with the relevant code snippet..
>
> // See if client sent a page modified header to see if we can
> // just send a not modified header instead
> if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
> $_SERVER['HTTP_IF_MODIFIED_SINCE'] == self::$_gmmodtime) {
>
>   header('HTTP/1.1 304 Not Modified');
>   return null;
> }
>
> if (isset($_SERVER['HTTP_IF_NONE_MATCH']) &&
> stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) == self::$_etag) {
>
>   header('HTTP/1.1 304 Not Modified');
>   return null;
> }
>
>
> HTTP/1.x 304 Not Modified
> Date: Wed, 20 Jan 2010 07:21:32 GMT
> Server: Apache/2.2.11 (Ubuntu)
> Connection: Keep-Alive
> Keep-Alive: timeout=5, max=1000
> Etag: 444fbd9951f540ec1b6928db864c10dc
> Expires: Sun, 24 Jan 2010 06:16:06 GMT
> Cache-Control: public, must-revalidate
> Vary: Accept-Encoding
>
> I hope it helps..
>
> Regards
> Rich
>

I'll try this (and some other things I recently thought about) when I get
back home on friday :) I'll keep you updated.

Thanks!

-- 
Mailed by:
UnReAl4U - unreal4u
ICQ #: 54472056
www1: http://www.chw.net/
www2: http://unreal4u.com/


Re: [PHP] Cookies & sessions

2010-01-20 Thread clancy_1
On Wed, 20 Jan 2010 20:05:42 -0200, bsfaja...@gmail.com (Bruno Fajardo) wrote:

>2010/1/20  :
>> When you are working with sessions, provided you start your program with 
>> session_id(), you
>> can then do anything you like with session variables at any point in your 
>> program.
>
>Hi,
>
>You meant session_start() instead of session_id(), right?

Yes; Oops!

> But yes,
>once you started a session (before any output is sent to the browser,
>that includes echo and print statements, empty space chars, etc) you
>can do anything you like with the $_SESSION array, being able to read
>the stored values in other requests / scripts of your app, as long as
>the session is started.
>
>> In my
>> original question I asked if there was a cookie equivalent.
>
>As far as I know, yes, there is. You set a cookie using the
>setcookie() function. This function, in the same way as
>session_start(), must be called before any output is sent to the
>browser. Once a cookie is set in the client, you can read the $_COOKIE
>array in any subsequent request of your client, in any point of your
>app, just like session.

It is not equivalent if you can't set a cookie after you have generated any 
output.
>
>>
>> Someone said there was, but the above is simply demonstrating that their 
>> suggested
>> solution doesn't work. It appears there is no solution, but that the 
>> workaround is to turn
>> on output buffering, at least until you finish setting cookies, so that you 
>> can be certain
>> that no output is generated before this point.
>
>You don't need to use output buffering at all. You only need this
>mechanism if your script needs to output stuff before the
>session_start() or setcookie() functions get executed.

I don't NEED output buffering if I put the cookie handling logic right at the 
start of the
program, and don't ever want to put any diagnostics into it.  But there is a 
logical place
for it much later in my program, and I often want to put diagnostics into even 
the
simplest bit of code, and life is much easier if this doesn't disable the 
cookie handler.
>
>Well, I hope this information is helpful.

Yes, thanks to everyone who contributed.  I now have a better understanding of 
what
cookies are, and have turned on output buffering, enabling me to put the 
handler where I
want, and still be able to debug it.

Clancy

>Cheers,
>Bruno.
>
>>
>> --
>> 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] Open Source CMS

2010-01-20 Thread Hendry
Hi,

Anyone can share your favorite PHP open source CMS to work with and
what's the reason? I'm looking for something that easily extensible.
I've googled and found severals but I'm still confused, some from the
lists:
- Drupal
- Tomato CMS
- modx
- xoops
- Symphony

Thanks

# Hendry

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



Re: [PHP] Open Source CMS

2010-01-20 Thread Allen McCabe
I've not had much experience with CMS's, however Drupal seems pretty
featured, with the steep-learning curve; it's not very user friendly.

I'm working on my own CMS which is more generic, so that it can be used with
any kind of website (basically). I suggest you do the same; have a page
class with methods that allow you to create new pages. I have not yet
fleshed out this class, but I eventually plan to get it so that when I
"create a new page", my class will generate a PHP file with a unique page ID
number. Then it will log the link to this page into a links table and save
content I enter in different areas, eg. Scripts (here I write any PHP I will
need) and content (the body of the document, which can also make use of
PHP).

The Scripts and Body are saved to include files with the same name as the
ID, and the page loads the items associated with that ID. For example:











Does this make sense?


Anyone else have any questions/comments/critiques?


On Wed, Jan 20, 2010 at 7:29 PM, Hendry  wrote:

> Hi,
>
> Anyone can share your favorite PHP open source CMS to work with and
> what's the reason? I'm looking for something that easily extensible.
> I've googled and found severals but I'm still confused, some from the
> lists:
> - Drupal
> - Tomato CMS
> - modx
> - xoops
> - Symphony
>
> Thanks
>
> # Hendry
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Open Source CMS

2010-01-20 Thread Robert Cummings

Allen McCabe wrote:

I've not had much experience with CMS's, however Drupal seems pretty
featured, with the steep-learning curve; it's not very user friendly.


Not to disregard your own experience, but I've found Drupal surprisingly 
easy to get running with. In fact it's pretty much my first choice when 
installing a CMS for a client and I demsontrate how simple it is for 
them to add content. This is especially true in Canada where many 
websites are multilingual and Drupal offers one of the best interfaces 
for providing multilingual content. Additionally, the ability to create 
custom content types while possibly difficult for clients to grasp, is 
really simple for them to use if I do the legwork of creating the 
content types and associated views.


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] Open Source CMS

2010-01-20 Thread Allen McCabe
For a work in progress, view http://www.mwclans.com/new_index.php

The login fields are a 'component' I include in the header.
The links are generated from the 'links' table; the primary_navigation links
are a class by the same name, and the 'footer_navigation' are also a
different category. All links on this page are generated from the Links
table, and each row has 90% of the properties the HTML 'a' tag can have (eg.
fields: id, link_text, href, target, onmouseover, onmouseout, onclick, name,
class, etc.). The class is the same as the category.

The content is pulled from an include file with the same ID number as this
page ("home" page), which is "1", and the scripts.

There are additional features, like a theme class which pulls a theme ID
from the DB (a `site_settings` table).

Here is an example of the source code for the above link:





http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
http://www.w3.org/1999/xhtml";
xmlns:v="urn:schemas-microsoft-com:vml" >

 - 
















query('SELECT * FROM `links` WHERE `category` =
\'primary_navigation\'');

while ($listitem = $db->fetch_array($result))
{
echo "\t" . '' . $listitem['text'] . '' . "\n";
}
?>

 







query('SELECT * FROM `directories`
WHERE `id`=' . $pageFolder);
$row_1 = $db->fetch_row($result_1);
$folder_url = $row_1[2];
include(ROOT . $folder_url . 'content/' . $pageName
. '.inc.php'); # content/Homepage.inc.php
?>





query('SELECT * FROM `components`
WHERE `id` IN (' . $pageComponentsLeft . ');');
$count = $db->affected_rows;
$i = 1;

if ($count > 0)
{
while ($row = $db->fetch_array($result))
{
require_once($row['url']);
if ($i < $count)
{
echo "\n" . '' . "\n";
}

$i++;
}
}
}
?>
The CSS used for this layout is 100% valid and hack free.
To overcome Internet Explorer's broken box model, no horizontal padding or
margins are used. Instead, this design uses pixel widths and clever relative
positioning.





query('SELECT * FROM `components`
WHERE `id` IN (' . $pageComponentsRight . ');');
$count = $db->affected_rows;
$i = 1;

if ($count > 0)
{
while ($row = $db->fetch_array($result))
{
require_once($row['url']);
if ($i < $count)
{
echo "\n" . '' . "\n";
}

$i++;
}
}
}
?>
The holy grail 3 column liquid Layout has been tested on
the following browsers:






query($sql);
$row = $db->fetch_row($result);

if ($db->affected_rows > 0)
{
# /components/footerlinks.inc.php
include(ROOT . $row[2]);
}

?>










Again, any questions/comments/critiques are welcome!!

Allen



On Wed, Jan 20, 2010 at 7:29 PM, Hendry  wrote:

> Hi,
>
> Anyone can share your favorite PHP open source CMS to work with and
> what's the reason? I'm looking for something that easily extensible.
> I've googled and found severals but I'm still confused, some from the
> lists:
> - Drupal
> - Tomato CMS
> - modx
> - xoops
> - Symphony
>
> Thanks
>
> # Hendry
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Open Source CMS

2010-01-20 Thread Allen McCabe
I suppose I am opposed to 'custom systems' with PHP. I feel that you
shouldn't have to learn "new-stuff" that is specific to a certain system if
it is so extensive. I know, I'm lazy, but I've been trying to learn PHP (as
well as needing to learn JavaScript, SQL, and CSS 2.0 lately) and not stuff
that will only work in a closed system.

That said; Drupal is VERY powerful, and VERY convenient given the
multi-lingual aspects you (Rob) mentioned. From my angle, achieving what
wanted through Drupal was proving to be almost impossible, when I had a good
idea of how to accomplish it on my own, and figuring out how to integrate
Drupal with my own custom scripts was proving to be a headache for me, so I
ditched Drupal.

Again, Drupal is amazing. I guess what I was trying to say was "it depends".
Drupal is great for non-programmers who want to do very simple things, or
for professional PHP programmers who want to do pretty much anything.

Cheers :)

Allen

On Wed, Jan 20, 2010 at 8:14 PM, Robert Cummings wrote:

> Allen McCabe wrote:
>
>> I've not had much experience with CMS's, however Drupal seems pretty
>> featured, with the steep-learning curve; it's not very user friendly.
>>
>
> Not to disregard your own experience, but I've found Drupal surprisingly
> easy to get running with. In fact it's pretty much my first choice when
> installing a CMS for a client and I demsontrate how simple it is for them to
> add content. This is especially true in Canada where many websites are
> multilingual and Drupal offers one of the best interfaces for providing
> multilingual content. Additionally, the ability to create custom content
> types while possibly difficult for clients to grasp, is really simple for
> them to use if I do the legwork of creating the content types and associated
> views.
>
> Cheers,
> Rob.
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>


Re: [PHP] Open Source CMS

2010-01-20 Thread Hendry
Hi,

Thanks for both Robert and Allen for sharing, I agree, Drupal is very
easy to start with, and it is also very powerful, but somehow, I find
it very hard to extend which is might be due to my lack of experience.

# Hendry

On Thu, Jan 21, 2010 at 12:21 PM, Allen McCabe  wrote:
> I suppose I am opposed to 'custom systems' with PHP. I feel that you
> shouldn't have to learn "new-stuff" that is specific to a certain system if
> it is so extensive. I know, I'm lazy, but I've been trying to learn PHP (as
> well as needing to learn JavaScript, SQL, and CSS 2.0 lately) and not stuff
> that will only work in a closed system.
>
> That said; Drupal is VERY powerful, and VERY convenient given the
> multi-lingual aspects you (Rob) mentioned. From my angle, achieving what
> wanted through Drupal was proving to be almost impossible, when I had a good
> idea of how to accomplish it on my own, and figuring out how to integrate
> Drupal with my own custom scripts was proving to be a headache for me, so I
> ditched Drupal.
>
> Again, Drupal is amazing. I guess what I was trying to say was "it depends".
> Drupal is great for non-programmers who want to do very simple things, or
> for professional PHP programmers who want to do pretty much anything.
>
> Cheers :)
>
> Allen

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



Re: [PHP] PHP 5.3 shared hosting

2010-01-20 Thread Adam Richardson
On Fri, Jan 15, 2010 at 6:25 PM, Michael A. Peters  wrote:

> Adam Richardson wrote:
>
>> Hi,
>>
>> I've developed a framework that requires PHP 5.3 (it takes a more
>> functional
>> approach.)  I'm hosting my own apps on a dedicated server running cpanel
>> (thanks to their recent upgrade.)  However, for client work I prefer not
>> to
>> personally host the websites.
>>
>> I've been contacting hosts about their shared hosting options, and I've
>> only
>> found a couple that accommodate PHP 5.3 so far.  Anybody have
>> recommendations for shared hosting providers that are supporting php 5.3
>> (many of the smaller sites I'm working with don't merit a VPS?)
>>
>> Thank you very much for your help,
>>
>> Adam
>>
>>
> I would suggest pointing your clients at something like linode that allows
> them to run whatever they hell they want to run.
>
> I'm running CentOS 5.x w/ php 5.2.12 for example.
>
> I need to update them, but if you want, here are some php 5.3 src.rpm's
> that can be used to build php 5.3 on a CentOS / RHEL 5.x system -
>
> http://www.clfsrpm.net/php/
>
> Running a xen instance is a lot nicer than shared hosting, and not really
> that expensive, and is really preferable to "shared hosting".
>

Because it's hard to find them (even using Google), I've added a page to
display the web hosts that I've found offering PHP 5.3 on shared accounts:
http://nephtaliproject.com/php_53_hosts/index.php

Please feel free to suggest others (or just make a better listing page,
which wouldn't be much work, either.)

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] Open Source CMS

2010-01-20 Thread Paul M Foster
On Thu, Jan 21, 2010 at 11:29:54AM +0800, Hendry wrote:

> Hi,
> 
> Anyone can share your favorite PHP open source CMS to work with and
> what's the reason? I'm looking for something that easily extensible.
> I've googled and found severals but I'm still confused, some from the
> lists:
> - Drupal
> - Tomato CMS
> - modx
> - xoops
> - Symphony

Add CodeIgniter to your list. Relatively easy to understand and extend.
Though I'm not sure I'd classify it as a "content management system".
(Same for Symfony.)

Paul

-- 
Paul M. Foster

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



Re: [PHP] Open Source CMS

2010-01-20 Thread Paul M Foster
On Wed, Jan 20, 2010 at 08:15:55PM -0800, Allen McCabe wrote:

> For a work in progress, view http://www.mwclans.com/new_index.php
> 
> The login fields are a 'component' I include in the header.
> The links are generated from the 'links' table; the primary_navigation links
> are a class by the same name, and the 'footer_navigation' are also a
> different category. All links on this page are generated from the Links
> table, and each row has 90% of the properties the HTML 'a' tag can have (eg.
> fields: id, link_text, href, target, onmouseover, onmouseout, onclick, name,
> class, etc.). The class is the same as the category.
> 
> The content is pulled from an include file with the same ID number as this
> page ("home" page), which is "1", and the scripts.
> 
> There are additional features, like a theme class which pulls a theme ID
> from the DB (a `site_settings` table).
> 
> Here is an example of the source code for the above link:
> 

You're free to do this as you like, and I've done it in the past just as
you did. But I think the general concensus is that you want to
intersperse as little complicated PHP inside your HTML as possible. For
example, you're doing a database call inside your HTML and then
displaying the results. The more acceptable practice is to make these
calls before you start outputting HTML, shove the values into variables
or an array, and then just loop through the *values* inside your HTML.
There are a couple of reasons for doing it this way. First, anyone
looking at the HTML later who isn't a programmer will have an easier
time of it if there aren't lines and lines of PHP code inside the HTML.
Second, it makes your code more "modular". That is, it puts your main
body of PHP code all together. That aids in debugging, testing and the
like later. This approach means your code is dispersed among several
files instead of just one. But it aids in debugging. I find it painful
to have to scan through HTML for PHP code, so I can fix a problem.

You'll also find that if you have a variety of pages which are all laid
out the same way, it's better to put that HTML in a separate "template"
file. Insert some code in it to display values as needed. Then when you
want to paint a page, simply define the values you want to display, and

include('template.php');

This way, if you make a change to the design or look of the site, you
can make that change to one (template) file and it will echo all over
the site. This is particularly important if you're working with
"designers" who don't know HTML but do the work of designing pages.

This is just simple advice based on my experience. Feel free to ignore
it completely if you work better a different way.

Paul

-- 
Paul M. Foster

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



[PHP] PHPCoder Help

2010-01-20 Thread Alberto García Gómez
I have a couple of php script coded with PHPCoder, which (I don't know why) 
isn't working. I need someone who can decode those scripts for me and send me 
the codes decrypted or teach me how do it...thanks a lot

Saludos Fraternales
_
Atte.
Alberto García Gómez M:.M:.
Administrador de Redes/Webmaster
IPI "Carlos Marx", Matanzas. Cuba.
0145-2887(30-33) ext 124


__ Información de ESET NOD32 Antivirus, versión de la base de firmas de 
virus 4791 (20100120) __

ESET NOD32 Antivirus ha comprobado este mensaje.

http://www.eset.com