Server IP : 80.241.246.6 / Your IP : 216.73.216.188 Web Server : Apache/2.4.25 (Debian) System : Linux kharagauli 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64 User : www-data ( 33) PHP Version : 7.0.33-0+deb9u12 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_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/kharagauli1/moduls/img_gallery/site/ |
Upload File : |
<?php /* @author suxoza <suxoza@gmail.com> */ if(realpath(__FILE__) == realpath($_SERVER['SCRIPT_FILENAME']))die("__main__ ".__FILE__); //$_->pre($_POST); //$_->pre($_FILES); $select_body = $_->select("*","body","big",["page_id",$select_menu['id']]); $select_body = (isset($select_body['body']) && count($select_body['body']))?$select_body['body']:FALSE; $iterator = 1; $_array = []; deletes($_); foreach($_POST as $key => $value){ if($_->startsWith($key,'file_')){ if(isset($_POST['title_'.$_->language_config[0].'_'.$iterator])){ $bool = (isset($_POST['id_'.$iterator]))?$_POST['id_'.$iterator]:''; $file = ($bool)?find_in_array($select_body,$bool):''; //echo $file."<br/>"; //echo ($bool)?'id_exists '.$iterator.'<br/>':'id_not_exists '.$iterator.'<br/>'; if($value){ delete_old_file($file,$_); if($_->startsWith($value,'http')) copy_file($key,$value,$iterator,$_,$file); else if($_->startsWith($value,'data:')) move_uploaded($key,$value,$iterator,$_,$file); } $insert = ['logo','attributes','page_date','date_modify']; $value = [$file,'',time(),time()]; for($i = 0; $i < count($_->language_config); $i++){ $insert[] = "body_".$_->language_config[$i]; $value[] = $_->clier($_POST['title_'.$_->language_config[$i].'_'.$iterator]); } if(!$bool){ array_push($insert,'page_id','date'); array_push($value,$select_menu['id'],time()); $_->insert("body",[$insert,$value]); }else{ $_->update("body",[$insert,$value,["page_id",$select_menu['id'],"id",$bool]]); } } $iterator++; } } function copy_file($key,$file,$iterator,$_,&$_array){ $masiv = explode('.',$file); $end = end($masiv); $file_name = str_replace(' ','_',$key).'_'.time().'_'.$iterator; if(copy($file,$_->_dir.'img/banners/'.$file_name.'.'.$end)){ $_->main_images($file_name.'.'.$end,$_->_dir.'img/banners',$_->_dir.'img/banners/small',$file_name,240,2); $_array = $file_name.'.'.$end; } } function move_uploaded($key,$file,$iterator,$_,&$_array){ $file_name = str_replace(' ','_',$key).'_'.time().'_'.$iterator; if(substr($file,0,5) == 'data:'){ $dat = explode(';',$file); $dat = explode('/',$dat[0]); $dat = str_replace('e','',$dat[1]); $data = base64_decode(str_replace(' ','+',explode(',', $file)[1])); // if(substr($file,5,5) == 'video'){ // if(file_put_contents('img/video/'.$file_name.'.'.$dat,$data)){ // $file = 'img/video/'.$file_name.'.'.$dat; // } // } // else if(substr($file,5,5) == 'image'){ if(file_put_contents($_->_dir.'img/banners/'.$file_name.'.'.$dat,$data)){ $_->main_images($file_name.'.'.$dat,$_->_dir.'img/banners',$_->_dir.'img/banners/small',$file_name,240,2); $_array = $file_name.'.'.$dat; } } } } function deletes($_){ if($_POST['deletes']){ $delete = substr($_POST['deletes'], 0, -1); $delete = explode('|', $delete); $obj = new stdClass(); $obj->c_type = "big"; $obj->sql = " and id in(".join(",",$delete).")"; $sel = $_->select("*","body",$obj)['body']; for($i = 0; $i < count($sel); $i++){ $file = $sel[$i]['logo']; delete_old_file($file,$_); } $sql = "delete from body where id in(".join(",",$delete).")"; $_->con->exec($sql); //echo $sql; } } function delete_old_file(&$file,$_){ if($file){ if(file_exists($_->_dir.'img/banners/'.$file))@unlink($_->_dir.'img/banners/'.$file); if(file_exists($_->_dir.'img/banners/small/'.$file))@unlink($_->_dir.'img/banners/small/'.$file); $file = ''; } } function find_in_array($array,$id){ if(!count($array))return ''; $length = count($array); for($i = 0; $i < $length; $i++){ if($array[$i]['id'] == $id) return $array[$i]['logo']; }return ''; } header("Location:".$_SERVER['HTTP_REFERER'].$_COOKIE['location_href_menu']."/changed/"); exit; /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// // $select_body = $_->select("logo","body","small",["page_id",$select_menu['id']]); // $_logo = $select_body; // // if($_FILES['file']['name'] && preg_match('/[.](jpg)|(JPG)|(jpeg)|(JPEG)|(gif)|(GIF)|(png)|(PNG)$/',$_FILES['file']['name'])) // $_logo = $_->upload_image($_FILES['file'],$_logo); // else{ // // // // if($_POST['delete_logo']){ // if($_logo){ // if(file_exists($_->_dir.'img/banners/'.$_logo))@unlink($_->_dir.'img/banners/'.$_logo); // if(file_exists($_->_dir.'img/banners/small/'.$_logo))@unlink($_->_dir.'img/banners/small/'.$_logo); // $_logo = ''; // } // } // } // $_time = 0; // if($_POST['time']){ // list($day,$month,$year) = explode('/',$_->clier($_POST['time'])); // $_time = mktime(0, 0, 0, $month, $day, $year); // } // // $insert = ['page_id','logo','attributes','page_date','date_modify']; // $value = [$select_menu['id'],$_logo,'',$_time,time()]; // for($i = 0; $i < count($_->language_config); $i++){ // $insert[] = "name_".$_->language_config[$i]; // $insert[] = "body_".$_->language_config[$i]; // $value[] = $_->clier($_POST['name_'.$_->language_config[$i]]); // $value[] = $_->clier($_POST['body_'.$_->language_config[$i]]); // } // // // if($_->update("body",[$insert,$value,["page_id",$select_menu['id']]])) // header("Location:".$_SERVER['HTTP_REFERER'].$_COOKIE['location_href_menu']."/changed/"); // else // die("insert error!!!!!"); ?>