File manager - Edit - /home/autoph/public_html/tasks/configuration.tar
Back
update_website_information.php 0000644 00000005372 15025114107 0012671 0 ustar 00 <?php include_once("../../cfg/db.php"); $return_arr["status"]=0; $return_arr["message"]=" No Action."; if(!isset($_POST['website-name'])){ exit(); } $post_website_name = $db -> escape(trim($_POST['website-name'])); $post_website_link = $db -> escape(trim($_POST['website-link'])); $post_signup_title = $db -> escape(trim($_POST['title'])); $post_signup_content = $db -> escape(trim($_POST['content'])); $db -> sql_query("UPDATE `settings` SET `value`='$post_website_name' where `name` = 'site_name'"); $db -> sql_query("UPDATE `settings` SET `value`='$post_website_link' where `name` = 'site_link'"); $db -> sql_query("UPDATE `settings_legals` SET title='$post_signup_title',`content`='$post_signup_content' where `name` = 'signup'"); if(isNotEmpty($_FILES['upload_picture']['name'])){ // Getting file name $filename = $_FILES['upload_picture']['name']; $maxsize = 6097152; if($_FILES['upload_picture']['size'] >= $maxsize || $_FILES['upload_picture']['size'] == 0 ){ $return_arr["status"]=0; $return_arr["message"]=" Image file too large. Image must less than 2 megabytes."; echo json_encode($return_arr); return; } $quality = 60; if($_FILES['upload_picture']['size'] >= $maxsize/2){ $quality = 30; } // Valid extension $valid_ext = array('png','jpeg','jpg'); // file extension $file_extension = pathinfo($filename, PATHINFO_EXTENSION); $file_extension = strtolower($file_extension); $RandomAccountNumber = uniqid(); $post_picture = $RandomAccountNumber.'.'.$file_extension; // Location $location = "../../dist/img/".$post_picture; // Check extension if(in_array($file_extension,$valid_ext)){ // Compress Image compressImage($_FILES['upload_picture']['tmp_name'],$location,$quality); }else{ $return_arr["status"]=0; $return_arr["message"]=" Invalid file type."; } $query_website_photo = "UPDATE `settings` SET `value`='$post_picture' where `name` = 'logo' "; $db -> sql_query($query_website_photo); } $return_arr["status"]=1; $return_arr["message"]=" Successfully updated."; echo json_encode($return_arr); // Compress image function compressImage($source, $destination, $quality) { $info = getimagesize($source); if ($info['mime'] == 'image/jpeg') $image = imagecreatefromjpeg($source); elseif ($info['mime'] == 'image/jpg') $image = imagecreatefromgif($source); elseif ($info['mime'] == 'image/png') $image = imagecreatefrompng($source); imagejpeg($image, $destination, $quality); } function isNotEmpty($data){ return preg_match('/\S/', $data); } ?>