Пример #1
0
$s =& $this->user->sess;
if (!isset($s['POSTFORM_TEMP_POSTS'])) {
    $s['POSTFORM_TEMP_POSTS'] = array();
}
if (!isset($s['POSTFORM_TEMP_POSTS'][$post_temp_id])) {
    $s['POSTFORM_TEMP_POSTS'][$post_temp_id] = new newpost();
}
$post_temp =& $s['POSTFORM_TEMP_POSTS'][$post_temp_id];
$post_edit = isset($_POST['editpost']) ? trim($_POST['editpost']) : FALSE;
if ($post_edit) {
    if (!preg_match('/^(public|private)_([0-9]+)$/', $post_edit, $m)) {
        echo '<result></result>';
        exit;
    }
    $p = new newpost();
    if (!$p->load_post($m[1], $m[2])) {
        echo '<result><status>ERROR</status><message>' . $this->lang('pf_msgerr_sys') . '</message></result>';
        exit;
    }
    $p->set_message($post_message);
    $a = $p->get_attached();
    $all = array('link', 'image', 'file', 'videoembed');
    foreach ($all as $type) {
        if (isset($_POST['at_' . $type]) && $_POST['at_' . $type] == "-1") {
            $tmp = $post_temp->get_attached();
            $a[$type] = $tmp[$type];
        } elseif (isset($_POST['at_' . $type], $a[$type]) && $_POST['at_' . $type] == $a[$type]->attachment_id) {
        } else {
            if (isset($a[$type])) {
                unset($a[$type]);
            }