php-general Digest 26 Aug 2008 06:24:46 -0000 Issue 5645

Topics (messages 278680 through 278709):

Re: concatenating with "." or ","
        278680 by: Yeti
        278682 by: Robert Cummings
        278687 by: tedd
        278697 by: Bernhard Kohl

Re: alphabetical filenames with readdir
        278681 by: Ed Curtis
        278685 by: tedd

Re: Attributes vs. Accessors
        278683 by: Eric Butera

APC vs. eaccelerator?
        278684 by: David Park
        278688 by: Colin Guthrie
        278689 by: mike
        278690 by: Robert Cummings
        278691 by: Colin Guthrie
        278692 by: Nathan Nobbe
        278693 by: Nathan Nobbe

Re: Auto-generating a graphs Y scale
        278686 by: tedd

Re: newbie OT Eudora
        278694 by: tedd
        278695 by: tedd

comments function being spammed, how do I stop it?
        278696 by: Barnaby Walters
        278698 by: Thiago H. Pojda
        278699 by: David Otton
        278700 by: Jim Lucas

Remote File download is very slow
        278701 by: Shiplu
        278702 by: Shiplu
        278703 by: David Otton
        278704 by: Shiplu
        278705 by: David Otton
        278707 by: Shiplu
        278708 by: Shiplu

Re: [SPAM] [PHP] FIFO files on PHP?
        278706 by: Waynn Lue

render html
        278709 by: VamVan

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 ---
That is why i love this list. Always something new to learn.
What I am still wondering about is if it is faster to use commas or
the "{}" brackets? ( I don't know how that technique is called, since
I'm not a walking dictionary)

Example:

$var = "blah blah";
echo $var,"test";
echo "{$var}test";

--- End Message ---
--- Begin Message ---
On Mon, 2008-08-25 at 17:34 +0200, Yeti wrote:
> That is why i love this list. Always something new to learn.
> What I am still wondering about is if it is faster to use commas or
> the "{}" brackets? ( I don't know how that technique is called, since
> I'm not a walking dictionary)

Here is the order of speed from fastest to slowest:

    commas      - only useful if using echo or print
    .           - concatenation
    "{$foo}"    - interpolation of variables via double quotes
    <<<         - heredoc

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
At 5:34 PM +0200 8/25/08, Yeti wrote:
That is why i love this list. Always something new to learn.
What I am still wondering about is if it is faster to use commas or
the "{}" brackets? ( I don't know how that technique is called, since
I'm not a walking dictionary)

Example:

$var = "blah blah";
echo $var,"test";
echo "{$var}test";

One of the other things about this list is that sometimes people actually test their ideas.

It's not that big of a deal to set up a test to show which is faster. So, if you would like to know, then write a test for it.

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test for Tedd</title>
</head>
<body>
<?php

# Ok tedd, if you insist ..

$iterations = 20000;
$test_string = md5('test'); // a 32 character string
$test_array = array();
for ($i = 0; $i < $iterations; ++$i) $test_array[] = str_shuffle($test_string);
# <--------- Comma
ob_start();
$s_t = microtime(true);
foreach ($test_array as $array_value) {
        echo $test_string, $array_value;
}
$e_t = microtime(true);
ob_end_clean();
echo '<p>Comma took: <strong>'.(abs($e_t -
$s_t)*1000/$iterations).'</strong> milliseconds on average.</p>';
# <---------- Concatenation
ob_start();
$s_t = microtime(true);
foreach ($test_array as $array_value) {
        echo $test_string.$array_value;
}
$e_t = microtime(true);
ob_end_clean();
echo '<p>Concatenation: <strong>'.(abs($e_t -
$s_t)*1000/$iterations).'</strong> milliseconds on average.</p>';
# <---------- Interpolation
ob_start();
$s_t = microtime(true);
foreach ($test_array as $array_value) {
        echo "{$test_string}{$array_value}";
}
$e_t = microtime(true);
ob_end_clean();
echo '<p>Interpolation: <strong>'.(abs($e_t -
$s_t)*1000/$iterations).'</strong> milliseconds on average.</p>';
# <---------- HereDoc
ob_start();
$s_t = microtime(true);
foreach ($test_array as $array_value) {
           echo <<<TEST
                $test_string$array_value
TEST;
}
$e_t = microtime(true);
ob_end_clean();
echo '<p>Heredoc: <strong>'.(abs($e_t -
$s_t)*1000/$iterations).'</strong> milliseconds on average.</p>';
/*
I usually get results similar to these ones:

Comma took: 0.0191585 milliseconds on average.
Concatenation: 0.0195376 milliseconds on average.
Interpolation: 0.0279227 milliseconds on average.
Heredoc: 0.0247411 milliseconds on average.

*/
?>
</body>
</html>

--- End Message ---
--- Begin Message ---
Ed Curtis wrote:
Is there a way to make readdir output filenames alphabetically?

Thanks,

Ed


Never mind. I figured out how to do it using an array and sort.

--- End Message ---
--- Begin Message ---
At 10:45 AM -0400 8/25/08, Ed Curtis wrote:
Is there a way to make readdir output filenames alphabetically?

Thanks,

Ed

Sure -- put the results in an array and then sort() or natsort() it.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Mon, Aug 25, 2008 at 11:01 AM, Richard Heyes <[EMAIL PROTECTED]> wrote:
>>> Curious. Which do you prefer and why?
>
> Accessor methods. They allow for changes in the future that may well
> be unforeseen at the moment. Or at least that would be my response
> with PHP4. Now with the __get and __set built-in accessors, that's
> pretty much taken care of.
>
>> I access directly to avoid pointless method calls for reads.  It'd be
>> nice if there were a way to define a public read-only mode,
>
> Not tried this, but you may be able to do it with a __get method that
> doesn't return anything.
>
> --
> Richard Heyes
> http://www.phpguru.org
>

Oh it'd be possible, but all this does is distract me from the purpose
of my code.  I am easily distracted though seeing as I'm writing this
out in the first place!  :)  A simple note in the docs saying this is
read only is enough for me.  You'd have to put a note in there about
how it will throw an exception upon write anyways.  *shrug*  But again
these are very specific pieces of code that are getting public
properties.

This goes in line with all the other coding practices I try to use.
Registry over singleton, notification queue over direct observer, etc.
 Let something else do the heavy lifting when possible.


class readonlytest {

        private $readonly = array('meh');
        private $meh = 'meh value';
        public $blah;
        
        private function __get($name) {
                if (in_array($name, $this->readonly)) {
                        return $this->{$name};
                }
        }
        
        private function __set($name, $value) {
                if (in_array($name, $this->readonly)) {
                        throw new Exception("The property {$name} is read 
only");
                }
                $this->{$name} = $value;
        }

}

$test = new readonlytest;

echo "Pre-blah:";
var_dump($test->blah);
$test->blah = 'blah';
echo "Post-blah:";
var_dump($test->blah);

echo "Reading meh:";
var_dump($test->meh);
try {
        $test->meh = 'meh';
} catch (Exception $e) {
        echo "Exception:";
        var_dump($e);
}
var_dump($test->meh);

But why would I want to clutter up my class with that nonsense?

Output:

Pre-blah:
null
Post-blah:
string 'blah' (length=4)
Reading meh:
string 'meh value' (length=9)
Exception:
object(Exception)[2]
  protected 'message' => string 'The property meh is only' (length=24)
  private 'string' => string '' (length=0)
  protected 'code' => int 0
  protected 'file' => string '/Users/eric/Sites/blah.php' (length=26)
  protected 'line' => int 18
  private 'trace' =>
    array
      0 =>
        array
          'file' => string '/Users/eric/Sites/blah.php' (length=26)
          'line' => int 36
          'function' => string '__set' (length=5)
          'class' => string 'readonlytest' (length=12)
          'type' => string '->' (length=2)
          'args' =>
            array
              0 => string 'meh' (length=3)
              1 => string 'meh' (length=3)
string 'meh value' (length=9)

--- End Message ---
--- Begin Message ---
Hi All,

I currently run a phpBB site using phpBB v. 2.0.22 and PHP4.  We'd like to
install either APC or eaccelerator to speed up the site's performance.  I'm
not sure whether we should choose APC or eaccelerator since I'm a newbie to
PHP caching.

Which do you think is better - APC or eacclerator?  Here are some criteria
that I'd like to use in evaluating APC vs. eacclerator: 1) compatibility, 2)
stability and 3) speed.

Some older posts on the net (from 2006) complained about incompatibilities
between APC/eacclerator and phpBB and about crashes of APC/eacclerator.  I'm
hoping that these problems have been cleared up by now.

Thanks for your help!

David

--- End Message ---
--- Begin Message ---
David Park wrote:
Hi All,

I currently run a phpBB site using phpBB v. 2.0.22 and PHP4.  We'd like to
install either APC or eaccelerator to speed up the site's performance.  I'm
not sure whether we should choose APC or eaccelerator since I'm a newbie to
PHP caching.

Which do you think is better - APC or eacclerator?  Here are some criteria
that I'd like to use in evaluating APC vs. eacclerator: 1) compatibility, 2)
stability and 3) speed.

Some older posts on the net (from 2006) complained about incompatibilities
between APC/eacclerator and phpBB and about crashes of APC/eacclerator.  I'm
hoping that these problems have been cleared up by now.

I'm a pretty happy APC user right now.

Amoung other things, I do run a not-overly-busy phpBB site under it and I've not had any complaints.

For me APC was just a drop in task and while I did keep a careful look out for any issues, it was all rather painless. I went for APC due to the fact that there were some interesting Summer of Code projects proposed that should allow for even more interesting stuff in the future :)

Also APC has an extension that you can turn on that gets the status of file uploads, so if you operate a site where users can upload large files, this is a nice feature for interactive displays.

Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


--- End Message ---
--- Begin Message ---
On 8/25/08, David Park <[EMAIL PROTECTED]> wrote:

> Some older posts on the net (from 2006) complained about incompatibilities
> between APC/eacclerator and phpBB and about crashes of APC/eacclerator.  I'm
> hoping that these problems have been cleared up by now.

2006 is a century ago in open source time :P

i was using turck mmcache which turned into eaccelerator for a while.
i also tried xcache. however, i switched to APC over a year ago now.
it's maintained by core php developers, so i figure it's the best as
it would receive little "perks" due to new features/fixes being put in
to the core php code and the developers implementing them working on
APC.

i have never done any benchmarks or anything, but i'm pretty sure
they're all relatively close speed-wise. stability-wise i've never had
an issue with APC..

the file upload stuff would be cool except i need something that
supports multiple webservers, not shared memory on a specific host.

besides, i think i've heard PHP6 will have a built in byte-code cache
already, and i am sure it will use APC/portions of APC (why not, it's
already there)

--- End Message ---
--- Begin Message ---
On Mon, 2008-08-25 at 10:24 -0700, David Park wrote:
> Hi All,
> 
> I currently run a phpBB site using phpBB v. 2.0.22 and PHP4.  We'd like to
> install either APC or eaccelerator to speed up the site's performance.  I'm
> not sure whether we should choose APC or eaccelerator since I'm a newbie to
> PHP caching.
> 
> Which do you think is better - APC or eacclerator?  Here are some criteria
> that I'd like to use in evaluating APC vs. eacclerator: 1) compatibility, 2)
> stability and 3) speed.
> 
> Some older posts on the net (from 2006) complained about incompatibilities
> between APC/eacclerator and phpBB and about crashes of APC/eacclerator.  I'm
> hoping that these problems have been cleared up by now.

Many years ago now I was using PHPAccelerator... when it stopped being
updated I made the switch. At that time I checked out both APC and
eaccelerator and found eaccelerator to be the faster for my needs.
Recently, and I don't recall the link, I read something that indicated
eaccelerator is faster than APC. Mileage may vary though depending on
individual usage patterns. Either way, I'd say they are probably fairly
interchangeable.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
mike wrote:
besides, i think i've heard PHP6 will have a built in byte-code cache
already, and i am sure it will use APC/portions of APC (why not, it's
already there)


Oh yeah, that was another reason I went for APC... forgot about that one :)

Col


--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


--- End Message ---
--- Begin Message ---
On Mon, Aug 25, 2008 at 12:23 PM, Colin Guthrie <[EMAIL PROTECTED]>wrote:

> mike wrote:
>
>> besides, i think i've heard PHP6 will have a built in byte-code cache
>> already, and i am sure it will use APC/portions of APC (why not, it's
>> already there)
>>
>
>
> Oh yeah, that was another reason I went for APC... forgot about that one :)


yea; apc is supposed to be bundled w php6 (thats what i hrd from one of the
apc devs when i was in dc).

-nathan

--- End Message ---
--- Begin Message ---
On Mon, Aug 25, 2008 at 12:02 PM, Robert Cummings <[EMAIL PROTECTED]>wrote:

> On Mon, 2008-08-25 at 10:24 -0700, David Park wrote:
> > Hi All,
> >
> > I currently run a phpBB site using phpBB v. 2.0.22 and PHP4.  We'd like
> to
> > install either APC or eaccelerator to speed up the site's performance.
>  I'm
> > not sure whether we should choose APC or eaccelerator since I'm a newbie
> to
> > PHP caching.
> >
> > Which do you think is better - APC or eacclerator?  Here are some
> criteria
> > that I'd like to use in evaluating APC vs. eacclerator: 1) compatibility,
> 2)
> > stability and 3) speed.
> >
> > Some older posts on the net (from 2006) complained about
> incompatibilities
> > between APC/eacclerator and phpBB and about crashes of APC/eacclerator.
>  I'm
> > hoping that these problems have been cleared up by now.
>
> Many years ago now I was using PHPAccelerator... when it stopped being
> updated I made the switch. At that time I checked out both APC and
> eaccelerator and found eaccelerator to be the faster for my needs.
> Recently, and I don't recall the link, I read something that indicated
> eaccelerator is faster than APC. Mileage may vary though depending on
> individual usage patterns. Either way, I'd say they are probably fairly
> interchangeable.


i think i read this recently too, because we use eac at work (i was scoping
it out).  ive used only apc in that past myself.  after reading around a
little a couple of weeks back, and poking around in the eac source, it looks
like eac is pretty feature rich, and possibly faster at this point.
however, i suspect, with the growing popularity of apc, the tide will turn
at some point and apc will be the best opcode caching solution.

-nathan

--- End Message ---
--- Begin Message ---
At 3:52 PM +0100 8/25/08, Richard Heyes wrote:
 > First, the y scale is the one that runs up and down and not right to left.
  :-)


Yes I know.

 Second, the physical length of the y scale should be static and whatever you
 want it to be (i.e., 5 inches, 10 inches, etc.).

That gives a poor range IMO. JPGraph generates one which is better,
since it doesn't correspond exactly to the highest value. For example
for a bar graph with the value 2,6,7,7,4,8,7 it would (might) go from
one to ten and then plot appropriate marks.

This is really what I want to achieve. But it should be able to
accommodate all sorts of values, from small to large.

--
Richard Heyes


Richard:

There's no poor, nor good, range for that.

If it was me I might take the maximum x and y coordinates and use values that are 10 percent larger for the axis. The goodness or poorness depends upon the data and how well that data is shown for evaluation.

The point is that the way to create a graph is to figure out the maximum values, determined from the points, and then create axis to show that.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
At 8:47 AM -0500 8/25/08, Philip Thompson wrote:
Apple Mail. It's by far the best email app I've seen/used. =D You can hide/view headers as desired.

~Philip


Philip:

Of course, I have Apple's Mail and have used it, but I still like Eudora. However, I think I see the writing on the wall.

I'll look at Apple's Mail again, but I would like to keep all my emails (1995 to present) as Eudora does.

Eudora is actually my word processor of choice now.

Cheers,

tedd


--

-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
At 9:53 AM -0400 8/25/08, Wolf wrote:
Really, they still make Eudora? Or is this an old copy on the MacIntosh IIe that you are running. ;)

Wolf

Wolf:

Yes, Eudora is still around, but it's open source now. However, I haven't received/heard of an update in a long time. The critter is dated, but still works great.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

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

Hi there!

my comments function for my website (at www.waterpigs.co.uk/php/ phpTest.php) is being spammed, what would be your sugguestions of a way to deal with it? I was thinking of something to do with searching the strings of comments contained in the database for rude words, etc, but I'm unsure as to how to do it.

Any help would be appreciated greatly.

Thanks,
Barnaby
_____________________
www.waterpigs.co.uk
[EMAIL PROTECTED]




--- End Message ---
--- Begin Message ---
Captcha?

On 8/25/08, Barnaby Walters <[EMAIL PROTECTED]> wrote:
>
>
> Hi there!
>
> my comments function for my website (at www.waterpigs.co.uk/php/phpTest.php)
> is being spammed, what would be your sugguestions of a way to deal with it?
>  I was thinking of something to do with searching the strings of comments
> contained in the database for rude words, etc, but I'm unsure as to how to
>  do it.
>
> Any help would be appreciated greatly.
>
> Thanks,
> Barnaby
> _____________________
> www.waterpigs.co.uk
> [EMAIL PROTECTED]
>
>
>
>


-- 
Thiago Henrique Pojda

--- End Message ---
--- Begin Message ---
2008/8/25 Barnaby Walters <[EMAIL PROTECTED]>:

> my comments function for my website (at www.waterpigs.co.uk/php/phpTest.php)
> is being spammed, what would be your sugguestions of a way to deal with it?
>  I was thinking of something to do with searching the strings of comments
> contained in the database for rude words, etc, but I'm unsure as to how to
>  do it.

Akismet. One of the classes for interfacing with it is here:

http://www.achingbrain.net/stuff/php/akismet

-- 

http://www.otton.org/

--- End Message ---
--- Begin Message ---
Barnaby Walters wrote:

Hi there!

my comments function for my website (at www.waterpigs.co.uk/php/phpTest.php) is being spammed, what would be your sugguestions of a way to deal with it? I was thinking of something to do with searching the strings of comments contained in the database for rude words, etc, but I'm unsure as to how to do it.

Any help would be appreciated greatly.

Thanks,
Barnaby
_____________________
www.waterpigs.co.uk
[EMAIL PROTECTED]





Here is the function that I added to a generic guest book script. It works great for me. I have a predefined list of sexual, pharmaceutical, rude, vulgar, etc... words that I have in the spamwords.dat file.

function is_spam($str) {
  $data = './data/spamwords.dat';
  $spamword = file($data);
  $str = strtolower($str);
  foreach ($spamword AS $word) {
    $word = trim($word);
    if ( ! empty($word) &&                             // Blank line
         strpos($word, 0, 1) != '#' &&                 // Comment line
         strpos($str, strtolower($word)) !== false ) { // Compare
      return true;
    }
  }
  return false;
}

Just setup the spamwords.dat file to have each word/string that you want to reject for separated on each line.

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare


--- End Message ---
--- Begin Message ---
Hello folks,
I have written a method to download file from remote server. normally those
fill will be huge in size. from 1MB to 400MB.
I am using fsockopen and curl to download the file.
But the problem is its too slow.
Very very slow.
The code can be found on http://nopaste.info/55817730b3.html
I just put the method body.

Can any one help me on increasing the speed?

Thanks in Advance
--
http://talk.cmyweb.net/
http://twitter.com/shiplu

--- End Message ---
--- Begin Message ---
Okay, I attached the code. Not everyone will click the paste bin link. :P

the code is a downloading function of a class.
the class has some methods need to be explained.
1) $this->debugMessage, it sends message to a call back function to a caller

2) $this->doCallback, sends the amount of bytes read to a call back function
to the caller\
3) $this->localfilename is the file where the remote file will be downloaded

4) $this->lfp is localfilepointer
5) read_chunk_size = 512
6) $headers is a predefined array of headers
7) $postdata is the url encoded data to send by post method.

Here is the code....
_________________________________________________________________________
    $this->lfp = fopen($this->localfilename,"wb");

            if($this->lfp===false){return false;}

            if(function_exists('fsockopen')){
                  $pu = parse_url($this->download_url);
                  $request="POST {$pu['path']} HTTP/1.1\r\n";
                  $request.="Host: {$pu['host']}\r\n";
                  $request.="Content-type:
application/x-www-form-urlencoded\r\n";
                  $request.=implode("\r\n",$headers)."\r\n";
                  $request.="Connection: close\r\n";
                  $request.="Content-length: ".strlen($postdata)."\r\n\r\n";


                  $sock = fsockopen($pu['host'],80,$errno,$errstr);

                  fwrite($sock,$request);

                  $this->debugMessage("Headers Sent\r\n".$request);

                  fwrite($sock,$postdata);

                  $headers="";
                  do{
                        $headers.=fread($sock,128);
                  }while(strpos($headers,"\r\n\r\n")===false);

                  $pos = strpos($headers,"\r\n\r\n");
                  $headers = split("\r\n\r\n",$headers);
                  $headers = $headers[0];

                  $this->debugMessage("Headers recieved".$headers."\r\n");
                  $this->debugMessage("Downloading started. . .\r\n");
                  $content = substr($headers,$pos+4);
                  if($content!==false){
                        $this->doCallback(fwrite($this->lfp,$content));
                  }
                  while(!feof($sock)){

$this->doCallback(fwrite($this->lfp,fread($sock,$this->read_chunk_size)));

                  }
                  $this->debugMessage("Download finished\r\n");

                  fclose($sock);

            }else {
                  $ch = curl_init();
                  curl_setopt($ch, CURLOPT_URL,$this->download_url);
                  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                  if(!empty($this->cookiefile)){
                        curl_setopt($ch, CURLOPT_COOKIEFILE,
$this->cookiefile);
                        curl_setopt($ch, CURLOPT_COOKIEJAR,
$this->cookiefile);
                  }
                  curl_setopt($ch,CURLOPT_FILE,$this->lfp);
                  curl_setopt($ch, CURLOPT_POST,1);
                  curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata);

                  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

                  curl_exec($ch);
                  curl_close($ch);
            }
            fclose($this->lfp);
_________________________________________________________________________

-- 
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu

--- End Message ---
--- Begin Message ---
2008/8/25 Shiplu <[EMAIL PROTECTED]>:
> Hello folks,
> I have written a method to download file from remote server. normally those
> fill will be huge in size. from 1MB to 400MB.
> I am using fsockopen and curl to download the file.

> But the problem is its too slow.
> Very very slow.

What happens when you remove the first half of the if(), the bit that
relies on fsockopen(), and only use curl?

-- 

http://www.otton.org/

--- End Message ---
--- Begin Message ---
Nothing works.
I was using curl actually.
It was hell slow.
Then I added the fsockeopen option.
Its slwo too.
now I am thinking to add socket_* functions.
But If dont know what is the problem how can I resolve it.
change scheme may not solve it. :(

-- 
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu

--- End Message ---
--- Begin Message ---
2008/8/25 Shiplu <[EMAIL PROTECTED]>:
> Nothing works.
> I was using curl actually.
> It was hell slow.
> Then I added the fsockeopen option.
> Its slwo too.
> now I am thinking to add socket_* functions.
> But If dont know what is the problem how can I resolve it.
> change scheme may not solve it. :(

Ok, lets start by getting some accurate data.

Here's a script that downloads a 6Mb MP3:

<?php

$fp = fopen( "temp1.mp3", "wb" );
$ch = curl_init();

curl_setopt( $ch, CURLOPT_URL, "http://gramotunes.com/Life_is_Long.mp3"; );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $ch, CURLOPT_FILE, $fp );

curl_exec( $ch );

curl_close( $ch );

Save it as "download.php", and run the following two commands:

time php download.php
time wget http://gramotunes.com/Life_is_Long.mp3

I get

real    0m6.105s

and

real    0m5.927s

If your results are about equal, then the problem is not with PHP.

-- 

http://www.otton.org/

--- End Message ---
--- Begin Message ---
They take same time.
let me tell you how my code works.
it download a file and in the same time it reports a progress by a call back
function.
this script is called from web. not console. it provides live debug
messages.
I'll give you a time wise debug log.

-- 
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu

--- End Message ---
--- Begin Message ---
here are the log messages. see the timinings.

[2008-08-25 18:09:05.21780900]started downloading in
Live_In_Cuba_-_Louder_Than_War.part1.rar
[2008-08-25 18:09:05.60409200]Headers Sent
POST /files/108041147/1693469/Live_In_Cuba_-_Louder_Than_War.part1.rar HTTP/1.1
Host: rs246tl3.rapidshare.com
Content-type: application/x-www-form-urlencoded
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16
Accept: 
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-language: en-us,en;q=0.7,bn;q=0.3
Accept-charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: close
Content-length: 9
[2008-08-25 18:09:06.06572600]Headers recievedHTTP/1.1 200 OK
Date: Tue, 26 Aug 2008 00:09:05 GMT
Connection: close
Content-Type: application/octet-stream
Accept-Ranges: bytes
Content-Disposition: Attachment;
filename=Live_In_Cuba_-_Louder_Than_War.part1.rar
Content-Length: 104857600
[2008-08-25 18:09:06.06588900]Downloading started. . .
[2008-08-25 18:09:11.35468500]Downloaded 262144 bytes
[2008-08-25 18:09:15.26531200]Downloaded 524288 bytes
[2008-08-25 18:09:20.83112600]Downloaded 786432 bytes
[2008-08-25 18:09:26.26205800]Downloaded 1048576 bytes
[2008-08-25 18:09:31.78788500]Downloaded 1310720 bytes
[2008-08-25 18:09:37.27102800]Downloaded 1572864 bytes
[2008-08-25 18:09:42.72577600]Downloaded 1835008 bytes
[2008-08-25 18:09:48.08036500]Downloaded 2097152 bytes
[2008-08-25 18:09:53.46441000]Downloaded 2359296 bytes
[2008-08-25 18:09:58.91484500]Downloaded 2621440 bytes
[2008-08-25 18:10:04.42331800]Downloaded 2883584 bytes
[2008-08-25 18:10:10.00015700]Downloaded 3145728 bytes
[2008-08-25 18:10:15.30924700]Downloaded 3407872 bytes


see the speed?? Its too slow.


-- 
Blog: http://talk.cmyweb.net/
Follow me: http://twitter.com/shiplu

--- End Message ---
--- Begin Message ---
On Wed, Jul 2, 2008 at 1:22 AM, Chris Scott <[EMAIL PROTECTED]> wrote:

> > -----Original Message-----
> > From: Waynn Lue [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, July 01, 2008 11:06 PM
> > To: [EMAIL PROTECTED]
> > Subject: [SPAM] [PHP] FIFO files on PHP?
> > Importance: Low
> >
> > I'm trying to build a queue out using FIFO files (someone on the MySQL
> > list suggested checking them out instead of using the database), but
> > I'm running into a problem because of the synchronous fwrite call.
> > Here's the code:
> >
> >   $fifoFile = '/tmp/fifo';
> >   if (!file_exists($fifoFile)) {
> >     posix_mkfifo($fifoFile, 0600);
> >   }
> >   $fp = fopen($fifoFile, "w");
> >   fwrite($fp, "content");
> >   fclose($fp);
> >
> > But this will block until something actually reads the pipe.  Is there
> > any way to write to the pipe, then go away as opposed to waiting until
> > something consumes it?  Otherwise, I may just go back to a database
> > table.
> >
> > Thanks,
> > Waynn
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
> Fifo nodes are equivalent to a pipe (|) and have no size on the file
> system and therefore the write won't finish until some process reads
> from the node. See the man page http://linux.die.net/man/7/fifo .
>
Wow, my mail client filtered these responses so I only just noticed them--I
thought there were no responses.  Thanks for letting me know, I ended up
using threads to accomplish something similar.

--- End Message ---
--- Begin Message ---
hello,

i have html tags in the bod of text like:

$body = "hello<br/><ul>ier</ul>hellohello";

print $body;

Some how it does not render html properly in a html page , what might be
going wrong?  <br> still get displayed as <br> instead of line breaks.

How can I render my HTML properly. Please note that it happens in  my cms.

Thanks

--- End Message ---

Reply via email to