Private Screening

Users enter the darkened room to find an 8mm projector. A note indicates a number should be dialed to reach the projectionist. In fact, the user is transferred to a montreal phone number harvested from 411.ca. As demonstrated in the video above, the end of the call indicates to the Arduino to start and stop the projection for the time of this conversation. The film contains images of funerals and tombs captured at Notre Dame des Neiges cemetery in Montréal.
Project Code
Arduino
#include <Ethernet.h>
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {
132, 205, 136, 133 };
byte gateway[] = {
132, 205, 136, 1 };
byte subnet[] = {
255, 255, 255, 0 };
byte server[] = {
70, 80, 237, 203 }; // phone server address
Client client(server, 8080);
//variables for phone timing storage
const int idSize = 20; //The time storage sze is 20 chars long
const int timeLen = 32; //we leave room for 10 chars of time
char uniqID[idSize]; //this stores the channel number from the call
char newuniqID[idSize]; //this is used for comparison of two ids
char time[timeLen]; //the amound of time the call lasted
const int plug = 3; //set the pin of the 120v plug.
//RX TX Ethernet variables
char inByte = 'c'; //incoming byte from serial rx
int stringPos = 0; //string index counter
long lastCompletionTime = 0; //counter for delay after last completion
void setup()
{
Ethernet.begin(mac, ip, gateway, subnet);
Serial.begin(9600);
delay(1000);
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.println("GET /index.php HTTP/1.0");
client.println();
//wait for the content to be served
delay(3000);
//read in variable values for uniqID and the time
inByte = client.read();
while(client.available()){
//if we read a pipe "|" we have an id
if (inByte == '|'){
inByte = client.read();
while (inByte != '<' && inByte != '\n'){
//save the newuniqID channel id
uniqID[stringPos]=inByte;
stringPos ++;
//move to the next character
inByte = client.read();
}
}
else {
//keep reading
inByte = client.read();
}
}
//empty the client
client.flush();
Serial.println(uniqID);
}
else {
Serial.println("connection failed");
}
//set the default values
pinMode(plug,OUTPUT);
}
void loop()
{
//this is called when all data has been read from the remote server
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
//restart the server every 9 seconds
delay(9000);
{
fetchWeb();
}
}
}
void fetchWeb(){
//clear data from last request
inByte = -1;
stringPos = 0;
for (int i=0; i<timeLen;i++){
time[i] = -1;
}
Serial.println("re-connecting...");
if (client.connect()) {
Serial.println("connected");
client.println("GET /index.php HTTP/1.0");
client.println();
//wait for the content to be served
delay(3000);
//read in variable values for uniqID and the time
inByte = client.read();
while(client.available()){
//if we read a pipe "|" we have an id
if (inByte == '|'){
inByte = client.read();
//while we do not find <
while (inByte != '<' && inByte != '\n'){
//save the newuniqID channel id
newuniqID[stringPos]=inByte;
stringPos ++;
//move to the next character
inByte = client.read();
}
}
else {
//keep reading
inByte = client.read();
}
//looking for the left delimiter of a time
if (inByte == '<'){
//found time
Serial.println("starting time");
//we found a time string
stringPos =0;
inByte = client.read();
while (inByte != '>'){
time[stringPos]=inByte;
stringPos ++;
inByte = client.read();
}
}
}
//empty the client
client.flush();
}
else {
Serial.println("connection failed");
}
//check if we have a new call
Serial.print("old user is ");
Serial.println(uniqID);
Serial.print("new user is ");
Serial.println(newuniqID);
//check the id for identical matches
int flag = 0;
for (int i=0; i<idSize;i++){
if (uniqID[i] != newuniqID[i])
{
flag++;
} //increment the flag if different uniqIDs
}
if (flag>0){
//send the time in milliseconds to the projector
int timeMS = atoi(time);
Serial.print("projecting for");
Serial.println(timeMS);
project(timeMS);
//set the new id to the old id
for (int i=0; i<idSize;i++){
uniqID[i] = newuniqID[i];
}
//we finished projecting
}
else{
Serial.print("No new user this time");
}
}
void project(int t){
digitalWrite(plug,HIGH);
Serial.println("Circuit HOT for ");
Serial.println(t);
delay(t); //wait while we play
//Turn it off
digitalWrite(plug,LOW);
Serial.println("Circuit OFF");
}
[/code]
Phone Number Harvester
<?php
//By Emmanuel Lalande
//For CART 453
//OCT 18 2009
include('db_connection.php');
//get variables from address bar
$areaCode = $_GET['area'];
$city= $_GET['city'];
$startPage = $_GET['startp'];
$depth= $_GET['depth'];
$fLetter = $_GET['fletter'];
$lLetter = $_GET['lletter'];
//declaratoin of variables:
$rightDelimiter = '(';
$leftDelimiter = ') ';
//how deep will this search go?
$maxPages = $startPage+$depth;
//array to store phone numbers
$phoneNumbers = array();
//this will store the web address and its variables
$myFile = '';
//loop this for as many letters as there are in the alphabet
while($fLetter <= $lLetter){
//read pages as deep as we requested
for ($currPage = $startPage; $currPage <= $maxPages; $currPage++){
//scan 411.ca
$myFile = 'http://www.411.ca/whitepages/?fn=First%20Name&ln=' . $fLetter . '&cz=' . $city . '&page='. $currPage;
// make sure the file is successfully opened before doing anything else
if ($fp = fopen($myFile, 'r')) {
$content = file_get_contents ($myFile);
//there are 10 phone numbers per 411.ca page
for($i=1; $i<=10; $i++){
// find the first occurence of the phone number and truncate the file
$searchString = $rightDelimiter.$areaCode.$leftDelimiter;
$content = strstr ( $content , $searchString );
// convert the phone number to a numerical value and remove the '-' delimiters
$rawNumber = substr($content,6,9);
$rawNumber = $areaCode.substr($rawNumber,0,3).substr($rawNumber,4,4);
// send it to the array
$phoneNumbers[] = $rawNumber;
$content = substr($content,7);
}
} else {
// an error occured when trying to open the specified file
}
}
//move on to the next letter in the alphabet
$fLetter++;
}
//send the obtained values of this harvest to the Database
foreach ($phoneNumbers as $phoneNumber){
$query =
'INSERT INTO qwenippi_phones.number (id , number)
VALUES (
NULL , "'.$phoneNumber.'")';
mysql_query($query);
}
//success!
echo "Harvested ". count($phoneNumbers) . " phone numbers.";
?>
[/code]
Asterisk Dialplan
exten => 1234,1,ResetCDR(w)
; we will find the number here
exten => 1234,n,Monitor(wav)
; we will set the number to a variable and call it below
exten => 1234,n,AGI(picktransfer.php)
;set the maximum ring time to 20 seconds.
exten => 1234,n,Dial(SIP/Voipgo/${ARDUINOFW},20)
[/code]
Tell asterisk what number to dial (picktransfer.php)
Return 1 Phone Number
<?php
include('db_connection.php');
//this page returns one phone number that has not yet been called, at random, from the database
//it is called when the asterisk server receives a telephone call and runs its script
$query = '
SELECT *
FROM number
WHERE called = 0
ORDER BY RAND()
LIMIT 1
';
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
$id = $row['id'];
echo $row['number'];
}
//when we finish we must assume this number has been called
// we mark this in the DB
$sql = "UPDATE qwenippi_phones.number SET called=1 WHERE id=$id";
mysql_query($sql);
?>
[/code]















One Response
[...] Invading your life, one frame at a time. Read More [...]