]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/classes/FeedSub.php
Merge branch 'master' into 0.9.x
[quix0rs-gnu-social.git] / plugins / OStatus / classes / FeedSub.php
index 6f9e0856ab1aeb821b8927e43dbd412710c4eb33..7756f6a234325a5a50e751ce65c4c168bc7cdd7f 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+if (!defined('STATUSNET')) {
+    exit(1);
+}
+
 /**
  * @package OStatusPlugin
  * @maintainer Brion Vibber <brion@status.net>
@@ -39,7 +43,6 @@ PuSH subscription flow:
         hub sends us updates via POST
 
 */
-
 class FeedDBException extends FeedSubException
 {
     public $obj;
@@ -88,7 +91,6 @@ class FeedSub extends Memcached_DataObject
      *
      * @return array array of column definitions
      */
-
     function table()
     {
         return array('id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
@@ -143,7 +145,6 @@ class FeedSub extends Memcached_DataObject
      *
      * @return array key definitions
      */
-
     function keys()
     {
         return array_keys($this->keyTypes());
@@ -157,7 +158,6 @@ class FeedSub extends Memcached_DataObject
      *
      * @return array key definitions
      */
-
     function keyTypes()
     {
         return array('id' => 'K', 'uri' => 'U');
@@ -249,7 +249,7 @@ class FeedSub extends Memcached_DataObject
                 // We'll never actually get updates in this mode.
                 return true;
             } else {
-                throw new ServerException("Attempting to start PuSH subscription for feed with no hub.");
+                throw new ServerException(_m('Attempting to start PuSH subscription for feed with no hub.'));
             }
         }
 
@@ -279,7 +279,7 @@ class FeedSub extends Memcached_DataObject
                 // We'll never actually get updates in this mode.
                 return true;
             } else {
-                throw new ServerException("Attempting to end PuSH subscription for feed with no hub.");
+                throw new ServerException(_m('Attempting to end PuSH subscription for feed with no hub.'));
             }
         }
 
@@ -487,7 +487,15 @@ class FeedSub extends Memcached_DataObject
                 if ($their_hmac === $our_hmac) {
                     return true;
                 }
-                common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bad SHA-1 HMAC: got $their_hmac, expected $our_hmac");
+                if (common_config('feedsub', 'debug')) {
+                    $tempfile = tempnam(sys_get_temp_dir(), 'feedsub-receive');
+                    if ($tempfile) {
+                        file_put_contents($tempfile, $post);
+                    }
+                    common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bad SHA-1 HMAC: got $their_hmac, expected $our_hmac for feed $this->uri on $this->huburi; saved to $tempfile");
+                } else {
+                    common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bad SHA-1 HMAC: got $their_hmac, expected $our_hmac for feed $this->uri on $this->huburi");
+                }
             } else {
                 common_log(LOG_ERR, __METHOD__ . ": ignoring PuSH with bogus HMAC '$hmac'");
             }
@@ -500,5 +508,4 @@ class FeedSub extends Memcached_DataObject
         }
         return false;
     }
-
 }