php-general Digest 6 Jan 2010 14:46:27 -0000 Issue 6524
php-general Digest 6 Jan 2010 14:46:27 - Issue 6524 Topics (messages 300840 through 300849): Re: How to get a string from C library into PHP via SWIG? 300840 by: Nathan Nobbe 300841 by: Eric Fowler pass by reference variable length args 300842 by: viraj 300843 by: Robert Cummings 300844 by: viraj 300845 by: viraj 300846 by: Robert Cummings After editing only the httpd.conf PHP 5.2.12 works in Apache2.2 on WindowsXP Professional 2002 SP 3, Can this be? 300847 by: Varuna Seneviratna 300848 by: Jim Lucas Re: Open source project management tool - PHP 300849 by: Angelo Zanetti 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--- On Tue, Jan 5, 2010 at 4:38 PM, Eric Fowler eric.fow...@gmail.com wrote: A little more information: my crashes all relate to handling the char datatype. Floats and ints are happy. I suspect that a char type in PHP is not the same as a char type in C. But I am not sure at all. More recently I have used cmalloc.i to allocate arrays of chars and floats. The floats are happy, the chars crash upon allocation. neat, swig generates php extensions. i wonder Eric, how much functionality you intend to expose to php, a series of functions, classes? from the sounds of your earlier description i would imagine maybe one class or a single set of functions to operate on a single string variable, with additional parameters for metadata. im curious, if youre sold on the generator, or if youre interested to just try your hand writing an extension. if youre strong w/ C you could probly crank it out quickly. another option would be to version the generated (swig) C, and repair it by hand, putting those changes in a branch. during subsequent generations, you could merge the work from said branch and iterate on that. of course the other option is to figure out swig, lol. anyways, is this C of yours for a private project or is it something i could take a peak at; im halfway curious what youre working w/. o, and guess what, reading through the swig php page, i discovered you can write php extensions 'in c++', by creating a thin C wrapper - wow, i had never thought of that, lol. -nathan ---End Message--- ---BeginMessage--- I will expose only one function, prototyped like the foo() example I described. cstring.i is not implemented for a PHP target (wah). I think I will go the shell approach. I have enough time in this already. Eric On Tue, Jan 5, 2010 at 6:26 PM, Nathan Nobbe quickshif...@gmail.com wrote: On Tue, Jan 5, 2010 at 4:38 PM, Eric Fowler eric.fow...@gmail.com wrote: A little more information: my crashes all relate to handling the char datatype. Floats and ints are happy. I suspect that a char type in PHP is not the same as a char type in C. But I am not sure at all. More recently I have used cmalloc.i to allocate arrays of chars and floats. The floats are happy, the chars crash upon allocation. neat, swig generates php extensions. i wonder Eric, how much functionality you intend to expose to php, a series of functions, classes? from the sounds of your earlier description i would imagine maybe one class or a single set of functions to operate on a single string variable, with additional parameters for metadata. im curious, if youre sold on the generator, or if youre interested to just try your hand writing an extension. if youre strong w/ C you could probly crank it out quickly. another option would be to version the generated (swig) C, and repair it by hand, putting those changes in a branch. during subsequent generations, you could merge the work from said branch and iterate on that. of course the other option is to figure out swig, lol. anyways, is this C of yours for a private project or is it something i could take a peak at; im halfway curious what youre working w/. o, and guess what, reading through the swig php page, i discovered you can write php extensions 'in c++', by creating a thin C wrapper - wow, i had never thought of that, lol. -nathan ---End Message--- ---BeginMessage--- hi all, i'm trying to write a wrapper function for mysqli_stmt_bind_results. and expect it to work the same way it accepts and bind results to the original function. the problem is, i couldn't find a way to pass the args by reference via func_get_args and register the out put from call_user_func_array to the caller scope.. any idea? here goes few lines which i'm trying hard for past 48 hours.. with no luck.. :( class stmt { private $stmt; public function bind_result() { $argsToBindResult = func_get_args(); $argList =
php-general Digest 7 Jan 2010 03:09:18 -0000 Issue 6525
php-general Digest 7 Jan 2010 03:09:18 - Issue 6525 Topics (messages 300850 through 300863): Re: Open source project management tool - PHP 300850 by: Andrew Williams 300853 by: Robert Cummings SVG Won't Color? 300851 by: Alice Wei 300852 by: Ashley Sheridan How to POST JSON data via PHP? 300854 by: Rob Gould 300855 by: shiplu First time PHP user question 300856 by: Rick Dwyer PHP programming strategy; lots of little include files, or a few big ones? 300857 by: clancy_1.cybec.com.au 300858 by: Robert Cummings 300859 by: Al SVG and PHP 300860 by: Bob Strasser 300861 by: Bob Strasser 300862 by: Bob Strasser Site Moved From PHP4 to PHP5 Server - header, location no longer working 300863 by: Vernon Webb 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--- What could be a php potential problem with contact forms that are only protected against SQL injections and have an admin side view for the enquiry? ---End Message--- ---BeginMessage--- Angelo Zanetti wrote: Thanks all, for the responses and advice. After much research and trying out we decided to go with: http://www.fengoffice.com/ its PHP based and also uses the EXTJS library. Its got quite a lot of features (calendar, tasks, email, notes, documents, reporting) etc... with a great AJAX interface and good functionality. I'm using it within a government context and they're really enjoying it. I had a to make a few coding adjustments to facilitate a language switcher between English and French as is normal in a Canadian context. Additionally, due to the lack of folder hierarchy for documents (they rely on the tagging system which is inefficient for our document management) we are abusing the workspace system to provide the folder hierarchy. This necessitated a hack to prevent the aggregated view of all documents within sub-workspaces at parent workspace levels. If you're using 1.5 btw, you should update to 1.6 ASAP since it corrects some issues with inherited group permissions. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ---End Message--- ---BeginMessage--- Hi, I have the code as in the following, and I am trying to colorize the map. The SVG File is located here: http://upload.wikimedia.org/wikipedia/commons/5/5f/USA_Counties_with_FIPS_and_names.svg. Looks like when I tried to modify the contents of the line, it does not seem to take into affect. Thus, my map does not get colorized. Do I have to save the file here? Or, is there something else I have missed here? ?php //We are outputting an SVG header(Content-type: image/svg+xml); $array= array(); $array2= array(); $array3= array(); $array4= array(); #Map Colors $colors_array= array(#F1EEF6,#D4B9DA,#C994C7,#DF65B0,#DD1C77,#980043); $file = file(unemployment09.csv); foreach ($file as $line) { $chars = preg_split(/,/, $line); $unemployment_rate = $chars[12]; array_push($array,$unemployment_rate); } //Calculate the number of elements in array $total_num = count($array); #Load the Map $ourFileName= USA_Counties_with_FIPS_and_names.svg; $fh = fopen($ourFileName, r) or die(Can't open file); $contents = fread($fh,filesize($ourFileName)); $lines2= file($ourFileName); #Color the counties based on unemployment rate for ($i=0;$i$total_num;$i++){ switch($array[$i]){ case ($array[$i] 10): $color = 5; break; case ($array[$i] 8): $color = 4; break; case ($array[$i] 6): $color = 3; break; case ($array[$i] 4): $color = 2; break; case ($array[$i] 2): $color = 1; break; default: $color= 0; break; } $color_class= $colors_array[$color]; array_push($array4,$color_class); } foreach ($lines2 as $line_num = $line2) { $line_add_one = $line_num + 1; if(preg_match(/path/,$line2)) { $rest = substr($lines2[$line_add_one],0,-3); $colors_style = ;color: . $array4[$line_add_one]; $rest = $rest . $colors_style . \; } array_push($array3,$lines2[$line_add_one]); } echo $contents; fclose($fh); ? Thanks for your help. Alice _ Hotmail: Trusted email with Microsoft’s powerful SPAM protection. http://clk.atdmt.com/GBL/go/196390706/direct/01/---End Message--- ---BeginMessage--- On Wed, 2010-01-06 at 11:27 -0500, Alice Wei wrote: Hi, I have the code as in the following, and I am trying to colorize the map. The SVG File is located here:
RE: [PHP] Open source project management tool - PHP
Thanks all, for the responses and advice. After much research and trying out we decided to go with: http://www.fengoffice.com/ its PHP based and also uses the EXTJS library. Its got quite a lot of features (calendar, tasks, email, notes, documents, reporting) etc... with a great AJAX interface and good functionality. Regards Angelo http://www.wapit.co.za http://www.elemental.co.za -Original Message- From: Gaurav Kumar [mailto:kumargauravjuke...@gmail.com] Sent: 18 December 2009 10:34 AM To: Robert Cummings Cc: Angelo Zanetti; php-general@lists.php.net Subject: Re: [PHP] Open source project management tool - PHP OK one more the list http://dotproject.net/ Its a nice one with all project management features. Easy to use. Just checkout the website. Gaurav Kumar blog.oswebstudio.com On Fri, Dec 18, 2009 at 12:16 AM, Robert Cummings rob...@interjinn.comwrote: Angelo Zanetti wrote: Hi guys I would like to know what open source project management tools you use for your projects. We are looking at installing one that is PHP based and is easy to use. We have found: http://www.projectpier.org/ and http://trac.edgewall.org/ Has anyone used the above and how did you find them? Also are there any others you would recommend or not recommend and why? I use Mantis for most bug tracking needs. However, I've recently rolled out OpenGoo for a couple of different clients. http://fengoffice.com/web/community/community_index.php 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Open source project management tool - PHP
What could be a php potential problem with contact forms that are only protected against SQL injections and have an admin side view for the enquiry?
[PHP] PHP programming strategy; lots of little include files, or a few big ones?
I have a flexible program, which can do many different things according to the type of data it is fed. Ideally the flexibility is achieved by calling different functions, though when the functionality is ill-defined I sometimes just include blocks of code. Ideally, from the point of program maintenance, each module should not be too long -- preferably just a page or so. This doesn't raise problems in a compiled language, but in an interpreted language like PHP the programmer must decide whether to lump a whole lot of functions into a single large include file, or to include lots of little files as the particular functions are needed. The first case can lead to memory bloat, as there are likely to be a lot of unused functions in memory on any given pass, whereas the second case may require lots of little files to be loaded. Are there likely to be significant performance costs for either approach, and what are your feelings about the relative virtues of the two approaches? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP programming strategy; lots of little include files, or a few big ones?
clanc...@cybec.com.au wrote: I have a flexible program, which can do many different things according to the type of data it is fed. Ideally the flexibility is achieved by calling different functions, though when the functionality is ill-defined I sometimes just include blocks of code. Ideally, from the point of program maintenance, each module should not be too long -- preferably just a page or so. This doesn't raise problems in a compiled language, but in an interpreted language like PHP the programmer must decide whether to lump a whole lot of functions into a single large include file, or to include lots of little files as the particular functions are needed. The first case can lead to memory bloat, as there are likely to be a lot of unused functions in memory on any given pass, whereas the second case may require lots of little files to be loaded. Are there likely to be significant performance costs for either approach, and what are your feelings about the relative virtues of the two approaches? Use a bytecode cache and stop worrying. 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
[PHP] Re: PHP programming strategy; lots of little include files, or a few big ones?
On 1/6/2010 7:18 PM, clanc...@cybec.com.au wrote: I have a flexible program, which can do many different things according to the type of data it is fed. Ideally the flexibility is achieved by calling different functions, though when the functionality is ill-defined I sometimes just include blocks of code. Ideally, from the point of program maintenance, each module should not be too long -- preferably just a page or so. This doesn't raise problems in a compiled language, but in an interpreted language like PHP the programmer must decide whether to lump a whole lot of functions into a single large include file, or to include lots of little files as the particular functions are needed. The first case can lead to memory bloat, as there are likely to be a lot of unused functions in memory on any given pass, whereas the second case may require lots of little files to be loaded. Are there likely to be significant performance costs for either approach, and what are your feelings about the relative virtues of the two approaches? It is highly unlikely you are going to create any significant memory bloat. Your code will likely be infinitesimal compared PHP's memory requirement. I suggest 3 files, one with your configuration settings, so they are all in one place and easy to find and change, another file with your functions and the third file contains the code for handling the internet interface. Obviously, the interface file controls everything by calling various functions as needed. Al... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SVG and PHP
Hi, Just went online and saw an SVG generated from Python, and wanted to do the similar thing by loading the SVG into an PHP script. Here is the script that I have: ?php #Load the Map $ourFileName= USA_Counties_with_FIPS_and_names.svg; $fh = fopen($ourFileName, r) or die(Can't open file); fclose($fh); ? The problem is that my screen appears as blank even though I could open up USA_Counties_with_FIPS_and_names.svg and see the entire US Map. Does anyone know what I might have done wrong here? Thanks in advance. Alice _ Hotmail: Trusted email with Microsofts powerful SPAM protection. http://clk.atdmt.com/GBL/go/177141664/direct/01/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SVG and PHP
Hi, Just went online and saw an SVG generated from Python, and wanted to do the similar thing by loading the SVG into an PHP script. Here is the script that I have: ?php #Load the Map $ourFileName= USA_Counties_with_FIPS_and_names.svg; $fh = fopen($ourFileName, r) or die(Can't open file); fclose($fh); ? The problem is that my screen appears as blank even though I could open up USA_Counties_with_FIPS_and_names.svg and see the entire US Map. Does anyone know what I might have done wrong here? Thanks in advance. Alice _ Hotmail: Trusted email with Microsofts powerful SPAM protection. http://clk.atdmt.com/GBL/go/177141664/direct/01/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] SVG and PHP
Hi, Just went online and saw an SVG generated from Python, and wanted to do the similar thing by loading the SVG into an PHP script. Here is the script that I have: ?php #Load the Map $ourFileName= USA_Counties_with_FIPS_and_names.svg; $fh = fopen($ourFileName, r) or die(Can't open file); fclose($fh); ? The problem is that my screen appears as blank even though I could open up USA_Counties_with_FIPS_and_names.svg and see the entire US Map. Does anyone know what I might have done wrong here? Thanks in advance. Alice _ Hotmail: Trusted email with Microsofts powerful SPAM protection. http://clk.atdmt.com/GBL/go/177141664/direct/01/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Site Moved From PHP4 to PHP5 Server - header, location no longer working
I move a number of sites from one server to another and one the one server we had php4 and now we have php5 and since then my server seems to hang every time there is a header, location redirect. Anyone have any ideas on how to resolve this? Is there something I can easily change in the php.ini file that will resolve this issue? Thanks ~V
RE: [PHP] Re: PHP programming strategy; lots of little include files, or a few big ones?
-Original Message- From: Al [mailto:n...@ridersite.org] Sent: Wednesday, January 06, 2010 5:09 PM To: php-general@lists.php.net Subject: [PHP] Re: PHP programming strategy; lots of little include files, or a few big ones? On 1/6/2010 7:18 PM, clanc...@cybec.com.au wrote: I have a flexible program, which can do many different things according to the type of data it is fed. Ideally the flexibility is achieved by calling different functions, though when the functionality is ill-defined I sometimes just include blocks of code. Ideally, from the point of program maintenance, each module should not be too long -- preferably just a page or so. This doesn't raise problems in a compiled language, but in an interpreted language like PHP the programmer must decide whether to lump a whole lot of functions into a single large include file, or to include lots of little files as the particular functions are needed. The first case can lead to memory bloat, as there are likely to be a lot of unused functions in memory on any given pass, whereas the second case may require lots of little files to be loaded. Are there likely to be significant performance costs for either approach, and what are your feelings about the relative virtues of the two approaches? I think it's a case by case basis. Generally File I/O is expensive, but then again, as you say, having everything in a couple files is also sub-optimal for organizing and keeping things modular. I suggest you go with smaller files that are organized into logical 'chunks'. For example, functions that are used frequently are grouped into a common.inc.php rather than by topic (such as file/date/xml/forms/etc). And then use topical includes for the rest. More importantly, I suggest you get a good caching system like memecached or any of the others out there. Then you can pre-compile and load these files and the whole point becomes close to moot. ÐÆ5ÏÐ http://daevid.com Some people, when confronted with a problem, think 'I know, I'll use XML.' Now they have two problems. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP programming strategy; lots of little include files, or a few big ones?
Daevid Vincent wrote: -Original Message- From: Al [mailto:n...@ridersite.org] Sent: Wednesday, January 06, 2010 5:09 PM To: php-general@lists.php.net Subject: [PHP] Re: PHP programming strategy; lots of little include files, or a few big ones? On 1/6/2010 7:18 PM, clanc...@cybec.com.au wrote: I have a flexible program, which can do many different things according to the type of data it is fed. Ideally the flexibility is achieved by calling different functions, though when the functionality is ill-defined I sometimes just include blocks of code. Ideally, from the point of program maintenance, each module should not be too long -- preferably just a page or so. This doesn't raise problems in a compiled language, but in an interpreted language like PHP the programmer must decide whether to lump a whole lot of functions into a single large include file, or to include lots of little files as the particular functions are needed. The first case can lead to memory bloat, as there are likely to be a lot of unused functions in memory on any given pass, whereas the second case may require lots of little files to be loaded. Are there likely to be significant performance costs for either approach, and what are your feelings about the relative virtues of the two approaches? I think it's a case by case basis. Generally File I/O is expensive, but then again, as you say, having everything in a couple files is also sub-optimal for organizing and keeping things modular. I suggest you go with smaller files that are organized into logical 'chunks'. For example, functions that are used frequently are grouped into a common.inc.php rather than by topic (such as file/date/xml/forms/etc). And then use topical includes for the rest. More importantly, I suggest you get a good caching system like memecached or any of the others out there. Then you can pre-compile and load these files and the whole point becomes close to moot. ÐÆ5ÏÐ http://daevid.com Some people, when confronted with a problem, think 'I know, I'll use XML.' Now they have two problems. I had a similar issue but with classes (not functions). I opted to keep my classes short and succinct, rather than shoving all the method functionality into one all-purpose class. Instead of blindly loading all the little classes on each http request, I used (and was recommended on this list to use) __autoload(). The script would only load my classes if the individual request needed it. This helped to avoid the memory bloat. I've heard magic functions like __autoload are a bit slower, but the code is so much cleaner b/c of it. Also, an opcode cache as suggested previously would facilitate the rapid include of many small files. Unfortunately, php does not offer an __autoload() type function to autoload functions. If you are able to encapsulate your functions functionality into classes you may be able to use the above solution of using an opcode cache to help __autoload() a bunch of small classes. hth, dK ` -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP programming strategy; lots of little include files, or a few big ones?
Daniel Kolbo wrote: Daevid Vincent wrote: -Original Message- From: Al [mailto:n...@ridersite.org] Sent: Wednesday, January 06, 2010 5:09 PM To: php-general@lists.php.net Subject: [PHP] Re: PHP programming strategy; lots of little include files, or a few big ones? On 1/6/2010 7:18 PM, clanc...@cybec.com.au wrote: I have a flexible program, which can do many different things according to the type of data it is fed. Ideally the flexibility is achieved by calling different functions, though when the functionality is ill-defined I sometimes just include blocks of code. Ideally, from the point of program maintenance, each module should not be too long -- preferably just a page or so. This doesn't raise problems in a compiled language, but in an interpreted language like PHP the programmer must decide whether to lump a whole lot of functions into a single large include file, or to include lots of little files as the particular functions are needed. The first case can lead to memory bloat, as there are likely to be a lot of unused functions in memory on any given pass, whereas the second case may require lots of little files to be loaded. Are there likely to be significant performance costs for either approach, and what are your feelings about the relative virtues of the two approaches? I think it's a case by case basis. Generally File I/O is expensive, but then again, as you say, having everything in a couple files is also sub-optimal for organizing and keeping things modular. I suggest you go with smaller files that are organized into logical 'chunks'. For example, functions that are used frequently are grouped into a common.inc.php rather than by topic (such as file/date/xml/forms/etc). And then use topical includes for the rest. More importantly, I suggest you get a good caching system like memecached or any of the others out there. Then you can pre-compile and load these files and the whole point becomes close to moot. ÐÆ5ÏÐ http://daevid.com Some people, when confronted with a problem, think 'I know, I'll use XML.' Now they have two problems. I had a similar issue but with classes (not functions). I opted to keep my classes short and succinct, rather than shoving all the method functionality into one all-purpose class. Instead of blindly loading all the little classes on each http request, I used (and was recommended on this list to use) __autoload(). The script would only load my classes if the individual request needed it. This helped to avoid the memory bloat. I've heard magic functions like __autoload are a bit slower, but the code is so much cleaner b/c of it. Also, an opcode cache as suggested previously would facilitate the rapid include of many small files. They'll mostly likely already be loaded and compiled in memory. The filesystem probably won't even get hit. 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] Site Moved From PHP4 to PHP5 Server - header, location no longer working
On Thu, Jan 7, 2010 at 1:35 PM, Vernon Webb ver...@comp-wiz.com wrote: I move a number of sites from one server to another and one the one server we had php4 and now we have php5 and since then my server seems to hang every time there is a header, location redirect. Anyone have any ideas on how to resolve this? Is there something I can easily change in the php.ini file that will resolve this issue? Off the top of my head it sounds like something is being output before the header, which causes an error. If you also have error display turned off, you will likely just see a white screen with no useful information. Make sure none of your includes have trailing whitespace or are trying to print out information before the header itself. Best bet is to turn on errors and log them, then you will see where the output started if infact that is your issue. Cheers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Resin/Quercus
Hi, I wonder if anyone has experience with running PHP on the Resin server. Opinions, good, bad? Gotchas? Similar projects? http://www.caucho.com/projects/resin/ Thanks, Mattias -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php