diff --git a/plugins/ice-repo/.gitignore b/plugins/ice-repo/.gitignore
new file mode 100644
index 0000000..43c661a
--- /dev/null
+++ b/plugins/ice-repo/.gitignore
@@ -0,0 +1 @@
+error-log.txt
\ No newline at end of file
diff --git a/plugins/ice-repo/LICENSE.md b/plugins/ice-repo/LICENSE.md
index fb21f97..5d6d102 100644
--- a/plugins/ice-repo/LICENSE.md
+++ b/plugins/ice-repo/LICENSE.md
@@ -1,4 +1,4 @@
-Copyright (C) 2012 Matt Pass
+Copyright (C) 2013 Matt Pass
Website: mattpass.com
Email: matt@mattpass.com
Twitter: @mattpass
diff --git a/plugins/ice-repo/README.md b/plugins/ice-repo/README.md
index daca2a6..6f8fe5a 100644
--- a/plugins/ice-repo/README.md
+++ b/plugins/ice-repo/README.md
@@ -15,7 +15,7 @@ Cool huh?
**Current screnshot:**
-
+
This lib uses customised & minified versions of these brilliant and time tested repos:
@@ -33,29 +33,15 @@ $ git clone git@github:mattpass/ICErepo
####Step 2: Enter your auth settings
```
-Open index.php and enter either your Github oauth token or username & password
+Open settings.php and enter either your Github oauth token or username & password
oauth is recommended here, view http://developer.github.com/v3/oauth/ for info
(If using oauth ensure you have repo scope & your app is granted the URL you'll run under)
```
####Step 3: Enter your repo & server dir settings
```
-Also in index.php, enter the repo & corresponding server paths
+Also in settings.php, enter the repo & corresponding server paths
Enter 'selected' as a 3rd param next to your default repo/server option to autoload that
-Finally, set $_SESSION['userLevel'] to be > 0 with your own login system, or simply uncomment line 3
+Finally, set $_SESSION['userLevel'] to be > 0 with your own login system
Upload ICErepo, visit in a web browser & enjoy
-```
-
-**Dev schedule:**
-
-**v0.8**
-Bug testing, refactoring & optimisation
-
-**v0.9**
-Alpha testing
-
-**v0.95**
-Beta testing
-
-**v1.0**
-Version 1 released
\ No newline at end of file
+```
\ No newline at end of file
diff --git a/plugins/ice-repo/contents.php b/plugins/ice-repo/contents.php
index 796b323..2defdbb 100644
--- a/plugins/ice-repo/contents.php
+++ b/plugins/ice-repo/contents.php
@@ -1,23 +1,8 @@
-
+
-ICErepo v
+ICErepo v
@@ -29,24 +14,6 @@ function numClean($var) {
getPathname(), $b->getPathname());
-}
-
-// Class to put forward the values for sorting
-class SortingIterator implements IteratorAggregate {
- private $iterator = null;
- public function __construct(Traversable $iterator, $callback) {
- $array = iterator_to_array($iterator);
- usort($array, $callback);
- $this->iterator = new ArrayIterator($array);
- }
- public function getIterator() {
- return $this->iterator;
- }
-}
-
// Get a full list of dirs & files and begin sorting using above class & function
$repoPath = explode("@",strClean($_POST['repo']));
$repo = $repoPath[0];
@@ -55,15 +22,24 @@ $objectList = new SortingIterator(new RecursiveIteratorIterator(new RecursiveDir
// Finally, we have our ordered list, so display
$i=0;
-$dirListArray = array();
-$dirSHAArray = array();
-$dirTypeArray = array();
-$finfo = finfo_open(FILEINFO_MIME_TYPE);
+$dirListArray = $dirSHAArray = $dirTypeArray = array();
foreach ($objectList as $objectRef) {
- $fileFolderName = rtrim(substr($objectRef->getPathname(), strlen($path)),"..");
- if ($objectRef->getFilename()!="." && $fileFolderName[strlen($fileFolderName)-1]!="/") {
+ $fileFolderName = @rtrim(substr(str_replace("\\","/",$objectRef->getPathname()), strlen($path)),"..");
+ if (!is_dir($path.$fileFolderName)) {
$contents = file_get_contents($path.$fileFolderName);
- if (strpos(finfo_file($finfo, $path.$fileFolderName),"text")===0) {
+ $finfo = "";
+ // Determine what to do based on mime type
+ if (function_exists('finfo_open')) {
+ $finfoMIME = finfo_open(FILEINFO_MIME_TYPE);
+ $finfo = finfo_file($finfoMIME, $path.$fileFolderName);
+ finfo_close($finfoMIME);
+ } else {
+ $fileExt = explode(" ",pathinfo($path.$fileFolderName, PATHINFO_EXTENSION));
+ $fileExt = $fileExt[0];
+ if (array_search($fileExt,array("coffee","css","htm","html","js","less","md","php","py","rb","ruby","txt","xml"))!==false) {$finfo = "text";};
+ if (array_search($fileExt,array("gif","jpg","jpeg","png"))!==false) {$finfo = "image";};
+ }
+ if (strpos($finfo,"text")===0 || strpos($finfo,"empty")!==false) {
$contents = str_replace("\r","",$contents);
};
$store = "blob ".strlen($contents)."\000".$contents;
@@ -74,7 +50,6 @@ foreach ($objectList as $objectRef) {
array_push($dirTypeArray,$type);
}
}
-finfo_close($finfo);
?>
-