php-general Digest 29 Jan 2005 18:48:55 -0000 Issue 3256

Topics (messages 207674 through 207683):

Re: PHP4/Apache2 Content-Length stripped?
        207674 by: Stoian Ivanov
        207678 by: Jason Barnett
        207680 by: Stoian Ivanov

Returning reference problem
        207675 by: Jon

Sessions memory allocation problem
        207676 by: adrian zaharia

Re: mail problem at interland
        207677 by: Ben Ramsey

Re: Trying to compile PECL fileinfo on Windows
        207679 by: Jason Barnett

Re: Regex help
        207681 by: Michael Sims
        207683 by: Bret Hughes

Re: [PHP-WIN] Random
        207682 by: Leif Gregory

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 ---
Richard Lynch wrote:

> Stoian Ivanov wrote:
>> I'm writing a wap download script involving dynamic image resizing and so
>> on. I've notice that some phones are quitting in the mids of http
>> transfer.
>> After looking further I found out that headers() is sometimes ignored or
>> stripped. I've googled around and found in a perl forum that flush-ing
>> helps but in PHP4.3.10/Apache2/Gentoo/linux2.6  it seems to not help (at
>> least in my configuration) Is there a work-around or something...
>>            (I'm going to post same question in apache's mailiing list..)
> 
> WILD GUESS
> 
> It sounds like the phones are simply ignoring any image larger than X
> bytes.

Some may ignore most won't. Modern phones have megabytes of memory. Anyway
this is not the problem. There is a fine working custom http server but it
is for windows and since we're migrateing to Linux we/I have to produce a
solution. So I pick up PHP/Apache and now I have a problem :(

--- End Message ---
--- Begin Message --- Stoian Ivanov wrote:
Richard Lynch wrote:


Stoian Ivanov wrote:

I'm writing a wap download script involving dynamic image resizing and so
on. I've notice that some phones are quitting in the mids of http
transfer.
After looking further I found out that headers() is sometimes ignored or
stripped. I've googled around and found in a perl forum that flush-ing
helps but in PHP4.3.10/Apache2/Gentoo/linux2.6  it seems to not help (at
least in my configuration) Is there a work-around or something...
          (I'm going to post same question in apache's mailiing list..)

WILD GUESS

It sounds like the phones are simply ignoring any image larger than X
bytes.


Actually, I thought that size limitations would be an issue as well. Especially for images... and especially for my dinosaur of a phone :)



Some may ignore most won't. Modern phones have megabytes of memory. Anyway this is not the problem. There is a fine working custom http server but it

Wish you would have stated the original problem in the first place then! All is not lost. If I were you I would start by going to http://www.hawhaw.de and checking to see if that fit my needs.


is for windows and since we're migrateing to Linux we/I have to produce a
solution. So I pick up PHP/Apache and now I have a problem :(

If hawhaw doesn't work and you can't bend PHP / Apache to do what you need (at least not quickly enough) you could always try emulating windows on the Linux box and running that custom server. It would totally blow (if it even worked), but hey, it's a last resort.



-- Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY | http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

--- End Message ---
--- Begin Message ---
Jason Barnett wrote:

> Stoian Ivanov wrote:
>> Richard Lynch wrote:
>> 
>> 
>>>Stoian Ivanov wrote:
>>>
>>>>I'm writing a wap download script involving dynamic image resizing and
>>>>so on. I've notice that some phones are quitting in the mids of http
>>>>transfer.
>>>>After looking further I found out that headers() is sometimes ignored or
>>>>stripped. I've googled around and found in a perl forum that flush-ing
>>>>helps but in PHP4.3.10/Apache2/Gentoo/linux2.6  it seems to not help (at
>>>>least in my configuration) Is there a work-around or something...
>>>>           (I'm going to post same question in apache's mailiing list..)
>>>
>>>WILD GUESS
>>>
>>>It sounds like the phones are simply ignoring any image larger than X
>>>bytes.
>> 
> 
> Actually, I thought that size limitations would be an issue as well.
> Especially for images... and especially for my dinosaur of a phone :)
> 
>> 
>> Some may ignore most won't. Modern phones have megabytes of memory.
>> Anyway this is not the problem. There is a fine working custom http
>> server but it
> 
> Wish you would have stated the original problem in the first place then!
>   All is not lost.  If I were you I would start by going to
> http://www.hawhaw.de and checking to see if that fit my needs.
> 
>From what I sow hawhaw is a php library/site/whatever which might be good in
what it is supposed to but the main problem (as stated in the subject) is
Content-Length header beaning removed alldough header ('Content-Length:'
$size) call is made in code
:( 

--- End Message ---
--- Begin Message ---
Starting over since my last thread had too little effort put in it.  I
have this script that should create a multi-demensional array that would
resemble a directory structure.  The problem is that after adding one
element to a "folder" it appears to be creating a new object instead of
adding another item to the current object.  So there can only be one
"file" or "folder" in the parent "folder" with the exception of the top
level. My entire script is below.

Thanks, Jon

<? 
class dir {

  var $name; 
  var $subdirs; 
  var $files; 
  var $num; 
  var $prio;

  function dir($name,$num,$prio) { 
    $this->name = $name; 
    $this->num = $num; 
    $this->prio = $prio; 
    $this->files = array(); 
    $this->subdirs = array(); 
  }

  function addFile($file) { 
    $this->files[] =& $file; 
    return $file; 
  }

  function &addDir($dir) { 
    $this->subdirs[] =& $dir; 
    return $dir; 
  }

  function &findDir($name) { 
      foreach($this->subdirs as $v){ 
        if($v->name == $name) 
          return $v; 
      } 
      return false; 
  }

  function draw($parent) {


echo('d.add('.$this->num.','.$parent.',"'.$this->name."\",".$this->prio.");\n");

  foreach($this->subdirs as $v) { 
      $v->draw($this->num); 
  }

  foreach($this->files as $v) 
      if(is_object($v)) { 
        echo("d.add(".$v->num.",".$this->num.",
\"".$v->name."\",".$v->prio.");\n"); 
      } 
  } 
}


class file {

  var $name; 
  var $prio; 
  var $size; 
  var $num;

  function file($name,$num,$size,$prio) { 
    $this->name = $name; 
    $this->num = $num; 
    $this->size = $size; 
    $this->prio = $prio;

  }

} 
$arFiles = array 
  ( 
  0 => array 
    ( 
    'path' => array 
      ( 
      0 => 'folder1', 
      1 => 'subfolder1', 
      2 => 'file1.ext' 
      ), 
    'length' => 5464, 
    'size' => 8765 
    ), 
  1 => array 
    ( 
    'path' => array 
      ( 
      0 => 'folder1', 
      1 => 'subfolder1', 
      2 => 'file2.ext' 
      ), 
    'length' => 5464, 
    'size' => 8765 
    ), 
  2 => array 
    ( 
    'path' => array 
      ( 
      0 => 'folder1', 
      1 => 'subfolder2', 
      2 => 'file1.ext' 
      ), 
    'length' => 5464, 
    'size' => 8765 
    ), 
  3 => array 
    ( 
    'path' => array 
      ( 
      0 => 'folder2', 
      1 => 'subfolder1', 
      2 => 'file1.ext' 
      ), 
    'length' => 5464, 
    'size' => 8765 
    ) 
  ); 
$prio = array(); 
      for($i=0;$i<count($arFiles);$i++) 
         $prio[$i] = -1;

 $dirnum = count($arFiles); 
 $tree = new dir("/",$dirnum,isset($prio[$dirnum])?$prio[$dirnum]:-1);

 foreach( $arFiles as $filenum => $file) { 
      $depth = count($file['path']); 
      $branch =& $tree; 
      for($i=0; $i < $depth; $i++){ 
        if ($i != $depth-1){ 
          $d =& $branch->findDir($file['path'][$i]); 
echo "<BR><B>Tree after find dir:</B>"; 
print_r($tree); 
          if($d) 
            $branch =& $d; 
          else{ 
            $dirnum++; 
            $d =& $branch->addDir(new dir($file['path'][$i], $dirnum,
(isset($prio[$dirnum])?$prio[$dirnum]:-1))); 
echo "<BR><B>Tree after add dir:</B>"; 
print_r($tree); 
            $branch =& $d; 
          } 
        }else{ 
          $branch->addFile(new
file($file['path'][$i]." (".$file['length'].")",$filenum,$file['size'],
$prio[$filenum]));

echo "<BR><B>Tree after add file:</B>"; 
print_r($tree);} 
      } 
    } 
$tree->draw(-1); 
?>

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

I am testing the following code that pushes a file to the browser 
(Apache 1.3 + PHP 4.3.8 but tested also under several other configs)

Try it with a BIG test1.zip (e.g. 100M in size)

<?php
ignore_user_abort();
set_time_limit(0);

session_save_path('/tmp');
session_start();

$sFileName = 'test1.zip';
$sFileDir = '/var/www/html/';

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment;filename=\"" . $sFileName . "\"");
header("Content-Length: " . filesize($sFileDir . $sFileName));
header('Pragma: cache');
header('Cache-Control: public, must-revalidate, max-age=0');
header('Connection: close');
header('Expires: ' . date('r', time()+60*60));
header('Last-Modified: ' . date('r', time()));

$oFp = fopen($sFileDir . $sFileName, "rb");
$iReadBufferSize = 512;
while (!feof($oFp)) {
        echo fread ($oFp, $iReadBufferSize);
}
fclose ($oFp);
exit;

?>

What i discovered is that if i keep the 2 session initialisation functions
the script will work ONLY if the allocated memory is greater than the size
of the tested file. If i remove the session functions the script works fine
even if the test1.zip file is very big (hundreds of Megs)

Is it something i do wrong? Or is a bug and i should report it?

I mention that I NEED the 2 functions so removing them is not THE solution.
Nor setting in php.ini a huge memory limit :(

Thank you,

Adrian Zaharia

--- End Message ---
--- Begin Message --- David Edwards wrote:
Hi,

I have a fairly simple script written that uses the mail() function on a client site hosted at Interland. I have used a similar script quite a few times before with no problem. However although the script generates no errors, no emails appear at their intended destination. Interland support has not been that helpful and they did suggest I try the '-f' option in the header. That did not work either. Has anyone seen this before, I am running out of ideas. The mail portion of the script is below:

$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: 1\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: $emailfrom\n";

$mailsent = mail($emailto, $subject, $msg, $headers,"-f" . $emailfrom);

Any help would be MUCH appreciated.



If you haven't solved this yet, try sending it via SMTP instead of using mail(). This will require that you send it by first logging into a valid e-mail account and sending it through a socket. PEAR::Mail <http://pear.php.net/package/Mail> can do all this for you.


Take a look at the documentation here: <http://pear.php.net/manual/en/package.mail.mail.intro.php>.

--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com

--- End Message ---
--- Begin Message --- Chris wrote:
Hi,

Are there any places that might have instructions on compiling PECL extensions on Windows? I tried going the pear install <package> route, but fileinfo is not considered stable yet.

Chris

Trying a PEAR or PECL list might do you more good. That being said... are you trying to install packages that are listed as unstable when your configuration tries to install stable releases?


--
Teach a man to fish...

NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://www.php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php
LAZY | http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins

--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
> OK, this is off-topic like every other "regex help" post, but I know
> some of you enjoy these puzzles :)

This isn't an exam question, is it? ;)

> I need a validation regex that will "pass" a string. The string can
> be no longer than some maximum length, and it can contain any
> characters except two consecutive ampersands (&) anywhere in the
> string.
>
> I'm stumped - ideas?

Yup, use this perl regex:

/^(?:(&)(?!&)|[^&]){1,5}$/

Where 5 above is the maximum length of the string.  You can change this to
any positive value and the regex will still work.  Basically it says "look
for 1 to 5 single characters where each either isn't an ampersand, or IS an
ampersand but isn't immediately followed by an ampersand".  The (?!&) is a
zero-width negative look-ahead assertion which is like other assertions such
as "\b" that don't eat up the portions of the string that they match.

Sample code, tested:

$maxLen = 5;

$testStrings = array(
  'a',
  '&g',
  'd&f',
  'adfdf',
  'adfsdfff',
  '&f&f&',
  '&&dfds&',
  'dsdf&',
  'd&&df',
  'dff&&'
);

foreach ($testStrings as $string) {
  if (preg_match("/^(?:(&)(?!&)|[^&]){1,$maxLen}$/", $string)) {
    print "$string matches.\n";
  } else {
    print "$string does not match.\n";
  }
}

Hope this helps you (pass your exam? ;) )

--- End Message ---
--- Begin Message ---
On Sat, 2005-01-29 at 08:58, Michael Sims wrote:
> [EMAIL PROTECTED] wrote:
> > OK, this is off-topic like every other "regex help" post, but I know
> > some of you enjoy these puzzles :)
> 
> This isn't an exam question, is it? ;)
> 
> > I need a validation regex that will "pass" a string. The string can
> > be no longer than some maximum length, and it can contain any
> > characters except two consecutive ampersands (&) anywhere in the
> > string.
> >
> > I'm stumped - ideas?
> 
> Yup, use this perl regex:
> 
> /^(?:(&)(?!&)|[^&]){1,5}$/
> 
> Where 5 above is the maximum length of the string.  You can change this to
> any positive value and the regex will still work.  Basically it says "look
> for 1 to 5 single characters where each either isn't an ampersand, or IS an
> ampersand but isn't immediately followed by an ampersand".  The (?!&) is a
> zero-width negative look-ahead assertion which is like other assertions such
> as "\b" that don't eat up the portions of the string that they match.


Great explanation.  Thanks from one who has not had an exam for over ten
years.

Bret

--- End Message ---
--- Begin Message ---
Hello SargeTron,

Wednesday, January 19, 2005, 10:10:20 AM, you wrote:
S> rand() only returns an int (number), but I would like something
S> like dd75$6*, you know, containing any character. I would like it
S> only to do a certain string ONCE, so there are no duplicates (in a
S> for loop). Hopefully I won't need to do a huge array. Any
S> suggestions?

Take a look at this random e-mail address generator (hasn't everyone
written one of these? <grin>) that I wrote a bit back.

You should be able to see how to do exactly what you want from it.

http://www.devtek.org/software/randmail/index.php

$upperLowerNumber = rand(1,10); controls the so called seed for the
script because I placed constraints on how often uppercase and numbers
could appear.


Cheers,
Leif Gregory 

-- 
TB Lists Moderator (and fellow registered end-user)
PCWize Editor  /  ICQ 216395  /  PGP Key ID 0x7CD4926F
Web Site <http://www.PCWize.com>

--- End Message ---

Reply via email to