php-general Digest 6 Dec 2008 21:24:07 -0000 Issue 5830
php-general Digest 6 Dec 2008 21:24:07 - Issue 5830 Topics (messages 284233 through 284243): Re: Convert .docx /.pdf file to .txt 284233 by: Colin Guthrie 284234 by: Ashley Sheridan Re: How to Insert ?xml-stylesheet .? into DOMDocument 284235 by: Nathan Rixham 284243 by: Carlos Medina Re: Poll of sorts: Javascript Form validation or PHP 284236 by: Per Jessen 284237 by: Nathan Rixham Re: Parsing Strings 284238 by: tedd 284239 by: VamVan 284240 by: Nathan Rixham 284241 by: Nathan Rixham How do you organise your PHP work ? 284242 by: franzemmanuel Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- 'Twas brillig, and Jagdeep Singh at 06/12/08 06:46 did gyre and gimble: Hi! I need a function to fetch text from docx file, but it is showing formated characters in output. I was using fopen, fgets etc function . I want to fetch text from .docx and save it to .txt file Without special characters (Microsoft formated characters) Is there any function or an example?? Nothing that I know of built in to PHP (although as docx is just XML AFAIK, you could just write an XSLT to extract the content). You could also shell out to an application that would do it for you. After about 5 seconds on google I found: http://sourceforge.net/project/showfiles.php?group_id=235455 If it works or not I have no idea! Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] ---End Message--- ---BeginMessage--- On Sat, 2008-12-06 at 09:17 +, Colin Guthrie wrote: 'Twas brillig, and Jagdeep Singh at 06/12/08 06:46 did gyre and gimble: Hi! I need a function to fetch text from docx file, but it is showing formated characters in output. I was using fopen, fgets etc function . I want to fetch text from .docx and save it to .txt file Without special characters (Microsoft formated characters) Is there any function or an example?? Nothing that I know of built in to PHP (although as docx is just XML AFAIK, you could just write an XSLT to extract the content). You could also shell out to an application that would do it for you. After about 5 seconds on google I found: http://sourceforge.net/project/showfiles.php?group_id=235455 If it works or not I have no idea! Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] Also, as far as I believe, docx isn't just an XML document, but rather a zip file of xml docs and other media. Ash www.ashleysheridan.co.uk ---End Message--- ---BeginMessage--- Shanon Swafford wrote: I have the following code: #!/usr/bin/php -q ?PHP error_reporting(E_ALL); ini_set('display_errors', '1'); $doc = new DOMDocument(); $doc-formatOutput = true; $foo = $doc-createElement(foo); $doc-appendChild($foo); $bar = $doc-createElement(bar); $foo-appendChild($bar); $bazz = $doc-createElement(bazz); $foo-appendChild($bazz); echo $doc-saveXML(); ? Which generates: ?xml version=1.0? foo bar/ bazz/ /foo Is there a way to make it create the following XML? ?xml version=1.0? ?xml-stylesheet href=xsl_table.xsl type=text/xsl? foo bar/ bazz/ /foo I can't seem to find any dom functions to do this. Thanks in advance, Shanon DOMProcessingInstruction as such: ?php error_reporting(E_ALL | E_STRICT); $doc = new DOMDocument(); $doc-formatOutput = true; // processing instruction data $styleheetParams = 'href=xsl_table.xsl type=text/xsl'; // create processing instruction $xmlstylesheet = new DOMProcessingInstruction( 'xml-stylesheet', $styleheetParams); //append it to the doc $doc-appendChild($xmlstylesheet); $foo = $doc-createElement(foo); $doc-appendChild($foo); $bar = $doc-createElement(bar); $foo-appendChild($bar); $bazz = $doc-createElement(bazz); $foo-appendChild($bazz); echo $doc-saveXML(); ? regards; ---End Message--- ---BeginMessage--- Shanon Swafford schrieb: I have the following code: #!/usr/bin/php -q ?PHP error_reporting(E_ALL); ini_set('display_errors', '1'); $doc = new DOMDocument(); $doc-formatOutput = true; $foo = $doc-createElement(foo); $doc-appendChild($foo); $bar = $doc-createElement(bar); $foo-appendChild($bar); $bazz = $doc-createElement(bazz);
[PHP] Re: Poll of sorts: Javascript Form validation or PHP
On Fri, 5 Dec 2008 12:28:08 -0600, Terion Miller wrote: I have a huge form to validate and wonder which is better javascript validation or php, the page is a php page, I actually put js validation on it but then it stopped working (stopped inserting into the db) not sure if that had anything to do with it What does everyone prefer? As per all others here (and nice to see that!) I say always validate in PHP, and if you have time, add JavaScript to improve the user experience. Never trust your inputs to be valid; always check in PHP. Terion who is actually finally learning stuff to her surprise!! Good, because when you stop learning is when you start dying... -- Ross McKay, Toronto, NSW Australia Before enlightenment: chop wood, carry water; After enlightenment: chop wood, carry water - Wu Li -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Convert .docx /.pdf file to .txt
'Twas brillig, and Jagdeep Singh at 06/12/08 06:46 did gyre and gimble: Hi! I need a function to fetch text from docx file, but it is showing formated characters in output. I was using fopen, fgets etc function . I want to fetch text from .docx and save it to .txt file Without special characters (Microsoft formated characters) Is there any function or an example?? Nothing that I know of built in to PHP (although as docx is just XML AFAIK, you could just write an XSLT to extract the content). You could also shell out to an application that would do it for you. After about 5 seconds on google I found: http://sourceforge.net/project/showfiles.php?group_id=235455 If it works or not I have no idea! Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Convert .docx /.pdf file to .txt
On Sat, 2008-12-06 at 09:17 +, Colin Guthrie wrote: 'Twas brillig, and Jagdeep Singh at 06/12/08 06:46 did gyre and gimble: Hi! I need a function to fetch text from docx file, but it is showing formated characters in output. I was using fopen, fgets etc function . I want to fetch text from .docx and save it to .txt file Without special characters (Microsoft formated characters) Is there any function or an example?? Nothing that I know of built in to PHP (although as docx is just XML AFAIK, you could just write an XSLT to extract the content). You could also shell out to an application that would do it for you. After about 5 seconds on google I found: http://sourceforge.net/project/showfiles.php?group_id=235455 If it works or not I have no idea! Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/] Also, as far as I believe, docx isn't just an XML document, but rather a zip file of xml docs and other media. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to Insert ?xml-stylesheet .....? into DOMDocument
Shanon Swafford wrote: I have the following code: #!/usr/bin/php -q ?PHP error_reporting(E_ALL); ini_set('display_errors', '1'); $doc = new DOMDocument(); $doc-formatOutput = true; $foo = $doc-createElement(foo); $doc-appendChild($foo); $bar = $doc-createElement(bar); $foo-appendChild($bar); $bazz = $doc-createElement(bazz); $foo-appendChild($bazz); echo $doc-saveXML(); ? Which generates: ?xml version=1.0? foo bar/ bazz/ /foo Is there a way to make it create the following XML? ?xml version=1.0? ?xml-stylesheet href=xsl_table.xsl type=text/xsl? foo bar/ bazz/ /foo I can't seem to find any dom functions to do this. Thanks in advance, Shanon DOMProcessingInstruction as such: ?php error_reporting(E_ALL | E_STRICT); $doc = new DOMDocument(); $doc-formatOutput = true; // processing instruction data $styleheetParams = 'href=xsl_table.xsl type=text/xsl'; // create processing instruction $xmlstylesheet = new DOMProcessingInstruction( 'xml-stylesheet', $styleheetParams); //append it to the doc $doc-appendChild($xmlstylesheet); $foo = $doc-createElement(foo); $doc-appendChild($foo); $bar = $doc-createElement(bar); $foo-appendChild($bar); $bazz = $doc-createElement(bazz); $foo-appendChild($bazz); echo $doc-saveXML(); ? regards; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
Terion Miller wrote: I have a huge form to validate and wonder which is better javascript validation or php, the page is a php page, I actually put js validation on it but then it stopped working (stopped inserting into the db) not sure if that had anything to do with it What does everyone prefer? I don't think it's about the developer preference, it's about the user. Javascript enables lots of checking at data entry time, and can improve the overall user experience. If you're not particularly concerned with the user experience, don't bother with javascript. /Per Jessen, Zürich -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
Per Jessen wrote: Terion Miller wrote: I have a huge form to validate and wonder which is better javascript validation or php, the page is a php page, I actually put js validation on it but then it stopped working (stopped inserting into the db) not sure if that had anything to do with it What does everyone prefer? I don't think it's about the developer preference, it's about the user. Javascript enables lots of checking at data entry time, and can improve the overall user experience. If you're not particularly concerned with the user experience, don't bother with javascript. /Per Jessen, Zürich where as I think validation always needs to happen at the server side; each application or script should be self contained, it needs to check that the data it recieves is valid before working with it; if it is not valid it needs to inform the system that sent it the data is not valid. The system that sent it in this case is the html output; so you need a method of displaying errors in the html. That is the bare minimum and always needed. As for making the experience nicer; javascript is good for this; it can be used to pre-validate input on the way in to the system; but should not be relied upon as it can be turned off, stop functioning due to another faulty javascript on the page or simply not be supported by the client. You still need the server side validation though. So.. more of a case of always validate server side; and should / do you want to use javascript validation in addition. IMHO :p -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Parsing Strings
At 4:18 PM -0800 12/5/08, Jason Todd Slack-Moehrle wrote: How might I also parse and address like: SCOTTSDALE, AZ 85254 It has a comma and a space -Jason On Dec 5, 2008, at 4:02 PM, Jason Todd Slack-Moehrle wrote: OK, making good learning progress today. I have a string that is: Jason Slack and I want it broken at the space so i get Jason and then Slack I am looking at parse_str, but I dont get how to do it with a space. The example is using []=. Then I want to assign like: $fname = Jason; $lname = Slack; Any ideas? -Jason -Jason: This is pretty basic stuff -- read the manuals about strings: http://www.php.net/manual/en/book.strings.php If you have shown that you've spent time reading and then have a problem, please post your question. But don't expect us to do your homework for you. 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] Parsing Strings
u can use split() or explode (). Thanks On Sat, Dec 6, 2008 at 9:27 AM, tedd [EMAIL PROTECTED] wrote: At 4:18 PM -0800 12/5/08, Jason Todd Slack-Moehrle wrote: How might I also parse and address like: SCOTTSDALE, AZ 85254 It has a comma and a space -Jason On Dec 5, 2008, at 4:02 PM, Jason Todd Slack-Moehrle wrote: OK, making good learning progress today. I have a string that is: Jason Slack and I want it broken at the space so i get Jason and then Slack I am looking at parse_str, but I dont get how to do it with a space. The example is using []=. Then I want to assign like: $fname = Jason; $lname = Slack; Any ideas? -Jason -Jason: This is pretty basic stuff -- read the manuals about strings: http://www.php.net/manual/en/book.strings.php If you have shown that you've spent time reading and then have a problem, please post your question. But don't expect us to do your homework for you. 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] Parsing Strings
tedd wrote: At 4:18 PM -0800 12/5/08, Jason Todd Slack-Moehrle wrote: How might I also parse and address like: SCOTTSDALE, AZ 85254 It has a comma and a space -Jason On Dec 5, 2008, at 4:02 PM, Jason Todd Slack-Moehrle wrote: OK, making good learning progress today. I have a string that is: Jason Slack and I want it broken at the space so i get Jason and then Slack I am looking at parse_str, but I dont get how to do it with a space. The example is using []=. Then I want to assign like: $fname = Jason; $lname = Slack; Any ideas? -Jason -Jason: This is pretty basic stuff -- read the manuals about strings: http://www.php.net/manual/en/book.strings.php If you have shown that you've spent time reading and then have a problem, please post your question. But don't expect us to do your homework for you. Cheers, tedd this is wrong on so many levels, but his name indicates that he's more of a delegator than a doer :p -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to Insert ?xml-stylesheet .....? into DOMDocument
Shanon Swafford schrieb: I have the following code: #!/usr/bin/php -q ?PHP error_reporting(E_ALL); ini_set('display_errors', '1'); $doc = new DOMDocument(); $doc-formatOutput = true; $foo = $doc-createElement(foo); $doc-appendChild($foo); $bar = $doc-createElement(bar); $foo-appendChild($bar); $bazz = $doc-createElement(bazz); $foo-appendChild($bazz); echo $doc-saveXML(); ? Which generates: ?xml version=1.0? foo bar/ bazz/ /foo Is there a way to make it create the following XML? ?xml version=1.0? ?xml-stylesheet href=xsl_table.xsl type=text/xsl? foo bar/ bazz/ /foo I can't seem to find any dom functions to do this. Thanks in advance, Shanon Hi Shanon, please look at the Class itself, if you can modify the Header of the XML data over a method/Constant. Greetings Carlos Medina -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How do you organise your PHP work ?
franzemmanuel wrote: Hi ! I wanted to know how you organise your work when you develop a project ? - I have a checking list to control each file. - I make a diagram (with Impress). - And a CalcSheet to follow my variables. (examples : http://www.surleweb.biz/development.php). And you ? How do you work ? Have a good evening everybody ! Personally I sanity check with unit tests; document everything thoroughly as i go and run through phpdoc frequently. if I need a visual representation I normally do it at the planning stage using amateras or a similar UML tool. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: How to Insert ?xml-stylesheet .....? into DOMDocument
Is there a way to make it create the following XML? ?xml version=1.0? ?xml-stylesheet href=xsl_table.xsl type=text/xsl? foo bar/ bazz/ /foo I can't seem to find any dom functions to do this. Thanks in advance, Shanon DOMProcessingInstruction as such: ?php error_reporting(E_ALL | E_STRICT); $doc = new DOMDocument(); $doc-formatOutput = true; // processing instruction data $styleheetParams = 'href=xsl_table.xsl type=text/xsl'; // create processing instruction $xmlstylesheet = new DOMProcessingInstruction( 'xml-stylesheet', $styleheetParams); //append it to the doc $doc-appendChild($xmlstylesheet); $foo = $doc-createElement(foo); $doc-appendChild($foo); $bar = $doc-createElement(bar); $foo-appendChild($bar); $bazz = $doc-createElement(bazz); $foo-appendChild($bazz); echo $doc-saveXML(); ? Thanks Nathan, That worked perfect! Shanon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Poll of sorts: Javascript Form validation or PHP
I agree with Nathan. Always do server side validation, and if you have the skills, time, or are being paid then add javascript validation to make the user experience better. I have a general contact form which checks the input server side (PHP) and if there's something wrong then it indicates as such, and shows the user their input, with the errors and why (e.g not a valid email address, etc..). If it was for anything larger than about 10 fields per page, then javascript validation can be useful. Slightly off topic, but does anyone know of an easy way of checking user input like the PHP filter_var() function? I've seen plenty of libraries for AJAX, and the like (Prototype, jquery, etc), but haven't run across any for standard form input validation. Thanks. Michael Kubler* * http://www.greyphoenix.biz Nathan Rixham wrote: where as I think validation always needs to happen at the server side; each application or script should be self contained, it needs to check that the data it recieves is valid before working with it; if it is not valid it needs to inform the system that sent it the data is not valid. The system that sent it in this case is the html output; so you need a method of displaying errors in the html. That is the bare minimum and always needed. As for making the experience nicer; javascript is good for this; it can be used to pre-validate input on the way in to the system; but should not be relied upon as it can be turned off, stop functioning due to another faulty javascript on the page or simply not be supported by the client. You still need the server side validation though. So.. more of a case of always validate server side; and should / do you want to use javascript validation in addition. IMHO :p -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php