Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions Aunthenticate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/**
* Created deepface19.
* User: deepface19
* Date: 26-03-2021
* Time: 3:10 PM
*/


class Authenticate
{
private $redisHost;
private $redisPort;
private $redisTime;

public function __construct($redisHost, $redisPort, $redisTime) {
$this->redisHost = $redisHost;
$this->redisPort = $redisPort;
$this->redisTime = $redisTime;
}

public function getRedisConnection(){
$redis = new RedisSession($this->redisHost,$this->redisPort,$this->redisTime);
return $redis;
}
public function getAuthenticate($redis){
$redis->key = isset($_POST['token'])?$_POST['token']:'';
$data = $redis->getSessionValue();
return $data;
}

}



$authenticate = new Authenticate($config->REDIS_HOST, $config->REDIS_PORT, $config->REDIS_EXPIRY);
$redis = $authenticate->getRedisConnection();

global $redisData;

$redisData = $authenticate->getAuthenticate($redis);

if (empty($redisData)) {
if (!isset($_POST['token'])) {
return;
}
$error = new Error();
$error->responseCode = 403;
$error->string = "Invalid token";
$error->errorHandler();
}
212 changes: 212 additions & 0 deletions File upload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@


<?php

/**
* Created by deepface19.
* User: deepface19
* Date: 26-03-2021
* Time: 6:56 PM
*/
class FileUploader
{
public $path;
public $filename;
private $width;
private $height;
public $resolutionError;

public function __construct()
{
$this->resolutionError = 0;
}

/**
* @return mixed
*/
public function getPath()
{
return $this->path;
}

/**
* @param mixed $path
*/
public function setPath($path)
{
$this->path = $path;
}


/**
* @return mixed
*/
public function getFilename()
{
return $this->filename;
}

/**
* @param mixed $filename
*/
public function setFilename($filename)
{
$this->filename = $filename;
}

/**
* @param mixed $width
*/
public function setWidth($width)
{
$this->width = $width;
}

/**
* @param mixed $height
*/
public function setHeight($height)
{
$this->height = $height;
}

/**
* @return mixed
*/
public function getWidth()
{
return $this->width;
}

/**
* @return mixed
*/
public function getHeight()
{
return $this->height;
}

public function resolution($files, $key = null) {
if ($key != NULL) {
$imageResolution = getimagesize($files[$key]["tmp_name"]);

$width = $imageResolution[0];
$height = $imageResolution[1];
if (($height != $this->getHeight()) || ($width != $this->getWidth())) {
$this->resolutionError = 1;
return false;
}
} else {
foreach ($files as $file) {
$imageResolution = getimagesize($file['tmp_name']);

$width = $imageResolution[0];
$height = $imageResolution[1];
if (($height != $this->getHeight()) || ($width != $this->getWidth())) {
$this->resolutionError = 1;
return false;
}
}
}
}


/**
* File uploading..
* @param $files
* @param $key - upload using particular key
* @return bool
*/
public function uploadAndReturnFile($files, $key = NULL)
{
if ($key != NULL) {

$upload_dir = _DIR_ . "/../uploads/{$this->path}/";
$filename = basename($files[$key]["name"]);
$file_explode = explode('.', basename($filename));
$ext = end($file_explode);
$renamedFile = TagdToUtils::getUniqueId() . '.' . $ext;
$target_file = $upload_dir . $renamedFile;

if (!is_dir($upload_dir)) {
mkdir($upload_dir, 0777, true);
}

if (move_uploaded_file($files[$key]["tmp_name"], $target_file)) {
$this->filename = $renamedFile;
return $this->filename;

} else {
return false;
}
}
}
public function upload($files, $key = NULL) {
if (!$this->path) {
return false;
}

$imageArray=array();

if ($key != NULL) {

$upload_dir = dirname(__FILE__). "/../uploads/{$this->path}/";
$filename = basename($files[$key]["name"]);
$file_explode = explode('.', basename($filename));
$ext = end($file_explode);
$renamedFile = TagdToUtils::getUniqueId(). '.'. $ext;
$target_file = $upload_dir.$renamedFile;

if (!is_dir($upload_dir)) {
mkdir($upload_dir, 0777, true);
}

if (move_uploaded_file($files[$key]["tmp_name"], $target_file)) {
$this->filename = $renamedFile;
return true;

} else {
return false;
}

} else {
foreach ($files as $file) {
$upload_dir = dirname(__FILE__). "/../uploads/{$this->path}/";
$filename = basename($file["name"]);
$file_explode = explode('.', basename($filename));
$ext = end($file_explode);
$renamedFile = TagdToUtils::getUniqueId(). '.'. $ext;
$target_file = $upload_dir.$renamedFile;

if (!is_dir($upload_dir)) {
mkdir($upload_dir, 0777, true);
}

if (move_uploaded_file($file["tmp_name"], $target_file)) {
$this->filename = $renamedFile;

$imageArray[]=$this->filename;
} else {

}
}
}

return $imageArray;
}

/**
* For deleting the uploaded file
* @return bool
*/
public function deleteFile() {
if (!empty($this->getFilename())) {
$filePath = _DIR_. "/../uploads/{$this->getPath()}/{$this->getFilename()}";

if (file_exists($filePath)) {
unlink($filePath);
}
}
return true;
}
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Example-projects-KYC-
This is a back end KYC
This is a back end php projects KYC
for ceramic on gitcoin
Loading