function saveData($data) { //dohvati ID $id = getIdentificator("identifikatori.txt", 'id_korisnika'); //spremi u bazu $handle = fopen("korisnici.txt", "a"); if ($handle) { fwrite($handle, $id . ';' . htmlentities($data['name']) . ';' . htmlentities($data['surname']) . ';' . htmlentities($data['email']) . ';' . sha1($data['password']) . "\n"); fclose($handle); } else { echo "error happened while opening file"; } }
function saveData($data) { $identificators = array(); //dohvati ID $id = getIdentificator("identifikatori.txt", 'id_galerije'); //spremi u bazu $handle = fopen("galerije.txt", "a"); $line = $id . ';'; if (isset($_POST['description'])) { $line .= htmlentities($_POST['description']) . ';'; } else { $line .= ';'; } $line .= htmlentities($_POST['name']) . ';'; $line .= $_SESSION['user_id'] . "\n"; if ($handle) { fwrite($handle, $line); fclose($handle); } else { echo "error happened while opening file"; } }
function storePicture($picture, $title, $description, $userID, $galleryID) { $SMALL_WIDTH = 64; $SMALL_HEIGHT = 64; $MEDIUM_WIDTH = 128; $MEDIUM_HEIGHT = 128; $LARGE_WIDTH = 512; $LARGE_HEIGHT = 512; $dimensions = getimagesize($picture); $picture_width = $dimensions[0]; $picture_height = $dimensions[1]; //dohvati ID $id = getIdentificator("identifikatori.txt", 'id_slike'); //spremi u bazu $handle = fopen("slike.txt", "a"); if ($handle) { fwrite($handle, $id . ';' . htmlentities($title) . ';' . htmlentities($description) . ';' . $userID . ';' . $galleryID . "\n"); fclose($handle); } else { echo "error happened while opening file"; } //save to disk $imagesDir = './images'; if ($_FILES["file"]["error"] == UPLOAD_ERR_OK) { $name = $id . '_original'; if (move_uploaded_file($picture, "{$imagesDir}/{$name}")) { makeThumbnail("{$imagesDir}/{$name}", "{$imagesDir}/{$id}" . '_small', $SMALL_WIDTH, $SMALL_HEIGHT, 100); if ($picture_height > $MEDIUM_HEIGHT && $picture_width > $MEDIUM_WIDTH) { makeThumbnail("{$imagesDir}/{$name}", "{$imagesDir}/{$id}" . '_medium', $MEDIUM_WIDTH, $MEDIUM_HEIGHT, 100); if ($picture_height > $LARGE_HEIGHT && $picture_width > $LARGE_WIDTH) { makeThumbnail("{$imagesDir}/{$name}", "{$imagesDir}/{$id}" . '_large', $LARGE_WIDTH, $LARGE_HEIGHT, 100); } } } else { echo "failed to upload, please try again."; } } }