Просмотр файла reklamadd.php

Размер файла: 3.52Kb
<?php
session_start();
$title='Добавить рекламу';
include"set.php";
include"top.php";
if (!isset($_POST['select']) && !isset($_POST['submit']))
{ echo 'Выберите то,что нужно добавить к рекламе в конце:<br>';
echo '<form method="POST">';
echo '<input type="radio" name="type" value="text" checked="checked">Обычный текст<br>';
echo '<input type="radio" name="type" value="href">Ссылку<br>';
echo '<input type="radio" name="type" value="image">Картинку со ссылкой<br>';
echo '<input type="submit" name="select" value="Выбираем"></form>';
echo'<a href="mainadmin.php">Назад в админку</a>';
}
if (isset($_POST['select']) and !isset($_POST['submit']))
{
switch ($_POST['type'])
{ case "text":
echo '<form method="POST">
Введите нужный текст:<br><input type="text" name="text" maxlength="100"><br>
Перенос в конце(абзац):<br><input type="radio" name="br" value="Yes" checked>Да<br>
<input type="radio" name="br" value="No">Нет<br>
<input type="hidden" name="type" value="text"><input type="submit" name="submit" value="Добавить"></form>';
break;
case"href":
echo '<form method="POST">
Введите ссылку:<br><input type="text" name="href" maxlength="50"><br>
Введите название ссылки:<br><input type="text" name="name" maxlength="50"><br>
Перенос в конце(абзац):<br><input type="radio" name="br" value="Yes" checked>Да<br>
<input type="radio" name="br" value="No">Нет<br>
<input type="hidden" name="type" value="href"><input type="submit" name="submit" value="Добавить"></form>';
break;
case"image":
echo '<form method="POST">
Ссылка на нужную картинку:<br><input type="text" name="image" maxlength="50"><br>
Ссылка при нажатии на картинку:<br><input type="text" name="href" maxlength="50"><br>
Перенос в конце(абзац):<br><input type="radio" name="br" value="Yes" checked>Да<br>
<input type="radio" name="br" value="No">Нет<br>
<input type="hidden" name="type" value"image"><input type="submit" name="submit" value="Добавить"></form>';
break;
default:
echo 'Запрос не понятный!<br>';
echo '<a href="mainadmin.php">Назад в админку</a>';
break;
}}
if (isset($_POST['submit']))
{
switch ($_POST['type'])
{ case "text":
$text=trim($_POST['text']);
if ($_POST['br'] == 'Yes')
$text=$text.'<br>';
$fp=fopen('reklama.php','a') or die('Ошибка записи! Дайте папке atmer chmod 777!');
fwrite ($fp, $text);
fclose($fp);
echo '<a href="mainadmin.php">В админ-панель</a>';
break;
case "href":
$href=trim($_POST['href']);
$name=htmlspecialchars(trim($_POST['name']));
$text='<a href="'.$href.'">'.$name.'</a>';
if ($_POST['br'] == 'Yes')
$text=$text.'<br>';
$fp=fopen('reklama.php','a') or die('Ошибка записи! Дайте папке atmer chmod 777!');
fwrite ($fp, $text);
fclose($fp);
echo '<a href="mainadmin.php">В админ-панель</a>';
break;
case "image":
$href=trim($_POST['href']);
$image=trim($_POST['name']);
$text='<a href="'.$href.'"><img src="'.$image.'" alt="reklama"></a>';
if ($_POST['br'] == 'Yes')
$text=$text.'<br>';
$fp=fopen('reklama.php','a') or die('Ошибка записи! Дайте папке atmer chmod 777!');
fwrite ($fp, $text);
fclose($fp);
echo '<a href="mainadmin.php">В админ-панель</a>';
break;
default:
echo 'Ошибка! Модуля не существует!';
break;
}}
?></body></html>