Created
July 1, 2014 00:11
-
-
Save zsprackett/11ab7f3007b5f628def7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[email protected] updates.sugarcrm.com]# ls -lR sortinghat | |
sortinghat: | |
total 4 | |
drwxrwsr-x 7 apache apache 4096 Jun 30 17:07 11323432 | |
sortinghat/11323432: | |
total 20 | |
drwxrwsr-x 2 apache apache 4096 Jun 30 17:02 0 | |
drwxrwsr-x 2 apache apache 4096 Jun 30 17:03 1 | |
drwxrwsr-x 2 apache apache 4096 Jun 30 17:05 2 | |
drwxrwsr-x 2 apache apache 4096 Jun 30 17:05 3 | |
drwxrwsr-x 2 apache apache 4096 Jun 30 17:07 4 | |
sortinghat/11323432/0: | |
total 0 | |
sortinghat/11323432/1: | |
total 0 | |
sortinghat/11323432/2: | |
total 4 | |
-rw-rw-r-- 1 apache apache 58 Jun 30 17:05 info.json | |
sortinghat/11323432/3: | |
total 4 | |
-rw-rw-r-- 1 apache apache 58 Jun 30 17:05 info.json | |
sortinghat/11323432/4: | |
total 8 | |
-rw-rw-r-- 1 apache apache 58 Jun 30 17:07 info.json | |
-rw-rw-r-- 1 apache apache 242 Jun 30 17:07 sh.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ | |
<?php | |
$SHDIR = './sortinghat/'; | |
if (!array_key_exists('key', $_POST) || !array_key_exists('log', $_FILES)) { | |
echo "Invalid\n"; | |
exit(1); | |
} | |
if (!is_dir($SHDIR)) { | |
echo "SHDIR isn't a directory\n"; | |
exit(1); | |
} | |
$key = preg_replace("([^\w\s\d\-_~,;:\[\]\(\].]|[\.]{2,})", '', $_POST['key']); | |
if (!is_dir($SHDIR . $key)) { | |
echo "here $SHDIR$key\n"; | |
if (!mkdir($SHDIR . $key)) { | |
echo "Failed to create sortinghat instance directory.\n"; | |
exit(1); | |
} | |
} | |
$path; | |
for ($i = 0; $i < 100; $i++) { | |
$path = $SHDIR . $key . '/' . $i; | |
if (mkdir($path)) { | |
break; | |
} | |
} | |
if (!is_dir($path)) { | |
echo "Failed to create sortinghat results directory.\n"; | |
exit(1); | |
} | |
file_put_contents($path . '/info.json', json_encode($_POST)); | |
move_uploaded_file($_FILES['log']['tmp_name'], $path . '/sh.log'); | |
echo "Saved:$path\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment