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

Размер файла: 4.4Kb
<?php
require('includes/header.php');
require('includes/utils.php');
require('includes/db.php');
require('includes/auth.php');

$message = '';

if((isset($_GET['page']) && preg_match('/[^\w\.]/', $_GET['page'])))
{
?>
<wml>
<card id="error" title="error" ontimer="main.php?id=<?php echo $id; ?>&amp;p=<?php echo $login; ?>"><timer value="15"/>
<p align="center">
Неправильное имя страницы
</p>
</card>
</wml>
<?php
   exit;
}

if(isset($_GET['ask']) && $_GET['ask'] == 'del')
{

   $contents = file("$login/" . addslashes($_GET['page']));
   preg_match_all('/<do type=\"(.*?)\" label=\"(.*?)\">(.*?)<\/do>/i', $contents[4], $res);
   $labels = $res[2];
   $urls = $res[3];
   $contents[4] = ''; // строка с кнопками
   for($i = 0; $i < count($labels); $i++)
   {
      if(($i+1) != $_POST['sk'])
         $contents[4] .= ' <do type="options" name="b' . rand(100, 10000) . '" label="' . $labels[$i] . '">' . $urls[$i] . '</do>';
   }
   $contents[4] .= "\n";
   $fp = fopen("$login/" . addslashes($_GET['page']), 'wb');
   fputs($fp, join('', $contents));
   fclose($fp);
}

if(isset($_POST['ask']))
{
   $contents = file("$login/" . addslashes($_GET['page']));
   preg_match_all('/<do type=\"(.*?)\" label=\"(.*?)\">(.*?)<\/do>/i', $contents[4], $res);
   $labels = $res[2];
   $urls = $res[3];
   $contents[4] = ''; // строка с кнопками
   if($_POST['ask'] == 'addab')
     $contents[4] .= ' <do type="options" name="b' . rand(100, 1000) . '" label="' . $_POST['text'] . '"><go href="' . $_POST['link'] . '"/></do>';
   for($i = 0; $i < count($labels); $i++)
   {
      if(($i+1) == $_POST['sk'] && $_POST['ask'] == 'rew')
        $contents[4] .= ' <do type="options" name="b' . rand(100, 1000) . '" label="' . $_POST['text'] . '"><go href="' . $_POST['link'] . '"/></do>';
      else
        $contents[4] .= ' <do type="options" label="' . $labels[$i] . '">' . $urls[$i] . '</do>';
   }
   if($_POST['ask'] == 'addbel')
     $contents[4] .= ' <do type="options" name="b' . rand(100, 1000) . '" label="' . $_POST['text'] . '"><go href="' . $_POST['link'] . '"/></do>';

   $contents[4] .= "\n";
   $fp = fopen("$login/" . addslashes($_GET['page']), 'wb');
   fputs($fp, join('', $contents));
   fclose($fp);
}

$contents = file("$login/" . addslashes($_GET['page']));
$contents = $contents[4];
preg_match_all('/<do type=\"(.*?)\" label=\"(.*?)\">(.*?)<\/do>/i', $contents, $res);
$labels = $res[2];
$urls = $res[3];

?>
<wml>
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>
<card id="buttons" title="Co&#x0444;&#x0442;-&#x043A;&#x043B;a&#x0432;&#x0438;&#x0448;&#x044B;">
<p>
<?php echo $message; ?>
Co&#x0444;&#x0442;-&#x043A;&#x043B;a&#x0432;&#x0438;&#x0448;a:<br/>
<select name="sk">
<?php
for($i = 0; $i < count($labels); $i++)
   echo '<option value="' . ($i+1) . '">' . $labels[$i] . '</option>' . "\n";
?>
</select><br/>
<anchor title="go">&#x0423;&#x0434;a&#x043B;&#x0438;&#x0442;&#x044C;<go href="buttons.php?id=<?php echo $id; ?>&amp;p=<?php echo $login; ?>&amp;page=<?php echo $_GET['page']; ?>&amp;ask=del" method="post">
<postfield name="sk" value="$(sk)"/>
</go></anchor><br/>
<b>&#x0418;&#x043B;&#x0438;:</b><br/>
Ha&#x0437;&#x0432;a&#x043D;&#x0438;e:<br/>
<input name="text" emptyok="true" maxlength="25" title="text"/><br/>
URL:<br/>
<input name="link" emptyok="true" maxlength="150" value="http://" title="link"/><br/>
<select name="ask">
<option value="addab">&#x0414;o&#x0431;a&#x0432;&#x0438;&#x0442;&#x044C; &#x0432;&#x044B;&#x0448;e</option>
<option value="addbel">&#x0414;o&#x0431;a&#x0432;&#x0438;&#x0442;&#x044C; &#x043D;&#x0438;&#x0436;e</option>
<option value="rew">&#x041F;epe&#x0437;a&#x043F;&#x0438;ca&#x0442;&#x044C;</option>
</select><br/>
<anchor title="go">Ok<go href="buttons.php?id=<?php echo $id; ?>&amp;p=<?php echo $login; ?>&amp;page=<?php echo $_GET['page']; ?>&amp;ask=rew" method="post">
<postfield name="sk" value="$(sk)"/>
<postfield name="ask" value="$(ask)"/>
<postfield name="text" value="$(text)"/>
<postfield name="link" value="$(link)"/>
</go></anchor><br/>
*********<br/>
<a href="edit.php?id=<?php echo $id; ?>&amp;p=<?php echo $login; ?>&amp;page=<?php echo $_GET['page']; ?>">Pe&#x0434;a&#x043A;&#x0442;op</a><br/>
*********<br/>
&#x0438;&#x043C;&#x044F;:<?php echo $_GET['page']; ?>, Pa&#x0437;&#x043C;ep:<?php echo filesize($login . '/' . $_GET['page']); ?> byte
</p>
</card>
</wml>