private function rev_uploader() { $key = Tools::getValue('security_key'); if (empty($key) || Tools::encrypt(GlobalsRevSlider::MODULE_NAME) != $key) { echo json_encode(array('error_on' => 1, 'error_details' => 'Security Error')); die; } $targetFolder = ABSPATH . '/uploads/'; $randnum = rand(00, 9999999); $sds_time = time(); $NewFileName = $randnum . '-' . $sds_time; //$verifyToken = md5('unique_salt' . $_POST['timestamp']); if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; //$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder; $targetPath = $targetFolder; //$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name']; // Validate the file type $fileTypes = array('jpg', 'jpeg', 'gif', 'png'); // File extensions $fileParts = pathinfo($_FILES['Filedata']['name']); if (in_array($fileParts['extension'], $fileTypes)) { // $worked = UniteFunctionsWPRev::import_media_img($tempFile, $targetPath, $randnum.$_FILES['Filedata']['name']); $worked = UniteFunctionsWPRev::import_media_img($tempFile, $targetPath, $NewFileName . '.' . $fileParts['extension']); if (!empty($worked)) { echo '1'; } } else { echo '0'; } } }
require_once ABSPATH . "/revslider_admin.php"; $admin = new RevSliderAdmin(ABSPATH, false); $key = Tools::getValue('security_key'); if (empty($key) || Tools::encrypt(GlobalsRevSlider::MODULE_NAME) != $key) { echo json_encode(array('error_on' => 1, 'error_details' => 'Security Error')); die; } // Define a destination // $targetFolder = _PS_MODULE_DIR_.'revsliderprestashop/uploads'; // Relative to the root $targetFolder = ABSPATH . '/uploads/'; $randnum = rand(00, 9999999); //$verifyToken = md5('unique_salt' . $_POST['timestamp']); if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; //$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder; $targetPath = $targetFolder; //$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name']; // Validate the file type $fileTypes = array('jpg', 'jpeg', 'gif', 'png'); // File extensions $fileParts = pathinfo($_FILES['Filedata']['name']); if (in_array($fileParts['extension'], $fileTypes)) { $worked = UniteFunctionsWPRev::import_media_img($tempFile, $targetPath, $randnum . $_FILES['Filedata']['name']); if (!empty($worked)) { echo '1'; } } else { echo 'Invalid file type.'; } die; }
$is_img = false; } if ($is_img) { /*revolution odl system*/ $targetFolder = ABSPATH . '/uploads/'; $randnum = rand(00, 9999999); $sds_time = time(); $NewFileName = $randnum . '-' . $sds_time; $tempFile = $_FILES['file']['tmp_name']; $targetPath = $targetFolder; // Validate the file type $fileTypes = array('jpg', 'jpeg', 'gif', 'png'); // File extensions $fileParts = pathinfo($_FILES['file']['name']); if (in_array($fileParts['extension'], $fileTypes)) { $worked = UniteFunctionsWPRev::import_media_img($tempFile, $targetPath, $NewFileName . '.' . $fileParts['extension']); if (!empty($worked)) { echo '1'; } } else { echo '0'; } } } else { header('HTTP/1.1 406 file not permitted', true, 406); exit; } } else { header('HTTP/1.1 405 Bad Request', true, 405); exit; }