2011-05-25 05:40:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once('include/attach.php');
|
2014-02-21 01:07:43 +00:00
|
|
|
require_once('include/identity.php');
|
2015-03-16 22:33:08 +00:00
|
|
|
require_once('include/photos.php');
|
2011-05-25 05:40:52 +00:00
|
|
|
|
|
|
|
function wall_attach_post(&$a) {
|
|
|
|
|
2014-02-21 01:07:43 +00:00
|
|
|
if(argc() > 1)
|
|
|
|
$channel = get_channel_by_nick(argv(1));
|
2015-03-16 22:33:08 +00:00
|
|
|
elseif($_FILES['media']) {
|
|
|
|
require_once('include/api.php');
|
|
|
|
$user_info = api_get_user($a);
|
|
|
|
$nick = $user_info['screen_name'];
|
|
|
|
$channel = get_channel_by_nick($user_info['screen_name']);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(! $channel)
|
2013-01-23 03:36:14 +00:00
|
|
|
killme();
|
2011-05-25 05:40:52 +00:00
|
|
|
|
2015-03-16 22:33:08 +00:00
|
|
|
$observer = $a->get_observer();
|
|
|
|
|
|
|
|
|
|
|
|
if($_FILES['userfile']['tmp_name']) {
|
2015-03-16 22:50:45 +00:00
|
|
|
$x = @getimagesize($_FILES['userfile']['tmp_name']);
|
2015-04-19 00:40:44 +00:00
|
|
|
logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
|
2015-04-19 22:06:24 +00:00
|
|
|
if(($x) && ($x[2] === IMAGETYPE_GIF || $x[2] === IMAGETYPE_JPEG || $x[2] === IMAGETYPE_PNG)) {
|
2015-03-16 22:33:08 +00:00
|
|
|
$args = array( 'source' => 'editor', 'visible' => 0, 'contact_allow' => array($channel['channel_hash']));
|
|
|
|
$ret = photo_upload($channel,$observer,$args);
|
|
|
|
if($ret['success']) {
|
|
|
|
echo "\n\n" . $ret['body'] . "\n\n";
|
|
|
|
killme();
|
|
|
|
}
|
|
|
|
if($using_api)
|
|
|
|
return;
|
|
|
|
notice($ret['message']);
|
|
|
|
killme();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$r = attach_store($channel,(($observer) ? $observer['xchan_hash'] : ''));
|
2013-02-01 07:56:46 +00:00
|
|
|
|
2013-02-01 00:13:44 +00:00
|
|
|
if(! $r['success']) {
|
|
|
|
notice( $r['message'] . EOL);
|
2013-01-23 03:36:14 +00:00
|
|
|
killme();
|
2011-05-25 05:40:52 +00:00
|
|
|
}
|
|
|
|
|
2013-02-01 00:13:44 +00:00
|
|
|
echo "\n\n" . '[attachment]' . $r['data']['hash'] . ',' . $r['data']['revision'] . '[/attachment]' . "\n";
|
2011-05-25 05:40:52 +00:00
|
|
|
killme();
|
2013-02-01 00:13:44 +00:00
|
|
|
|
2011-05-25 05:40:52 +00:00
|
|
|
}
|