<?php
require_once('functions.php');
is_login();
csrf_attemp();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../style.css">
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>Scriobai / Edit Post</title>
<style type="text/css">
<!--
table
{
border-collapse:collapse;
}
table,th, td
{
border: 1px solid black;
}
-->
</style>
</head>
<body>
<table bgcolor="#f57900" width="100%">
<tbody>
<tr>
<td>
<div align="left"><a href="manage.php" style="text-decoration: none;"><img style="width: 34px; height: 33px;" border="0" src="img_functions/arrow_left.png" alt="<==="></a></div>
</td>
<td>
<div align="center"><font color="#4b4b4b"><?php $time = date("H:i:s"); $date = date("d/m/Y"); echo "<b>Today</b>: $date <b>time</b>: $time"; ?></font></div>
</td>
<td>
<div align="right"><img style="width: 34px; height: 33px;" src="../img/yacumana.png" alt="../img/yacumana.png"></div>
</td>
</tr>
</tbody>
</table>
<br>
<div style="background-color: rgb(51, 0, 204);">
<table width="100%">
<tbody>
<tr>
<td>
<img src="img_functions/text_edit.png"> <font color="white"><big>Edit a post</big></font>
</td>
</tr>
<tr>
<td>
<?php
$db = "../db/*.html";
$path_1 = glob( $db );
if ( $path_1 != 0 ) {
$path = "../db/";
$dir_handle = @opendir($path) or die("Can't open the directory $path");
echo "<font color=\"white\">Watch the files post in the db <font color=\"red\"><b>$path</b></font></font><br />";
while ( $file = readdir( $dir_handle ) ) {
if( $file!="." && $file!=".." )
echo "<br><a href='$path$file' target=\"_blank\">$file</a> <font color=\"yellow\">-</font> ";
$post_content = file_get_contents("../db/$file");
if (preg_match("/style=\"text-decoration: none\">(.*?)<\/a><\/h1>/", $post_content, $out))
{
echo '<font color="red"><b>'.$out[1].'</b></font><br>';
}
}
closedir( $dir_handle );
}
elseif ( $path_1 == 0 )
{
echo "<font color=\"red\">no post in the <b>/db/</b> before delete a post, you must create a post...</font>";
}
?>
</td>
</tr>
<tr>
<td>
<br>
<form method="post" action="edit.php"><font color="white">Insert the number of post: <b>(Only numbers)</b> <input size="20" name="numid" type="text">.html/php</font><br>
<br>
<?php echo "<input name='sid' type='hidden' value='$_COOKIE[sid]'>"; ?>
<input value="Edit" type="submit"><br>
<br>
</form>
</td>
</tr>
<tr>
<td>
<?php
include('config.php');
$num = htmlspecialchars(str_replace(".", "_", $_POST['numid']));
if ( !empty( $_POST['numid'] ) ) {
if (!( file_exists('../db/'.$num.'.html') )) {
echo "<font color=\"red\"><b>The post doesn't exists!</b></font>";
} else {
$page_content = file_get_contents('../db/'.$num.'.html');
$content = parser($page_content);
$replacements[0] = "<img alt=':)' src='".$website."emotion/0.gif'>";
$replacements[1] = "<img alt=':D' src='".$website."emotion/01.gif'>";
$replacements[2] = "<img alt=';)' src='".$website."emotion/02.gif'>";
$replacements[3] = "<img alt='lol' src='".$website."emotion/03.gif'>";
$replacements[4] = "<img alt=':S' src='".$website."emotion/04.gif'>";
$replacements[5] = "<img alt='lool' src='".$website."emotion/05.gif'>";
$replacements[6] = "<img alt='8)' src='".$website."emotion/06.gif'>";
$replacements[7] = "<img alt=':(' src='".$website."emotion/07.gif'>";
$replacements[8] = "<img alt='O.O' src='".$website."emotion/08.gif'>";
$replacements[9] = "<img alt=':@' src='".$website."emotion/09.gif'>";
$replacements[10] = "<img alt='(!)' src='".$website."emotion/10.gif'>";
$replacements[11] = "<img alt='(?)' src='".$website."emotion/11.gif'>";
$replacements[12] = "<img alt=':P' src='".$website."emotion/12.gif'>";
$replacements[13] = "<img alt=':°(' src='".$website."emotion/13.gif'>";
$replacements[14] = "<img alt=':O' src='".$website."emotion/14.gif'>";
$replacements[15] = "<img alt='asd' src='".$website."emotion/15.gif'>";
$replacements[16] = "<img alt='xD' src='".$website."emotion/16.gif'>";
$replacements[17] = "<img alt='bye' src='".$website."emotion/17.gif'>";
$replacements[18] = "<img alt='boh!' src='".$website."emotion/18.gif'>";
$replacements[19] = "<br />";
$replacements[20] = "<code>";
$replacements[21] = "</code>";
$replacements[22] = "<code>";
$patterns[0] = ":)";
$patterns[1] = ":D";
$patterns[2] = ";)";
$patterns[3] = ":lol:";
$patterns[4] = ":S";
$patterns[5] = ":lool:";
$patterns[6] = "8)";
$patterns[7] = ":(";
$patterns[8] = "O.O";
$patterns[9] = ":@";
$patterns[10] = "(!)";
$patterns[11] = "(?)";
$patterns[12] = ":P";
$patterns[13] = ":°(";
$patterns[14] = ":O";
$patterns[15] = ":asd:";
$patterns[16] = "xD";
$patterns[17] = ":bye:";
$patterns[18] = ":boh:";
$patterns[19] = "[br]";
$patterns[20] = "<?php";
$patterns[21] = "?>";
$patterns[22] = "<?";
$content[1] = str_replace($replacements,$patterns,$content[1]);
$replace = array(
'/<b>(.*?)<\/b>/',
'/<i>(.*?)<\/i>/',
'/<img border="0" src="(.*?)" alt="(.*?)" \/>/',
'/<a target="_blank" href="(.*?)">(.*?)<\/a>/',
'/<a target="_blank" href="(.*?)">(.*?)<\/a>/',
'/<font color="#FF0000">(.*?)<\/font>/',
'/<font color="#FFFF00">(.*?)<\/font>/',
'/<font color="#0000FF">(.*?)<\/font>/',
'/<font color="#00FF00">(.*?)<\/font>/',
'/<font color="#000000">(.*?)<\/font>/',
'/<big>(.*?)<\/big>/',
'/<small>(.*?)<\/small>/',
'/<code>(.*?)<\/code>/',
'/<blockquote>(.*?)<\/blockquote>/',
);
$search = array(
'[b]$1[/b]',
'[i]$1[/i]',
'[img]$1[/img]',
'[url=$1]$2[/url]',
'[url]$1[/url]',
'[red]$1[/red]',
'[yellow]$1[/yellow]',
'[blue]$1[/blue]',
'[green]$1[/green]',
'[black]$1[/black]',
'[big]$1[/big]',
'[small]$1[/small]',
'[code]$1[/code]',
'[quote]$1[/quote]',
);
$content[1] = preg_replace($replace,$search,$content[1]);
echo "<form method=\"POST\" action=\"edit_act.php?id=$num\">";
echo "<font color=\"white\">Modify the post number</font> <font color=\"red\">$num</font><br>";
echo "<font color=\"yellow\"><i>(Compile the forms below)</i></font><br /><br />";
echo "<input name='sid' type='hidden' value='$_COOKIE[sid]'>";
echo "<font color=\"yellow\">Title</font><br />";
echo "<input type=\"text\" name=\"title\" id=\"title\" value=\"$content[0]\"><br />";
echo "<font color=\"yellow\">Body</font><br />";
echo "<textarea rows=\"10\" cols=\"70\" name=\"body\" id=\"body\">$content[1]</textarea><br /><br />";
echo "<font color=\"red\"><b>what would you to do? </b></font>
<select name=\"choice\">
<option value=\"0\"></option>
<option value=\"1\">Post</option>
<option value=\"2\">Preview</option>
</select><br /><br />";
echo "<input type=\"submit\" value=\"Confirms\"><br />";
echo "</form>";
}
}
?>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<div align="center"><font color="yellow"><i>Scriobai CMS is Free software under the GNU/GPL license</i></font></div>
<br>
</body>
</html>