Re: filesize question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 7, 2013 at 10:16 PM, Curtis Maurand <curtis@xxxxxxxxxxx> 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@xxxxxxxxx> wrote:
>>
>> On Tue, May 7, 2013 at 8:16 AM, Curtis Maurand <curtis@xxxxxxxxxxx> 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.

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





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux