Файл: wall/edit_post.php
Строк: 75
<?php
require_once '../incfiles/core.php';
require_once '../incfiles/func.php';
require_once '../incfiles/auth.php';
require_once '../incfiles/user.php';
if (empty($user_id)) go(URL);
if (!empty($_GET['id']) && is_numeric($_GET['id']))
{
$id = abs(intval($_GET['id']));
$result = mysql_query("SELECT * FROM `wall` WHERE `id` = '".$id."' AND `user_id` = '".$user_id."' LIMIT 1");
if (mysql_num_rows($result) == true)
{
$arr_post = mysql_fetch_array($result);
if ($arr_post['type'] == 'update_avatar') go(URL.'/avatars/preview.php?fname='.$arr_post['photos']);
}
else go(URL);
$arr_user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '".$arr_post['wall_id']."' LIMIT 1"));
if ($arr_user['ban'] == 1) exit;
}
else go(URL);
$title = lang('Редактирование записи','Редагування запису');
require_once '../incfiles/head.php';
require_once 'handler/edit_post.php';
?>
<script type="text/javascript">
$(function(){
$('#form').on('submit', function(e){
e.preventDefault();
var $that = $(this),
formData = new FormData($that.get(0));
$.ajax({
url: $that.attr('action'),
type: $that.attr('method'),
contentType: false,
processData: false,
data: formData,
success: function(response){
if(response){
Page.Go('<?echo URL.'/wall/post.php?id='.$id;?>');
}
}
});
});
});
</script>
<?
echo '<div class="title">'.$title.'</div>
<div class="block2">
<form id="form" method="post" action="'.URL.'/wall/edit_post.php?id='.$id.'">
<textarea id="textarea" class="input" name="text" rows="4">'.no_tags($arr_post['text']).'</textarea>
<p><div id="cache_photos">';
if (!empty($arr_post['photos']))
{
$q = explode("||", substr($arr_post['photos'], 1, -1));
$count = count($q);
for ($i = 0; $i < $count; $i++)
{
echo '<a id="'.($i+1).'" class="del_cache" href="'.URL.'/wall/edit_post.php?id='.$id.'&del_photo='.$q[$i].'" onclick="FormContent.DelCache(this.id,this.href); return false">'.(file_exists(HOME .'/files/wall/'.$user_id.'/photos/'.$q[$i])?'<img class="preview_icons" src="'.URL.'/files/wall/'.$user_id.'/photos/icons/'.$q[$i].'"/>':'<img style="width:50px;" class="preview_icons" src="'.URL.'/design/img/image_not_found.png"/>').'</a>';
}
}
echo '</div></p>';
if (!empty($arr_post['audio']))
{
$q = explode("||", substr($arr_post['audio'], 1, -1));
$count = count($q);
for ($i = 0; $i < $count; $i++)
{
echo '<div id="'.($i+1).'"><p>';
echo track($q[$i]);
echo ' <a id="'.($i+1).'" href="'.URL.'/wall/edit_post.php?id='.$id.'&del_audio='.$q[$i].'" onclick="FormContent.DelCache(this.id,this.href); return false"> <img src="'.URL.'/design/img/closed.png"/></a>
</p></div>';
}
}
echo '<input class="button2" type="submit" value="'.lang('Сохранить','Зберегти').'"/>
<a class="button3" href="'.URL.'/ajax/smiles.php" onclick="FormContent.Smiles(this.href); return false"><img src="'.URL.'/design/img/smile.png"/></a>
</form>
</div>
<div id="form_content"></div>';
require_once '../incfiles/foot.php';
?>