summaryrefslogtreecommitdiff
path: root/shell/bin/rm.php
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-11-27 11:29:44 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-11-27 11:29:44 -0500
commitde5cb6329b4e6a4c409d1418f16a3488a53ca953 (patch)
tree3a5af4ef0fd42e4f4904326d2cc94d53582e028e /shell/bin/rm.php
parent76ead734626996f82caddaca57dc2f84243b0947 (diff)
This is what was deployed on the lnns serverHEADmaster
Diffstat (limited to 'shell/bin/rm.php')
-rw-r--r--shell/bin/rm.php46
1 files changed, 36 insertions, 10 deletions
diff --git a/shell/bin/rm.php b/shell/bin/rm.php
index 5eadaff..c55de8c 100644
--- a/shell/bin/rm.php
+++ b/shell/bin/rm.php
@@ -1,10 +1,36 @@
-<?php
-class p_rm extends prog {
- public static function main($args, $env) {
- $me = array_shift($args);
- foreach ($args as $file) {
- unlink($file);
- }
- }
-}
-
+<?php
+class p_rm extends prog {
+ static function recurse_rm($src) {
+ if ( is_dir($src) ) {
+ $dir = opendir($src);
+ while(false !== ( $file = readdir($dir)) ) {
+ if (( $file != '.' ) && ( $file != '..' )) {
+ self::recurse_rm($src.'/'.$file);
+ }
+ }
+ closedir($dir);
+ rmdir($src);
+ } else {
+ self::rm($src);
+ }
+ }
+
+ public static function rm($file) {
+ chown($file,666);
+ unlink($file);
+ }
+
+ public static function main($args, $env) {
+ $me = array_shift($args);
+ $flags = '';
+ while (substr($args[0],0,1) == '-') {
+ $flags .= array_shift($args);
+ }
+ $flags = preg_replace('/[ -]/','',$flags);
+ foreach ($args as $file) {
+ if (strpos($flags,'r')===false) { self::rm($file); }
+ else { self::recurse_rm($file); }
+ }
+ }
+}
+