<?php
include_once('./_common.php');

if (!$is_member) die('0');

$uid     = amina_trim($_REQUEST['uid']);
$subject = amina_trim(stripslashes($_REQUEST['subject']));
$content = amina_trim(stripslashes($_REQUEST['content']));

if ($subject && $content) {
    $sql = " select count(*) as cnt from {$g4['autosave_table']} where mb_id = '{$member['mb_id']}' and as_subject = '$subject' and as_content = '$content' ";
    $row = sql_fetch($sql);
    if (!$row['cnt']) {
        $sql = " insert into {$g4['autosave_table']} set mb_id = '{$member['mb_id']}', as_uid = '{$uid}', as_subject = '$subject', as_content = '$content', as_datetime = '".G4_TIME_YMDHIS."' on duplicate key update as_subject = '$subject', as_content = '$content', as_datetime = '".G4_TIME_YMDHIS."' ";
        $result = sql_query($sql, false);

        echo autosave_count($member['mb_id']);
    }
}
?>