Example #1
0
    }
    $data = elements(array('title', 'galleryOption'), $_POST);
    $allGood = true;
    foreach ($data as $value) {
        if ($value === null || empty($value)) {
            $allGood = false;
            break;
        }
    }
    $data['description'] = element('description', $_POST, '');
    foreach ($data as $key => $value) {
        $data[$key] = htmlentities($value);
    }
    if ($allGood) {
        //save to database
        updatePicture($_GET['id'], $data['title'], $data['description'], $data['galleryOption']);
        header('Location: mypictures.php');
    } else {
        echo "Not all required fields are filled..";
    }
}
$galleries = getGalleries($_SESSION['user_id']);
$galleryId = array_values(getGalleriesIds(array($_GET['id']), 'slike.txt'))[0];
//napravi izbor korisnikovih galerija
$options = array();
foreach ($galleries as $key => $value) {
    if ($key == $galleryId) {
        array_push($options, create_element("option", true, ["contents" => $value, "value" => $key, "selected" => "selected"]));
    } else {
        array_push($options, create_element("option", true, ["contents" => $value, "value" => $key]));
    }
Example #2
0
         $image_bytes = $json['image'];
         $content = base64_decode($image_bytes);
         $image = imagecreatefromstring($content);
         if ($image === false) {
             header('Content-Type: application/json');
             echo json_encode(['error' => 'Error: Could not decode the image!']);
             exit;
         }
         $upload_dir = '/var/www/gm/assets/pictures/';
         $upload_url = 'http://35.9.22.229:8080/assets/pictures/';
         // Generates unique filename for the image
         $filename = uniqid('image', true) . '.jpg';
         // Stores file on the server
         if (imagejpeg($image, $upload_dir . $filename)) {
             $picture_url = $upload_url . $filename;
             $result = updatePicture($picture_url, $upload_dir, $interaction_id);
             header('Content-Type: application/json');
             echo json_encode($result);
             exit;
         } else {
             header('Content-Type: application/json');
             echo json_encode(['error' => 'Error: Could not store the image!']);
             exit;
         }
     } else {
         header('Content-Type: application/json');
         echo json_encode(['error' => 'Error: Image not found!']);
         exit;
     }
 } else {
     header('Content-Type: application/json');
Example #3
0
     $fileFolder = $BASE_DIR . "images/users/";
     $filePathSmall = $fileFolder . $_SESSION['username'] . "_small" . "." . $extension;
     $filePathMedium = $fileFolder . $_SESSION['username'] . "_medium" . "." . $extension;
     $filePathLarge = $fileFolder . $_SESSION['username'] . "_large" . "." . $extension;
     if (getPictureLargeId($_SESSION['username'])['idpicture'] == 1) {
         createPicture($_SESSION['username'], 'small', $filePathSmall);
         createPicture($_SESSION['username'], 'medium', $filePathMedium);
         createPicture($_SESSION['username'], 'large', $filePathLarge);
     } else {
         $idpictures = getUserPicturesId($_SESSION['username']);
         foreach ($idpictures as $idpicture) {
             unlink(getPicturePath($idpicture)['path']);
         }
         updatePicture($_SESSION['username'], 'small', $filePathSmall);
         updatePicture($_SESSION['username'], 'medium', $filePathMedium);
         updatePicture($_SESSION['username'], 'large', $filePathLarge);
     }
     $wmaxsmall = 50;
     $hmaxsmall = 50;
     $wmaxmedium = 100;
     $hmaxmedium = 100;
     $wmaxlarge = 110;
     $hmaxlarge = 110;
     ak_img_resize($fileTmpPath, $filePathSmall, $wmaxsmall, $hmaxsmall, $extension);
     ak_img_resize($fileTmpPath, $filePathMedium, $wmaxmedium, $hmaxmedium, $extension);
     ak_img_resize($fileTmpPath, $filePathLarge, $wmaxlarge, $hmaxlarge, $extension);
     chmod($filePathSmall, 0644);
     chmod($filePathMedium, 0644);
     chmod($filePathLarge, 0644);
     unlink($fileTmpPath);
 } else {