]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #1168 from annando/1409-application-source-name
authorfabrixxm <fabrix.xm@gmail.com>
Mon, 29 Sep 2014 07:24:41 +0000 (09:24 +0200)
committerfabrixxm <fabrix.xm@gmail.com>
Mon, 29 Sep 2014 07:24:41 +0000 (09:24 +0200)
API: Detecting the source name of the application

1  2 
include/api.php

diff --combined include/api.php
index 1ccd3edb3d915a0d3af5df48e8246eb79742b93e,f2f20606316494693f5a516df866e03d33664589..f6096f29074eb1107f8edf0ef21bd74f5e288267
                return false;
        }
  
+       function api_source() {
+               if (requestdata('source'))
+                       return (requestdata('source'));
+               // Support for known clients that doesn't send a source name
+               if (strstr($_SERVER['HTTP_USER_AGENT'], "Twidere"))
+                       return ("Twidere");
+               logger("Unrecognized user-agent ".$_SERVER['HTTP_USER_AGENT'], LOGGER_DEBUG);
+               return ("api");
+       }
        function api_date($str){
                //Wed May 23 06:01:13 +0000 2007
                return datetime_convert('UTC', 'UTC', $str, "D M d H:i:s +0000 Y" );
                if($parent)
                        $_REQUEST['type'] = 'net-comment';
                else {
- //                    logger("api_statuses_update: upload ".print_r($_FILES, true)." ".print_r($_POST, true)." ".print_r($_GET, true), LOGGER_DEBUG);
- //die("blubb");
                        $_REQUEST['type'] = 'wall';
                        if(x($_FILES,'media')) {
                                // upload the image if we have one
  
                $_REQUEST['api_source'] = true;
  
-               if (!isset($_REQUEST["source"]) OR ($_REQUEST["source"] == ""))
-                       $_REQUEST["source"] = "api";
+               if (!x($_REQUEST, "source"))
+                       $_REQUEST["source"] = api_source();
  
                // call out normal post function
  
                        $_REQUEST['type'] = 'wall';
                        $_REQUEST['api_source'] = true;
  
-                       if (!isset($_REQUEST["source"]) OR ($_REQUEST["source"] == ""))
-                               $_REQUEST["source"] = "api";
+                       if (!x($_REQUEST, "source"))
+                               $_REQUEST["source"] = api_source();
  
                        require_once('mod/item.php');
                        item_post($a);
                        AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`deleted` = 0
                        AND `contact`.`id` = `item`.`contact-id`
                        AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
 -                      AND `item`.`parent` IN (SELECT `iid` from thread where uid = %d AND `mention`)
 +                      AND `item`.`parent` IN (SELECT `iid` from thread where uid = %d AND `mention` AND !`ignored`)
                        $sql_extra
                        AND `item`.`id`>%d
                        ORDER BY `item`.`id` DESC LIMIT %d ,%d ",