Пример #1
0
 if (!$D->error && empty($D->message)) {
     $D->error = TRUE;
     $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) {
Пример #2
0
     if (empty($message)) {
         continue;
     }
     $p = null;
     $p = new newpost();
     $p->set_api_id(2);
     $tmpu = $network->get_user_by_id($obj->user_id);
     $tmpu->info = $tmpu;
     $tmpu->is_logged = TRUE;
     $p->set_user_advanced($network, $tmpu);
     $p->set_message($message);
     if (!empty($item->source_url)) {
         $p->attach_link($item->source_url);
     }
     if (!empty($item->source_image)) {
         $p->attach_image($item->source_image);
     }
     if (!empty($item->source_video)) {
         $p->attach_videoembed($item->source_video);
     }
     if (!empty($item->source_description) && $item->source_description != $message) {
         $p->attach_richtext($item->source_description);
     }
     if ($pid = $p->save()) {
         $pid = intval(str_replace(array('_private', '_public'), '', $pid));
         $db2->query('INSERT INTO users_rssfeeds_posts SET rssfeed_id="' . $obj->id . '", post_id="' . $pid . '" ');
         $new_rss_posts++;
         $posts++;
     }
 }
 if ($posts > 0) {
Пример #3
0
 private function item_validate_attachments($item)
 {
     if (!empty($item->source_image)) {
         $p = new newpost();
         if (!($a = $p->attach_image($item->source_image))) {
             $item->source_image = '';
         } elseif ($a->size_original[0] < 100 || $a->size_original[1] < 100) {
             $item->source_image = '';
         }
     }
     if (!empty($item->source_video)) {
         $p = new newpost();
         if (!($a = $p->attach_videoembed($item->source_video))) {
             $item->source_video = '';
         }
     }
     return $item;
 }
Пример #4
0
 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 {
             echo generate_error($api_session->format, 'Invalid image file.', $_SERVER['REQUEST_URI'], $api_session->callback);
         }
         exit;
     }
 }
 $ok = $newpost->save();
 if (!$ok) {
     if (!isset($_POST['suppress_response_codes'])) {
         header('HTTP/1.1 500 Internal Server Error');
     } else {
         echo generate_error($api_session->format, 'Server error (Stage 1).', $_SERVER['REQUEST_URI'], $api_session->callback);
     }