Re: [PHP] Auto-generating HTML

2010-09-21 Thread Simcha Younger
On Sep 20, 2010, at 2:56 PM, Andy McKenzie wrote:

 
 Hey folks,
 
  Here's the problem.  I'm writing a lot of pages, and I hate going in
 and out of PHP.  At the same time, I want my HTML to be legible.  When
 you look at it, that's kind of a problem, though... for instance
 (assume this had some PHP in the middle, and there was actually a
 reason not to just put this in HTML in the first place):

Unless you are looking at the HTML alot, you can just paste the source into an 
editor which can auto-format the code, or look at the code in firebug (that is 
the usual place where I look at my HTML.)

If there is a specific place you want to look at in the html, just change the 
lines there to look like this:
echo 'html
';
but this will make your PHP quite messy if you do it alot.

I would go with templating, as many here suggested. 

-- 
Simcha Younger simcha.youn...@gmail.com

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



Re: [PHP] Auto-generating HTML

2010-09-21 Thread Benjamin Hawkes-Lewis
On 20 Sep 2010, at 22:02, Bastien Koert wrote:
 The standard suggests that double quotes are to be used for HTML
 attributes.

Where?

--
Benjamin Hawkes-Lewis

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



[PHP] Database Administration

2010-09-21 Thread Tom Barrett
Hi

I need to build a custom client management app, which will build and manage
a database per client. This means that on top of the usual sql crud, it
needs to be able to create databases, add/edit/delete database users, create
tables.

Is there a way for me to do this nicely as PHP solution? am I better off
incorporating non PHP pieces into this (e.g. shell)? or should I leave the
admin tasks (e.g. database creation) as a 'normal' administrative task
(commandline/webmin/watever)?


Re: [PHP] Database Administration

2010-09-21 Thread Peter Lind
On 21 September 2010 11:48, Tom Barrett t...@miramedia.co.uk wrote:
 Hi

 I need to build a custom client management app, which will build and manage
 a database per client. This means that on top of the usual sql crud, it
 needs to be able to create databases, add/edit/delete database users, create
 tables.

 Is there a way for me to do this nicely as PHP solution? am I better off
 incorporating non PHP pieces into this (e.g. shell)? or should I leave the
 admin tasks (e.g. database creation) as a 'normal' administrative task
 (commandline/webmin/watever)?


Seeing as all the extra stuff you need is just plain sql commands, I
don't see the problem as such. You just need to make sure access to
the tool is done right (i.e. a user that can create/destroy databases
needs to be aware of this and you need to restrict the access to those
specific persons).

Regards
Peter

-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

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



RE: [PHP] Database Administration

2010-09-21 Thread Jangita
Possible. Google phpmyadmin I believe it is completely written in PHP and
does complete database administration (has some weaknesses on stored
procedures though in my view)

Jangita | +254 76 918383 | MSN  Y!: jang...@yahoo.com
Skype: jangita | GTalk: jangita.nyag...@gmail.com



-Original Message-
From: Tom Barrett [mailto:t...@miramedia.co.uk] 
Sent: 21 September 2010 11:48 AM
To: PHP General List
Subject: [PHP] Database Administration

Hi

I need to build a custom client management app, which will build and manage
a database per client. This means that on top of the usual sql crud, it
needs to be able to create databases, add/edit/delete database users, create
tables.

Is there a way for me to do this nicely as PHP solution? am I better off
incorporating non PHP pieces into this (e.g. shell)? or should I leave the
admin tasks (e.g. database creation) as a 'normal' administrative task
(commandline/webmin/watever)?


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



Re: [PHP] Auto-generating HTML

2010-09-21 Thread Richard Quadling
On 20 September 2010 19:56, Andy McKenzie amckenz...@gmail.com wrote:
 Hey folks,

  I have the feeling this is a stupid question, but I can't even find
 anything about it.  Maybe I'm just not searching for the right things.

  Here's the problem.  I'm writing a lot of pages, and I hate going in
 and out of PHP.  At the same time, I want my HTML to be legible.  When
 you look at it, that's kind of a problem, though... for instance
 (assume this had some PHP in the middle, and there was actually a
 reason not to just put this in HTML in the first place):

 Simple PHP:
 ?php

 echo 'html';
 echo 'head';
 echo '  titlePage Title/title';
 echo '/head';
 echo 'body';
 echo 'pThis is the page body/p';
 echo '/body';
 echo '/html';

 ?


 Output page source:
 htmlhead  titlePage Title/title/headbodypThis is the
 page body/p/body/html


 Now, I can go through and add a newline to the end of each line (echo
 'html' . \n; and so on), but it adds a lot of typing.  Is there a
 way to make this happen automatically?  I thought about just building
 a simple function, but I run into problem with quotes -- either I
 can't use single quotes, or I can't use double quotes.  Historically,
 I've dealt with the issue by just having ugly output code, but I'd
 like to stop doing that.  How do other people deal with this?

 Thanks,
  Alex

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



There is also the tidy extension which will take your badly formatted
html tag soup and create formatted html, xhtml, etc.

But really, why bother?

Whenever I need to view the source I use the browsers viewsource
option or firebug/console/etc. Essentially, client side.

But using templates with heredoc ...

?php
// Template to display a username row.
// Requires a $a_User array
return  END_HTML
 tr
  th{$a_User['Name']}/th
  /tr
END_HTML;


sort of thing is easy enough to build. And in a loop ...

$s_Users = '';
foreach($a_Users as $a_User) {
 $s_Users .= include '../templates/users.tmpl';
}

Now, $s_Users contains the rows to display the users and you could do
something to it if you wanted to.

Of course, rolling your own system is fine, but there are other
templating systems available, though, of course, PHP _IS_ the
templating system, so why learn another one.

If you are using a designer to structure the HTML and then adding your
code to build the pages, then a templating system compatible with the
designer's tools would be a good option.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



RES: [PHP] Invalid chars in XML

2010-09-21 Thread Alejandro Michelin Salomon
Hi 

I am working with xml, in portuguese, and i have many problems with special
characters.

I find this code to work with this problem...

When create xml ExpandEntities :
function ExpandEntities( $sText )
{
$trans = array('' = 'amp;',
   ' = 'apos;',
   '' = 'quot;',
   '' = 'lt;',
   '' = 'gt;' );

return strtr( $sText, $trans );
}

When read xml CompEntities
function CompEntities( $sText )
{
$trans = array('amp;'  = '',
   'apos;' = ',
   'quot;' = '',
   'lt;'   = '',
   'gt;'   = '' );

return strtr( $sText, $trans );
}

Alejandro M.S.
-Mensagem original-
De: robert mena [mailto:robert.m...@gmail.com] 
Enviada em: segunda-feira, 20 de setembro de 2010 17:08
Para: php-general@lists.php.net
Assunto: [PHP] Invalid chars in XML

Hi,

I am trying to parse a XML file with simplexml_load but it gave me error.
 While inspecting the contents I found a  inside the value of a tag.
tagsomething  something/tag.

After I've removed the  everything went fine.  So which chars I should not
put in my file?   Should I use some conversion function like html_entities?

Does the receiver of the XML has to do anything to convert is back?


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



RE: [PHP] Database Administration

2010-09-21 Thread Jay Blanchard

[snip]
I need to build a custom client management app, which will build and
manage
a database per client. This means that on top of the usual sql crud, it
needs to be able to create databases, add/edit/delete database users,
create
tables.

Is there a way for me to do this nicely as PHP solution? am I better off
incorporating non PHP pieces into this (e.g. shell)? or should I leave
the
admin tasks (e.g. database creation) as a 'normal' administrative task
(commandline/webmin/watever)?
[/snip]

Have you thought about using phpMyAdmin?

http://www.phpmyadmin.net/home_page/index.php


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



Re: [PHP] Auto-generating HTML

2010-09-21 Thread Andy McKenzie
On Tue, Sep 21, 2010 at 3:32 AM, Simcha Younger
simcha.youn...@gmail.com wrote:
 On Sep 20, 2010, at 2:56 PM, Andy McKenzie wrote:


 Hey folks,

  Here's the problem.  I'm writing a lot of pages, and I hate going in
 and out of PHP.  At the same time, I want my HTML to be legible.  When
 you look at it, that's kind of a problem, though... for instance
 (assume this had some PHP in the middle, and there was actually a
 reason not to just put this in HTML in the first place):

 Unless you are looking at the HTML alot, you can just paste the source into 
 an editor which can auto-format the code, or look at the code in firebug 
 (that is the usual place where I look at my HTML.)

 If there is a specific place you want to look at in the html, just change the 
 lines there to look like this:
 echo 'html
 ';
 but this will make your PHP quite messy if you do it alot.

 I would go with templating, as many here suggested.

 --
 Simcha Younger simcha.youn...@gmail.com


That's actually why this came up -- for the first time I AM looking at
the generated HTML a lot.  I'm building a frontend for a set of DBs we
use (for various reasons none of the pre-built ones I could find would
work for us), and I'm spending a fair amount of time trying to figure
out whether I messed up the code, or the output just doesn't display
as I expected.  I've never done anything quite this complex, and have
therefore never needed to look at the output html a lot.  I've also
just gotten tired of having my output completely unreadable... I'd
like to have this project done right, and to me that means the source
and the output should both be reasonably easy to parse, in addition to
other things (paying a lot more attention to security than I usually
do, for instance...).

-Alex

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



[PHP] Re: Sending Encrypted Email

2010-09-21 Thread Erik L. Arneson
On Thu, 16 Sep 2010, Nathan Rixham wrote:
 Floyd Resler wrote:
 I need to send encrypted email. Can I use our server's signed certificate we 
 use for Apache?

 Yes you can use the servers certificate, you can use any x509
 certificate you like - however, I'd recommend checking out
 startssl.org who will give you a free smime certificate.

But that is probably just for *signing* the email.  If you'd like to
encrypt email, you will need a public key or shared secret from the
email recipient.

-- 
Erik Arneson dyb...@lnouv.com
  GPG Key ID : 1024D/62DA1D25   BitCoin : 1LqvuGUqJ4ZUSoE7YE9ngETjwp4yZ2uSdP
  Office : +1.541.291.9776Skype : callto://pymander
http://www.leisurenouveau.com/


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



Re: [PHP] Re: Sending Encrypted Email

2010-09-21 Thread Floyd Resler

On Sep 21, 2010, at 1:00 AM, Erik L. Arneson wrote:

 On Thu, 16 Sep 2010, Nathan Rixham wrote:
 Floyd Resler wrote:
 I need to send encrypted email. Can I use our server's signed certificate 
 we use for Apache?
 
 Yes you can use the servers certificate, you can use any x509
 certificate you like - however, I'd recommend checking out
 startssl.org who will give you a free smime certificate.
 
 But that is probably just for *signing* the email.  If you'd like to
 encrypt email, you will need a public key or shared secret from the
 email recipient.
 
 -- 
 Erik Arneson dyb...@lnouv.com
  GPG Key ID : 1024D/62DA1D25   BitCoin : 1LqvuGUqJ4ZUSoE7YE9ngETjwp4yZ2uSdP
  Office : +1.541.291.9776Skype : callto://pymander
http://www.leisurenouveau.com/
 
 

I got it all figured out.  The part I was missing was combining the certificate 
with the key and giving it to the end-user to install on their system.  I was 
able to use the Web server's certificate for the encryption.  The interesting 
thing is that the client wants ALL passwords sent via encrypted email.  Of 
course, they need the P12 file installed in order to view the email and that 
requires a password to install it.  So, obviously, I can't send that password 
encrypted.  So, my solution is to provide a Web page that the user gets to by 
an emailed link that has a unique identifier and the user must enter a piece of 
personal information for verification (in this case, ZIP code).  Once verified, 
they are shown the password on the page.  That's the only way I can think of to 
do it.  Is that a good solution or does someone have a better way?

Thanks!
Floyd



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



RE: [PHP] Auto-generating HTML

2010-09-21 Thread Bob McConnell
From: Andy McKenzie

 I think the main thing I'm seeing is that there isn't a single,
 accepted, simple way to do this:  no matter what I do, it will be a
 workaround of some type.  Either I'm adding complexity (a function to
 convert everything), or I'm adding lines (heredoc/nowdoc seem to
 require that the opening and closing tags be on lines without any of
 the string on them), or I'm adding typing (adding ' . \n' to the end
 of every line of HTML).  Perhaps I'll put some effort into building a
 function to do it, but not this week... I think for now I'll keep
 appending those newlines, and just have more code to fix at a later
 date.  It's reasonably clean, it's just mildly annoying.

It should be relatively easy to do a search and replace on the double
tag locations and insert the newlines. Using tr(1) to replace all 
pairs with \n might be an improvement. Would it be easier to remove
the extras, or to insert all of them in the first place?

Bob McConnell

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



[PHP] Re: Sending Encrypted Email

2010-09-21 Thread Erik L. Arneson
On Tue, 21 Sep 2010, Floyd Resler wrote:
 I got it all figured out.  The part I was missing was combining the
 certificate with the key and giving it to the end-user to install on
 their system.  I was able to use the Web server's certificate for the
 encryption.  The interesting thing is that the client wants ALL
 passwords sent via encrypted email.  Of course, they need the P12 file
 installed in order to view the email and that requires a password to
 install it.

Wait, you didn't send the webserver's certificate to the user, did you?
That's a bad idea.  The email recipient should have her own certificate,
which has both a private and a public part.

The webserver's certificate (presumably the one you have signed by the
CA), especially the private key, needs to be kept *private*, and not
sent all over the place.  Using the same private/public key pair on both
endpoints defeats the purpose of PKI.  You would be better off using
plain old symmetric encryption.

So, obviously, I can't send that password encrypted.  So, my solution
is to provide a Web page that the user gets to by an emailed link that
has a unique identifier and the user must enter a piece of personal
information for verification (in this case, ZIP code).  Once verified,
they are shown the password on the page.  That's the only way I can
think of to do it.  Is that a good solution or does someone have a
better way?

I'm sure there are some good products out there to handle this.
Personally, for email encryption I always prefer the OpenPGP family of
tools (including GnuPG and commercial PGP).  End-users can install PGP
on their systems, generate public keys, and then send them to the
webserver.  No passwords need to be handed out---they will come up with
their own passphrases when they generate their public/private key pairs.

-- 
Erik Arneson dyb...@lnouv.com
  GPG Key ID : 1024D/62DA1D25   BitCoin : 1LqvuGUqJ4ZUSoE7YE9ngETjwp4yZ2uSdP
  Office : +1.541.291.9776Skype : callto://pymander
http://www.leisurenouveau.com/


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



Re: [PHP] Re: Sending Encrypted Email

2010-09-21 Thread Floyd Resler

On Sep 21, 2010, at 11:15 AM, Erik L. Arneson wrote:

 On Tue, 21 Sep 2010, Floyd Resler wrote:
 I got it all figured out.  The part I was missing was combining the
 certificate with the key and giving it to the end-user to install on
 their system.  I was able to use the Web server's certificate for the
 encryption.  The interesting thing is that the client wants ALL
 passwords sent via encrypted email.  Of course, they need the P12 file
 installed in order to view the email and that requires a password to
 install it.
 
 Wait, you didn't send the webserver's certificate to the user, did you?
 That's a bad idea.  The email recipient should have her own certificate,
 which has both a private and a public part.
 
 The webserver's certificate (presumably the one you have signed by the
 CA), especially the private key, needs to be kept *private*, and not
 sent all over the place.  Using the same private/public key pair on both
 endpoints defeats the purpose of PKI.  You would be better off using
 plain old symmetric encryption.
 
 So, obviously, I can't send that password encrypted.  So, my solution
 is to provide a Web page that the user gets to by an emailed link that
 has a unique identifier and the user must enter a piece of personal
 information for verification (in this case, ZIP code).  Once verified,
 they are shown the password on the page.  That's the only way I can
 think of to do it.  Is that a good solution or does someone have a
 better way?
 
 I'm sure there are some good products out there to handle this.
 Personally, for email encryption I always prefer the OpenPGP family of
 tools (including GnuPG and commercial PGP).  End-users can install PGP
 on their systems, generate public keys, and then send them to the
 webserver.  No passwords need to be handed out---they will come up with
 their own passphrases when they generate their public/private key pairs.
 
 -- 
 Erik Arneson dyb...@lnouv.com
  GPG Key ID : 1024D/62DA1D25   BitCoin : 1LqvuGUqJ4ZUSoE7YE9ngETjwp4yZ2uSdP
  Office : +1.541.291.9776Skype : callto://pymander
http://www.leisurenouveau.com/
 
 

I used OpenSSL to generate the P12 file (I haven't actually sent this to anyone 
since I'm still testing).  So, I assumed that it was okay for distribution.  
Perhaps not.  At any rate, I like the idea of the OpenPGP better.  I'll see how 
to do that.

Thanks!
Floyd



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



[PHP] Re: Sending Encrypted Email

2010-09-21 Thread Erik L. Arneson
On Tue, 21 Sep 2010, Floyd Resler wrote:
 I used OpenSSL to generate the P12 file (I haven't actually sent this
 to anyone since I'm still testing).  So, I assumed that it was okay
 for distribution.  Perhaps not.  At any rate, I like the idea of the
 OpenPGP better.  I'll see how to do that. 

Oh good, good.  That should work just fine.  I thought you were saying
that you'd sent the webserver's keys to the end-user.

There's an email encryption method called S/MIME that uses that uses
certificates and such that I think is handled pretty well by Outlook (or
whatever Microsoft users do their email with these days).  You could
also look into that.  It *might* be easier for your end-users.

-- 
Erik Arneson dyb...@lnouv.com
  GPG Key ID : 1024D/62DA1D25   BitCoin : 1LqvuGUqJ4ZUSoE7YE9ngETjwp4yZ2uSdP
  Office : +1.541.291.9776Skype : callto://pymander
http://www.leisurenouveau.com/


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



Re: [PHP] Auto-generating HTML

2010-09-21 Thread tedd

At 2:56 PM -0400 9/20/10, Andy McKenzie wrote:

Hey folks,

  I have the feeling this is a stupid question, but I can't even find
anything about it.  Maybe I'm just not searching for the right things.

  Here's the problem.  I'm writing a lot of pages, and I hate going in
and out of PHP.  At the same time, I want my HTML to be legible.  When
you look at it, that's kind of a problem, though... for instance


-snip-

You can mix html and php more effectively and with better clarity than that.

Two things you should consider:

1. Effective use of includes. Please review and learn from this demo:

http://sperling.com/examples/include-demo/

2. Isolated use of echo()'s. I only mix html and php when it is 
necessary to inject values created by a php/mysql process. To show 
these values I typically use this format:


?php echo($whatever); ?

within html -- for example:

h1?php echo($title);?/h1

As such, all my code (html, css, php, mysql, javascript) is not 
complex, nor unreadable, and is easily maintainable.


Cheers,

tedd

--
---
http://sperling.com/

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



Re: [PHP] Database Administration

2010-09-21 Thread tedd

At 10:48 AM +0100 9/21/10, Tom Barrett wrote:

Hi

I need to build a custom client management app, which will build and manage
a database per client. This means that on top of the usual sql crud, it
needs to be able to create databases, add/edit/delete database users, create
tables.

Is there a way for me to do this nicely as PHP solution? am I better off
incorporating non PHP pieces into this (e.g. shell)? or should I leave the
admin tasks (e.g. database creation) as a 'normal' administrative task
(commandline/webmin/watever)?


I'm not sure as to what you need, but for me I do all my database 
creation in phpMyAdmin. From there I populate with php.


Cheers,

tedd
--
---
http://sperling.com/

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



Re: [PHP] PHP Email Question

2010-09-21 Thread J Ravi Menon
Just on this topic, I found swiftmailer library to be really useful
esp. in dealing with 'template' emails with custom variables per
recipient:

http://swiftmailer.org/

The e.g. on email template processing:

http://swiftmailer.org/docs/decorator-plugin-howto

There are batchSend() functionalities, ability to compose various mime
type emails etc...

Ravi

On Mon, Sep 20, 2010 at 8:20 AM, chris h chris...@gmail.com wrote:
 Ignore the other parameters unless you are very familiar with RFCs 2821,
 2822 and their associated RFCs



 I would advise against ignoring the other parameters.  Doing so will pretty
 much guarantee having your email end up in SPAM.  Instead look up the
 examples in the docs, or better yet use something like phpmailer as Tom
 suggested.


 Chris.


 On Sun, Sep 19, 2010 at 6:37 PM, TR Shaw ts...@oitc.com wrote:


 On Sep 19, 2010, at 6:00 PM, Joe Jackson wrote:

  Hi
 
  Sorry for the simple question but I am trying to get my head around PHP.
  I
  have a sample PHP script that I am trying to use to send a php powered
 email
  message.  The snippet of code is shown below
 
     mail('em...@address.com', 'Subject', $values['message'], From:
  \{$values['name']}\ {$values['emailaddress']});
 
  This works fine, but how can I add in other fields to the email that is
  recieved?
 
  For example in the form there are fields called, 'emailaddress',
  'telephone', 'address' and 'name' which I need to add into the form along
  with the message field
 
  Also with the formatting how can I change the format of the email to
 
  Name: $values['name'],
  Address: etc
  Message:
 

 Joe

 The mail command lets you send mail (an RFC2821 envelop). The function is:

 bool mail ( string $to , string $subject , string $message [, string
 $additional_headers [, string$additional_parameters ]] )

 $to is where you want it to go
 $subject is whatever you want the subject to be
 $message is the information you want to send

 Ignore the other parameters unless you are very familiar with RFCs 2821,
 2822 and their associated RFCs


 So if you want to send info from a form you might want to roll it up in xml
 and send it via the message part. when you receive it you can easily decode
 it. If you don't want to do that put it in a format that you can easily
 decode on the receiving end.

 Basically mail is a way to deliver information in the $message body. How
 you format the information there is up to you. However, depending on your
 system's config you are probably constrained to placing only 7bit ascii in
 the $message body.

 You might also move away from the mail function and look at phpmailer at
 sf.net if you need more complex capabilities.

 Tom






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