Exemplo n.º 1
0
 public function reduceImage($routeDest)
 {
     $img = new \abeautifulsite\SimpleImage($this->route . $this->getFileName());
     $img->fit_to_width(300);
     $img->save();
     if ($routeDest) {
         $img->thumbnail(100, 75);
         $img->save($routeDest . $this->fileName);
     }
 }
Exemplo n.º 2
0
 public function checkAddSmallProfileImage($profileImage)
 {
     $file = new File();
     $file->Load('name = ?', array($profileImage->name . "_small"));
     if (empty($file->id)) {
         LogManager::getInstance()->info("Small profile image " . $profileImage->name . "_small not found");
         $largeFileUrl = $this->getFileUrl($profileImage->name);
         $file->name = $profileImage->name . "_small";
         $signInMappingField = SIGN_IN_ELEMENT_MAPPING_FIELD_NAME;
         $file->{$signInMappingField} = $profileImage->{$signInMappingField};
         $file->filename = $file->name . str_replace($profileImage->name, "", $profileImage->filename);
         $file->file_group = $profileImage->file_group;
         file_put_contents("/tmp/" . $file->filename . "_orig", file_get_contents($largeFileUrl));
         if (file_exists("/tmp/" . $file->filename . "_orig")) {
             //Resize image to 100
             $img = new abeautifulsite\SimpleImage("/tmp/" . $file->filename . "_orig");
             $img->fit_to_width(100);
             $img->save("/tmp/" . $file->filename);
             $uploadFilesToS3Key = SettingsManager::getInstance()->getSetting("Files: Amazon S3 Key for File Upload");
             $uploadFilesToS3Secret = SettingsManager::getInstance()->getSetting("Files: Amazone S3 Secret for File Upload");
             $s3Bucket = SettingsManager::getInstance()->getSetting("Files: S3 Bucket");
             $uploadname = CLIENT_NAME . "/" . $file->filename;
             $localFile = "/tmp/" . $file->filename;
             $s3FileSys = new S3FileSystem($uploadFilesToS3Key, $uploadFilesToS3Secret);
             $result = $s3FileSys->putObject($s3Bucket, $uploadname, $localFile, 'authenticated-read');
             unlink("/tmp/" . $file->filename);
             unlink("/tmp/" . $file->filename . "_orig");
             LogManager::getInstance()->info("Upload Result:" . print_r($result, true));
             if (!empty($result)) {
                 $ok = $file->Save();
             }
             return $file;
         }
         return null;
     }
     return $file;
 }
Exemplo n.º 3
0
 public function createVersion($imagePath, $sizeString = false)
 {
     if (strlen($this->urlAlias) < 1) {
         throw new \Exception('Image without urlAlias!');
     }
     $cachePath = $this->getModule()->getCachePath();
     $subDirPath = $this->getSubDur();
     $fileExtension = pathinfo($this->filePath, PATHINFO_EXTENSION);
     if ($sizeString) {
         $sizePart = '_' . $sizeString;
     } else {
         $sizePart = '';
     }
     $pathToSave = $cachePath . '/' . $subDirPath . '/' . $this->urlAlias . $sizePart . '.' . $fileExtension;
     BaseFileHelper::createDirectory(dirname($pathToSave), 0777, true);
     if ($sizeString) {
         $size = $this->getModule()->parseSize($sizeString);
     } else {
         $size = false;
     }
     if ($this->getModule()->graphicsLibrary == 'Imagick') {
         $image = new \Imagick($imagePath);
         $image->setImageCompressionQuality(100);
         if ($size) {
             if ($size['height'] && $size['width']) {
                 $image->cropThumbnailImage($size['width'], $size['height']);
             } elseif ($size['height']) {
                 $image->thumbnailImage(0, $size['height']);
             } elseif ($size['width']) {
                 $image->thumbnailImage($size['width'], 0);
             } else {
                 throw new \Exception('Something wrong with this->module->parseSize($sizeString)');
             }
         }
         $image->writeImage($pathToSave);
     } else {
         $image = new \abeautifulsite\SimpleImage($imagePath);
         if ($size) {
             if ($size['height'] && $size['width']) {
                 //$image->thumbnail($size['width'], $size['height']);
                 $image->best_fit($size['width'], $size['height']);
             } elseif ($size['height']) {
                 $image->fit_to_height($size['height']);
             } elseif ($size['width']) {
                 $image->fit_to_width($size['width']);
             } else {
                 throw new \Exception('Something wrong with this->module->parseSize($sizeString)');
             }
         }
         //WaterMark
         if ($this->getModule()->waterMark) {
             if (!file_exists(Yii::getAlias($this->getModule()->waterMark))) {
                 throw new Exception('WaterMark not detected!');
             }
             $wmMaxWidth = intval($image->get_width() * 0.4);
             $wmMaxHeight = intval($image->get_height() * 0.4);
             $waterMarkPath = Yii::getAlias($this->getModule()->waterMark);
             $waterMark = new \abeautifulsite\SimpleImage($waterMarkPath);
             if ($waterMark->get_height() > $wmMaxHeight or $waterMark->get_width() > $wmMaxWidth) {
                 $waterMarkPath = $this->getModule()->getCachePath() . DIRECTORY_SEPARATOR . pathinfo($this->getModule()->waterMark)['filename'] . $wmMaxWidth . 'x' . $wmMaxHeight . '.' . pathinfo($this->getModule()->waterMark)['extension'];
                 //throw new Exception($waterMarkPath);
                 if (!file_exists($waterMarkPath)) {
                     $waterMark->fit_to_width($wmMaxWidth);
                     $waterMark->save($waterMarkPath, 100);
                     if (!file_exists($waterMarkPath)) {
                         throw new Exception('Cant save watermark to ' . $waterMarkPath . '!!!');
                     }
                 }
             }
             $image->overlay($waterMarkPath, 'bottom right', 0.5, -10, -10);
         }
         $image->save($pathToSave, 100);
     }
     return $image;
 }
Exemplo n.º 4
0
        }
    }
    if ($_FILES['file']['tmp_name']) {
        if ($_FILES['file']['error'] > 0) {
            $err['file'] = "An error has occurred";
        } elseif ($_FILES["file"]["type"] != "image/gif" && $_FILES["file"]["type"] != "image/jpeg" && $_FILES["file"]["type"] != "image/pjpeg" && $_FILES["file"]["type"] != "image/png") {
            $err['file'] = "Invalid file type";
        }
    }
    if (sizeof($err) == 0) {
        $sql = "update shoutUsers set fname = '{$first}', lname = '{$last}', email = '{$email}' where id = '{$_SESSION['uid']}'";
        $result = mysqli_query($db, $sql) or die('Query failed: ' . mysqli_error($db));
        if ($_FILES['file']['tmp_name']) {
            try {
                $img = new abeautifulsite\SimpleImage($_FILES['file']['tmp_name']);
                $img->fit_to_width(250)->save('photos/' . $_SESSION['uid'] . '.jpg');
                $img->fit_to_width(800)->save('photos/lg_' . $_SESSION['uid'] . '.jpg');
            } catch (Exception $e) {
                echo 'Error: ' . $e->getMessage();
            }
        }
        $_SESSION['first'] = $first;
        $_SESSION['last'] = $last;
        header("Location: account.php?success=true");
        exit;
    } else {
        header("Location: account.php?success=false1");
        exit;
    }
} elseif ($_POST['submit1']) {
    $sql = "select upass from shoutUsers where id = '{$_SESSION['uid']}'";
 $output_dir = "../../img/slider/";
 if (isset($_FILES["myfile"])) {
     $ret = array();
     $error = $_FILES["myfile"]["error"];
     //You need to handle  both cases
     //If Any browser does not support serializing of multiple files using FormData()
     if (!is_array($_FILES["myfile"]["name"])) {
         $fileName = 'slider-' . rand(1000, 10000) . '.' . pathinfo($_FILES["myfile"]["name"], PATHINFO_EXTENSION);
         while (file_exists($output_dir . $fileName)) {
             $fileName = 'slider-' . rand(1000, 10000) . '.' . pathinfo($_FILES["myfile"]["name"], PATHINFO_EXTENSION);
         }
         if (move_uploaded_file($_FILES["myfile"]["tmp_name"], $output_dir . $fileName)) {
             mysql_query("INSERT INTO mainslider(path) VALUES ('{$fileName}')");
         }
         $image = new abeautifulsite\SimpleImage($output_dir . $fileName);
         $image->fit_to_width(200)->save($output_dir . 'k-' . $fileName);
         $ret[] = $fileName;
         $ret[] = mysql_insert_id();
         $ret[] = mysql_error();
     } else {
         $fileCount = count($_FILES["myfile"]["name"]);
         for ($i = 0; $i < $fileCount; $i++) {
             $fileName = 'slider-' . rand(1000, 10000) . '.' . pathinfo($_FILES["myfile"]["name"], PATHINFO_EXTENSION);
             while (file_exists($output_dir . $fileName)) {
                 $fileName = 'slider-' . rand(1000, 10000) . '.' . pathinfo($_FILES["myfile"]["name"], PATHINFO_EXTENSION);
             }
             if (move_uploaded_file($_FILES["myfile"]["tmp_name"], $output_dir . $fileName)) {
                 mysql_query("INSERT INTO mainslider(path) VALUES ('{$fileName}')");
             }
             $image = new SimpleImage();
             $image->load($output_dir . $fileName);
Exemplo n.º 6
0
 public function createVersion($imagePath, $sizeString = false, $crop = true, $fitImageInCanvas = false)
 {
     if (strlen($this->urlAlias) < 1) {
         throw new \Exception('Image without urlAlias!');
     }
     $cachePath = $this->getModule()->getCachePath();
     $subDirPath = $this->getSubDur();
     $fileExtension = pathinfo($this->filePath, PATHINFO_EXTENSION);
     if ($sizeString) {
         $sizePart = '_' . $sizeString;
     } else {
         $sizePart = '';
     }
     $pathToSave = $cachePath . '/' . $subDirPath . '/' . $this->urlAlias . $sizePart . '.' . $fileExtension;
     BaseFileHelper::createDirectory(dirname($pathToSave), 0777, true);
     if ($sizeString) {
         $size = $this->getModule()->parseSize($sizeString);
     } else {
         $size = false;
     }
     if ($this->getModule()->graphicsLibrary == 'Imagick') {
         // Fixes interlaced images
         $interlaceFix = $this->interlaceFix($imagePath);
         if ($interlaceFix) {
             $image = new \Imagick();
             $image->readImageBlob($interlaceFix);
         } else {
             $image = new \Imagick($imagePath);
         }
         $image->setImageCompressionQuality(100);
         // Fixes image rotations
         $this->ImagickAutoRotateImage($image);
         // If the dimensions of the original image match the requested
         // dimensions the original image is just copied to the new path
         if ($image->getImageWidth() == $size['width'] && $image->getImageHeight() == $size['height']) {
             copy($imagePath, $pathToSave);
             return $image;
         }
         if ($size) {
             if ($size['height'] && $size['width']) {
                 if (!$crop && $fitImageInCanvas) {
                     $image = $this->fitImageInCanvas($image, $size['width'], $size['height']);
                 } elseif ($crop) {
                     $image->cropThumbnailImage($size['width'], $size['height']);
                 } else {
                     $image->resizeImage($size['width'], $size['height'], \Imagick::FILTER_HAMMING, 1, false);
                 }
             } elseif ($size['height']) {
                 $image->thumbnailImage(0, $size['height']);
             } elseif ($size['width']) {
                 $image->thumbnailImage($size['width'], 0);
             } else {
                 throw new \Exception('Something wrong with this->module->parseSize($sizeString)');
             }
         }
         $image->writeImage($pathToSave);
     } else {
         $image = new \abeautifulsite\SimpleImage($imagePath);
         // If the dimensions of the original image match the requested
         // dimensions the original image is just copied to the new path
         if ($image->get_width() == $size['width'] && $image->get_height() == $size['height']) {
             copy($imagePath, $pathToSave);
             return $image;
         }
         if ($size) {
             if ($size['height'] && $size['width']) {
                 if ($crop) {
                     $image->thumbnail($size['width'], $size['height']);
                 } else {
                     $image->resize($size['width'], $size['height']);
                 }
             } elseif ($size['height']) {
                 $image->fit_to_height($size['height']);
             } elseif ($size['width']) {
                 $image->fit_to_width($size['width']);
             } else {
                 throw new \Exception('Something wrong with this->module->parseSize($sizeString)');
             }
         }
         //WaterMark
         if ($this->getModule()->waterMark) {
             if (!file_exists(Yii::getAlias($this->getModule()->waterMark))) {
                 throw new Exception('WaterMark not detected!');
             }
             $wmMaxWidth = intval($image->get_width() * 0.4);
             $wmMaxHeight = intval($image->get_height() * 0.4);
             $waterMarkPath = Yii::getAlias($this->getModule()->waterMark);
             $waterMark = new \abeautifulsite\SimpleImage($waterMarkPath);
             if ($waterMark->get_height() > $wmMaxHeight or $waterMark->get_width() > $wmMaxWidth) {
                 $waterMarkPath = $this->getModule()->getCachePath() . DIRECTORY_SEPARATOR . pathinfo($this->getModule()->waterMark)['filename'] . $wmMaxWidth . 'x' . $wmMaxHeight . '.' . pathinfo($this->getModule()->waterMark)['extension'];
                 //throw new Exception($waterMarkPath);
                 if (!file_exists($waterMarkPath)) {
                     $waterMark->fit_to_width($wmMaxWidth);
                     $waterMark->save($waterMarkPath, 100);
                     if (!file_exists($waterMarkPath)) {
                         throw new Exception('Cant save watermark to ' . $waterMarkPath . '!!!');
                     }
                 }
             }
             $image->overlay($waterMarkPath, 'bottom right', 0.5, -10, -10);
         }
         $image->save($pathToSave, 100);
     }
     return $image;
 }
Exemplo n.º 7
0
 public function save()
 {
     $eqApp = new Apps();
     $getFinfo_q = 'SELECT * FROM cms_records 
                    WHERE 
                    fieldsetid = "' . $_POST['fieldsetid'] . '" 
                    ORDER BY sortorder ASC';
     $getFinfo_r = mysql_query($getFinfo_q);
     $getFinfo_n = mysql_num_rows($getFinfo_r);
     $pnum = 1;
     $checkPosted = 0;
     //START INSERT QUERY BEGINNING WITH USUAL STARTING VALUES
     $query_q = 'UPDATE cms_content SET ';
     //WHILE LOOP FOR ADDING THE DATABASE VALUES
     while ($getFinfo = mysql_fetch_array($getFinfo_r)) {
         switch ($getFinfo['type']) {
             case "file":
                 if (isset($_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]["name"])) {
                     $fileInput = rand() . $_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]["name"];
                     if (!file_exists('../uploads/' . $_POST['id'] . '/')) {
                         mkdir('../uploads/' . $_POST['id'] . '/', 0777);
                     }
                     if (!file_exists('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'])) {
                         mkdir('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'], 0777);
                     } else {
                         foreach (glob('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'] . '/*') as $file) {
                             if (is_dir($file)) {
                                 recursiveRemoveDirectory($file);
                             } else {
                                 unlink($file);
                             }
                         }
                     }
                     move_uploaded_file($_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]["tmp_name"], '../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'] . '/' . $filename . '.' . $fileext);
                     $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . $fileInput . '" ';
                     $checkPosted++;
                 }
                 break;
             case "photo":
                 if (!empty($_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]["name"])) {
                     if (!file_exists('../uploads/' . $_POST['id'] . '/')) {
                         mkdir('../uploads/' . $_POST['id'] . '/', 0777);
                     }
                     if (!file_exists('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'])) {
                         mkdir('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'], 0777);
                     } else {
                         foreach (glob('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'] . '/*') as $file) {
                             if (is_dir($file)) {
                                 recursiveRemoveDirectory($file);
                             } else {
                                 unlink($file);
                             }
                         }
                     }
                     $filename = pathinfo($_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]["name"], PATHINFO_FILENAME);
                     $fileext = strtolower(pathinfo($_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]["name"], PATHINFO_EXTENSION));
                     $filename = strtolower(rand() . $filename);
                     $img = new abeautifulsite\SimpleImage($_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]['tmp_name']);
                     $img->fit_to_width(300)->save('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'] . '/300xauto_' . $filename . '.' . $fileext);
                     $img->save('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'] . '/' . $filename . '.' . $fileext);
                     move_uploaded_file($_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]["tmp_name"], '../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'] . '/' . $filename . '.' . $fileext);
                     $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . $filename . '.' . $fileext . '" ';
                     $checkPosted++;
                 }
                 break;
             case "html":
                 $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . addslashes(htmlspecialchars($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']])) . '" ';
                 $checkPosted++;
                 break;
             case "yesno":
                 $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . $_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']] . '" ';
                 $checkPosted++;
                 break;
             case "multiselect":
             case "checkboxes":
                 $vals = "";
                 $x = 0;
                 if (isset($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']])) {
                     foreach ($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']] as $key => $value) {
                         $x++;
                         $vals .= $value . ($x < count($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']]) ? "," : "");
                     }
                     $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . $vals . '" ';
                     $checkPosted++;
                 }
                 break;
             case "radio":
                 $vals = "";
                 $x = 0;
                 if (!empty($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']])) {
                     $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . htmlspecialchars($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']]) . '" ';
                     $checkPosted++;
                 }
                 break;
             case "foreignkey":
                 $fkeyOptions = $eqApp->get_field_options($getFinfo['options'], $pnum - 1);
                 if ($fkeyOptions['record_fkeytype'] == "select") {
                     $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . htmlspecialchars($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']]) . '" ';
                     $checkPosted++;
                 } elseif ($fkeyOptions['record_fkeytype'] == "multiselect") {
                     $vals = '';
                     if (isset($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']])) {
                         $d = 0;
                         foreach ($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']] as $key => $value) {
                             $d++;
                             $vals .= htmlspecialchars($value) . ($d < count($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']]) ? "," : "");
                         }
                     }
                     $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . $vals . '" ';
                     $checkPosted++;
                 }
                 break;
             case "custom_url":
                 $custom_url = ltrim(rtrim($getFinfo['custom_url'], '/'), '/');
                 $perma = explode('/', $custom_url);
                 $postedCustomUrl = "";
                 $ddnum = 0;
                 foreach ($perma as $links) {
                     $ddnum++;
                     if (isset($_POST[$links])) {
                         $postedCustomUrl .= $eqApp->permaLink($_POST[$links]) . '/';
                     }
                 }
                 $postedCustomUrl = rtrim($postedCustomUrl, '/');
                 $checkCU_q = 'SELECT * FROM cms_content 
                                     WHERE 
                                     custom_url = "' . $postedCustomUrl . '" 
                                     AND id <> "' . $_POST['id'] . '"';
                 $checkCU_r = mysql_query($checkCU_q);
                 $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . $postedCustomUrl . (mysql_num_rows($checkCU_r) > 0 ? rand() : '') . '" ';
                 $checkPosted++;
                 break;
             default:
                 //for text,textarea,colorpicker,date,select
                 $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . htmlspecialchars($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']]) . '" ';
                 $checkPosted++;
                 break;
         }
         $pnum++;
     }
     $query_q .= 'WHERE id = "' . $_POST['id'] . '"';
     if ($checkPosted > 0) {
         mysql_query($query_q) or die(mysql_error());
     }
     exit;
 }
Exemplo n.º 8
0
function serve($width, $height, $person)
{
    $app = \Slim\Slim::getInstance();
    $response = $app->response();
    $response['Content-Type'] = 'image/jpeg';
    $img = new abeautifulsite\SimpleImage(getBestImage($width, $height, $person));
    if ($img->get_width() / $img->get_height() >= $width / $height) {
        $img->fit_to_height($height);
        $centre = round($img->get_width() / 2);
        $x1 = $centre - $width / 2;
        $x2 = $centre + $width / 2;
        $img->crop($x1, 0, $x2, $height);
    } else {
        $img->fit_to_width($width);
        $centre = round($img->get_height() / 2);
        $y1 = $centre - $height / 2;
        $y2 = $centre + $height / 2;
        $img->crop(0, $y1, $width, $y2);
    }
    $img = applyFilters($img);
    $img->output();
}
Exemplo n.º 9
0
/**
 * Resize and save an image
 * 
 * @param
 * @return
 */
function resizeAndSaveImage($originalPath, $destination, $W, $H)
{
    list($width, $height, $type, $attr) = getimagesize($originalPath);
    $img = new abeautifulsite\SimpleImage($originalPath);
    if ($width / $height < $W / $H) {
        //portrait
        $y1 = ($height * $W / $width - $H) / 2;
        $y2 = ($height * $W / $width - $H) / 2 + $H;
        $img->fit_to_width($W)->crop(0, $y1, $W, $y2)->save($destination);
    } else {
        //landscape
        $x1 = ($width * $H / $height - $W) / 2;
        $x2 = ($width * $H / $height - $W) / 2 + $W;
        $img->fit_to_height($H)->crop($x1, 0, $x2, $H)->save($destination);
    }
    /*
    		 if($width/$height < $W/$H){
    			$img->fit_to_width($W)->crop(0, ($height - $H) / 2, $W, (($height - $H) / 2) + $H)->save($destination);
    		} else{
    			$img->fit_to_height($H)->crop(($width - $W) / 2, 0, (($width - $W) / 2) + $W, $H)->save($destination);
    		}
    */
}
Exemplo n.º 10
0
 private function save_action_image($new_file_name)
 {
     ini_set('memory_limit', '256M');
     include './third_part/SimpleImage.php';
     try {
         $img = new abeautifulsite\SimpleImage($this->user_action_uploads_dir . $new_file_name);
         $wim = $img->get_width();
         $him = $img->get_height();
         if ($wim > 1000 && $him > 250) {
             $img->fit_to_width(740)->save($this->user_action_save_dir . '740_' . $new_file_name);
             $img->fit_to_width(200)->save($this->user_action_save_dir . '200_' . $new_file_name);
             if (file_exists($this->user_action_save_dir . '740_' . $new_file_name) && file_exists($this->user_action_save_dir . '200_' . $new_file_name)) {
                 unlink($this->user_action_uploads_dir . $new_file_name);
                 echo json_encode(array('file_name' => $new_file_name, "success" => 1));
             } else {
                 echo json_encode(array("error" => -1, 'error_message' => 'unknown_file'));
             }
         } else {
             unlink($this->user_action_uploads_dir . $new_file_name);
             echo json_encode(array("error" => -1, 'error_message' => 'size_error'));
         }
     } catch (Exception $e) {
         echo json_encode(array("error" => -1, 'error_message' => $e->getMessage()));
     }
 }