Merge pull request #5171 from annando/removed-deprecated-upload

Removed some quick and dirty hack to upload pictures
This commit is contained in:
Tobias Diekershoff 2018-06-05 09:26:05 +02:00 committed by GitHub
commit 4cd730ea16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 42 deletions

View File

@ -1066,7 +1066,7 @@ function requestdata($k)
}
/**
* Waitman Gobble Mod
* Deprecated function to upload media.
*
* @param string $type Return type (atom, rss, xml, json)
*
@ -1100,12 +1100,10 @@ function api_statuses_mediap($type)
$a->argv[1] = $user_info['screen_name']; //should be set to username?
// tell wall_upload function to return img info instead of echo
$_REQUEST['hush'] = 'yeah';
$bebop = wall_upload_post($a);
$picture = wall_upload_post($a, false);
// now that we have the img url in bbcode we can add it to the status and insert the wall item.
$_REQUEST['body'] = $txt . "\n\n" . $bebop;
$_REQUEST['body'] = $txt . "\n\n" . '[url=' . $picture["albumpage"] . '][img]' . $picture["preview"] . "[/img][/url]";
item_post($a);
// this should output the last post (the one we just posted).
@ -1254,10 +1252,9 @@ function api_statuses_update($type)
if (x($_FILES, 'media')) {
// upload the image if we have one
$_REQUEST['hush'] = 'yeah'; //tell wall_upload function to return img info instead of echo
$media = wall_upload_post($a);
if (strlen($media) > 0) {
$_REQUEST['body'] .= "\n\n" . $media;
$picture = wall_upload_post($a, false);
if (is_array($picture)) {
$_REQUEST['body'] .= "\n\n" . '[url=' . $picture["albumpage"] . '][img]' . $picture["preview"] . "[/img][/url]";
}
}

View File

@ -16,8 +16,8 @@ use Friendica\Database\DBM;
use Friendica\Model\Photo;
use Friendica\Object\Image;
function wall_upload_post(App $a, $desktopmode = true) {
function wall_upload_post(App $a, $desktopmode = true)
{
logger("wall upload: starting new upload", LOGGER_DEBUG);
$r_json = (x($_GET, 'response') && $_GET['response'] == 'json');
@ -291,25 +291,18 @@ function wall_upload_post(App $a, $desktopmode = true) {
echo json_encode(['picture' => $picture]);
killme();
}
logger("upload done", LOGGER_DEBUG);
return $picture;
}
logger("upload done", LOGGER_DEBUG);
if ($r_json) {
echo json_encode(['ok' => true]);
killme();
}
/* mod Waitman Gobble NO WARRANTY */
// if we get the signal then return the image url info in BBCODE
if ($_REQUEST['hush']!='yeah') {
echo "\n\n" . '[url=' . System::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . System::baseUrl() . "/photo/{$hash}-{$smallest}.".$Image->getExt()."[/img][/url]\n\n";
} else {
$m = '[url='.System::baseUrl().'/photos/'.$page_owner_nick.'/image/'.$hash.'][img]'.System::baseUrl()."/photo/{$hash}-{$smallest}.".$Image->getExt()."[/img][/url]";
return($m);
}
/* mod Waitman Gobble NO WARRANTY */
killme();
// NOTREACHED
}