php-general Digest 2 Jun 2009 15:49:59 -0000 Issue 6155

Topics (messages 293470 through 293489):

PHP problem
        293470 by: tRace DOliveira

PHP Help
        293471 by: tRace DOliveira
        293479 by: Bastien Koert
        293484 by: Topbit
        293488 by: Eddie Drapkin

Web application design considerations - a good reference ?
        293472 by: Angus Mann
        293473 by: Larry Garfield
        293476 by: Tony Marston
        293477 by: mrfroasty
        293480 by: bruce
        293481 by: Paul M Foster
        293482 by: Lists
        293483 by: Sancar Saran
        293485 by: Tony Marston
        293486 by: Eddie Drapkin

Re: Create multipart email
        293474 by: Guus Ellenkamp
        293475 by: Guus Ellenkamp

Re: PHP scalability problem -- APC vs EAccelerator
        293478 by: Eddie Drapkin

PCI compliance issue
        293487 by: Skip Evans

[php] most recent row from table
        293489 by: HELP!

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
I think that PHP is the best scripting language ever created...I'm currently 
doing a study of PHP and I want to know how APC can be used to improve PHP 
performance and how it can be implemented and also if there is some  other 
alternative other than APC of improving PHP performance ? The problem that I 
face is that as many requests are made the server is placed under alot of 
pressure and cannot deal with it....



      

--- End Message ---
--- Begin Message ---
I think that PHP is the best scripting language ever created...I'm currently 
doing a study of PHP and I want to know how APC can be used to improve PHP 
performance and how it can be implemented and also if there is some  other 
alternative other than APC of improving PHP performance ? The problem that I 
face is that as many requests are made the server is placed under alot of 
pressure and cannot deal with it....
Thank you, 
Leonard D'Oliveira 


      

--- End Message ---
--- Begin Message ---
On Tue, Jun 2, 2009 at 12:33 AM, tRace DOliveira <[email protected]> wrote:
>
> I think that PHP is the best scripting language ever created...I'm currently 
> doing a study of PHP and I want to know how APC can be used to improve PHP 
> performance and how it can be implemented and also if there is some  other 
> alternative other than APC of improving PHP performance ? The problem that I 
> face is that as many requests are made the server is placed under alot of 
> pressure and cannot deal with it....
> Thank you,
> Leonard D'Oliveira
>
>
>

memchaced
eAccelerator

custom caching scripts

opcode caching to cache bytecode

stfw
eAccelerator

--

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
On Tue, Jun 2, 2009 at 5:33 AM, tRace DOliveira <[email protected]> wrote:
> I think that PHP is the best scripting language ever created...I'm currently 
> doing a study of PHP and I want to know how APC can be used to improve PHP 
> performance and how it can be implemented and also if there is some  other 
> alternative other than APC of improving PHP performance ? The problem that I 
> face is that as many requests are made the server is placed under alot of 
> pressure and cannot deal with it....

A large part of the reason PHP is so good at what it does is that
scaling it up on a single, and then to multi-machine sites and from
there to even millions of users is a well understood path.

For APC, if you are running your own server and running a PHP site on
there, if you're not already running APC or a similar caching system
on there, you are just wasting CPU effort.

There are a number of websites already out there that demonstrate the
sort of caching and optimisations that can be performed on a LAMP
stack, both within PHP code (but the various micro-optimisations of
changing quotes and using one kind of array handling over another is
only useful at the most extreme end of optimisations - and if you
wonder if you need them - then you don't).  I'll be writing on the
topic of scaling on my blog soon as well, so it might be useful to
keep an eye on the in the next few weeks as well.

For now, http://google.com/search?q=scaling+PHP will give you a lot of
food for thought.

Topbit
http://topbit.co.uk/

--- End Message ---
--- Begin Message ---
There's a few things about your post I'd like to comment on.  One, if you're
not using APC, I definitely agree with the fact that you're just wasting
resources.  However, you mention micro-optimizations and say that they're
hardly useful, but in some cases it's a huge difference. ' vs. " is like a
0.1% speed difference or something equally negligible, but using
isset($foo['bar']) instead of in_array($foo, 'bar') is almost an exponential
speedup (it approaches that level of difference as the array size gets
larger and larger), so there are some definite good practices with common
fundamental structures that are worth paying attention to.  And finally, you
mention optimizing the LAMP stack, when the fact of the matter is the best
way to optimize that stack is to get rid of it.  Apache is huge and slow and
there are very fast and viable replacements for it (I use nginx, but a lot
of people are satisfied with lighttpd) and using either spawn-fcgi or fpm,
php concurrency can increase by as much as 50%.  And regarding MySQL,
installing XtraDB, Percona's enhanced InnoDB build with a whole boatload of
patches, is the easiest way to squeeze more performance out of MySQL.

To the OP, though, the point is that there is a definite scalability path
with regards to PHP and it's not something to really fret over, as there are
tons of documentation, talks, presentations, blog posts, strategies, etc to
achieve the most with PHP.  Although, in the end, PHP itself is rarely your
bottleneck, but instead the way you have your webserver setup bottlenecks
your clientele and the way you have your queries written bottlenecks your
server.  I don't want to say that PHP speed is negligible, but if you write
the world's worst PHP, but have an opcode cache and a fast DB implementation
(and a 100 ySlow score) no one is ever going to notice how bad your code is,
whereas someone else could write great code on a poorly performing site and
wind up in a much worse situation.

On Tue, Jun 2, 2009 at 10:20 AM, Topbit <[email protected]> wrote:

> On Tue, Jun 2, 2009 at 5:33 AM, tRace DOliveira <[email protected]>
> wrote:
> > I think that PHP is the best scripting language ever created...I'm
> currently doing a study of PHP and I want to know how APC can be used to
> improve PHP performance and how it can be implemented and also if there is
> some  other alternative other than APC of improving PHP performance ? The
> problem that I face is that as many requests are made the server is placed
> under alot of pressure and cannot deal with it....
>
> A large part of the reason PHP is so good at what it does is that
> scaling it up on a single, and then to multi-machine sites and from
> there to even millions of users is a well understood path.
>
> For APC, if you are running your own server and running a PHP site on
> there, if you're not already running APC or a similar caching system
> on there, you are just wasting CPU effort.
>
> There are a number of websites already out there that demonstrate the
> sort of caching and optimisations that can be performed on a LAMP
> stack, both within PHP code (but the various micro-optimisations of
> changing quotes and using one kind of array handling over another is
> only useful at the most extreme end of optimisations - and if you
> wonder if you need them - then you don't).  I'll be writing on the
> topic of scaling on my blog soon as well, so it might be useful to
> keep an eye on the in the next few weeks as well.
>
> For now, http://google.com/search?q=scaling+PHP will give you a lot of
> food for thought.
>
> Topbit
> http://topbit.co.uk/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Hi all.

I'm working on a PHP project for my own personal business use. It will handle billing and invoices as well as payments and time management, bookings, appointments and a few more. I may add things like personal messaging between the various users and a customer login to check on the progress of their accounts.

It is a big project and will probably take a year or so to complete in my spare time.

I have made a couple of starts but I have no experience in creating such large applications and I find I often end up with spaghetti code. I've tried using session variables to keep track of where and what the program is doing but there are so many permuations and combinations I found myself writing endless streams of if's, and's and or's just to figure out what page to display.

The code is not the probblem for me...it's the flow and organization of the code.

Can anybody point me to a good book or tutorial that lays down the principles and gives some suggestions for integrating the many subroutines of a large application? I want to make the code readable and logical in its flow, and avoid repetition of code segments.

Much appreciated.
Angus






--- End Message ---
--- Begin Message ---
Do not under any circumstances try to do this from scratch. :-)  Use an 
existing framework like Zend Framework or CakePHP or a CMS/framework hybrid 
like Drupal or a dedicated app for billing and processing.  It will save you 
months of work, and countless security holes.  

Even if you don't use it directly, studying a large existing system like that 
will open your mind to better ways of thinking.  I only half-joke when I say 
that everything I know about PHP I learned from Drupal. :-)

On Monday 01 June 2009 11:50:36 pm Angus Mann wrote:
> Hi all.
>
> I'm working on a PHP project for my own personal business use. It will
> handle billing and invoices as well as payments and time management,
> bookings, appointments and a few more. I may add things like personal
> messaging between the various users and a customer login to check on the
> progress of their accounts.
>
> It is a big project and will probably take a year or so to complete in my
> spare time.
>
> I have made a couple of starts but I have no experience in creating such
> large applications and I find I often end up with spaghetti code. I've
> tried using session variables to keep track of where and what the program
> is doing but there are so many permuations and combinations I found myself
> writing endless streams of if's, and's and or's just to figure out what
> page to display.
>
> The code is not the probblem for me...it's the flow and organization of the
> code.
>
> Can anybody point me to a good book or tutorial that lays down the
> principles and gives some suggestions for integrating the many subroutines
> of a large application? I want to make the code readable and logical in its
> flow, and avoid repetition of code segments.
>
> Much appreciated.
> Angus

-- 
Larry Garfield
[email protected]

--- End Message ---
--- Begin Message ---
If you are building a business application with PHP rather than an ordinary 
website then I suggest that you use a framework instead of trying to 
reinvent the wheel (and making a hash of it). The Radicore framework was 
specifically designed for CRUD applications - it uses forms to perform 
Create/Read/Update/Delete operations on the database - so it would be a 
better fit than one which was designed for common-or-garden websites.

The heart of any database application is the database design. Get this wrong 
and you are stuffed from the very start. Once you have used the rules of 
data normalisation to design your database you simply build it, then import 
the database into the Radicore data dictionary. Then you export each table 
to produce a class file for that table. Still in the data dictionary you can 
build end-user transactions by selecting a database table, a transaction 
pattern, then pressing the 'generate' button. This will generate the scripts 
and the screen layouts to access the table,  and you can run these scripts 
through the Radicore menu system. All this without having to write a single 
line of SQL, HTML or even PHP. The only PHP code you need to write is when 
you want to alter the default behaviour or implement custom business rules.

The Radicore framework comes with a built-in Role Based Access Control 
(RBAC) system, and Audit Logging system and a Workflow system. It was 
designed using the Three Tier Architecture and MVC design patterns, so makes 
maximum use of reusable modules.

There is an enormous amount of documentation to be found at 
http://www.radicore.org as well as a tutorial and some sample applications. 
Try it and see.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

""Angus Mann"" <[email protected]> wrote in message 
news:e23929c24916447cbef5c45eac9af...@guspc...
> Hi all.
>
> I'm working on a PHP project for my own personal business use. It will 
> handle billing and invoices as well as payments and time management, 
> bookings, appointments and a few more. I may add things like personal 
> messaging between the various users and a customer login to check on the 
> progress of their accounts.
>
> It is a big project and will probably take a year or so to complete in my 
> spare time.
>
> I have made a couple of starts but I have no experience in creating such 
> large applications and I find I often end up with spaghetti code. I've 
> tried using session variables to keep track of where and what the program 
> is doing but there are so many permuations and combinations I found myself 
> writing endless streams of if's, and's and or's just to figure out what 
> page to display.
>
> The code is not the probblem for me...it's the flow and organization of 
> the code.
>
> Can anybody point me to a good book or tutorial that lays down the 
> principles and gives some suggestions for integrating the many subroutines 
> of a large application? I want to make the code readable and logical in 
> its flow, and avoid repetition of code segments.
>
> Much appreciated.
> Angus
>
>
>
>
> 



--- End Message ---
--- Begin Message ---
I am on the same position, half a year ago I tried to wrote the PHP
application (sake of learning) using from scratch approaches.
Now I want to have a production application, I am bussy to start over
and writting/intergrating everthing using a framework.
I think for my case is Joomla...
So I think its worth using platforms...

GR
Muhsin



Angus Mann wrote:
> Hi all.
>
> I'm working on a PHP project for my own personal business use. It will
> handle billing and invoices as well as payments and time management,
> bookings, appointments and a few more. I may add things like personal
> messaging between the various users and a customer login to check on
> the progress of their accounts.
>
> It is a big project and will probably take a year or so to complete in
> my spare time.
>
> I have made a couple of starts but I have no experience in creating
> such large applications and I find I often end up with spaghetti code.
> I've tried using session variables to keep track of where and what the
> program is doing but there are so many permuations and combinations I
> found myself writing endless streams of if's, and's and or's just to
> figure out what page to display.
>
> The code is not the probblem for me...it's the flow and organization
> of the code.
>
> Can anybody point me to a good book or tutorial that lays down the
> principles and gives some suggestions for integrating the many
> subroutines of a large application? I want to make the code readable
> and logical in its flow, and avoid repetition of code segments.
>
> Much appreciated.
> Angus
>
>
>
>
>
>


-- 
Extra details:
OSS:Gentoo Linux
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,VB,VHDL,bash,PHP,SQL,HTML,CSS
Typo:40WPM
url:http://mambo-tech.net
url:http://blog.mambo-tech.net


--- End Message ---
--- Begin Message ---
hi angus...

You're probably going to get a lot of different approaches to this one! as a
long term/time developer in a past life.. In my humble opinion, a reasonable
approach is to start by laying out the key things that the app has to
accomplish, and then to break this down into a list/sublist until you get a
comprehensive list of things that your app should do... You can put these
items into buckets to help keep track of what you've thought about. Each
bucket can then be aligned with a given section of your website as you start
to get into the UI/Look-feel of the site.

One of the most important/key things you can try to do, is to find someone a
few people, who are willing to act as a sounding board for the different
aspects/parts of your project.

Once you've gotten the list, and a basic UI/Wireframe kind of overview (and
you can use word/openoffice/etc.. to create a wireframe) you can then have
something that you can kind of look at, kick the tires so to speak of what
you're envisioning the app to be. This overall process forces you to really
think about what the app should consist of, as well well as how it's going
to be put together, how the different sections are going to flow...

Once you all of the above, you can focus on the workflow/processes of the
app. What happens when the user does X, who gets notified, when the user
does Y, that kind of thing...

There's a lot more, but this should get you started!!!

Good luck!


-----Original Message-----
From: Angus Mann [mailto:[email protected]]
Sent: Monday, June 01, 2009 9:51 PM
To: [email protected]
Subject: [PHP] Web application design considerations - a good reference
?


Hi all.

I'm working on a PHP project for my own personal business use. It will
handle billing and invoices as well as payments and time management,
bookings, appointments and a few more. I may add things like personal
messaging between the various users and a customer login to check on the
progress of their accounts.

It is a big project and will probably take a year or so to complete in my
spare time.

I have made a couple of starts but I have no experience in creating such
large applications and I find I often end up with spaghetti code. I've tried
using session variables to keep track of where and what the program is doing
but there are so many permuations and combinations I found myself writing
endless streams of if's, and's and or's just to figure out what page to
display.

The code is not the probblem for me...it's the flow and organization of the
code.

Can anybody point me to a good book or tutorial that lays down the
principles and gives some suggestions for integrating the many subroutines
of a large application? I want to make the code readable and logical in its
flow, and avoid repetition of code segments.

Much appreciated.
Angus






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


--- End Message ---
--- Begin Message ---
On Tue, Jun 02, 2009 at 02:50:36PM +1000, Angus Mann wrote:

> Hi all.
>
> I'm working on a PHP project for my own personal business use. It will
> handle billing and invoices as well as payments and time management,
> bookings, appointments and a few more. I may add things like personal
> messaging between the various users and a customer login to check on the
> progress of their accounts.
>
> It is a big project and will probably take a year or so to complete in my
> spare time.
>
> I have made a couple of starts but I have no experience in creating such
> large applications and I find I often end up with spaghetti code. I've 
> tried
> using session variables to keep track of where and what the program is 
> doing
> but there are so many permuations and combinations I found myself writing
> endless streams of if's, and's and or's just to figure out what page to
> display.
>
> The code is not the probblem for me...it's the flow and organization of the
> code.
>
> Can anybody point me to a good book or tutorial that lays down the
> principles and gives some suggestions for integrating the many subroutines
> of a large application? I want to make the code readable and logical in its
> flow, and avoid repetition of code segments.

Other responders have cautioned you to use a framework (my vote is
CodeIgniter) to save time. You can do this, but I've done what you're
doing, without a framework, and it's not that hard.

The first and most important point is to get the database right, as
pointed out elsewhere. Think long and hard about this one. Once done,
write code to build the database from scratch (I typically call this
"coldstart" code).

In general, your screens will involve adding, editing, deleting,
searching and listing records from your database. Consider doing an
outline of what screens you'll need. Take the various items you deal
with, like customers, invoices, jobs, etc., and determine if you want to
create add, edit, delete, search and listing screens for each. Put
everthing you might need in your outline.

You may find, in the process of doing all this, that you need to rethink
parts of your database.

Think about security, as in passwords, usernames, etc. Put in your
outline some screens for logging in and logging out, and add whatever
infrastructure you need to your database. One point here: The only time
I use session variables is in this area. Otherwise, you shouldn't need
them for keeping track of things.

Let me expand on that. When you have a form (which is what most of your
application will be composed of), it will return all the data you need
to process it. You process it, and proceed to a menu or somesuch to
tackle the next task. If, for some reason, you need to track data across
invocations of screens, you can typically do it with hidden fields in
your forms.

You'll typically need a template which contains the HTML stuff that
needs to fit around your individual screens, and which won't change from
screen to screen. Inside that template, you can include a call to
whatever "view" file is needed for that screen. Something like:

<?php include($viewfile); ?>

You can build each screen however you want, but it's really just form
work-- a field for name, a field for address, etc. At the bottom, a
submit button. Each form will be driven by a "controller" which sets
everything up for the view file. And it will also process the results
for the view (once the user hits the "submit" button). It will hand off
results to the "model" file, which knows all about the database, so the
model file (class) can vet and store the data properly.

That's the way I've done this, through two iterations of my
applications. My internal system handles customers, invoices, payables,
statistics, mailing lists, payroll, pricing, a calendar, and several
other areas for my business.

Others will doubtless argue about how I've done this. There are about as
many opinions about how all this should be done as there are developers.
I'm just giving you advice on how I've done it. Feel free to ask other
questions.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
Angus Mann wrote:
Hi all.

I'm working on a PHP project for my own personal business use. It will handle billing and invoices as well as payments and time management, bookings, appointments and a few more. I may add things like personal messaging between the various users and a customer login to check on the progress of their accounts.

It is a big project and will probably take a year or so to complete in my spare time.

I have made a couple of starts but I have no experience in creating such large applications and I find I often end up with spaghetti code. I've tried using session variables to keep track of where and what the program is doing but there are so many permuations and combinations I found myself writing endless streams of if's, and's and or's just to figure out what page to display.

The code is not the probblem for me...it's the flow and organization of the code.

Can anybody point me to a good book or tutorial that lays down the principles and gives some suggestions for integrating the many subroutines of a large application? I want to make the code readable and logical in its flow, and avoid repetition of code segments.

Much appreciated.
Angus

I wrote one from Scratch over many years and I don't know how I would
operate my business without it at this point. Some little things I would suggest... if you have multiple relationships over several .dbs.. customers db relating to a invoices db, proposals db, quotes db etc..
make sure to use a global unique ID across all databases.. meaning,
every time a new record is created in any of these databases, I
grab an I.D. from a function that exists only to create a unique ID.
This way you don't run the risk of creating false relationships.

Some ideas?.. I probably went over board, but all my invoices, quotes etc. also have a corresponding hard copy (file that is written), other
than the database record, which acts as redundancy.

The problem with any framework such as Drupal is, though you can avoid reinventing the wheel in some cases, you also build stuff that looks like existing stuff and you have the same known security management as existing stuff, and you are sometimes limited on function... So, I just wanted to add this alternate perspective that it is perfectly doable starting from the ground up.

Donovan





--
  =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o
  D. BROOKE                       EUCA Design Center
                               WebDNA Software Corp.
  WEB:> http://www.euca.us  |   http://www.webdna.us
  =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o
  WebDNA: [** Square Bracket Utopia **]

--- End Message ---
--- Begin Message ---
On Tuesday 02 June 2009 07:50:36 am Angus Mann wrote:
> Hi all.
>
> I'm working on a PHP project for my own personal business use. It will
> handle billing and invoices as well as payments and time management,
> bookings, appointments and a few more. I may add things like personal
> messaging between the various users and a customer login to check on the
> progress of their accounts.
>
> It is a big project and will probably take a year or so to complete in my
> spare time.
>
> I have made a couple of starts but I have no experience in creating such
> large applications and I find I often end up with spaghetti code. I've
> tried using session variables to keep track of where and what the program
> is doing but there are so many permuations and combinations I found myself
> writing endless streams of if's, and's and or's just to figure out what
> page to display.
>
> The code is not the probblem for me...it's the flow and organization of the
> code.
>
> Can anybody point me to a good book or tutorial that lays down the
> principles and gives some suggestions for integrating the many subroutines
> of a large application? I want to make the code readable and logical in its
> flow, and avoid repetition of code segments.
>
> Much appreciated.
> Angus


Hello,

Use CMS/Framework

like Drupal or TYPO3

All of them have coding principles.

You can follow. Plus they do tons of things.

(authentication. this that)

Your time may cut 3 months.

--- End Message ---
--- Begin Message ---
"Paul M Foster" <[email protected]> wrote in message 
news:[email protected]...
> On Tue, Jun 02, 2009 at 02:50:36PM +1000, Angus Mann wrote:
>
>> Hi all.
>>
>> I'm working on a PHP project for my own personal business use. It will
>> handle billing and invoices as well as payments and time management,
>> bookings, appointments and a few more. I may add things like personal
>> messaging between the various users and a customer login to check on the
>> progress of their accounts.
>>
>> It is a big project and will probably take a year or so to complete in my
>> spare time.
>>
>> I have made a couple of starts but I have no experience in creating such
>> large applications and I find I often end up with spaghetti code. I've
>> tried
>> using session variables to keep track of where and what the program is
>> doing
>> but there are so many permuations and combinations I found myself writing
>> endless streams of if's, and's and or's just to figure out what page to
>> display.
>>
>> The code is not the probblem for me...it's the flow and organization of 
>> the
>> code.
>>
>> Can anybody point me to a good book or tutorial that lays down the
>> principles and gives some suggestions for integrating the many 
>> subroutines
>> of a large application? I want to make the code readable and logical in 
>> its
>> flow, and avoid repetition of code segments.
>
> Other responders have cautioned you to use a framework (my vote is
> CodeIgniter) to save time. You can do this, but I've done what you're
> doing, without a framework, and it's not that hard.
>
> The first and most important point is to get the database right, as
> pointed out elsewhere. Think long and hard about this one.

So, so true.

> Once done,
> write code to build the database from scratch (I typically call this
> "coldstart" code).

With the Radicore framework you don't write code to build the database, you 
build your database then import the schema into the data dictionary and then 
have the code generated for you.

> In general, your screens will involve adding, editing, deleting,
> searching and listing records from your database. Consider doing an
> outline of what screens you'll need. Take the various items you deal
> with, like customers, invoices, jobs, etc., and determine if you want to
> create add, edit, delete, search and listing screens for each. Put
> everthing you might need in your outline.

As a rule of thumb for most tables you will need the same family of forms - 
list, search, create, read, update and delete - and the Radicore framework 
has patterns that will generate these for you at the touch of a button.

When you want  to combine 2 tables in a single form, such as "for a selected 
CUSTOMER show me a list of related INVOICES" or "for a selected INVOICE show 
me a list of related INVOICE_LINES" then there is a different pattern.

Try it, and be anazed at how much code you DON'T have to write.

> You may find, in the process of doing all this, that you need to rethink
> parts of your database.
>
> Think about security, as in passwords, usernames, etc. Put in your
> outline some screens for logging in and logging out,

These functions are built into Radicore, along with password encryption. You 
also have the choice of Single or Two Factor Authentication (via a RADIUS or 
LDAP server)

> and add whatever
> infrastructure you need to your database. One point here: The only time
> I use session variables is in this area. Otherwise, you shouldn't need
> them for keeping track of things.
>
> Let me expand on that. When you have a form (which is what most of your
> application will be composed of), it will return all the data you need
> to process it. You process it, and proceed to a menu or somesuch to
> tackle the next task. If, for some reason, you need to track data across
> invocations of screens, you can typically do it with hidden fields in
> your forms.

I would advise against this as hidden fields in forms are NOT in fact 
invisible. The user can see what is there simply by using the browser's 
"View Source" button. It is even possible for the user to copy the the form, 
change the variables and submit it with different data. How much of a 
security breach could that be? I use session data for everything so that 
nothing is exposed on the client that does not need to be.

> You'll typically need a template which contains the HTML stuff that
> needs to fit around your individual screens, and which won't change from
> screen to screen. Inside that template, you can include a call to
> whatever "view" file is needed for that screen. Something like:
>
> <?php include($viewfile); ?>
>
> You can build each screen however you want, but it's really just form
> work-- a field for name, a field for address, etc. At the bottom, a
> submit button. Each form will be driven by a "controller" which sets
> everything up for the view file. And it will also process the results
> for the view (once the user hits the "submit" button). It will hand off
> results to the "model" file, which knows all about the database, so the
> model file (class) can vet and store the data properly.

In Radicore the screens structure files are generated using default details 
from the data dictionary, but these can be customised very easily. You don't 
need to write page controllers as there is already a pre-built page 
controller for each transaction pattern. You don't need to write any code to 
perform primary validation (such as checking that required fields are not 
empty, date fields contain dates, numeric fields contain numbers,etc) as the 
framework does this for yo automatcally using information exported from the 
data dictionary.

> That's the way I've done this, through two iterations of my
> applications. My internal system handles customers, invoices, payables,
> statistics, mailing lists, payroll, pricing, a calendar, and several
> other areas for my business.

Likewise I have written an entire ERP application using nothing but the 
Radicore framework and the Data Model Resource Book by Len Silverston. I 
built the PARTY, PRODUCT, ORDER, SHIPMENTS and INVENTORY databases from the 
shemas in the book, then used the Radicore data dictionary to generate  the 
basic trasactions. All I had to do then was modify the table classes for the 
business rules, customise a few screens, and I have my working application. 
It is being used in real life by an online jewelery company, so it's not 
just an amateur product.

> Others will doubtless argue about how I've done this. There are about as
> many opinions about how all this should be done as there are developers.

How true. How very true.

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

> I'm just giving you advice on how I've done it. Feel free to ask other
> questions.
>
> Paul
>
> -- 
> Paul M. Foster 



--- End Message ---
--- Begin Message ---
My suggestion to you is probably mosty a rehashing of what a lot of other
people have said.  I definitely think you should take a good, hard look at
some existing solutions (frameworks, cms's, etc.) and decide whether you
want to use one or not.  In my experience, which is admittedly limited,
pre-fabricated frameworks like those mentioned in this thread often have way
more functionality than you'll actually need, like putting up a painting
with a jackhammer.  If you decide not to use one, you'll at the very least
get a lot of invaluable experience working with PHP and seeing how things
are setup.  Maybe you'll directly emulate a code layout and flow structure,
maybe you'll take a bit from drupal, and a bit from cake, and a bit from
wordpress, or maybe by seeing them, you'll reject their ideas for your own.
No matter what you do, it's exposure to someone else's ideas and through
that, you can help build your own instead of walking down that same road and
falling in the same pitfalls that other people have.

I'd also like to second someone's previous suggestion that you not work
alone.  In my experience, there's pros and cons to every idea and every idea
has a sibling - at least one other way of accomplishing the same task.  If
you surround yourself with good people that know what they're doing and have
a good discourse about how to do A, B and C and bounce ideas off of one
another, there's a good chance that the ultimate product will be much better
than if you had elected to work alone.

That's all I've got

--Eddie

On Tue, Jun 2, 2009 at 9:48 AM, Lists <[email protected]> wrote:

> Angus Mann wrote:
>
>> Hi all.
>>
>> I'm working on a PHP project for my own personal business use. It will
>> handle billing and invoices as well as payments and time management,
>> bookings, appointments and a few more. I may add things like personal
>> messaging between the various users and a customer login to check on the
>> progress of their accounts.
>>
>> It is a big project and will probably take a year or so to complete in my
>> spare time.
>>
>> I have made a couple of starts but I have no experience in creating such
>> large applications and I find I often end up with spaghetti code. I've tried
>> using session variables to keep track of where and what the program is doing
>> but there are so many permuations and combinations I found myself writing
>> endless streams of if's, and's and or's just to figure out what page to
>> display.
>>
>> The code is not the probblem for me...it's the flow and organization of
>> the code.
>>
>> Can anybody point me to a good book or tutorial that lays down the
>> principles and gives some suggestions for integrating the many subroutines
>> of a large application? I want to make the code readable and logical in its
>> flow, and avoid repetition of code segments.
>>
>> Much appreciated.
>> Angus
>>
>
> I wrote one from Scratch over many years and I don't know how I would
> operate my business without it at this point. Some little things I would
> suggest... if you have multiple relationships over several .dbs.. customers
> db relating to a invoices db, proposals db, quotes db etc..
> make sure to use a global unique ID across all databases.. meaning,
> every time a new record is created in any of these databases, I
> grab an I.D. from a function that exists only to create a unique ID.
> This way you don't run the risk of creating false relationships.
>
> Some ideas?.. I probably went over board, but all my invoices, quotes etc.
> also have a corresponding hard copy (file that is written), other
> than the database record, which acts as redundancy.
>
> The problem with any framework such as Drupal is, though you can avoid
> reinventing the wheel in some cases, you also build stuff that looks like
> existing stuff and you have the same known security management as existing
> stuff, and you are sometimes limited on function... So, I just wanted to add
> this alternate perspective that it is perfectly doable starting from the
> ground up.
>
> Donovan
>
>
>
>
>
> --
>  =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o
>  D. BROOKE                       EUCA Design Center
>                               WebDNA Software Corp.
>  WEB:> http://www.euca.us  |   http://www.webdna.us
>  =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o
>  WebDNA: [** Square Bracket Utopia **]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Thanks. I tried and it seems quite straightforward. However, I get the 
message 'could not instantiate mail function'. Seemed to have something to 
do with the 'to' address, but could not figure out what exactly. Also 
searched the internet, but did not find the solution. Any suggestion?

"Phpster" <[email protected]> wrote in message 
news:[email protected]...
> Use phpmailer, makes it simple
>
> Bastien
>
> Sent from my iPod
>
> On May 28, 2009, at 4:47, "Guus Ellenkamp"  <[email protected]> 
> wrote:
>
>> I'm trying to attach an uploaded file to an e-mail which I receive in
>> Outlook. Neither the first part, nor the second part displays  properly. 
>> The
>> header looks ok when displayed on the screen. What am I missing?
>>
>> See code below.
>> function xmail($mailto, $from_mail, $from_name, $replyto, $subject,
>> $message, $origname, $tempfile, $filetype) {
>>
>> $file = $tempfile;
>>
>> $file_size = filesize($file);
>>
>> $handle = fopen($file, "r");
>>
>> $content = fread($handle, $file_size);
>>
>> fclose($handle);
>>
>> $content = chunk_split(base64_encode($content));
>>
>> $uid = md5(uniqid(time()));
>>
>> $name = basename($origname);
>>
>> $header = "From: ".$from_name." <".$from_mail.">\r\n";
>>
>> $header .= "Reply-To: ".$replyto."\r\n";
>>
>> $header .= "MIME-Version: 1.0\r\n";
>>
>> $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n 
>> \r\n";
>>
>> $header .= "This is a multi-part message in MIME format.\r\n";
>>
>> $header .= "--".$uid."\r\n";
>>
>> $header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
>>
>> $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
>>
>> $header .= $message."\r\n\r\n";
>>
>> $header .= "--".$uid."\r\n";
>>
>> $header .= "Content-Type: ".$filetype."; name=\"".$name."\"\r\n"; //  use
>> diff. tyoes here
>>
>> $header .= "Content-Transfer-Encoding: base64\r\n";
>>
>> $header .= "Content-Disposition: attachment; file=\"".$name."\"\r\n\r 
>> \n";
>>
>> $header .= $content."\r\n\r\n";
>>
>> $header .= "--".$uid."--";
>>
>> echo $header;
>>
>> if (mail($mailto, $subject, "test", $header)) {
>>
>> echo "mail send ... OK"; // or use booleans here
>>
>> } else {
>>
>> echo "mail send ... ERROR!";
>>
>> }
>>
>> }
>>
>> // how to use
>>
>> $my_name = "Guus";
>>
>> $my_mail = "[email protected]";
>>
>> $my_replyto = "[email protected]";
>>
>> $my_subject = "This is a mail with attachment.";
>>
>> $my_message = "Hallo,\r\ndo you like this script? I hope it will
>> help.\r\n\r\ngr. Olaf";
>>
>> xmail("[email protected]", $my_mail, $my_name, $my_replyto,
>> $my_subject, $my_message,$fileName, $fileTempName, $fileType);
>>
>>
>>
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 



--- End Message ---
--- Begin Message ---
A bit of overkill, but it seems to work. Thanks!

"Eric Butera" <[email protected]> wrote in message 
news:[email protected]...
> On Thu, May 28, 2009 at 4:47 AM, Guus Ellenkamp
> <[email protected]> wrote:
>> I'm trying to attach an uploaded file to an e-mail which I receive in
>> Outlook. Neither the first part, nor the second part displays properly. 
>> The
>> header looks ok when displayed on the screen. What am I missing?
>
> If you value your time then use Zend_Mail and be done with it.  :D 



--- End Message ---
--- Begin Message ---
EAcellerator is "just" an opcode cache.  It transparently caches PHP
opcodes; all you have to do to use it is download, compile and enable and
never worry about it again.  APC, on the other hand, does a bit more.  While
APC also caches opcodes, it performs worse than EAC or xcache does (there's
a bit of debate as to which is better, for my particular needs, EAC was
marginally faster, but both outperformed APC) for opcode caching.  APC, on
the other hand, also has some useful features that aren't related to opcode
caching, but rather apc_store, apc_fetch and apc_define_constants.  If you
install apc and don't set apc_enable=1 in php.ini and leave the opcode
caching to EAC / XCache, you still have the ability to use those three
functions, which allow you to have persistent values in RAM between
requests, which is really useful if you have a lot of generic data that
never changes but is needed often.  I personally use apc to set and fetch
global variables and constants and allow EAC to cache the opcodes.

It gets really hairy if you decide to use memcached in conjunction with an
external opcode cacher and APC, because there's specific cases where APC is
useful to store/fetch persistent data and other cases where memcached makes
more sense to use.  I recommend reading
www.scribd.com/doc/4069180/Caching-Performance-*Lessons-from-Facebook * for
a good analysis of when and where and how to implement the two in tandem.

Speaking more generically, building with memcached in mind is a huge
paradigm shift from your typical php/mysql architecture, as you have to
compensate for the fact that the database is dynamically changing, and
either abstract away, or manually manage the data structures in memcached.
There's two strategies - hard mode and extreme mode, if you will - to doing
this: delete every key when the data within them changes, or dynamically
update them as the database changes (theoretically offering you the
potential to have 95%+ cache hit rate, with database reads being a rare
case).  It's a lot more difficult to drop in later than it is to design with
it in mind, and in many cases implementing it means re-writing a lot of
legacy code, but the fact of the matter is that a solid memcached
implementation can all but bypass the SQL database altogether (and by doing
so bypass the bottleneck for the vast majority of requests) and there's
nothing else that offers the performance increase of memcace (orders of
magnitude).  If you'd like a more complete example - with (pseudo)code
example, let me know and I'll write out something more descriptive.

If you're  worried about scalability, there's a few links I'd recommend:

http://highscalability.com/ - blog dedicated to scalability, has talks with
a lot of huge, high visibility sites (not all built on php) including, but
not limited to, digg, facebook and wolfram|alpha

www.*mysqlperformanceblog*.com/ - another blog dedicated to performance, but
less generically and more how to squeeze the most out of mysql.  It's run by
Percona, which is a very respectable company despite their flaws, and they
also distribute XtraDB, the easiest way to increase MySQL performance.
Pardon me for assuming you use MySQL if you don't.

http://blog.facebook.com/ - facebook's official blog, often has useful talks
and links about the ways they've solved their scalability problems.

http://blog.digg.com/ - same as previous, save for digg

You'll have to dig (pun not intended) through a lot of cruft for "the good
stuff" with those last two links, but you can easily spend several hours on
the first two links and all four offer pretty impressive advice.

Let me know if there's anything else I can do for you :)

--Eddie

On Mon, Jun 1, 2009 at 9:44 PM, Daevid Vincent <[email protected]> wrote:

> Eddie can you explain the differences between APC (which is now built into
> PHP) and EAccelerator. You seem to give mixed signals here as you endorse
> both it seems, but I would think they would collide and as the Highlander
> says, "There can be only one!"
>
> http://us.php.net/apc
> http://eaccelerator.net/
>
> Why would we choose one over the other, or do they really work in tandem
> together?
>
> We looked into memcached or memcache or some $hit (it's too confusing and I
> don't remember the exact one) but after installing, we realized it would
> not
> work so well for us as it makes your SQL queries potentially stale. In our
> case, they all have to be live and accurate. And there is a 1MB data limit
> per cache object. :(
>
> http://us.php.net/manual/en/book.memcache.php
> http://us.php.net/manual/en/book.memcached.php
> http://www.danga.com/memcached/
>
> However we did install the APC and that seems to work very well for caching
> the page's opcodes, and are quite pleased with it so far. Plus it's nice
> that it's an "official" module for PHP and a simple apt-get install.
>
> > -----Original Message-----
> > From: Eddie Drapkin [mailto:[email protected]]
> > Sent: Tuesday, May 26, 2009 8:20 PM
> >
> > 2) It's easier to start with a persistent caching
> > setup and go from there than apply one later.  Look into memcache,
> > memcachedb, and __apc__ for some absolutely required tools.
> >
> > 6) Install an opcode cache, I recommend __EAccelerator__.  Script
> > CPU time will be decreased by (a) order of magnitude(s).
>
>

--- End Message ---
--- Begin Message ---
Hey all,

Some may remember my question awhile back about ensuring all CC forms are behind https. I've always put them so, but I've taken over maintenance on a site that did not and have since corrected the problem.

Now the client is going for PCI compliance as a requirement by their credit card processor and we have been dealing with issues determined risks by Security Metrics, most which were legit (except one thinking IIS was running on a Linux server!), but this one has me scratching my head.

The original programmer created the following in the system's .htaccess file:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php

...which sends any incorrect URL to the home page, correct? But Security Metrics, as part of their test ran two URLs through the system that while both displaying the home page had different things in the header, which they flagged as an issue. Here is there explanation below, but my question is, why is this considered a security risk, and what suggestions might some of you have to correct it?

Thanks much!
Skip

----------------------
The reason why this issue is being flagged is simply that both links should bring you to the same page but if look at the HTTP header response (http://www.ranghart.com/cgi-bin/?D=A) it returns a 403 forbidden even though it still takes you to the main site page, with the other URL (http://www.ranghart.com/cgi-bin/%3fD=A) it is returning a 200 OK when it is the same page as the URL that is returning a 403. You will need to make sure that the pages are responding in the same way to correct this issue.
---------------------


--
====================================
Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com
------------------------------------
Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

--- End Message ---
--- Begin Message ---
Hi,

how do you select the most recent row from sql table if the date are stored
this format  date('Y-m-d H:i:s')  e.g (2009-06-02 10:10:30)

i have tried select top 1 from table where id = xx
any solution
-- 
www.bemycandy.com

--- End Message ---

Reply via email to