index.php:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Word Dosyası Düzenleme</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
h1 {
text-align: center;
}
form {
max-width: 500px;
margin: 0 auto;
display: grid;
gap: 10px;
}
label {
display: block;
margin-bottom: 5px;
}
.form-row {
display: grid;
gap: 10px;
}
.form-row.small-inputs {
grid-template-columns: 1fr;
}
.form-row.large-inputs {
grid-template-columns: 1fr 1fr;
}
.submit-row {
display: flex;
justify-content: center;
align-items: center;
gap: 10px;
}
input[type="text"],
input[type="file"] {
width: 100%;
padding: 8px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[type="submit"] {
background-color: #4CAF50;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
input[type="submit"]:hover {
background-color: #45a049;
}
h2 {
margin-top: 20px;
margin-bottom: 10px;
}
h3 {
margin-top: 15px;
margin-bottom: 5px;
}
</style>
</head>
<body>
<h1>Word Dosyası Düzenleme</h1>
<form action="process.php" method="post" enctype="multipart/form-data">
<h2>Sınav Bilgileri</h2>
<label for="SINAVKODU">SINAVKODU:</label>
<input type="text" name="SINAVKODU" required><br><br>
<label for="SINAVTARIHISAATI">SINAVTARIHISAATI:</label>
<input type="text" name="SINAVTARIHISAATI" required><br><br>
<label for="SINAVYERI">SINAVYERI:</label>
<input type="text" name="SINAVYERI" required><br><br>
<label for="MYKSINAVYERIKODU">MYKSINAVYERIKODU:</label>
<input type="text" name="MYKSINAVYERIKODU" required><br><br>
<label for="TARİH">TARİH:</label>
<input type="text" name="TARİH" required><br><br>
<h2>Aday İşlemleri</h2>
<h3>Aday 1</h3>
<label for="1ADAYADSOYAD">ADAYADSOYAD:</label>
<input type="text" name="1ADAYADSOYAD" required><br><br>
<label for="1ADAYTC">ADAYTC:</label>
<input type="text" name="1ADAYTC" required><br><br>
<label for="ADAY1TELEFON">ADAYTELEFON:</label>
<input type="text" name="ADAY1TELEFON" required><br><br>
<h3>Aday 2</h3>
<label for="2ADAYADSOYAD">ADAYADSOYAD:</label>
<input type="text" name="2ADAYADSOYAD" required><br><br>
<label for="2ADAYTC">ADAYTC:</label>
<input type="text" name="2ADAYTC" required><br><br>
<label for="ADAY2TELEFON">ADAYTELEFON:</label>
<input type="text" name="ADAY2TELEFON" required><br><br>
<h3>Aday 3</h3>
<label for="3ADAYADSOYAD">ADAYADSOYAD:</label>
<input type="text" name="3ADAYADSOYAD" required><br><br>
<label for="3ADAYTC">ADAYTC:</label>
<input type="text" name="3ADAYTC" required><br><br>
<label for="ADAY3TELEFON">ADAYTELEFON:</label>
<input type="text" name="ADAY3TELEFON" required><br><br>
<h2>Değerlendirici İşlemleri</h2>
<label for="DEĞERLENDİRİCİAD">DEĞERLENDİRİCİAD:</label>
<input type="text" name="DEĞERLENDİRİCİAD" required><br><br>
<label for="DEĞERLENDİRİCİTC">DEĞERLENDİRİCİTC:</label>
<input type="text" name="DEĞERLENDİRİCİTC" required><br><br>
<label for="GÖZETMENAD">GÖZETMENAD:</label>
<input type="text" name="GÖZETMENAD" required><br><br>
<label for="GÖZETMENADTC">GÖZETMENADTC:</label>
<input type="text" name="GÖZETMENADTC" required><br><br>
<label for="fileToUpload">Word Dosyası Seç:</label>
<input type="file" name="fileToUpload" id="fileToUpload" accept=".docx" required><br><br>
<input type="submit" value="Dosyaları Yükle ve Düzenle" name="submit">
</form>
</body>
</html>process.php<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_FILES['fileToUpload'])) {
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$fileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
// Word dosyasını yükle
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "Dosya " . basename($_FILES["fileToUpload"]["name"]) . " başarıyla yüklendi.";
} else {
echo "Dosya yüklenirken hata oluştu.";
exit;
}
// Word dosyasını düzenle
$zip = new ZipArchive;
if ($zip->open($target_file) === TRUE) {
$content = $zip->getFromName('word/document.xml');
$content = str_replace('{{SINAVKODU}}', $_POST['SINAVKODU'], $content);
$content = str_replace('{{SINAVTARIHISAATI}}', $_POST['SINAVTARIHISAATI'], $content);
$content = str_replace('{{SINAVYERI}}', $_POST['SINAVYERI'], $content);
$content = str_replace('{{MYKSINAVYERIKODU}}', $_POST['MYKSINAVYERIKODU'], $content);
$content = str_replace('{{1ADAYADSOYAD}}', $_POST['1ADAYADSOYAD'], $content);
$content = str_replace('{{1ADAYTC}}', $_POST['1ADAYTC'], $content);
$content = str_replace('{{ADAY1TELEFON}}', $_POST['ADAY1TELEFON'], $content);
$content = str_replace('{{2ADAYADSOYAD}}', $_POST['1ADAYADSOYAD'], $content);
$content = str_replace('{{2ADAYTC}}', $_POST['1ADAYTC'], $content);
$content = str_replace('{{ADAY2TELEFON}}', $_POST['ADAY1TELEFON'], $content);
$content = str_replace('{{3ADAYADSOYAD}}', $_POST['1ADAYADSOYAD'], $content);
$content = str_replace('{{3ADAYTC}}', $_POST['1ADAYTC'], $content);
$content = str_replace('{{ADAY3TELEFON}}', $_POST['ADAY1TELEFON'], $content);
$content = str_replace('{{DEĞERLENDİRİCİAD}}', $_POST['DEĞERLENDİRİCİAD'], $content);
$content = str_replace('{{DEĞERLENDİRİCİTC}}', $_POST['DEĞERLENDİRİCİTC'], $content);
$content = str_replace('{{GÖZETMENAD}}', $_POST['GÖZETMENAD'], $content);
$content = str_replace('{{GÖZETMENADTC}}', $_POST['GÖZETMENADTC'], $content);
$content = str_replace('{{TARİH}}', $_POST['TARİH'], $content);
$content = str_replace('{{SINAVTARİHİSAATİ}}', $_POST['SINAVTARİHİSAATİ'], $content);
$zip->deleteName('word/document.xml');
$zip->addFromString('word/document.xml', $content);
$zip->close();
// Düzenlenmiş Word dosyasını indir
header("Content-Type: application/docx");
header("Content-Disposition: attachment; filename=edited_document.docx");
readfile($target_file);
} else {
echo "Word dosyası açılırken bir hata oluştu.";
}
// Geçici dosyayı sil
unlink($target_file);
} else {
echo "Dosya yüklenirken bir hata oluştu veya dosya bulunamadı.";
}
?>