| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | include 'admin.php'; |
|---|
| 4 | |
|---|
| 5 | include 'includes/class-wp-filesystem-base.php'; |
|---|
| 6 | |
|---|
| 7 | // Allows you to pass the permission value you want as the filename |
|---|
| 8 | class Loopback_WP_Filesystem_Base extends WP_Filesystem_Base { |
|---|
| 9 | function getchmod($file) { |
|---|
| 10 | return $file; |
|---|
| 11 | } |
|---|
| 12 | } |
|---|
| 13 | $Loopback_WP_Filesystem_Base = new Loopback_WP_Filesystem_Base; |
|---|
| 14 | |
|---|
| 15 | echo '<pre>'; |
|---|
| 16 | echo " From to And back \n"; |
|---|
| 17 | foreach ( range( 001, 07777 ) as $v ) { |
|---|
| 18 | |
|---|
| 19 | $human_readable = $Loopback_WP_Filesystem_Base->gethchmod( $v ); |
|---|
| 20 | |
|---|
| 21 | // Returns a octal number as a string, ie. '666' instead of 0666 |
|---|
| 22 | $converted_back_to_octal = $Loopback_WP_Filesystem_Base->getnumchmodfromh( $human_readable ); |
|---|
| 23 | |
|---|
| 24 | // Convert to string to compare since they're different datatypes |
|---|
| 25 | if ( sprintf( "%'08o", $v) == sprintf( "%'08s", $converted_back_to_octal ) ) |
|---|
| 26 | echo '<span style="color:green">'; |
|---|
| 27 | else |
|---|
| 28 | echo '<span style="color:red">'; |
|---|
| 29 | |
|---|
| 30 | printf( "%'08o %s %'08s", $v, $human_readable, $converted_back_to_octal ); |
|---|
| 31 | echo '</span><br />'; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | echo '</pre>'; |
|---|