File size: 11.46Kb
<?php
require('includes/header.php');
require('includes/utils.php');
require('includes/db.php');
require('includes/auth.php');
if(isset($_POST['action']))
{
$banners = mysql_query('SELECT banner FROM users WHERE login = "' . $login . '"');
list($banner) = mysql_fetch_array($banners);
if(preg_match('/[^\w\.]/', $_GET['page']))
{
?>
<wml>
<card id="error" title="error" ontimer="main.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>"><timer value="15"/>
<p align="center">
Неправильное имя страницы
</p>
</card>
</wml>
<?php
exit;
}
$contents = file("$login/" . addslashes($_GET['page']));
for($i = 0; $i < count($contents); $i++)
{
if($banner == 'top' && $i == 6)
{
}
else
{
$contents2[] = $contents[$i];
}
if(trim($contents[$i]) == '<p align="center">' || trim($contents[$i]) == '<p align="left">' || trim($contents[$i]) == '<p align="right">')
{
if($banner == 'top')
$contents2[] = get_random_link();
}
if((isset($contents[$i+1]) && trim($contents[$i+1]) == '</p>') || (isset($contents[$i+2]) && trim($contents[$i+2]) == '</card>'))
{
if($banner == 'bottom')
{
array_pop($contents2);
$contents2[] = get_random_link();
}
}
if($i == $_GET['i'])
{
if($i == 5 && $_POST['location'] == 'rewrite' && $_POST['action'] != 'left' && $_POST['action'] != 'center' && $_POST['action'] != 'right')
{
?>
<wml>
<card id="added" title="added" ontimer="edit.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>&page=<?php echo $_GET['page']; ?>"><timer value="15"/>
<p>
В этой строке Вы можете использовать только выравнивание текста<br/>
</p>
</card>
</wml>
<?php
exit;
}
$_POST['text'] = str_replace('&', '&', $_POST['text']);
$_POST['text'] = str_replace('$', '$$', $_POST['text']);
if($_POST['strip'] == 'yes')
$_POST['text'] = strip_tags($_POST['text']);
if($_POST['text'] == '' && ($_POST['action'] != 'left' && $_POST['action'] != 'center' && $_POST['action'] != 'right'))
{
?>
<wml>
<card id="added" title="added" ontimer="edit.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>&page=<?php echo $_GET['page']; ?>"><timer value="15"/>
<p>
Вы не ввели текст<br/>
</p>
</card>
</wml>
<?php
exit;
}
switch($_POST['action'])
{
case 'link':
$new_line = '<a href="' . $_POST['link'] . '">' . $_POST['text'] . "</a>\n";
break;
case 'linkb':
$new_line = '<b><a href="' . $_POST['link'] . '">' . $_POST['text'] . "</a></b>\n";
break;
case 'linki':
$new_line = '<i><a href="' . $_POST['link'] . '">' . $_POST['text'] . "</a></i>\n";
break;
case 'links':
$new_line = '<small><a href="' . $_POST['link'] . '">' . $_POST['text'] . "</a></small>\n";
break;
case 'linku':
$new_line = '<u><a href="' . $_POST['link'] . '">' . $_POST['text'] . "</a></u>\n";
break;
case 'text':
$new_line = $_POST['text'] . "\n";
break;
case 'textb':
$new_line = '<b>' . $_POST['text'] . "</b>\n";
break;
case 'texti':
$new_line = '<i>' . $_POST['text'] . "</i>\n";
break;
case 'texts':
$new_line = '<small>' . $_POST['text'] . "</small>\n";
break;
case 'textu':
$new_line = '<u>' . $_POST['text'] . "</u>\n";
break;
case 'picture':
$new_line = '<img src="' . $_POST['picture'] . '" alt="' . $_POST['text'] . '"/>' . "\n";
break;
case 'urlpict':
$new_line = '<a href="' . $_POST['link'] . '"><img src="' . $_POST['picture'] . '" alt="' . $_POST['text'] . '"/></a>' . "\n";
break;
case 'br':
$new_line = '<br/>' . "\n";
break;
case 'left':
if($_GET['i'] == 5)
$new_line = '<p align="left">' . "\n";
else
$new_line = '</p><p align="left">' . "\n";
break;
case 'center':
if($_GET['i'] == 5)
$new_line = '<p align="center">' . "\n";
else
$new_line = '</p><p align="center">' . "\n";
break;
case 'right':
if($_GET['i'] == 5)
$new_line = '<p align="right">' . "\n";
else
$new_line = '</p><p align="right">' . "\n";
break;
default:
$new_line = '';
}
if($_POST['abr'] == 'yes')
$new_line .= "\n<br/>\n";
if($_POST['location'] == 'below')
{
// adding new line
$contents2[] = $new_line;
}
if($_POST['location'] == 'rewrite')
{
// adding new line
if($_GET['i'] == 5)
{
$adv_link = array_pop($contents2);
array_pop($contents2);
$contents2[] = $new_line;
//$contents2[] = $adv_link;
}
else
{
array_pop($contents2);
$contents2[] = $new_line;
}
}
if($_POST['location'] == 'above')
{
// adding new line
$curr_row = array_pop($contents2);
$contents2[] = $new_line;
array_push($contents2, $curr_row);
}
}
}
$fp = fopen("$login/" . addslashes($_GET['page']), 'wb');
fputs($fp, join('', $contents2));
fclose($fp);
?>
<wml>
<card id="added" title="added" ontimer="edit.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>&page=<?php echo $_GET['page']; ?>"><timer value="15"/>
<p>
Строка изменена<br/>
</p>
</card>
</wml>
<?php
exit;
}
if(!isset($_GET['page']))
$_GET['page'] = 'index.wml';
if(preg_match('/[^\w\.]/', $_GET['page']))
{
?>
<wml>
<card id="error" title="error" ontimer="main.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>"><timer value="15"/>
<p align="center">
Неправильное имя страницы
</p>
</card>
</wml>
<?php
exit;
}
if(isset($_GET['action']) && $_GET['action'] == 'del')
{
if($_GET['i'] != 5) // строка с первым <p align ...
{
$contents = file("$login/" . addslashes($_GET['page']));
$contents2 = array();
for($i = 0; $i < count($contents); $i++)
{
if($i != $_GET['i'])
$contents2[] = $contents[$i];
}
$fp = fopen("$login/" . addslashes($_GET['page']), 'w');
fputs($fp, join('', $contents2));
fclose($fp);
$message = 'Текст удален';
}
else
{
$message = 'Данную строку нельзя удалить';
}
?>
<wml>
<card id="added" title="added" ontimer="edit.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>&page=<?php echo $_GET['page']; ?>&"><timer value="15"/>
<p>
<?php echo $message; ?><br/>
</p>
</card>
</wml>
<?php
exit;
}
$contents = file("$login/" . addslashes($_GET['page']));
?>
<wml>
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>
<card id="Edit" title="Peдaктop">
<p>
<?php echo htmlspecialchars($contents[(int)$_GET['i']]);//echo htmlentities($contents[(int)$_GET['i']]); ?><br/>
<a href="edittext.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>&page=<?php echo $_GET['page']; ?>&i=<?php echo $_GET['i']; ?>&action=del">Удaлить</a><br/>
*********<br/>
<br/>
Teкcт:<br/>
<input name="text" emptyok="true" value="" title="text"/><br/>
URL:<br/>
<input name="link" emptyok="true" maxlength="150" value="http://" title="link"/><br/>
Кapтинкa:<br/>
<input name="picture" emptyok="true" maxlength="150" value="http://" title="picture"/><br/>
Coздaть кaк:<br/>
<select name="action">
<option value="link">Линк</option>
<option value="linkb">Жирный линк</option>
<option value="linki">Курсивный линк</option>
<option value="linku">Подчеркнутый линк</option>
<option value="links">Малый линк</option>
<option value="text">Teкcт</option>
<option value="textb">Жирный текст</option>
<option value="texti">РљСѓСЂСЃРёРІ</option>
<option value="textu">Подчеркнутый</option>
<option value="texts">Малый текст</option>
<option value="picture">Кapтинкa</option>
<option value="urlpict">Линк в кapтинкe</option>
<option value="br"><br/></option>
<option value="left">align=left</option>
<option value="center">align=center</option>
<option value="right">align=right</option>
</select><br/>
Aвтo<br/>:<br/>
<select name="abr">
<option value="yes">Дa</option>
<option value="no">Нeт</option>
</select><br/>
Pacпoлoжeниe:<br/>
<select name="location">
<option value="below">Hиже</option>
<option value="rewrite">Пepeзaпиcь</option>
<option value="above">Вышe</option>
</select><br/>
Резать теги:<br/>
<select name="strip">
<option value="yes">Да</option>
<option value="no">Нет</option>
</select><br/>
<anchor title="go">OK<go href="edittext.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>&page=<?php echo $_GET['page']; ?>&i=<?php echo $_GET['i']; ?>" method="post">
<postfield name="action" value="$(action)"/>
<postfield name="location" value="$(location)"/>
<postfield name="abr" value="$(abr)"/>
<postfield name="text" value="$(text)"/>
<postfield name="link" value="$(link)"/>
<postfield name="picture" value="$(picture)"/>
<postfield name="strip" value="$(strip)"/>
</go></anchor><br/>
<br/>
<a href="buttons.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>&page=<?php echo $_GET['page']; ?>">Coфт-клaвиши</a><br/>
<a href="edittitle.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>&page=<?php echo $_GET['page']; ?>&i=<?php echo $_GET['id']; ?>&cp=go">Coздaть cтpaницу или измeнить зaгoлoвoк</a><br/>
*********<br/>
<a href="edit.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>&page=<?php echo $_GET['page']; ?>">Ha cтpaницу</a><br/>
<a href="main.php?id=<?php echo $id; ?>&p=<?php echo $login; ?>">Меню</a><br/>
имя:<?php echo $_GET['page']; ?>, Paзмep:<?php echo filesize($login . '/' . $_GET['page']); ?> byte
</p>
</card>
</wml>