| Server IP : 188.114.97.2 / Your IP : 104.23.197.230 Web Server : Apache/2.4.59 (Debian) System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64 User : edlftp ( 1002) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/git/sms.edl.codes.solutions/application/models/ |
Upload File : |
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class File_model extends CI_Model {
function __construct() {
parent::__construct();
}
function getHash($data){
if (is_string($data)){
$initialLength=strlen($data);
$parsedString=preg_replace('/[^0-9a-f_]/','',$data);
$parsedLength=strlen($parsedString);
if ($parsedLength==$initialLength && $parsedLength==32){
$hash=$parsedString;
}
else {
$hash=md5($data);
}
return $hash;
}
if (is_array($data) || is_object($data)){
return $this->getHash(md5(json_encode($data)));
}
}
function getFilterID($data,$createIfNone=true){
$hash=$this->getHash($data);
$fileFilterID=0;
$fileFilterData=$this->db->get_where('file_filter',array('hash'=>$hash),1)->row_array();
if (!empty($fileFilterData)){
$fileFilterID=$fileFilterData['file_filter_id'];
}
elseif($createIfNone) {
$this->db->insert('file_filter',array('hash'=>$hash));
$fileFilterID=$this->db->insert_id();
}
return $fileFilterID;
}
function updateFilter($source,$target){
$sourceFilterID=$this->getFilterID($source,false);
if ($sourceFilterID>0){
$file=$this->db->where('file_filter_id',$sourceFilterID)->get('file',1)->row_array();
if ($file){
$targetFilterID=$this->getFilterID($target,false);
if ($targetFilterID>0){
$this->db->where('file_filter_id',$sourceFilterID)
->update('file',array('file_filter_id'=>$targetFilterID));
$this->db->where('file_filter_id',$sourceFilterID)->delete('file_filter');
return $targetFilterID;
}
else {
$this->db->where('file_filter_id',$sourceFilterID)
->update('file_filter',array('hash'=>$this->getHash($target)));
return $sourceFilterID;
}
}
else {
$this->db->where('file_filter_id',$sourceFilterID)->delete('file_filter');
}
}
else {
return $this->getFilterID($target,false);
}
return 0;
}
function remove($fileID){
$this->db->where('file_id',$fileID*1)->delete('file');
}
}
?>