1
Peekay
How do you create a list of file paths with sizes in bytes
  • 2012/1/22 15:57

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


I am doing some modifications to a module which performs a file integrity check in the module admin. The admin script reads a text file containing a list of PHP files that should be present in a particular folder and compares this with the actual files.

The content of the text file looks like this:

/.htaccess 33 2/admin/.htaccess 33 2/admin/batch.php 1295 40
/admin/catmanager.php 1925 49/admin/cat_table_manage.php 1016 29
/admin/checkgd2.php 1016 32/admin/checktables.php 1852 46

etc
...


At first I thought the module installer might create this, but it appears to have been done pre-installation. The first value after the path is the size in bytes. I have no idea what the second value is, but as you can see it can be the same for two different files.

Does anyone recognise the output format? I wondered if it might just some kind of a UNIX list command sent to print?

Any help would be welcome
A thread is for life. Not just for Christmas.

2
redheadedrod
Re: How do you create a list of file paths with sizes in bytes

Can you find the code that made these?

I am guessing it is one of three things...

file permissions (Most likely), group id, or user id.

If you look at the PHP command fileperms($path) you can try running that on those files to see what comes up.

There are other file commands in PHP that can help you identify what those are. It also is dependent on if you are running on linux, windows etc.

Attending College working towards Bachelors in Software Engineering and Network Security.

3
Peekay
Re: How do you create a list of file paths with sizes in bytes
  • 2012/1/22 20:51

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Well, I booted up my Linux laptop and it turns out you can do this using a rather convoluted combination of FIND, LS and AWK. For example:

find $pwd . -name "*.*" -exec ls -{} ; | awk '{print $NF,":"$5}'


that gives me:

/admin/catmanager.php 1925


which is pretty close. I just have to decide what to do about the second value. It's not a standard file attribute that I can see. Thankfully the script only seems concerned with the byte sizes so I'll probably just add a fixed value and see what happens.

Of course, in the time it took me to get the above to work, I could probably have gone through the file and changed the values one by one!
A thread is for life. Not just for Christmas.

4
redheadedrod
Re: How do you create a list of file paths with sizes in bytes

Well if you check out the following link it explains the number you get better..

It is not the normal Octal number we are used to.

This link explains how to use the number to extract what you want with PHP if in face you care about the file permissions.

http://www.php.net/manual/en/function.fileperms.php
Attending College working towards Bachelors in Software Engineering and Network Security.

5
Peekay
Re: How do you create a list of file paths with sizes in bytes
  • 2012/1/23 14:08

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


Thx for the link redheadedrod.

Quote:
It's not a standard file attribute that I can see.


In fact, looking closer I think the second value is the number of links, which is in fact a standard file attribute in UNIX.
A thread is for life. Not just for Christmas.

Login

Who's Online

154 user(s) are online (112 user(s) are browsing Support Forums)


Members: 0


Guests: 154


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits