- $this->Connector = new Connector();
- $this->Connector->setDB($this->Connector->DB);
- $result = [];
- $files = $this->diverseArray($files);
- foreach ($files as $file) {
- $hash = sha1_file($file['tmp_name']);
- $this->FILE_INFO = [
- 'TEMP_NAME' => $file['tmp_name'],
- 'NAME' => strip_tags($this->checkNameLength($file['name'])),
- 'SIZE' => $file['size'],
- 'SHA1' => $hash,
- 'EXTENSION' => $this->fileExtension($file),
- 'MIME' => $this->fileMIME($file),
- ];
-
- if ($this->Connector->CONFIG['ANTI_DUPE']) {
- $dupeResult = $this->Connector->antiDupe($hash);
- if ($dupeResult['result']) {
- $this->FILE_INFO['NEW_NAME'] = $dupeResult['name'];
+ public array $FILE_INFO;
+ public array $fingerPrintInfo;
+ private mixed $Connector;
+
+ /**
+ * Takes an array of files, and returns an array of arrays containing the file's temporary name,
+ * name, size, SHA1 hash, extension, and MIME type
+ *
+ * @param $files array The files array from the $_FILES superglobal.
+ *
+ * @return array An array of arrays.
+ */
+ public function reFiles(array $files):array
+ {
+ $this->Connector = new Connector();
+ $result = [];
+ $files = $this->diverseArray($files);
+ foreach ($files as $file) {
+ $this->FILE_INFO = [
+ 'TEMP_NAME' => $file['tmp_name'],
+ 'NAME' => strip_tags($this->checkNameLength($file['name'])),
+ 'SIZE' => $file['size'],
+ 'SHA1' => sha1_file($file['tmp_name']),
+ 'EXTENSION' => $this->fileExtension($file),
+ 'MIME' => $this->fileMIME($file),
+ 'DUPE' => false,
+ 'FILENAME' => null,
+ ];
+ // Check if anti dupe is enabled
+ if ($this->Connector->CONFIG['ANTI_DUPE']) {
+ // Check if hash exists in DB, if it does return the name of the file
+ $dupeResult = $this->Connector->antiDupe($this->FILE_INFO['SHA1']);
+ if ($dupeResult['result']) {
+ $this->FILE_INFO['FILENAME'] = $dupeResult['name'];
+ $this->FILE_INFO['DUPE'] = true;
+ }