php-general Digest 13 Feb 2006 03:43:12 -0000 Issue 3960

Topics (messages 230267 through 230291):

Flatfile forum?
        230267 by: Nicholas Couloute
        230272 by: Weber Sites LTD
        230276 by: Rory Browne

memory leak when referencing associative arrays
        230268 by: Gonzalo MC

Smart anti-aliasing
        230269 by: tedd
        230270 by: Curt Zirzow
        230275 by: tedd

Re: unsupported binary characters in database,
        230271 by: Mark Steudel

PHP function called by onclick
        230273 by: Alain Roger
        230277 by: Chris Shiflett
        230278 by: Paul Novitski

What's the average color?
        230274 by: tedd

php as a content filter?
        230279 by: Juraj Bednar

Re: Limitation on PEAR : Spreadsheet_Excel_Writer
        230280 by: Adam Ashley

Re: string lenght?
        230281 by: Eli

PHP multi-threading ?
        230282 by: Eli
        230283 by: Chris
        230286 by: Eli

test
        230284 by: benifactor

string size in bytes
        230285 by: benifactor
        230287 by: Philip Hallstrom
        230289 by: Eli
        230290 by: Curt Zirzow

xml-rpc and xml-rpci
        230288 by: Alex Duggan

Re: Clone of the concurrent users limit of Zend Encoder 4.0 ?
        230291 by: Curt Zirzow

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message --- 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

--- End Message ---
--- Begin Message ---
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: [email protected]
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

--- End Message ---
--- Begin Message ---
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: [email protected]
> 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
>
>

--- End Message ---
--- Begin Message ---
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.

--- End Message ---
--- Begin Message ---
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/

--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
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/

--- End Message ---
--- Begin Message ---
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;$i<strlen($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?

--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
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/

--- End Message ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
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/

--- End Message ---
--- Begin Message ---
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.

--- End Message ---
--- Begin Message ---
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

Attachment: signature.asc
Description: This is a digitally signed message part


--- End Message ---
--- Begin Message ---
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);

--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---

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

--- End Message ---
--- Begin Message ---
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!

--- End Message ---
--- Begin Message ---
test

--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
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.
--- End Message ---
--- Begin Message ---
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";
?>

--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
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

--- End Message ---
--- Begin Message ---
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

--- End Message ---

Reply via email to