Example #1
0
 /**
  * Receives an array containing hashes for all uploaded files, compares our uploaded files
  * retreives new objects if necessary
  *
  * @return void
  */
 private function updateFiles()
 {
     $uploads = json_decode($this->request['files'], true);
     if (is_array($uploads) === false) {
         return;
     }
     foreach ($uploads as $upload => $hash) {
         $file = \BASE_DOCROOT_DIR . $upload;
         if (file_exists($file) === true) {
             if (hash_file('crc32b', $file) !== $hash) {
                 \unlink($file);
                 // the value of forceDownload is 0 or 1
                 if ($this->request['forceDownload'] == true) {
                     \OriginRequest::getUpdatedFile($upload);
                 }
             }
         } elseif ($this->request['forceDownload'] == true) {
             /**
              * The files don't currenty exist, but origin wants us to retrieve them now
              * Make an OriginRequest for the file path
              */
             \OriginRequest::getUpdatedFile($upload);
         }
     }
 }