Files
Anonupload/system/core.class.php

60 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2022-12-19 11:00:34 -06:00
<?php
require_once 'config.php';
class core
{
protected $timestamp;
/*
* @module File Type Verification
* @desc This Module check if a file is with the correct type (like png or zip). This option can be edit in config file
*/
2023-01-19 11:46:03 -06:00
public function FileTypeVerification($file){
$filetype_list = array();
$type = explode(",", FILELIST);
2022-12-19 11:00:34 -06:00
foreach ($type as $filetype) {
array_push($filetype_list, $filetype);
}
2023-01-19 11:46:03 -06:00
$ext = pathinfo($file["name"], PATHINFO_EXTENSION);
if(in_array($ext, $filetype_list)){
return true;
}else{
return false;
2022-12-19 11:00:34 -06:00
}
}
/*
* @module File Size Verification
* @desc This Module check if the file size is correct or if is too high. This option can be disabled in config file
*/
2023-01-19 11:46:03 -06:00
public function FileSizeVerification($file){
if(size_verification == true){
if($file["size"] < max_size && $file["size"] > min_size){
2022-12-19 11:00:34 -06:00
return true;
2023-01-19 11:46:03 -06:00
}else{
2022-12-19 11:00:34 -06:00
return false;
}
2023-01-19 11:46:03 -06:00
}else{
2022-12-19 11:00:34 -06:00
return true;
2023-01-19 11:46:03 -06:00
}
2022-12-19 11:00:34 -06:00
}
/*
* @module File Name Convertor
* @desc This Module convert file name into a encrypted name. This option can be disabled in config file
*/
2023-01-19 11:46:03 -06:00
public function FileNameConvertor($file){
2022-12-19 11:00:34 -06:00
$TransformFileName = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIKLMNOPQRSTUVWXYZ123456789'), 0, 15);
2023-01-19 11:46:03 -06:00
$filename = $TransformFileName.'-'.basename($_FILES["fileToUpload"]["name"]);
return $filename;
2022-12-19 11:00:34 -06:00
}
2023-01-19 11:46:03 -06:00
public function UploadFile($file, $target){
2022-12-19 11:00:34 -06:00
$newtarget = file_destination.'/'.$target;
2023-01-19 11:46:03 -06:00
if(move_uploaded_file($file["tmp_name"], $newtarget)){
2022-12-19 11:00:34 -06:00
return true;
2023-01-19 11:46:03 -06:00
}else{
2022-12-19 11:00:34 -06:00
return false;
}
}
}