Example #1
0
<?php

/***********************************************
DAVE PHP API
https://github.com/evantahler/PHP-DAVE-API
Evan Tahler | 2011

I will create a new lobby for folks to chat within
***********************************************/
if ($ERROR == 100) {
    $LobbyKey = md5($PARAMS['LobbyName'] . time() . rand());
}
if ($ERROR == 100) {
    $resp = _ADD("lobbies", array("LobbyName" => $PARAMS['LobbyName'], "LobbyKey" => $LobbyKey));
    if ($resp[0] == false) {
        $ERROR = $resp[1];
    } else {
        $LobbyID = $resp[1]["LobbyID"];
        $details = _VIEW("lobbies", array("LobbyID" => $LobbyID));
        $OUTPUT["LobbyID"] = $LobbyID;
        $OUTPUT["LobbyName"] = $details[1][0]["LobbyName"];
        $OUTPUT["LobbyKey"] = $details[1][0]["LobbyKey"];
    }
}
function create_session()
{
    $key = md5(uniqid());
    _ADD("sessions", array("KEY" => $key, "DATA" => serialize(array()), "created_at" => date("Y-m-d H:i:s"), "updated_at" => date("Y-m-d H:i:s")));
    return $key;
}
Example #3
0
***********************************************/
if ($ERROR == 100) {
    if (empty($PARAMS["LobbyKey"])) {
        $ERROR = "Please Provide a LobbyKey";
    }
}
if ($ERROR == 100) {
    if (empty($PARAMS["Speaker"])) {
        $ERROR = "Please Provide a Speaker.  Who are you?";
    }
}
if ($ERROR == 100) {
    if (empty($PARAMS["Message"])) {
        $ERROR = "Please Provide a Message";
    }
}
if ($ERROR == 100) {
    $resp = _VIEW("lobbies", array("LobbyKey" => $PARAMS['LobbyKey']));
    if ($resp[0] == false) {
        $ERROR = $resp[1];
    }
    if (count($resp[1]) != 1) {
        $ERROR = "That Lobby cannot be found";
    } else {
        $LobbyID = $resp[1][0]["LobbyID"];
    }
}
if ($ERROR == 100) {
    $resp = _ADD("messages", array("LobbyID" => $LobbyID, "Speaker" => $PARAMS["Speaker"], "Message" => $PARAMS["Message"]));
    $OUTPUT["MessageID"] = $resp["1"]["MessageID"];
}
Example #4
0
    if ($func_out != 100) {
        $ERROR = $func_out;
    }
}
if ($ERROR == 100 && strlen($PARAMS["PhoneNumber"]) > 0) {
    list($fun_out, $PARAMS["PhoneNumber"]) = validate_PhoneNumber($PARAMS["PhoneNumber"]);
    // baisc format checking
    if ($func_out != 100) {
        $ERROR = $func_out;
    }
}
if ($ERROR == 100) {
    if (strlen($PARAMS["Password"]) > 0) {
        $Salt = md5(rand(1, 999) . microtime() / rand(1, 999) . rand(1, 999));
        $PasswordHash = md5($PARAMS["Password"] . $Salt);
    } else {
        $ERROR = "Please provide a Password";
    }
}
// use the DAVE Add to take care of the actual DB checks and adding
if ($ERROR == 100) {
    $UserData = only_table_columns($PARAMS, "users");
    $UserData["PasswordHash"] = $PasswordHash;
    $UserData["Salt"] = $Salt;
    list($pass, $result) = _ADD("users", $UserData);
    if (!$pass) {
        $ERROR = $result;
    } else {
        $OUTPUT[$TABLES['users']['META']['KEY']] = $result[$TABLES['users']['META']['KEY']];
    }
}
Example #5
0
 public function ADD()
 {
     $resp = _ADD($this->DaveTableObject->table(), $this->DATA);
     $this->DATA = $this->VIEW();
     //load in generated data and remove non-col data
     return $resp[1];
 }