[PHP] Re: Regex
M. Sokolewicz wrote: Nadim Attari wrote: Hello, I have some text in a table... the text contains hyperlinks (but not html coded, i.e. plain Some text...http://www.something.com;) When i retrieve these texts from the table, i want the hyperlinks to become clickable, i.e. a href etc added automatically. Some text...a href=http://www.something.com;http://www.something.com/a I know this sould be done using Regex, but i don't know regex. Any help (links, examples, etc) Thanks Nadim Attari You don't know Regex. Well, that's simple then, TRY to learn it. Noone will (or should) give you any answers if it's absolutely clear that you're not putting any effort into trying to find one yourself. I know this should be done using Regex, but I don't know regex., wouldn't you think it'd be a good idea to look up a tutorial somewhere or try to find out what this regex exactly is? Try to type regex in the php doc, see the notes for the various functions? really, a little more effort goes a long way. - tul Hello, I know i MUST learn it.. time does not permit me. But surely i'll learn how to use this powerful tool! And if i didn't need a quick help from this ML, why i would be here ... do you think if time permitted me to learn this, i'll ask a little help from this ML ? I am learning and will continue to learn throughout my life. And remember, the day one says i've learnt everthing now this is the day his downfall begins ... Anyway i've got something working: function hyperlinks($text = '', $class = 'link') { $text = trim($text); if ($text != '') { if (trim($class) != '') $class = ' class='.$class.''; $in = array('`((?:https?|ftp)://\\S+)(\\s|\\z)`', '`([[:alnum:]]([-_.]?[[:alnum:]])[EMAIL PROTECTED]:alnum:]]([-_.]?[[:alnum:]])*\.([a-z]{2,4}))`'); $out = array('a href=$1'.$class.' target=_blank$1/a$2', 'a href=mailto:$1;'.$class.'$1/a'); $text = preg_replace($in, $out, $text); } return $text; } Renders http, https, ftp, mailto. Thanks M. Sokolewicz and everyone. Nadim Attari -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strange mysqli error
how do you know which object is destroyed first? also you are using 3 different versions of php - not something that will help narrow down the problem. Richard K Miller wrote: Good afternoon. I'm getting a weird mysqli error in my object destructor. Here's an example: ?php $db = new mysqli('localhost', USERNAME, PASSWORD, DATABASE); class Test { function __construct() { global $db; $db-query(SELECT 'test'); print_r($db-error); } function __destruct() { global $db; $db-query(SELECT 'test'); // line 20 print_r($db-error); // line 21 } } $test = new Test(); what happens if you add the following line: unset($test); ? A. On my dev machine (Mac OS X + PHP 5.1.4 + MySQL 5.0.19) I get the following errors EVERY time: Warning: mysqli::query() [function.mysqli-query]: Couldn't fetch mysqli in /Users/richard/Projects/data/private/mgftest.php on line 20 Warning: Test::__destruct() [function.Test---destruct]: Couldn't fetch mysqli in /Users/richard/Projects/data/private/mgftest.php on line 21 B. On my production server (FreeBSD + PHP 5.1.2 + MySQL 5.0.19) I SOMETIMES get the following error: (If I refresh the page repeatedly, sometimes there's an error, sometimes not.) Warning: mysqli::query() [function.query]: Couldn't fetch mysqli in /usr/local/www/data/private/mgftest.php on line 20 C. On a commercial web host (PHP 5.0.4 + MySQL 5.0.22) I NEVER get any errors. There's nothing else in my error logs, $db-errno is 0, and $db-error is empty. Interestingly, I never get any errors from the constructor. Any ideas? Richard --- Richard K. Miller www.richardkmiller.com --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] Session / cookie issues
Hi all. I mailed some time ago regarding a cookie/session issue I am having and thank you all for your useful and knowledgeable responses. I have now used 10 separate testers and 9 are able to progress through a 3-stage form process that validates data as it goes along and enters the data into the session array - enabling the user to go back and see previous forms pre-populated with their selected data (cahcing is enforced on these pages). However, the client still has issues and I have confirmed that their browser is rejecting cookies. They are using IE on Win XP and have Internet security set to Medium. I set mine to the same, used IE to go through the process and had no such issues. Can anyone tell me if I am missing something obvious? -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
[PHP] switch it button
At the moment I have this, but I want to change it to one switch button a href=?php echo $_SERVER['PHP_SELF'];??session_switch=1switch it/a. I have tried but keep getting wrapped up in nested if-else statements. Does anyone know how to make an efficient one button on-off switch. ? $session_switch = isset($_GET['session_switch']) ? $_GET['session_switch'] : 0; if ($session_switch==1) { echo on; ? //do something here ? } else { //do something else } ? a href=?php echo $_SERVER['PHP_SELF'];??session_switch=0off/a a href=?php echo $_SERVER['PHP_SELF'];??session_switch=1on/a -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] switch it button
[snip] At the moment I have this, but I want to change it to one switch button a href=?php echo $_SERVER['PHP_SELF'];??session_switch=1switch it/a. I have tried but keep getting wrapped up in nested if-else statements. Does anyone know how to make an efficient one button on-off switch. [/snip] Have you considered a switch statement? http://www.php.net/switch -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strange mysqli error
On Aug 23, 2006, at 2:33 AM, Jochem Maas wrote: how do you know which object is destroyed first? also you are using 3 different versions of php - not something that will help narrow down the problem. Richard K Miller wrote: Good afternoon. I'm getting a weird mysqli error in my object destructor. Here's an example: ?php $db = new mysqli('localhost', USERNAME, PASSWORD, DATABASE); class Test { function __construct() { global $db; $db-query(SELECT 'test'); print_r($db-error); } function __destruct() { global $db; $db-query(SELECT 'test'); // line 20 print_r($db-error); // line 21 } } $test = new Test(); what happens if you add the following line: unset($test); No errors when I use unset(). I see what you mean about not knowing which object is destroyed first. Maybe I'll have to use a non-OOP connection to MySQL, since it wouldn't appear there's any way to specify the order of destruction of objects. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] switch it button
On 23 August 2006 12:45, Ross wrote: At the moment I have this, but I want to change it to one switch button a href=?php echo $_SERVER['PHP_SELF'];??session_switch=1switch it/a. I have tried but keep getting wrapped up in nested if-else statements. Does anyone know how to make an efficient one button on-off switch. ? $session_switch = isset($_GET['session_switch']) ? $_GET['session_switch'] 0; if ($session_switch==1) { echo on; //do something here ? } else { //do something else } a href=?php echo $_SERVER['PHP_SELF'];??session_switch=0off/a a href=?php echo $_SERVER['PHP_SELF'];??session_switch=1on/a How about something like: a href=?php echo $_SERVER['PHP_SELF'] ??session_switch=?php $_GET['session_switch']?0:1 ?switch/a Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch it button
At 12:44 PM +0100 8/23/06, Ross wrote: At the moment I have this, but I want to change it to one switch button I think I know what you mean -- a single switch button. Please review this kiddie-script: http://xn--ovg.com/a/toggle.php hth's tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] switch it button
Ford, Mike wrote: How about something like: a href=?php echo $_SERVER['PHP_SELF'] ??session_switch=?php $_GET['session_switch']?0:1 ?switch/a Beware that PHP_SELF is injectable like several other $_SERVER variables, so you must at least encode it to prevent XSS attacks. Eg. http://example.com/foo.php/;/ascriptalert('xss here');/script Passing it through htmlspecialchars() will encode it safely, but in this case you can just omit it. href=?foo=bar is perfectly valid and works fine. Arpad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Why small big?
Hi gang: I have a thumbnail script, which does what it is supposed to do. However, the thumbnail image generated is larger than the original image, how can that be? Here's the script working: http://xn--ovg.com/thickbox And, here's the script: ?php /* thumb from file */ /* some settings */ ignore_user_abort(); set_time_limit( 0 ); error_reporting( FATAL | ERROR | WARNING ); /* security check */ ini_set( 'register_globals', '0' ); /* start buffered output */ ob_start(); /* some checks */ if ( ! isset( $_GET['s'] ) ) die( 'Source image not specified' ); $filename = $_GET['s']; // Set a maximum height and width $width = 200; $height = 200; // Get new dimensions list($width_orig, $height_orig) = getimagesize($filename); if ($width ($width_orig $height_orig)) { $width = ($height / $height_orig) * $width_orig; } else { $height = ($width / $width_orig) * $height_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output Content type header('Content-type: image/jpeg'); imagejpeg($image_p, null, 100); /* end buffered output */ ob_end_flush(); ? --- Thanks in advance for any comments, suggestions or answers. 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: Why small big?
I'm not quite sure, but consider the following: Considering the fact that most JPEG images are stored with some form of compression usually ~75% that would mean the original image, in actual size, is about 1.33x bigger than it appears in filesize. When you make a thumbnail, you limit the amount of pixels, but you are setting compression to 100% (besides that, you also use a truecolor pallete which adds to its size). So, for images which are scaled down less than 25% (actually this will prob. be more around 30-ish, due to palette differences) you'll actually see the thumbnail being bigger in *filesize* than the original (though smaller in memory-size) - tul P.S. isn't error_reporting( FATAL | ERROR | WARNING ); supposed to be error_reporting( E_FATAL | E_ERROR | E_WARNING ); ?? tedd wrote: Hi gang: I have a thumbnail script, which does what it is supposed to do. However, the thumbnail image generated is larger than the original image, how can that be? Here's the script working: http://xn--ovg.com/thickbox And, here's the script: ?php /* thumb from file */ /* some settings */ ignore_user_abort(); set_time_limit( 0 ); error_reporting( FATAL | ERROR | WARNING ); /* security check */ ini_set( 'register_globals', '0' ); /* start buffered output */ ob_start(); /* some checks */ if ( ! isset( $_GET['s'] ) ) die( 'Source image not specified' ); $filename = $_GET['s']; // Set a maximum height and width $width = 200; $height = 200; // Get new dimensions list($width_orig, $height_orig) = getimagesize($filename); if ($width ($width_orig $height_orig)) { $width = ($height / $height_orig) * $width_orig; } else { $height = ($width / $width_orig) * $height_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output Content type header('Content-type: image/jpeg'); imagejpeg($image_p, null, 100); /* end buffered output */ ob_end_flush(); ? --- Thanks in advance for any comments, suggestions or answers. tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MCrypt resource limits?
Hi list, Yesterday I noticed one of the sites I had created was running really slow. Yet all the other sites on our webserver were running great. I had our network admin look at the cpu, ram usage, etc of the webserver and everything looked fine. Finally I just recommended we stick Xdebug on there to find out what the exact problem was. It boiled down to my encryption wrapper object. I guess there were too many MCrypt resources open at once. I'm not really sure of the real problem, but when I switched around some code to avoid unnecessarily loading initializing the resource, the site was zippy again. As I was developing locally everything was fine because it was just me hitting the site. When I pushed it to the server though there was quite a bit of traffic to it. So my question is, are there limits in PHP to how many resources can be opened? What about limits to how many MCrypt resources you can have open? This specific instance was a stupid mistake on my part, but I just want to know for future reference. Thanks!
[PHP] Re: Why small big?
M Sokolewice got it nearly correct. However, the situation is a little more complex than he has discussed. The % compression figure for jpeg is translated into the amount of information stored in the reverse cosine matrix. The size of the compressed file is not proportional to the % you set in the compressor. Thus 100% actually means store all the information in the reverse cosine matrix. This is like storing the image in a 24 bit png, but with the compressor turned off. So at 100% jpeg is quite inefficient. The other issue is the amount of high frequency information in your images. If you have a 2000x2000 image with most of the image dynamics at a 10 pixel frequency, and you reduce this to 200x200 then the JPEG compression algorithm will 'see' approximately the same amount of information in the image :-( The reality is not quite as simple as this because of the way JPEG uses blocks etc, but it is an easy way of thinking about it. What all this means is that as you reduce the size of an image, if you want it to retain some of the detail of the original but at a smaller size, there will be a point at which 8 or 24 bit PNG will become a better bet. Clear as mud? AJ M. Sokolewicz wrote: I'm not quite sure, but consider the following: Considering the fact that most JPEG images are stored with some form of compression usually ~75% that would mean the original image, in actual size, is about 1.33x bigger than it appears in filesize. When you make a thumbnail, you limit the amount of pixels, but you are setting compression to 100% (besides that, you also use a truecolor pallete which adds to its size). So, for images which are scaled down less than 25% (actually this will prob. be more around 30-ish, due to palette differences) you'll actually see the thumbnail being bigger in *filesize* than the original (though smaller in memory-size) - tul P.S. isn't error_reporting( FATAL | ERROR | WARNING ); supposed to be error_reporting( E_FATAL | E_ERROR | E_WARNING ); ?? tedd wrote: Hi gang: I have a thumbnail script, which does what it is supposed to do. However, the thumbnail image generated is larger than the original image, how can that be? Here's the script working: http://xn--ovg.com/thickbox And, here's the script: ?php /* thumb from file */ /* some settings */ ignore_user_abort(); set_time_limit( 0 ); error_reporting( FATAL | ERROR | WARNING ); /* security check */ ini_set( 'register_globals', '0' ); /* start buffered output */ ob_start(); /* some checks */ if ( ! isset( $_GET['s'] ) ) die( 'Source image not specified' ); $filename = $_GET['s']; // Set a maximum height and width $width = 200; $height = 200; // Get new dimensions list($width_orig, $height_orig) = getimagesize($filename); if ($width ($width_orig $height_orig)) { $width = ($height / $height_orig) * $width_orig; } else { $height = ($width / $width_orig) * $height_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output Content type header('Content-type: image/jpeg'); imagejpeg($image_p, null, 100); /* end buffered output */ ob_end_flush(); ? --- Thanks in advance for any comments, suggestions or answers. tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strange mysqli error
Richard K Miller wrote: On Aug 23, 2006, at 2:33 AM, Jochem Maas wrote: how do you know which object is destroyed first? also you are using 3 different versions of php - not something that will help narrow down the problem. ... No errors when I use unset(). I see what you mean about not knowing which object is destroyed first. Maybe I'll have to use a non-OOP connection to MySQL, you can still use OOP, only you can't rely on auto destruct with regard to object existance. since it wouldn't appear there's any way to specify the order of destruction of objects. try the ini settings auto_prepend_file auto_append_file http://php.net/manual/en/ini.core.php#ini.auto-append-file and use them to control the startup /or shutdown phase of your app. e.g: class DB { private $connObj; // obj of class DB // don't allow references to it outside the class static function shutdown() { unset(self::$connObj); /* trigger self::__destruct() */ } function __destruct() { /* do stuff (which you could just as well do in self::shutdown()?) */ } } shutdown.php: ?php DB::shutdown(); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Why small big?
Alex: Excuse for top posting: You said: Clear as mud? Well actually, it's simperer than I thought. After your reply, I did some reading on jpeg and found it's simply a transform, not unlike FFT where two-dimensional temporal data is transformed from the time domain to the frequency domain -- very interesting reading. The reverse cosine matrix you mention is probably the discrete cosine transform (DCT) matrix where the x, y pixels of an image file have a z component representing color. From that you can translate the data into the frequency domain, which actually generates more data than the original. However, the quality setting is where you make it back up in compression ratio's by trimming off higher frequencies which don't add much to the data. Unlike the FFT, the algorithm does not address phasing, which I found interesting. However, the answer to my question deals with the quality statement. In the statement: imagejpeg($image_p, null, 100); I should have used something less than 100. I've change the figure to 25 and don't see any noticeable difference in quality of the thumbnail. It seems to me there should be a table (or algorithm) somewhere that would recommend what quality to use when reducing the size of an image via this method. In this case, I reduced an image 62 percent (38% of the original) with a quality setting of 25 and see no difference. I think this (the quality factor) is programmable. As for png images, I would probably agree (if I saw comparisons), but not all browsers accept them. I belive that at least one IE has problems with png's, right? tedd At 4:45 PM +0100 8/23/06, Alex Turner wrote: M Sokolewice got it nearly correct. However, the situation is a little more complex than he has discussed. The % compression figure for jpeg is translated into the amount of information stored in the reverse cosine matrix. The size of the compressed file is not proportional to the % you set in the compressor. Thus 100% actually means store all the information in the reverse cosine matrix. This is like storing the image in a 24 bit png, but with the compressor turned off. So at 100% jpeg is quite inefficient. The other issue is the amount of high frequency information in your images. If you have a 2000x2000 image with most of the image dynamics at a 10 pixel frequency, and you reduce this to 200x200 then the JPEG compression algorithm will 'see' approximately the same amount of information in the image :-( The reality is not quite as simple as this because of the way JPEG uses blocks etc, but it is an easy way of thinking about it. What all this means is that as you reduce the size of an image, if you want it to retain some of the detail of the original but at a smaller size, there will be a point at which 8 or 24 bit PNG will become a better bet. Clear as mud? AJ M. Sokolewicz wrote: I'm not quite sure, but consider the following: Considering the fact that most JPEG images are stored with some form of compression usually ~75% that would mean the original image, in actual size, is about 1.33x bigger than it appears in filesize. When you make a thumbnail, you limit the amount of pixels, but you are setting compression to 100% (besides that, you also use a truecolor pallete which adds to its size). So, for images which are scaled down less than 25% (actually this will prob. be more around 30-ish, due to palette differences) you'll actually see the thumbnail being bigger in *filesize* than the original (though smaller in memory-size) - tul P.S. isn't error_reporting( FATAL | ERROR | WARNING ); supposed to be error_reporting( E_FATAL | E_ERROR | E_WARNING ); ?? tedd wrote: Hi gang: I have a thumbnail script, which does what it is supposed to do. However, the thumbnail image generated is larger than the original image, how can that be? Here's the script working: http://xn--ovg.com/thickbox And, here's the script: ?php /* thumb from file */ /* some settings */ ignore_user_abort(); set_time_limit( 0 ); error_reporting( FATAL | ERROR | WARNING ); /* security check */ ini_set( 'register_globals', '0' ); /* start buffered output */ ob_start(); /* some checks */ if ( ! isset( $_GET['s'] ) ) die( 'Source image not specified' ); $filename = $_GET['s']; // Set a maximum height and width $width = 200; $height = 200; // Get new dimensions list($width_orig, $height_orig) = getimagesize($filename); if ($width ($width_orig $height_orig)) { $width = ($height / $height_orig) * $width_orig; } else { $height = ($width / $width_orig) * $height_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output Content type header('Content-type: image/jpeg'); imagejpeg($image_p, null, 100); /* end buffered output */ ob_end_flush(); ? ---
RE: [PHP] Shopping cart
Richard Lynch mailto:[EMAIL PROTECTED] on Tuesday, August 22, 2006 10:30 AM said: Guys, don't take this wrong but... How do you think all the other PHP shopping carts got started?... Pretty much the same way. So you really need to spend the next couple months figuring out what they did wrong, why they did that, and how to avoid doing it... Finally, some sanity. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] strange mysqli error
On Aug 23, 2006, at 11:41 AM, Jochem Maas wrote: you can still use OOP, only you can't rely on auto destruct with regard to object existance. try the ini settings auto_prepend_file auto_append_file http://php.net/manual/en/ini.core.php#ini.auto-append-file and use them to control the startup /or shutdown phase of your app. e.g: class DB { private $connObj; // obj of class DB // don't allow references to it outside the class static function shutdown() { unset(self::$connObj); /* trigger self::__destruct() */ } function __destruct() { /* do stuff (which you could just as well do in self::shutdown()?) */ } } shutdown.php: ?php DB::shutdown(); Jochem, That's a good idea, and I'm glad to learn about the auto-append-file directive for the first time, but that seems a bit more hack-ey than I want. Just to document this a bit more, this page has a quote supposedly from Andi Gutmans saying we must not rely in any way on the order of destruction during shutdown: http://www.phpbuilder.com/board/archive/index.php/t-10293485.html Previous bug reports on this issue: http://bugs.php.net/bug.php?id=36034 http://bugs.php.net/bug.php?id=31326 Since these bugs don't appear to be slated for fixing, I submitted a request to change the documentation: http://bugs.php.net/bug.php?id=38572 The documentation ought to reflect that we cannot rely on the the order of destruction rather than the current The destructor method will be called as soon as all references to a particular object are removed, which is incorrect. But I'd actually prefer that the bug be fixed rather than the documentation changed. Richard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Where to download APC for windows?
I used to have a bookmark on where to download APC for windows. Anyone have a link? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] usort within a class
Hi, Is it possible to have the compare function in a class? I can not get it to work, this is pseudo code: class A { function getArray() { //dosomethingandgetanarray $array = blabla; usort($array, $this-myCompareFunction); //Or maybe A::myCompareFunction } function myCompareFunction($a, $b) { //return rajraj depending on $a and $b values } } Right now I have keep the compare function outside of the class like this: class A { function getArray() { //dosomethingandgetanarray $array = blabla; usort($array, $this-myCompareFunction); } } function myCompareFunction($a, $b) { //return rajraj depending on $a and $b values } Best regards, Peter Lauri -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] usort within a class
On Thu, 2006-08-24 at 03:13 +0700, Peter Lauri wrote: Hi, Is it possible to have the compare function in a class? I can not get it to work, this is pseudo code: class A { function getArray() { //dosomethingandgetanarray $array = blabla; usort($array, $this-myCompareFunction); //Or maybe A::myCompareFunction } function myCompareFunction($a, $b) { //return rajraj depending on $a and $b values } } Right now I have keep the compare function outside of the class like this: class A { function getArray() { //dosomethingandgetanarray $array = blabla; usort($array, $this-myCompareFunction); } } function myCompareFunction($a, $b) { //return rajraj depending on $a and $b values } RTF :) usort( $array, array( $this, 'myCompareFunction' ) ) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP BEA Weblogic 8.
Given that Weblogic is an application server, I don't think you're going to have much luck. PHP is typically installed directly on the web server (Apache, or similar). On 8/20/06, BKruger [EMAIL PROTECTED] wrote: Could anyone please direct me to installation instructions for PHP on BEA Weblogic 8.1? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] OT alternate website authentication methods
Everyone, Been out of the office for a few days... As nearly everyone has pointed out, the downside(s) to visual/audial authentication methods are greater than the benefits Thanks! Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] E_ALL | E_STRICT
- tul P.S. isn't error_reporting( FATAL | ERROR | WARNING ); supposed to be error_reporting( E_FATAL | E_ERROR | E_WARNING ); ?? Good catch. I'm not sure where I got that -- probably a message from some flounder (Bullwinkle circa 1964). In my newer scripts I use: ini_set('error_reporting', E_ALL | E_STRICT); However, I'm not sure if that's redundant. tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP BEA Weblogic 8.
I agree that it is probably pretty non standard! You could write a bean to drive it using the java version of fcgi. But then the app server will hate you for ever as beans are not supposed to do things like open sockets etc. I am very very interested in why you want to do such a thing :-) AJ Andrew Kreps wrote: Given that Weblogic is an application server, I don't think you're going to have much luck. PHP is typically installed directly on the web server (Apache, or similar). On 8/20/06, BKruger [EMAIL PROTECTED] wrote: Could anyone please direct me to installation instructions for PHP on BEA Weblogic 8.1? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Where to download APC for windows?
At the risk of being flamed to death, I thought it was in ext in the standard windows distro. If it is not, I am stuffed if I can remember where I got it from (blush). AJ steve wrote: I used to have a bookmark on where to download APC for windows. Anyone have a link? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Why small big?
Tedd, Sorry for the floppy language. You are quite correct, the name is discrete cosine. I get too relaxed sometimes! As to the visual impact of a degree of compression, I don't think that you can automate this. The issue surrounds the way the brain processes information. When you see something, you brain processes the visual field and looks for patters that it recognizes and then your conscious mind becomes aware of the patterns, not actually the thing you are looking at. Optical illusions can illustrate this point. For example where you see a bunch of blobs on a white background and then someone tells you it is a dog and you see the dog. Once you see the dog you can no longer 'not see it'. This is because of the way the brain processes patterns. The trick to DCT is that in most 'organic' images - people, trees etc - the patterns for which your brain is looking actually occupy low frequencies. However, the majority of the information which is encoded into the image is in high frequencies. Consequently, by selectively removing the high frequencies, the image appears to the conscious mind to be the same whilst in reality it is degraded. The snag come when the pattern your brain is looking to match to requires high frequencies. The classic is a edge. If one has an infinitely large white background with a single infinitely sharp line on it, you require infinite frequencies to encode it correctly (ten years ago I knew the proof for this, time and good wine has put a stop to that). This is much like the side band problem in radio transmission. If you encode an image in dimensional space rather than in frequency space you don't get this problem (hence PNG permitting perfectly sharp lines). So - back on topic. If you take an image with sharp lines in it, then pass it through DCT twice (the process in symmetrical) but loose some of the high frequency data in the process (compression) then the result is that the very high frequency components that encode the edge are stripped off. Rather than (as one might like) this making the edge fussy, it produces what is called mosquito noise around the edges. Because mosquito noise is nothing like what you are 'expecting' to see, the brain is very sensitive to it. Thus, the amount you notice the compression of JPEG depends on the nature of the image you compress. Now it gets nasty. DCT scales as a power of n (where n is the size of image) - there is a fast DCT process like the F in FFT. But it is still non linear. This means that to make the encoding and decoding of JPEG reasonably quick the image is split into blocks and each block is separately passed through the DCT process. This is fine except that it produces errors from one block to the next as to where the edges are in HSV space. Thus, as the compression is turned up, the edges of the block can become visible due to discontinuities in the color, huge and saturation at the borders. This again is sensitive to the sort of image you are compressing. For example, if it has a very flat (say black or white) background, then you will not notice. Alternatively, if the image is tonally rich, like someone's face, you will notice it a lot. Again, this effect means that it is not really possible to automate the process of figuring out what compression setting is optimum. As for PNG: As far as I know, the only issue with any realistic browser (other than very old ones like IE2 or something) is that the alpha channel is not supported. As there is no alpha channel in JPEG, so there is no difference. Though I do not profess to be absolutely sure that all browsers you might encounter manage PNG ok. Side Issues: DCT is integer. This means that if you have zero compression in the DCT process, then you get out what you put in (except if you get overflow, which can be avoided as far as I know). This is not the case in FFT where floating point errors mean you always loose something. Thus JPEG/100% should be at or near perfect (lossless) but does not actually compress. Another area where FFT and DCT become very interesting is in moving picture processing. You can filter video using FFT or DCT in ways that are hard or impossible using spacing filters. This can be good for improving noisy or fussy 'avi' files etc. Best wishes AJ PS - I'll stick the above on my nerd blog nerds-central.blogspot.com, if you have any good links to suggest to expand the subject, please let me know and I shall add them. tedd wrote: Alex: Excuse for top posting: You said: Clear as mud? Well actually, it's simperer than I thought. After your reply, I did some reading on jpeg and found it's simply a transform, not unlike FFT where two-dimensional temporal data is transformed from the time domain to the frequency domain -- very interesting reading. The reverse cosine matrix you mention is probably the discrete cosine transform (DCT) matrix where
Re: [PHP] E_ALL | E_STRICT
tedd wrote: - tul P.S. isn't error_reporting( FATAL | ERROR | WARNING ); supposed to be error_reporting( E_FATAL | E_ERROR | E_WARNING ); ?? Good catch. I'm not sure where I got that -- probably a message from some flounder (Bullwinkle circa 1964). In my newer scripts I use: ini_set('error_reporting', E_ALL | E_STRICT); However, I'm not sure if that's redundant. tedd It isn't redundant :) - E_STRICT isn't covered under E_ALL in PHP5 IIRC. -- life is a game... so have fun. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Where to download APC for windows?
Yeah, sorry, it is missing from a test version of PHP 5.2. In the test version, it is not available, nor is it on snaps. Likely doesn't work. On 8/23/06, Alex Turner [EMAIL PROTECTED] wrote: At the risk of being flamed to death, I thought it was in ext in the standard windows distro. If it is not, I am stuffed if I can remember where I got it from (blush). AJ steve wrote: I used to have a bookmark on where to download APC for windows. Anyone have a link? -- 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] usort within a class
Working perfect, thanks :) I did RTFM but I did miss that :) -Original Message- From: Robert Cummings [mailto:[EMAIL PROTECTED] Sent: Thursday, August 24, 2006 3:46 AM To: Peter Lauri Cc: php-general@lists.php.net Subject: Re: [PHP] usort within a class On Thu, 2006-08-24 at 03:13 +0700, Peter Lauri wrote: Hi, Is it possible to have the compare function in a class? I can not get it to work, this is pseudo code: class A { function getArray() { //dosomethingandgetanarray $array = blabla; usort($array, $this-myCompareFunction); //Or maybe A::myCompareFunction } function myCompareFunction($a, $b) { //return rajraj depending on $a and $b values } } Right now I have keep the compare function outside of the class like this: class A { function getArray() { //dosomethingandgetanarray $array = blabla; usort($array, $this-myCompareFunction); } } function myCompareFunction($a, $b) { //return rajraj depending on $a and $b values } RTF :) usort( $array, array( $this, 'myCompareFunction' ) ) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Where to download APC for windows?
It's a pecl extension, so it is with all the other pecl extensions for Windows at http://pecl4win.php.net/ -Rasmus steve wrote: Yeah, sorry, it is missing from a test version of PHP 5.2. In the test version, it is not available, nor is it on snaps. Likely doesn't work. On 8/23/06, Alex Turner [EMAIL PROTECTED] wrote: At the risk of being flamed to death, I thought it was in ext in the standard windows distro. If it is not, I am stuffed if I can remember where I got it from (blush). AJ steve wrote: I used to have a bookmark on where to download APC for windows. Anyone have a link? -- 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