RE: [PHP] Download Script

2004-08-27 Thread Ivo Pletikosic
> I am 
> wondering if this is my headers that are doing this, but I 
> really dont know.

I think its an IE or Windows behavior and what causes it is the multiple
dots in the filename. I resorted to naming our downloads
"filename-v1_0_2_1.exe"

> -Original Message-
> From: Aaron Todd [mailto:[EMAIL PROTECTED] 
> Sent: Friday, August 27, 2004 11:35 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Download Script
> 
> 
> I've created a download script that works quite nicely.  The 
> only issue with 
> it is that when I download a file where the file name is like 
> "filename 
> v1.0.2.1.exe" there is some extra characters added into the 
> name when it is 
> downloaded.  So that file will be "filename v1[1].0.2.1.exe".  I am 
> wondering if this is my headers that are doing this, but I 
> really dont know.
> 
> Here is my code:
>  $file = $_GET['file'];
> $path = $_GET['type'];
> $rootpath = "/home/virtual/site341/fst/var/www/downloads/";
> $filename = "$rootpath$path/$file";
> if (file_exists($filename)) {
>   header("Content-Description: File Transfer");
>   header("Pragma: no-cache");
>   header("Content-Type: application/force-download");
>   header("Content-Disposition: attachment; 
> filename=".basename($filename));
>   header("Content-Length: ".filesize($filename));
>   $handle = fopen(($filename), "r");
>   print(fread($handle, filesize($filename)));
>   flush();
>   fclose($handle);
> } else {
>   header("HTTP/1.0 404 Not Found");
> }
> ?>
> If anyone can let me know what is going on I'd appreciate it.
> 
> Thanks,
> 
> Aaron 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



RE: [PHP] view outputed headers?

2004-01-12 Thread Ivo Pletikosic
I've been using mozilla firebird as a test browser with the 'Live HTTP
Headers' extension. I've found it most useful.

http://texturizer.net/firebird/extensions/#livehttpheaders


> -Original Message-
> From: Scott Taylor [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, January 11, 2004 9:34 PM
> Subject: [PHP] view outputed headers?
> 
> 
> 
> What is the easiest way to view the headers that a PHP page has put 
> out?  I've seen the |var_dump(headers_list()); on php.net but this 
> always gives me an error (such as: |
> 
> Fatal error:  Call to undefined function:  
> headers_list() in 
> /usr/local/psa/home/vhosts/a.com/httpdocs/my/page.php on 
> line 79

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



RE: [PHP] Verifying a url

2004-01-06 Thread Ivo Pletikosic
It did not work for me but since I have only one http port and one https
port on my server i use instead

if( $_SERVER['SERVER_PORT'] == "80" ) echo 'http';

C.


> -Original Message-
> From: Richard Davey [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, January 06, 2004 6:56 PM
> To: Thomas Andersen
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Verifying a url
> 
> 
> Hello Thomas,
> 
> Wednesday, January 7, 2004, 2:49:48 AM, you wrote:
> 
> TA> My web site has two different ways to be accessed.  One 
> is through a SSL
> TA> connection and the other not.
> 
> TA> Does anyone know how to check either the URL that is 
> being used (https would
> TA> give away the SSL) or if you can check if SSL is being used?
> 
> I'm pretty sure the following would work:
> 
> if ($_SERVER['SERVER_PROTOCOL'] == "HTTP/1.1")
> {
>  echo "Normal site";
> }
> 
> -- 
> Best regards,
>  Richardmailto:[EMAIL PROTECTED]

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



[PHP] Strong typed or Weak typed? (was: if("NANC" < 0) - always evaluates TRUE...)

2004-01-06 Thread Ivo Pletikosic

> -Original Message-
> From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] 
> 
> From: "Kelly Hallman" <[EMAIL PROTECTED]>
> 
> > On Tue, 6 Jan 2004, Ivo Pletikosic wrote:
> > > $data = 'NANC';
> > > if(is_numeric($data) && $data < 0) { die('Not OK'); }
> >
> > Interesting problem, one of the first legit oddities I've seen since
> > joining the list.  Anyway, in addition to your workaround, 
> casting the
> > variable as an int also appears to result in the desired behavior:
> >
> > (int)"NANC" < 0 == false
> 
> This all kind of begs the question of why you'd check if a 
> "string" was less
> than zero, anyhow, doesn't it???
> 
> ---John Holmes...

I have a function that returns a string on success or a negative value
on error. I was operating under the impression that php was weakly typed
but the bug.php.net entry I just did was summarily closed with the
comment "never ever compare different types like that".

So I am incorrect about what weakly typed means or something is off. In
php I indicate strong-type comparisons with === and weak with == . When
doing relative (< or > ) comparisons tho then casting is necessary or
the results are unexpected.

C.

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



RE: [PHP] if("NANC" < 0) - always evaluates TRUE...

2004-01-06 Thread Ivo Pletikosic
Hi,

Never noticed it before...only after the linux box got updated to
v4.3.4...running the script against my v4.2.3 also outputs err 3 &
err4...version 4.0.6 outputs nothing as it should.

Odd...not sure where to start digging to figure this...in the meantime
I'll work it around like this:

$data = 'NANC';
if(is_numeric($data) && $data < 0)
{
   die('Not OK');
}
print('OK');

Where do I file this for developers with some time on their hands to
look at?

Thanks,

Ivo

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



[PHP] if("NANC" < 0) - always evaluates TRUE...

2004-01-06 Thread Ivo Pletikosic
...no matter what follows the NANC...seems like a bug.

if("NA" < 0)
{
   print("err 1\n");
}

if("NAN" < 0)
{
   print("err 2\n");
}

if("NANC" < 0)
{
   print("err 3\n");
}

if("NANCY" < 0)
{
   print("err 4\n");
}

// output
err 3
err 4

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



RE: [PHP] Extracting Compressed Files

2003-08-14 Thread Ivo Pletikosic
Hey Matt,

Below is a cut down version of how I'm doing it. I lifted most of it right
out of the manual examples. It assumes a single entry in each compressed
file.

function uncompress($filepath, $new_filename, $compression)
{
if($compression == COMPRESSION_GZIP)
{
$zp = gzopen( $filepath, "r" );
$fp = fopen( $new_filename, "w");
if(! $fp )
{
return BDBERR_TITLE_GZ_FILE_COPY_FAILED;
}

$buffer = '';
if( $zp )
{
 while(! gzeof($zp))
 {
$buffer = gzgets ($zp, 4096);
if( $buffer === FALSE)
{
fclose($fp);
unlink($new_filename);
return BDBERR_TITLE_GZ_FILE_COPY_FAILED;
}
fputs($fp, $buffer);
 }
 gzclose( $zp );
 fclose( $fp );
}
else
{
return BDBERR_TITLE_GZ_FILE_COPY_FAILED;
}
return SUCCESS;
}
else if($compression == COMPRESSION_BZIP2)
{
$bz_fp = fopen( $filepath, "r");
$bzipped_contents = fread ($bz_fp, filesize($filepath) );
fclose($bz_fp);

$uncompressed = bzdecompress( $bzipped_contents );

$fp = fopen( $new_filename, "w");
if(! $fp )
{
return BDBERR_TITLE_BZ2_FILE_COPY_FAILED;
}
if( ! fwrite($fp, $uncompressed) )
{
return BDBERR_TITLE_BZ2_FILE_COPY_FAILED;
}
fclose($fp);
return SUCCESS;
}
else if($compression == COMPRESSION_ZIP)
{
$zip = zip_open($filepath);

if ($zip)
{
$zip_entry = zip_read($zip);
if (zip_entry_open($zip, $zip_entry, "r"))
{
$unzipped_contents = zip_entry_read($zip_entry,
zip_entry_filesize($zip_entry));
zip_entry_close($zip_entry);
}
zip_close($zip);

$fp = fopen( $new_filename, "w");
if(! $fp )
{
return BDBERR_TITLE_ZIP_FILE_COPY_FAILED;
}
if( ! fwrite($fp, $unzipped_contents) )
{
return BDBERR_TITLE_ZIP_FILE_COPY_FAILED;
}
fclose($fp);
}
else
{
return BDBERR_TITLE_ZIP_FILE_COPY_FAILED;
}
}
else
{
return BDBERR_UNKNOWN_COMPRESSION_METHOD;
}
}



-Original Message-
From: Matt Palermo [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 04, 2003 7:33 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Extracting Compressed Files


Does anyone know of easy ways to be able to extract all
files/folders/subfolders from different types of compressed files (.zip,
.tar.gz, etc.)?  If anyone could help me out with this, I would really
appreciate it.  
 
Thanks,
 
Matt

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



RE: [PHP] Invalid Characters, XML...

2003-08-04 Thread Ivo Pletikosic
I had a similar problem recently, but was not able to work with it in PHP
tho. The array for that mapped characters to their entity turned out to be
HUGE and it took forever to evaluate long XML files.

I ended up killing several birds with one stone by wrapping the html-tidy
utility (tidy.sourceforge.net) in php. It validates xml, converts all
characters >127 into their respective entity, pretties up the XML output,
cleans up Word 2000 specific content and deals with a variety of
input/output encodings. It did all these a lot faster that any of the
scripts I had written and saved me from writing others.

-Original Message-
From: Russell P Jones [mailto:[EMAIL PROTECTED] 
Sent: Sunday, August 03, 2003 6:52 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Invalid Characters, XML...


Im using PHP to write to XML files, but I am having some problems. A lot of
users are cutting and pasting content from text editors like word, which
uses odd quotation marks, dashes, etc. which PHP writes to the XML file, and
then the XML parser does not under stand. Is there a
stripslashes() or htmlspecialchars() equivalent that will convert this kind
of stuff to the correct ascii text?

Russ


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

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



[PHP] Test a zip file for validity

2003-08-01 Thread Ivo Pletikosic
Hello all,

How do I go about checking if a file is a zip file?

Wrapping the zipinfo utility in php did not help since it does not return an
exit code whether it succeeded or not.

Thanks,

IP




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



[PHP] Uploading files time out every so often

2003-07-03 Thread Ivo Pletikosic
Hello,

I am currently involved in a site where users frequently need to upload text
files of various sizes. Every so often users will experience problems where
the uploads will start timing-out and need to be reinitiated.

The timeout problem comes and goes, so far I've been unable to find the root
cause. It happens with files of all sizes, from 10k to several MB,
eventually they all get uploaded, tho sometimes it can take days re-trying.

Another issue is experienced when the above symptom is happening which makes
me think they're related. An additional tool on the site writes out files
with information provided by a user thru a form. A user submits a form with
some text and php writes out a file with the received info and notifies the
user the task was done. Every so often the browser will timeout with no file
written out by php or notification. This symptom can go on for days. The
info being written to a file is never longer than a dozen lines of text so
it's quite small.

Initially we thought that the server just did not have the resources to
service simultaneous uploads but monitoring tools show the cpu appears to be
near idle when this is experienced. I've experienced the file writing
problem when I was the only user on the server with all unnecessary services
disabled. The browser will just time out, then one days voila! it works
until the next problem day.

This is on a Linux box with Apache 1.3, php 4.2.2 & experienced across
multiple browsers. All the scripts have set_time_limit(0). File system has
the proper permissions and with plenty of free space.

We've been collecting quite a lot of info from the server to try to capture
it's state at the time of the problem but nothing raises any flags.

Has anyone experienced this issue or a similar issue? Any pointers and help
is greatly appreciated. 

Ivo

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



RE: [PHP] strip white space

2003-07-02 Thread Ivo Pletikosic
would

$team_name = trim(ereg_replace( " +", " ", $team_name ));

do it?

-Original Message-
From: Steve Buehler [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 02, 2003 9:50 AM
To: PHP
Subject: [PHP] strip white space


I am not sure how to go about this and hope that someone can help here.  I 
have a variable like the following:
$team_name="BV Stars  Black";

it has two spaces between the words Stars and Black.  What I am trying to 
do is to take this variable, check for and strip the following:
1.  Leading spaces
2.  Ending spaces
3.  Double (or more) spaces in the variable leaving only one space between 
words.

Does php have any built in function that I can not find that will do this?

Thank You in Advance
Steve


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

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



RE: [PHP] Serving files with different filename from their own

2003-06-27 Thread Ivo Pletikosic
You can also initiate the download with headers yourself...tho it might be a
bit cumbersome than just using direct links:

Header( "Content-Type: application/octet-stream" );
Header( "Content-Length:" . filesize( $path ) );
Header( "Content-Disposition: attatchment; filename=$filename" );

readfile( $path );
exit;

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]
Sent: Friday, June 27, 2003 3:25 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Serving files with different filename from their own


On Friday 27 June 2003 18:11, Jason End wrote:
> Is there a way to serve files with a different file
> name than they actually have?
> Here's my situation:
> Users can upload software manuals, which are then
> saved with a unique name. Their title, filename, type
> and id are then save into a db.
> But when they go to download a file, they'll of course
> see a very cryptic filename in their save as dialog.
> Lets say they aren't smart enough to change that name.
>
> So would their be a way to serve a file with a
> different name than it's actual one?

On a un*x system you can use symlinks.

Otherwise you can have php handle the download, see archives for more info.

-- 
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
--
/*
Carson's Consolation:
Nothing is ever a complete failure.
It can always be used as a bad example.
*/


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

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