[PHP] Re: Class/functions question
Paul Goepfert wrote: Hi all, I building a website with PHP. I am going to be using functions to deal with vaildation. I am putting all the methods in a class called Validation. My problem is I do not know how to call the function. Well I shouldn't say that. I know how to call functlions, I just just don't know how to do it in PHP. Let me put it this way. When I write programs in C++/Java I know that I have to do the following steps, create an object reference to the class use the object reference to access the methods. I am almost certain that it is the same thing in PHP. So this is what I did in my web page. ?php if (isset($submit)) { //validation code class Validation { function checkEmpty ($var) { if (empty($var)) { echo YEAH It works!!; } } } else {? . tr td align=leftFirst Name/td td align=left span class=color*/spaninput type=text name=name size=20 ?php $v = new Validation; $v-checkEmpty($_POST[name]); ? /td /tr .. ... = rest of php/html code the else block holds the entire html code for the page Do I have the logic right? Paul Yes and no. Yes, you're calling it correctly, and no because when submit is set, your php scipt will have a class called Validation, and no HTML is being sent to output. On the other hand, when submit is not set, you output a bunch of HTML, but never define your class, and thus will get a couple of errors from it. - tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Class/functions question
Paul Goepfert wrote: I know how to call functlions, I just just don't know how to do it in PHP. Based on the rest of your question, I think you mean methods, not functlions. :-) If you're struggling with syntax, you should take one step at a time. Try this: ?php class myClass { function myMethod() { echo 'pmyMethod()/p'; } } $myObject = new myClass; $myObject-myMethod(); ? That should help you with any syntax problems, but I suspect your problem has more to do with logic than with syntax. if (isset($submit)) { class Validation { /* ... */ } } else { /* ... */ $v = new Validation; $v-checkEmpty($_POST[name]); If the form is submitted, define the class, else use the class. That doesn't sound right... Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Clone of the concurrent users limit of Zend Encoder 4.0 ?
Let me give an example: on fileplanet.com, they have something so called download slot and lines. They limit the number of concurrent downloads. If there are too many users, they will disallow new user to download their files. As I know, they do it with custom HTTP server. Not so custom ... Apache has quite a few bandwidth limiting modules. I use mod_bandwidth to accomplish this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Flatfile forum?
I am interested in creating a flatfile database forum! How would I go about doing this. I know it has been done before! I want to make one from the ground up! ~Nick Couloute co-owner/Web Designer Sidekick2Music.Com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] memory leak when referencing associative arrays
Hi all, I'm having some pain with this process. I'll try to explain it well, my english is little bad... :-) I've got two main loops, handled by timeouts. One loop calls to an object method every half second to do a computation. It reads from external device, creates helper arrays for calculations, and then creates/updates another array where the final calculations are stored. In the other loop, fired by events or some circunstances, I loop thru the calculations array and get the new state for some values. This is not done on the same object. I'm having some memory leak trouble while doing that from within objects using global variables to store the associative arraya, so it seems to me that some references are keep by php to these data I do generate and destroy or update on each computation loop, and that memory it is not freed anytime until program execution ends. If I do the same computation, but I don't do the data lookups to the associative arrays, the memory is normaly fred as expected -I noticed the same trouble with this that depends on how the arrays are handled or accesed before deleting them, when trying to test for that problem-. But if I do the array lookups (i mean with this to do a loop to the array to get all item updates ...) to data is being processed / updated from other objects, the trouble I explained begin... It is somewhat complex to give an example to reproduce the whole thing... Notice I use php4.4.1, and sadly, it is a long running script as it handles some phpgtk interface. I noticed the same results when converting these global variables to local object properties, sadly. It is possible on PHP4 to call on runtime to the garbage collector? possibly via a php extension / C code? Does the php garbage collector keep track of uncollectable objects / zvals as python gc does? It is some way to freed some memory I know it should be really unreferenced? Some thing like a manual force to the garbage collection of a zval -associative array at php level-? Perhaps should I use a different mechanism for storing the associative arrays so I could not suffer this issue? If my trouble is not very clear, please don't hesitate to ask me. Thanks in advance. Regards, Gonzalo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Smart anti-aliasing
Hi: I know how to create a watermark by simply imposing one image on another via imagecopy() or imagecopymerge(). However, is there a way to place a watermark on a image such that the watermark is actually anti-aliased against the background of the base image? For example, please review: http://xn--ovg.com/watermark2 The centered watermark is clearly problematic because it was originally generated with anti-aliasing ON over a white background -- and thus white pixels are shown mixed throughout. I could turn off the original anti-aliasing in generating the original watermark, but then I get a jagged watermark that looks just about as bad. So, what I am asking is there a way to place text on an existing image such that the anti-aliasing adjust (i.e., smart) to the background of the image? One of the possible solutions I was thinking was to create an image and then draw text on top of it, via something like this: ?php Header (Content-type: image/gif); $im = imagecreate (150, 150); $background = ImageColorAllocate ($im, 238, 238, 238); $text_color = ImageColorAllocate ($im, 00, 51, 102); ImageTTFText ($im, 20, 45, 30, 130, $text_color, arial.ttf,copyright 2006); ImageGif ($im); ImageDestroy ($im); ? But, it's not an image that's imported and the background in only one color. So, is there a way to load an image and then draw smart anti-aliased text on top of it? Many thanks to all who reply. tedd -- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Smart anti-aliasing
On Sun, Feb 12, 2006 at 01:40:42PM -0500, tedd wrote: Hi: I know how to create a watermark by simply imposing one image on another via imagecopy() or imagecopymerge(). However, is there a way to place a watermark on a image such that the watermark is actually anti-aliased against the background of the base image? For example, please review: http://xn--ovg.com/watermark2 Create the image you are going to watermark with as a PNG, png doesn't suffer the issues of the antialiasing issues like GIF. You just want to make sure you use the function: imagealphablending(); On the original image before you apply the watermark in your merge. $image = imagecreatefromjpeg($source_file); imagealphablending($image, true) $watermark = imagecreatefrompng($watermark_file); and then just do your imagecopymerge() normally HTH, Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] unsupported binary characters in database,
Hmmm ... I guess that's an idea. Any other ways of dealing with this? -Original Message- From: Webmaster [mailto:[EMAIL PROTECTED] Sent: Saturday, February 11, 2006 6:06 PM To: Mark Steudel Subject: Re: [PHP] unsupported binary characters in database, Mark Steudel wrote: I have the following encryption function: function RC4( $data) { //ecncrypt $data with the key in $keyfile with an rc4 algorithm $pwd = implode('', file(/key.php')); $pwd_length = strlen($pwd); for ($i = 0; $i 255; $i++) { $key[$i] = ord(substr($pwd, ($i % $pwd_length)+1, 1)); $counter[$i] = $i; } for ($i = 0; $i 255; $i++) { $x = ($x + $counter[$i] + $key[$i]) % 256; $temp_swap = $counter[$i]; $counter[$i] = $counter[$x]; $counter[$x] = $temp_swap; } for ($i = 0; $i strlen($data); $i++) { $a = ($a + 1) % 256; $j = ($j + $counter[$a]) % 256; $temp = $counter[$a]; $counter[$a] = $counter[$j]; $counter[$j] = $temp; $k = $counter[(($counter[$a] + $counter[$j]) % 256)]; $Zcipher = ord(substr($data, $i, 1)) ^ $k; $Zcrypt .= chr($Zcipher); } return $Zcrypt; } source: zend code gallery When I encrypt a string that ends in e it shows up as a space in the database, when I pull it back out of the database, the string is missing the e. I tried converting the field in the database to a blob and that didn't work either. My next idea is to add a bin2hex and then a hex2bin: function hex2bin($hexdata) { $bindata=; for ($i=0;$istrlen($hexdata);$i+=2) { $bindata.=chr(hexdec(substr($hexdata,$i,2))); } return $bindata; } source: phil at internetprojectmanagers dot com I was hoping to get some feedback if this is a good way to go about this. Thanks, Mark Just add a different letter to the end of the string. So long as it isn't e it should be ok yeah? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Flatfile forum?
Sorry for the lame question :) But why? Sincerely berber Visit the Weber Sites Today, To see where PHP might take you tomorrow. PHP code examples : http://www.weberdev.com PHP MySQL Forums : http://www.weberforums.com Learn PHP MySQL Playing Trivia : http://www.webertrivia.com -Original Message- From: Nicholas Couloute [mailto:[EMAIL PROTECTED] Sent: Sunday, February 12, 2006 5:35 PM To: php-general@lists.php.net Subject: [PHP] Flatfile forum? I am interested in creating a flatfile database forum! How would I go about doing this. I know it has been done before! I want to make one from the ground up! ~Nick Couloute co-owner/Web Designer Sidekick2Music.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] PHP function called by onclick
Hi, I have a link in my web page and when user click on this link, i would like to execute a PHP function with a parameter. how can i do it ? ex : ?php function lang($language) { $lg = $language; } ? ... A href=?php lang(eng);?test/A but this does not work :-( thanks for help. Alain
[PHP] What's the average color?
Hi gang: Given an image, what's the average color? Here's an example: http://www.degraeve.com/color-palette/ I would think that one could load an image (or a portion of it) and then go through it pixel by pixel to determine what the average RBG content would be. Is there a routine for that? Thanks. tedd -- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Smart anti-aliasing
Create the image you are going to watermark with as a PNG, png doesn't suffer the issues of the antialiasing issues like GIF. You just want to make sure you use the function: imagealphablending(); On the original image before you apply the watermark in your merge. $image = imagecreatefromjpeg($source_file); imagealphablending($image, true) $watermark = imagecreatefrompng($watermark_file); and then just do your imagecopymerge() normally HTH, Curt. Curt: First, thanks for helping. Second, I wasn't using a GIF -- my copyright was a png and my image was a jpg. Third, the following is my code, I think I'm following what you said -- but something is wrong -- the problem remains as shown here: http://xn--ovg.com/watermark3 --- code follows --- ?php $original=imagecreatefromjpeg(mydog.jpg); imagealphablending($original, true); $watermark=imagecreatefrompng(copyright.png); $osx=imagesx($original); $osy=imagesy($original); $wsx=imagesx($watermark); $wsy=imagesy($watermark); imagecopymerge($original, $watermark, ($osx-$wsx)/2, ($osy-$wsy)/2, 0, 0, $wsx, $wsy,100); imagepng($original, trans.png); ? tedd -- http://sperling.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Flatfile forum?
I'm not sure what you mean. 10 different programmers would do this 10 different ways. Personally I'd create a forum-data manipulation API, and then create a frontend to access this. I suggest you abstract the data access routines into an API of its own, so that when you come to your senses, you can change it to a proper db. -Original Message- From: Nicholas Couloute [mailto:[EMAIL PROTECTED] Sent: Sunday, February 12, 2006 5:35 PM To: php-general@lists.php.net Subject: [PHP] Flatfile forum? I am interested in creating a flatfile database forum! How would I go about doing this. I know it has been done before! I want to make one from the ground up! ~Nick Couloute co-owner/Web Designer Sidekick2Music.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
Re: [PHP] PHP function called by onclick
Alain Roger wrote: I have a link in my web page and when user click on this link, i would like to execute a PHP function with a parameter. You'll need to initiate a new request. Browsers don't execute PHP code. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP function called by onclick
At 11:46 AM 2/12/2006, Alain Roger wrote: I have a link in my web page and when user click on this link, i would like to execute a PHP function with a parameter. how can i do it ? If you're using PHP in the usual way as a server-side script, it doesn't run in the same time-frame as user interaction such as clicks. First PHP generates the page and downloads it to the client (browser); then the human interacts with the page. Therefore in order to trigger a PHP function from a human event, you must request a page or submit a form to the server. However, it sounds like what you're really after is an immediate response to a user action, in which case you should be using a client-side scripting language such as JavaScript. If you really do want to execute a PHP function on the server after a client-side interaction, you can: 1) request a page with parameters, such as: a href=http://example.com/smart.php?thing=thang;click here/a 2) submit a form with fields that contain the parameter values: form action=smart.php ... input name=thing value=thang ... / 3) use Ajax technology (XMLHttpRequest) to bring new data into your web page without making a complete reload request. Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php as a content filter?
Hello, I would like to use PHP as a content filter for proxy. Has anyone tried this before? Is there a way to interface PHP with Apache2's proxy mechanism? I can fetch the page myself or let apache do it, but I would like to change the final data before it passes the client. Is it possible with current PHP? Juraj. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Limitation on PEAR : Spreadsheet_Excel_Writer
On Fri, 2006-02-10 at 05:47 +0700, Bagus Nugroho wrote: Hello Everyone, I'm succesfully generate report from mysql table using PEAR : Spreadsheet_Excel_Writer, but I have problem to generate from table which contain long text, the text is not download completely. such as blablabla. it only contain blab How can manipulate PEAR, to get full text on excel sheet. Next time direct your question to the PEAR General List ([EMAIL PROTECTED]) to get a much more useful answer. This is due to the default mode of Spreadsheet_Excel_Writer creating an Excel 7 (or maybe 6) compatible spreadsheet which has these string limitations. If you change the version of spreadsheet it is creating you will not have these problems. I don't know the exact commands or versions to set it to but check the documentation or search the archives of pear-general. I know for sure it is in the pear-general archives as this question has been asked and answered many times. Adam Ashley signature.asc Description: This is a digitally signed message part
[PHP] Re: string lenght?
William Stokes wrote: How can I test whether a string is 1 or 2 digits long? You can use regular expressions: preg_match('/^\d{1,2}$/',$str); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP multi-threading ?
Hi, Is PHP gonna support multi-threading (not multi-processing) capabilities in the future? Even just for the CLI (and CGI) mode.. It would be very helpful to use PHP as server scripting language on linux (rather than perl). ;-) Where can I check the road map of PHP development? -thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP multi-threading ?
Is PHP gonna support multi-threading (not multi-processing) capabilities in the future? Is this what you're after? http://www.php.net/pcntl specifically http://www.php.net/pcntl_fork Where can I check the road map of PHP development? http://blog.justbe.com/articles/2005/11/23/php6-minutes-php-developers-meeting-in-paris http://www.php.net/~derick/meeting-notes.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] string size in bytes
can someone point me in the right direction... i need to know how many bytes are in a string example: $string = blah; string == how many bytes also i need to know how to find out how fast a page renders example; page rendered in 1.114 seconds any help would be greatly appreciated thank you
Re: [PHP] PHP multi-threading ?
Chris wrote: Is this what you're after? http://www.php.net/pcntl specifically http://www.php.net/pcntl_fork Sorry, but no... This is multi-processing, not multi-threading. And it's supported on CLI mode already and not on windows. Where can I check the road map of PHP development? http://blog.justbe.com/articles/2005/11/23/php6-minutes-php-developers-meeting-in-paris http://www.php.net/~derick/meeting-notes.html I'm looking for features list to support in the future.. Anyways, nothing is mentioned on multi-threading there.. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string size in bytes
i need to know how many bytes are in a string example: $string = blah; string == how many bytes Well, if you're willing to ignore all the unicode stuff, you can use strlen() since 1 byte = 1 character. Check that manpage to see if there's a unicode safe version. also i need to know how to find out how fast a page renders example; page rendered in 1.114 seconds microtime(). Call it at the beginning of your script, then at the end, and substract the two values to see how long it took. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] xml-rpc and xml-rpci
Hello, What is the future of the xml-rpc client and server functions in php 5.x? I see the old xml-rpc extension is still marked as expirimental and the newer xml-rpci extention in pecl has not been worked on in 12 months and doesn't have server functionality. I am in the process of porting a large web app to php and I want to use the most updated and maintained xml-rpc implimentation. Thanks, Alex -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: string size in bytes
benifactor wrote: also i need to know how to find out how fast a page renders example; page rendered in 1.114 seconds ?php $start_time = microtime(true); // ... code goes here ... // $end_time = microtime(true); $duration = $end_time - $start_time; echo page rendered in $duration seconds; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] string size in bytes
On Sun, Feb 12, 2006 at 08:13:42PM -0600, Philip Hallstrom wrote: i need to know how many bytes are in a string example: $string = blah; string == how many bytes Well, if you're willing to ignore all the unicode stuff, you can use strlen() since 1 byte = 1 character. Check that manpage to see if there's a unicode safe version. strlen will count bytes but not necessarily characters (if unicode is used) Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Clone of the concurrent users limit of Zend Encoder 4.0 ?
On Sun, Feb 12, 2006 at 10:32:27AM -0500, Mark Charette wrote: Let me give an example: on fileplanet.com, they have something so called download slot and lines. They limit the number of concurrent downloads. If there are too many users, they will disallow new user to download their files. As I know, they do it with custom HTTP server. Not so custom ... Apache has quite a few bandwidth limiting modules. I use mod_bandwidth to accomplish this. I would suggest going this method instead of trying to chisel a round wheel from a square granite rock. Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Smart anti-aliasing
On Sun, Feb 12, 2006 at 03:33:39PM -0500, tedd wrote: Create the image you are going to watermark with as a PNG, png doesn't suffer the issues of the antialiasing issues like GIF. ... First, thanks for helping. No problem Second, I wasn't using a GIF -- my copyright was a png and my image was a jpg. Third, the following is my code, I think I'm following what you said -- but something is wrong -- the problem remains as shown here: I'm not an expert on all this, but it seems that it is because your anti-alias method is against white, you really want it against transparent. I think it might be a bit off topic for discussion here but what does your copyight.png look like? Oh, one thing that might be important is what version of gd is php compiled with? Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Asynchronous Processing
On Sun, Feb 12, 2006 at 12:51:34AM -0200, Gustavo Rios wrote: Hey folks, i am writing a small program in C that does mysql queries. The problem i am facing is that it is done in synchronous fashion. I wonder how php does mysql queries in asynchronous fashion? How do you mean synchronous/asynchronous fashion? PHP programming with mysql is different monster than using the mysql C API. Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Where is Zend
I have had difficulty going to zend.com to download Zend Optimizer for php-4.4.2 since last week. Anybody that have a copy of Zend Optimizer, I would appreciate if you could provide me with a link to your server that I can download a copy. TIA. --roger --- Sign Up for free Email at http://ureg.home.net.my/ --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Where is Zend
Quoting Chris [EMAIL PROTECTED]: Roger Thomas wrote: I have had difficulty going to zend.com to download Zend Optimizer for php-4.4.2 since last week. Have you contacted zend and told them you were having a problem ? I'm sure they have an easy to fill in contact form on their site. I can't even access the site. --roger --- Sign Up for free Email at http://ureg.home.net.my/ --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Where is Zend
last night i've dowloaded zend studio ...zend.com... it's up an runnin'
Re: [PHP] Where is Zend
Roger Thomas wrote: I have had difficulty going to zend.com to download Zend Optimizer for php-4.4.2 since last week. Have you contacted zend and told them you were having a problem ? I'm sure they have an easy to fill in contact form on their site. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php