[PHP] svg 2 gif/png
I'm moving all of my dynamic image generation to svg. Not only does it look better, but it is less resource intensive on my server allowing me to generate the svg on demand instead of pre-generating (via cron) twice a month like I had to do with gd dynamic generation. However, some browsers *cough*IE*cough* do not support SVG, so I still need png or gif fallback (I'll decide which after investigating size difference). Example SVG to convert - http://www.shastaherps.org/map/map22.svg Using convert from ImageMagick in the CLI is fast enough that I may just use the ImageMagick php module and do the fallback dynamic for the IE users, but I've run into a bit of a snag - it seems that ImageMagick doesn't understand xlink. IE running convert --size=800x574 map22.svg map22.png on above file results in a nice pretty map with the county and text, but the colored hexagons are not displayed. Is there an easy way around this? IE a php class/function that understands SVG w/ xlink and can replace the use tags with the polygons they refer to? If not, I'll have to try to write one, but I'd rather not ... Thanks for suggestions. It is too bad ImageMagick doesn't understand the use tag and xlink, that is one of the more useful features of SVG that I have personally found, makes dynamic generation so much easier. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] svg 2 gif/png
Michael A. Peters wrote: *snip* Is there an easy way around this? IE a php class/function that understands SVG w/ xlink and can replace the use tags with the polygons they refer to? If not, I'll have to try to write one, but I'd rather not ... I just did, haven't tested yet, but this may work - function use2polygon($use,$polygon) { // get the xy coords $x = 0; $y = 0; if ($use->hasAttribute('x') { $x = 0 + $use->getAttribute('x'); } if ($use->hasAttribute('y') { $y = 0 + $use->getAttribute('y'); } // clone the polygon if ($polygon->hasAttribute('points') { $points = preg_replace('/\s+/',' ',$polygon->getAttribute('points')); $pointArray = explode(' ',$points); $sizeof = sizeof($pointArray); for ($i=0;$i<$sizeof;$i++) { $foo = explode(',',$pointArray[$i]); $foo[0] = $x + $foo[0]; $foo[1] = $y + $foo[1]; $pointArray[$i] = $foo[0] . ',' . $foo[1]; } $points = implode(' ',$points); $newPolygon = $polygon->cloneNode(true); $newPolygon->setAttribute('points',$points); $use->parentNode->replaceChild($newPolygon,$use); } } of course that requires domdocument and probably requires looping through the dom node list backwards, but hopefully that will do it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] session.entropy_file and hostname
On Wed, Mar 3, 2010 at 07:28, Sascha Wojewsky wrote: > thank you for your answer, > >> If you want server-unique session ids, use session_name() before >> session_start()..? > > i cannot use session_name, because i've to regenarete a session id by > permanent login. > i'm using session_regenerate_id, and session_name doesen't works with it (?) It should work fine. You must change the session name (either using the session_name() function or by changing session.name in php.ini) before you call session_start(). Note that the session name and the session ID are two different things. -- Daniel Egeberg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] svg 2 gif/png
Michael A. Peters wrote: Michael A. Peters wrote: *snip* Is there an easy way around this? IE a php class/function that understands SVG w/ xlink and can replace the use tags with the polygons they refer to? If not, I'll have to try to write one, but I'd rather not ... I just did, haven't tested yet, but this may work - This does work (fixed version of function): function use2polygon($use,$polygon) { // get the xy coords $x = 0; $y = 0; if ($use->hasAttribute('x')) { $x = 0 + $use->getAttribute('x'); } if ($use->hasAttribute('y')) { $y = 0 + $use->getAttribute('y'); } // clone the polygon if ($polygon->hasAttribute('points')) { $points = preg_replace('/\s+/',' ',$polygon->getAttribute('points')); $pointArray = explode(' ',$points); $sizeof = sizeof($pointArray); for ($i=0;$i<$sizeof;$i++) { $foo = explode(',',$pointArray[$i]); $foo[0] = $x + $foo[0]; $foo[1] = $y + $foo[1]; $pointArray[$i] = $foo[0] . ',' . $foo[1]; } $points = implode(' ',$pointArray); $newPolygon = $polygon->cloneNode(true); $newPolygon->setAttribute('points',$points); $use->parentNode->replaceChild($newPolygon,$use); } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Memory investigation
ON Linux I have kcacheGrind setup with Xdebug and I find it is a nice little thing to have. It won't tell you the memory consumed but it will find cycles and display object maps. if you have Kcachegrind it is likely you have valgrind installed. http://www2.mandriva.com/ http://valgrind.org/ http://kcachegrind.sourceforge.net/html/Home.html http://xdebug.org/ Larry Garfield wrote: Hi folks. I have a complicated PHP app that is eating up more memory than I think it should. I have a couple of theories as to where it could be going, but I need some way to verify it. There are a number of large data structures (mostly arrays) that get built up throughout the course of the request. What I'd like to be able to do is at certain points check to see how much memory those data structures are using. Because they're not all built at once, the usual "check memory before, build, check after" routine won't work. Plus, that gets screwed up by PHP's use of copy-on-write at times. I know that it would result in essentially over-reporting, but I would ideally like to be able to ignore the copy-on-write issue and say "if this variable were the only thing in memory (and its dependents, of course, for a nested array), what would its memory usage be? I just have no idea how to do that. Anyone have a suggestion for how to accomplish that? --Larry Garfield -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] svg 2 gif/png
Michael A. Peters wrote: Michael A. Peters wrote: Michael A. Peters wrote: *snip* Is there an easy way around this? IE a php class/function that understands SVG w/ xlink and can replace the use tags with the polygons they refer to? If not, I'll have to try to write one, but I'd rather not ... I just did, haven't tested yet, but this may work - This does work (fixed version of function): function use2polygon($use,$polygon) { // get the xy coords $x = 0; $y = 0; if ($use->hasAttribute('x')) { $x = 0 + $use->getAttribute('x'); } if ($use->hasAttribute('y')) { $y = 0 + $use->getAttribute('y'); } // clone the polygon if ($polygon->hasAttribute('points')) { $points = preg_replace('/\s+/',' ',$polygon->getAttribute('points')); $pointArray = explode(' ',$points); $sizeof = sizeof($pointArray); for ($i=0;$i<$sizeof;$i++) { $foo = explode(',',$pointArray[$i]); $foo[0] = $x + $foo[0]; $foo[1] = $y + $foo[1]; $pointArray[$i] = $foo[0] . ',' . $foo[1]; } $points = implode(' ',$pointArray); $newPolygon = $polygon->cloneNode(true); $newPolygon->setAttribute('points',$points); $use->parentNode->replaceChild($newPolygon,$use); } } doh - for xml sanity, add this before the replaceChild if ($newPolygon->hasAttribute('id')) { $newPolygon->removeAttribute('id'); } Now it works, and makes identical svg image that works with convert. http://www.shastaherps.org/map/map22.svg vs http://www.shastaherps.org/map/map22.svg?convert=true -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help with exec.
I need to pipe some data to an external application. I have this: while ($row = mysql_fetch_array($theData[0])) { $src_ip[] = $row[0]; $dst_ip[] = $row[1]; $sig_desc[] = $row[2]; $rec ++; if ( $rec == $recCount ) { break; } } for ($i = 0; $i < sizeof($src_ip); $i++) { $tmpResult[] = "$sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n"; } The external program is called like: cat results.csv | theprogram outputfilename Is there a way mimic this w/o outputting $tmpResult to a file first? Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with exec.
On 3 March 2010 13:01, Paul Halliday wrote: > I need to pipe some data to an external application. > > I have this: > > while ($row = mysql_fetch_array($theData[0])) { > $src_ip[] = $row[0]; > $dst_ip[] = $row[1]; > $sig_desc[] = $row[2]; > > $rec ++; > if ( $rec == $recCount ) { > break; > } > } > > for ($i = 0; $i < sizeof($src_ip); $i++) { > $tmpResult[] = "$sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n"; > } > > > The external program is called like: > > cat results.csv | theprogram outputfilename > > Is there a way mimic this w/o outputting $tmpResult to a file first? > > Thanks. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > I believe you can use popen() to open "theprogram" and pipe to it the content and read back the results. All without writing to any files. -- - Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with exec.
On Wed, 2010-03-03 at 13:04 +, Richard Quadling wrote: > On 3 March 2010 13:01, Paul Halliday wrote: > > I need to pipe some data to an external application. > > > > I have this: > > > > while ($row = mysql_fetch_array($theData[0])) { > >$src_ip[] = $row[0]; > >$dst_ip[] = $row[1]; > >$sig_desc[] = $row[2]; > > > >$rec ++; > >if ( $rec == $recCount ) { > >break; > >} > > } > > > > for ($i = 0; $i < sizeof($src_ip); $i++) { > >$tmpResult[] = "$sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n"; > > } > > > > > > The external program is called like: > > > > cat results.csv | theprogram outputfilename > > > > Is there a way mimic this w/o outputting $tmpResult to a file first? > > > > Thanks. > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > I believe you can use popen() to open "theprogram" and pipe to it the > content and read back the results. All without writing to any files. > popen() either reads from a pipe or writes to a pipe, if I remember well, not both. Teus. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with exec.
I work by example :) I can't find enough of an example to get me going with this. I have this: $glow = popen('afterglow.pl -c color.properties -s -e 3 -p 1 -l 2000 | neato -Tpng -o /usr/local/www/test.png','r'); how do I feed my array to that? Thanks. On Wed, Mar 3, 2010 at 9:04 AM, Richard Quadling wrote: > On 3 March 2010 13:01, Paul Halliday wrote: >> I need to pipe some data to an external application. >> >> I have this: >> >> while ($row = mysql_fetch_array($theData[0])) { >> $src_ip[] = $row[0]; >> $dst_ip[] = $row[1]; >> $sig_desc[] = $row[2]; >> >> $rec ++; >> if ( $rec == $recCount ) { >> break; >> } >> } >> >> for ($i = 0; $i < sizeof($src_ip); $i++) { >> $tmpResult[] = "$sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n"; >> } >> >> >> The external program is called like: >> >> cat results.csv | theprogram outputfilename >> >> Is there a way mimic this w/o outputting $tmpResult to a file first? >> >> Thanks. >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > I believe you can use popen() to open "theprogram" and pipe to it the > content and read back the results. All without writing to any files. > > > > -- > - > Richard Quadling > "Standing on the shoulders of some very clever giants!" > EE : http://www.experts-exchange.com/M_248814.html > EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > ZOPA : http://uk.zopa.com/member/RQuadling > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Help with exec.
On 03/03/2010 13:01, Paul Halliday wrote: > I need to pipe some data to an external application. > > I have this: > > while ($row = mysql_fetch_array($theData[0])) { > $src_ip[] = $row[0]; > $dst_ip[] = $row[1]; > $sig_desc[] = $row[2]; > > $rec ++; > if ( $rec == $recCount ) { > break; > } > } > > for ($i = 0; $i < sizeof($src_ip); $i++) { > $tmpResult[] = "$sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n"; > } > > > The external program is called like: > > cat results.csv | theprogram outputfilename > > Is there a way mimic this w/o outputting $tmpResult to a file first? > > Thanks. > Hi, I have used this code to feed data to gpg and read back the encrypted result, Im sure you can adapt it to your needs. function Encrypt($data){ # http://www.theoslogic.com/scripts/php-gpg/ $gpg_command="/usr/bin/gpg $parameters"; $errLog = "/tmp/errors.log"; $dspecs = array( 0=>array("pipe", "r"), 1=>array("pipe", "w"), 2=>array("file", $errLog, "a") ); $encrypted=""; $procdata=""; $gpgproc = proc_open($gpg_command, $dspecs, $pipes); if (is_resource($gpgproc)) { fwrite($pipes[0], $data); fclose($pipes[0]); while($procdata = fgets($pipes[1], 1024)) { $encrypted .= $procdata; } fclose($pipes[1]); } return $encrypted; } It works really well. Regards Ian -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP: inexplicable behaviour of pre- and post-increment operators
> On Fri, Feb 26, 2010 at 11:01 PM, wrote: > > while ($i < $j) { $b[$i] = $a[$i++]; } B. > > > > You get $b[0] = $a[1], and so on (as you would expect). > Wouldn't that be $b[0] = $a[0], with the value of $i being 1 *after* the statement was finished executing? You used a post-decrement operator on $i at the end of your statement, so I don't think that $i would be increased before being used to index into the $a array. // Todd
Re: [PHP] Re: Help with exec.
and its that easy! it took me a minute to figure out; but all I had to do was: if (is_resource($process)) { for ($i = 0; $i < sizeof($src_ip); $i++) { fwrite($pipes[0], "$sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n"); } fclose($pipes[0]); fclose($pipes[1]); proc_close($process); } thanks. On Wed, Mar 3, 2010 at 10:08 AM, Ian wrote: > On 03/03/2010 13:01, Paul Halliday wrote: >> I need to pipe some data to an external application. >> >> I have this: >> >> while ($row = mysql_fetch_array($theData[0])) { >> $src_ip[] = $row[0]; >> $dst_ip[] = $row[1]; >> $sig_desc[] = $row[2]; >> >> $rec ++; >> if ( $rec == $recCount ) { >> break; >> } >> } >> >> for ($i = 0; $i < sizeof($src_ip); $i++) { >> $tmpResult[] = "$sig_desc[$i],$src_ip[$i],$dst_ip[$i]\n"; >> } >> >> >> The external program is called like: >> >> cat results.csv | theprogram outputfilename >> >> Is there a way mimic this w/o outputting $tmpResult to a file first? >> >> Thanks. >> > > Hi, > > I have used this code to feed data to gpg and read back the encrypted > result, Im sure you can adapt it to your needs. > > function Encrypt($data){ > > # http://www.theoslogic.com/scripts/php-gpg/ > > $gpg_command="/usr/bin/gpg $parameters"; > > $errLog = "/tmp/errors.log"; > > $dspecs = array( > 0=>array("pipe", "r"), > 1=>array("pipe", "w"), > 2=>array("file", $errLog, "a") > ); > > $encrypted=""; > $procdata=""; > > $gpgproc = proc_open($gpg_command, $dspecs, $pipes); > > if (is_resource($gpgproc)) { > fwrite($pipes[0], $data); > fclose($pipes[0]); > > while($procdata = fgets($pipes[1], 1024)) { > $encrypted .= $procdata; > } > fclose($pipes[1]); > } > > return $encrypted; > } > > It works really well. > > Regards > > Ian > -- > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Memory investigation
Yep, I'm familiar with XDebug and KCacheGrind. As you say, though, it doens't (as far as I am aware) offer the particular data that I'm after. We've already got cachegrind gurus working on the code who know how to use it better than I do. :-) What I'm looking for is "see this big cache object we've been building up in memory for this whole page request? Now that we're done with the page, how big is it, really?" --Larry Garfield u...@domain.invalid wrote: ON Linux I have kcacheGrind setup with Xdebug and I find it is a nice little thing to have. It won't tell you the memory consumed but it will find cycles and display object maps. if you have Kcachegrind it is likely you have valgrind installed. http://www2.mandriva.com/ http://valgrind.org/ http://kcachegrind.sourceforge.net/html/Home.html http://xdebug.org/ Larry Garfield wrote: Hi folks. I have a complicated PHP app that is eating up more memory than I think it should. I have a couple of theories as to where it could be going, but I need some way to verify it. There are a number of large data structures (mostly arrays) that get built up throughout the course of the request. What I'd like to be able to do is at certain points check to see how much memory those data structures are using. Because they're not all built at once, the usual "check memory before, build, check after" routine won't work. Plus, that gets screwed up by PHP's use of copy-on-write at times. I know that it would result in essentially over-reporting, but I would ideally like to be able to ignore the copy-on-write issue and say "if this variable were the only thing in memory (and its dependents, of course, for a nested array), what would its memory usage be? I just have no idea how to do that. Anyone have a suggestion for how to accomplish that? --Larry Garfield -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Memory investigation
On 3 March 2010 15:49, la...@garfieldtech.com wrote: > Yep, I'm familiar with XDebug and KCacheGrind. As you say, though, it > doens't (as far as I am aware) offer the particular data that I'm after. > We've already got cachegrind gurus working on the code who know how to use > it better than I do. :-) What I'm looking for is "see this big cache object > we've been building up in memory for this whole page request? Now that > we're done with the page, how big is it, really?" You could try Memtrack (http://pecl.php.net/package/memtrack) but I can't comment as to what state it's in. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Memory investigation
function check_memory_usage(&$memory) { $memory[] = memory_get_usage(); return $memory; } something like this? you can put it wherever you like and returns an array for further processing. You could optionally add a second argument to set the index to a name and check if the name exists to add 1 to the end of the name so your indexes stay maintained. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Memory investigation
That's not really what I'm after. Let me try an example: function foo($id) { static $foos = array(); if (empty($foos[$id]) { $foos[$id] = load_foo($id); } return $foos[$id]; } When load_foo() is slow (e.g., lots of DB traffic or remote-server calls or whatever), such caching can have a significant performance boost. Sometime after foo() has been called 15 times from 30 places in code, when I get to the end of the request (or just every time I call foo() would be fine) I want to be able to do something like: $cost = get_memory_used_by($foos); So that I can determine how much memory that caching is costing me over the lifetime of the page, and determine if it's a worthwhile trade-off. --Larry Garfield dsiemba...@gmail.com wrote: function check_memory_usage(&$memory) { $memory[] = memory_get_usage(); return $memory; } something like this? you can put it wherever you like and returns an array for further processing. You could optionally add a second argument to set the index to a name and check if the name exists to add 1 to the end of the name so your indexes stay maintained. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Database design
a good tool for mapping mysql databases is mysql-workbench. the real question is how much normalization is normal? http://wb.mysql.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] basic authentication and redirection
Hi there, In certain circumstances controlled by my users, I'd like to redirect my users to another site, a third party whom we have contracted with. The second site uses basic authentication with a simple username and password. Can I write my PHP code so my users do not have to login (or even know the username/password) on the remote site? This isn't intended to stop serious hackers, just enough security to stop casual passers-by. Thanks, Bill -- Bill Rausch We first make our habits and then our habits make us. --John Dryden -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Best os shopping cart
Hi, I apologise if this is not strictly php related. What Open Source Shopping cart system do you recommend between osCommerce and Zen-Cart for ease of use and a php guy with dangerously little javascript knowledge? This is not for a massive shopping site, simply a cart to power a subscription sign-up page. Thanks for the advice. Haig
Re: [PHP] Best os shopping cart
Haig Davis wrote: Hi, I apologise if this is not strictly php related. What Open Source Shopping cart system do you recommend between osCommerce and Zen-Cart for ease of use and a php guy with dangerously little javascript knowledge? This is not for a massive shopping site, simply a cart to power a subscription sign-up page. At this point in time I would choose ZenCart over osCommerce since development of osCommerce has languished for the past 3+ years at version 2.2 and version 3.0 has been in alpha for just as long. 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] basic authentication and redirection
depends on how that site does its authentication... if it's a form, it may need an extra setting to allow you to go to a specific page on that site after authentication. On Wed, Mar 3, 2010 at 8:25 PM, Bill Rausch wrote: > > > Hi there, > > In certain circumstances controlled by my users, I'd like to redirect my > users to another site, a third party whom we have contracted with. The > second site uses basic authentication with a simple username and password. > Can I write my PHP code so my users do not have to login (or even know the > username/password) on the remote site? > > This isn't intended to stop serious hackers, just enough security to stop > casual passers-by. > > Thanks, > > Bill > > > -- > Bill Rausch > > We first make our habits and then our habits make us. --John Dryden > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Memory investigation
global $fooSize = 0; function foo($id) { global $fooSize; if (empty($foos($id)) { $b = get_memory_usage(true); $foos[$id] = load_foo($id); $fooSize+= $b - get_memory_usage(true); } ... } On Wed, Mar 3, 2010 at 8:16 PM, la...@garfieldtech.com wrote: > That's not really what I'm after. Let me try an example: > > function foo($id) { > static $foos = array(); > > if (empty($foos[$id]) { > $foos[$id] = load_foo($id); > } > return $foos[$id]; > } > > When load_foo() is slow (e.g., lots of DB traffic or remote-server calls or > whatever), such caching can have a significant performance boost. Sometime > after foo() has been called 15 times from 30 places in code, when I get to > the end of the request (or just every time I call foo() would be fine) I > want to be able to do something like: > > $cost = get_memory_used_by($foos); > > So that I can determine how much memory that caching is costing me over the > lifetime of the page, and determine if it's a worthwhile trade-off. > > --Larry Garfield > > dsiemba...@gmail.com wrote: >> >> function check_memory_usage(&$memory) >> { >> $memory[] = memory_get_usage(); >> return $memory; >> } >> >> something like this? >> you can put it wherever you like and returns an array for further >> processing. You could optionally add a second argument to set the index to a >> name and check if the name exists to add 1 to the end of the name so your >> indexes stay maintained. >> > > -- > 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] basic authentication and redirection
[snip] In certain circumstances controlled by my users, I'd like to redirect my users to another site, a third party whom we have contracted with. The second site uses basic authentication with a simple username and password. Can I write my PHP code so my users do not have to login (or even know the username/password) on the remote site? This isn't intended to stop serious hackers, just enough security to stop casual passers-by. [/snip] Have a look at cURL (http://www.php.net/curl) as it will allow you to perform remote POST's which may be enough to get you through. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] basic authentication and redirection
Jay Blanchard wrote: [snip] In certain circumstances controlled by my users, I'd like to redirect my users to another site, a third party whom we have contracted with. The second site uses basic authentication with a simple username and password. Can I write my PHP code so my users do not have to login (or even know the username/password) on the remote site? This isn't intended to stop serious hackers, just enough security to stop casual passers-by. [/snip] Have a look at cURL (http://www.php.net/curl) as it will allow you to perform remote POST's which may be enough to get you through. Or you can use JavaScript on an intermediate page to post directly to the remote site's login form. If JavaScript is disabled, just have a button "Please continue to XXX" which then performs the post tot he remote site. 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] Re: Memory investigation
couple questions Larry is this application composed of classes or straight up no holes barred procedural code? la...@garfieldtech.com wrote: That's not really what I'm after. Let me try an example: function foo($id) { static $foos = array(); if (empty($foos[$id]) { $foos[$id] = load_foo($id); } return $foos[$id]; } When load_foo() is slow (e.g., lots of DB traffic or remote-server calls or whatever), such caching can have a significant performance boost. Sometime after foo() has been called 15 times from 30 places in code, when I get to the end of the request (or just every time I call foo() would be fine) I want to be able to do something like: $cost = get_memory_used_by($foos); So that I can determine how much memory that caching is costing me over the lifetime of the page, and determine if it's a worthwhile trade-off. --Larry Garfield dsiemba...@gmail.com wrote: function check_memory_usage(&$memory) { $memory[] = memory_get_usage(); return $memory; } something like this? you can put it wherever you like and returns an array for further processing. You could optionally add a second argument to set the index to a name and check if the name exists to add 1 to the end of the name so your indexes stay maintained. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Memory investigation
Currently it's mostly procedural with some components that are OO. I suspect most of the memory sinks are large arrays (we have a lot of them), but I am not certain of that. Hence my interest in more accurate investigation tools. --Larry Garfield dsiemba...@gmail.com wrote: couple questions Larry is this application composed of classes or straight up no holes barred procedural code? la...@garfieldtech.com wrote: That's not really what I'm after. Let me try an example: function foo($id) { static $foos = array(); if (empty($foos[$id]) { $foos[$id] = load_foo($id); } return $foos[$id]; } When load_foo() is slow (e.g., lots of DB traffic or remote-server calls or whatever), such caching can have a significant performance boost. Sometime after foo() has been called 15 times from 30 places in code, when I get to the end of the request (or just every time I call foo() would be fine) I want to be able to do something like: $cost = get_memory_used_by($foos); So that I can determine how much memory that caching is costing me over the lifetime of the page, and determine if it's a worthwhile trade-off. --Larry Garfield dsiemba...@gmail.com wrote: function check_memory_usage(&$memory) { $memory[] = memory_get_usage(); return $memory; } something like this? you can put it wherever you like and returns an array for further processing. You could optionally add a second argument to set the index to a name and check if the name exists to add 1 to the end of the name so your indexes stay maintained. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Best os shopping cart
On Wed, 2010-03-03 at 14:46 -0500, Robert Cummings wrote: > Haig Davis wrote: > > Hi, > > > > I apologise if this is not strictly php related. What Open Source Shopping > > cart system do you recommend between osCommerce and Zen-Cart for ease of use > > and a php guy with dangerously little javascript knowledge? > > > > This is not for a massive shopping site, simply a cart to power a > > subscription sign-up page. > > At this point in time I would choose ZenCart over osCommerce since > development of osCommerce has languished for the past 3+ years at > version 2.2 and version 3.0 has been in alpha for just as long. > > Cheers, > Rob. > -- > http://www.interjinn.com > Application and Templating Framework for PHP > If it's an option, I'd recommend Magento. I've not used it, but I've heard a lot of good things about it. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Best os shopping cart
At 11:29 AM -0800 3/3/10, Haig Davis wrote: Hi, I apologise if this is not strictly php related. What Open Source Shopping cart system do you recommend between osCommerce and Zen-Cart for ease of use and a php guy with dangerously little javascript knowledge? This is not for a massive shopping site, simply a cart to power a subscription sign-up page. Thanks for the advice. Haig Haig: A subscription sign-up page? That doesn't sound like a shopping cart problem. You mean something like this: http://webbytedd.com/b/sub-email/ 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
[PHP] Re: Best os shopping cart
Haig Davis wrote: > Hi, > > I apologise if this is not strictly php related. What Open Source Shopping > cart system do you recommend between osCommerce and Zen-Cart for ease of use > and a php guy with dangerously little javascript knowledge? > > This is not for a massive shopping site, simply a cart to power a > subscription sign-up page. > > Thanks for the advice. > > Haig > For just a subscription sign-up I use a PayPal button. PayPal supports subscription based billing. -- 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] PHP: inexplicable behaviour of pre- and post-increment operators
On Wed, 3 Mar 2010 08:21:06 -0600, halip...@gmail.com (haliphax) wrote: >> On Fri, Feb 26, 2010 at 11:01 PM, wrote: >> > while ($i < $j) { $b[$i] = $a[$i++]; } B. >> > >> > You get $b[0] = $a[1], and so on (as you would expect). >> > >Wouldn't that be $b[0] = $a[0], with the value of $i being 1 *after* the >statement was finished executing? You used a post-decrement operator on $i >at the end of your statement, so I don't think that $i would be increased >before being used to index into the $a array. Try it! Clancy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XMLRPC issue
Hi all, I was upgrading php from 5.6 to 5.11 and came across one odd issue. Hope someone could point out what is the problem. Following code demonstrates it: $xml = 'encoding="UTF-8"?>'; echo xmlrpc_decode($xml); I suspect to get "" as a result, but for some reason < and > are cut out and i'm getting "Test/". So basically all entities are dropped from response. I have 2nd server running same OS (CentOS 5) which has been upgraded first and it works as i suspect, code above shows "". Any advice will be much appreciated. Currently I have temporary workaround for this: $xml = str_replace(array('<','>'), array('<','>'), $xml); but would like to fix xmlrpc somehow. Regards, Dmitry Ruban -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php