<h3><?=MODIFYPOST_TITLE?></h3>
<br>
<?php
if (isset($bid) && $bid != '' && is_numeric($bid) && $bid > 0) {
if (isset($_POST['action']) && $_POST['action'] == MODIFYPOST_FORM_SUBMIT_VALUE) {
$title = $_POST['title'];
$code = $_POST['code'];
$body = $_POST['body'];
$publish = $_POST['publish']; //checkpox
$isPublish = 1;
if (isset($publish)) {
$isPublish = 1;
} else {
$isPublish = 0;
}
$query = "update ".TABPREFIX."blog set code='".addslashes($code)."',";
$query .= "title='".addslashes($title)."',";
$query .= "body='".addslashes($body)."',";
$query .= "last_modify=NOW(),";
$query .= "published=".$isPublish;
$query .= " where id=".$bid;
$result = $db->query($query);
$msg = "";
if ($result->sizeIDU() != -1) {
$msg = MODIFYPOST_OK;
} else {
$msg = MODIFYPOST_ERROR;
}
?>
<center>
<?=$msg?>
<a href="home.php?id=blog&action=manage&type=e" class="back">[ Continue ]</a>
</center>
<?php
} else {
$query = $db->query("select * from ".TABPREFIX."blog where id=".$bid);
$row = $query->fetch();
$isPublshed = "";
if ($row['published'] == 1) {
$isPublshed = 'checked="checked"';
}
?>
<script type="text/javascript">
function changeTest(form) {
var s = document.getElementById('title').value;
//replace all special chars
s = s.replace(/[^0-9a-zA-Z]+/g, "_");
document.getElementById('code').value = s.toLowerCase();
}
</script>
<form action="home.php?id=blog&action=modify&bid=<?=$bid?>" method="post" name="form_blog" id="form_blog">
<input type="hidden" id="idpost" name="idpost" value="<?=$bid?>">
<fieldset>
<div>
<label><?=MODIFYPOST_FORM_PUBLISH?></label>
<input type="checkbox"" id="idpublish" name="publish" <?=$isPublshed?>>
</div>
<div>
<label><?=MODIFYPOST_FORM_TITLE?></label>
<input type="text" id="title" name="title" size="40" value="<?=$row['title']?>" onkeyup="changeTest(this)">
</div>
<div>
<label><?=MODIFYPOST_FORM_ID?></label>
<input type="text" id="code" name="code" size="40" value="<?=$row['code']?>">
</div>
<div>
<label><?=MODIFYPOST_FORM_TEXT?></label>
<textarea rows="20" class="tinymce" name="body"><?=$row['body']?></textarea>
</div>
<div style="text-align: center;">
<input type="submit" name="action" value="<?=MODIFYPOST_FORM_SUBMIT_VALUE?>">
</div>
</fieldset>
</form>
<br>
<center>
<a href="javascript:history.back()" class="back"><?=MODIFYPOST_LINK_BACK?></a>
</center>
<?php
}
}
?>