Вот сам код
Код: Выделить всё
<?php
$this->title = 'Письмо';
$this->params['breadcrumbs'][] = $this->title;
$dannie = $_POST;
if($dannie['process']=='go') {
//-------------------------------------------------------------------------------------------------------
$zip = new ZipArchive();
$outputFilename = 'tst.docx';
print"<hr> Пришло: ";
echo $dannie;
print "<br>";
print_r($dannie);
print "<br>";
echo $num = $dannie['num'];
$sss1 = $dannie['sss1'];
$token3 = $dannie['token3'];
$token4 = $dannie['token4'];
$token6 = $dannie['token6'];
$dates = date("d.m.Y", 1356361196); //24.12.2012
print"<hr> ";
print "<br>";
echo $num;
print "<br>";
echo $token4;
print "<br>";
print "<br>";
$dates = date("d.m.Y", 1356361196); //24.12.2012
$newfile = "web/msg/$num-$dates.docx";
$file = 'blank_pismo.docx';
if (!copy($file, $newfile)) {
echo "не удалось скопировать $file...\n";
}
/*
//
if (!copy($file, $newfile)) {
echo "не удалось скопировать $file...\n";
}*/
print"<hr> ";
$inputFilename = $newfile;
mysql_connect('localhost','root','');
mysql_select_db(tst);
$one=mysql_real_escape_string($_POST['token6']);
$two=mysql_real_escape_string($_POST['token4']);
$query="INSERT INTO IShodpisma (`tema`,`text`,`num`) VALUES ($token6,$token4,$num)";
if ($zip->open($inputFilename, ZipArchive::CREATE)!==TRUE) {
echo "Cannot open $filename :( "; die;
}
// Fetch the document.xml file from the word subdirectory in the archive.
$xml = $zip->getFromName('word/document.xml');
// Replace the tokens.
$xml = str_replace('{NUM}',$num, $xml);
$xml = str_replace('{KOMY}',$sss1, $xml);
$xml = str_replace('{OBR}',$token3, $xml);
$xml = str_replace('{TEXT}',$token4, $xml);
$xml = str_replace('{TEMA}',$token6, $xml);
$xml = str_replace('{DATA}',$dates, $xml);
// Write back to the document and close the object
if ($zip->addFromString('word/document.xml', $xml)) { echo 'File written!'; }
else { echo 'File not written. Go back and add write permissions to this folder!l'; }
$zip->close();
//-------------------------------------------------------------------------------------------------------
}
else{
?>
<div class="site-contact">
<form method="POST" action="">
<p>Номер <input name="num" type="text" value="777"></p>
<p>Кому <input name="sss1" type="text" value="Пипкину"></p>
<p>Обращение<input name="token3" type="text" value="Глубокоуважаемый"></p>
<p>Сообщение<input name="token4" class="token5" type="text" size="100" value="текст большой текст" ></p>
<p>Тема Сообщеиия<input name="token6" type="text" value="Тема"></p>
<p>Дата<input name="dates" type="text" value="06.06.2018"></p>
<p>Дата<input name="process" type="hidden" value="go"></p>
<input type="submit" value="Сохранить">
</form>
</div>
<?
}
?>