RE: [PHP] Please Help Me ASAP

2009-04-10 Thread abdulazeez alugo


 

 Date: Fri, 10 Apr 2009 08:33:10 +0530
 From: usang...@gmail.com
 To: php-general@lists.php.net
 Subject: [PHP] Please Help Me ASAP
 
 Hello,
 I'm building my own website without any knowledge of PHP,  i'm almost done
 with that..as my website works fine on my local server
 i:e WAMPSERVER 2.0,
 but the same code is not working on server...n i'm rilli 'd of coz of
 that...
 
 The error is :PHP Parse error: syntax error, unexpected $end in
 /home/usang2me/public_html/sign_up.php on line 145
 
 145 happens to be last line i:e ? , but here becoz of pattern..itz not
 into its proper way...
 
 
 After filling the sign up form correctly . it says ALL FIELD ARE
 MANDATORYi dont understand ...y soi'm pasting my code here...please
 help me asap ...
 each and every suggestion will be appreciat'd
 
 
 
 Here Is The Code:
 
 ?php
 $username = $_POST['username'];
 $password1 = $_POST['password1'];
 $password2 = $_POST['password2'];
 $name = $_POST['name'];
 $address = $_POST['address'];
 $city = $_POST['city'];
 $state = $_POST['state'];
 $code = $_POST['code'];
 $phone = $_POST['phone'];
 $email = $_POST['email'];
 //$bankname = $_POST['bankname'];
 //$bankbranch = $_POST['bankbranch'];
 //$accountnumber = $_POST['bankac'];
 $refer_id = $_POST['refer_id'];
 //$country = $_POST['country'];
 // Connects to your Database
 include('database_connect_local.php');
 //This makes sure they did not leave any fields blank
 $minuser_len = 6; //username minimum length
 $minpass_len = 6; //password minimum length
 $mincode_len = 6; //code minimum length
 $minphone_len = 10; //phone minimum length
 //$refer_id_len = 6; //refer_id minimum length
 
 if (strlen($username)  $minuser_len || strlen($password1)  $minpass_len ||
 strlen($code)  $mincode_len || strlen($phone)  $minphone_len)
 {
 echo html;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo table align=center border=1 cellpadding=0 cellspacing=0
 bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
 echo tr td align=centerp font color=black span
 style=font-size:11pt;bMinimum length values for Username or Password or
 Pincode or Mobile is missing. Please try again with correct
 values./b/span/font/p/td /tr /table /html;
 include 'signup.php';
 exit;
 //die(User/password was not long enough!);
 }elseif (!is_numeric($code) || !is_numeric($phone)){
 echo html;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo table align=center border=1 cellpadding=0 cellspacing=0
 bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
 echo tr td align=centerp font color=black span
 style=font-size:11pt;bNon Numeric Character Where only Numeric Value is
 Allowed./b/span/font/p/td /tr /table /html;
 include 'signup.php';
 exit;
 //}elseif (empty($username)|| empty($password1) || empty($password2) ||
 empty($name) || empty($address) || empty($city) || empty($state) ||
 empty($code) || //empty($phone) || empty($email) || empty($refer_id)){
 //echo html;
 //echo nbsp;;
 //echo nbsp;;
 //echo nbsp;;
 //echo nbsp;;
 //echo nbsp;;
 //echo nbsp;;
 //echo nbsp;;
 //echo nbsp;;
 //echo nbsp;;
 //echo table align=center border=1 cellpadding=0 cellspacing=0
 bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
 //echo tr td align=centerp font color=black span
 style=font-size:11pt;bAll fields are Mandatory/b/span/font/p/td
 /tr /table ///html;
 //include 'signup.php';
 }else{
 // checks if the username is in use
 $checkuser = mysql_query(SELECT username FROM id_users WHERE
 username='$username');
 $username_exist = mysql_num_rows($checkuser);
 $referid = mysql_query(SELECT username FROM id_users WHERE
 username='$refer_id');
 $referid_exist = mysql_num_rows($referid);
 if($username_exist != 0){
 echo html;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo table align=center border=1 cellpadding=0 cellspacing=0
 bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
 echo tr td align=centerp font color=black span
 style=font-size:11pt;bI'm sorry but the username you specified has
 already been taken. Please pick another one./b/span/font/p/td
 /tr /table /html;
 unset($username);
 include 'signup.php';
 }elseif($referid_exist  0){
 echo html;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo table align=center border=1 cellpadding=0 cellspacing=0
 bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
 echo tr td align=centerp font color=black span
 style=font-size:11pt;bI'm sorry but the referral id doesn't exist. Please
 check the referral id or enter the valid one./b/span/font/p/td
 /tr /table /html;
 unset($username);
 include 'signup.php';
 }else{
 // this makes sure both passwords entered match
 if ($password1 != $password2) {
 die('Your passwords did not match.');
 }else{
 //}
 // now 

Re: [PHP] Please Help Me ASAP

2009-04-10 Thread Bipin Upadhyay

kunal sharma wrote:

 Hello,
I'm building my own website without any knowledge of PHP,  i'm almost done
with that..as my website works fine on my local server
i:e WAMPSERVER 2.0,
but the same code is not working on server...n i'm rilli 'd of coz of
that...

The error is :PHP Parse error: syntax error, unexpected $end in
/home/usang2me/public_html/sign_up.php on line 145

145 happens to be last line i:e ? , but here becoz of pattern..itz not
into its proper way...


After filling the sign up form correctly . it says ALL FIELD ARE
MANDATORYi dont understand ...y soi'm pasting my code here...please
help me asap ...
each and every suggestion will be appreciat'd



Here Is The Code:

?php
$username = $_POST['username'];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$code = $_POST['code'];
$phone = $_POST['phone'];
$email = $_POST['email'];
//$bankname = $_POST['bankname'];
//$bankbranch = $_POST['bankbranch'];
//$accountnumber = $_POST['bankac'];
$refer_id = $_POST['refer_id'];
//$country = $_POST['country'];
// Connects to your Database
include('database_connect_local.php');
//This makes sure they did not leave any fields blank
$minuser_len = 6; //username minimum length
$minpass_len = 6; //password minimum length
$mincode_len = 6; //code minimum length
$minphone_len = 10; //phone minimum length
//$refer_id_len = 6; //refer_id minimum length

if (strlen($username)  $minuser_len || strlen($password1)  $minpass_len ||
strlen($code)  $mincode_len || strlen($phone)  $minphone_len)
{
echo html;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
echo tr td align=centerp font color=black span
style=font-size:11pt;bMinimum length values for Username or Password or
Pincode or Mobile is missing. Please try again with correct
values./b/span/font/p/td /tr /table /html;
include 'signup.php';
exit;
//die(User/password was not long enough!);
}elseif (!is_numeric($code) || !is_numeric($phone)){
echo html;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
echo tr td align=centerp font color=black span
style=font-size:11pt;bNon Numeric Character Where only Numeric Value is
Allowed./b/span/font/p/td /tr /table /html;
include 'signup.php';
exit;
//}elseif (empty($username)|| empty($password1) || empty($password2) ||
empty($name) || empty($address) || empty($city) || empty($state) ||
empty($code) || //empty($phone) || empty($email) || empty($refer_id)){
//echo html;
//echo nbsp;;
//echo nbsp;;
//echo nbsp;;
//echo nbsp;;
//echo nbsp;;
//echo nbsp;;
//echo nbsp;;
//echo nbsp;;
//echo nbsp;;
//echo table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
//echo tr td align=centerp font color=black span
style=font-size:11pt;bAll fields are Mandatory/b/span/font/p/td
/tr /table ///html;
//include 'signup.php';
}else{
// checks if the username is in use
$checkuser = mysql_query(SELECT username FROM id_users WHERE
username='$username');
$username_exist = mysql_num_rows($checkuser);
$referid = mysql_query(SELECT username FROM id_users WHERE
username='$refer_id');
$referid_exist = mysql_num_rows($referid);
if($username_exist != 0){
echo html;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
echo tr td align=centerp font color=black span
style=font-size:11pt;bI'm sorry but the username you specified has
already been taken. Please pick another one./b/span/font/p/td
/tr /table /html;
unset($username);
include 'signup.php';
}elseif($referid_exist  0){
echo html;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo nbsp;;
echo table align=center border=1 cellpadding=0 cellspacing=0
bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
echo tr td align=centerp font color=black span
style=font-size:11pt;bI'm sorry but the referral id doesn't exist. Please
check the referral id or enter the valid one./b/span/font/p/td
/tr /table /html;
unset($username);
include 'signup.php';
}else{
// this makes sure both passwords entered match
if ($password1 != $password2) {
die('Your passwords did not match.');
}else{
//}
// now we insert it into the database
//$password3 = md5($_POST['password1']);//
$insert = INSERT INTO id_users (username, password, name, address, city,
state, code, phone, email, payment_status, member_status, total_member,
refer_id)
VALUES ('$username', '$password1', '$name', 

Re: [PHP] Please Help Me ASAP

2009-04-10 Thread Jignesh Thummar
whenever you want to print HTMLs in your code you don't need to call echo or
print everytime.
You can use plain HTML in your php code this way.

?php
//php code
?
your HTML code
?php
//php code
?
your HTML code

or you can use HEREDOC to print long string ( http://in.php.net/types.string)

- Jignesh

On Fri, Apr 10, 2009 at 12:37 PM, Bipin Upadhyay muxical.g...@gmail.comwrote:

 kunal sharma wrote:

  Hello,
 I'm building my own website without any knowledge of PHP,  i'm almost
 done
 with that..as my website works fine on my local server
 i:e WAMPSERVER 2.0,
 but the same code is not working on server...n i'm rilli 'd of coz of
 that...

 The error is :PHP Parse error: syntax error, unexpected $end in
 /home/usang2me/public_html/sign_up.php on line 145

 145 happens to be last line i:e ? , but here becoz of pattern..itz
 not
 into its proper way...

 
 After filling the sign up form correctly . it says ALL FIELD ARE
 MANDATORYi dont understand ...y soi'm pasting my code
 here...please
 help me asap ...
 each and every suggestion will be appreciat'd



 Here Is The Code:

 ?php
 $username = $_POST['username'];
 $password1 = $_POST['password1'];
 $password2 = $_POST['password2'];
 $name = $_POST['name'];
 $address = $_POST['address'];
 $city = $_POST['city'];
 $state = $_POST['state'];
 $code = $_POST['code'];
 $phone = $_POST['phone'];
 $email = $_POST['email'];
 //$bankname = $_POST['bankname'];
 //$bankbranch = $_POST['bankbranch'];
 //$accountnumber = $_POST['bankac'];
 $refer_id = $_POST['refer_id'];
 //$country = $_POST['country'];
 // Connects to your Database
 include('database_connect_local.php');
 //This makes sure they did not leave any fields blank
 $minuser_len = 6; //username minimum length
 $minpass_len = 6; //password minimum length
 $mincode_len = 6; //code minimum length
 $minphone_len = 10; //phone minimum length
 //$refer_id_len = 6; //refer_id minimum length

 if (strlen($username)  $minuser_len || strlen($password1)  $minpass_len
 ||
 strlen($code)  $mincode_len || strlen($phone)  $minphone_len)
 {
 echo html;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo table align=center border=1 cellpadding=0 cellspacing=0
 bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
 echo tr td align=centerp font color=black span
 style=font-size:11pt;bMinimum length values for Username or Password or
 Pincode or Mobile is missing. Please try again with correct
 values./b/span/font/p/td /tr /table /html;
 include 'signup.php';
 exit;
 //die(User/password was not long enough!);
 }elseif (!is_numeric($code) || !is_numeric($phone)){
 echo html;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo table align=center border=1 cellpadding=0 cellspacing=0
 bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
 echo tr td align=centerp font color=black span
 style=font-size:11pt;bNon Numeric Character Where only Numeric Value is
 Allowed./b/span/font/p/td /tr /table /html;
 include 'signup.php';
 exit;
 //}elseif (empty($username)|| empty($password1) || empty($password2) ||
 empty($name) || empty($address) || empty($city) || empty($state) ||
 empty($code) || //empty($phone) || empty($email) || empty($refer_id)){
 //echo html;
 //echo nbsp;;
 //echo nbsp;;
 //echo nbsp;;
 //echo nbsp;;
 //echo nbsp;;
 //echo nbsp;;
 //echo nbsp;;
 //echo nbsp;;
 //echo nbsp;;
 //echo table align=center border=1 cellpadding=0 cellspacing=0
 bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
 //echo tr td align=centerp font color=black span
 style=font-size:11pt;bAll fields are
 Mandatory/b/span/font/p/td
 /tr /table ///html;
 //include 'signup.php';
 }else{
 // checks if the username is in use
 $checkuser = mysql_query(SELECT username FROM id_users WHERE
 username='$username');
 $username_exist = mysql_num_rows($checkuser);
 $referid = mysql_query(SELECT username FROM id_users WHERE
 username='$refer_id');
 $referid_exist = mysql_num_rows($referid);
 if($username_exist != 0){
 echo html;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo table align=center border=1 cellpadding=0 cellspacing=0
 bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
 echo tr td align=centerp font color=black span
 style=font-size:11pt;bI'm sorry but the username you specified has
 already been taken. Please pick another one./b/span/font/p/td
 /tr /table /html;
 unset($username);
 include 'signup.php';
 }elseif($referid_exist  0){
 echo html;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo nbsp;;
 echo table align=center border=1 cellpadding=0 cellspacing=0
 bordercolor=#FF6600 bgcolor=#C0C0C0 width=50% height=10;
 echo tr td align=centerp font color=black span
 style=font-size:11pt;bI'm sorry but the referral id doesn't exist.
 Please
 check the 

[PHP] wana join ur group

2009-04-10 Thread Sabrina Akter
With Regards

Sabrina Akter
Web App. Developer
'IBACS' - www.ibacs.co.uk


RE: [PHP] wana join ur group

2009-04-10 Thread abdulazeez alugo

 

 Date: Fri, 10 Apr 2009 15:14:53 +0600
 From: lizzeel...@gmail.com
 To: php-general@lists.php.net
 Subject: [PHP] wana join ur group
 
 With Regards
 
 Sabrina Akter
 Web App. Developer
 'IBACS' - www.ibacs.co.uk

 

Greetings Sabrina,

You're welcome to this mailing list (group? someone evn reffered to us as gang 
the other day; I think it was Tedd). Anywayz, as long as you stick to the 
rules, I bet you're gonna enjoy your time here with us. Please do not hesitate 
to ask questions and always be ready to contribute your opinion to others' 
problems. I would have loved to introduce you to everyone on the list by name 
but time wouldn't allow me (lol).

 

Enjoy.

 

N.B.: Beware of a guy named Dan Brown on this list. He's popularly reffered to 
as the self-acclaimed-Almighty and of course he's not the famous writer of The 
DA VINCI CODE.

 

Cheers.

 

Alugo Abdulazeez.


_
Show them the way! Add maps and directions to your party invites. 
http://www.microsoft.com/windows/windowslive/products/events.aspx

RE: [PHP] wana join ur group

2009-04-10 Thread abdulazeez alugo


 





Date: Fri, 10 Apr 2009 15:29:58 +0600
Subject: Re: [PHP] wana join ur group
From: lizzeel...@gmail.com
To: defati...@hotmail.com

hello Alugo,
Thanks for your reply. I hope its not a auto reply mail. I really dont know how 
to join. and where to login. Can you please instruct me? 


Hi LizOh!!! that hurts.

Now I'm really thinking yours is an auto reply mail else you should know that 
you already on the list or how did you get here in the first place? did you 
register on the PHP site at all?. The thing is, if you wanna send a message and 
you want everybody to see it, send it to php-general@lists.php.net and if you 
wanna reply to a message, you should always press the Reply to all and not just 
Reply.

I hope you understand that.

 

Cheers.

 

N.B.: I could use some apology too.

 

Alugo Abdulazeez.

_
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/

Re: [PHP] Caching

2009-04-10 Thread Richard Heyes
Hi,

 I started caching some of the static files on my application,
 I was wondering - Lets say I have an article on my website and I *want* to
 cache it. How will I cache it AND will be able to make my visitors
 re-cache it if it has been changed?

Work from the last modified date/time on the file. When you update the
file it will change. Though if your files really are static, then
there's little point - the OS will do a far better job of caching them
than you will.

Also, you may also want to have a goosey at the Cache-Control: HTTP
header over Expires:. It can give you more control.

 How do I use *Header set Expires* (on htaccess) and specifying in a week?

A quick Google found this:

Header set Expires Thu, 15 Apr 2010 20:00:00 GMT

-- 
Richard Heyes

HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.net (Updated March 28th)

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



Re: [PHP] wana join ur group

2009-04-10 Thread 9el
Welcome Sabrina, you are already in the giant php mailing listin the world.

Enjoy Questioning here.

Regards

Lenin

www.twitter.com/nine_L

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



Re: [PHP] extracting text - regex

2009-04-10 Thread Ashley Sheridan
On Wed, 2009-04-08 at 17:14 +0200, Merlin Morgenstern wrote:
 
 George Larson wrote:
  On Wed, Apr 8, 2009 at 9:13 AM, George Larson 
  george.g.lar...@gmail.comwrote:
  
  I'm what you might consider rather green, myself.
  I certainly wouldn't use this code for production but if you're just
  debugging or something then how about something like this:
 
  ?php
  $handle = @fopen('page.htm', 'r');
  if ($handle) {
  while (!feof($handle)) {
  $eos = trim(fgets($handle, 4096));
  if (strpos($eos,div) !== FALSE) { $echo_output = TRUE; }
  if (strpos($eos,\div) !== FALSE) { $echo_output = FALSE; }
  if ($echo_output == TRUE) { echo $eos; }
  }
  fclose($handle);
  }
  ?
 
 
 
 
  On Wed, Apr 8, 2009 at 8:30 AM, Per Jessen p...@computer.org wrote:
 
  Merlin Morgenstern wrote:
 
  Hello,
 
  I am trying read text out of a text that is inbetween two divs.
  Somehow this should be possible with regex, I just can't figure out
  how.
 
  Example:
 
  div id=test
  bla blub
  /div
 
  I would like to extract the text bla blub out of this example.
 
  This might do the trick (not tested):
 
  preg_match( /div\s+[^]*([^]*)\/div, $yourtext, $match );
  print $match[1];
 
 
  /Per
 
 
  --
  Per Jessen, Zürich (16.8°C)
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
  Sorry about the top-post.  I forgot. :)
  
 
 
 Thank you everbody. I figured it out without regex. It's not for 
 production, just testing:
   $pos_1 = strpos($contents, $word1);
   $pos_2 = strpos($contents, $word2, $pos_1);
   $text = strip_tags(substr($contents, $pos_1, $pos_2 - $pos_1));
 
 That works as well.
 
 
 
Or...

strip_tags() which would work perfectly well for the example excerpt you
gave us!


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] convert video files to FLV

2009-04-10 Thread Ashley Sheridan
On Wed, 2009-04-08 at 22:34 -0700, Michael Shadle wrote:
 On Wed, Apr 8, 2009 at 10:30 PM, Gevorg Harutyunyan gevorg...@gmail.com 
 wrote:
  Hi,
 
  I need to convert video files to FLV using php.
 
  The only solution that I found is to use ffmpeg, but because I am using
  shared hosting I am not allowed to install it on server.
  Do you know any other ways to convert any video file types to flv using PHP.
 
 use ffmpeg.
 
 there is an ffmpeg-php extension but it's kinda buggy and i am not
 sure it supports enough for what you want. but using ffmpeg for it is
 pretty simple. just system() the calls to it. google for it

I know of no way you can do this. Not only would any potential solution
be too slow, but it would affect other users of the server, and more
than likely result in an email from you hosting provider!

Have you considered using YouTube for videos? Just upload them there,
and you can embed their player in your pages.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] A Tool For Building PHP Web Apps

2009-04-10 Thread Phpster
Roadsend is very beta when I last checked and while promising seemed  
to be geared more towards taking php and moving it to the desktop  
without using gtk.


I could see the uses but I think adobe air fits that model better with  
less to worry about.


Personally, I am leaning more and more towards using php to build  
XSLTs and just passing the data via XML. It fits nicely with the mvc  
framework models and reduces the view code dramatically.



Sorry for top posting

Bastien

Sent from my iPod

On Apr 10, 2009, at 1:32, Asher Snyder asny...@noloh.com wrote:


This might be what you're looking for:
http://www.roadsend.com/home/index.php

-Original Message-
From: Paul M Foster [mailto:pa...@quillandmouse.com]
Sent: Friday, April 10, 2009 1:28 AM
To: php-general@lists.php.net
Subject: [PHP] A Tool For Building PHP Web Apps

Here's a hairbrained idea I was kicking around. I object to the idea  
of

including 15 or 30 files in a PHP application just to display one page
on the internet. It makes the coding faster, but it makes the display
slower and seems silly to me.

So what if you had a tool or a set of tools where you could write code
snippets and such, and then hit a button or issue a command, and
everything you specified got written into a single file? You'd specify
that this page needs to read the config, set up a database connection,
validate these fields, etc. When you were done, it would write all  
this
code to a *single* file, which the user would invoke by surfing to  
that

page. The resulting code would be *static*, not like what results from
most templating systems. So rather than specify a specific variable
value in the resulting file, it would embed the PHP code to display  
the

variable, etc.

What might be the liabilities of something like that? Would there be
security issues? Would there be increased difficulty in debugging?  
What

can you think of?

Paul

--
Paul M. Foster

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



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



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



RE: [PHP] A Tool For Building PHP Web Apps

2009-04-10 Thread Bob McConnell
From: Paul M Foster
 
 Here's a hairbrained idea I was kicking around. I object to the idea
of
 including 15 or 30 files in a PHP application just to display one page
 on the internet. It makes the coding faster, but it makes the display
 slower and seems silly to me.
 
 So what if you had a tool or a set of tools where you could write code
 snippets and such, and then hit a button or issue a command, and
 everything you specified got written into a single file? You'd specify
 that this page needs to read the config, set up a database connection,
 validate these fields, etc. When you were done, it would write all
this
 code to a *single* file, which the user would invoke by surfing to
that
 page. The resulting code would be *static*, not like what results from
 most templating systems. So rather than specify a specific variable
 value in the resulting file, it would embed the PHP code to display
the
 variable, etc.
 
 What might be the liabilities of something like that? Would there be
 security issues? Would there be increased difficulty in debugging?
What
 can you think of?

Programs to do that used to be called compilers. There is an entire
branch of computer science and a lot of tools (lex, yacc, etc.)
dedicated to that topic.

It's not a bad idea, but there is one precarious assumption that
underlies it. Can you absolutely guarantee there will never be a second,
or third, or more pages on that server that will need some of those
functions or classes? As soon as the site begins to evolve and grow, you
will have multiple copies of many of those snippets, and when (not if)
you need to modify them, you will have to find and change every single
copy.

So you need to ask yourself if this strategy is maintainable in your
case. And will it make any real difference in the end?

Bob McConnell

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



Re: [PHP] A Tool For Building PHP Web Apps

2009-04-10 Thread Paul M Foster
On Fri, Apr 10, 2009 at 09:01:14AM -0400, Bob McConnell wrote:

 From: Paul M Foster
  
  Here's a hairbrained idea I was kicking around. I object to the idea
 of
  including 15 or 30 files in a PHP application just to display one page
  on the internet. It makes the coding faster, but it makes the display
  slower and seems silly to me.
  
  So what if you had a tool or a set of tools where you could write code
  snippets and such, and then hit a button or issue a command, and
  everything you specified got written into a single file? You'd specify
  that this page needs to read the config, set up a database connection,
  validate these fields, etc. When you were done, it would write all
 this
  code to a *single* file, which the user would invoke by surfing to
 that
  page. The resulting code would be *static*, not like what results from
  most templating systems. So rather than specify a specific variable
  value in the resulting file, it would embed the PHP code to display
 the
  variable, etc.
  
  What might be the liabilities of something like that? Would there be
  security issues? Would there be increased difficulty in debugging?
 What
  can you think of?
 
 Programs to do that used to be called compilers. There is an entire
 branch of computer science and a lot of tools (lex, yacc, etc.)
 dedicated to that topic.

I know compilers. I've coded in C for years. I'm not talking about a
compiler here. It's more an aggregator. The resulting page would still
be php/html, but everything needed in it would be self-contained (except
the web server and PHP interpreter). Kind of like what make does,
except that make typically invokes the compiler to mash it all into one
executable at the end.

 
 It's not a bad idea, but there is one precarious assumption that
 underlies it. Can you absolutely guarantee there will never be a second,
 or third, or more pages on that server that will need some of those
 functions or classes? As soon as the site begins to evolve and grow, you
 will have multiple copies of many of those snippets, and when (not if)
 you need to modify them, you will have to find and change every single
 copy.
 
 So you need to ask yourself if this strategy is maintainable in your
 case. And will it make any real difference in the end?
 

Good point. That's why I asked the question in the first place. Every
time you revised a supporting file, you'd have to regenerate all the
files that depended on it. Might be okay for a small site, but could be
a nightmare for a large site.

Paul

-- 
Paul M. Foster

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



Re: [PHP] A Tool For Building PHP Web Apps

2009-04-10 Thread Leonard Burton
Correct me if I am wrong, but wasn't there a few PHP code generators
that did what the OP is asking?

I remember hearing about Code Generation a few years ago, but that has
been about it.

On Fri, Apr 10, 2009 at 9:48 AM, Paul M Foster pa...@quillandmouse.com wrote:
 On Fri, Apr 10, 2009 at 09:01:14AM -0400, Bob McConnell wrote:

 From: Paul M Foster
 
  Here's a hairbrained idea I was kicking around. I object to the idea
 of
  including 15 or 30 files in a PHP application just to display one page
  on the internet. It makes the coding faster, but it makes the display
  slower and seems silly to me.
 
  So what if you had a tool or a set of tools where you could write code
  snippets and such, and then hit a button or issue a command, and
  everything you specified got written into a single file? You'd specify
  that this page needs to read the config, set up a database connection,
  validate these fields, etc. When you were done, it would write all
 this
  code to a *single* file, which the user would invoke by surfing to
 that
  page. The resulting code would be *static*, not like what results from
  most templating systems. So rather than specify a specific variable
  value in the resulting file, it would embed the PHP code to display
 the
  variable, etc.
 
  What might be the liabilities of something like that? Would there be
  security issues? Would there be increased difficulty in debugging?
 What
  can you think of?

 Programs to do that used to be called compilers. There is an entire
 branch of computer science and a lot of tools (lex, yacc, etc.)
 dedicated to that topic.

 I know compilers. I've coded in C for years. I'm not talking about a
 compiler here. It's more an aggregator. The resulting page would still
 be php/html, but everything needed in it would be self-contained (except
 the web server and PHP interpreter). Kind of like what make does,
 except that make typically invokes the compiler to mash it all into one
 executable at the end.


 It's not a bad idea, but there is one precarious assumption that
 underlies it. Can you absolutely guarantee there will never be a second,
 or third, or more pages on that server that will need some of those
 functions or classes? As soon as the site begins to evolve and grow, you
 will have multiple copies of many of those snippets, and when (not if)
 you need to modify them, you will have to find and change every single
 copy.

 So you need to ask yourself if this strategy is maintainable in your
 case. And will it make any real difference in the end?


 Good point. That's why I asked the question in the first place. Every
 time you revised a supporting file, you'd have to regenerate all the
 files that depended on it. Might be okay for a small site, but could be
 a nightmare for a large site.

 Paul

 --
 Paul M. Foster

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





-- 
Leonard Burton, N9URK
http://www.jiffyslides.com
serv...@jiffyslides.com
leonardbur...@gmail.com

The prolonged evacuation would have dramatically affected the
survivability of the occupants.

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



Re: [PHP] A Tool For Building PHP Web Apps

2009-04-10 Thread Marcus Gnaß

Paul M Foster wrote:

On Fri, Apr 10, 2009 at 09:01:14AM -0400, Bob McConnell wrote:

  

From: Paul M Foster


Here's a hairbrained idea I was kicking around. I object to the idea
  

of


including 15 or 30 files in a PHP application just to display one page
on the internet. It makes the coding faster, but it makes the display
slower and seems silly to me.

So what if you had a tool or a set of tools where you could write code
snippets and such, and then hit a button or issue a command, and
everything you specified got written into a single file? You'd specify
that this page needs to read the config, set up a database connection,
validate these fields, etc. When you were done, it would write all
  

this


code to a *single* file, which the user would invoke by surfing to
  

that


page. The resulting code would be *static*, not like what results from
most templating systems. So rather than specify a specific variable
value in the resulting file, it would embed the PHP code to display
  

the


variable, etc.

What might be the liabilities of something like that? Would there be
security issues? Would there be increased difficulty in debugging?
  

What


can you think of?
  

Programs to do that used to be called compilers. There is an entire
branch of computer science and a lot of tools (lex, yacc, etc.)
dedicated to that topic.



I know compilers. I've coded in C for years. I'm not talking about a
compiler here. It's more an aggregator. The resulting page would still
be php/html, but everything needed in it would be self-contained (except
the web server and PHP interpreter). Kind of like what make does,
except that make typically invokes the compiler to mash it all into one
executable at the end.

  

It's not a bad idea, but there is one precarious assumption that
underlies it. Can you absolutely guarantee there will never be a second,
or third, or more pages on that server that will need some of those
functions or classes? As soon as the site begins to evolve and grow, you
will have multiple copies of many of those snippets, and when (not if)
you need to modify them, you will have to find and change every single
copy.

So you need to ask yourself if this strategy is maintainable in your
case. And will it make any real difference in the end?




Good point. That's why I asked the question in the first place. Every
time you revised a supporting file, you'd have to regenerate all the
files that depended on it. Might be okay for a small site, but could be
a nightmare for a large site.

Paul

  


You could try to substitute all your calls to include() or require() 
with SSI-includes and let your webserver do the aggregation then.


I read an article about retrieving the webservers result after 
performing SSI actions but before handing this over to the application 
server, but I can't remember where ...


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



Re: [PHP] A Tool For Building PHP Web Apps

2009-04-10 Thread Yannick Mortier
2009/4/10 Marcus Gnaß gona...@gmx.de:
 Paul M Foster wrote:

 On Fri, Apr 10, 2009 at 09:01:14AM -0400, Bob McConnell wrote:



 From: Paul M Foster


 Here's a hairbrained idea I was kicking around. I object to the idea


 of


 including 15 or 30 files in a PHP application just to display one page
 on the internet. It makes the coding faster, but it makes the display
 slower and seems silly to me.

 So what if you had a tool or a set of tools where you could write code
 snippets and such, and then hit a button or issue a command, and
 everything you specified got written into a single file? You'd specify
 that this page needs to read the config, set up a database connection,
 validate these fields, etc. When you were done, it would write all


 this


 code to a *single* file, which the user would invoke by surfing to


 that


 page. The resulting code would be *static*, not like what results from
 most templating systems. So rather than specify a specific variable
 value in the resulting file, it would embed the PHP code to display


 the


 variable, etc.

 What might be the liabilities of something like that? Would there be
 security issues? Would there be increased difficulty in debugging?


 What


 can you think of?


 Programs to do that used to be called compilers. There is an entire
 branch of computer science and a lot of tools (lex, yacc, etc.)
 dedicated to that topic.


 I know compilers. I've coded in C for years. I'm not talking about a
 compiler here. It's more an aggregator. The resulting page would still
 be php/html, but everything needed in it would be self-contained (except
 the web server and PHP interpreter). Kind of like what make does,
 except that make typically invokes the compiler to mash it all into one
 executable at the end.



 It's not a bad idea, but there is one precarious assumption that
 underlies it. Can you absolutely guarantee there will never be a second,
 or third, or more pages on that server that will need some of those
 functions or classes? As soon as the site begins to evolve and grow, you
 will have multiple copies of many of those snippets, and when (not if)
 you need to modify them, you will have to find and change every single
 copy.

 So you need to ask yourself if this strategy is maintainable in your
 case. And will it make any real difference in the end?



 Good point. That's why I asked the question in the first place. Every
 time you revised a supporting file, you'd have to regenerate all the
 files that depended on it. Might be okay for a small site, but could be
 a nightmare for a large site.

 Paul



 You could try to substitute all your calls to include() or require() with
 SSI-includes and let your webserver do the aggregation then.

 I read an article about retrieving the webservers result after performing
 SSI actions but before handing this over to the application server, but I
 can't remember where ...

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




I guess using caching would be better. It would resolve the issues of
loosing so much time including all the files you need and it doesn't
waste more time than installing the opcode cache and setting it up.
I'm quite happy with apc, it boosts up the speed a lot!

It even has an option to optimize the require_once and include_once
function calls. Though I don't really know what it does.


-- 
Currently developing a browsergame...
http://www.p-game.de
Trade - Expand - Fight

Follow me on twitter!
http://twitter.com/moortier

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



Re: [PHP] How can I echo a javascript var in an email subject line? Possible? (Yes!)RESOLVED

2009-04-10 Thread Terion Miller
Thanks
Terion

Happy Freecycling
Free the List !!
www.freecycle.org
Over Moderation of Freecycle List Prevents Post Timeliness.
Report Moderator Abuse Here:
http://www.freecycle.org/faq/faq/contact-info
Or Email Your Complaint to:
f...@freecycle.org or i...@freecycle.org

Twitter?
http://twitter.com/terionmiller

Facebook:
a href=http://www.facebook.com/people/Terion-Miller/1542024891;
title=Terion Miller's Facebook profile target=_TOPimg src=
http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0
alt=Terion Miller's Facebook profile/a


On Wed, Apr 8, 2009 at 7:43 PM, Raymond Irving xwis...@yahoo.com wrote:


 For me its very easy to pass php values to the client:

 echo _var($value,'name');

 But the best part is taking control of what your client sees from the
 server-side:

 C('#info')-show(); // now you see it
 ...
 C('#info')-hide(); // now you don't!

 Take control and start building powerful web apps with Raxan PDI -
 http://raxanpdi.com

 __
 Raymond Irving
 Create Rich Ajax/PHP Web Apps today!
 Raxan PDI - http://raxanpdi


 --- On Wed, 4/8/09, Michael A. Peters mpet...@mac.com wrote:

  From: Michael A. Peters mpet...@mac.com
  Subject: Re: [PHP] How can I echo a javascript var in an email subject
 line? Possible?
  To: Terion Miller webdev.ter...@gmail.com
  Cc: PHP General php-general@lists.php.net
  Date: Wednesday, April 8, 2009, 2:34 PM
  Terion Miller wrote:
  
  
  
  
   On Wed, Apr 8, 2009 at 12:50 PM, Michael A. Peters
  mpet...@mac.com
  mailto:mpet...@mac.com
  wrote:
  
   Terion Miller wrote:
  
  
  
  javascript is
  client side.
  php is server
  side.
  To use
  something client side in a server side script, the web
   page
  has to send
  it to the server from the client.
  
  The best way
  to do what you want to do is probably to do the work
  count server
  side, but if you really want to use what javascript
  produced you
  can create a hidden input with a specified id,
   and use
  dhtml via
  javascript to modify the input and insert the value
   into
  the value
  field of the hidden input. Then it will get sent to the
  server when
  the user hits the post button.
  
  However,
  since you should be validating any user input server
   side,
  you'll need
  to validate that the variable is accurate - might as
  well just do
  the count with php server side.
  
  
  
   Thanks Michael I
  was kind of moving in the right direction as
   far as the
  hidden input goes, going to have to google on how to
   do it with the
  dhtml and all like you suggested.
  
  
   Look at the various DOM
  functions - IE for
  
   input type=hidden
  name=wordcount id=hiddenStudd value=
  
   you coud do in your js:
  
   var myHidden =
  document.getElementById('hiddenStuff');
  
 myHidden.setAttribute('value',$yourvalue);
  
  
   Thought I would go ahead and post a bit more on this,
  so here is my wordcount little function on the textarea of
  the form:
  
   textarea name=Comments
  cols=55 rows=5 wrap=hard
  onKeyDown=wordCounter(this.form.Comments,this.form.remLen,
  300);
  onKeyUp=wordCounter(this.form.Comments,this.form.remLen,
  300);?php if (isset($_SESSION['Comments'])) {echo
  $_SESSION['Comments'];}
  ?/textareabrLetters to the Editor are
  limited to 300 words or less.brWords remaining:
  input type=box readonly name=remLen size=3
  value=300
  
   So I was thinking I should be able to pass that again
  to the next page which is the emailform.php page that is
  taking all the id= and printing them to an email 
   should be able to reuse that function right?
  
   input type=hidden id=words  value=
  onSubmit=return
  wordCounter(this.form.Comments,this.form.remLen); 
  
   or do I need to define the variable? think I'm
  starting to confuse myself lol
 
  You don't want the onSubmit in the the hidden input.
 
  I'm not a javascript guru - but I believe you can have the
  form onSubmit do the word count and insert it into the input
  field before the actual submit happens, I've never tried
  having an onsubmit function alter a value field though.
 
  I would change the textarea to have an id=Comments field
  and the remLen input to have an id=remLen field to make it
  easy to find via getElementById (as id attributes have to be
  unique), count the words and set them to a variable that
  then gets put into the hidden input before whatever function
  you run on the submit type onSubmit returns true.
 
  not tested - but something like this:
 
  function countTheWords() {
 var comment =
  $document.getElementById('Comments');
 var remLen  =
  $document.getElementById('remLen').value;
 var count =
  

Re: [PHP] convert video files to FLV

2009-04-10 Thread Michael Shadle
On Fri, Apr 10, 2009 at 4:31 AM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:

 I know of no way you can do this. Not only would any potential solution
 be too slow, but it would affect other users of the server, and more
 than likely result in an email from you hosting provider!

 Have you considered using YouTube for videos? Just upload them there,
 and you can embed their player in your pages.

Some people have private videos, and that would require Youtube to
have an API, otherwise he would have to say hey, go here and upload
your videos and then paste your link!

What do you mean I know of no way you can do this ?

I've got two different styles of installation doing video conversions
on two platforms with cronjobs controlling them using system() calls
through PHP to ffmpeg.

One of them uses ffmpeg-php to identify the source file ahead of time
to try to get basic info like the dimensions and aspect ratio and such
so when it does it's long ffmpeg command line it puts in some extra
parameters to make the conversion work well...

I have a 3 webserver cluster that does nginx+php-fpm+up to one convert
job at a time and there is no noticable impact to my end users. In
fact, I'm looking to replace them with slightly beefier machines so
the convert jobs can move faster and I have more resources available
in general...

What I had meant is I am not sure ffmpeg-php has enough of the API and
functions available to do a proper conversion, which is why I
recommended using system() for now.

It would be major brownie points for someone to beef up ffmpeg-php and
add in things like mp4box, neroAacEnc and other conversion tools all
into PHP API calls with appropriate return values, I try to stay away
from system() calls if I can; also, the imagick PECL extension dumps
core files too often (on an unrelated note) and that could use some
additional help too.

I would love to pool some money together to sponsor some stuff like
that. I dislike having to use system() for my imagemagick calls as
well.

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



Re: [PHP] convert video files to FLV

2009-04-10 Thread Ashley Sheridan
On Fri, 2009-04-10 at 09:01 -0700, Michael Shadle wrote:
 On Fri, Apr 10, 2009 at 4:31 AM, Ashley Sheridan
 a...@ashleysheridan.co.uk wrote:
 
  I know of no way you can do this. Not only would any potential solution
  be too slow, but it would affect other users of the server, and more
  than likely result in an email from you hosting provider!
 
  Have you considered using YouTube for videos? Just upload them there,
  and you can embed their player in your pages.
 
 Some people have private videos, and that would require Youtube to
 have an API, otherwise he would have to say hey, go here and upload
 your videos and then paste your link!
 
 What do you mean I know of no way you can do this ?
 
 I've got two different styles of installation doing video conversions
 on two platforms with cronjobs controlling them using system() calls
 through PHP to ffmpeg.
 
 One of them uses ffmpeg-php to identify the source file ahead of time
 to try to get basic info like the dimensions and aspect ratio and such
 so when it does it's long ffmpeg command line it puts in some extra
 parameters to make the conversion work well...
 
 I have a 3 webserver cluster that does nginx+php-fpm+up to one convert
 job at a time and there is no noticable impact to my end users. In
 fact, I'm looking to replace them with slightly beefier machines so
 the convert jobs can move faster and I have more resources available
 in general...
 
 What I had meant is I am not sure ffmpeg-php has enough of the API and
 functions available to do a proper conversion, which is why I
 recommended using system() for now.
 
 It would be major brownie points for someone to beef up ffmpeg-php and
 add in things like mp4box, neroAacEnc and other conversion tools all
 into PHP API calls with appropriate return values, I try to stay away
 from system() calls if I can; also, the imagick PECL extension dumps
 core files too often (on an unrelated note) and that could use some
 additional help too.
 
 I would love to pool some money together to sponsor some stuff like
 that. I dislike having to use system() for my imagemagick calls as
 well.

If you'll note, the original question was to find a way which did not
require ffmpeg. I should really have rephrased that to say I know of no
way you can do this without ffmpeg. I've used ffmpeg and mencoder
myself to transcode videos to flv, but in environments where I had full
control over the server. Short of moving servers (or at least moving
this part of the work to another server) I see no clear way to do it.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] convert video files to FLV

2009-04-10 Thread Michael Shadle
On Fri, Apr 10, 2009 at 9:12 AM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:

 If you'll note, the original question was to find a way which did not
 require ffmpeg. I should really have rephrased that to say I know of no
 way you can do this without ffmpeg. I've used ffmpeg and mencoder
 myself to transcode videos to flv, but in environments where I had full
 control over the server. Short of moving servers (or at least moving
 this part of the work to another server) I see no clear way to do it.

I think in the original question (I have it deleted now) he didn't say
he didn't have access to it, but later he did.

Then I kinda just veered off into general discussion about it.

There -are- API-based services for video transcoding. They're all PPV
(pay-per-view) so you pay for how much you use...

- Softlayer offers it to customers (http://www.softlayer.com) - it
would be a very fast transfer too as you'd be on the same network as
the conversion servers
- http://www.gomediaplug.com/ appears to leverage EC2 itself
- http://www.multicastmedia.com/solutions/eat.php Transcoding as a service

Also, the OP could leverage Amazon's EC2 and make an encoding farm
(all depending on budget) - again it is PPV too, so it will only
charge for how much he actually needs. Isn't utility computing great?

(Or just install Ubuntu/some OS yourself and setup ffmpeg on your EC2
boxes yourself)

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



[PHP] Re: unknown number of inputs

2009-04-10 Thread Al


PJ wrote:

I have a script with $_POST and form to load data with text input.
Situation: enter name of author(s) for book. I have the script set up to
enter first_name, last_name for Author1 and the same for Author 2.
Check if entry 1 exists then proceed accordingly
Check if entry 2 exists then proceed accordingly.
Now, If I have three or more authors to enter, is there a way to add a
radio button to add more rows for input or to skip further inputs, if I
have to enter the inputs for each additional author?
I'm looking for a simple way to do this. Could or should Ajax be
involved in this somehow?



Here's the way I do it, especially if typically the number 
of entries are small. e.g., 4 or so.


Show the 4 and let the user Submit them.

Then, if they used all 4, return the page with an additional 
4. Show all 8.


Then, if they've used all 8, repeat until they leave at 
least one unused. Process the page.


Make the batch size a constant that you can easily change. 
And consider making the first rendering say 6 and subsequent 
additions 3, or whatever.


If you want to get a little fancy. Make a simple log file 
for the total number of entries. After the application has 
been used for a while, you can check the log and adjust your 
batch size constant(s) accordingly.


Al

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



[PHP] Help on how to grab data from a page?

2009-04-10 Thread Terion Miller
I'm trying to grab our towns restaurant inspection results , store them in a
db ... I have a script that is able to pull the inspections and divides them
by the paragraphs, now I need a way to grab each line (I think) so that I
can hopefully store the data with fields like RestName, RestAddress etc...
(I haven't created the db yet...)
Anyone ever done this?
here is my script so far, it works but I can't seem to get the line br part
to do anything.
___script
?php


$TESTING = TRUE;


$target_url = 
http://www.springfieldmo.gov/health/database/foodinspections/index.jsp?st_pfx=nonecurrent_name=start_day=1end_year=2009start_month=1st_nmbr=end_month=4end_day=6Submit=Searchst_name=start_year=2009str_loc=noneoffset=0
;

$userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)';


$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
$html = curl_exec($ch);
if (!$html) {
echo br /cURL error number: .curl_errno($ch);
echo br /cURL error: . curl_error($ch);
exit;
}


// parse the html into a DOMDocument
$dom = new DOMDocument();
@$dom-loadHTML($html);

echo $html;

$graphs = split(p, $html);

// Start at 6 to clear out junk at top. Use $i+1 since last paragraph
//is footnote that is not needed.
for ($i = 6; $i+1  count($graphs); $i++)
{


if($TESTING)
echo $i: $graphs[$i]br /;

//split the paragraphs into lines

   $graphs-getAttribute('graphs');
   $lines = split(br, $graphs);

//for ($i = 1; $i+1  count($lines); $i++)
{
// Grab restaurant name
if($TESTING)
echo $i: $lines[$i]br /;
}
// Grab address

// Grab city


// Grab date and visit type
Thanks
Terion

Happy Freecycling
Free the List !!
www.freecycle.org
Over Moderation of Freecycle List Prevents Post Timeliness.
Report Moderator Abuse Here:
http://www.freecycle.org/faq/faq/contact-info
Or Email Your Complaint to:
f...@freecycle.org or i...@freecycle.org

Twitter?
http://twitter.com/terionmiller

Facebook:
a href=http://www.facebook.com/people/Terion-Miller/1542024891;
title=Terion Miller's Facebook profile target=_TOPimg src=
http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0
alt=Terion Miller's Facebook profile/a


Re: [PHP] Re: unknown number of inputs

2009-04-10 Thread Phpster



On Apr 10, 2009, at 12:44, Al n...@ridersite.org wrote:



PJ wrote:

I have a script with $_POST and form to load data with text input.
Situation: enter name of author(s) for book. I have the script set  
up to

enter first_name, last_name for Author1 and the same for Author 2.
Check if entry 1 exists then proceed accordingly
Check if entry 2 exists then proceed accordingly.
Now, If I have three or more authors to enter, is there a way to  
add a
radio button to add more rows for input or to skip further inputs,  
if I

have to enter the inputs for each additional author?
I'm looking for a simple way to do this. Could or should Ajax be
involved in this somehow?


Here's the way I do it, especially if typically the number of  
entries are small. e.g., 4 or so.


Show the 4 and let the user Submit them.

Then, if they used all 4, return the page with an additional 4. Show  
all 8.


Then, if they've used all 8, repeat until they leave at least one  
unused. Process the page.


Make the batch size a constant that you can easily change. And  
consider making the first rendering say 6 and subsequent additions  
3, or whatever.


If you want to get a little fancy. Make a simple log file for the  
total number of entries. After the application has been used for a  
while, you can check the log and adjust your batch size constant(s)  
accordingly.


Al

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



Why, why make trips to the server when you don't need to? I have an  
ongoing arguement with the vp from my company ( I'm the director of  
dev) where he's done the same thing. It is a more complex app and he  
does it in blocks of ten. But when the clients try to add 100 items,  
all the processing he does makes that entire process take almost an  
hour when all is said and done. I keep telling him it should be js  
only to add new rows, with no trips to the server. But then he's as  
smart as the guy who wrote the jpeg image compression ;-P


I digress but never make a trip back when you don't need to.

Bastien 


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



Re: [PHP] Caching

2009-04-10 Thread דניאל דנון
Hey! About   Header set Expires Thu, 15 Apr 2010 20:00:00 GMT 
The problem is the files might change, lets say - every week. How can I use
 Header set Expires Thu, 15 Apr 2010 20:00:00 GMT to something like

Header set Expires today plus week

(or X seconds / y minutes / etc...)

On Fri, Apr 10, 2009 at 12:15 PM, Richard Heyes rich...@php.net wrote:

 Hi,

  I started caching some of the static files on my application,
  I was wondering - Lets say I have an article on my website and I *want*
 to
  cache it. How will I cache it AND will be able to make my visitors
  re-cache it if it has been changed?

 Work from the last modified date/time on the file. When you update the
 file it will change. Though if your files really are static, then
 there's little point - the OS will do a far better job of caching them
 than you will.

 Also, you may also want to have a goosey at the Cache-Control: HTTP
 header over Expires:. It can give you more control.

  How do I use *Header set Expires* (on htaccess) and specifying in a
 week?

 A quick Google found this:

 Header set Expires Thu, 15 Apr 2010 20:00:00 GMT

 --
 Richard Heyes

 HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
 http://www.rgraph.net (Updated March 28th)



Re: [PHP] Re: unknown number of inputs

2009-04-10 Thread Al



Phpster wrote:



On Apr 10, 2009, at 12:44, Al n...@ridersite.org wrote:



PJ wrote:

I have a script with $_POST and form to load data with text input.
Situation: enter name of author(s) for book. I have the script set up to
enter first_name, last_name for Author1 and the same for Author 2.
Check if entry 1 exists then proceed accordingly
Check if entry 2 exists then proceed accordingly.
Now, If I have three or more authors to enter, is there a way to add a
radio button to add more rows for input or to skip further inputs, if I
have to enter the inputs for each additional author?
I'm looking for a simple way to do this. Could or should Ajax be
involved in this somehow?


Here's the way I do it, especially if typically the number of entries 
are small. e.g., 4 or so.


Show the 4 and let the user Submit them.

Then, if they used all 4, return the page with an additional 4. Show 
all 8.


Then, if they've used all 8, repeat until they leave at least one 
unused. Process the page.


Make the batch size a constant that you can easily change. And 
consider making the first rendering say 6 and subsequent additions 3, 
or whatever.


If you want to get a little fancy. Make a simple log file for the 
total number of entries. After the application has been used for a 
while, you can check the log and adjust your batch size constant(s) 
accordingly.


Al

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



Why, why make trips to the server when you don't need to? I have an 
ongoing arguement with the vp from my company ( I'm the director of dev) 
where he's done the same thing. It is a more complex app and he does it 
in blocks of ten. But when the clients try to add 100 items, all the 
processing he does makes that entire process take almost an hour when 
all is said and done. I keep telling him it should be js only to add new 
rows, with no trips to the server. But then he's as smart as the guy who 
wrote the jpeg image compression ;-P


I digress but never make a trip back when you don't need to.

Bastien


Everything is a compromise. I avoid scripts on the client 
side; just another thing to be concerned about for 
compatibility.


Todays speeds for servers, browsers and the net are so fast 
one can hardly get their finger off the mouse button before 
pages are replaced.


For 100 rows, sounds to me like you need a complete 
application on the client side that does all or most of the 
processing. Must take an hour for your users to simple enter 
data into 100 rows.


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



[PHP] ServInt feedback

2009-04-10 Thread la...@garfieldtech.com
Hi folks.  A while back I inquired about managed VPS hosting services. 
   I have since gotten a recommendation for ServInt.net, which seems to 
offer an actual managed VPS or something very close to it.  Does anyone 
else have experience with them, good or bad?  Are they decently 
responsible about maintaining the server image, and responsive about 
requests to change things?  Decent uptime?  All that usual stuff. :-)


Thanks in advance.

--Larry Garfield

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



Re: [PHP] How about a saveXHTML for the DOM?

2009-04-10 Thread Raymond Irving




--- On Wed, 4/8/09, Michael A. Peters mpet...@mac.com wrote:

 From: Michael A. Peters mpet...@mac.com
 Subject: Re: [PHP] How about a saveXHTML for the DOM?
 
 saveXML() already does what is needed to provide valid
 xhtml output.

From my test it sometimes generate this like #13; at the end of the page 
elements. It also generate things like script src=file.js / which does not 
work in most browsers.

So we have to process the out string to convert things like script / 
textarea / to script/script and textrea/textarea

There are other times when saveXML will remove the \n altogether from the code 
which caused tags to be displayed in a single line. In addition saveXML() does 
not preserve html entities. So things like copy; gets converted to ©.

Sometimes working with saveHTML and saveXML is like being caught between a rock 
and a hard place. 

I'm trying to figure out which would be easier to do:

Going from saveHTML() to XHTML 
Going from saveXML() to XHTML

__
Raymond Irving
Create Rich Ajax/PHP Web apps Today!
Raxan PDI - http://raxanpdi.com


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



Re: [PHP] A Tool For Building PHP Web Apps

2009-04-10 Thread Raymond Irving


Maybe this can help:

http://www.intorel.com/index.php?page=ActiveSiteCompiler-default_asp



--- On Fri, 4/10/09, Paul M Foster pa...@quillandmouse.com wrote:

 From: Paul M Foster pa...@quillandmouse.com
 Subject: [PHP] A Tool For Building PHP Web Apps
 To: php-general@lists.php.net
 Date: Friday, April 10, 2009, 1:28 AM
 Here's a hairbrained idea I was
 kicking around. I object to the idea of
 including 15 or 30 files in a PHP application just to
 display one page
 on the internet. It makes the coding faster, but it makes
 the display
 slower and seems silly to me.
 
 So what if you had a tool or a set of tools where you could
 write code
 snippets and such, and then hit a button or issue a
 command, and
 everything you specified got written into a single file?
 You'd specify
 that this page needs to read the config, set up a database
 connection,
 validate these fields, etc. When you were done, it would
 write all this
 code to a *single* file, which the user would invoke by
 surfing to that
 page. The resulting code would be *static*, not like what
 results from
 most templating systems. So rather than specify a specific
 variable
 value in the resulting file, it would embed the PHP code to
 display the
 variable, etc.
 
 What might be the liabilities of something like that? Would
 there be
 security issues? Would there be increased difficulty in
 debugging? What
 can you think of?
 
 Paul
 
 -- 
 Paul M. Foster
 
 -- 
 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] Re: unknown number of inputs

2009-04-10 Thread Michael A. Peters

Phpster wrote:



On Apr 10, 2009, at 12:44, Al n...@ridersite.org wrote:



PJ wrote:

I have a script with $_POST and form to load data with text input.
Situation: enter name of author(s) for book. I have the script set up to
enter first_name, last_name for Author1 and the same for Author 2.
Check if entry 1 exists then proceed accordingly
Check if entry 2 exists then proceed accordingly.
Now, If I have three or more authors to enter, is there a way to add a
radio button to add more rows for input or to skip further inputs, if I
have to enter the inputs for each additional author?
I'm looking for a simple way to do this. Could or should Ajax be
involved in this somehow?


Here's the way I do it, especially if typically the number of entries 
are small. e.g., 4 or so.


Show the 4 and let the user Submit them.

Then, if they used all 4, return the page with an additional 4. Show 
all 8.


Then, if they've used all 8, repeat until they leave at least one 
unused. Process the page.


Make the batch size a constant that you can easily change. And 
consider making the first rendering say 6 and subsequent additions 3, 
or whatever.


If you want to get a little fancy. Make a simple log file for the 
total number of entries. After the application has been used for a 
while, you can check the log and adjust your batch size constant(s) 
accordingly.


Al

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



Why, why make trips to the server when you don't need to?


I agree.
Write a simple javascript that creates an input and adds it as a child 
to the node that contains your inputs.extension) and replace it with a 
virgin input.


var someInput = document.createElement(input);
someInput.setAttribute(type,file);
someInput.setAttribute(name,voucher[]);
someInput.setAttribute(style,width: 42em;);
myDiv.appendChild(myImage);

Put something like that in a function where myDiv is the parent div of 
your inputs.


Then you can add as many extra inputs as you want client side by calling 
the function and there is no need to mess with ajax or any other server 
side tech.


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



Re: [PHP] Re: unknown number of inputs

2009-04-10 Thread Phpster



On Apr 10, 2009, at 15:21, Al n...@ridersite.org wrote:




Phpster wrote:

On Apr 10, 2009, at 12:44, Al n...@ridersite.org wrote:


PJ wrote:
I have a script with $_POST and form to load data with text  
input.
Situation: enter name of author(s) for book. I have the script  
set up to

enter first_name, last_name for Author1 and the same for Author 2.
Check if entry 1 exists then proceed accordingly
Check if entry 2 exists then proceed accordingly.
Now, If I have three or more authors to enter, is there a way to  
add a
radio button to add more rows for input or to skip further  
inputs, if I

have to enter the inputs for each additional author?
I'm looking for a simple way to do this. Could or should Ajax be
involved in this somehow?


Here's the way I do it, especially if typically the number of  
entries are small. e.g., 4 or so.


Show the 4 and let the user Submit them.

Then, if they used all 4, return the page with an additional 4.  
Show all 8.


Then, if they've used all 8, repeat until they leave at least one  
unused. Process the page.


Make the batch size a constant that you can easily change. And  
consider making the first rendering say 6 and subsequent additions  
3, or whatever.


If you want to get a little fancy. Make a simple log file for the  
total number of entries. After the application has been used for a  
while, you can check the log and adjust your batch size  
constant(s) accordingly.


Al

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

Why, why make trips to the server when you don't need to? I have an  
ongoing arguement with the vp from my company ( I'm the director of  
dev) where he's done the same thing. It is a more complex app and  
he does it in blocks of ten. But when the clients try to add 100  
items, all the processing he does makes that entire process take  
almost an hour when all is said and done. I keep telling him it  
should be js only to add new rows, with no trips to the server. But  
then he's as smart as the guy who wrote the jpeg image  
compression ;-P

I digress but never make a trip back when you don't need to.
Bastien


Everything is a compromise. I avoid scripts on the client side; just  
another thing to be concerned about for compatibility.


Todays speeds for servers, browsers and the net are so fast one can  
hardly get their finger off the mouse button before pages are  
replaced.


For 100 rows, sounds to me like you need a complete application on  
the client side that does all or most of the processing. Must take  
an hour for your users to simple enter data into 100 rows.


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



The web app works well if slowly, but if I could rework the pages in  
question, though a move to an Adobe AIR project is what I would do.


As for speed, since our app is sold as a hosted or an inhouse version,  
there is often other factors involved in the overall network speed and  
server ability. And since it's purchased app, we can dictate  
requirements like js being available. 


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



Re: [PHP] Escape Data In/Out of db [solved]

2009-04-10 Thread tedd

At 9:12 PM -0700 4/9/09, Jim Lucas wrote:

tedd wrote:

At 5:03 PM +0200 4/9/09, Jan G.B. wrote:


You might want to use htmlspecialchars($str, ENT_QUOTES)


OUT from db to html

and


mysql_real_escape_string(stripslashes($_POST['yourself']));




The above tells me that you probably need to look at your magic 
quotes setting.


The php info says:

magic_quotes_runtimeOff Off
magic_quotes_sybase Off Off

I'm assuming that means OFF, right?

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] How about a saveXHTML for the DOM?

2009-04-10 Thread Michael A. Peters

Raymond Irving wrote:




--- On Wed, 4/8/09, Michael A. Peters mpet...@mac.com wrote:


From: Michael A. Peters mpet...@mac.com
Subject: Re: [PHP] How about a saveXHTML for the DOM?

saveXML() already does what is needed to provide valid
xhtml output.


From my test it sometimes generate this like #13; at the end of the page elements. It also 
generate things like script src=file.js / which does not work in most browsers.



script src=foo.js /

will work on any browser that advertises it accepts the xhtml+xml mime type.

Internet exploder does not and therefore internet exploder should be 
sent xhtml document. Send html documents to internet exploder.


?php
if (! isset($usexml)) {
   $usexml=1;
   }
if ($usexml == 1) {
   if (isset( $_SERVER['HTTP_ACCEPT'] )) {
  if(! strpos( $_SERVER['HTTP_ACCEPT'], application/xhtml+xml ) ) {
 $usexml=0;
 }
  } else {
  $usexml=0;
  }
   }
?

That will result in $usexml being set to 1 for browsers (like Firefox 
and Opera) that accept xhtml+xml while setting it to 0 for browsers that 
do not accept xhtml+xml.


Then when you create your DOM -

?php
$xhtmldtd=!DOCTYPE html PUBLIC \-//W3C//DTD XHTML 1.1//EN\ 
\http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\;;
$htmldtd=!DOCTYPE html PUBLIC \-//W3C//DTD HTML 4.01//EN\ 
\http://www.w3.org/TR/html4/strict.dtd\;;


$myxhtml = new DOMDocument(1.0,UTF-8);
$myxhtml-preserveWhiteSpace = false;
$myxhtml-formatOutput = true;
if ($usexml == 0) {
   $xmlstring = $htmldtd . html/html;
   } else {
   $xmlstring = ?xml version=\1.0\ encoding=\UTF-8\? . 
$xhtmldtd . html/html;

   }
$myxhtml-loadXML($xmlstring);
$elements = $myxhtml-getElementsByTagName(html);
$xmlHtml = $elements-item(0);
?

You then add your children (IE head and body) to $xmlHtml.

When it comes time to serve the page -

?php
function sendxhtmlheader($usexml) {
   if ($usexml == 1) {
  header(Content-Type: application/xhtml+xml; charset=utf-8);
  } else {
  header(Content-type: text/html; charset=utf-8);
  }
   }
?

makes sure the right header describing the content is set.
Send the page like this:

?php
if ($usexml == 0) {
   print $myxhtml-saveHTML();
   } else {
   print $myxhtml-saveXML();
   }
?

That way you only send xhtml to browsers that advertised to your server 
that they know what to do with the application/xhtml+xml mime type, 
those that did not advertise they know what to do get the text/html mime 
type and an html page.


It works extremely well in my test environment (my web app is not live 
yet) for sending valid xhtml 1.1 to browsers that properly handle xhtml 
and sending html 4.1 strict to browsers that do not properly handle 
xhtml+xml (IE internet exploder).


As far as I can tell - as long as you aren't using an extension to xhtml 
(like MathML) - the only problem where you can't produce both valid 
xhtml 1.1 and html 4.01 strict from the same php code would be if you 
were using the ruby (not programming language, the tags) elements that 
are allowed in xhtml 1.1 but not defined in HTML 4.01


No browser I have tested with that broadcasts it accepts xhtml+xml has 
ever had a problem with self closing script (or input or meta or ...) tags.


If you send xhtml with the text/plain mime type then the failure is on 
your end for violating the specification and self closing script tags 
are not legal.


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



Re: [PHP] Re: unknown number of inputs

2009-04-10 Thread PJ
Michael A. Peters wrote:
 Phpster wrote:


 On Apr 10, 2009, at 12:44, Al n...@ridersite.org wrote:


 PJ wrote:
 I have a script with $_POST and form to load data with text input.
 Situation: enter name of author(s) for book. I have the script set
 up to
 enter first_name, last_name for Author1 and the same for Author 2.
 Check if entry 1 exists then proceed accordingly
 Check if entry 2 exists then proceed accordingly.
 Now, If I have three or more authors to enter, is there a way to add a
 radio button to add more rows for input or to skip further inputs,
 if I
 have to enter the inputs for each additional author?
 I'm looking for a simple way to do this. Could or should Ajax be
 involved in this somehow?

 Here's the way I do it, especially if typically the number of
 entries are small. e.g., 4 or so.

 Show the 4 and let the user Submit them.

 Then, if they used all 4, return the page with an additional 4. Show
 all 8.

 Then, if they've used all 8, repeat until they leave at least one
 unused. Process the page.

 Make the batch size a constant that you can easily change. And
 consider making the first rendering say 6 and subsequent additions
 3, or whatever.

 If you want to get a little fancy. Make a simple log file for the
 total number of entries. After the application has been used for a
 while, you can check the log and adjust your batch size constant(s)
 accordingly.

 Al

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


 Why, why make trips to the server when you don't need to?

 I agree.
 Write a simple javascript that creates an input and adds it as a child
 to the node that contains your inputs.extension) and replace it with a
 virgin input.

 var someInput = document.createElement(input);
 someInput.setAttribute(type,file);
 someInput.setAttribute(name,voucher[]);
 someInput.setAttribute(style,width: 42em;);
 myDiv.appendChild(myImage);

 Put something like that in a function where myDiv is the parent div of
 your inputs.

 Then you can add as many extra inputs as you want client side by
 calling the function and there is no need to mess with ajax or any
 other server side tech.

Thanks, guys, got it. JS makes sense for what I was looking for.
As to speed, yes it takes probably more time to enter 100 inputs for my
app, but then it's only for administrators and it's only to add db data;
not for users.
Thanks.
PJ

-- 
unheralded genius: A clean desk is the sign of a dull mind. 
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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



Re: [PHP] How about a saveXHTML for the DOM?

2009-04-10 Thread Michael A. Peters

Michael A. Peters wrote:


$myxhtml-loadXML($xmlstring);
$elements = $myxhtml-getElementsByTagName(html);
$xmlHtml = $elements-item(0);
?


forgot this tidbit -

?pjp
if ($usexml == 1) {
   $xmlHtml-setAttribute(xmlns,http://www.w3.org/1999/xhtml;);

$xmlHtml-setAttributeNS('http://www.w3.org/XML/1998/namespace','xml:lang','en');
   }

*now* you can have your php code populate the dom by appending children 
to $xmlHtml neutral to whether or not it eventually is going to be sent 
as xml or html.


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



Re: [PHP] How about a saveXHTML for the DOM?

2009-04-10 Thread Raymond Irving


Thanks for the feedback Michael. I will look into your suggesstions.

Is there an option on the DOMDocument that we can set to not have saveXML() 
append #13; to the end of the tags?

This is normally the case if the html content was loaded using loadHTMLFile()

__
Raymond Irving

--- On Fri, 4/10/09, Michael A. Peters mpet...@mac.com wrote:

From: Michael A. Peters mpet...@mac.com
Subject: Re: [PHP] How about a saveXHTML for the DOM?
To: Raymond Irving xwis...@yahoo.com
Cc: php-general@lists.php.net php-general@lists.php.net
Date: Friday, April 10, 2009, 3:57 PM

Raymond Irving wrote:
 
 
 
 --- On Wed, 4/8/09, Michael A. Peters mpet...@mac.com wrote:
 
 From: Michael A. Peters mpet...@mac.com
 Subject: Re: [PHP] How about a saveXHTML for the DOM?
 
 saveXML() already does what is needed to provide valid
 xhtml output.
 
 From my test it sometimes generate this like 
 at the end of the page elements. It also generate things like script 
src=file.js / which does not work in most browsers.
 

script src=foo.js /

will work on any browser that advertises it accepts the xhtml+xml mime type.

Internet exploder does not and therefore internet exploder should be sent xhtml 
document. Send html documents to internet exploder.

?php
if (! isset($usexml)) {
   $usexml=1;
   }
if ($usexml == 1) {
   if (isset( $_SERVER['HTTP_ACCEPT'] )) {
      if(! strpos( $_SERVER['HTTP_ACCEPT'], application/xhtml+xml ) ) {
         $usexml=0;
         }
      } else {
      $usexml=0;
      }
   }
?

That will result in $usexml being set to 1 for browsers (like Firefox and 
Opera) that accept xhtml+xml while setting it to 0 for browsers that do not 
accept xhtml+xml.

Then when you create your DOM -

?php
$xhtmldtd=!DOCTYPE html PUBLIC \-//W3C//DTD XHTML 1.1//EN\ 
\http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\;;
$htmldtd=!DOCTYPE html PUBLIC \-//W3C//DTD HTML 4.01//EN\ 
\http://www.w3.org/TR/html4/strict.dtd\;;

$myxhtml = new DOMDocument(1.0,UTF-8);
$myxhtml-preserveWhiteSpace = false;
$myxhtml-formatOutput = true;
if ($usexml == 0) {
   $xmlstring = $htmldtd . html/html;
   } else {
   $xmlstring = ?xml version=\1.0\ encoding=\UTF-8\? . $xhtmldtd . 
html/html;
   }
$myxhtml-loadXML($xmlstring);
$elements = $myxhtml-getElementsByTagName(html);
$xmlHtml = $elements-item(0);
?

You then add your children (IE head and body) to $xmlHtml.

When it comes time to serve the page -

?php
function sendxhtmlheader($usexml) {
   if ($usexml == 1) {
      header(Content-Type: application/xhtml+xml; charset=utf-8);
      } else {
      header(Content-type: text/html; charset=utf-8);
      }
   }
?

makes sure the right header describing the content is set.
Send the page like this:

?php
if ($usexml == 0) {
   print $myxhtml-saveHTML();
   } else {
   print $myxhtml-saveXML();
   }
?

That way you only send xhtml to browsers that advertised to your server that 
they know what to do with the application/xhtml+xml mime type, those that did 
not advertise they know what to do get the text/html mime type and an html page.

It works extremely well in my test environment (my web app is not live yet) for 
sending valid xhtml 1.1 to browsers that properly handle xhtml and sending html 
4.1 strict to browsers that do not properly handle xhtml+xml (IE internet 
exploder).

As far as I can tell - as long as you aren't using an extension to xhtml (like 
MathML) - the only problem where you can't produce both valid xhtml 1.1 and 
html 4.01 strict from the same php code would be if you were using the ruby 
(not programming language, the tags) elements that are allowed in xhtml 1.1 but 
not defined in HTML 4.01

No browser I have tested with that broadcasts it accepts xhtml+xml has ever had 
a problem with self closing script (or input or meta or ...) tags.

If you send xhtml with the text/plain mime type then the failure is on your end 
for violating the specification and self closing script tags are not legal.


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



Re: [PHP] How about a saveXHTML for the DOM?

2009-04-10 Thread Michael A. Peters

Raymond Irving wrote:


Thanks for the feedback Michael. I will look into your suggesstions.

Is there an option on the DOMDocument that we can set to not have saveXML() append 
#13; to the end of the tags?

This is normally the case if the html content was loaded using loadHTMLFile()


I think I've seen that appear in textarea as well - I believe it has to 
do with the libebreaks of the application that created the file (or in 
case of textarea from a form, the line break convention of the browser).


Does it happen when you run

sed -i 's/\r//g' file.html

to remove the DOS carriage return from the line breaks?

That would be my guess.

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