Re: [PHP] Security Concerns with Uploaded Images:

2006-05-15 Thread Jason Wong
On Monday 15 May 2006 10:53, Richard Lynch wrote:
 On Sat, May 13, 2006 5:11 pm, Nick Wilson wrote:
  are there any security concerns with uploaded images?

 YES!!!

Just what are the security concerns exactly? Assuming we're only focusing 
on attacks to the webserver[1] then I can only think of 2 (are there 
anymore?):

1) the uploaded file is a binary executable
2) the uploaded file is a script (perl/php/python/etc)

In the case of (1), the attacker, having uploaded a malicious file would 
then have to find some way of getting it executed. On a un*x-like system 
the uploaded file would/should not have the executable bit set, so the 
attacker would have to find a way to set that bit AND to execute it. This 
would be very unlikely.

In the case of (2), if the script relies on its shebang line to execute 
then it would have to overcome the same obstacles as (1) for it to get 
executed. Otherwise, eg in the case of PHP, it would have to rely on the 
web application to include()[2] or eval() the malicious file. Since it is 
supposed to be an image file then the web developer would/should not 
intentionally use include()/eval() on such files. However in poorly 
written applications where input to include()/eval() can come from the 
user/attacker and are not properly sanitised it is then that the attacker 
will have a field day.

To summarise: the uploading of an executable masquerading as an image file 
can be protected against via coding at the application level

  My thought is that it wouldnt be too hard to have some kind of script
  masquerade as a gif file, and perhaps cause damage.

More worrying and much harder to protect against are zero-day exploits 
against the graphics libraries themselves - libpng, libtiff, gd lib, zlib 
- have all had security problems in the past.

 Or, for that matter, load the images in through http://php.net/gd and

And the potential irony is that: in order to protect against executables 
masquerading as image files you trigger a zero-day exploit of gd :)

I would love to hear Chris Shiflett's views on this.



[1] as opposed to attacks on a user's browser when later on that file is 
accessed or downloaded
[2] this includes (pun intended) include()'s siblings - require() etc.


-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



[PHP] Copy of image - smaller

2006-05-15 Thread Gustav Wiberg

Hi there!

When I upload a picture from a form, then I want to create a copy with a 
smaller image.
For example: I upload a picture with dimensions 200x150 name 4.jpg. I also 
want a copy of this image but with the dimensions 100x75 pixels. I've tried 
this below, but I'm missing something I think... :-)


I'm using PHP 4.x  (don't know exactly the vers.nr, but I can search for it 
if it is of importance)


The code down below is a function for uploading a picture. The part I want 
help with is after the comment: //What should/could I do here?


Best regards
Gustav Wiberg



?php
function uploadPic($idUpload, $picUpload, $addUpload, $copyFile, $toPath) {

  //Upload chosen file to upload-map (
  //
  if (strlen($_FILES[$picUpload]['name'])0)
  {
  //ECHO yes! ID=$idUpload PIC=$picUpload ADD=$addUploadbr;
  $uploaddir = dirname($_FILES[$picUpload]['tmp_name']) . /;

  //Replace .jpeg to .jpg
  //
  $_FILES[$picUpload]['name'] = 
str_replace(.jpeg,.jpg,$_FILES[$picUpload]['name']);


  //Get first 4 last characters of uploaded filename
  //
  $ble = strtolower(substr($_FILES[$picUpload]['name'], -4, 4));

  //Move to path $toPath (followed by what to add after file (that is sent 
to this function)) and ext.)

  //
  $mfileAdd = $idUpload . $addUpload . $ble;

  move_uploaded_file($_FILES[$picUpload]['tmp_name'], $toPath . $mfileAdd);


  //echo mfileAdd=$mfileAddbrbr;
  //Set appropiate rights for file
  //
  //echo FILE TO TEST=$mfileAdd;
  chmod($toPath . $mfileAdd, intval('0755', 8));


  //Copy this file to another file?
  //
  if (strlen($copyFile)0) {
  $mfile = $idUpload . $copyFile . $ble;
  //echo MFILE=$mfile;
  copy($toPath . $mfileAdd, $toPath . $mfile);
  chmod($toPath . $mfile, intval('0755', 8));
  }


//What should/could I do here?
//

   //Set new width and height
   //
  $new_width = 100;
  $new_height = 200;
  $tmp_image=imagecreatefromjpeg($toPath . $mfileAdd);
  $width = imagesx($tmp_image);
  $height = imagesy($tmp_image);
  $new_image = imagecreatetruecolor($new_width,$new_height);
   ImageCopyResized($new_image, $tmp_image,0,0,0,0, $new_width, 
$new_height, $width, $height);


   //Grab new image
   ob_start();
   ImageJPEG($new_image);
   $image_buffer = ob_get_contents();
   ob_end_clean();
   ImageDestroy($new_image);

   //Create temporary file and write to it
   $fp = tmpfile();
   fwrite($fp, $image_buffer);
   rewind($fp);

   //Upload new image
   $copyTo = 'http://www.ledins.se/test.jpg';
   $conn_id = ftp_connect('domain');
   ftp_login($conn_id,'username for domain','password');
   ftp_fput($conn_id, $copyTo, $fp, FTP_BINARY);
   fclose($fp);



  //Return the filename created based on productID
  //
  return $mfileAdd;
  }



}


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



Re: [PHP] Security Concerns with Uploaded Images:

2006-05-15 Thread Chris

Jason Wong wrote:

On Monday 15 May 2006 10:53, Richard Lynch wrote:


On Sat, May 13, 2006 5:11 pm, Nick Wilson wrote:


are there any security concerns with uploaded images?


YES!!!



Just what are the security concerns exactly? Assuming we're only focusing 
on attacks to the webserver[1] then I can only think of 2 (are there 
anymore?):


1) the uploaded file is a binary executable
2) the uploaded file is a script (perl/php/python/etc)

In the case of (1), the attacker, having uploaded a malicious file would 
then have to find some way of getting it executed. On a un*x-like system 
the uploaded file would/should not have the executable bit set, so the 
attacker would have to find a way to set that bit AND to execute it. This 
would be very unlikely.


In the case of (2), if the script relies on its shebang line to execute 
then it would have to overcome the same obstacles as (1) for it to get 
executed. Otherwise, eg in the case of PHP, it would have to rely on the 
web application to include()[2] or eval() the malicious file. Since it is 
supposed to be an image file then the web developer would/should not 
intentionally use include()/eval() on such files. However in poorly 
written applications where input to include()/eval() can come from the 
user/attacker and are not properly sanitised it is then that the attacker 
will have a field day.


Not necessarily. Poor checks on the filetype could result in a php 
script being uploaded into a temp or cache folder, then you can just 
access it through a browser.


See recent thread starting here: 
http://marc.theaimsgroup.com/?l=php-generalm=114643000627380w=2


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Copy of image - smaller

2006-05-15 Thread Gustav Wiberg

Hi there!

If I understand this right, I must have adminstration rights for installing 
Magic Wand...
The problem is that my host doesn't have any support for this application. 
(It's not MY server)


Is there any workaround?

Best regards
/Gustav Wiberg

- Original Message - 
From: Sascha Braun [EMAIL PROTECTED]

To: Gustav Wiberg [EMAIL PROTECTED]
Sent: Monday, May 15, 2006 9:18 AM
Subject: Re: [PHP] Copy of image - smaller


I dont have the code you  need handy at the moment, but please take a look 
at

imagemagick.org and the

convert -size 120x80 in.jpg -resize 120x80 out.jpg

command.

First you have to use gd getimagesize command to find out
the width and height of the uploaded image, to find out if
the image has a higher width or height value.

The scale it down by the factor needed.

200 / 120 * factor i guess.

Don't forget the path in the convert command otherwise
you are going to delete the original image.

Normaly i do a copy(/tmp/file, /to/destination/path);

unlink(/tmp(file);

convert original source path to thumbnail destination path

and so forth.

When you get handy with ffmpeg you can do the same stuff
with movies. Lame helps you to do the same with audio files.

Have fun!

Sascha Braun
___
SMS schreiben mit WEB.DE FreeMail - einfach, schnell und
kostenguenstig. Jetzt gleich testen! http://f.web.de/?mc=021192



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



Re: [PHP] Copy of image - smaller

2006-05-15 Thread Chris

Gustav Wiberg wrote:

Hi there!

When I upload a picture from a form, then I want to create a copy with a 
smaller image.
For example: I upload a picture with dimensions 200x150 name 4.jpg. I 
also want a copy of this image but with the dimensions 100x75 pixels. 
I've tried this below, but I'm missing something I think... :-)


I'm using PHP 4.x  (don't know exactly the vers.nr, but I can search for 
it if it is of importance)


First of all *run* to this thread and add some security checks to your 
image uploading:


http://marc.theaimsgroup.com/?l=php-generalm=114755779206436w=2

Secondly, what does or doesn't happen with your code?

It looks fine at first glance but do you get an error? What do you 
expect it to do and what does it actually do?


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Wierd ass code...

2006-05-15 Thread Gonzalo Monzón

Gonzalo Monzón escribió:


Attached results and code. (tested on PHP 4.3.4)
--

Testing bidimensional and single dimension array manipulation

Fill style A, bidimensional array: 2,1603
Iteration style A, bidimensional array: 9,9071
Total time style A: 12,0681

Fill style B, single-dimension array: 4,2362
Iteration style B, single-dimension array: 1,5452
Total time style B: 5,7821

Fill style A, bidimensional array: 2,3548
Iteration style A, bidimensional array: 13,1935
Total time style A: 15,5489

Fill style B, single-dimension array: 4,2891
Iteration style B, single-dimension array: 1,5413
Total time style B: 5,8312

Fill style A, bidimensional array: 2,36
Iteration style A, bidimensional array: 17,8439
Total time style A: 20,2046

Fill style B, single-dimension array: 4,2982
Iteration style B, single-dimension array: 1,5554
Total time style B: 5,8544

Fill style A, bidimensional array: 2,3756
Iteration style A, bidimensional array: 17,8817
Total time style A: 20,2579

Fill style B, single-dimension array: 4,3203
Iteration style B, single-dimension array: 1,5332
Total time style B: 5,8543

Fill style A, bidimensional array: 2,3554
Iteration style A, bidimensional array: 19,2986
Total time style A: 21,6547

Fill style B, single-dimension array: 4,3013
Iteration style B, single-dimension array: 1,5508
Total time style B: 5,8528

I wonder how does PHP4 performs in this test, comparing with Python when 
using dictionaries.
Python wins!  Please, don't flame this as I don't want to mean PHP is 
bad, they are different languages for different approaches. But these 
are the results for this test. Interesting...


Best case A, bi-dimensional:   PHP 12,0681   Python: 1,9930   (n/6,3)
Best case B, single-dimension:   PHP 5,7821   Python: 3,6950   (n/1,56)

Python test, results  code (tested on Python 2.4.3):
---

Fill style A, bidimensional array:  1.742000
Iteration style A, bidimensional array:  0.251000
Total time style A: 1.993000

Fill style B, single-dimension array:  3.414000
Iteration style B, single-dimension array:  0.271000
Total time style B: 3.695000

Fill style A, bidimensional array:  2.073000
Iteration style A, bidimensional array:  0.24
Total time style A: 2.313000

Fill style B, single-dimension array:  3.846000
Iteration style B, single-dimension array:  0.31
Total time style B: 4.166000

Fill style A, bidimensional array:  2.133000
Iteration style A, bidimensional array:  0.251000
Total time style A: 2.384000

Fill style B, single-dimension array:  3.735000
Iteration style B, single-dimension array:  0.35
Total time style B: 4.085000

Fill style A, bidimensional array:  2.144000
Iteration style A, bidimensional array:  0.24
Total time style A: 2.384000

Fill style B, single-dimension array:  3.795000
Iteration style B, single-dimension array:  0.381000
Total time style B: 4.176000
-

import time

def TimeMS():
   return time.time()*1000

def TestA():
   global gTestA
   gTestA = {}
   for a in xrange(0,999):
   gTestA[a] = {}
   for b in xrange(0,999):
   gTestA[a][b] = %s%s % (a,b)

def TestB():
   global gTestB
   gTestB = {}
   for a in xrange(0,999):
   for b in xrange(0,999):
   gTestB[%s%s % (a,b)] = %s%s % (a,b)

def TestA2():
   global gTestA
   for a in gTestA:
   for b in gTestA[a]:
   c = gTestA[a][b]

def TestB2():
   global gTestB
   for a in gTestB:
   c = gTestB[a]

# TEST:  
for n in xrange(1,5):

   gTestA = {}
   print \nFill style A, bidimensional array: ,
   startt = TimeMS()
   TestA()
   print %f % ((TimeMS() - startt)/1000)

   print Iteration style A, bidimensional array: ,
   startt2 = TimeMS()
   TestA2()
   print %f % ((TimeMS() - startt2)/1000)
   print Total time style A: %f % ((TimeMS() - startt)/1000)

   gTestB = {}
   print \nFill style B, single-dimension array: ,
   startt = TimeMS()
   TestB()
   print %f % ((TimeMS() - startt)/1000)

   print Iteration style B, single-dimension array: ,
   startt2 = TimeMS()
   TestB2()
   print %f % ((TimeMS() - startt2)/1000)
   print Total time style B: %f % ((TimeMS() - startt)/1000)

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



[PHP] Perl PHP output format mismatching

2006-05-15 Thread mickb
Hello,

I'm currently writing a PHP page, which uses a small Perl script. But I
encounter an annoying problem with endline character.

A small example :

$perl = new Perl();
$perl-eval('print toto\ntata');

In this configuration, the HTML page generated sends me :
toto tata

Of course and you should have understood already :-), I would like :
toto
tata

I suppose I have to do a little manipulation on the PHP streams to make them
correctly interpret the endline character returned by Perl. But I didn't find
what :(

Help would be greatly appreciated.

Thanks.

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



Re: [PHP] Perl PHP output format mismatching

2006-05-15 Thread chris smith

On 5/15/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

Hello,

I'm currently writing a PHP page, which uses a small Perl script. But I
encounter an annoying problem with endline character.

A small example :

$perl = new Perl();
$perl-eval('print toto\ntata');

In this configuration, the HTML page generated sends me :
toto tata

Of course and you should have understood already :-), I would like :
toto
tata

I suppose I have to do a little manipulation on the PHP streams to make them
correctly interpret the endline character returned by Perl. But I didn't find
what :(


\n is not html so your browser doesn't know you want a newline. What
you need is a br tag.

See http://www.php.net/nl2br

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Exceptions in PHP

2006-05-15 Thread Kevin Waterson
This one time, at band camp, John Meyer [EMAIL PROTECTED] wrote:

 I have the following script:
 
 try {
   $conn = mysql_connect(localhost,webuser,testme) or die(Could not 
 connect);

-- snipped for sake of sanity --

I think if you wish to push down this path you may wish to look at PDO.

Kind regards
Kevin


-- 
Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote.

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



[PHP] Check before uploading

2006-05-15 Thread Gustav Wiberg

Hi there!

Just a thought. Someone posted a question if you could check filesize before 
uploading some days ago. Maybe this is possible with Javascript?
Javascript wouldn't be the best solution, cause of it's incompability 
between browsers, that users can inactivate it. But it's might be better 
than nothing.. The important thing is not to RELY on the Javascript-code.


Best regards
/Gustav Wiberg 


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



Re: [PHP] Check before uploading

2006-05-15 Thread Stut

Gustav Wiberg wrote:

Just a thought. Someone posted a question if you could check filesize 
before uploading some days ago. Maybe this is possible with Javascript?
Javascript wouldn't be the best solution, cause of it's incompability 
between browsers, that users can inactivate it. But it's might be 
better than nothing.. The important thing is not to RELY on the 
Javascript-code.



This was suggested at the time, but for what should be obvious reasons 
it's not possible due to security restrictions.


-Stut

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



Re: [PHP] Wierd ass code...

2006-05-15 Thread Robin Vickery

On 14/05/06, Gonzalo Monzón [EMAIL PROTECTED] wrote:

Satyam escribió:
 Of course, another possibility is that the author does not know how to
 handle multidimensional arrays (just to say it before anyone else
 points an obvious alternative)


I don't think the author does not know how to handle multidimensional
arrays. I thought the author was more concerned about performance than
other issues people like as coding beautifuly...  Maybe author's
approach is weird, but its twice faster in the worst case!!

Sure the author only needs to loop the whole array and doesn't need
multi-dimensional approach... 'cause its a lot faster to iterate once
the array is filled!!

Look at the test I've done (below) its seems filling multi-dimensional
arrays is n/2 faster than single dimension, but then when you need to
read the array data, a multi-dimensional approach is always worse than
n*6!!


Your setup is odd. I get much more similar results with both php 4 and 5.

You're also using a more than slightly odd way of iterating through the array.

These does exactly the same as your Test functions and are considerably faster:

?php
function Test_c() {
 global $testC;
 for ($a=1;$a999;++$a) {
   for ($b=1;$b999;++$b) {
 $testC[$a][$b] = $a . $b;
   }
 }
}

function Test_c2() {
 global $testC;
 foreach ($testC as $k = $v) {
   foreach ($v as $k2 = $v2);
 }
}
?

Test results from PHP 5.0.5:

Fill style A, bidimensional array: 3.0747
Iteration style A, bidimensional array: 2.4385
Total time style A: 5.5135

Fill style B, single-dimension array: 4.6502
Iteration style B, single-dimension array: 2.3964
Total time style B: 7.047

Fill style C, bidimensional array: 2.5237
Iteration style C, bidimensional array, foreach loop: 1.3415
Total time style C: 3.8656

Test results from PHP 4.4.0:

Fill style A, bidimensional array: 3.2056
Iteration style A, bidimensional array: 2.3848
Total time style A: 5.5907

Fill style B, single-dimension array: 5.1468
Iteration style B, single-dimension array: 2.4016
Total time style B: 7.5488

Fill style C, bidimensional array: 2.6899
Iteration style C, bidimensional array, foreach loop: 1.4073
Total time style C: 4.0976

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



Re: [PHP] Copy of image - smaller

2006-05-15 Thread Rabin Vincent

On 5/15/06, Gustav Wiberg [EMAIL PROTECTED] wrote:
[snip]

//What should/could I do here?
//

//Set new width and height
//
   $new_width = 100;
   $new_height = 200;
   $tmp_image=imagecreatefromjpeg($toPath . $mfileAdd);
   $width = imagesx($tmp_image);
   $height = imagesy($tmp_image);
   $new_image = imagecreatetruecolor($new_width,$new_height);
ImageCopyResized($new_image, $tmp_image,0,0,0,0, $new_width,
$new_height, $width, $height);


I can't see anything wrong with this resizing.


//Grab new image
ob_start();
ImageJPEG($new_image);
$image_buffer = ob_get_contents();
ob_end_clean();
ImageDestroy($new_image);
//Create temporary file and write to it
$fp = tmpfile();
fwrite($fp, $image_buffer);
rewind($fp);


Instead of doing this, you may want to use the filename
argument of ImageJPEG to save the image directly to a file.


//Upload new image
$copyTo = 'http://www.ledins.se/test.jpg';
$conn_id = ftp_connect('domain');
ftp_login($conn_id,'username for domain','password');
ftp_fput($conn_id, $copyTo, $fp, FTP_BINARY);


Destination file ($copyTo) is supposed to be a path (eg.
public_html/test.jpg) and not a URL.

Rabin

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



[PHP] Views on e-commerce download tracking

2006-05-15 Thread Chris Grigor

Hey all

Was just wondering what others have used on there e-commerce sites to 
manage digital downloads, for instance how to track if a user 
succesfully downloaded a complete file from you (what happens if there 
connection drops halfway through a download)


Is there something in php / javascript that could do this - 
javascript:oncomplete_ofdownloadfile send response to server

Anyone have any ideas?

Your views / suggestions are appreciated.
Chris

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



[PHP] Create database with pdo_mysql

2006-05-15 Thread Kevin Waterson
Is it possible to create a database with pdo_mysql?
$dbh = new PDO(mysql:host=$hostname;dbname=my_db, $username, $password);
is sort of what it requires... is there some way to omit the dbname?

Kind regards
Kevin


-- 
Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote.

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



[PHP] Re: Views on e-commerce download tracking

2006-05-15 Thread Barry

Chris Grigor schrieb:

Hey all

Was just wondering what others have used on there e-commerce sites to 
manage digital downloads, for instance how to track if a user 
succesfully downloaded a complete file from you (what happens if there 
connection drops halfway through a download)


Is there something in php / javascript that could do this - 
javascript:oncomplete_ofdownloadfile send response to server

Anyone have any ideas?

Your views / suggestions are appreciated.
Chris

Well checking the logs is very useful for that.
(talking about the apache / webserverlogs)

I don't know any javascript doing something like that.

You can buffer the file to the client via fread or such and buffer only 
a few chunks and let php wait till he downloaded it.

On sucessfull download you might add a db entry or whatever.

Something like that though.

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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



Re: [PHP] Going nuts with this, cant figure out whats the prob

2006-05-15 Thread Ryan A
Hey Chris / Richard,


 I was wondering if the different line endings
 (dos/unix) might play a 
 factor but I doubt it.

Chris:
Ok, that really helped, I was testing the test.txt
file on my Win2k machine and was testing the whole
script on a FreeBSD machine... so I took the small
test and upped it on the FreeBSD machine, ran it and
this is what I got:
--- output --
In
while(),Start..193.150.249.47|-|200|18897|/usr/local/www/nocme.com/www/coinpass/coinpass|End
of stdin


Fatal error:  Call to undefined function: 
preg_match() in
/usr/local/www/nocme.com/www/coinpass/test/test_regex.php
on line 12

--- output --

As you can see it is reading the first line without a
problem, as it touches preg_match it screws up,
searching google I see that the problem might be that
PCRE has not been installed on this machine
(http://wordpress.org/support/topic/67726) , will
contact the host.
Thanks for your help again, I hope this helps someone
else later on.



Richard:
clip
You *DO* see this bit in the log right?...

And is $line what you expect it to be, newlines and
all?...
/clip

Its exactly as it should be...



clip
$pattern=/^(\d+\.\d+\.\d+\.\d+)\|(.+)\|(\d+)\|([\d-]+)\|(.+)\|(.+)$/;

It's NOT your problem, but...

\ has an awful lot of different meanings inside of 
marks in PHP.

I'd recommend using \\ to get a single \ embedded in a
string.
/clip

I didnt write that, am still learning the basics of
REGEX and fooling around with the regex coach,
according to that it does match the pattern I am
looking for, want to tune it a bit but for now will
let it be till I can understand regex better.
Thanks for the advise on future regex writing though,
I am sure it will come in handy when I understand
regexs a bit better.

The thing is, I thought this was bundled with the
standard package of PHP, if yes, why would anybody
want to turn this off?

Thanks!
Ryan



--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
-
Fight back spam! Download the Blue Frog.
http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



[PHP] PHP stdout stream

2006-05-15 Thread mickb
Hello,

I've a quite simple question : one of my PHP script executes a Perl script which
outputs a lot of text. My wish is to redirect PHP stdout stream to NULL,
executing the perl script, and after this make the stdout stream back to
normal. I've not found a solution in online documentation. Anyone could provide
help ?

thanks.

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



[PHP] Re: Re: Upload File (binary files?)

2006-05-15 Thread Michelle Konzack
Am 2006-05-11 13:40:34, schrieb tedd:

 Plus, moving images from one system to another 
 was much easier because you just moved the dB and 
 you don't have to worry about the file system and 
 breaking links.

This can be done from a script to...

 In addition, if you are using multiple hosts, who 
 require the same images, then using mySQL is far 
 superior than trying to keep all the images in 
 different file systems synchronized.

This can be donw from filesystem too

http://pics.your-domain.tld/path/to/pic.png

 Furthermore, according to Paul DuBois (author of 
 MySQL Cookbook, great book btw) who says If you 
 store images on the file system, directory 
 look-up my become slow in his comparing file 
 system to mySQL for image storage.

???

It depends, how many pics you have. But if you install a dedicated
Server for the pics with, e.g. 1 GByte of memory and apache 1.3.
It is fast as the heaven...  My Linux-Box hold all pics in memory.

 Granted, if you use mySQL for storing images, 
 then you bloat the tables and approach your 
 system limits faster than using a file system. 
 But for a limited amount of images, there isn't 
 any real problems.

Hmmm, My PostgreSQL is around 370 Gbyte now and if
I import all Pics, it would be around 1,8 TByte...

Good night...

 And for goodness sake NO, Google is NOT always 
 right -- it's only a collection of everyone's 
 view. When did Google replace valid research? I 
 can see tomorrow's mother's saying to their 
 children If Google jumped off a bridge, would 
 you do it?

Yes, because I like Bungee-Jumping...
(Paraglideing too)

;-)

Greetings
Michelle Konzack


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
   50, rue de Soultz MSM LinuxMichi
0033/6/6192519367100 Strasbourg/France   IRC #Debian (irc.icq.com)

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



[PHP] Re: Re: Upload File (binary files?)

2006-05-15 Thread Michelle Konzack
Am 2006-05-12 09:28:36, schrieb tedd:

 But, at some point (and I forgot to mention this in my previous post) 
 all programmers start thinking in collections of data and a dB 
 becomes a well suited solution (record holder and organizer) for 
 that. As such, all data connected to a record, including images, are 
 better suited if organized and saved in one place.

And if your database like mine crashs then you have lost all...
Restoring a Database of 1,8 TByte takes some hours!!!

No one restore a database of 1,8 TByte in less then one hour.
I have my database and currently 1 FileServer with the binary files.

(I will switch to 3 FileServers of 2U insteed of one 6U)

 I did the same thing including merging a copyright on the image. I 
 believe that saving all related data in a dB is really the right 
 way to go. From there, you can do anything you want with the data.

Served from a filesystem too

The overhead form getting a pic from the database is bigger then
from a filesystem.  I had allready tried it.  I can resize on the
fly too.  Now, where is the problem, if a php script get the pic
from a filserver using http or ftp?

My system is
  pgsql.example.com
 /   (maybve a cluster)
client - www.example.com
 \
  bin1.example.com
  bin2.example.com

Greetings
Michelle Konzack


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
   50, rue de Soultz MSM LinuxMichi
0033/6/6192519367100 Strasbourg/France   IRC #Debian (irc.icq.com)

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



[PHP] php-cli and daemon

2006-05-15 Thread Michelle Konzack
Hello,

I run a webserver which is a frontend for a huge PostgreSQL database.
Now I like to code some stand-alone Apps, which can connect to a
daemon uploading files and geting infos from the database

(NO, the have no right to connect directly to the database)

Questions for now:

1)  How to code a daemon?

2)  How to use ssl-certs for the connection?
The $USER must use an USB-Key with its one cert.

Greetings
Michelle Konzack


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
   50, rue de Soultz MSM LinuxMichi
0033/6/6192519367100 Strasbourg/France   IRC #Debian (irc.icq.com)

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



Re: [PHP] Wierd ass code...

2006-05-15 Thread Gonzalo Monzón

Robin Vickery escribió:


On 14/05/06, Gonzalo Monzón [EMAIL PROTECTED] wrote:


Satyam escribió:
 Of course, another possibility is that the author does not know how to
 handle multidimensional arrays (just to say it before anyone else
 points an obvious alternative)


I don't think the author does not know how to handle multidimensional
arrays. I thought the author was more concerned about performance than
other issues people like as coding beautifuly...  Maybe author's
approach is weird, but its twice faster in the worst case!!

Sure the author only needs to loop the whole array and doesn't need
multi-dimensional approach... 'cause its a lot faster to iterate once
the array is filled!!

Look at the test I've done (below) its seems filling multi-dimensional
arrays is n/2 faster than single dimension, but then when you need to
read the array data, a multi-dimensional approach is always worse than
n*6!!



Your setup is odd. I get much more similar results with both php 4 and 5.

You're also using a more than slightly odd way of iterating through 
the array.


These does exactly the same as your Test functions and are 
considerably faster:


?php
function Test_c() {
 global $testC;
 for ($a=1;$a999;++$a) {
   for ($b=1;$b999;++$b) {
 $testC[$a][$b] = $a . $b;
   }
 }
}

function Test_c2() {
 global $testC;
 foreach ($testC as $k = $v) {
   foreach ($v as $k2 = $v2);
 }
}
?

Test results from PHP 5.0.5:

Fill style A, bidimensional array: 3.0747
Iteration style A, bidimensional array: 2.4385
Total time style A: 5.5135

Fill style B, single-dimension array: 4.6502
Iteration style B, single-dimension array: 2.3964
Total time style B: 7.047

Fill style C, bidimensional array: 2.5237
Iteration style C, bidimensional array, foreach loop: 1.3415
Total time style C: 3.8656

Test results from PHP 4.4.0:

Fill style A, bidimensional array: 3.2056
Iteration style A, bidimensional array: 2.3848
Total time style A: 5.5907

Fill style B, single-dimension array: 5.1468
Iteration style B, single-dimension array: 2.4016
Total time style B: 7.5488

Fill style C, bidimensional array: 2.6899
Iteration style C, bidimensional array, foreach loop: 1.4073
Total time style C: 4.0976


Hi Robin,

Don't thought my setup is odd. Only I can say my computer maybe isn't as 
faster than yours. I use centrino mobile, windows xp, and test was run 
on php 4.3.9 ( sorry i missed that, thought was 4.3.4)


I know it can be coded to be faster, but my point with that php snippet 
was to compare the same odd way with single or multi dimensional 
approaches. Sure $a.$b is faster than $a$b and foreach than do while 
(the more if you didn't use each element datum!! that's hi - 
optimization! does sense for you using foreach without assigning any 
value from it? yes, you've got them inside foreach $v2 - $k2, but in my 
code i've got too them inside key($v) $v[key($v)], and I do assign them 
to another var, so if you want to compare performance, please to it too! 
anyway I checked this and both multidimensional approaches performs 
pretty equal. )


I didn't code that snippet to the best / faster execution methodology 
for this individual case but a generic odd way for comparing both 
cases. The same I did in python, as that language as far more adaptable 
data structures for letting you choose the best for your case needs (I 
could use python numarray (uses C arrays) and I thought you could't beat 
it in PHP or any PHP C extension, but that's far from the purpose of my 
posts.


If do I use $a.$b instead $a$b and assign each element key  val from 
foreach in type c test, that's what I got: -see below- B  C perform 
nearly equal on total time, of course, the best approach would be highly 
dependent on the real data to use. The only I thing could say about your 
foreach approach is I allways avoided using it in some kind of projects, 
as it does a copy of the data on every iteration, so when using lots of 
objects, huge data, or pass-per-reference had lot of memory performance 
issues using it in php4 -Im speaking about very long-running scripts 
where these issues really care- so do { } while(next()) is the only you 
can use safely...


Notice huge gap in running the type A test in my computer and in yours 
for php 4.4.0 - me 4.3.9, you get 5.59 and I got 13.9, and other tests 
seems my install always performs better than yours! :-) (type b: you 
5.12 - 2.40 = 7.54  me 4.08 - 1.66 = 5.57 that's about 2 secods!!). That 
means to me so this test don't probe nothing, they are all very 
variable... I don't know why that great difference, but I don't think  
the php revision changes from 4.3.9 to 4.4.0 are relevant enought as for 
these performance gaps. We should use a real tests library for choosing 
best case of several runs, and so on...


Anyway these are the results using your test_c modified code with two 
lines added... notice filling type A and C share the same code, and 
there is some gap: 1,97 - 2,16 !


Fill style A, bidimensional array: 

[PHP] Re: Re: Upload File

2006-05-15 Thread Michelle Konzack
Hi Rory

Am 2006-05-10 23:05:07, schrieb Rory Browne:

 you can say newbie as well. As a newbie I thought myself that storing images
 in a DB would be a nice clean solution. Voices of experience said otherwise.
 Over the years as I grew more experienced I began to understand myself, why
 putting images into a MySQL Db is a Bad Thing[tm].

Like me... in 2000/2001 where I had only a very small database
of 1 GByte I had done this too...  No I have 370 GByte of text
data and 1,5 TByte binaries laying around...  It would be a
nightmare to store thise binaries in the database

 Sorry if this seems rough / harsh, but if it causes a person to think twice
 before using MySQL as a file storage solution, then it's justified.

FullACK

 PHP has the facilities built-in to perform this search/sort/filter - while
 their use isn't always the cleanest solution, anything is better than
 putting files in a db.

And if the PICs are in JPEG format, maybe they have EXIF infos
which can be extracted and stored in the database...

Greetings
Michelle Konzack


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
   50, rue de Soultz MSM LinuxMichi
0033/6/6192519367100 Strasbourg/France   IRC #Debian (irc.icq.com)

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



Re: [PHP] PHP stdout stream

2006-05-15 Thread nicolas figaro

[EMAIL PROTECTED] a écrit :

Hello,

I've a quite simple question : one of my PHP script executes a Perl script which
outputs a lot of text. My wish is to redirect PHP stdout stream to NULL,
executing the perl script, and after this make the stdout stream back to
normal. I've not found a solution in online documentation. Anyone could provide
help ?

  

hi,

if your php and perl runs on unix :
system (perl perl_prg.pl  /dev/null);

N F

thanks.

  


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



Re: [PHP] php-cli and daemon

2006-05-15 Thread chris smith

On 5/14/06, Michelle Konzack [EMAIL PROTECTED] wrote:

Hello,

I run a webserver which is a frontend for a huge PostgreSQL database.
Now I like to code some stand-alone Apps, which can connect to a
daemon uploading files and geting infos from the database

(NO, the have no right to connect directly to the database)

Questions for now:

1)  How to code a daemon?


This would be a good place to start.

http://www.php.net/pcntl

Depending on your app you might need to look at shared memory, but the
main area to check out would be the process functions.

http://www.php.net/manual/en/ref.sem.php


2)  How to use ssl-certs for the connection?
The $USER must use an USB-Key with its one cert.


There are ssl functions you can use:

http://www.php.net/manual/en/ref.openssl.php

--
Postgresql  php tutorials
http://www.designmagick.com/

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



[PHP] Re: PHP output stream

2006-05-15 Thread mickb
Thanks for your answer. I already have thought about your solution. The problem
is I have to use the Perl module for PHP. An example :

$perl = new Perl();
$perl-require('mct.pl');
$perl-MCT_polling();

where MCT_polling() is a function of my script mct.pl. I would find very strange
the fact it's impossible to manipulate PHP stdout stream.

[EMAIL PROTECTED] a #65533;crit :
 Hello,

 I've a quite simple question : one of my PHP script executes a Perl script
which
 outputs a lot of text. My wish is to redirect PHP stdout stream to NULL,
 executing the perl script, and after this make the stdout stream back to
 normal. I've not found a solution in online documentation. Anyone could
provide
 help ?


hi,

if your php and perl runs on unix :
system (perl perl_prg.pl  /dev/null);

N F
 thanks.



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



[PHP] Sessions - session_start()

2006-05-15 Thread Jonas Rosling
Hi,
I've been building a site with PHP 5 on my develop machine. I've been woring
alot with session handling. For example I've been using session_start() now
and then depending on where the user/vistor are or are doing.
But now I've moved the site to a host server with PHP 4.3.8 and now I keep
getting error messages all the time where I use session_start(). The error
message looks like this:

Warning: session_start(): Cannot send session cookie - headers already sent
by (output started at /var/www/html/index.php:9) in /var/www/html/index.php
on line 82

But I found out that if I put the tag in the absolute top of every page it
seems to work. But then I need to do alot of changes on all the pages.

Does anyone know if there's any workaround for this?

Thanks in advance // Jonas

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



Re: [PHP] Re: PHP output stream

2006-05-15 Thread nicolas figaro

[EMAIL PROTECTED] a écrit :

Thanks for your answer. I already have thought about your solution. The problem
is I have to use the Perl module for PHP. An example :

$perl = new Perl();
$perl-require('mct.pl');
$perl-MCT_polling();

where MCT_polling() is a function of my script mct.pl. I would find very strange
the fact it's impossible to manipulate PHP stdout stream.
  
can't you edit the mct.pl script so the MCT_polling function won't 
output anything ?

N F

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



Re: [PHP] Sessions - session_start()

2006-05-15 Thread nicolas figaro

Jonas Rosling a écrit :

Hi,
I've been building a site with PHP 5 on my develop machine. I've been woring
alot with session handling. For example I've been using session_start() now
and then depending on where the user/vistor are or are doing.
But now I've moved the site to a host server with PHP 4.3.8 and now I keep
getting error messages all the time where I use session_start(). The error
message looks like this:

Warning: session_start(): Cannot send session cookie - headers already sent
by (output started at /var/www/html/index.php:9) in /var/www/html/index.php
on line 82

But I found out that if I put the tag in the absolute top of every page it
seems to work. But then I need to do alot of changes on all the pages.

Does anyone know if there's any workaround for this?

Thanks in advance // Jonas

  

check in your code if there is a print or echo somewhere.
*http://www.php.net/manual/en/function.session-start.php :
Note: * If you are using cookie-based sessions, you must call 
*session_start()* before anything is outputted to the browser.


N F

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



[PHP] Re: PHP output stream

2006-05-15 Thread mickb
[EMAIL PROTECTED] a #65533;crit :
 Thanks for your answer. I already have thought about your solution. The
problem
 is I have to use the Perl module for PHP. An example :

 $perl = new Perl();
 $perl-require('mct.pl');
 $perl-MCT_polling();

 where MCT_polling() is a function of my script mct.pl. I would find very
strange
 the fact it's impossible to manipulate PHP stdout stream.

can't you edit the mct.pl script so the MCT_polling function won't
output anything ?
 N F

It's a solution indeed, but very annoying for multiples reasons. If I can't find
another way, I won't have the choice...

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



Re: [PHP] Sessions - session_start()

2006-05-15 Thread Thomas Munz
put ob_start(); on the first line of your page 

on Monday 15 May 2006 15:53, Jonas Rosling wrote:
 Hi,
 I've been building a site with PHP 5 on my develop machine. I've been
 woring alot with session handling. For example I've been using
 session_start() now and then depending on where the user/vistor are or are
 doing.
 But now I've moved the site to a host server with PHP 4.3.8 and now I keep
 getting error messages all the time where I use session_start(). The error
 message looks like this:

 Warning: session_start(): Cannot send session cookie - headers already sent
 by (output started at /var/www/html/index.php:9) in /var/www/html/index.php
 on line 82

 But I found out that if I put the tag in the absolute top of every page it
 seems to work. But then I need to do alot of changes on all the pages.

 Does anyone know if there's any workaround for this?

 Thanks in advance // Jonas

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



[PHP] imagefrompng() question

2006-05-15 Thread D A GERM
I'm having difficulty displaying text after imagefrompng().  I'm using 
PEARS's Image_Barcode to displa a barcode and trying to wrap 
imagefrompng() around it.  I am able to display the barcode properly but 
not the rest of my document (a mix a text and other images). 

Is there a proper heading I should use?  I been looking over the docs 
for imagefrompng() and PEAR's Image_Barcode but have not found anything 
useful to offer a solution to my problem.  Any suggestions?


thanks in advance.

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



Re: [PHP] Security Concerns with Uploaded Images:

2006-05-15 Thread tedd

To summarise: the uploading of an executable masquerading as an image file
can be protected against via coding at the application level


  My thought is that it wouldnt be too hard to have some kind of script
  masquerade as a gif file, and perhaps cause damage.


More worrying and much harder to protect against are zero-day exploits
against the graphics libraries themselves - libpng, libtiff, gd lib, zlib
- have all had security problems in the past.


 Or, for that matter, load the images in through http://php.net/gd and


And the potential irony is that: in order to protect against executables
masquerading as image files you trigger a zero-day exploit of gd :)

I would love to hear Chris Shiflett's views on this.


I certainly don't speak for Chris, but I can say that I've read his 
book Essential PHP Security and didn't find mention of any concerns 
regarding executable code masquerading as an image file.


He does speak about attaching stuff to a url request for an image to 
make a CSRF (cross site request forgery), but the offending code was 
not in the image.


However, if this is a real concern, then what about:

1. Uploading the file into a black hole as Wolf provided some time 
back. I think he tackled a similar problem.


2. Resampling the image -- I doubt any code that's been resampled can 
pose any threat. In fact, there are several things one can do to an 
image that would alter the internal binary significantly while not 
adversely affecting the image much. Alter any of my programs by a 
single character, and they will crater -- of course they seldom need 
help to do that.


tedd
--

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

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



Re: [PHP] Sessions - session_start()

2006-05-15 Thread Jonas Rosling
Den 06-05-15 15.56, skrev nicolas figaro [EMAIL PROTECTED]:

 Jonas Rosling a écrit :
 Hi,
 I've been building a site with PHP 5 on my develop machine. I've been woring
 alot with session handling. For example I've been using session_start() now
 and then depending on where the user/vistor are or are doing.
 But now I've moved the site to a host server with PHP 4.3.8 and now I keep
 getting error messages all the time where I use session_start(). The error
 message looks like this:
 
 Warning: session_start(): Cannot send session cookie - headers already sent
 by (output started at /var/www/html/index.php:9) in /var/www/html/index.php
 on line 82
 
 But I found out that if I put the tag in the absolute top of every page it
 seems to work. But then I need to do alot of changes on all the pages.
 
 Does anyone know if there's any workaround for this?
 
 Thanks in advance // Jonas
 
   
 check in your code if there is a print or echo somewhere.
 *http://www.php.net/manual/en/function.session-start.php :
 Note: * If you are using cookie-based sessions, you must call
 *session_start()* before anything is outputted to the browser.
 
 N F

Will take a look at the echos. It'll be some rewriting though.

Thanks // Jonas

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



Re: [PHP] Sessions - session_start()

2006-05-15 Thread Jonas Rosling
Den 06-05-15 16.00, skrev Thomas Munz [EMAIL PROTECTED]:

 put ob_start(); on the first line of your page
 
 on Monday 15 May 2006 15:53, Jonas Rosling wrote:
 Hi,
 I've been building a site with PHP 5 on my develop machine. I've been
 woring alot with session handling. For example I've been using
 session_start() now and then depending on where the user/vistor are or are
 doing.
 But now I've moved the site to a host server with PHP 4.3.8 and now I keep
 getting error messages all the time where I use session_start(). The error
 message looks like this:
 
 Warning: session_start(): Cannot send session cookie - headers already sent
 by (output started at /var/www/html/index.php:9) in /var/www/html/index.php
 on line 82
 
 But I found out that if I put the tag in the absolute top of every page it
 seems to work. But then I need to do alot of changes on all the pages.
 
 Does anyone know if there's any workaround for this?
 
 Thanks in advance // Jonas

ob_start(); doesn't change anything in my case. But thanks anyway.

// Jonas

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



Re: [PHP] Sessions - session_start()

2006-05-15 Thread Eric Butera

On 5/15/06, Jonas Rosling [EMAIL PROTECTED] wrote:

Hi,
I've been building a site with PHP 5 on my develop machine. I've been woring
alot with session handling. For example I've been using session_start() now
and then depending on where the user/vistor are or are doing.
But now I've moved the site to a host server with PHP 4.3.8 and now I keep
getting error messages all the time where I use session_start(). The error
message looks like this:

Warning: session_start(): Cannot send session cookie - headers already sent
by (output started at /var/www/html/index.php:9) in /var/www/html/index.php
on line 82

But I found out that if I put the tag in the absolute top of every page it
seems to work. But then I need to do alot of changes on all the pages.

Does anyone know if there's any workaround for this?

Thanks in advance // Jonas

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



I bet the reason you're seeing this now is because your local machine
is configured to have X amount of output buffering while the server is
not.  If you make two scripts that have...

?php
phpinfo();
?

...on the remote and local environments you can check this by looking
for output_buffering.  On some it is set to 4096 by default, while
others are not.

Do what Nicolas Figaro said and also check for any whitespace or line
returns outside of your ?php ? tags.

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



[PHP] Re: Re: Upload File (binary files?)

2006-05-15 Thread tedd

At 12:18 AM +0200 5/14/06, Michelle Konzack wrote:

Am 2006-05-12 09:28:36, schrieb tedd:


 But, at some point (and I forgot to mention this in my previous post)
 all programmers start thinking in collections of data and a dB
 becomes a well suited solution (record holder and organizer) for
 that. As such, all data connected to a record, including images, are
 better suited if organized and saved in one place.


And if your database like mine crashs then you have lost all...
Restoring a Database of 1,8 TByte takes some hours!!!


How does a dB crash? Is it a hardware or software crash?

If it's software, then have you published the problem? Does mySQL have a bug?

If it's hardware, then it doesn't make any difference if the data is 
stored in a file-system or in a dB -- it's just so much binary on a 
hard drive that's no longer accessible.


Redundancy helps. While I've never done it, but from what I've read 
there are metrologies using multiple servers (like RAID) to keep 
things current on-the-fly so that you virtually eliminate lose 
everything crashes. While one may crash, the others live on in 
real-time.


If I was working with investments as large as that, then I would be 
looking for ways to protect it other than inspecting the overhead.


tedd
--

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

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



[PHP] Re: Re: Upload File (binary files?)

2006-05-15 Thread tedd

At 12:18 AM +0200 5/14/06, Michelle Konzack wrote:

Am 2006-05-12 09:28:36, schrieb tedd:


 But, at some point (and I forgot to mention this in my previous post)
 all programmers start thinking in collections of data and a dB
 becomes a well suited solution (record holder and organizer) for
 that. As such, all data connected to a record, including images, are

  better suited if organized and saved in one place.


-snip-


The overhead form getting a pic from the database is bigger then
from a filesystem.  I had allready tried it.  I can resize on the
fly too.  Now, where is the problem, if a php script get the pic
from a filserver using http or ftp?


Well... if you define the problem in terms of If it can be done 
then there's no real problem.


But the purpose of programming is to gather, organize, process, and 
display data. We do this under the paradigm of keep it simple -- 
the simpler is usually the better.


I only said that from a programming perspective -- of collecting and 
placing data into organizable groups -- keeping things in one system 
is preferable (simpler) than dividing things up into different 
organizational elements (i.e., file system v dB).


Plus, a dB has search capabilities that a file system doesn't -- 
that's probably the reason why dB's came into existence, right?


As for overhead and time to process stuff -- that's just a current 
observation and the problem (if there is one) will most certainly 
pass.


I think the future on this is pretty clear as to what regime will be 
preferable for data organization. Not that I'm implying such to you, 
I remember DOS types saying What moron will ever use a mouse? and 
now they're saying Only Idiots and Morons place images in dB's.


To each their own.

tedd
--

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

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



Re: [PHP] $ENV['SCRIPT_FILENAME']

2006-05-15 Thread John Wells

On 5/14/06, Ryan A [EMAIL PROTECTED] wrote:

Anyone have an idea of a variable (eg:
$_SERVER['REQUEST_METHOD'] ) that will be set only if
called via the web and ignored if called via cli?


I have no experience with CLI, and haven't tested this, but I believe
that any time a request comes through a web browser, the $_GET and
$_POST values are set, even if they're empty.  This may go for the
$_COOKIE global as well.  So you could simply check if one of these
are set:

isset($_POST)

But again I have no CLI experience, so I could be off.  But it's worth
testing...

HTH,
John W

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



Re: [PHP] Re: Upload File (binary files?)

2006-05-15 Thread Rory Browne


How is it not suited?

I stopped using mySQL to store images because of
browser refresh problems, but other than that --
I didn't find any major problems with using it.

Plus, moving images from one system to another
was much easier because you just moved the dB and
you don't have to worry about the file system and
breaking links.



Bullshit. there are multiple tools for copying files from host to host,
including ftp, scp, sftp, rsync, nfs, etc. Planning ahead, is  a better way
to avoid breaking links than using MySQL to store your images.


In addition, if you are using multiple hosts, who

require the same images, then using mySQL is far
superior than trying to keep all the images in
different file systems synchronized.


Not it's not. If you have a single mysql server then this situation can be
replicated by having a single image server. If you have a clustered mysql
system, then this can be replicated using something like rsync



Furthermore, according to Paul DuBois (author of

MySQL Cookbook, great book btw) who says If you
store images on the file system, directory
look-up my become slow in his comparing file
system to mySQL for image storage.


I notice you've misspelt the most important word there. He says the lookup
_MAY_ become slow. This behavour is dependent on the filesystem you are
using. You will encounter this problem with ext3 if you have too many files
in the same dir. You're less likely to encounter it with reiser. This comes
down to the competance of the administrator. An incompetantly setup mysql
table ( without indexes ) would have the same problem.


Additionally, transactional behavior is more

difficult with a file system than it is with
mySQL.

Granted, if you use mySQL for storing images,
then you bloat the tables and approach your
system limits faster than using a file system.
But for a limited amount of images, there isn't
any real problems.



For a small enough site you can encode all your images inside a bigger image
using stenography. Bad solutions generally work for small enough sites.
Failing to plan for the growth of your site is however a bad idea.

And granted, pulling images from mySQL to be used

in web sites are slightly slower and present
refresh differences between some browsers, but
that's certainly not a reason to say that mySQL
is categorically not suited for the storage of
binary files -- like with everything else, there
are trade-offs. Do you not see that?



We're not talking about generic binary files. We're talking about images
images that people upload. Using blobs to store small (order of kbs) of
transient data is fine. I just don't want to end up maintaining systems that
store images in the sql db.

---


At 1:53 AM +1000 5/11/06, Peter Hoskin wrote:
So, if ASCII and Binary are both codesets... which does SQL use to store
its data?

Is ASCII stored differently than binary on a hard drive?

From my limited experience in using a hex editor,
the data all looks the same to me. If it wasn't
for my hex editor, I would be looking at 1's and
0's, right?

After all, isn't an image in a file system stored
on a hard drive the exact same fashion as an
image stored on a hard drive via mySQL?

The only difference I can see is in overhead --
but then again, I may be a Moron or an Idiot like
Rory Browne suggests.

Perhaps someone might enlighten me as to why
mySQL is not suited to store images -- and prove
it.

And for goodness sake NO, Google is NOT always
right -- it's only a collection of everyone's
view. When did Google replace valid research? I
can see tomorrow's mother's saying to their
children If Google jumped off a bridge, would
you do it?

Let's get real about what Google can offer.
Specificity is inversely proportional to the
number of people voicing an opinion. I would
guess that even Morons and Idiots know that.

tedd

Typical disclaimers apply -- I did not mean to
offend anyone nor to imply that anyone is an
Idiot or a Moron. Your mileage may vary. No
warranties expressed or implied. This is not a
solicitation for an investment opportunity.
Consult you doctor before applying.  No hable
inglés.

--


http://sperling.com

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




Re: [PHP] Re: Upload File (binary files?)

2006-05-15 Thread Rory Browne


How is it not suited?

I stopped using mySQL to store images because of
browser refresh problems, but other than that --
I didn't find any major problems with using it.

Plus, moving images from one system to another
was much easier because you just moved the dB and
you don't have to worry about the file system and
breaking links.



Bullshit. there are multiple tools for copying files from host to host,
including ftp, scp, sftp, rsync, nfs, etc. Planning ahead, is  a better way
to avoid breaking links than using MySQL to store your images.


In addition, if you are using multiple hosts, who

require the same images, then using mySQL is far
superior than trying to keep all the images in
different file systems synchronized.


Not it's not. If you have a single mysql server then this situation can be
replicated by having a single image server. If you have a clustered mysql
system, then this can be replicated using something like rsync



Furthermore, according to Paul DuBois (author of

MySQL Cookbook, great book btw) who says If you
store images on the file system, directory
look-up my become slow in his comparing file
system to mySQL for image storage.


I notice you've misspelt the most important word there. He says the lookup
_MAY_ become slow. This behavour is dependent on the filesystem you are
using. You will encounter this problem with ext3 if you have too many files
in the same dir. You're less likely to encounter it with reiser. This comes
down to the competance of the administrator. An incompetantly setup mysql
table ( without indexes ) would have the same problem.


Additionally, transactional behavior is more

difficult with a file system than it is with
mySQL.

Granted, if you use mySQL for storing images,
then you bloat the tables and approach your
system limits faster than using a file system.
But for a limited amount of images, there isn't
any real problems.



For a small enough site you can encode all your images inside a bigger image
using stenography. Bad solutions generally work for small enough sites.
Failing to plan for the growth of your site is however a bad idea.

And granted, pulling images from mySQL to be used

in web sites are slightly slower and present
refresh differences between some browsers, but
that's certainly not a reason to say that mySQL
is categorically not suited for the storage of
binary files -- like with everything else, there
are trade-offs. Do you not see that?



We're not talking about generic binary files. We're talking about images
images that people upload. Using blobs to store small (order of kbs) of
transient data is fine. I just don't want to end up maintaining systems that
store images in the sql db.

---


At 1:53 AM +1000 5/11/06, Peter Hoskin wrote:
So, if ASCII and Binary are both codesets... which does SQL use to store
its data?

Is ASCII stored differently than binary on a hard drive?

From my limited experience in using a hex editor,
the data all looks the same to me. If it wasn't
for my hex editor, I would be looking at 1's and
0's, right?

After all, isn't an image in a file system stored
on a hard drive the exact same fashion as an
image stored on a hard drive via mySQL?

The only difference I can see is in overhead --
but then again, I may be a Moron or an Idiot like
Rory Browne suggests.


I notice you took the first two words of my post and ignored the rest - I
also allowed the option of newbie. my biggest problem with it is the
administration difficulties this presents.



Perhaps someone might enlighten me as to why

mySQL is not suited to store images -- and prove
it.


At work our MySQL DB recently hit a 4G limit in the table storage Engine.
That wouldn't have happened if a competant programmer had set it up to put
the images in the FS.


And for goodness sake NO, Google is NOT always

right -- it's only a collection of everyone's
view. When did Google replace valid research? I
can see tomorrow's mother's saying to their
children If Google jumped off a bridge, would
you do it?

Let's get real about what Google can offer.
Specificity is inversely proportional to the
number of people voicing an opinion. I would
guess that even Morons and Idiots know that.


Okay - you're right, and everyone who put up sites on this topic, that got
indexed by google is wrong.

tedd


Typical disclaimers apply -- I did not mean to
offend anyone nor to imply that anyone is an
Idiot or a Moron. Your mileage may vary. No
warranties expressed or implied. This is not a
solicitation for an investment opportunity.
Consult you doctor before applying.  No hable
inglés.

--


http://sperling.com

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




Re: [PHP] Re: Re: Upload File (binary files?)

2006-05-15 Thread Rory Browne

On 5/15/06, tedd [EMAIL PROTECTED] wrote:


At 12:18 AM +0200 5/14/06, Michelle Konzack wrote:
Am 2006-05-12 09:28:36, schrieb tedd:

  But, at some point (and I forgot to mention this in my previous post)
  all programmers start thinking in collections of data and a dB
  becomes a well suited solution (record holder and organizer) for
  that. As such, all data connected to a record, including images, are
   better suited if organized and saved in one place.

-snip-

The overhead form getting a pic from the database is bigger then
from a filesystem.  I had allready tried it.  I can resize on the
fly too.  Now, where is the problem, if a php script get the pic
from a filserver using http or ftp?

Well... if you define the problem in terms of If it can be done
then there's no real problem.

But the purpose of programming is to gather, organize, process, and
display data. We do this under the paradigm of keep it simple --
the simpler is usually the better.

I only said that from a programming perspective -- of collecting and
placing data into organizable groups -- keeping things in one system
is preferable (simpler) than dividing things up into different
organizational elements (i.e., file system v dB).

Plus, a dB has search capabilities that a file system doesn't --
that's probably the reason why dB's came into existence, right?



Last time I checked we had tools to search the filesystem. locate, find and
awk spring to mind.




As for overhead and time to process stuff -- that's just a current

observation and the problem (if there is one) will most certainly
pass.

I think the future on this is pretty clear as to what regime will be
preferable for data organization. Not that I'm implying such to you,
I remember DOS types saying What moron will ever use a mouse? and
now they're saying Only Idiots and Morons place images in dB's.

To each their own.



lets just hope I never have to maintain your code.

tedd

--


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

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




Re: [PHP] Re: Re: Upload File (binary files?)

2006-05-15 Thread tedd

Plus, a dB has search capabilities that a file system doesn't --
that's probably the reason why dB's came into existence, right?

Last time I checked we had tools to search the filesystem. locate, 
find and awk spring to mind.


So, you are claiming that those file-system tools match all the 
functionally that MySQL offers? Interesting -- when was the last time 
you looked into that claim?



As for overhead and time to process stuff -- that's just a current
observation and the problem (if there is one) will most certainly
pass.

I think the future on this is pretty clear as to what regime will be
preferable for data organization. Not that I'm implying such to you,
I remember DOS types saying What moron will ever use a mouse? and
now they're saying Only Idiots and Morons place images in dB's.

To each their own.

lets just hope I never have to maintain your code.


We're not talking about my code, nor did I make this thread personal. 
Attacks on me do nothing to support your argument.


tedd
--

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

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



Re: [PHP] Views on e-commerce download tracking

2006-05-15 Thread tedd

At 1:38 PM +0200 5/15/06, Chris Grigor wrote:

Hey all

Was just wondering what others have used on there e-commerce sites 
to manage digital downloads, for instance how to track if a user 
succesfully downloaded a complete file from you (what happens if 
there connection drops halfway through a download)


Is there something in php / javascript that could do this - 
javascript:oncomplete_ofdownloadfile send response to server

Anyone have any ideas?

Your views / suggestions are appreciated.
Chris


Chris:

Just a suggestion -- many times I've download digital stuff I 
purchased. In most cases, the seller just provides a url and I 
download as I may. If the connection drops, or if I interrupt it, or 
it doesn't work for some reason or another, then I am free to try 
again. If after repeated failures, then I'll contact the seller and 
find another means to get what I purchased.


However, in none of many downloads I've experienced (from memory) 
showed any signs that the download had been successfully completed.


So, based upon that -- I wouldn't worry about it.

hth's

tedd

--

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

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



[PHP] Development Environments/Automation

2006-05-15 Thread Brian Anderson

Hello,

I am being asked to find some sort of development environment for 
PHP/MySQL, if is exists, in which it has some sort of 
automation/wizzardry. What is being done is a mass of MSAccess 
interfaces, forms, reports, etc. are needing to be re-written in php and 
connected to a MySQL database instead of the Access.


What is being asked for is something that although being able to build 
some interfaces through wizzards/gui's, that is be somewhat logical, and 
streamlined in its management of code and html.  Something that 
implements some kind of smarty tag or similar woould be good instead of 
say... Macromedia which can do some fairly bloated and cumbersome things 
with logic and markup. Also, It would need to be flexible enough to 
manage projects back and forth between wizzards, and hand coding so that 
one wasn't limited to the narrow applications of the wizzard.


Does something like this exist?

I have played around with Macromedia, and another app called CodeCharge 
Studio. I hope that I am asking the right or at least an intelligent 
question.


-Brian

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



Re: [PHP] Copy of image - smaller

2006-05-15 Thread Gustav Wiberg


- Original Message - 
From: Chris [EMAIL PROTECTED]

To: Gustav Wiberg [EMAIL PROTECTED]
Cc: PHP General php-general@lists.php.net
Sent: Monday, May 15, 2006 9:42 AM
Subject: Re: [PHP] Copy of image - smaller



Gustav Wiberg wrote:

Hi there!

When I upload a picture from a form, then I want to create a copy with a 
smaller image.
For example: I upload a picture with dimensions 200x150 name 4.jpg. I 
also want a copy of this image but with the dimensions 100x75 pixels. 
I've tried this below, but I'm missing something I think... :-)


I'm using PHP 4.x  (don't know exactly the vers.nr, but I can search for 
it if it is of importance)


First of all *run* to this thread and add some security checks to your 
image uploading:


http://marc.theaimsgroup.com/?l=php-generalm=114755779206436w=2

Secondly, what does or doesn't happen with your code?

It looks fine at first glance but do you get an error? What do you expect 
it to do and what does it actually do?


--
Postgresql  php tutorials
http://www.designmagick.com/

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


Hi there!

Thanx for tip about security!

There is no errors displayed, but the file test.jpg isn't created. It isn't 
accessible when accessing http://www.ledins.se/test.jpg


Best regards
/Gustav Wiberg

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



Re: [PHP] Check before uploading

2006-05-15 Thread Gustav Wiberg


- Original Message - 
From: Stut [EMAIL PROTECTED]

To: Gustav Wiberg [EMAIL PROTECTED]
Cc: PHP General php-general@lists.php.net
Sent: Monday, May 15, 2006 12:50 PM
Subject: Re: [PHP] Check before uploading



Gustav Wiberg wrote:

Just a thought. Someone posted a question if you could check filesize 
before uploading some days ago. Maybe this is possible with Javascript?
Javascript wouldn't be the best solution, cause of it's incompability 
between browsers, that users can inactivate it. But it's might be 
better than nothing.. The important thing is not to RELY on the 
Javascript-code.



This was suggested at the time, but for what should be obvious reasons 
it's not possible due to security restrictions.


-Stut


Hi there!

Ok, do you have a solution the problem now?

Best regards
/Gustav Wiberg

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



Re: [PHP] Copy of image - smaller

2006-05-15 Thread Gustav Wiberg


- Original Message - 
From: Rabin Vincent [EMAIL PROTECTED]

To: Gustav Wiberg [EMAIL PROTECTED]
Cc: PHP General php-general@lists.php.net
Sent: Monday, May 15, 2006 1:35 PM
Subject: Re: [PHP] Copy of image - smaller


On 5/15/06, Gustav Wiberg [EMAIL PROTECTED] wrote:
[snip]

//What should/could I do here?
//

//Set new width and height
//
   $new_width = 100;
   $new_height = 200;
   $tmp_image=imagecreatefromjpeg($toPath . $mfileAdd);
   $width = imagesx($tmp_image);
   $height = imagesy($tmp_image);
   $new_image = imagecreatetruecolor($new_width,$new_height);
ImageCopyResized($new_image, $tmp_image,0,0,0,0, $new_width,
$new_height, $width, $height);


I can't see anything wrong with this resizing.


//Grab new image
ob_start();
ImageJPEG($new_image);
$image_buffer = ob_get_contents();
ob_end_clean();
ImageDestroy($new_image);
//Create temporary file and write to it
$fp = tmpfile();
fwrite($fp, $image_buffer);
rewind($fp);


Instead of doing this, you may want to use the filename
argument of ImageJPEG to save the image directly to a file.


//Upload new image
$copyTo = 'http://www.ledins.se/test.jpg';
$conn_id = ftp_connect('domain');
ftp_login($conn_id,'username for domain','password');
ftp_fput($conn_id, $copyTo, $fp, FTP_BINARY);


Destination file ($copyTo) is supposed to be a path (eg.
public_html/test.jpg) and not a URL.

Ok! Thanx, that might be the problem! :-)

Best regards
/Gustav Wiberg

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



Re: [PHP] Failing FastCGI PHP

2006-05-15 Thread Mike Milano

chris smith wrote:

On 5/14/06, Frank de Bot [EMAIL PROTECTED] wrote:

I'll start by compiling php with --enable-debug

At the moment I get backtrace results like this:

#0  0x48c7d95b in memcpy () from /usr/lib/libc_r.so.4
#1  0x8977280 in ?? ()
#2  0x10 in ?? ()
#3  0x894e500 in ?? ()
#4  0x894dc00 in ?? ()
#5  0x8962000 in ?? ()
#6  0x8960200 in ?? ()
#7  0x894e4e0 in ?? ()
#8  0x894e4c0 in ?? ()
etc etc etc...

Thus useless :P


Unfortunately yes, rather useless :(

Might get better help on the internals list (I don't know what else to
suggest, was hoping someone else might jump in and help you!).




There seems to be a bug with 5.1.4 and FastCGI.  I'm running Windows and 
had an issue with 5.1.4 as well.  I reported a but and was advised to 
try 5.2 from http://snaps.php.net/


FastCGI works for me with 5.2.

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



RE: [PHP] Paged Results Set in MySQL DB with one result

2006-05-15 Thread Chris W. Parker
tedd mailto:[EMAIL PROTECTED]
on Friday, May 12, 2006 12:23 PM said:

 That's as it should be -- and technically, Next did appear so the
 page wasn't blank.

Splitting hairs aside, a user, civilian or not, would not expect they
need to click Next from a blank page to get to the content they are
looking for.

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



Re: [PHP] Sessions - session_start()

2006-05-15 Thread tedd

At 4:33 PM +0200 5/15/06, Jonas Rosling wrote:

Den 06-05-15 16.00, skrev Thomas Munz [EMAIL PROTECTED]:


 put ob_start(); on the first line of your page

 on Monday 15 May 2006 15:53, Jonas Rosling wrote:

 Hi,
 I've been building a site with PHP 5 on my develop machine. I've been
 woring alot with session handling. For example I've been using
 session_start() now and then depending on where the user/vistor are or are
 doing.
 But now I've moved the site to a host server with PHP 4.3.8 and now I keep

  getting error messages all the time where I use session_start(). The error

 message looks like this:

 Warning: session_start(): Cannot send session cookie - headers already sent
 by (output started at /var/www/html/index.php:9) in /var/www/html/index.php
 on line 82

 But I found out that if I put the tag in the absolute top of every page it
 seems to work. But then I need to do alot of changes on all the pages.

 Does anyone know if there's any workaround for this?

 Thanks in advance // Jonas


ob_start(); doesn't change anything in my case. But thanks anyway.

// Jonas

-


ob_start() was only half a possible solution:

http://www.weberdev.com/ob_start

There's the other part ( ob_end_flush ) that makes it work:

http://www.weberdev.com/ob_end_flush

However, as I understand it, using session_start() requires it to be 
the first line before everything else.


tedd
--

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

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



Re: [PHP] Re: PHP output stream

2006-05-15 Thread Stut

[EMAIL PROTECTED] wrote:

Thanks for your answer. I already have thought about your solution. The problem
is I have to use the Perl module for PHP. An example :

$perl = new Perl();
$perl-require('mct.pl');
$perl-MCT_polling();

where MCT_polling() is a function of my script mct.pl. I would find very strange
the fact it's impossible to manipulate PHP stdout stream.


This *should* work...

ob_start();
$perl-MCT_polling();
ob_end_clean();

See the manual pages for output buffering for full details on what it 
can do.


-Stut

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



Re: [PHP] Check before uploading

2006-05-15 Thread Stut

Gustav Wiberg wrote:

From: Stut [EMAIL PROTECTED]

Gustav Wiberg wrote:

Just a thought. Someone posted a question if you could check filesize 
before uploading some days ago. Maybe this is possible with Javascript?
Javascript wouldn't be the best solution, cause of it's incompability 
between browsers, that users can inactivate it. But it's might be 
better than nothing.. The important thing is not to RELY on the 
Javascript-code.


This was suggested at the time, but for what should be obvious reasons 
it's not possible due to security restrictions.


Ok, do you have a solution the problem now?


It wasn't my problem, and not I don't really have the solution. There 
really isn't a solution short of using a Java applet. PHP doesn't get a 
look in until the file has been uploaded, and Javascript doesn't have 
the security scruples.


-Stut

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



Re: [PHP] Sessions - session_start()

2006-05-15 Thread tg-php
session_start() doesn't need to be the first line of your PHP code, it just 
needs to be called before any other output is performed.  Including any blank 
spaces or anything else.  If you have:

---
1:
2: ?php
3:   session_start();
4: ?
---

It's not going to work because you have a blank line being output to the 
browser for interpretation.  Same problem would occur if you even had:

---
1: ?php   // Leading single blank space character
2:   session_start();
3: ?
---

Output buffering may help in some cases, but I'd look at the error where it 
says:

output started at /var/www/html/index.php:9

Sounds like there's a way to solve this without resorting to output buffering.

In addition to the basic command reference listed below, check out the user 
contributed comments on these pages:

http://www.php.net/manual/en/function.session-start.php

http://www.php.net/manual/en/function.ob-start.php

According to the first comment, ob_end_flush() is called automatically at the 
end of your script, so it's not mandatory that you use it (but probably good 
'complete' programming practice).

Good luck Jonas.

-TG

= = = Original message = = =

At 4:33 PM +0200 5/15/06, Jonas Rosling wrote:
Den 06-05-15 16.00, skrev Thomas Munz [EMAIL PROTECTED]:

  put ob_start(); on the first line of your page

  on Monday 15 May 2006 15:53, Jonas Rosling wrote:
  Hi,
  I've been building a site with PHP 5 on my develop machine. I've been
  woring alot with session handling. For example I've been using
  session_start() now and then depending on where the user/vistor are or are
  doing.
  But now I've moved the site to a host server with PHP 4.3.8 and now I keep
   getting error messages all the time where I use session_start(). The error
  message looks like this:

  Warning: session_start(): Cannot send session cookie - headers already sent
  by (output started at /var/www/html/index.php:9) in /var/www/html/index.php
  on line 82

  But I found out that if I put the tag in the absolute top of every page it
  seems to work. But then I need to do alot of changes on all the pages.

  Does anyone know if there's any workaround for this?

  Thanks in advance // Jonas

ob_start(); doesn't change anything in my case. But thanks anyway.

// Jonas

-

ob_start() was only half a possible solution:

http://www.weberdev.com/ob_start

There's the other part ( ob_end_flush ) that makes it work:

http://www.weberdev.com/ob_end_flush

However, as I understand it, using session_start() requires it to be 
the first line before everything else.

tedd


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



[PHP] DOMElement-setAttribute() loops forever (node_list_unlink bug?)

2006-05-15 Thread Riku Palomäki
Hello,

I'm having problems with DOMElement-setAttribute() -method with my php
script. I stripped down the code to this:

--
$doc = new DOMDocument();
$doc-resolveExternals = true;
$doc-loadXml('!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;a b= /');

$root = $doc-getElementsByTagName('a')-item(0);
$root-setAttribute('b', 'gt;');
$root-setAttribute('b', '');

// This will never be executed
echo done\n;
--


That another setAttribute() -call never finishes, and the script will
just eventually die because of PHP Fatal error:  Maximum execution
time.. I have tried this with cgi and cli versions of PHP 5.1.4, 5.1.1
and 5.0.5 on different servers (and different ISPs).

When running, php-process takes all CPU. I tried to debug it with gdb
and got this backtrace: http://www.palomaki.fi/dev/tmp/bt.txt - I ran
it, waited for ~5 seconds, and hit ctrl+c to pause the program to get
the backtrace. node_list_unlink seems to be calling itself forever.

Is there something I don't get, or should I just fill the bug report?

-- 
Riku Palomäki

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



Re: [PHP] Check before uploading

2006-05-15 Thread Gustav Wiberg


- Original Message - 
From: Stut [EMAIL PROTECTED]

To: Gustav Wiberg [EMAIL PROTECTED]
Cc: PHP General php-general@lists.php.net
Sent: Monday, May 15, 2006 10:32 PM
Subject: Re: [PHP] Check before uploading



Gustav Wiberg wrote:

From: Stut [EMAIL PROTECTED]

Gustav Wiberg wrote:

Just a thought. Someone posted a question if you could check filesize 
before uploading some days ago. Maybe this is possible with Javascript?
Javascript wouldn't be the best solution, cause of it's incompability 
between browsers, that users can inactivate it. But it's might be 
better than nothing.. The important thing is not to RELY on the 
Javascript-code.


This was suggested at the time, but for what should be obvious reasons 
it's not possible due to security restrictions.


Ok, do you have a solution the problem now?


It wasn't my problem, and not I don't really have the solution. There 
really isn't a solution short of using a Java applet. PHP doesn't get a 
look in until the file has been uploaded, and Javascript doesn't have the 
security scruples.


-Stut

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


Ok!

Best regards
/Gustav Wiberg 


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



[PHP] cURLing sites for images

2006-05-15 Thread Wolf
OK, I give up (for now at least).  I've been trying to figure out a way
to run a single script and download my favorite comics.  The problem is
that:

1.  The URLs include numerous websites (and the image is hosted on
another server from the original)
2.  The filename can change but has the same basic name

What I would love to do is use cURL to load the list of URLs, and then
save all the images within each page into a directory based off the
date.  What I have not been able to figure out how to do is use CURL to
open the page and save all the *.gif and *.jpg files only.

Anyone have a good pointer on this?  I've been going through the
archives and some tutorials, but most seem for posting to another site,
not snagging files.

Thanks,
Wolf

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



Re: [PHP] imagefrompng() question

2006-05-15 Thread Richard Lynch
On Mon, May 15, 2006 9:16 am, D A GERM wrote:
 I'm having difficulty displaying text after imagefrompng().  I'm using
 PEARS's Image_Barcode to displa a barcode and trying to wrap
 imagefrompng() around it.  I am able to display the barcode properly
 but
 not the rest of my document (a mix a text and other images).

 Is there a proper heading I should use?  I been looking over the docs
 for imagefrompng() and PEAR's Image_Barcode but have not found
 anything
 useful to offer a solution to my problem.  Any suggestions?

You cannot slam both the image and your HTML into a single URL /
document.

You need more like:

somepage.php
htmlbodyimg src=image.php /This is text output./body/html

image.php
?php
  $image = imagecreatetruecolor(400, 300);
  header(Content-type: image/png);
  imagepng($image);
?

So you need SEPARATE URLs and files for the HTML and the PNG --
exactly the same as you would with static HTML and PNGs.

Or any image format, not just PNG.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] cURLing sites for images

2006-05-15 Thread Richard Lynch
On Mon, May 15, 2006 5:36 pm, Wolf wrote:
 OK, I give up (for now at least).  I've been trying to figure out a
 way
 to run a single script and download my favorite comics.  The problem
 is
 that:

 1.  The URLs include numerous websites (and the image is hosted on
 another server from the original)
 2.  The filename can change but has the same basic name

 What I would love to do is use cURL to load the list of URLs, and then
 save all the images within each page into a directory based off the
 date.  What I have not been able to figure out how to do is use CURL
 to
 open the page and save all the *.gif and *.jpg files only.

A preg to find the .gif and .jpg files, and then you need to use
CURLOPT_BINARYTRANSFER to get the .gif/.jpeg

If you switch back and forth to text/binary, you'll want to get PHP
from CVS, cuz there was a bug:
http://bugs.php.net/bug.php?id=37061

Thank [deity] the PHP Devs could take my meandering ill-formed bug
report and turn it into something useful... :-^

 Anyone have a good pointer on this?  I've been going through the
 archives and some tutorials, but most seem for posting to another
 site,
 not snagging files.

It should look something like this:

?php
$cookie_file = '/path/to/php/writable/file/somwhere/cookies.txt';

//basic curl handle:
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file);
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_file);

//snag HTML
curl_setopt($curl, CURLOPT_URL, 'http://example.com');
$html = curl_exec($curl);

//Find the images:
//This pattern is almost for sure wrong cuz I suck at PCRE:
preg_match_all('/img[^]+src=([^]+)/iS', $html, $images);
$images = $images[1];

//snag each image in turn:
curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1);
foreach($images as $image_url){
  curl_setopt($curl, CURLOPT_URL, $image_url);
  $image = curl_exec($curl);
  file_put_contents(/some/path/to/where/you/want/images/$image_url,
$image);
}
?

This is untested code off the top of my head, but it should be pretty
close.

You could maybe use Tidy or something DOM-like to find the images in
the URL if you were more of a purist, but I'm assuming that isn't the
issue, based on your post.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Re: PHP output stream

2006-05-15 Thread Richard Lynch
On Mon, May 15, 2006 8:53 am, nicolas figaro wrote:
 [EMAIL PROTECTED] a écrit :
 Thanks for your answer. I already have thought about your solution.
 The problem
 is I have to use the Perl module for PHP. An example :

 $perl = new Perl();
 $perl-require('mct.pl');
 $perl-MCT_polling();

 where MCT_polling() is a function of my script mct.pl. I would find
 very strange
 the fact it's impossible to manipulate PHP stdout stream.

 can't you edit the mct.pl script so the MCT_polling function won't
 output anything ?

Or wrap it in another shell script to do the re-directs?

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Sessions - session_start()

2006-05-15 Thread Richard Lynch
On Mon, May 15, 2006 8:53 am, Jonas Rosling wrote:
 Warning: session_start(): Cannot send session cookie - headers already
 sent
 by (output started at /var/www/html/index.php:9) in
 /var/www/html/index.php
 on line 82

 But I found out that if I put the tag in the absolute top of every
 page it
 seems to work. But then I need to do alot of changes on all the pages.

This *is* the right answer, from a structured logical code point of view.

 Does anyone know if there's any workaround for this?

The reason it works on your dev site is that you've got output
buffering turned on in php.ini -- which is a workaround, but I
honestly believe you'd be better off re-factoring your code, in the
long run.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Create database with pdo_mysql

2006-05-15 Thread Richard Lynch
On Mon, May 15, 2006 7:18 am, Kevin Waterson wrote:
 Is it possible to create a database with pdo_mysql?
 $dbh = new PDO(mysql:host=$hostname;dbname=my_db, $username,
 $password);
 is sort of what it requires... is there some way to omit the dbname?

If you can't elminate it, 'mysql' as a dbname= is gonna work on
virtually every MySQL server.

That's where the username/password tables live.

'Course, you may not be allowed to connect to that database with the
login info you have...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Views on e-commerce download tracking

2006-05-15 Thread Richard Lynch
On Mon, May 15, 2006 6:38 am, Chris Grigor wrote:
 Was just wondering what others have used on there e-commerce sites to
 manage digital downloads, for instance how to track if a user
 succesfully downloaded a complete file from you (what happens if there
 connection drops halfway through a download)

 Is there something in php / javascript that could do this -
 javascript:oncomplete_ofdownloadfile send response to server
 Anyone have any ideas?

I can guarantee that anything you THINK does this will not work under
ALL conditions.

You're better off to give them a login and let them re-download it a
reasonable number of times -- much simpler, and will not give you
anywhere near as much grief.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Perl PHP output format mismatching

2006-05-15 Thread Richard Lynch
On Mon, May 15, 2006 4:21 am, [EMAIL PROTECTED] wrote:
 I'm currently writing a PHP page, which uses a small Perl script. But
 I
 encounter an annoying problem with endline character.

 A small example :

 $perl = new Perl();
 $perl-eval('print toto\ntata');

Your apostrophes in PHP don't interpolate anything except:
\' an embedded apostrophe
\\ an embedded backslash

$perl = new Perl();
$perl-eval(print \toto\ntata\);

would work.

If Perl is okay with ' for a string delimiter, this would also work:
$perl-eval(print 'toto\ntata');
and maybe be more readable to a novice PHP developer.

Homework:
http://php.net/manual/en/language.types.string.php

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Development Environments/Automation

2006-05-15 Thread Miles Thompson

At 02:01 PM 5/15/2006, Brian Anderson wrote:


Hello,

I am being asked to find some sort of development environment for 
PHP/MySQL, if is exists, in which it has some sort of 
automation/wizzardry. What is being done is a mass of MSAccess interfaces, 
forms, reports, etc. are needing to be re-written in php and connected to 
a MySQL database instead of the Access.


What is being asked for is something that although being able to build 
some interfaces through wizzards/gui's, that is be somewhat logical, and 
streamlined in its management of code and html.  Something that implements 
some kind of smarty tag or similar woould be good instead of say... 
Macromedia which can do some fairly bloated and cumbersome things with 
logic and markup. Also, It would need to be flexible enough to manage 
projects back and forth between wizzards, and hand coding so that one 
wasn't limited to the narrow applications of the wizzard.


Does something like this exist?

I have played around with Macromedia, and another app called CodeCharge 
Studio. I hope that I am asking the right or at least an intelligent question.


-Brian


Do you mean a framework?

Have a look at Qcodo, Cake, etc. Qcodo allows you to preserve your 
interface while making logic / database changes.


Regards - Miles Thompson 



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.392 / Virus Database: 268.5.6/339 - Release Date: 5/14/2006

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



Re: [PHP] Copy of image - smaller

2006-05-15 Thread Richard Lynch

I'd make a wild guess that the FTP stuff isn't working...

Your biggest mistake is a total lack of error-handling...




On Mon, May 15, 2006 2:03 am, Gustav Wiberg wrote:
 Hi there!

 When I upload a picture from a form, then I want to create a copy with
 a
 smaller image.
 For example: I upload a picture with dimensions 200x150 name 4.jpg. I
 also
 want a copy of this image but with the dimensions 100x75 pixels. I've
 tried
 this below, but I'm missing something I think... :-)

 I'm using PHP 4.x  (don't know exactly the vers.nr, but I can search
 for it
 if it is of importance)

 The code down below is a function for uploading a picture. The part I
 want
 help with is after the comment: //What should/could I do here?

 Best regards
 Gustav Wiberg



 ?php
 function uploadPic($idUpload, $picUpload, $addUpload, $copyFile,
 $toPath) {

//Upload chosen file to upload-map (
//
if (strlen($_FILES[$picUpload]['name'])0)
{
//ECHO yes! ID=$idUpload PIC=$picUpload ADD=$addUploadbr;
$uploaddir = dirname($_FILES[$picUpload]['tmp_name']) . /;

//Replace .jpeg to .jpg
//
$_FILES[$picUpload]['name'] =
 str_replace(.jpeg,.jpg,$_FILES[$picUpload]['name']);

//Get first 4 last characters of uploaded filename
//
$ble = strtolower(substr($_FILES[$picUpload]['name'], -4, 4));

//Move to path $toPath (followed by what to add after file (that is
 sent
 to this function)) and ext.)
//
$mfileAdd = $idUpload . $addUpload . $ble;

move_uploaded_file($_FILES[$picUpload]['tmp_name'], $toPath .
 $mfileAdd);


//echo mfileAdd=$mfileAddbrbr;
//Set appropiate rights for file
//
//echo FILE TO TEST=$mfileAdd;
chmod($toPath . $mfileAdd, intval('0755', 8));


//Copy this file to another file?
//
if (strlen($copyFile)0) {
$mfile = $idUpload . $copyFile . $ble;
//echo MFILE=$mfile;
copy($toPath . $mfileAdd, $toPath . $mfile);
chmod($toPath . $mfile, intval('0755', 8));
}


 //What should/could I do here?
 //

 //Set new width and height
 //
$new_width = 100;
$new_height = 200;
$tmp_image=imagecreatefromjpeg($toPath . $mfileAdd);
$width = imagesx($tmp_image);
$height = imagesy($tmp_image);
$new_image = imagecreatetruecolor($new_width,$new_height);
 ImageCopyResized($new_image, $tmp_image,0,0,0,0,
 $new_width,
 $new_height, $width, $height);

 //Grab new image
 ob_start();
 ImageJPEG($new_image);
 $image_buffer = ob_get_contents();
 ob_end_clean();
 ImageDestroy($new_image);

 //Create temporary file and write to it
 $fp = tmpfile();
 fwrite($fp, $image_buffer);
 rewind($fp);

 //Upload new image
 $copyTo = 'http://www.ledins.se/test.jpg';
 $conn_id = ftp_connect('domain');
 ftp_login($conn_id,'username for domain','password');
 ftp_fput($conn_id, $copyTo, $fp, FTP_BINARY);
 fclose($fp);



//Return the filename created based on productID
//
return $mfileAdd;
}



 }


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




-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Security Concerns with Uploaded Images:

2006-05-15 Thread Richard Lynch
On Mon, May 15, 2006 1:58 am, Jason Wong wrote:
 2) the uploaded file is a script (perl/php/python/etc)

 In the case of (2), if the script relies on its shebang line to
 execute

Not necessarily -- What if I upload an image file named
badscript.php and then I surf to it, after it's in your /images
directory?

Game Over


If you want Shifflet's view, just go to http://phpsec.org

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Re: DOMElement-setAttribute() loops forever (node_list_unlink bug?)

2006-05-15 Thread Rob Richards

Riku Palomäki wrote:

Hello,

I'm having problems with DOMElement-setAttribute() -method with my php
script. I stripped down the code to this:

--
$doc = new DOMDocument();
$doc-resolveExternals = true;
$doc-loadXml('!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;a b= /');

$root = $doc-getElementsByTagName('a')-item(0);
$root-setAttribute('b', 'gt;');
$root-setAttribute('b', '');

// This will never be executed
echo done\n;
--


Can you please bug this (no need for the backtrace), so I don't forget 
it. I see the problem but will take me a day or two to get around to fix.


As a work around for now you can do:
$root-setAttributeNode(new DOMAttr('b', 'gt;'));
$root-setAttribute('b', '');

Rob

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



Re: [PHP] Going nuts with this, cant figure out whats the prob

2006-05-15 Thread Richard Lynch
On Mon, May 15, 2006 7:30 am, Ryan A wrote:
 The thing is, I thought this was bundled with the
 standard package of PHP, if yes, why would anybody
 want to turn this off?

PCRE got added after POSIX Regex had been in awhile.

There was some resistance to having two Regexes in PHP.

I think the default is on these days for PCRE.

One viable reason to turn it off might be to conserve RAM -- I
daresay PCRE takes up a goodly chunk of RAM for its codebase, if
you're really scrimping and saving...  This would make more sense in
something like an embedded PHP app rather than shared hosting
environment.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] php-cli and daemon

2006-05-15 Thread Richard Lynch
On Sat, May 13, 2006 5:40 pm, Michelle Konzack wrote:
 I run a webserver which is a frontend for a huge PostgreSQL database.
 Now I like to code some stand-alone Apps, which can connect to a
 daemon uploading files and geting infos from the database

 (NO, the have no right to connect directly to the database)

 Questions for now:

 1)  How to code a daemon?

http://php.net/sockets

 2)  How to use ssl-certs for the connection?
 The $USER must use an USB-Key with its one cert.

Ya got me there...

You may want to look into http://gtk.php.net for coding the GUI part
of the stand-alone client application.  And that MIGHT have some
built-in SSL stuff to make this crystal-clear and dead easy...

I'm a bit confused between the deamon, the uploading files, and the
read-only access to the database, personally...

That said, the PostgreSQL documentation probably has pretty clear
description of how to do an SSL connection if it can be done, and
workarounds if it can't:
http://postgresql.org/

You might also consider tunneling all the data, uploads and PostgreSQL
through SSH as a sort of Poor Man's VPN deal...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Copy of image - smaller

2006-05-15 Thread Alberto Ferrer

For that i recomend detect the MIME, my 2 cents:

function image_get_info($image) {
 $details = array();
 $data = @getimagesize($image);
 if (is_array($data)){
   $types = array(
   '1' = 'GIF',
   '2' = 'JPEG',
   '3' = 'PNG',
   '4' = 'SWF',
   '5' = 'PSD',
   '6' = 'BMP',
   '7' = 'TIFF',
   '8' = 'TIFF',
   '9' = 'JPC',
   '10' = 'JP2',
   '11' = 'JPX',
   '12' = 'JB2',
   '13' = 'SWC',
   '14' = 'IFF',
   '15' = 'WBMP',
   '16' = 'XBM'
   );
   $type = array_key_exists($data[2], $types) ? $types[$data[2]] :
'Tipo de Imagen No valida o Desconocida';
   $details = array('width' = $data[0],
'height'= $data[1],
'type'  = $type,
'mime_type' = $data['mime']
);
 }
 return $details;
}

i cutpaste :P
2006/5/15, Chris [EMAIL PROTECTED]:

Gustav Wiberg wrote:
 Hi there!

 When I upload a picture from a form, then I want to create a copy with a
 smaller image.
 For example: I upload a picture with dimensions 200x150 name 4.jpg. I
 also want a copy of this image but with the dimensions 100x75 pixels.
 I've tried this below, but I'm missing something I think... :-)

 I'm using PHP 4.x  (don't know exactly the vers.nr, but I can search for
 it if it is of importance)

First of all *run* to this thread and add some security checks to your
image uploading:

http://marc.theaimsgroup.com/?l=php-generalm=114755779206436w=2

Secondly, what does or doesn't happen with your code?

It looks fine at first glance but do you get an error? What do you
expect it to do and what does it actually do?

--
Postgresql  php tutorials
http://www.designmagick.com/

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





--
bet0x

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



Re: [PHP] Wierd ass code...

2006-05-15 Thread Richard Lynch
On Sat, May 13, 2006 2:20 pm, Ryan A wrote:
 Been reading some other code that I got from the net,
 and  have come across some wierd looking code, would
 appreciate it if someone could explain it to me:

 $hits = array();
 $bytes = array();
 $blocked = array();
 $baps = array();
 $bapm = array();

 So far so good then further down:

 // Add to the running totals
 @$hits[$username|$subnet]++;
 @$bytes[$username|$subnet]+=$byte;
 @$baps[$username|$subnet|$this_second]++;
 @$bapm[$username|$subnet|$this_minute]++;

@ is suppressing the E_NOTICE error message that the variables are not
pre-set.

This is BAD if register_globals is ON as it means that somebody would
use:
http://example.com/example.php?hits[user|192.168]=1
to forge the hit counters

The rest of it is just funky array indexes, and the ++ operator to add
1 to each thingie.

Homework:
http://www.php.net/manual/language.operators.errorcontrol.php

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] METHOD=POST not worikng

2006-05-15 Thread Richard Lynch
On Sat, May 13, 2006 9:16 am, IraqiGeek wrote:
 I'm learning PHP on a  Debian Etch with Apache 2.0.54 and PHP 4.3.10,
 and
 using Firefox 1.5.3 on a Windows XP box to browse the sample site. I
 wrote a
 small form to get user input. If I use METHOD=GET, then the form works
 fine,
 without any glitches. However, if I use METHOD=POST in the form, I
 don't get
 the data back to the script.

 Googling around, I found a reference to mod_bandwidth, but AFAIK, this
 module is used to regulate/limit user traffic.

 Are there any modules missing that prvent METHOD=POST from working
 properly?
 any config files that need to be edited?

httpd.conf for Apache can be configured to not accept POST data.

I believe some default httpd.conf settings did just that, in olden
days...

You'd be getting an error message from the server if that was the
case, though.

What are you using to try to SEE the data?

It's also possible that php.ini settings for EGCPS order preference
(whose name is escaping me) might be badly-configured enough to cause
this...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] touch()ing it....advise needed.

2006-05-15 Thread Richard Lynch
You could just do a touch() on all the files with no test for
existence, if there will be a LOT of files...

That will save a little bit of work, and might be worthwhile info to
track, or at least not mess things up to have the filemtime altered
all the time.

Of course, you also need to be VERY careful with filename so that
something like:
../../../../../../etc/passwd
won't work.

On Sat, May 13, 2006 7:48 am, Ryan A wrote:
 Hey,
 Heres my setup, I have a directory full of files and I
 get a request with an array of filenames
 For this example:
 a.txt
 b.txt
 c.txt

 if the above files dont already exist I need to create
 them (I am using touch() instead of fopen())

 My question is which would you recommend, doing a
 readdir() and getting all the existing filenames in an
 array then doing a loop to see which exists and create
 the others OR

 just taking the new filenames, doing a while/for loop
 with a files_exists() on each and then creating the
 files

 I am favouring the second approach as in the first
 approach there are a lot of files the array could be
 pretty big which would cause other problems, but I
 would rather be corrected now if my thinking is
 flawed.

 Your advise appreciated.

 Thanks!
 Ryan

 --
 - The faulty interface lies between the chair and the keyboard.
 - Creativity is great, but plagiarism is faster!
 - Smile, everyone loves a moron. :-)
 -
 Fight back spam! Download the Blue Frog.
 http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D

 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam protection around
 http://mail.yahoo.com

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




-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] METHOD=POST not worikng

2006-05-15 Thread Richard Lynch

GET === $_GET
POST === $_POST

You have to change them in parallel.

Or, use $_REQUEST which has GET + POST + COOKIES in it.

On Sat, May 13, 2006 11:11 am, IraqiGeek wrote:
 On Saturday, May 13, 2006 4:59 PM GMT,
 [EMAIL PROTECTED] [EMAIL PROTECTED]
 wrote:

 AFAIK it should be working just fine.  I'm not aware of POST not
 working in any circumstance other than PHP not working at all.

 Can you post your test script?  We could better judge what's
 happening
 based off that.  Just make sure you're referencing the variables
 with
 $_POST or $_REQUEST, not $_GET.

 Slightly off topic.  If you're not already, always make sure to
 verify/escape your input from POST/GET/RSS/etc.  That will help make
 your pages more secure.  It might seem like you don't need to do it
 right now at the beginning, but it's a good habit to get into... One
 that I need to follow better (especially when I have a really short
 deadline).

 Ray


 PHP is indeed working. If I use METHOD=GET instead of POST, the script
 works
 without any issues. Here is the test script I'm using:
 html
 titletest script/title
 body
 ?php
   //If the user wants to add a joke
   if(isset($_GET['addtext'])):
 ?//If I use METHOD=GET here, the script works flawlessly
 form action=?php echo($_SERVER['php_self']);? METHOD=POST
 pType your text here:br
 textarea name=text rows=10 cols=40 wrap/textarea/br
 input type=submit name=submit value=SUBMIT
 /form
 ?php
   else:
   //connect to the database server
   [EMAIL PROTECTED](localhost,username,password);
   if(!$dbcnx){
   echo(pUnable to connect to the database server at 
 this
 time./p);
   exit();
   }
   //select test database
   if([EMAIL PROTECTED](test)){
   echo(pUnable to locate test database at this 
 time./p);
   exit();
   }
   //if a sample text has been submitted, add it to the database.
   if(SUBMIT==$_REQUEST['submit']){ //I have tried _GET, _POST, 
 and
 _REQUEST
   $text=$_REQUEST['text'];   //Same thing here, _GET, 
 _POST, and
 _REQUEST
   $sql=insert into test_table set .
   Text='$text', .
   Date=CURDATE();;
   if(mysql_query($sql)){
   echo(pYour text has been added./P);
   }
   else {
   echo(pError Adding submitted text: .
   mysql_error()./p);
   }
   }
   echo(pHere are all the texts in our database: /p);

   //Request the text of all the texts
   $result=mysql_query(select Text from test_table);
   if(!$result){
   echo(pError performing query: 
 .mysql_error()./p);
   exit();
   }
   //display the texts in a paragraph
   while($row=mysql_fetch_array($result)){
   echo(p.$row[Text]./p);
   }

   //when clicked, this link will load this page with the text
   //submission form displayed.

   $self=$_SERVER['PHP_SELF'];
   echo(pa href='$self?addtext=1'.
   Add a text/a/p);
   endif;
 ?
 /body
 /htmlThanks.

 Regards,
 IraqiGeek
 www.iraqigeek.com

 My computer isn't that nervous... it's just a bit ANSI.

  Original Message 
 Subject: [PHP] METHOD=POST not worikng
 From: IraqiGeek [EMAIL PROTECTED]
 Date: Sat, May 13, 2006 7:16 am
 To: PHP-General php-general@lists.php.net

 Hi all,

 I'm learning PHP on a  Debian Etch with Apache 2.0.54 and PHP
 4.3.10, and using Firefox 1.5.3 on a Windows XP box to browse the
 sample site. I wrote a small form to get user input. If I use
 METHOD=GET, then the form works fine, without any glitches.
 However,
 if I use METHOD=POST in the form, I don't get the data back to the
 script.

 Googling around, I found a reference to mod_bandwidth, but AFAIK,
 this module is used to regulate/limit user traffic.

 Are there any modules missing that prvent METHOD=POST from working
 properly? any config files that need to be edited?

 Thanks.

 Regards,
 IraqiGeek
 www.iraqigeek.com

 The average woman would rather have beauty than brains, because the
 average man can see better than he can think.


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




-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Copy of image - smaller

2006-05-15 Thread Richard Lynch
On Mon, May 15, 2006 7:09 pm, Alberto Ferrer wrote:
 For that i recomend detect the MIME, my 2 cents:

 function image_get_info($image) {
   $details = array();
   $data = @getimagesize($image);
   if (is_array($data)){
 $types = array(
 '1' = 'GIF',
 '2' = 'JPEG',
 '3' = 'PNG',
 '4' = 'SWF',
 '5' = 'PSD',
 '6' = 'BMP',
 '7' = 'TIFF',
 '8' = 'TIFF',
 '9' = 'JPC',
 '10' = 'JP2',
 '11' = 'JPX',
 '12' = 'JB2',
 '13' = 'SWC',
 '14' = 'IFF',
 '15' = 'WBMP',
 '16' = 'XBM'
 );

One might want to use the existing PHP constants here...

IMAGETYPE_GIF for example.

 $type = array_key_exists($data[2], $types) ? $types[$data[2]] :
 'Tipo de Imagen No valida o Desconocida';
 $details = array('width' = $data[0],
  'height'= $data[1],
  'type'  = $type,
  'mime_type' = $data['mime']
  );
   }
   return $details;
 }

 i cutpaste :P
 2006/5/15, Chris [EMAIL PROTECTED]:
 Gustav Wiberg wrote:
  Hi there!
 
  When I upload a picture from a form, then I want to create a copy
 with a
  smaller image.
  For example: I upload a picture with dimensions 200x150 name
 4.jpg. I
  also want a copy of this image but with the dimensions 100x75
 pixels.
  I've tried this below, but I'm missing something I think... :-)
 
  I'm using PHP 4.x  (don't know exactly the vers.nr, but I can
 search for
  it if it is of importance)

 First of all *run* to this thread and add some security checks to
 your
 image uploading:

 http://marc.theaimsgroup.com/?l=php-generalm=114755779206436w=2

 Secondly, what does or doesn't happen with your code?

 It looks fine at first glance but do you get an error? What do you
 expect it to do and what does it actually do?

 --
 Postgresql  php tutorials
 http://www.designmagick.com/

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




 --
 bet0x

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




-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Wierd ass code...

2006-05-15 Thread Richard Lynch
On Sat, May 13, 2006 6:37 pm, Rory Browne wrote:
 There are some cases where the Error Suppression operator may be
 useful in
 good code.

Last I checked, you pretty much HAD to use it for pg_fetch_row() since
it does an E_NOTICE when you try to fetch a row beyind the number
available...

You could use pg_num_rows() but that was slower, since the number of
rows would not necassarily be readily available, as I understand it.

Never did understand why that would do that. [shrug]

Things may well have changed since I looked into this almost a decade
ago...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] METHOD=POST not worikng

2006-05-15 Thread IraqiGeek

On Tuesday, May 16, 2006 1:20 AM GMT,
Richard Lynch [EMAIL PROTECTED] wrote:


On Sat, May 13, 2006 9:16 am, IraqiGeek wrote:

I'm learning PHP on a  Debian Etch with Apache 2.0.54 and PHP 4.3.10,
and
using Firefox 1.5.3 on a Windows XP box to browse the sample site. I
wrote a
small form to get user input. If I use METHOD=GET, then the form
works fine,
without any glitches. However, if I use METHOD=POST in the form, I
don't get
the data back to the script.

Googling around, I found a reference to mod_bandwidth, but AFAIK,
this module is used to regulate/limit user traffic.

Are there any modules missing that prvent METHOD=POST from working
properly?
any config files that need to be edited?


httpd.conf for Apache can be configured to not accept POST data.

I believe some default httpd.conf settings did just that, in olden
days...

You'd be getting an error message from the server if that was the
case, though.

What are you using to try to SEE the data?

It's also possible that php.ini settings for EGCPS order preference
(whose name is escaping me) might be badly-configured enough to cause
this...


Richard,

Thanks for the replies. I have already fixed this problem thanks to the help 
from the list members. Rabin has noted to me that php_self, as a string is 
case sensative. I corrected the call to be $_SERVER['PHP_SELF'], and 
everything was fine.



Regards,
IraqiGeek
www.iraqigeek.com

Bollo^G^G^Gther, said Pooh, on his VT220 emulator. 


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



Re: [PHP] Uploading large files

2006-05-15 Thread Richard Lynch
On Sat, May 13, 2006 9:23 am, php @ net mines wrote:
 is there a way to upload large files (e.g. 15mb) without changing the
 default settings in php.ini***?

Probably not.

This particular setting is weird in that the setting is the SMALLEST
of:
php.ini
.htaccess
The HTML INPUT thingie (MAX_UPLOAD_SIZE ?)

I believe this is intentional so that a webhost can limit uploads and
a client of the webhost can limit it more but can't over-ride the
webhost's limit.

At least, that was my assumption when I played around with this way
back when.

After I asked my webhost to increase the size, it got taken care of,
and I never checked again...

 Preferably by using php, but if not is there another web tech (e.g.
 Java
 applets) that will allow me to do this?

You could probably use Java applets, Javascript, or plain old FTP to
do this, but the PHP component would be pretty non-existent, so I
dunno what more could be said about that here.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Class/function scope general question

2006-05-15 Thread Richard Lynch
You can't do that.

The whold class has to be in a single contiguous file.

Last I checked.

On the plus side, it's incredibly unlikely that having the functions
in separate files was a Good Idea...

On Fri, May 12, 2006 12:34 pm, Edward Vermillion wrote:
 I'm doing some re-writing of a huge class I've got (don't think OOP
 cause it's really not, just the usual class full of functions). What
 I'm doing is moving the functions out of the class and into separate
 files so the (I'm hoping) memory footprint will be smaller.

 The basic setup I started with is:

 class foo {

   function doSomething()
   {
   switch($var) {
   case '1':
   $this-bar();
   break;
   case '2':
   $this-baz();
   break;
   }
   }

   function bar(){ // do something useful }

   function baz(){ // do something else useful }

   [...]
 }

 I've moved bar() and baz() into their own file and am now including
 those files from the original functions as so:

 class foo {

   function doSomething()
   {
   switch($var) {
   case '1':
   $this-bar();
   break;
   case '2':
   $this-baz();
   break;
   }
   }

   function bar(){ include_once 'bar.php'; newBar(); }

   function baz(){ include_once 'baz.php'; newBaz(); }

   [...]
 }

 where newBar() and newBaz() are just the functions copied from the
 original class like

 bar.php
 ?php
 function newBar(){ // do something useful }

 Now the interesting bit I don't quite comprehend...

 var_dump($this); from inside newBar() returns null.

 Sort of unexpected behavior to me, but only slightly. Shouldn't the
 newBar() function pick up the scope from foo::bar() since, as I
 understand includes, it's the same as writing the code in the file
 where the include statement is at?

 Outside of newBar() in bar.php var_dump($this) gives me the foo class.

 Is it because there is basically a function within a function at this
 point and somehow the scope of $this is being lost? I would have
 thought that it would carry down, but obviously I'm wrong.

 Not looking for a fix really, I'm passing in a reference to $this to
 newBar() so it's all cool there, just looking for an explanation to
 have for future reference.

 PHP4.4.2 btw... if that makes any difference.

 Thanks!
 Ed

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




-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Wierd ass code...

2006-05-15 Thread Ryan A
Hey Rich,

  // Add to the running totals
  @$hits[$username|$subnet]++;
  @$bytes[$username|$subnet]+=$byte;
  @$baps[$username|$subnet|$this_second]++;
  @$bapm[$username|$subnet|$this_minute]++;
 
 @ is suppressing the E_NOTICE error message that the
 variables are not
 pre-set.


Yep, I got that.

 
 This is BAD if register_globals is ON as it means
 that somebody would
 use:

http://example.com/example.php?hits[user|192.168]=1
 to forge the hit counters


I know, but he's done some funky programming above
that so it cant happen, basically; anybody accessing
the script via get/post etc (the web) would get the
welcome page, but if the script is run as a shell
script then and only then is access granted to the
above part (after meeting other conditions...)


 Homework:

http://www.php.net/manual/language.operators.errorcontrol.php

Yes sir

:-)


Thanks!
Ryan


--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
-
Fight back spam! Download the Blue Frog.
http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



Re: [PHP] Going nuts with this, cant figure out whats the prob

2006-05-15 Thread Ryan A
Hey,

 On Mon, May 15, 2006 7:30 am, Ryan A wrote:
  The thing is, I thought this was bundled with the
  standard package of PHP, if yes, why would anybody
  want to turn this off?
 
 PCRE got added after POSIX Regex had been in awhile.
 
 There was some resistance to having two Regexes in
 PHP.

Makes sense...

 I think the default is on these days for PCRE.

So just my luck it was off :-(
Anyway, wrote to my host and they are mostly nice guys
there so he is enabling it for me.

I did check the manual and it didnt say anything about
it being off by default, so I think its safe to assume
that its usually on by default.

 One viable reason to turn it off might be to
 conserve RAM -- I
 daresay PCRE takes up a goodly chunk of RAM for its
 codebase, if
 you're really scrimping and saving...  This would
 make more sense in
 something like an embedded PHP app rather than
 shared hosting
 environment.

I'm mostly on shared environments, except in rare
cases, and I dont do (sell) hosting so I dont think
the above applies to me... but thanks for the info.

Cheers!
Ryan

--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
-
Fight back spam! Download the Blue Frog.
http://www.bluesecurity.com/register/s?user=bXVzaWNndTc%3D

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



Re: [PHP] Re: Re: Upload File (binary files?)

2006-05-15 Thread Richard Lynch
On Mon, May 15, 2006 10:18 am, tedd wrote:
 crash

It DOES make a difference as to how fast you can restore the DB and
the images, and more importantly, the PERCEIVED time for your site to
be back up

If you can get your DB up fast, but the images aren't available, MOST
sites, other than, like, flickr or whatever it is, are considered by
most visitors to be up

 Plus, a dB has search capabilities that a file system doesn't --
 that's probably the reason why dB's came into existence, right?

After you start working for the CIA and actually write a function that
*DOES* something with the blob data to search for common facial
features or something, you can use this argument...

Until then, it's really rather empty.

:-) :-):-)

 As for overhead and time to process stuff -- that's just a current
 observation and the problem (if there is one) will most certainly
 pass.

The DB adds layers of overhead, almost always.

The only time it doesn't, is when you've got teeny tiny images, and
not very many of them, such as, say, the nav buttons on your site, and
that's from caching in the DB layer more than anything else.

 I think the future on this is pretty clear as to what regime will be
 preferable for data organization. Not that I'm implying such to you,
 I remember DOS types saying What moron will ever use a mouse? and
 now they're saying Only Idiots and Morons place images in dB's.



-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] displaying result problem

2006-05-15 Thread Richard Lynch
On Fri, May 12, 2006 6:33 am, adi zebic wrote:
 I have little problem while displaying a result from one simple
 querry.
 If i insert values into mysql DB in following order (12, 3, 14, 4 )
 I allways have  ( 12, 14, 3, 4 ) displaying when query the DB. (same
 with
 letters - dcba - abcd etc)
 I would like to be able to display the data like they are inserted
 into
 database.

SQL *never* gurantees any particular order unless YOU impose it with
an ORDER BY clause.

It might *happen* to work for awhile, in some particular
implementation of SQL, but it ain't gonna survive for long, especially
once you start deleting values.

If you want an order, you gotta add/use a column that defines what
order you want and use ORDER BY.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Re: include_path and absolute paths in include functions

2006-05-15 Thread Richard Lynch
On Thu, May 11, 2006 8:10 pm, Steven Stromer wrote:
 relative versus 'include_path'-based paths?  I know that putting a
 variable into the path is a no-no, but any other considerations?

I suspect that the advice to use absolute paths is somebody NOT
understanding the include_path system, and just giving up on it,
possibly combined and confused with not using an unconstrained
variable in the path...

Nothing irks me more than stupidly-designed software that hard-codes
paths into includes so I can't move all their include files OUT of the
web-tree without a lot of grief.

More than a few software packages will not get installed for my
clients, no matter how nice the software might seem, until this is
fixed, because I just don't have the time to fix their mistakes.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Parsing a stdClass Object created with mimeDecode

2006-05-15 Thread Richard Lynch
On Fri, May 12, 2006 6:12 am, Jochem Maas wrote:
 Graham Anderson wrote:
 I am trying to get the body text from a number of different emails
 using mimeDecode [Pear]
 Unfortunately, it appears that the body text could be in any number
 of
 locations in the stdClass Object depending on which email is
 processed.
 At this point, I can only access the node by looking at the print_r
 ($structure) directly :(

As I recall, finding the plain-text body was a royal pain in the ass...

I think you end up having to write a recursive function searching
through all the headers and crap until you find a mime type plain/text

I believe I ended up just giving up and assuming that any email with
a too complex HTML body part struture *MUST* be spam, and I just
threw it away.  But I was writing a custom spam filter at the time, so
that may have influenced my decision. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Parsing images

2006-05-15 Thread Richard Lynch
On Fri, May 12, 2006 8:47 am, David Tulloh wrote:
 My favorite story was
 a
 small free porn site that required you to enter a captcha to get in.
 They were taking the captcha's they needed to break and getting horny
 teenagers to do the recognition phase for them.

According to the 'net, this was not ACTUALLY done and was merely a
thought experiment for how CAPTCHA could be easily broken

I'm sure we could find volunteers to research the matter if you have a
specific URL that you believe is actively doing this :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Does PECL install modify my php.ini? or even look at it?

2006-05-15 Thread Richard Lynch
On Thu, May 11, 2006 6:02 pm, D. Dante Lorenso wrote:
  pecl install memcache

Wild Guess Alert!!!

Is it possible that pecl has an --extension-dir flag to tell it WHERE
to install stuff, or perhaps an optional command line arg or ...

Cuz, really, the odds on it being where you want it to be are pretty
slim.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Trouble sending data via TCP socket

2006-05-15 Thread J. King
To further my understanding of how Jabber works I have decided I should  
try and write my own XMPP implementation in PHP.  However, I've run into  
trouble rather quickly.


To connect to a Jabber server, one must open a TCP socket to the server  
(typically through port 5269) send an XML-based stream header, wait for  
the server's confirmation and then log in, etc.  As an initial test I  
tried to open a TCP socket, send a stream header, get the server's  
response, then disconnect.  I did so thusly:


  $server = jabber.org; //example server
  $port = 5269; //default port
  $nsStream = http://etherx.jabber.org/streams;; // Streams namespace

  $socket = stream_socket_client(tcp://$server:$port);
  $header = stream:stream to='$server' xmlns='jabber:client'  
xmlns:stream='$nsClient' xml:lang='en' version='1.0';

  fwrite($socket, $header); //send header
  echo stream_get_contents($socket); //get server confirmation

  //close connection
  fwrite($socket, /stream:stream);
  fclose($socket);

I'm supposed to get something like this in reply (taken from my desktop  
Jabber client's debug window):


  ?xml version='1.0'?
  stream:stream xmlns:stream='http://etherx.jabber.org/streams'
 id='4468F937' xmlns='jabber:client'
 from='jabber.org'

Instead, I get this error message:

  stream:error
   invalid-namespace
 xmlns='urn:ietf:params:xml:ns:xmpp-streams'/
  /stream:error

That I get a conformant Jabber error message suggests that I -am- at least  
connecting to the server properly, but that the data is not getting to the  
server intact.  I am certain that the XML header is correct: I also tested  
another PHP Jabber implementation[1] with the same result, even though a  
search of this mailing list suggests that said implementation has been  
known to work for other people.  Since I tested it on two different  
machines (my home Windows computer and a Linux Dreamhost Web server) using  
three different versions of PHP (PHP 5.1.4 Winodws CLI, PHP 4.3.3 Windows  
CLI, PHP 5.1.1 Linux FastCGI), it's pretty clear that it's not a bug in  
the version of PHP I initially tested on.  I also tried connecting to  
three different Jabber servers (my private dark-phantasy server,  
jabber.org, and a test Wildfire server on my colleague's machine) and all  
three gave me similar errors (with differing levels of spec compliance...).


In short, I am stumped.  If anyone with some experience in these matters  
could shed some light on my problem I would be most grateful.


[1] http://cjphp.netflint.net/

--
J. King
http://jking.dark-phantasy.com/

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



[PHP] Help w/ 'headers already sent' and file download

2006-05-15 Thread Mike Walsh
I have an application which I am working on which takes a file supplied by 
the user via a File Upload, peforms some processing on it, then prompts the 
user to download a generated CSV file.  What I would like to do is report 
some processing statistics prior to the user prior to sending the CSV steam.

My CSV export ends with this:


header(Content-type: application/vnd.ms-excel) ;
header(Content-disposition:  attachment; filename=CSVData. . 
date(Y-m-d)..csv) ;

print $csvStream ;

Unfortunately if I display any content prior to sending the CSV stream I get 
the 'headers already sent' error message.

Is there a way to both display a web page and send content to be saved by 
the user?  If someone knows of an example I could look at I'd be greatful.

Thanks,

Mike

--
Mike Walsh - mike_walsh at mindspring.com 

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



Re: [PHP] Help w/ 'headers already sent' and file download

2006-05-15 Thread Rabin Vincent

On 5/16/06, Mike Walsh [EMAIL PROTECTED] wrote:

I have an application which I am working on which takes a file supplied by
the user via a File Upload, peforms some processing on it, then prompts the
user to download a generated CSV file.  What I would like to do is report
some processing statistics prior to the user prior to sending the CSV steam.

My CSV export ends with this:


header(Content-type: application/vnd.ms-excel) ;
header(Content-disposition:  attachment; filename=CSVData. .
date(Y-m-d)..csv) ;

print $csvStream ;

Unfortunately if I display any content prior to sending the CSV stream I get
the 'headers already sent' error message.

Is there a way to both display a web page and send content to be saved by
the user?  If someone knows of an example I could look at I'd be greatful.


No, you cannot display both a webpage and send a file
on the same page to the user.

What you could do is save the processed file in a temporary
folder and provide a link to download the file in your processing
statistics page. Or, you could redirect the user to the file after
showing the statistics page.

Rabin

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



Re: [PHP] Wierd ass code...

2006-05-15 Thread Chris

Richard Lynch wrote:

On Sat, May 13, 2006 6:37 pm, Rory Browne wrote:


There are some cases where the Error Suppression operator may be
useful in
good code.



Last I checked, you pretty much HAD to use it for pg_fetch_row() since
it does an E_NOTICE when you try to fetch a row beyind the number
available...


FYI - not any more.

I find I have to with imap_open though (should get around to posting a 
bug report about that)..


--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] Trouble sending data via TCP socket

2006-05-15 Thread Rabin Vincent

On 5/16/06, J. King [EMAIL PROTECTED] wrote:

To further my understanding of how Jabber works I have decided I should
try and write my own XMPP implementation in PHP.  However, I've run into
trouble rather quickly.

To connect to a Jabber server, one must open a TCP socket to the server
(typically through port 5269) send an XML-based stream header, wait for
the server's confirmation and then log in, etc.  As an initial test I
tried to open a TCP socket, send a stream header, get the server's
response, then disconnect.  I did so thusly:

   $server = jabber.org; //example server
   $port = 5269; //default port
   $nsStream = http://etherx.jabber.org/streams;; // Streams namespace

   $socket = stream_socket_client(tcp://$server:$port);
   $header = stream:stream to='$server' xmlns='jabber:client'
xmlns:stream='$nsClient' xml:lang='en' version='1.0';
   fwrite($socket, $header); //send header
   echo stream_get_contents($socket); //get server confirmation

   //close connection
   fwrite($socket, /stream:stream);
   fclose($socket);


[snipped]

I played with your code and here are some observations:

Shouldn't that variable inside $header be $nsStream (and not
$nsClient)? Also, stream_get_contents may not be ideal here
since it tries to get the full contents of the stream (until EOF?),
so you should probably be using fread() here.

Another thing, the Jabber.org default port seems to be 5222
(class.jabber.php also uses that port).

Rabin

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