ÿØÿà JFIF ` ` ÿþxØ
| Server IP : 109.234.164.53 / Your IP : 216.73.216.110 Web Server : Apache System : Linux cervelle.o2switch.net 4.18.0-553.32.1.lve.el8.x86_64 #1 SMP Thu Dec 19 13:14:03 UTC 2024 x86_64 User : computer3 ( 1098) PHP Version : 7.1.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/computer3/atlanticswim.fr/cp-admin/includes/functions/ |
Upload File : |
<?php
/*
Images upload
*/
function create_resized_picture($criteria=array()) {
$source_file_full_path = $criteria['source_file_full_path'];
$destination_folder = $criteria['destination_folder'];
$filename = $criteria['filename'];
$width = $criteria['width'];
$height = $criteria['height'];
$handle = new upload($source_file_full_path);
if ($handle->uploaded) {
// Create the miniatures
//$handle->file_new_name_body = $filename; // rename the file
//$handle->image_resize = true;
//$handle->image_ratio_pixels = 10000;
$handle->image_resize = true;
$handle->image_ratio_crop = true;
$handle->file_overwrite = true;
$handle->image_y = $width;
$handle->image_x = $height;
$handle->Process($destination_folder);
}
else {
echo $handle->error;
}
}
function clone_pictures($criteria=array()) {
$source_file_full_path = $criteria['source_file_full_path'];
$destination_folder = $criteria['destination_folder'];
$image_ratio_pixels = $criteria['image_ratio_pixels']; //ex: 10000
$handle = new upload($source_file_full_path);
if ($handle->uploaded) {
// Create the miniatures
if($image_ratio_pixels!='') $handle->image_ratio_pixels = $image_ratio_pixels;
$handle->image_resize = true;
$handle->image_ratio_crop = true;
$handle->file_overwrite = true;
//$handle->image_y = 206;
//$handle->image_x = 166;
$handle->Process($destination_folder);
}
else {
echo $handle->error;
}
}
function upload_image($file, $criteria) {
$file_path = $criteria['file_path'];
$file_name = $criteria['file_name'];
$max_file_size = $criteria['max_file_size'];
$image_ratio_pixels = $criteria['image_ratio_pixels'];
$handle = new Upload($file);
if ($handle->uploaded) {
$extension = $handle->file_src_name_ext;
$handle->file_new_name_body = $file_name; // rename the file
$handle->file_max_size = $max_file_size; // max size 1024=1ko
$handle->allowed = array('image/*');
if($image_ratio_pixels!='') $handle->image_ratio_pixels = $image_ratio_pixels;
$handle->image_resize = true;
$handle->image_ratio_crop = true;
$handle->file_overwrite = true;
$handle->Process($file_path);
if ($handle->processed) {
$upload_result['success'] = 1;
$upload_result['file_name'] = $handle->file_dst_name;
$upload_result['file_full_path'] = $file_path.$handle->file_dst_name;
return $upload_result;
}
else {
// one error occured
$upload_result['success'] = 0;
$upload_result['error'] = $handle->error;
return $upload_result;
}
//$handle-> Clean();
}
else {
$upload_result['success'] = 0;
$upload_result['error'] = $handle->error;
return $upload_result;
}
}
function uploadPictureByURL($criteria) {
$url = $criteria['url'];
$filename = $criteria['filename'];
$upload_directory = $criteria['upload_directory'];
$max_file_size = $criteria['max_file_size'];
if($max_file_size=='') $max_file_size = $GLOBALS['profile_picture_max_size'];
$url_flag=1;
preg_match('/^(http:\/\/)?([\w\-\.]+)\:?([0-9]*)\/(.*)$/', $url, $url_ary);
$base_get = '/' . $url_ary[4];
$port = ( !empty($url_ary[3]) ) ? $url_ary[3] : 80;
if ( !($fsock = fsockopen($url_ary[2], $port, $errno, $errstr)) ) {
die("Can't open the connexion...");
}
fputs($fsock, "GET $base_get HTTP/1.1\r\n");
fputs($fsock, "Host: " . $url_ary[2] . "\r\n");
fputs($fsock, "Accept-Language: fr\r\n");
fputs($fsock, "Accept-Encoding: none\r\n");
fputs($fsock, "User-Agent: PHP\r\n");
fputs($fsock, "Connection: close\r\n\r\n");
unset($data);
while( !feof($fsock) ) {
$data .= fread($fsock, $max_file_size);
}
fclose($fsock);
if (!preg_match('#Content-Length\: ([0-9]+)[^ /][\s]+#i', $data, $file_data1) || !preg_match('#Content-Type\: image/[x\-]*([a-z]+)[\s]+#i', $data, $file_data2)) {
die("Can't download the image (no data)...");
}
$filesize = $file_data1[1];
$filetype = $file_data2[1];
if ( $filesize > 0 && $filesize < $max_file_size ) {
$data = substr($data, strlen($data) - $filesize, $filesize);
$file_full_path = $_SERVER["DOCUMENT_ROOT"].'/'.$upload_directory.$filename.'.'.$filetype;
$fptr = @fopen($file_full_path, 'wb');
$bytes_written = @fwrite($fptr, $data, $filesize);
@fclose($fptr);
//echo $file_full_path.'<br>';
if ( $bytes_written != $filesize ) {
die("Can't upload the image (writting error).");
}
$upload_result['file_name'] = $filename.'.'.$filetype;
$upload_result['file_full_path'] = $file_full_path;
return $upload_result;
}
else {
die("Image too big.");
}
}
?>