├── README ├── needsoftheoccupiers ├── README ├── do_search.php ├── twitter_search.php ├── twitter_lookup.php └── twitter_script.php ├── README.md └── augmented_peoples_mic ├── twilio_version ├── incoming-call.xml └── check-pin.php ├── gather.xml ├── lookup.php ├── gather_processing.php ├── process_poll.php └── tropo_version └── tropo_everything.php /README: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /needsoftheoccupiers/README: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OWS-Globe- 2 | 3 | The Augmented People's Mic directory contains code to run People's Skype. 4 | 5 | The code is designed to run on both Twilio and Tropo SMS / Voice & Messaging platforms. 6 | 7 | The Needs of the Occupiers directory contains code to run Twitter Network Analysis: 8 | 9 | -------------------------------------------------------------------------------- /augmented_peoples_mic/twilio_version/incoming-call.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Welcome to the people's mike. To start a new mike, press 1 and then pound, otherwise enter a four digit mike PIN. 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /augmented_peoples_mic/gather.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Welcome to people's mike. Press 1 to start a new mike, or enter a mike check number followed by the pound sign. 7 | 8 | 9 | We didn't get any input from you, talk to you later! 10 | -------------------------------------------------------------------------------- /needsoftheoccupiers/do_search.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | find(array("need" => $_POST['search'])); 24 | 25 | foreach ($cursor as $need) { 26 | echo "Occupy Location ".$need["location"] . "
"; 27 | echo "Tweeted by ".$need["user"]."
"; 28 | echo "Raw Tweet ".$need["rawtext"]."
"; 29 | echo "Needs "; 30 | 31 | foreach ($need["need"] as $needarray) { 32 | echo " ".$needarray." "; 33 | } 34 | echo "

"; 35 | } 36 | 37 | 38 | } 39 | 40 | ?> -------------------------------------------------------------------------------- /augmented_peoples_mic/lookup.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Votes 7 | find(); 28 | 29 | // $cursor = iterator_to_array($cursor); 30 | 31 | //var_dump($cursor); 32 | 33 | 34 | foreach ($cursor as $need) { 35 | 36 | 37 | 38 | //echo $value." "; 39 | echo $need."
"; 40 | 41 | } 42 | 43 | 44 | 45 | ?> 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /augmented_peoples_mic/gather_processing.php: -------------------------------------------------------------------------------- 1 | \n"; 3 | 4 | if ($_REQUEST['Digits'] == '1') { 5 | 6 | echo "You started a new mike, your mike number is".rand(1000,9999).""; 7 | 8 | } 9 | 10 | 11 | else if ($_REQUEST['Digits'] == '2') { 12 | echo "Unsure"; 13 | //---------------------------------------// 14 | } 15 | 16 | else if ($_REQUEST['Digits'] == '3') { 17 | 18 | echo "Disagree"; 19 | //---------------------------------------// 20 | } 21 | 22 | else if ($_REQUEST['Digits'] == '4') { 23 | 24 | echo "Point of Process"; 25 | //---------------------------------------// 26 | } 27 | 28 | else if ($_REQUEST['Digits'] == '5') { 29 | 30 | echo "Point of Information"; 31 | //---------------------------------------// 32 | } 33 | 34 | else if ($_REQUEST['Digits'] == '6') { 35 | 36 | echo "Wrap it Up"; 37 | //---------------------------------------// 38 | } 39 | 40 | else if ($_REQUEST['Digits'] == '7') { 41 | 42 | echo "Block"; 43 | //---------------------------------------// 44 | } 45 | 46 | 47 | else { 48 | 49 | echo "You joined mike check number " . $_REQUEST['Digits'] . ". Press 1 to agree. 2 if unsure, 3 if disagree, 4 for point of process, 5 for point of information, 6 to wrap it up, 7 for block, 8 for current vote stats, 9 to leave this mic. 0 for help. Goodbye for now. "; 50 | 51 | } 52 | ?> -------------------------------------------------------------------------------- /needsoftheoccupiers/twitter_search.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Need of the Occupiers 5 | 6 | 7 | 8 | 42 | 43 | 44 | 45 |
46 |
47 | What do you have to offer? 48 |
49 | 50 |
51 |
52 |
53 |
54 | 55 |
Search results for
56 |
    57 |
58 | 59 |
60 |
61 | 62 | 63 | -------------------------------------------------------------------------------- /augmented_peoples_mic/process_poll.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | look it up by typing in 34 | 35 | 36 | if ($_REQUEST['Digits'] == '1') { 37 | //----New JSON Object------// 38 | $vote = array( 39 | 'signal' =>'agree' 40 | ); 41 | insertVoter($vote,$collection); 42 | $say = 'Agree.'; 43 | 44 | //---------------------------------------// 45 | } 46 | 47 | else if ($_REQUEST['Digits'] == '2') { 48 | //----New JSON Object------// 49 | $vote = array( 50 | 'signal' =>'unsure' 51 | ); 52 | insertVoter($vote,$collection); 53 | $say = 'Unsure.'; 54 | //---------------------------------------// 55 | } 56 | 57 | else if ($_REQUEST['Digits'] == '3') { 58 | //----New JSON Object------// 59 | $vote = array( 60 | 'signal' =>'disagree' 61 | ); 62 | insertVoter($vote,$collection); 63 | $say = 'Disagree.'; 64 | //---------------------------------------// 65 | } 66 | 67 | else if ($_REQUEST['Digits'] == '4') { 68 | //----New JSON Object------// 69 | $vote = array( 70 | 'signal' =>'pointofprocess' 71 | ); 72 | insertVoter($vote,$collection); 73 | $say = 'Point of Process.'; 74 | //---------------------------------------// 75 | } 76 | 77 | else if ($_REQUEST['Digits'] == '5') { 78 | //----New JSON Object------// 79 | $vote = array( 80 | 'signal' =>'pointofinformation' 81 | ); 82 | insertVoter($vote,$collection); 83 | $say = 'Point of Information.'; 84 | //---------------------------------------// 85 | } 86 | 87 | else if ($_REQUEST['Digits'] == '6') { 88 | //----New JSON Object------// 89 | $vote = array( 90 | 'signal' =>'wrapitup' 91 | ); 92 | insertVoter($vote,$collection); 93 | $say = 'Wrap it up.'; 94 | //---------------------------------------// 95 | } 96 | 97 | else if ($_REQUEST['Digits'] == '7') { 98 | //----New JSON Object------// 99 | $vote = array( 100 | 'signal' =>'block' 101 | ); 102 | insertVoter($vote,$collection); 103 | $say = 'Block.'; 104 | //---------------------------------------// 105 | } 106 | 107 | else { 108 | $say = "Try that again."; 109 | } 110 | 111 | // @end snippet 112 | // @start snippet 113 | $response = new Services_Twilio_Twiml(); 114 | $response->say($say); 115 | //$response->hangup(); 116 | header('Content-Type: text/xml'); 117 | print $response; 118 | // @end snippet 119 | ?> -------------------------------------------------------------------------------- /augmented_peoples_mic/twilio_version/check-pin.php: -------------------------------------------------------------------------------- 1 | '; 5 | 6 | require_once("/var/www/dev/mongoTest/functions.php"); 7 | 8 | $pin = $_REQUEST['Digits']; 9 | $caller = $_REQUEST['From']; 10 | 11 | //new random number string for PIN 12 | $micNumber = rand(1000,9999); 13 | $micNumber = $micNumber.''; 14 | 15 | //-------- Set up Mongo DB----------// 16 | 17 | //auth call 18 | $un = "xxxxxxxxx"; 19 | $pw = "xxxxxxxxx"; 20 | 21 | //database we have credentials to 22 | $dtb = "OWS"; 23 | 24 | $coll = "miccheck"; 25 | 26 | //set our collection 27 | $collection = mongoCollection($un, $pw, $dtb, $coll); 28 | 29 | //---------------------------------// 30 | 31 | ?> 32 | 33 | findOne(array('pin'=>$micNumber)); 40 | 41 | //checking to see if PIN already in database, generating random until unique 42 | while ($cursor['pin'] == $micNumber){ 43 | $micNumber = rand(1000,9999); 44 | $micNumber = $micNumber.''; 45 | } 46 | 47 | //----New JSON Object------// 48 | $mic = array( 49 | 'pin' =>$micNumber 50 | ); 51 | //------------------------// 52 | 53 | //inserting mic into DB 54 | insertMic($mic,$collection); 55 | 56 | echo 'Your mike check number is '.$micNumber.''; 57 | echo ''; 58 | echo ''.$micNumber.''; 59 | echo ''; 60 | } 61 | 62 | //if user typed a PIN at first menu... 63 | else 64 | { 65 | 66 | //check to see if PIN is valid in DB 67 | $cursor = $collection->findOne(array('pin'=>$pin)); 68 | 69 | //if PIN exists, connect 70 | if ($cursor['pin'] == $pin){ 71 | echo 'Connecting to mike check number '.$pin.''; 72 | 73 | echo ''; 74 | echo ''.$pin; 75 | //gather DTMF here doesn't work!! no support for this in Twilio 76 | echo ''; 77 | echo 'Press 1'; 78 | echo ''; 79 | echo ''; 80 | echo ''; 81 | } 82 | 83 | else { 84 | // Invalid PIN entered. Go back to main menu 85 | echo 'Sorry, that PIN is not valid.'; 86 | echo 'incoming-call.xml'; 87 | } 88 | } 89 | 90 | //insert PIN into DB 91 | function insertMic($json,$collection){ 92 | $safe_insert = true; 93 | $collection->insert($json,$safe_insert); 94 | } 95 | 96 | function micListen(){ 97 | return $output; 98 | } 99 | ?> 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /needsoftheoccupiers/twitter_lookup.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Needs 7 | find(); 29 | 30 | foreach ($cursor as $need) { 31 | 32 | 33 | foreach ($need["need"] as $needarray) { 34 | 35 | 36 | //temporary solution to bad words getting through 37 | if( 38 | 39 | $needarray === 's' || 40 | $needarray === 'to' || 41 | $needarray === 'Mills' || 42 | $needarray === 'lack' || 43 | $needarray === 'urgent' || 44 | $needarray === 'dangerously' || 45 | $needarray === 'folks' || 46 | $needarray === 'Oh' || 47 | $needarray === 'Bosn' || 48 | $needarray === 'ane' || 49 | $needarray === 'gt' || 50 | $needarray === 'night' || 51 | $needarray === 'forgot' || 52 | $needarray === 'treat' || 53 | $needarray === 'ZERO' || 54 | $needarray === 'Very' || 55 | $needarray === 'low' || 56 | $needarray === 'We' || 57 | $needarray === 'Pls' || 58 | $needarray === 'dealing' || 59 | $needarray === 'Including' || 60 | $needarray === 'Needs' || 61 | $needarray === 'we' || 62 | $needarray === 'w' || 63 | $needarray === 'tell' || 64 | $needarray === 'Committee' || 65 | $needarray === 'NYers' || 66 | $needarray === 'of' || 67 | $needarray === 'pile' || 68 | $needarray === 'sitting' || 69 | $needarray === 'badly' || 70 | $needarray === 'beg4' || 71 | $needarray === 'bad' || 72 | $needarray === 'List' || 73 | $needarray === 'bring' || 74 | $needarray === 'Park' || 75 | $needarray === 'one' || 76 | $needarray === 'page' || 77 | $needarray === 'address' || 78 | $needarray === 'derelicts' || 79 | $needarray === 'NYC' || 80 | $needarray === 'NYer' || 81 | $needarray === 'UP' || 82 | $needarray === 'large' || 83 | $needarray === 'clear' || 84 | $needarray === 'blue' || 85 | $needarray === 'black' || 86 | $needarray === 'General' || 87 | $needarray === 'colors' || 88 | $needarray === 'shit' || 89 | $needarray === 'black' || 90 | $needarray === 'General' || 91 | $needarray === 'colors' || 92 | $needarray === 'shit' || 93 | $needarray === 'liquid' || 94 | $needarray === 'South' || 95 | $needarray === 'St' || 96 | $needarray === 'lawn' || 97 | $needarray === 'at' || 98 | $needarray === 'off' || 99 | $needarray === 'Drop' || 100 | $needarray === '1st' || 101 | $needarray === 'fist' || 102 | $needarray === 'sketch' || 103 | $needarray === 'Can' || 104 | $needarray === 'link' || 105 | $needarray === 'send' || 106 | $needarray === 'quot' || 107 | $needarray === 'white' || 108 | $needarray === 'Hey' || 109 | $needarray === 'wrote' || 110 | $needarray === 'Boston' 111 | 112 | ){ 113 | continue; 114 | } 115 | 116 | 117 | $needarray = str_replace(array( 118 | 'antacid' 119 | ), 'liquid antacid - pepper spray treatment', $needarray); 120 | 121 | $needarray = str_replace(array( 122 | 'maalox' 123 | ), 'maalox - tear gas treatment', $needarray); 124 | 125 | $needarray = str_replace(array( 126 | '311' 127 | ), 'call 311', $needarray); 128 | 129 | $needarray = str_replace(array( 130 | 'othpaste','toothpaste' 131 | ), 'toothpaste', $needarray); 132 | 133 | if ($needarray != ''){ 134 | array_push($commonWords,$needarray); 135 | } 136 | 137 | 138 | } 139 | 140 | } 141 | 142 | $commonWords = array_change_key_case($commonWords); 143 | 144 | $commonWords = array_count_values($commonWords); 145 | 146 | arsort($commonWords); 147 | 148 | 149 | foreach ($commonWords as $key=>$value){ 150 | 151 | //echo $value." "; 152 | echo $key."
"; 153 | 154 | } 155 | 156 | ?> 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /needsoftheoccupiers/twitter_script.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/php 2 | 3 | 4 | 5 | needtweets; 13 | //$collection = $db->needs; 14 | 15 | //------------MongoDB Connect---------// 16 | 17 | //auth call 18 | $un = "xxxxxx"; 19 | $pw = "xxxxxx"; 20 | 21 | //database we have credentials to 22 | $dtb = "OWS"; 23 | 24 | $coll = "needs"; 25 | 26 | //set our collection 27 | $collection = mongoCollection($un, $pw, $dtb, $coll); 28 | 29 | //---------------------------------------------// 30 | 31 | 32 | 33 | //-----FIND LAST TWEET ID-----// 34 | $cursor = $collection->find(); 35 | $idArray = array(); 36 | 37 | foreach($cursor as $check){ 38 | array_push($idArray,$check["id"]); 39 | } 40 | $since_id = max($idArray); 41 | 42 | //--------------------------// 43 | 44 | $latest = file_get_contents('http://search.twitter.com/search.json?q='.urlencode($hash_tag).'&since_id='.urlencode($since_id)); 45 | 46 | $occupyAt = array(); 47 | $occupyHash = array(); 48 | $occupyUser = array(); 49 | 50 | $tweetCount = json_decode($latest); //how many tweets 51 | $tweetCount = count($tweetCount->results); 52 | 53 | 54 | for($i=0;$i<=$tweetCount; $i++){ 55 | 56 | 57 | $text = json_decode($latest)->results[$i]->text; 58 | $user = json_decode($latest)->results[$i]->from_user; 59 | $geo = json_decode($latest)->results[$i]->geo; 60 | $created = json_decode($latest)->results[$i]->created_at; 61 | $tweetID = json_decode($latest)->results[$i]->id_str; 62 | 63 | //------------FUNCTION PLAYGROUND---------// 64 | 65 | $created = new MongoDate(strtotime($created)); //twitter time to mongodate 66 | $stripe = removeCommonWords($text); //remove common words in tweet string 67 | $occupyLocation = findOccupyLocation($stripe,$user); //find tweet occupy location 68 | $keywordArray = keywordProcessing($stripe); //making needs searchable keywords array 69 | 70 | //----------------------------------------// 71 | 72 | 73 | 74 | //----- Package tweet and DB insert-------// 75 | 76 | if ($occupyLocation != NULL && $keywordArray != NULL) { //filtering out unimportant tweets 77 | 78 | 79 | 80 | /* 81 | $cursor = $collection->find(); 82 | foreach ($cursor as $need) { 83 | echo $need["location"] . "\n"; 84 | foreach ($need["need"] as $needarray) { 85 | echo "

".$needarray . "


"; 86 | } 87 | } 88 | */ 89 | 90 | //----New JSON Object------// 91 | 92 | $need = array( 93 | 'created' =>$created, 94 | 'user'=>$user, 95 | 'location'=>$occupyLocation, 96 | 'need'=>$keywordArray, 97 | 'rawtext'=>$text, 98 | 'id'=>$tweetID 99 | ); 100 | 101 | insertTweet($need,$collection); 102 | } 103 | 104 | //---------------------------------------// 105 | } 106 | 107 | } 108 | 109 | 110 | function insertTweet($need,$collection){ 111 | 112 | $safe_insert = true; 113 | $collection->insert($need,$safe_insert); 114 | 115 | } 116 | 117 | 118 | function removeCommonWords($eh){ 119 | 120 | $commonWords = array('about', 'above', 'above', 'across', 'after', 'afterwards', 'again', 'against', 'all', 'almost', 'alone', 'along', 'already', 'also','although','always',' am ','among', 'amongst', 'amoungst', 'amount', ' an ', 'and', 'another', 'any','anyhow','anyone','anything','anyway', 'anywhere', 'are', 'around', 'back','be','became', 'because','become','becomes', 'becoming', 'been', 'before', 'beforehand', 'behind', 'being', 'below', 'beside', 'besides', 'between', 'beyond', 'bill', 'both', 'bottom','but', ' by ', 'call', 'can', 'cannot', 'cant', ' co ', ' con ', 'could', 'couldnt', 'cry', ' de ', 'describe', 'detail', ' do ', 'done', 'down', ' due ', 'during', 'each', ' eg ', 'eight', 'either', 'eleven','else', 'elsewhere', 'empty', 'enough', 'etc', 'even', 'ever', 'every', 'everyone', 'everything', 'everywhere', 'except', 'few', 'fifteen', 'fifty', 'fill', 'find', 'fire', 'first', 'five', 'for', 'former', 'formerly', 'forty', 'found', 'four', 'from', 'front', 'full', 'further', 'get', 'give', 'go', 'had', 'has', 'hasnt', 'have', 'he', 'hence', 'her', 'here', 'hereafter', 'hereby', 'herein', 'hereupon', 'hers', 'herself', 'him', 'himself', 'his', 'how', 'however', 'hundred', ' if ', 'inc', 'indeed', 'interest', 'into', ' is ', 'its', 'itself', 'keep', 'last', 'latter', 'latterly', 'least', 'less', 'made', 'many', 'may', 'me', 'meanwhile', 'might', 'mill', 'mine', 'more', 'moreover', 'most', 'mostly', 'move', 'much', 'must', 'my', 'myself', 'name', 'namely', 'neither', 'never', 'nevertheless', 'next', 'nine', ' no ', 'nobody', 'none', 'noone', 'nor', 'not', 'nothing', 'now', 'nowhere', ' of ', ' off ', 'often', ' on ', 'once', ' one ', 'only', 'onto', ' or ', 'other', 'others', 'otherwise', 'our', 'ours', 'ourselves', 'out', 'over', 'own','part', 'per', 'perhaps', 'please', 'put', 'rather', ' re ', 'same', 'see', 'seem', 'seemed', 'seeming', 'seems', 'serious', 'several', 'she', 'should', 'show', 'side', 'since', 'sincere', 'six', 'sixty', ' so ', 'some', 'somehow', 'someone', 'something', 'sometime', 'sometimes', 'somewhere', 'still', 'such', 'system', 'take', ' ten ', 'than', 'that', 'the', 'their', 'them', 'themselves', 'then', 'thence', 'there', 'thereafter', 'thereby', 'therefore', 'therein', 'thereupon', 'these', 'they', 'thickv', 'thin', 'third', 'this', 'those', 'though', 'three', 'through', 'throughout', 'thru', 'thus', ' to ', 'together', 'too', 'top', 'toward', 'towards', 'twelve', 'twenty', 'two', ' un ', 'under', 'until', ' up ', 'upon', 'us', 'very', 'via', ' was', ' we ', 'well', 'were', 'what', 'whatever', 'when', 'whence', 'whenever', 'where', 'whereafter', 'whereas', 'whereby', 'wherein', 'whereupon', 'wherever', 'whether', 'which', 'while', 'whither', 'who', 'whoever', 'whole', 'whom', 'whose', 'why', 'will', 'with', 'within', 'without', 'would', 'yet', 'you', 'your', 'yours', 'yourself', 'yourselves', ' the ', ' is ', ' on ', ' a ',' I ','Please RT',' We ',' and ',' or ',' of ','requests','please',' A ','RT','with','Please','help','Help',' in ',' at ', 'I ','MT','LOL','lol','need', 121 | 'Need',' The '); 122 | 123 | return preg_replace('/\b('.implode('|',$commonWords).')\b/',' ',$eh); 124 | } 125 | 126 | 127 | 128 | 129 | function findOccupyLocation($stripe,$user){ 130 | 131 | 132 | //------- Find Occupy @, #, usernames ---------// 133 | 134 | preg_match_all('/[@]Occupy\S*/i', $stripe, $occupyAt); //finding Occupy @ tags 135 | preg_match_all('/[#]Occupy\S*/i', $stripe, $occupyHash); //finding Occupy # tags 136 | preg_match('/Occupy\S*/i', $user, $occupyUser); //finding Occupy User 137 | 138 | 139 | //---------------------------------------------// 140 | 141 | 142 | $occupyAt_strip = preg_replace("/[#@]/","",$occupyAt[0][0]); 143 | $occupyHash_strip = preg_replace("/[#@]/","",$occupyHash[0][0]); 144 | 145 | 146 | //--------- Finding Location ---------// 147 | 148 | if ($occupyAt_strip != NULL && $occupyAt_strip === $occupyUser[0]){ //if there's an @occupy && it's == to username 149 | $occupyLocation = $occupyAt[0][0]; 150 | } 151 | else if ($occupyHash_strip != NULL && $occupyHash_strip === $occupyUser[0]){ //if there's #occupy && it's == to username 152 | $occupyLocation = $occupyAt[0][0]; 153 | } 154 | else if ($occupyAt_strip != NULL){ 155 | $occupyLocation = $occupyAt[0][0]; 156 | } 157 | else if ($occupyUser[0] === "OccupyWallStNYC"){ //username conditions 158 | $occupyLocation = $occupyUser[0]; 159 | } 160 | else if ($occupyHash_strip != NULL){ 161 | $occupyLocation = $occupyHash[0][0]; 162 | } 163 | else if ($occupyUser != NULL){ 164 | $occupyLocation = $occupyUser[0]; 165 | } 166 | else { 167 | $occupyLocation = NULL; 168 | } 169 | 170 | 171 | return $occupyLocation; 172 | 173 | } 174 | 175 | 176 | function keywordProcessing($stripe){ 177 | 178 | $stripe = preg_replace("/http\S*/i"," ",$stripe); //take out all website links 179 | $stripe = preg_replace("/[#@]\S*/i"," ",$stripe); //take out all symbols 180 | $stripe = preg_replace("/[^a-zA-Z0-9\s]/"," ",$stripe); 181 | 182 | //removing all other common words before keywording 183 | $stripe = str_replace(array( 184 | 'softheoccupiers','needsoftheoccupiers','asking','Occupy','occupy','99','Any','any','Occupiers','occupiers', 185 | 'really',' use ','lots','How','how','HQ','hq',' amp ',' in ',' or ',' sOf ','Thank','thank',' you ','You', ' s ', ' It ',' If ', ' if ', 186 | 'want','Want','NEED','SUPPORT','need','support',' ty ',' TY ',' it ','LoL',' does ','Always','always' 187 | ), ' ', $stripe); 188 | 189 | //-----keyword array creation-----------------// 190 | 191 | $keywords = array(); 192 | $keywords = explode(' ', $stripe); //make array out of spaces 193 | $keywordsCondense = array_filter($keywords); //taking away empty fields 194 | $keywordsStrip = array_values($keywordsCondense); 195 | 196 | //--------------------------------------------// 197 | 198 | 199 | //-------associative to numerical array-------// 200 | 201 | $keywordArray = array(); 202 | 203 | foreach($keywordsStrip as $key=>$value) { 204 | array_push($keywordArray, $value); 205 | } 206 | 207 | //-------------------------------------------// 208 | 209 | 210 | return $keywordArray; 211 | } 212 | 213 | 214 | getTweets('#needsoftheoccupiers'); //start search 215 | 216 | 217 | ?> 218 | -------------------------------------------------------------------------------- /augmented_peoples_mic/tropo_version/tropo_everything.php: -------------------------------------------------------------------------------- 1 | getFrom(); 15 | $id = $session->getcallid(); 16 | $caller = $caller['id']; 17 | 18 | 19 | $collection = mongoAuth_session(); //grab session info (phone # + callid) 20 | 21 | 22 | //----New DB JSON Entry------// 23 | $newPerson = array( 24 | 'sessionID' =>$id, 25 | 'admin'=>$caller 26 | ); 27 | 28 | insertMic($newPerson,$collection); 29 | 30 | //------------------------// 31 | 32 | $tropo = new Tropo(); 33 | 34 | $options = array("choices" => "[1-4 DIGITS]", "name" => "digits", "timeout" => 60, "mode" => "dtmf", "terminator" => "#"); 35 | 36 | $tropo->ask("Welcome to the people's mike. To start a new mike, press 1 and then pound, otherwise enter a four digit mike PIN", $options); 37 | 38 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=continue")); 39 | 40 | $tropo->RenderJson(); 41 | 42 | } 43 | 44 | dispatch_post('/continue', 'app_continue'); 45 | function app_continue() { 46 | 47 | //grabbing needed returned values 48 | $result = new Result(); 49 | $pin = $result->getValue(); 50 | $id = $result->getcallid(); 51 | 52 | 53 | $collection = mongoAuth_session(); 54 | 55 | $cursor = $collection->findOne(array('sessionID'=>$id)); //pulling caller number from matching callID 56 | $admin = $cursor['admin']; //current caller's phone number (for admin potential) 57 | 58 | $collection = mongoAuth(); 59 | 60 | 61 | if ($pin == '1'){ 62 | 63 | //---------------GENERATING NEW RANDOM PIN, CHECKING FOR DUPLICATE IN DB--------// 64 | 65 | $pinExists=true; 66 | 67 | //need to add a counter here, break while loop if it reaches 8999? occurences ---> then delete oldest DB entry 68 | while ($pinExists){ 69 | 70 | $micNumber = rand(1000,9999); 71 | $micNumber = $micNumber.''; //making it readable to tropo as string (to create a conference room in this name) 72 | 73 | $cursor = $collection->findOne(array('pin'=>$micNumber)); 74 | 75 | if ($micNumber !== $cursor['pin']){ 76 | 77 | $pinExists = false; 78 | } 79 | } 80 | 81 | //----------------------------------------------------------------------------// 82 | 83 | 84 | //----New Mic JSON Object------// 85 | $mic = array( 86 | 'pin' =>$micNumber, 87 | 'admin'=>$admin, 88 | 'callIDs'=>array($id), 89 | 'yes'=>array(), 90 | 'no'=>array() 91 | ); 92 | 93 | insertMic($mic,$collection); 94 | 95 | //-----------------------------// 96 | 97 | 98 | $tropo = new Tropo(); 99 | 100 | $pinSep = wordwrap($micNumber, 1, " ", true); //making PIN speakable (i.e. 5432 is 5 4 3 2) 101 | 102 | $tropo->say('Your mike check number is '.$pinSep.'. Press pound for speaker options'); 103 | 104 | $tropo->conference(null, array("name" => "conference", "id" => $micNumber, "mute" => false, "terminator" => "#")); 105 | 106 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=adminpanel")); 107 | 108 | $tropo->RenderJson(); 109 | 110 | } 111 | 112 | else 113 | { 114 | 115 | $cursor = $collection->findOne(array('pin'=>$pin)); 116 | 117 | $admin_auth = $cursor['admin']; //pulling admin's phone number from new mic object 118 | 119 | if ($cursor['pin'] == $pin){ 120 | 121 | $tropo = new Tropo(); 122 | 123 | $newdata = array('$push' => array('callIDs' => $id)); 124 | 125 | //$upsert = array("upsert" => $safe_insert); 126 | 127 | $collection->update(array('pin' => $pin), $newdata); 128 | 129 | $pinSep = wordwrap($pin, 1, " ", true); //making PIN speakable 130 | 131 | 132 | //if admin was disconnected they can reconnect to their conference with admin power here: 133 | if ($admin_auth == $admin){ 134 | 135 | $tropo->say('Reconnecting to mike check number '.$pinSep.'as the speaker'); 136 | 137 | $tropo->conference(null, array("name" => "conference", "id" => $pin, "mute" => false, "terminator" => "#")); 138 | 139 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=adminpanel")); 140 | } 141 | 142 | else { 143 | 144 | $tropo->say('Connecting to mike check number '.$pinSep.'. Press pound for voting options'); 145 | 146 | $tropo->conference(null, array("name" => "conference", "id" => $pin, "mute" => true, "terminator" => "#")); 147 | 148 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=vote")); 149 | } 150 | 151 | $tropo->RenderJson(); 152 | } 153 | 154 | else { 155 | 156 | $tropo = new Tropo(); 157 | 158 | $tropo->say('That is not a current mike check number'); 159 | 160 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=wrongpin")); 161 | $tropo->RenderJson(); 162 | } 163 | } 164 | } 165 | 166 | 167 | dispatch_post('/vote', 'vote_tally'); 168 | function vote_tally() { 169 | 170 | $tropo = new Tropo(); 171 | 172 | $options = array("choices" => "[1 DIGIT]", "name" => "digit", "timeout" => 60, "mode" => "dtmf"); 173 | 174 | $tropo->ask("1 for yes, 0 for no, 9 for vote stats", $options); 175 | 176 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=vote_collect")); 177 | 178 | $tropo->on(array("event" => "incomplete", "next" => "tropo_everything.php?uri=return_conf")); 179 | 180 | $tropo->RenderJson(); 181 | } 182 | 183 | 184 | dispatch_post('/vote_collect', 'vote_collected'); 185 | function vote_collected() { 186 | 187 | $result = new Result(); 188 | $id = $result->getcallid(); 189 | $vote = $result->getValue(); 190 | 191 | $collection = mongoAuth(); 192 | 193 | $cursor = $collection->findOne(array('callIDs'=>$id)); 194 | 195 | $pin = $cursor['pin']; 196 | 197 | $yes = 'yes'; 198 | $no = 'no'; 199 | 200 | $tropo = new Tropo(); 201 | 202 | //this is an awful voting system (where its just adding a "yes" string to an array then counting the number of yes strings)...will fix eventually using $inc :P 203 | if ($vote == "1"){ 204 | 205 | $newdata = array('$push' => array('yes' => $yes)); 206 | $upsert = array("upsert" => $safe_insert); 207 | 208 | $collection->update(array('pin' => $pin), $newdata, $upsert); 209 | 210 | $tropo->say('you voted yes'); 211 | } 212 | 213 | else if ($vote == "0"){ 214 | 215 | $newdata = array('$push' => array('no' => $no)); 216 | $upsert = array("upsert" => $safe_insert); 217 | 218 | $collection->update(array('pin' => $pin), $newdata, $upsert); 219 | $tropo->say('you voted no'); 220 | } 221 | 222 | //again, super lazy way to do voting, sorry :0 223 | else if ($vote == "9"){ 224 | 225 | $yesCount=0; 226 | $noCount=0; 227 | 228 | foreach ($cursor['yes'] as $key=>$value){ 229 | $yesCount++; 230 | } 231 | 232 | foreach ($cursor['no'] as $key=>$value){ 233 | $noCount++; 234 | } 235 | 236 | $tropo->say('the current vote is '.$yesCount.' yes and '.$noCount.'no'); 237 | } 238 | 239 | else { 240 | $tropo->say('please try again'); 241 | } 242 | 243 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=return_conf")); 244 | 245 | $tropo->RenderJson(); 246 | 247 | } 248 | 249 | 250 | dispatch_post('/return_conf', 'conf'); 251 | function conf() { 252 | 253 | $result = new Result(); 254 | $id = $result->getcallid(); 255 | $collection = mongoAuth(); 256 | 257 | $cursor = $collection->findOne(array('callIDs'=>$id)); 258 | 259 | $micpin = $cursor['pin']; 260 | 261 | $tropo = new Tropo(); 262 | 263 | $tropo->conference(null, array("name" => "conference", "id" => $micpin, "mute" => true, "terminator" => "#")); 264 | 265 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=vote")); 266 | 267 | $tropo->RenderJson(); 268 | } 269 | 270 | 271 | //if user enters wrong PIN, revert back here...can't redo new Session, so need this or it won't work! 272 | dispatch_post('/wrongpin', 'app_start2'); 273 | function app_start2() { 274 | 275 | $tropo = new Tropo(); 276 | 277 | $options = array("choices" => "[1-4 DIGITS]", "name" => "digits", "timeout" => 60, "mode" => "dtmf", "terminator" => "#"); 278 | 279 | $tropo->ask("Welcome to the people's mike. To start a new mike, press 1 and then pound, otherwise enter a four digit mike PIN", $options); 280 | 281 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=continue")); 282 | 283 | $tropo->RenderJson(); 284 | } 285 | 286 | //---------------------------------------------------------------// 287 | //------------------MIC ADMIN CONTROLS---------------------------// 288 | //---------------------------------------------------------------// 289 | 290 | dispatch_post('/adminpanel', 'admin_commands'); 291 | function admin_commands() { 292 | 293 | $tropo = new Tropo(); 294 | 295 | $options = array("choices" => "[1 DIGIT]", "name" => "digit", "timeout" => 60, "mode" => "dtmf"); 296 | 297 | $tropo->ask("press 1 for mike pin, 9 for current poll stats, 3 to clear poll stats", $options); 298 | 299 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=admin_collect")); 300 | 301 | $tropo->on(array("event" => "incomplete", "next" => "tropo_everything.php?uri=admin_return_conf")); 302 | 303 | $tropo->RenderJson(); 304 | } 305 | 306 | dispatch_post('/admin_collect', 'admin_collected'); 307 | function admin_collected() { 308 | 309 | $result = new Result(); 310 | $id = $result->getcallid(); 311 | $vote = $result->getValue(); 312 | $collection = mongoAuth(); 313 | 314 | $cursor = $collection->findOne(array('callIDs'=>$id)); 315 | 316 | $pin = $cursor['pin']; 317 | 318 | $yes = 'yes'; 319 | $no = 'no'; 320 | 321 | $tropo = new Tropo(); 322 | 323 | //the current mic pin 324 | if ($vote == "1"){ 325 | 326 | $pinSep = wordwrap($pin, 1, " ", true); //making PIN speakable 327 | 328 | $tropo->say('the mike pin is '.$pinSep); 329 | 330 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=admin_return_conf")); 331 | 332 | } 333 | 334 | // 335 | else if ($vote == "3"){ 336 | 337 | $options = array("choices" => "[1 DIGIT]", "name" => "digit", "timeout" => 60, "mode" => "dtmf"); 338 | 339 | $tropo->ask("press 3 again to clear poll, or press any other key to cancel", $options); 340 | 341 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=admin_poll_clear")); 342 | 343 | $tropo->on(array("event" => "incomplete", "next" => "tropo_everything.php?uri=admin_return_conf")); 344 | } 345 | 346 | else if ($vote == "9"){ 347 | 348 | $yesCount=0; 349 | $noCount=0; 350 | 351 | foreach ($cursor['yes'] as $key=>$value){ 352 | $yesCount++; 353 | } 354 | 355 | foreach ($cursor['no'] as $key=>$value){ 356 | $noCount++; 357 | } 358 | 359 | $tropo->say('the current vote is '.$yesCount.' yes and '.$noCount.'no'); 360 | 361 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=admin_return_conf")); 362 | 363 | } 364 | 365 | else { 366 | 367 | $tropo->say('please try again'); 368 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=admin_return_conf")); 369 | } 370 | 371 | $tropo->RenderJson(); 372 | } 373 | 374 | dispatch_post('/admin_return_conf', 'admin_conf'); 375 | function admin_conf() { 376 | 377 | $result = new Result(); 378 | $id = $result->getcallid(); 379 | $collection = mongoAuth(); 380 | $cursor = $collection->findOne(array('callIDs'=>$id)); 381 | 382 | $pin = $cursor['pin']; 383 | 384 | $tropo = new Tropo(); 385 | 386 | $tropo->conference(null, array("name" => "conference", "id" => $pin, "mute" => false, "terminator" => "#")); 387 | 388 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=adminpanel")); 389 | 390 | $tropo->RenderJson(); 391 | } 392 | 393 | dispatch_post('/admin_poll_clear', 'admin_clear'); 394 | function admin_clear() { 395 | 396 | $result = new Result(); 397 | $id = $result->getcallid(); 398 | $vote = $result->getValue(); 399 | 400 | 401 | $collection = mongoAuth(); 402 | $cursor = $collection->findOne(array('callIDs'=>$id)); 403 | 404 | $pin = $cursor['pin']; 405 | 406 | $tropo = new Tropo(); 407 | 408 | if ($vote == "3"){ 409 | 410 | //clearing votes here 411 | 412 | $yes = 'yes'; 413 | $no = 'no'; 414 | 415 | $cleardata_yes = array('$pull' => array('yes' => $yes)); 416 | $cleardata_no = array('$pull' => array('no' => $no)); 417 | 418 | $collection->update(array('pin' => $pin), $cleardata_yes, array('upsert' => true)); 419 | $collection->update(array('pin' => $pin), $cleardata_no, array('upsert' => true)); 420 | 421 | $tropo->say('the poll was cleared'); 422 | } 423 | 424 | else { 425 | 426 | $tropo->say('the poll was not cleared'); 427 | } 428 | 429 | $tropo->conference(null, array("name" => "conference", "id" => $pin, "mute" => false, "terminator" => "#")); 430 | 431 | $tropo->on(array("event" => "continue", "next" => "tropo_everything.php?uri=adminpanel")); 432 | 433 | $tropo->RenderJson(); 434 | } 435 | 436 | //---------------------------------------------------------------// 437 | //---------------------------------------------------------------// 438 | //---------------------------------------------------------------// 439 | 440 | 441 | run(); 442 | 443 | 444 | //---------------FUNCTIONS-----------------------// 445 | 446 | function insertMic($json,$collection){ 447 | 448 | $safe_insert = true; 449 | $collection->insert($json,$safe_insert); 450 | } 451 | 452 | function mongoAuth(){ 453 | 454 | //auth call 455 | $un = "xxxxxxxx"; 456 | $pw = "xxxxxxxx"; 457 | 458 | //database we have credentials to 459 | $dtb = "OWS"; 460 | 461 | $coll = "miccheck"; 462 | 463 | //set our collection 464 | $collection = mongoCollection($un, $pw, $dtb, $coll); 465 | 466 | return $collection; 467 | } 468 | 469 | function mongoAuth_session(){ 470 | 471 | //auth call 472 | $un = "xxxxxxxxx"; 473 | $pw = "xxxxxxxxx"; 474 | 475 | //database we have credentials to 476 | $dtb = "OWS"; 477 | 478 | $coll = "micsession"; 479 | 480 | //set our collection 481 | $collection = mongoCollection($un, $pw, $dtb, $coll); 482 | 483 | return $collection; 484 | } 485 | //---------------------------------------------------// 486 | 487 | 488 | ?> --------------------------------------------------------------------------------