update hash class
authorStricted <info@nexus-irc.de>
Sat, 7 Dec 2013 18:06:22 +0000 (19:06 +0100)
committerStricted <info@nexus-irc.de>
Sat, 7 Dec 2013 18:07:20 +0000 (19:07 +0100)
git.class.php
hash.class.php

index 96fbf5cf450611f1cb6364c135a0f7061c7e7d51..22a8e0b3c5baaf860a04a73702850c62d1025f8d 100644 (file)
@@ -177,5 +177,12 @@ class git {
        public function pull () {
                shell_exec("git --git-dir=".$this->repo." pull");
        }
+       
+       /*
+        * clone repo
+        */
+       public function clone () {
+               shell_exec("git clone --bare ".$this->repo);
+       }
 }
 ?>
\ No newline at end of file
index aaf77c2354a721cd2baae14426a269fdce86a4af..749b0137d65e776dfc3e167219ffafc8a496944c 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
  */
 class hash {
+       protected $raw;
+       protected $hmac;
+       protected $key;
        protected $algo;
        
        /**
         * constructor to validate algorithm
         *
-        * @param       string  $algo
+        * @param       string          $algo
+        * @param       optional        $raw
+        * @param       optional        $hmac
+        * @param       optional        $key
         */
-       public function __construct ($algo) {
+       public function __construct ($algo, $raw = Null, $hmac = Null, $key = Null) {
+               $this->raw = $raw;
+               $this->hmac = $hmac;
+               $this->key = $key;
                if (in_array($algo, hash_algos())) {
-                       $this-algo = $algo;
+                       $this->algo = $algo;
                } else {
                        die("algorithm ".$algo." not supported");
                }
@@ -36,46 +45,28 @@ class hash {
         * hash given data with given algorithm
         *
         * @param       mixed           $data
-        * @param       optional        $raw
-        * @return      hash
-        */
-       public function hash ($data, $raw = NULL) {
-               return hash($this-algo, $data, $raw);
-       }
-       
-       /**
-        * hash given file with given algorithm
-        *
-        * @param       mixed           $file
-        * @param       optional        $raw
-        * @return      hash
-        */
-       public function hash_file ($file, $raw = Null) {
-               return hash_file($this-algo, $data, $raw);
-       }
-       
-       /**
-        * hash given data with given algorithm
-        *
-        * @param       mixed           $data
-        * @param       mixed           $key
-        * @param       optional        $raw
         * @return      hash
         */
-       public function hash_hmac ($data, $key, $raw = Null) {
-               return hash_hmac($this-algo, $data, $key, $raw);
+       public function hash ($data) {
+               if (!empty($this->hmac)) {
+                       return hash_hmac($this->algo, $data, $this->key, $this->raw);
+               } else {
+                       return hash($this->algo, $data, $this->raw);
+               }
        }
        
        /**
         * hash given file with given algorithm
         *
         * @param       mixed           $file
-        * @param       mixed           $key
-        * @param       optional        $raw
         * @return      hash
         */
-       public function hash_hmac_file ($file, $key, $raw = Null) {
-               return hash_hmac_file($this-algo, $file, $key, $raw);
+       public function hash_file ($file) {
+               if (!empty($this->hmac)) {
+                       return hash_hmac_file($this->algo, $file, $this->key, $this->raw);
+               } else {
+                       return hash_file($this->algo, $file, $this->raw);
+               }
        }
        
        /**
@@ -83,17 +74,10 @@ class hash {
         *
         * @param       hash            $hash
         * @param       mixed           $data
-        * @param       optional        $raw
-        * @param       optional        $hmac
         * @return      boolean
         */
-       public function compare ($hash, $data, $raw = NULL, $hmac = NULL) {
-               $newhash = "";
-               if (!empty($hmac)) {
-                       $newhash = $this->hash_hmac($data, $key, $raw);
-               } else {
-                       $newhash = $this->hash($data, $raw);
-               }
+       public function compare ($hash, $data) {
+               $newhash = $this->hash($data);
                if ($newhash == $hash) {
                        return true;
                }
@@ -105,17 +89,10 @@ class hash {
         *
         * @param       hash            $hash
         * @param       mixed           $file
-        * @param       optional        $raw
-        * @param       optional        $hmac
         * @return      boolean
         */
-       public function compare_file ($hash, $file, $raw = NULL, $hmac = NULL) {
-               $newhash = "";
-               if (!empty($hmac)) {
-                       $newhash = $this->hash_hmac_file($file, $key, $raw);
-               } else {
-                       $newhash = $this->hash_file($file, $raw);
-               }
+       public function compare_file ($hash, $file) {
+               $newhash = $this->hash_file($file);
                if ($newhash == $hash) {
                        return true;
                }