Re: [PHP] PHP4/Apache2 Content-Length stripped?

2005-01-29 Thread Stoian Ivanov
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 :(

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Returning reference problem

2005-01-29 Thread Jon
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;$icount($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 BRBTree 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 BRBTree 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 BRBTree after add file:/B; 
print_r($tree);} 
  } 
} 
$tree-draw(-1); 
?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: mail problem at interland

2005-01-29 Thread Ben Ramsey
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Regex help

2005-01-29 Thread Michael Sims
[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',
  'df',
  'adfdf',
  'adfsdfff',
  'ff',
  'dfds',
  'dsdf',
  'ddf',
  '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? ;) )

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP4/Apache2 Content-Length stripped?

2005-01-29 Thread Jason Barnett
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-generalw=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=PHPsubmitform=Find+search+plugins

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: [PHP-WIN] Random

2005-01-29 Thread Leif Gregory
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Trying to compile PECL fileinfo on Windows

2005-01-29 Thread Jason Barnett
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-generalw=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=PHPsubmitform=Find+search+plugins

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP4/Apache2 Content-Length stripped?

2005-01-29 Thread Stoian Ivanov
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
:( 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Sessions memory allocation problem

2005-01-29 Thread adrian zaharia
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Regex help

2005-01-29 Thread Bret Hughes
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: [PHP-WIN] Random

2005-01-29 Thread trobi
Leif Gregory  wrote / napsal (a):
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 

 

whatabout uniqid()?
trobi
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Regex help

2005-01-29 Thread Michael Sims
Bret Hughes wrote:
 On Sat, 2005-01-29 at 08:58, Michael Sims wrote:
 [EMAIL PROTECTED] wrote:
 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}$/

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

Thanks...I actually just realized that the parentheses around the first
ampersand are unnecessary (that was a leftover from a previous attempt), so
this is simpler and will work just as well:

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

Or if you don't care about capturing portions of the match and then throwing
them away:

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Permissions on uploaded image don't allow for over writing

2005-01-29 Thread Dave
PHP List,
   The Situation:
   I am building a content management system where users can, among 
other things, upload images into a directory.

   The Problem:
   The image uploads fine, but once it's there, it can't be over 
written. So if a user uploads an image, and then changes his or her mind 
and wants to upload a new version over it, the file upload fails.

   What I've Tried So far:
   I can manually edit the file permissions using chmod and setting the 
files to 777. But of course that's not something I want to have to do 
every time someone uploads a file. I don't know enough about file 
permissions and settings to know how I can set these permissions at the 
time that someone makes the upload.

   The Question:
   How do I allow a user, who is uploading via the web, place an image 
on the server with permissions that allow the file to be over written?

--
Dave Gutteridge
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Returning reference problem

2005-01-29 Thread Jochem Maas
Jon wrote:
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; 
  }
a missing ampersand above might being causing you problems...
function addFile($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;$icount($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 BRBTree 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 BRBTree 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 BRBTree after add file:/B; 
print_r($tree);} 
  } 
} 
$tree-draw(-1); 
?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Trying to compile PECL fileinfo on Windows

2005-01-29 Thread Frank M. Kromann

FileInfo is not available on win32.

- Frank

 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-generalw=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=PHPsubmitform=Find+search+plugins
 
 -- 
 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] Regexp stopped working on my site

2005-01-29 Thread Kristian Hellquist
Hi!

I had a script for parsing text into html, similar to phpBB. Everything
has been working fine until now. Some of my 'pseudotags' like [b] are
still recognized (parsed into b) but some more advanced pattern
matching is not. I haven't changed the code, but the php-version on the
server has changed from default on debian-woody to php-4.3.10. I
haven't made the upgrade myself.

The users of the site reported the bug to me this week, but the users
aren't active so I don't really know when then bug was created. Because
I know it has worked before.

Does any of you have a clue or experience of this? Or has my code been
mysterious altered on the server?

Thanks!
Kristian

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Regexp stopped working on my site

2005-01-29 Thread Marek Kilimajer
Kristian Hellquist wrote:
Hi!
I had a script for parsing text into html, similar to phpBB. Everything
has been working fine until now. Some of my 'pseudotags' like [b] are
still recognized (parsed into b) but some more advanced pattern
matching is not. I haven't changed the code, but the php-version on the
server has changed from default on debian-woody to php-4.3.10. I
haven't made the upgrade myself.
The users of the site reported the bug to me this week, but the users
aren't active so I don't really know when then bug was created. Because
I know it has worked before.
Does any of you have a clue or experience of this? Or has my code been
mysterious altered on the server?
An example of the expressions?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Looking for ideas on scheduling

2005-01-29 Thread Marek Kilimajer
John Nichel wrote:
Chris W. Parker wrote:
Hello,
I'm looking to make a simple scheduler for myself and I'd like to get
some feedback on how to handle the events and their being executed at
the right time.
The two options I've come up with both involve adding a job(s) to
crontab.
1. Individual jobs are added to the users crontab file. This could
result in LOTS of entries in crontab, but less load on the server.
2. There is one job put in the crontab file that is executed every five
minutes. This job will be executing a PHP file that runs through the
database for the current user and checks to see if any events need to go
off at that time. This will result in only one event in crontab with a
greater potential for load on the server.
I'm leaning towards Option 2*. What do you think? What other options do
I have?

I'd go with option 2 also.  Option one wouldn't really be less load, as 
it would be more for cron to parse, and pretty much execute the same 
amount of times.
Option 2 needs cron too, and the parsing is done by php instead of cron, 
so this is not really valid point.

Option 1 also brings into question security and 
access.  To add entries to the users crontab, your script would have to 
have permission to do so (suexec?), and giving it that much access could 
be dangerous.
This is a valid point if php scripts are executed as apache user.
What about option 3:
Use at command to execute php script when the next event should be 
executed. This php script will execute this task and then set itself to 
execute at the time of the next event.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Permissions on uploaded image don't allow for over writing

2005-01-29 Thread Hugh Danaher
Use php's ftp commands.
Hugh
- Original Message - 
From: Dave [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Saturday, January 29, 2005 11:11 AM
Subject: [PHP] Permissions on uploaded image don't allow for over writing


PHP List,
   The Situation:
   I am building a content management system where users can, among 
other things, upload images into a directory.

   The Problem:
   The image uploads fine, but once it's there, it can't be over 
written. So if a user uploads an image, and then changes his or her mind 
and wants to upload a new version over it, the file upload fails.

   What I've Tried So far:
   I can manually edit the file permissions using chmod and setting the 
files to 777. But of course that's not something I want to have to do 
every time someone uploads a file. I don't know enough about file 
permissions and settings to know how I can set these permissions at the 
time that someone makes the upload.

   The Question:
   How do I allow a user, who is uploading via the web, place an image 
on the server with permissions that allow the file to be over written?

--
Dave Gutteridge
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.7.4 - Release Date: 1/25/2005


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.7.4 - Release Date: 1/25/2005
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Trying to compile PECL fileinfo on Windows

2005-01-29 Thread Chris
Jason Barnett wrote:
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?

I tried pear install fileinfo, and got the message No release with 
state equal to: 'stable' found for 'fileinfo'. I installed Pear for the 
sole purpose attempting to get fileinfo compiled. I know *nothing* about 
it. If I'm understanding you correctly there may be a way to modify the 
pear config to compile unstable releases? I'll look into that (hadn't 
occured to me before)

I am just trying to get a version of fileinfo (preferably the latest) 
working on my PHP 5.0.1 on Win2k Pro. This is a test-only server, so I'm 
not too picky about what, or how, but, since I'll probably want more 
PECL extensions in the future, I may as well learn the proper way to do it.

Thanks,
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] best way to handle user authentication, PHP vs. apache

2005-01-29 Thread Raymond Still
Hello;
I'm trying to figure out the best (most secure and most
user friendly, security of primary importance) way to
let a user log-in.
I am setting up a web application (database
application) that will be for private use only and I
want to keep it secure.
As I understand it, using the Apache htaccess method is
secure as there is essentially no communication without
a username and password, but it does lack a little in
flexibility and presentation.
On the other hand, PHP certainly has the edge on
flexibility and presentation, but I have questions
regarding it's security. If you look at the threads
regarding connecting to databases, you often see a
warning to the effect of: store your connection
password etc, outside of the document path in case PHP
fails and your file is displayed unprocessed.
So my question is, how can you count on PHP to log
somebody in, and prevent access to files when PHP may
fail, or the user could just go into the directory
structure and bypass security.
TIA
Ray 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Regular expressions stopped working

2005-01-29 Thread Kristian Hellquist
Hi!

I had a script for parsing text into html, similar to phpBB. Everything
has been working fine until now. Some of my 'pseudotags' like [b] are
still recognized (parsed into b) but some more advanced pattern
matching is not. I haven't changed the code, but the php-version on the
server has changed from default on debian-woody to php-4.3.10. I
haven't made the upgrade myself.

The users of the site reported the bug to me this week, but the users
aren't active so I don't really know when then bug was created. Because
I know it has worked before.

Does any of you have a clue or experience of this? Or has my code been
mysterious altered on the server?

Thanks!
Kristian

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Regex help

2005-01-29 Thread kjohnson
Michael Sims wrote:

  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.

Yup, use this perl regex:

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

[snip]

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


Thanks, Michael! I guess it is time for me to go review those zero-width 
negative look-ahead assertions - don't know how I missed them ;)

And no, not an exam - this is real life. My days as a frolicking schoolboy 
are quite some distance behind me ;)

Kirk

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Permissions on uploaded image don't allow for over writing

2005-01-29 Thread John Hicks
Dave wrote:
PHP List,
   The Situation:
   I am building a content management system where users can, among 
other things, upload images into a directory.

   The Problem:
   The image uploads fine, but once it's there, it can't be over 
written. So if a user uploads an image, and then changes his or her 
mind and wants to upload a new version over it, the file upload fails.

   What I've Tried So far:
   I can manually edit the file permissions using chmod and setting 
the files to 777. But of course that's not something I want to have to 
do every time someone uploads a file. I don't know enough about file 
permissions and settings to know how I can set these permissions at 
the time that someone makes the upload.

   The Question:
   How do I allow a user, who is uploading via the web, place an image 
on the server with permissions that allow the file to be over written?
Check the permissions on the file you have uploaded. Who is the owner? 
Does the user running PHP have the 'w' permission?

Try 'chown'ing the image directory to the user that is running PHP.
-John
-John
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: [PHP-WIN] Random

2005-01-29 Thread Leif Gregory
Hello trobi,

Saturday, January 29, 2005, 12:05:33 PM, you wrote:
t whatabout uniqid()?

He also wanted symbols [EMAIL PROTECTED]*() etc.


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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Creating a webpage from an HTML form via PHP

2005-01-29 Thread Marek Kilimajer
Mike Milligan wrote:
I'm have a PHP created HTML form that I want a user to be able to enter data
into, then see it as the PHP/HTML will format it, then post it to an HTML file.
 I've been trying all day to find something similar on your site, but to no
avail.
I am really new to PHP so I may not have done things the easy way.  The code
below outputs the proper data, but it does it without user concent.  I'd like
to have the user review what they typed prior to posting it to dates.htm.
Any help would be appreciated.
Thanks.
Mike
code as follows:
?php
//-INITIALIZE VARIABLES
$filename = 'dates.htm';
$handle = fopen($filename, rb);
$old = fread($handle, filesize($filename));
fclose($handle);
$date = $_REQUEST['date'] ;
$title = $_REQUEST['title'] ;
$desc = $_REQUEST['desc'] ;
$place = $_REQUEST['place'] ;
$cost = $_REQUEST['cost'] ;
$info = $_REQUEST['info'] ;
//-DISPLAY FORM
if (!isset($_REQUEST['date']))
   {
   ?
   html
   head
   titleAdd New Event/title
   /head
   body bgcolor=#FF
   form method=get action=calendar.php
   table style=border-collapse: collapse; bordercolor=#00
cellspacing=0 cellpadding=2 border=0
   tr
   td valign=top align=left width=18%
   divEvent Date: /div/td
   td valign=top
   div
   input type=text name=date/div/td
   tdnbsp;/td/tr
   tr
   td valign=top align=left width=18%
   divEvent Title: /div/td
   td valign=top
   div
   input type=text name=title/div/td
   tdnbsp;/td/tr
   tr
   td valign=top align=left width=18%
   divEvent Description: /div/td
   td valign=top colspan=2
   divtextarea name=desc rows=15 cols=50%
   /textarea/div/td/tr
   tr
   td valign=top align=left width=18%
   divLocation: /div/td
   td valign=top
   div
   input type=text name=place/div/td
   tdnbsp;/td
   tr
   td valign=top align=left width=18%
   divCost: /div/td
   td valign=top
   div
   input type=text name=cost/div/td
   tdnbsp;/td/tr
   tr
   td valign=top align=left width=18%
   divAdditional Information: /div/td
   td valign=top colspan=2
   divtextarea name=info rows=6 cols=50%
   /textarea/div/td/tr
   /table
   input type=submit value=Add New Event
   input type=reset value=Clear Form name=reset
   /FORM
   /body
   /html
   ?
   }
//CHECK FOR EMPTY FIELDS
elseif (empty($date) || empty($desc))
   {
   header( Expires: Mon, 20 Dec 1998 01:00:00 GMT );
   header( Last-Modified:  . gmdate(D, d M Y H:i:s) .  GMT );
   header( Cache-Control: no-cache, must-revalidate );
   header( Pragma: no-cache );
   ?
   html
   headtitleError/title/head
   body
   h1Incomplete Form/h1
   p
   The date and description of the event are required fields.  Press your BACK
button and try again./p
   /body
   /html
   ?
   }

//---PROCESS FORM
elseif(!empty($date) || !empty($desc))
   {
//SET FORM VARIABLES
   $a = 'strongfont color=#99 size=4 face=Arial, Helvetica,
sans-serif';
   $b = '/font/strong/pblockquotepfont color=#99 face=Arial,
Helvetica, sans-serifstrongb';
   $c = '/b/strong/font/ppfont color=#99 face=Arial,
Helvetica, sans-serif';
   $d = '/font/ppfont color=#99 face=Arial, Helvetica,
sans-serif';
   $e = 'br/fontfont color=#99 face=Arial, Helvetica, sans-serif';
   $f = '/font/p/blockquote';
//JOIN VARIABLES
   $all = array($a,$date,$b,$title,$c,$desc,$d,$place,$e,'Price:
',$cost,$d,'Additional Information: ',$info,$f);
   $new = implode($all);
   $array = array($new,$old);
   $joined = implode($array);
//CONFIRM ADDITION
?html
   head
   titleEntry Verification/title
   /head
   body bgcolor=#FF
   h1Please check your new entry!/h1p
   Correct errors by hitting your BACK button.p
   ?
   echo $new;
   ?
   form method=post action=calendar.php
   input type=submit value=Submit
Put here this, it will passed to your next page:
input type=hidden name=new value=?php echo htmlspecialchars($new) 
?

   /FORM
   /body
   /html
   ?
You are writing to your file right after displaying confirmation. You 
should have here:
} elseif(isset($_REQUEST['new'])) {

Don't forget to check for (non)existance of $_REQUEST['new'] where 
necessary.

//FILE ACCESS  WRITING
//OPEN FILE
   if (!$handle = fopen($filename, 'w'))
  {
  echo Cannot open file ($filename);
  exit;
  }
//WRITE TO FILE
   if (fwrite($handle, $joined) === FALSE)
  {
  echo Cannot write to file ($filename);
  exit;
  }
   echo Success, wrote ($joined) to file ($filename);
   fclose($handle);
   }
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Image Creation and Saving

2005-01-29 Thread NathanielGuy#21
Hello everyone,
I have been troubleshooting a problem with one of my scripts for a
while now, its purpose is to allow a user to upload a file, save it to
the server, resize it into a thumbnail, and save the thumbnail as
well.  In my script all goes well until it comes to saving the images,
the script throws these errors:

Warning: imagepng(): Unable to open
'/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15.png'
for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on
line 91

Warning: imagepng(): Unable to open
'/home/blacknut/public_html/picserv/picserv_mysql/pictures/blacknute/15t.png'
for writing in /home/blacknut/public_html/picserv_mysql/addpic.php on
line 95
Picture ffq was added to our database! The following is what we have
generated and it is what others will see

Here is the important part of the script, if more is needed i can post
it as well.

if ($mime_type == 'jpeg') {
 $new_image = imagecreatefromjpeg($_FILES['new_image']['tmp_name']);
//Create an image refrence
 }
elseif ($mime_type == 'png') {
 $new_image = imagecreatefrompng($_FILES['new_image']['tmp_name']);
//Create an image refrence
 }
elseif ($mime_type == 'gif') {
 $new_image = imagecreatefromgif($_FILES['new_image']['tmp_name']);
//Create an image refrence
 }

  //Image Sizes
list($new_image_width, $new_image_height) =
getimagesize($_FILES['new_image']['tmp_name']);//Get img size
if ($new_image_width  $new_image_height) {//Get thumb size
 $percent_image_size = (200 / $new_image_width);
 }
elseif ($new_image_width  $new_image_height) {
 $percent_image_size = (200 / $new_image_height);
 }
else {
 $percent_image_size = (200 / $new_image_height);
 }
$new_thumb_width = ($percent_image_size * $new_image_width);
$new_thumb_height = ($percent_image_size * $new_image_height);

$new_thumb_file = imagecreatetruecolor($new_image_width, 
$new_image_height);
  imagepng($new_image,
'/home/blacknut/public_html/picserv/picserv_mysql/pictures/' .
strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . '.png');
//Copy pic to user dir as pic_id.png

$new_thumb_image = imagecreatetruecolor($new_thumb_width,
$new_thumb_height); // Create Thumb file
imagecopyresampled($new_thumb_image, $new_image, 0, 0, 0, 0,
$new_thumb_width, $new_thumb_height, $new_image_width,
$new_image_height); //Copy resized to new thumb file
imagepng($new_thumb_image,
'/home/blacknut/public_html/picserv/picserv_mysql/pictures/' .
strtolower($_SESSION['user_sn']) . '/' . $new_pic_filename . 't.png');
//Save image thumb

I am very new to file/image manipulation in php so if you see any
errors, or unnecessary code please tell me.  I'm not quit sure how
everything works, although I do have a theoretical picture of how it
does.  Any comments will be appreciated.

--nathan

-- 
http://www.blacknute.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] design pattern/code generators

2005-01-29 Thread robert mena
Hi All,

I am looking for advice regarding design patterns/code generation in PHP5.

I have a simple code generation tool (written in PHP) to interface with
database.  It works fine for simple situations but seems a little
strange for more complex ones.

Suppose I have a table user (id, name, age) and a table
account(idAccount, idUser, name).  My generator creates a class for each
table and a standard db class.  Each class basically has a set/get
method for each property and some standard insert, delete, update,
search methods

ex.
class user
{
   var $db
   function setName(..)
   function getName()
   function insert()
   {
  $this-db-query(insert into user values...)
   }
...
}

I've omited the other methods/constructor but you can get the picture.

The problem comes when I have to access information the comes from 2+
tables.  Suppose I have to show all users accounts.   Now I end up with
something like this.

$u = new User() ;
$a = new Account() ;
if($u-search())
{
   for($i=0;$i...)
   {
  $idUser = $u-getId() ;  $u-next() ;
   $a-setIdUser($idUser) ;
   if($a-search())
   {
  // print
   }
}

While this works I feel there must be an easier/cleaner way. If I was just
querying the database a join would give me the result in one pass.

In my case what should I do ?  create a new method showAccounts ? 
Where should I put it, in User  or Account class ?

I am interested in advices regarding how to design it better so I can
make the proper adjustments in my generator.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Is this a mysql_connect() bug?

2005-01-29 Thread tom soyer
Hi,

I tried mysql_connect() function, and it won't reture FALSE if
connection failed. Instead, the script times out after 30 seconds and
displays an Fatal error message Maximum execution time of 30 seconds
exceeded. For example:

mysql_connect(' ',' '); returns TRUE because mysql logs in the user as
guest. But mysql_connect('servername','username','wrongpassword');
does not return FALSE. Instead, the script continues until it times
out. Does anyone know if this is a known bug, or can this be fixed by
changing a diretive/setting that I don't know about?

thanks,

Tom

P.S., I am using PHP 4.3.10, Apache 2.0.52(win 32), MSIE 6.0, Mysql
4.0.23-nt, Windows NT 5.1 (XP)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Is this a mysql_connect() bug?

2005-01-29 Thread trlists
On 29 Jan 2005 tom soyer wrote:

 I tried mysql_connect() function, and it won't reture FALSE if
 connection failed. Instead, the script times out after 30 seconds and
 displays an Fatal error message Maximum execution time of 30 seconds
 exceeded. 

I think the issue here is if the server does not respond it hits the 
execution time limit before the function returns.

I use code like this:

$olderr = error_reporting(0);
set_error_handler('ignoreerrhandler');
$dbHandle = mysql_connect($dbHost, $dbUser, $pw);
restore_error_handler();
error_reporting($olderr);

.

function ignoreerrhandler($errno, $errstr, $errfile, $errline) {
return;
}

You can also control the connection timeout with the 
mysql.connect_timeout setting in php.ini.

--
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Is this a mysql_connect() bug?

2005-01-29 Thread tom soyer
Thanks for the error handling code. I think PHP still has a basic
problem. If mysql sever connection times out because wrong username or
password was used, then mysql_connect() should return FALSE. But this
is not the case, why? Is it possible that mysql_connect() could not
read the connection failed message from mysql server?


On Sat, 29 Jan 2005 23:01:46 -0500, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 On 29 Jan 2005 tom soyer wrote:
 
  I tried mysql_connect() function, and it won't reture FALSE if
  connection failed. Instead, the script times out after 30 seconds and
  displays an Fatal error message Maximum execution time of 30 seconds
  exceeded.
 
 I think the issue here is if the server does not respond it hits the
 execution time limit before the function returns.
 
 I use code like this:
 
$olderr = error_reporting(0);
set_error_handler('ignoreerrhandler');
$dbHandle = mysql_connect($dbHost, $dbUser, $pw);
restore_error_handler();
error_reporting($olderr);
 
.
 
function ignoreerrhandler($errno, $errstr, $errfile, $errline) {
return;
}
 
 You can also control the connection timeout with the
 mysql.connect_timeout setting in php.ini.
 
 --
 Tom
 
 --
 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] Is this a mysql_connect() bug?

2005-01-29 Thread Michael Sims
tom soyer wrote:
 Thanks for the error handling code. I think PHP still has a basic
 problem. If mysql sever connection times out because wrong username or
 password was used, then mysql_connect() should return FALSE.

It does, at least for me on PHP 4.3.10 connecting to a local MySQL 4.0.23
server on Debian.  It returns a boolean false, and a warning is triggered:

Warning: mysql_connect(): Access denied for user: '[EMAIL PROTECTED]' (Using
password: YES) in ...

If I give it a server name it cannot connect to (due to a firewall blocking
the connection, for example) it will hang for about 60 seconds then return
false, triggering a warning:

Warning: mysql_connect(): Can't connect to MySQL server on ...

I was going to suggest that you run a cli test script and trace the system
calls to see what's going on but then I saw that you're using Windows.  I'm
not sure if there is an strace/truss equivalent for it (anyone know)?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Is this a mysql_connect() bug?

2005-01-29 Thread Burhan Khalid
tom soyer wrote:
Thanks for the error handling code. I think PHP still has a basic
problem. If mysql sever connection times out because wrong username or
password was used, then mysql_connect() should return FALSE. But this
is not the case, why? Is it possible that mysql_connect() could not
read the connection failed message from mysql server?
I don't think this is case, because I thought that the problem could be 
that the script is timing out before MySQL can return a status code 
(possibly because MySQL is busy; network congestion, etc.)

However, after reading this:
Note: The set_time_limit() function and the configuration directive 
max_execution_time only affect the execution time of the script itself. 
Any time spent on activity that happens outside the execution of the 
script such as system calls using system(), stream operations, database 
queries, etc. is not included when determining the maximum time that the 
script has been running.

I think the problem is not the script timing out, but rather it could be 
this:

Note: Whenever you specify localhost or localhost:port as server, 
the MySQL client library will override this and try to connect to a 
local socket (named pipe on Windows). If you want to use TCP/IP, use 
127.0.0.1 instead of localhost. If the MySQL client library tries to 
connect to the wrong local socket, you should set the correct path as 
mysql.default_host in your PHP configuration and leave the server field 
blank.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php