Merge pull request #1831 from annando/1508-twidere-crash
New versions of Twidere crashed during posting.
This commit is contained in:
commit
033f89c6fa
|
@ -9,6 +9,15 @@
|
|||
require_once("include/html2plain.php");
|
||||
require_once("mod/share.php");
|
||||
require_once("include/Photo.php");
|
||||
require_once("mod/item.php");
|
||||
require_once('include/security.php');
|
||||
require_once('include/contact_selectors.php');
|
||||
require_once('library/HTMLPurifier.auto.php');
|
||||
require_once('include/html2bbcode.php');
|
||||
require_once('mod/wall_upload.php');
|
||||
require_once("mod/proxy.php");
|
||||
require_once("include/message.php");
|
||||
|
||||
|
||||
/*
|
||||
* Twitter-Like API
|
||||
|
@ -151,7 +160,6 @@
|
|||
die('This api requires login');
|
||||
}
|
||||
|
||||
require_once('include/security.php');
|
||||
authenticate_success($record); $_SESSION["allow_api"] = true;
|
||||
|
||||
call_hooks('logged_in', $a->user);
|
||||
|
@ -185,7 +193,11 @@
|
|||
if (strpos($a->query_string, ".atom")>0) $type="atom";
|
||||
if (strpos($a->query_string, ".as")>0) $type="as";
|
||||
|
||||
$stamp = microtime(true);
|
||||
$r = call_user_func($info['func'], $a, $type);
|
||||
$duration = (float)(microtime(true)-$stamp);
|
||||
logger("API call duration: ".round($duration, 2)."\t".$a->query_string, LOGGER_DEBUG);
|
||||
|
||||
if ($r===false) return;
|
||||
|
||||
switch($type){
|
||||
|
@ -504,7 +516,6 @@
|
|||
$r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1", dbesc(normalise_link($uinfo[0]['url'])));
|
||||
}
|
||||
|
||||
require_once('include/contact_selectors.php');
|
||||
$network_name = network_to_name($uinfo[0]['network'], $uinfo[0]['url']);
|
||||
|
||||
$ret = Array(
|
||||
|
@ -686,9 +697,6 @@
|
|||
$txt = requestdata('status');
|
||||
//$txt = urldecode(requestdata('status'));
|
||||
|
||||
require_once('library/HTMLPurifier.auto.php');
|
||||
require_once('include/html2bbcode.php');
|
||||
|
||||
if((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
|
||||
$txt = html2bb_video($txt);
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
|
@ -701,12 +709,10 @@
|
|||
$a->argv[1]=$user_info['screen_name']; //should be set to username?
|
||||
|
||||
$_REQUEST['hush']='yeah'; //tell wall_upload function to return img info instead of echo
|
||||
require_once('mod/wall_upload.php');
|
||||
$bebop = wall_upload_post($a);
|
||||
|
||||
//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;
|
||||
require_once('mod/item.php');
|
||||
item_post($a);
|
||||
|
||||
// this should output the last post (the one we just posted).
|
||||
|
@ -729,9 +735,6 @@
|
|||
// logger('api_post: ' . print_r($_POST,true));
|
||||
|
||||
if(requestdata('htmlstatus')) {
|
||||
require_once('library/HTMLPurifier.auto.php');
|
||||
require_once('include/html2bbcode.php');
|
||||
|
||||
$txt = requestdata('htmlstatus');
|
||||
if((strpos($txt,'<') !== false) || (strpos($txt,'>') !== false)) {
|
||||
|
||||
|
@ -753,6 +756,11 @@
|
|||
$_REQUEST['title'] = requestdata('title');
|
||||
|
||||
$parent = requestdata('in_reply_to_status_id');
|
||||
|
||||
// Twidere sends "-1" if it is no reply ...
|
||||
if ($parent == -1)
|
||||
$parent = "";
|
||||
|
||||
if(ctype_digit($parent))
|
||||
$_REQUEST['parent'] = $parent;
|
||||
else
|
||||
|
@ -829,7 +837,6 @@
|
|||
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
|
||||
require_once('mod/wall_upload.php');
|
||||
$media = wall_upload_post($a);
|
||||
if(strlen($media)>0)
|
||||
$_REQUEST['body'] .= "\n\n".$media;
|
||||
|
@ -856,7 +863,6 @@
|
|||
|
||||
// call out normal post function
|
||||
|
||||
require_once('mod/item.php');
|
||||
item_post($a);
|
||||
|
||||
// this should output the last post (the one we just posted).
|
||||
|
@ -879,7 +885,6 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
require_once('mod/wall_upload.php');
|
||||
$media = wall_upload_post($a, false);
|
||||
if(!$media) {
|
||||
// Output error
|
||||
|
@ -1480,7 +1485,6 @@
|
|||
if (!x($_REQUEST, "source"))
|
||||
$_REQUEST["source"] = api_source();
|
||||
|
||||
require_once('mod/item.php');
|
||||
item_post($a);
|
||||
}
|
||||
|
||||
|
@ -1512,7 +1516,6 @@
|
|||
|
||||
$ret = api_statuses_show($a, $type);
|
||||
|
||||
require_once('include/items.php');
|
||||
drop_item($id, false);
|
||||
|
||||
return($ret);
|
||||
|
@ -1976,7 +1979,6 @@
|
|||
$include_entities = strtolower(x($_REQUEST,'include_entities')?$_REQUEST['include_entities']:"false");
|
||||
|
||||
if ($include_entities != "true") {
|
||||
require_once("mod/proxy.php");
|
||||
|
||||
preg_match_all("/\[img](.*?)\[\/img\]/ism", $bbcode, $images);
|
||||
|
||||
|
@ -2079,7 +2081,6 @@
|
|||
// If image cache is activated, then use the following sizes:
|
||||
// thumb (150), small (340), medium (600) and large (1024)
|
||||
if (!get_config("system", "proxy_disabled")) {
|
||||
require_once("mod/proxy.php");
|
||||
$media_url = proxy_url($url);
|
||||
|
||||
$sizes = array();
|
||||
|
@ -2471,8 +2472,6 @@
|
|||
|
||||
$sender = api_get_user($a);
|
||||
|
||||
require_once("include/message.php");
|
||||
|
||||
if ($_POST['screen_name']) {
|
||||
$r = q("SELECT `id`, `nurl`, `network` FROM `contact` WHERE `uid`=%d AND `nick`='%s'",
|
||||
intval(api_user()),
|
||||
|
|
61
mod/api.php
61
mod/api.php
|
@ -4,19 +4,19 @@ require_once('include/api.php');
|
|||
|
||||
function oauth_get_client($request){
|
||||
|
||||
|
||||
|
||||
$params = $request->get_parameters();
|
||||
$token = $params['oauth_token'];
|
||||
|
||||
$r = q("SELECT `clients`.*
|
||||
FROM `clients`, `tokens`
|
||||
WHERE `clients`.`client_id`=`tokens`.`client_id`
|
||||
|
||||
$r = q("SELECT `clients`.*
|
||||
FROM `clients`, `tokens`
|
||||
WHERE `clients`.`client_id`=`tokens`.`client_id`
|
||||
AND `tokens`.`id`='%s' AND `tokens`.`scope`='request'",
|
||||
dbesc($token));
|
||||
|
||||
if (!count($r))
|
||||
return null;
|
||||
|
||||
|
||||
return $r[0];
|
||||
}
|
||||
|
||||
|
@ -36,31 +36,31 @@ function api_post(&$a) {
|
|||
|
||||
function api_content(&$a) {
|
||||
if ($a->cmd=='api/oauth/authorize'){
|
||||
/*
|
||||
/*
|
||||
* api/oauth/authorize interact with the user. return a standard page
|
||||
*/
|
||||
|
||||
|
||||
$a->page['template'] = "minimal";
|
||||
|
||||
|
||||
|
||||
|
||||
// get consumer/client from request token
|
||||
try {
|
||||
$request = OAuthRequest::from_request();
|
||||
} catch(Exception $e) {
|
||||
echo "<pre>"; var_dump($e); killme();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (x($_POST,'oauth_yes')){
|
||||
|
||||
|
||||
$app = oauth_get_client($request);
|
||||
if (is_null($app)) return "Invalid request. Unknown token.";
|
||||
$consumer = new OAuthConsumer($app['client_id'], $app['pw'], $app['redirect_uri']);
|
||||
|
||||
$verifier = md5($app['secret'].local_user());
|
||||
set_config("oauth", $verifier, local_user());
|
||||
|
||||
|
||||
|
||||
|
||||
if ($consumer->callback_url!=null) {
|
||||
$params = $request->get_parameters();
|
||||
$glue="?";
|
||||
|
@ -68,35 +68,35 @@ function api_content(&$a) {
|
|||
goaway($consumer->callback_url.$glue."oauth_token=".OAuthUtil::urlencode_rfc3986($params['oauth_token'])."&oauth_verifier=".OAuthUtil::urlencode_rfc3986($verifier));
|
||||
killme();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$tpl = get_markup_template("oauth_authorize_done.tpl");
|
||||
$o = replace_macros($tpl, array(
|
||||
'$title' => t('Authorize application connection'),
|
||||
'$info' => t('Return to your app and insert this Securty Code:'),
|
||||
'$code' => $verifier,
|
||||
));
|
||||
|
||||
|
||||
return $o;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(! local_user()) {
|
||||
//TODO: we need login form to redirect to this page
|
||||
notice( t('Please login to continue.') . EOL );
|
||||
return login(false,$request->get_parameters());
|
||||
}
|
||||
//FKOAuth1::loginUser(4);
|
||||
|
||||
|
||||
$app = oauth_get_client($request);
|
||||
if (is_null($app)) return "Invalid request. Unknown token.";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$tpl = get_markup_template('oauth_authorize.tpl');
|
||||
$o = replace_macros($tpl, array(
|
||||
'$title' => t('Authorize application connection'),
|
||||
|
@ -105,15 +105,12 @@ function api_content(&$a) {
|
|||
'$yes' => t('Yes'),
|
||||
'$no' => t('No'),
|
||||
));
|
||||
|
||||
|
||||
//echo "<pre>"; var_dump($app); killme();
|
||||
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
echo api_call($a);
|
||||
killme();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue