Permalink
Browse files

app under git

  • Loading branch information...
andyyoung committed Jan 8, 2012
1 parent 394990e commit 7caea83ddb921ee675e07b53b28d1cd1a755217a
Showing with 6,253 additions and 0 deletions.
  1. +20 −0 LICENSE
  2. +116 −0 app/BaseApp.php
  3. +364 −0 app/CLIApp.php
  4. +58 −0 app/FilterTrack.php
  5. +78 −0 app/TweetQueue.php
  6. +217 −0 app/WebApp.php
  7. +16 −0 cli/check_stream_tracker.php
  8. +16 −0 cli/clean_queue.php
  9. +17 −0 cli/process_queue.php
  10. +15 −0 cli/restart_tracker.php
  11. +15 −0 cli/trackstream.php
  12. +32 −0 config/config.php
  13. +56 −0 config/database_schema.sql
  14. +1 −0 cron/check_stream_tracker.php
  15. +1 −0 cron/clean_queue.php
  16. +1 −0 cron/process_queue.php
  17. +131 −0 lib/DB/DB.php
  18. +26 −0 lib/DB/MySQL.php
  19. +78 −0 lib/Process.php
  20. +747 −0 lib/error_handler.php
  21. +1 −0 lib/facebook
  22. +1,147 −0 lib/facebook-v3.1.1/base_facebook.php
  23. +93 −0 lib/facebook-v3.1.1/facebook.php
  24. +121 −0 lib/facebook-v3.1.1/fb_ca_chain_bundle.crt
  25. +1 −0 lib/phirehose
  26. +4 −0 lib/phirehose_github_20111007/.gitignore
  27. +38 −0 lib/phirehose_github_20111007/Changelog.txt
  28. +47 −0 lib/phirehose_github_20111007/Readme.md
  29. +42 −0 lib/phirehose_github_20111007/example/filter-oauth.php
  30. +41 −0 lib/phirehose_github_20111007/example/filter-reconfigure.php
  31. +33 −0 lib/phirehose_github_20111007/example/filter-track-geo.php
  32. +30 −0 lib/phirehose_github_20111007/example/filter-track.php
  33. +146 −0 lib/phirehose_github_20111007/example/ghetto-queue-collect.php
  34. +131 −0 lib/phirehose_github_20111007/example/ghetto-queue-consume.php
  35. +29 −0 lib/phirehose_github_20111007/example/sample.php
  36. +57 −0 lib/phirehose_github_20111007/example/userstream-simple.php
  37. +339 −0 lib/phirehose_github_20111007/gpl.txt
  38. +157 −0 lib/phirehose_github_20111007/lib/OauthPhirehose.php
  39. +774 −0 lib/phirehose_github_20111007/lib/Phirehose.php
  40. +502 −0 lib/phirehose_github_20111007/lib/UserstreamPhirehose.php
  41. +1 −0 logs
  42. +15 −0 templates/footer.php
  43. +18 −0 templates/header.php
  44. +45 −0 templates/tabs.php
  45. +82 −0 www/help.php
  46. BIN www/img/app_3_115463795461_5640.gif
  47. BIN www/img/buffer_signup.png
  48. BIN www/img/bullet_blue.png
  49. BIN www/img/bullet_green.png
  50. BIN www/img/error.png
  51. BIN www/img/facebook.gif
  52. BIN www/img/feed.png
  53. BIN www/img/groupspaces.gif
  54. BIN www/img/link.png
  55. BIN www/img/linkedin.gif
  56. BIN www/img/new.png
  57. BIN www/img/tag_blue.png
  58. BIN www/img/twitter.gif
  59. +95 −0 www/index.php
  60. +105 −0 www/pages.php
  61. +28 −0 www/privacy.php
  62. +83 −0 www/settings.php
  63. +24 −0 wwwadmin/ok.php
  64. +19 −0 wwwadmin/zvbxrpl.php
View
20 LICENSE
@@ -0,0 +1,20 @@
+Selective Tweets
+Copyright (c) 2012 Andrew Young <andy@apexa.co.uk>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
View
@@ -0,0 +1,116 @@
+<?php
+/**
+ * This file is part of Selective Tweets.
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ *
+ * @author Andy Young <andy@apexa.co.uk>
+ * @license MIT
+ */
+$lib_dir = dirname(dirname(__FILE__)) . '/lib/';
+require_once $lib_dir . 'error_handler.php';
+require_once $lib_dir . '../config/config.php';
+if (defined('LOG_DIR')) {
+ ini_set('error_log', LOG_DIR . 'selectivestatus.log');
+}
+require_once $lib_dir . 'DB/MySQL.php';
+require_once $lib_dir . 'facebook/facebook.php';
+
+/**
+ * Controller-esque stuff for the Selective Tweets app
+ *
+ * Extended by concrete controllers for the Wep App and CLI scripts
+ */
+abstract class SelectiveTweets_BaseApp
+{
+ const CRASHED = 0;
+ const OK = 1;
+ const TEST_FAILED = -1;
+
+ /** @var DB DB Connection **/
+ protected $db;
+
+ /** @var Facebook Facebook SDK **/
+ protected $fb;
+
+ /**
+ * Factory
+ */
+ public static function factory()
+ {
+ $instance = new static;
+ $instance->init();
+ return $instance;
+ }
+
+ /**
+ * Protected constructor to force use of factory
+ */
+ protected function __construct() { }
+
+ /**
+ * Let's get this party started
+ */
+ protected function init()
+ {
+ $this->db = MySQL::factory(DB_HOST, DB_NAME, DB_USER, DB_PASS);
+ $this->fb = new Facebook(array(
+ 'appId' => FB_APP_ID,
+ 'secret' => FB_APP_SECRET,
+ ));
+ }
+
+ /**
+ * Accessor for the DB connection
+ *
+ * @return DB
+ */
+ public function getDB()
+ {
+ return $this->db;
+ }
+
+ /**
+ * Accessor for the Facebook SDK
+ *
+ * @return Facebook
+ */
+ public function getFacebook()
+ {
+ return $this->fb;
+ }
+
+ /**
+ * Detects whether the tracker for the Twitter feed is returning tweets a-ok
+ *
+ * Returns self::OK if all's fine, other return values indicate a problem
+ *
+ * @returns self::OK|self::CRASHED|self::TEST_FAILED
+ */
+ public function detectTrackerCrash()
+ {
+ $rs = $this->db->query('SELECT enqueued < DATE_SUB(NOW(), INTERVAL 60 SECOND) AS last_enqueued_delay FROM tweet_queue ORDER BY id DESC LIMIT 1');
+ if ($rs && ($row = $rs->fetch())) {
+ if ($row['last_enqueued_delay']) {
+ return self::CRASHED;
+ } else {
+ return self::OK;
+ }
+ } else {
+ return self::TEST_FAILED;
+ }
+ }
+
+ /**
+ * A logger's job is to log logs
+ */
+ protected function log($msg, $file = 'log', $newline = true)
+ {
+ if ($newline) {
+ $msg = date('D, j M H:i:s') . ' ' . $msg . "\n";
+ }
+ echo $msg;
+ file_put_contents(LOG_DIR . $file, $msg, FILE_APPEND);
+ }
+}
+
Oops, something went wrong.

0 comments on commit 7caea83

Please sign in to comment.