Re: filesize question

From: Date: Thu, 09 May 2013 03:33:06 +0000
Subject: Re: filesize question
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-321046@lists.php.net to get a copy of this message
On Tue, May 7, 2013 at 10:16 PM, Curtis Maurand <curtis@maurand.com> wrote: > find -name *.js -exec removestring.php '{}' \; > > That's how I get the I put file name. I think that I need the if statement > to look at the filesize and make sure that I can open them and they are at > least the size of the string that I'm looking to cleanse. That's how you pass the name into the php script; how does $inputfile get set (via $argv somehow) once you're inside php? This line: >>> $inputline = fread($inputfile, filesize($argv[1])); Somehow, you opened $inputfile (assuming via fopen) by passing it a file name, presumably off the command line. Show me(us) where that happens. > Would that joomla.modules would use the ftp layer if it were turned on. Then > I wouldn't have to be scanning files dor malicious iframes or if clamav > coyld remove offending code without removing the entire file... I don't know anything about joomla. > tamouse mailing lists <tamouse.lists@gmail.com> wrote: >> >> On Tue, May 7, 2013 at 8:16 AM, Curtis Maurand <curtis@maurand.com> wrote: >>> >>> Hello, >>> I'm feeding a filename to a php script on the command line (command line >>> program). I run the following against it: >>> >>> $inputline = fread($inputfile, filesize($argv[1])); >>> >>> I'm getting an error complaining that the second parameter can't be >>> '0' >> >> >> The thing to look for, is how did you get $inputfile out of the >> command line, and why you'd expect the file name to be in $argv[1] at >> that point? Marco's suggestion isn't really going to work as >> $inputfile will be a file handle, and filesize() needs the name of the >> file. Maybe want to give us a wider look at what your code is doing? >> >> Generically, you can wrap this >> up as: >> >> function binread_file($filename) >> { >> $handle = fopen($filename,'rb'); >> if (FALSE === $handle) die("Unable to open $filename"); >> $contents = fread($handle, filesize($filename)); >> if (FALSE === $contents) die("Unable to read $filename"); >> return $contents; >> } > > > -- > Sent from my Android phone with K-9 Mail. Please excuse my brevity.

« previous php.general (#321046) next »