php-general Digest 29 Jan 2010 11:30:34 -0000 Issue 6564
php-general Digest 29 Jan 2010 11:30:34 - Issue 6564 Topics (messages 301636 through 301648): Good source for sample data? 301636 by: Brian Dunning 301637 by: Shawn McKenzie 301638 by: Nathan Rixham 301639 by: TG 301640 by: james stojan exception throw from __autoload could not be catched on php 5.3.1 301641 by: Eric Lee 301642 by: Ashley Sheridan 301643 by: Ashley Sheridan 301644 by: Ryan 301645 by: Eric Lee 301646 by: Eric Lee Re: Do you use a public framework or roll your own? 301647 by: Michael A. Peters 301648 by: Tom Sparks Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Hey all - I need a few million sample contact records - name, company, address, email, web, phone, fax. ZIP codes and area codes and street addresses should be correct and properly formatted, but preferably not real people or companies or email addresses. But they'd work if you did address validation or mapping. Anyone have a suggestion? - Brian---End Message--- ---BeginMessage--- Brian Dunning wrote: Hey all - I need a few million sample contact records - name, company, address, email, web, phone, fax. ZIP codes and area codes and street addresses should be correct and properly formatted, but preferably not real people or companies or email addresses. But they'd work if you did address validation or mapping. Anyone have a suggestion? - Brian It should be easy to code a routine to generate random data. Maybe 20 - 30 lines of code. Obviously you may have a name like Dgidfgq Xcvbop and company Wsdkn, but it shouldn't matter if testing is your purpose. -- Thanks! -Shawn http://www.spidean.com ---End Message--- ---BeginMessage--- Brian Dunning wrote: Hey all - I need a few million sample contact records - name, company, address, email, web, phone, fax. ZIP codes and area codes and street addresses should be correct and properly formatted, but preferably not real people or companies or email addresses. But they'd work if you did address validation or mapping. Anyone have a suggestion? - Brian get the data from a whats near X API and obscure the personally identifiable data with dummy values. ? ---End Message--- ---BeginMessage--- I remembered a coworker found an online resource that generated sample data for you. I hit google and I think I found it: http://www.generatedata.com/ I I found it on a list of resources for data generation: http://www.webresourcesdepot.com/test-sample-data-generators/ I've never used any of these, but once again.. Google is your friend. -TG - Original Message - From: Brian Dunning br...@briandunning.com To: php-gene...@lists.php.net, my...@lists.mysql.com Date: Thu, 28 Jan 2010 15:52:41 -0800 Subject: [PHP] Good source for sample data? Hey all - I need a few million sample contact records - name, company, address, email, web, phone, fax. ZIP codes and area codes and street addresses should be correct and properly formatted, but preferably not real people or companies or email addresses. But they'd work if you did address validation or mapping. Anyone have a suggestion? - Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ---End Message--- ---BeginMessage--- Fakenamegenerator.com is pretty good for these kinds of records, alot of variety and can change order/formating for them but they do limit free orders to 50k records. http://www.fakenamegenerator.com/order.php On Thu, Jan 28, 2010 at 8:06 PM, TG tg-...@gryffyndevelopment.com wrote: I remembered a coworker found an online resource that generated sample data for you. I hit google and I think I found it: http://www.generatedata.com/ I I found it on a list of resources for data generation: http://www.webresourcesdepot.com/test-sample-data-generators/ I've never used any of these, but once again.. Google is your friend. -TG - Original Message - From: Brian Dunning br...@briandunning.com To: php-gene...@lists.php.net, my...@lists.mysql.com Date: Thu, 28 Jan 2010 15:52:41 -0800 Subject: [PHP] Good source for sample data? Hey all - I need a few million sample contact records - name, company, address, email, web, phone, fax. ZIP codes and area codes and street addresses should be correct and properly formatted, but preferably not real people or companies or email addresses. But they'd work if you did address validation or mapping. Anyone have a suggestion? - Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Do you use a public framework or roll your own?
Michael A. Peters wrote: Daevid Vincent wrote: I'm not looking to start a holy war here or re-hash the tired debate. I just want some hard cold numbers to look at. Do you use a public framework or roll your own? http://www.rapidpoll.net/8opnt1e And for those interested, here are the results of the last poll: To add the final ? in PHP or not... http://www.rapidpoll.net/show.aspx?id=arc1opy I'm relieved to know I'm in the majority (almost 2:1) who close their opening PHP tags. :) I roll my own, partially from classes I wrote and partially from classes at phpclasses.org and partially from neat stuff I find on the web. Not sure you could call it framework though, just a loose collection of independent classes. Just spent a couple days bringing that loose collection together along with CSS templates from http://www.freecsstemplates.org/ and now actually have my own (not quite finished) CMS. And it looks / works a hell of a lot better than anything I've done before (er, other than it not quite being finished ...) Making my classes work together specifically to make a generic CMS exposed a lot of bugs and poor design decisions in them that are now largely fixes (er, well, we'll see ...) Last few days have been like an epiphany for me. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Do you use a public framework or roll your own?
--- On Fri, 29/1/10, Michael A. Peters mpet...@mac.com wrote: Michael A. Peters wrote: Daevid Vincent wrote: I'm not looking to start a holy war here or re-hash the tired debate. I just want some hard cold numbers to look at. Do you use a public framework or roll your own? http://www.rapidpoll.net/8opnt1e And for those interested, here are the results of the last poll: To add the final ? in PHP or not... http://www.rapidpoll.net/show.aspx?id=arc1opy I have looked at a few open source frameworks, I have found them too hard to hack/edit/modify or incapable of doing what I need so it looks like I need write my own :( ts __ Yahoo!7: Catch-up on your favourite Channel 7 TV shows easily, legally, and for free at PLUS7. www.tv.yahoo.com.au/plus7 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Do you use a public framework or roll your own?
What could help a developer is to plunder the available open-source frameworks and use the loot in his own code. At times these frame-works are well thought out, and some of their classes are clean, and can easily be moved into other contexts. Teus. On Fri, 2010-01-29 at 03:30 -0800, Tom Sparks wrote: Do you use a public framework or roll your own? http://www.rapidpoll.net/8opnt1e -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Good source for sample data?
Agree'd. I've done this a couple of times. Usually best is to grab a couple of free online dictionary lists. One for peoples names, another for business names, then just randomly pull the data from the dictionaries. Addresses, websites, phone numbers, and zip codes can all be randomly generated, or you can use the GEONames database http://www.geonames.org/ to generate actual locations. Also, wasn't there some test data available by MySQL? I think it was the Sakila http://dev.mysql.com/doc/sakila/en/sakila.htmldatabase http://forums.mysql.com/list.php?121. -- Michael Kubler I believe in a better world. I support the Zeitgeist Movement Shawn McKenzie wrote: Brian Dunning wrote: Hey all - I need a few million sample contact records - name, company, address, email, web, phone, fax. ZIP codes and area codes and street addresses should be correct and properly formatted, but preferably not real people or companies or email addresses. But they'd work if you did address validation or mapping. Anyone have a suggestion? - Brian It should be easy to code a routine to generate random data. Maybe 20 - 30 lines of code. Obviously you may have a name like Dgidfgq Xcvbop and company Wsdkn, but it shouldn't matter if testing is your purpose.
Re: [PHP] Do you use a public framework or roll your own?
I converted one that was originally in classic ASP. It's terrible, with poor design and large overhead. Used for a few projects, but now use codeigniter. It's the easiest to adapt without many of the restrictions of th larger frameworks. Bastien Sent from my iPod On Jan 29, 2010, at 5:08 AM, Michael A. Peters mpet...@mac.com wrote: Michael A. Peters wrote: Daevid Vincent wrote: I'm not looking to start a holy war here or re-hash the tired debate. I just want some hard cold numbers to look at. Do you use a public framework or roll your own? http://www.rapidpoll.net/8opnt1e And for those interested, here are the results of the last poll: To add the final ? in PHP or not... http://www.rapidpoll.net/show.aspx?id=arc1opy I'm relieved to know I'm in the majority (almost 2:1) who close their opening PHP tags. :) I roll my own, partially from classes I wrote and partially from classes at phpclasses.org and partially from neat stuff I find on the web. Not sure you could call it framework though, just a loose collection of independent classes. Just spent a couple days bringing that loose collection together along with CSS templates from http://www.freecsstemplates.org/ and now actually have my own (not quite finished) CMS. And it looks / works a hell of a lot better than anything I've done before (er, other than it not quite being finished ...) Making my classes work together specifically to make a generic CMS exposed a lot of bugs and poor design decisions in them that are now largely fixes (er, well, we'll see ...) Last few days have been like an epiphany for me. -- 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] Good source for sample data?
The US Census Bureau has lists of first names and surnames online with a breakdown of their frequency within the US population. It was very simple to extract just the names into arrays. We found it quite useful for generating database records for testing. YMMV. Bob McConnell -Original Message- From: james stojan [mailto:james.sto...@gmail.com] Sent: Thursday, January 28, 2010 8:38 PM To: TG Cc: Brian Dunning; php-general@lists.php.net; my...@lists.mysql.com Subject: Re: [PHP] Good source for sample data? Fakenamegenerator.com is pretty good for these kinds of records, alot of variety and can change order/formating for them but they do limit free orders to 50k records. http://www.fakenamegenerator.com/order.php On Thu, Jan 28, 2010 at 8:06 PM, TG tg-...@gryffyndevelopment.com wrote: I remembered a coworker found an online resource that generated sample data for you. I hit google and I think I found it: http://www.generatedata.com/ I I found it on a list of resources for data generation: http://www.webresourcesdepot.com/test-sample-data-generators/ I've never used any of these, but once again.. Google is your friend. -TG - Original Message - From: Brian Dunning br...@briandunning.com To: php-general@lists.php.net, my...@lists.mysql.com Date: Thu, 28 Jan 2010 15:52:41 -0800 Subject: [PHP] Good source for sample data? Hey all - I need a few million sample contact records - name, company, address, email, web, phone, fax. ZIP codes and area codes and street addresses should be correct and properly formatted, but preferably not real people or companies or email addresses. But they'd work if you did address validation or mapping. Anyone have a suggestion? - Brian -- 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] Do you use a public framework or roll your own?
Michael A. Peters wrote: Michael A. Peters wrote: Daevid Vincent wrote: I'm not looking to start a holy war here or re-hash the tired debate. I just want some hard cold numbers to look at. Do you use a public framework or roll your own? http://www.rapidpoll.net/8opnt1e And for those interested, here are the results of the last poll: To add the final ? in PHP or not... http://www.rapidpoll.net/show.aspx?id=arc1opy I'm relieved to know I'm in the majority (almost 2:1) who close their opening PHP tags. :) I roll my own, partially from classes I wrote and partially from classes at phpclasses.org and partially from neat stuff I find on the web. Not sure you could call it framework though, just a loose collection of independent classes. Just spent a couple days bringing that loose collection together along with CSS templates from http://www.freecsstemplates.org/ and now actually have my own (not quite finished) CMS. And it looks / works a hell of a lot better than anything I've done before (er, other than it not quite being finished ...) Making my classes work together specifically to make a generic CMS exposed a lot of bugs and poor design decisions in them that are now largely fixes (er, well, we'll see ...) Last few days have been like an epiphany for me. great to hear; I've done this with pretty much every project for the last 5 years and in most cases I can apple it [1] - also find it beneficial to see coding styles over the years and refactor previous work - strangest thing is that as time goes on, the number of classes lines of code I need for each application seems to drop! [1] got a class for that -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating an Entire .html page with PHP
you can use Apache mod rewrite to create html pages having all programing saved in .php pages. I have never tried generating .html pages with this but have successfully generated .htm pages.. Hope this works.. On Tue, Jan 26, 2010 at 6:30 AM, deal...@gmail.com deal...@gmail.comwrote: Hi Folks, I would like to create an entire .html page gathered from database content mixed with html etc. and be able to save the page... like: --- save all this pre made content as .html page html head ... stuff /head body ... stuff ... stuff with database query results... ... stuff /body /html Q: Is there a function that might help with saving the whole content as .html page? Thanks, deal...@gmail.com [db-10] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://www.kingzones.org/
[PHP] RE: Good source for sample data?
If you need verifiable mailing addresses (actual street/city/state/zip combinations), you should look at some of the databases the USPS (usps.com) has available. They are mostly for tracking delivery statistics, and the like, but as a side effect they list streets all over the USA. The only thing you won't have are street numbers and names, but you can easily generate random combinations there. By the way, if you need real-sounding names you can get a pile of first names from http://www.socialsecurity.gov/OACT/babynames/decades/names2000s.html; I used that information as part of security screening for a registration system. Regards, Jerry Schwartz The Infoshop by Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 www.the-infoshop.com -Original Message- From: Shawn McKenzie [mailto:nos...@mckenzies.net] Sent: Thursday, January 28, 2010 7:20 PM To: Brian Dunning Cc: php-general@lists.php.net; my...@lists.mysql.com Subject: Re: Good source for sample data? Brian Dunning wrote: Hey all - I need a few million sample contact records - name, company, address, email, web, phone, fax. ZIP codes and area codes and street addresses should be correct and properly formatted, but preferably not real people or companies or email addresses. But they'd work if you did address validation or mapping. Anyone have a suggestion? - Brian It should be easy to code a routine to generate random data. Maybe 20 - 30 lines of code. Obviously you may have a name like Dgidfgq Xcvbop and company Wsdkn, but it shouldn't matter if testing is your purpose. -- Thanks! -Shawn http://www.spidean.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=jschwa...@the- infoshop.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating an Entire .html page with PHP
Ashley Sheridan wrote: On Fri, 2010-01-29 at 20:15 +0530, Raman . wrote: you can use Apache mod rewrite to create html pages having all programing saved in .php pages. I have never tried generating .html pages with this but have successfully generated .htm pages.. Hope this works.. On Tue, Jan 26, 2010 at 6:30 AM, deal...@gmail.com deal...@gmail.comwrote: Hi Folks, I would like to create an entire .html page gathered from database content mixed with html etc. and be able to save the page... like: --- save all this pre made content as .html page html head ... stuff /head body ... stuff ... stuff with database query results... ... stuff /body /html Q: Is there a function that might help with saving the whole content as .html page? Thanks, deal...@gmail.com [db-10] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You still have to create .php pages, mod_rewrite just masks what the user is requesting through their browser. You can set Apache to parse .html pages as PHP, but I wouldn't recommend it, as any html pages that don't contain PHP code still have to be parsed as if they did, which is slower. You can also do the following: AddType application/x-httpd-php .php .html .htm And then rewrite is unnecessary. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ideas please -- take query results --- output to image
other idea: iframes, and plain old links. On Fri, Jan 29, 2010 at 10:32 PM, Rene Veerman rene7...@gmail.com wrote: flash(develop.org) perhaps? or does that also fall under their no-active-x policy? On Fri, Jan 29, 2010 at 9:17 PM, Haig Davis level...@gmail.com wrote: Good Day All, The headscratcher of the day for me is as follows: I'm busy designing a scheduling page in a table form (actually series of floating css divs) showing days of week across/ rooms down. thats the easy part and bookings in each cell. I know I can take the results of a query call it expanded booking details start_ob output to html save to file/ image etc, that way on mouse over the date I can use CSS to explode the image file displaying the results. Here's my question. Any hints can I do all of this on the fly yet not display the HTML query results that are created until mouse over . I'm sure this is easy with javascript my problem is my client does has disabled javascript/ active X scripts. Been scratching my head for a while and it's starting to bleed. Thanks and have a great weekend. Cheers Haig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Good source for sample data?
Thanks for the suggestions but I couldn't find any that suited my needs, so I made my own. Feel free to download if you can use them, I made files with up to a million unique records. Name, Company, Address, Phone, Email, etc., all are fake but are real addresses with correct area codes, zips, exchange, so will work for mapping, phone or address validation, whatever your needs are. Hope someone find it useful. http://www.briandunning.com/sample-data/ On Jan 28, 2010, at 3:52 PM, Brian Dunning wrote: I need a few million sample contact records - name, company, address, email, web, phone, fax. ZIP codes and area codes and street addresses should be correct and properly formatted, but preferably not real people or companies or email addresses. But they'd work if you did address validation or mapping. Anyone have a suggestion? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] In need of PHP to JS collapsable array printing routine?
I'm wondering if anyone has a PHP debug-type routine that will take a PHP array and output it to the web page, but make all the dimensions of the array collapsable, ideally showing each sub-key (or index) as the name to click to expand it again. I'm dealing with some rather huge datasets in multi-dimensional hashes and printing them out with a beautified print_r() is just not cutting it anymore. I need to collapse them down to wrap my head around them. Some of them have 6 or more dimensions! I use jQuery for JS if that helps (in case your routine requires that too). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] In need of PHP to JS collapsable array printing routine?
Take a look at the Firebug addon for Firefox and another addon called FirePHP or FireConsole (the new name coming soon). It lets you output PHP debugging data to HTTP headers that show up in your Firebug console. I believe it supports collapsable tree type output. -TG - Original Message - From: Daevid Vincent dae...@daevid.com To: php-general@lists.php.net Date: Fri, 29 Jan 2010 15:54:33 -0800 Subject: [PHP] In need of PHP to JS collapsable array printing routine? I'm wondering if anyone has a PHP debug-type routine that will take a PHP array and output it to the web page, but make all the dimensions of the array collapsable, ideally showing each sub-key (or index) as the name to click to expand it again. I'm dealing with some rather huge datasets in multi-dimensional hashes and printing them out with a beautified print_r() is just not cutting it anymore. I need to collapse them down to wrap my head around them. Some of them have 6 or more dimensions! I use jQuery for JS if that helps (in case your routine requires that too). -- 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] how do I use php://memory?
Hello, I have a function that uses tidy to attempt to clean up a bunch of crappy HTML that I inherited. In order to use tidy, I write the crappy HTML to a temporary file on disk, run tidy, and extract and return the clean(er) HTML. The program itself works fine but with all of the disk access, it runs quite slowly. I saw on this page (http://www.php.net/manual/en/wrappers.php.php) that I could write to memory by using php://memory. Unfortunately, I could not quite get it to work. The problem is that in the below function, the code within the [[[if (file_exists($dirty_file_path))]]] does not get run if I change [[[$dirty_file_path]]] to php://memory. Has anyone ever successfully used php://memory before? If so, what can I do to use it in my code? Thank you. //== function cleanUpHtml($dirty_html, $enclose_text=true) { $parent_dir = /filesWrittenFromPHP/; $now = time(); $random = rand(); //save dirty html to a file so tidy can process it $dirty_file_path = $parent_dir . dirty . $now . - . $random . .txt; $dirty_handle = fopen($dirty_file_path, w); fwrite($dirty_handle, $dirty_html); fclose($dirty_handle); $cleaned_html = ; $start = 0; $end = 0; if (file_exists($dirty_file_path)) { exec(/usr/local/bin/tidy -miq -wrap 0 -asxhtml --doctype strict --preserve-entities yes --css-prefix \tidy\ --tidy-mark no --char-encoding utf8 --drop-proprietary-attributes yes --fix-uri yes . ($enclose_text ? --enclose-text yes : ) . $dirty_file_path . 2 /dev/null); $tidied_html = file_get_contents($dirty_file_path); $start = strpos($tidied_html, body) + 6; $end = strpos($tidied_html, /body) - 1; $cleaned_html = trim(substr($tidied_html, $start, ($end - $start))); } unlink($dirty_file_path); return $cleaned_html; } //== -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how do I use php://memory?
On Fri, Jan 29, 2010 at 5:35 PM, Mari Masuda mari.mas...@stanford.eduwrote: Hello, I have a function that uses tidy to attempt to clean up a bunch of crappy HTML that I inherited. In order to use tidy, I write the crappy HTML to a temporary file on disk, run tidy, and extract and return the clean(er) HTML. The program itself works fine but with all of the disk access, it runs quite slowly. why read from disk in the first place? http://us3.php.net/manual/en/tidy.parsestring.php -nathan
Re: [PHP] how do I use php://memory?
Op 1/30/10 1:35 AM, Mari Masuda schreef: Hello, I have a function that uses tidy to attempt to clean up a bunch of crappy HTML that I inherited. In order to use tidy, I write the crappy HTML to a temporary file on disk, run tidy, and extract and return the clean(er) HTML. The program itself works fine but with all of the disk access, it runs quite slowly. I saw on this page (http://www.php.net/manual/en/wrappers.php.php) that I could write to memory by using php://memory. Unfortunately, I could not quite get it to work. The problem is that in the below function, the code within the [[[if (file_exists($dirty_file_path))]]] does not get run if I change [[[$dirty_file_path]]] to php://memory. Has anyone ever successfully used php://memory before? If so, what can I do to use it in my code? Thank you. what does it matter that it runs slowly, run it once and be done with it? alternatively use the php tidy extension and avoid the file system and shelling out altogether. actually I'd imagine shelling out from a webserver process is the bottle neck and not saving/reading from the file system. lastly I don't suppose you've heard of /dev/shm ? and, er, no, I don't have experience with php://memory but you might try searching for other people's code: http://www.google.com/codesearch?q=php%3A%2F%2Fmemoryhl=enbtnG=Search+Code //== function cleanUpHtml($dirty_html, $enclose_text=true) { $parent_dir = /filesWrittenFromPHP/; $now = time(); $random = rand(); //save dirty html to a file so tidy can process it $dirty_file_path = $parent_dir . dirty . $now . - . $random . .txt; $dirty_handle = fopen($dirty_file_path, w); fwrite($dirty_handle, $dirty_html); fclose($dirty_handle); $cleaned_html = ; $start = 0; $end = 0; if (file_exists($dirty_file_path)) { exec(/usr/local/bin/tidy -miq -wrap 0 -asxhtml --doctype strict --preserve-entities yes --css-prefix \tidy\ --tidy-mark no --char-encoding utf8 --drop-proprietary-attributes yes --fix-uri yes . ($enclose_text ? --enclose-text yes : ) . $dirty_file_path . 2 /dev/null); $tidied_html = file_get_contents($dirty_file_path); $start = strpos($tidied_html, body) + 6; $end = strpos($tidied_html, /body) - 1; $cleaned_html = trim(substr($tidied_html, $start, ($end - $start))); } unlink($dirty_file_path); return $cleaned_html; } //== -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: how do I use php://memory?
Mari Masuda wrote: Has anyone ever successfully used php://memory before? If so, what can I do to use it in my code? Thank you. No, but I was intrigued to try it, so I tested this: $text = 'Some text.'; file_put_contents('php://memory', $text); echo file_get_contents('php://memory'); And it returned nothing. The docs suck on this and it apparently doesn't work. I see others use it with fopen(), but there is no mention of which file functions it works with and which it doesn't. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Ideas please -- take query results --- output to image
On Fri, 2010-01-29 at 22:33 +0100, Rene Veerman wrote: other idea: iframes, and plain old links. On Fri, Jan 29, 2010 at 10:32 PM, Rene Veerman rene7...@gmail.com wrote: flash(develop.org) perhaps? or does that also fall under their no-active-x policy? On Fri, Jan 29, 2010 at 9:17 PM, Haig Davis level...@gmail.com wrote: Good Day All, The headscratcher of the day for me is as follows: I'm busy designing a scheduling page in a table form (actually series of floating css divs) showing days of week across/ rooms down. thats the easy part and bookings in each cell. I know I can take the results of a query call it expanded booking details start_ob output to html save to file/ image etc, that way on mouse over the date I can use CSS to explode the image file displaying the results. Here's my question. Any hints can I do all of this on the fly yet not display the HTML query results that are created until mouse over . I'm sure this is easy with javascript my problem is my client does has disabled javascript/ active X scripts. Been scratching my head for a while and it's starting to bleed. Thanks and have a great weekend. Cheers Haig Quite easy to do with some CSS. a href=# class=details regular content div class=detailshidden until mouse overed/div /a And the CSS would be something like: a.details { position: relative; } a.details div.details { position: absolute; top: 0px; left: 0px; display: none; } a:hover div.details { display: block; } This is a simplified example, but works without Javascript, and if the browser doesn't support CSS, the hidden details are just displayed normally, which is the best fail method I think. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] In need of PHP to JS collapsable array printing routine?
On Fri, 2010-01-29 at 15:54 -0800, Daevid Vincent wrote: I'm wondering if anyone has a PHP debug-type routine that will take a PHP array and output it to the web page, but make all the dimensions of the array collapsable, ideally showing each sub-key (or index) as the name to click to expand it again. I'm dealing with some rather huge datasets in multi-dimensional hashes and printing them out with a beautified print_r() is just not cutting it anymore. I need to collapse them down to wrap my head around them. Some of them have 6 or more dimensions! I use jQuery for JS if that helps (in case your routine requires that too). I know it's not quite what you want, but what about copying and pasting the output from the view source to a more advanced text editor like Kate or Notepad++. They both support code-folding, and allow you to minimise blocks of code at points in the text, usually where you have opened brackets, etc. This also comes in handy when you're developing too. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Re: how do I use php://memory?
On Sat, Jan 30, 2010 at 9:00 AM, Shawn McKenzie nos...@mckenzies.netwrote: Mari Masuda wrote: Has anyone ever successfully used php://memory before? If so, what can I do to use it in my code? Thank you. No, but I was intrigued to try it, so I tested this: $text = 'Some text.'; file_put_contents('php://memory', $text); echo file_get_contents('php://memory'); And it returned nothing. The docs suck on this and it apparently doesn't work. I see others use it with fopen(), but there is no mention of which file functions it works with and which it doesn't. Shawn I did a sample test from the manual with fopen like this, ?php $fp = fopen('php://memory', 'r+'); if ($fp) { fputs($fp, line 1\n); } rewind($fp); echo stream_get_contents($fp); ? console output F:\wc\trunkphp -f m.php line 1 Regards, Eric, -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sessions across subdomains
Hi, I've always thought that session data was subdomain specific and would not carry over between http://www.mydomain.com and https://secure.mydomain.com, but it seems to be working for me now. Can I rely on this and post from http://www.mydomain.com to https://secure.mydomain.com and simply pass a hidden input containing PHPSESSID, or do I need to pass each key=value pair that _SESSION contains at www. and reset them as _SESSION vars at secure. https://secure.mydomain.com ? Thanks in advance, Ben
Re: [PHP] Creating an Entire .html page with PHP
On Thu, 28 Jan 2010 13:39:31 -0800, mpet...@mac.com (Michael A. Peters) wrote: clanc...@cybec.com.au wrote: On Thu, 28 Jan 2010 21:10:42 +0100, rene7...@gmail.com (Rene Veerman) wrote: On Thu, Jan 28, 2010 at 12:31 AM, clanc...@cybec.com.au wrote: On Wed, 27 Jan 2010 10:21:00 -0800, deal...@gmail.com (dealtek) wrote: Opening tables, etc, wrongly generally messes the page up completely, but forgetting to close them again often has no affect no visible effect at all -- until you make some innocent change and everything goes haywire! whenever i write an opening tag, i immediately write the closing tag next, then cursor back to fill it in. Not so easy when you are using PHP to generate a complex layout! Use DOMDocument. Then you don't have to worry about closing the tags ;) Ohhh? The index page of the manual has 110 lines of totally meaningless entries, and the introduction doesn't open. I haven't the faintest idea what it's all about, but I very much doubt if it would mean anything to the original writer. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating an Entire .html page with PHP
On Sat, 2010-01-30 at 12:34 +1100, clanc...@cybec.com.au wrote: On Thu, 28 Jan 2010 13:39:31 -0800, mpet...@mac.com (Michael A. Peters) wrote: clanc...@cybec.com.au wrote: On Thu, 28 Jan 2010 21:10:42 +0100, rene7...@gmail.com (Rene Veerman) wrote: On Thu, Jan 28, 2010 at 12:31 AM, clanc...@cybec.com.au wrote: On Wed, 27 Jan 2010 10:21:00 -0800, deal...@gmail.com (dealtek) wrote: Opening tables, etc, wrongly generally messes the page up completely, but forgetting to close them again often has no affect no visible effect at all -- until you make some innocent change and everything goes haywire! whenever i write an opening tag, i immediately write the closing tag next, then cursor back to fill it in. Not so easy when you are using PHP to generate a complex layout! Use DOMDocument. Then you don't have to worry about closing the tags ;) Ohhh? The index page of the manual has 110 lines of totally meaningless entries, and the introduction doesn't open. I haven't the faintest idea what it's all about, but I very much doubt if it would mean anything to the original writer. I've never used DomDoument to create an HTML page, and I probably never will. I also don't have much of a problem with creating decent html code that validates either. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Creating an Entire .html page with PHP
On Thu, 28 Jan 2010 16:23:05 -0500, pa...@quillandmouse.com (Paul M Foster) wrote: On Fri, Jan 29, 2010 at 08:17:34AM +1100, clanc...@cybec.com.au wrote: On Thu, 28 Jan 2010 21:10:42 +0100, rene7...@gmail.com (Rene Veerman) wrote: On Thu, Jan 28, 2010 at 12:31 AM, clanc...@cybec.com.au wrote: On Wed, 27 Jan 2010 10:21:00 -0800, deal...@gmail.com (dealtek) wrote: Opening tables, etc, wrongly generally messes the page up completely, but forgetting to close them again often has no affect no visible effect at all -- until you make some innocent change and everything goes haywire! whenever i write an opening tag, i immediately write the closing tag next, then cursor back to fill it in. Not so easy when you are using PHP to generate a complex layout! Use heredocs to do it. Then you can generate the layout in PHP and still do what deal...@gmail.com said. I don't think heredocs is relevant. The original writer wanted to save the HTML output of a working page to a file, whereas (I think!) heredocs are involved with getting messy stuff into PHP. I still think that simply capturing the page from the browser is the simplest solution for the original question, but if you want a more elegant one see: http://codeutopia.net/blog/2007/10/03/how-to-easily-redirect-php-output-to-a-file/ The writer appears to know what he's talking about, and I am pleased to have found this, as I have often wanted to to redirect PHP output to a file. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Pointers For Newbies, Reminders For Oldies
On Thu, 28 Jan 2010 10:02:56 -0500, rob...@interjinn.com (Robert Cummings) wrote: I don't know what you guys are doing wrong but the following should be the correct behaviour: ?php function get_memory( $init=false ) { static $base = null; if( $base === null || $init ) { $base = memory_get_usage(); } return memory_get_usage() - $base; } function simple_access( $data ) { $foo = $data[100]; echo 'Memory: '.get_memory().' (simple access)'.\n; } function foreach_value_access( $data ) { foreach( $data as $value ) { $foo = $value; break; } echo 'Memory: '.get_memory().' (foreach value access)'.\n; } function foreach_key_access( $data ) { foreach( $data as $key = $value ) { $foo = $key; $foo = $value; break; } echo 'Memory: '.get_memory().' (foreach key/value access)'.\n; } function modify_single_access( $data ) { $data[100] = str_repeat( '@', 1 ); echo 'Memory: '.get_memory().' (modify single access)'.\n; } function modify_all_access( $data ) { for( $i = 0; $i 1000; $i++ ) { $data[$i] = str_repeat( '@', 1 ); } echo 'Memory: '.get_memory().' (modify all access)'.\n; } get_memory( true ); $data = array(); for( $i = 0; $i 1000; $i++ ) { $data[$i] = str_repeat( '#', 1 ); } echo 'Memory: '.get_memory().' (data initialized)'.\n; simple_access( $data ); foreach_value_access( $data ); foreach_key_access( $data ); modify_single_access( $data ); modify_all_access( $data ); ? I get the following output (PHP 5.2.11 from command-line): Memory: 10160768 (data initialized) Memory: 10161008 (simple access) Memory: 10161104 (foreach value access) Memory: 10161240 (foreach key/value access) Memory: 10267312 (modify single access) Memory: 20321576 (modify all access) I don't double up on memory consumption until I force the write onto every element... this is expected because internally every array element is individually subject to the Copy-On-Write (COW) principle since each element is internally stored as a zval just like the array itself. Thanks for this. I was just revising a bit of code to insert some extra entries into an array. Previously I had opened a new array, copied the data up to the insertion point into it, put in the new entry, then copied the tail, then renamed the new array. After reading this, I realise the correct procedure was to copy the existing data into a temporary array, insert the new entry in the existing array, and then copy the tail from the copy back into the working data. This way only the data in the tail actually has to be copied, rather than the whole array. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions across subdomains
Op 1/30/10 2:25 AM, Ben Miller schreef: Hi, I've always thought that session data was subdomain specific and would not carry over between http://www.mydomain.com and https://secure.mydomain.com, but it seems to be working for me now. Can I rely on this and post from http://www.mydomain.com to https://secure.mydomain.com and simply pass a hidden input containing PHPSESSID, or do I need to pass each key=value pair that _SESSION contains at www. and reset them as _SESSION vars at secure. https://secure.mydomain.com ? 1. cookies are shared automatically on SUB domains, so if you set your cookie domain to example.com it will be available at both www.example.com and secure.example.com 2. cookies can have a HTTPS flag set which means they will not be shared with non-HTTPS connections. 3. DONT put the contents of $_SESSION on the wire. (given the question you're asking I'd hazard a guess you don't have the skills to sufficiently 4. google/read/search/learn about the security implications of sharing a cookie between HTTPS and non-HTTPS domains. 5. session_regenerate_id() - I would use this if you intend to pass session ids around, although it will probably give you a stack of problems in terms of usability (e.g. back button usage), actually I'd use it any time you log someone in or out or have a user perform a particularly sensitive action. 6. the $_SESSION will only be available on both sites if they are both on the same server and running with the same session ini settings (i.e. session save path, session name) - different servers could obviously be using a shared filesystem or an alternative session storage (e.g. memcached or database server). 7. consider not sharing the session - instead pass just the data that you need (e.g. shopping basket contents etc) and either including a hash of the data (which uses a secret string that is not included in the form/url/etc but that both servers/sites know about AND/OR using 2-way public key encryption on the data that you pass in between the servers/sites personally for higher end commercial sites I prefer to just to put everything on HTTPS solving all potential issues with sharing a cookie or data between nonHTTPS and HTTPS sites, and everything directly related ... the cost being extra overhead per request - but hardware is cheap and security is difficult to get exactly right. the biggest names on the web have [had] security loophopes/problems related to these issues, and they generally have tons of man power and some very clever/knowledgable people on their teams - which is to say: your chance (and mine for that matter) of not making any mistakes on this front are slimmer than theirs. Thanks in advance, Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] In need of PHP to JS collapsable array printing routine?
Op 1/30/10 12:54 AM, Daevid Vincent schreef: I'm wondering if anyone has a PHP debug-type routine that will take a PHP array and output it to the web page, but make all the dimensions of the array collapsable, ideally showing each sub-key (or index) as the name to click to expand it again. I'm dealing with some rather huge datasets in multi-dimensional hashes and printing them out with a beautified print_r() is just not cutting it anymore. I need to collapse them down to wrap my head around them. Some of them have 6 or more dimensions! I use jQuery for JS if that helps (in case your routine requires that too). what everyone else said ... additionally check out the recent archives for posts by Rene Veerman ... his current pet project seems to be something that would be of interest you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how do I use php://memory?
Eric Lee wrote: On Sat, Jan 30, 2010 at 9:00 AM, Shawn McKenzie nos...@mckenzies.netwrote: Mari Masuda wrote: Has anyone ever successfully used php://memory before? If so, what can I do to use it in my code? Thank you. No, but I was intrigued to try it, so I tested this: $text = 'Some text.'; file_put_contents('php://memory', $text); echo file_get_contents('php://memory'); And it returned nothing. The docs suck on this and it apparently doesn't work. I see others use it with fopen(), but there is no mention of which file functions it works with and which it doesn't. Shawn I did a sample test from the manual with fopen like this, ?php $fp = fopen('php://memory', 'r+'); if ($fp) { fputs($fp, line 1\n); } rewind($fp); echo stream_get_contents($fp); ? console output F:\wc\trunkphp -f m.php line 1 Regards, Eric, So maybe it only works with an open file/stream resource? Hard to tell with no docs. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: how do I use php://memory?
(Typing from the DROID, so forgive the top-posting.) Shawn, would you take a few moments to submit this as a bug at http://bugs.php.net/? I know you well enough that, if you say the docs suck, they probably do. On Jan 29, 2010 10:47 PM, Shawn McKenzie nos...@mckenzies.net wrote: Eric Lee wrote: On Sat, Jan 30, 2010 at 9:00 AM, Shawn McKenzie nos...@mckenzies.net wrote: ... So maybe it only works with an open file/stream resource? Hard to tell with no docs. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubsc...
Re: [PHP] how do I use php://memory?
On Jan 29, 2010, at 4:38 PM, Nathan Nobbe wrote: On Fri, Jan 29, 2010 at 5:35 PM, Mari Masuda mari.mas...@stanford.edu wrote: Hello, I have a function that uses tidy to attempt to clean up a bunch of crappy HTML that I inherited. In order to use tidy, I write the crappy HTML to a temporary file on disk, run tidy, and extract and return the clean(er) HTML. The program itself works fine but with all of the disk access, it runs quite slowly. why read from disk in the first place? http://us3.php.net/manual/en/tidy.parsestring.php -nathan Thank you, this looks like exactly what I need. Unfortunately I cannot get it to work on my machine. I recompiled PHP with --with-tidy=/usr/local and this is the version and modules in use: [Fri Jan 29 22:50:41] ~: php -vPHP 5.2.12 (cli) (built: Jan 29 2010 22:35:24) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies [Fri Jan 29 22:52:30] ~: php -m [PHP Modules] ctype date dom filter gd hash iconv json libxml mbstring mysql mysqli pcre PDO pdo_mysql pdo_sqlite posix Reflection session SimpleXML SPL SQLite standard tidy tokenizer xml xmlreader xmlwriter zlib [Zend Modules] [Fri Jan 29 22:52:34] ~: When I run this test code = ?php $html = htmlheadtitleblah/title/headbodyphello/p/body/html; $config = array('indent' = true, 'wrap' = '0'); // Tidy $tidy = new tidy(); var_dump($tidy); $tidy-parseString($html, $config, 'utf8'); var_dump($tidy); $tidy-cleanRepair(); var_dump($tidy); echo tidy_get_output($tidy); var_dump($tidy); ? = I get this output: = object(tidy)#1 (2) { [errorBuffer]= NULL [value]= NULL } object(tidy)#1 (2) { [errorBuffer]= NULL [value]= NULL } object(tidy)#1 (2) { [errorBuffer]= NULL [value]= NULL } object(tidy)#1 (2) { [errorBuffer]= NULL [value]= NULL } I have no clue what I'm doing wrong... Mari -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] how do I use php://memory?
On Jan 29, 2010, at 10:57 PM, Mari Masuda wrote: On Jan 29, 2010, at 4:38 PM, Nathan Nobbe wrote: On Fri, Jan 29, 2010 at 5:35 PM, Mari Masuda mari.mas...@stanford.edu wrote: Hello, I have a function that uses tidy to attempt to clean up a bunch of crappy HTML that I inherited. In order to use tidy, I write the crappy HTML to a temporary file on disk, run tidy, and extract and return the clean(er) HTML. The program itself works fine but with all of the disk access, it runs quite slowly. why read from disk in the first place? http://us3.php.net/manual/en/tidy.parsestring.php -nathan Thank you, this looks like exactly what I need. Unfortunately I cannot get it to work on my machine. [snip] So I figured it out... I was using the wrong command to compile libtidy. (I am not a *nix geek so I had no idea I was messing it up.) To get it working, I followed the instructions I found here: http://www.php.net/manual/en/ref.tidy.php#64281 My setup is slightly different from the person who wrote the directions in that I am running OS X 10.6.2 and PHP 5.2.12. However, the only difference between the instructions I followed and what I actually had to do is that the line to comment out for me was line 525 instead of 508. (The actual line is: typedef unsigned long ulong;) Thank you everyone for your help! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php