Пример #1
0
     $D->errmsg = 'newpost_err_emptymsg';
 }
 if (isset($_FILES['attach']) && is_uploaded_file($_FILES['attach']['tmp_name']) && ($C->ATTACH_IMAGE_DISABLED == 0 || $C->ATTACH_FILE_DISABLED == 0)) {
     $file = (object) $_FILES['attach'];
     $is_image = FALSE;
     $info = @getimagesize($file->tmp_name);
     if ($info && is_array($info)) {
         if ($info[2] == IMAGETYPE_GIF || $info[2] == IMAGETYPE_JPEG || $info[2] == IMAGETYPE_PNG) {
             $is_image = TRUE;
         }
     }
     $attach_res = FALSE;
     if ($is_image && $C->ATTACH_IMAGE_DISABLED == 0) {
         $attach_res = $p->attach_image($file->tmp_name, $file->name);
     } elseif ($C->ATTACH_FILE_DISABLED == 0) {
         $attach_res = $p->attach_file($file->tmp_name, $file->name);
     }
     if (!$attach_res) {
         $D->error = TRUE;
         $D->errmsg = 'newpost_err_attach';
     }
 }
 if (!$D->error) {
     if (!$p->save()) {
         $D->error = TRUE;
         $D->errmsg = 'newpost_err_system';
     }
 }
 if (!$D->error) {
     $this->redirect('newpost/okmsg:' . ($to_user ? 'sent' : 'posted'));
 }
Пример #2
0
     }
 }
 if (isset($_POST['video']) && !empty($_POST['video'])) {
     if (!$newpost->attach_videoembed(urldecode($_REQUEST['video']))) {
         if (!isset($_POST['suppress_response_codes'])) {
             header('HTTP/1.1 403 Forbidden');
         } else {
             echo generate_error($api_session->format, 'Invalid video link.', $_SERVER['REQUEST_URI'], $api_session->callback);
         }
         exit;
     }
 }
 if (isset($_POST['file']) && !empty($_POST['file']) && isset($_POST['file_type']) && !empty($_POST['file_type'])) {
     $tmp = $C->TMP_DIR . 'tmp_' . md5(time() . rand(0, 9999));
     $fl = file_put_contents($tmp, base64_decode($_POST['file']));
     if (!$newpost->attach_file($tmp, $fl . '.' . $_POST['file_type'])) {
         if (!isset($_POST['suppress_response_codes'])) {
             header('HTTP/1.1 403 Forbidden');
         } else {
             echo generate_error($api_session->format, 'Invalid file.', $_SERVER['REQUEST_URI'], $api_session->callback);
         }
         exit;
     }
 }
 if (isset($_POST['image']) && !empty($_POST['image'])) {
     $fl = $C->TMP_DIR . 'tmp_' . md5(time() . rand(0, 9999));
     file_put_contents($fl, base64_decode($_POST['image']));
     if (!$newpost->attach_image($fl)) {
         if (!isset($_POST['suppress_response_codes'])) {
             header('HTTP/1.1 403 Forbidden');
         } else {