예제 #1
0
$date_format = preg_replace('/{{month}}/', 'n', $date_format);
$date_format = preg_replace('/{{year}}/', 'Y', $date_format);
// 	set default date to yesterday in australia
$date = new DateTime('now', new DateTimeZone(TIME_ZONE));
$date->sub(new DateInterval("P01D"));
$dreamDefault = new Dream();
$dreamDefault->alchemyApiKey = ALCHEMY_API_KEY;
$dreamDefault->dateFormat = $date_format;
$dreamDefault->origin = isset($_SESSION['origin']) ? $_SESSION['origin'] : null;
$dreamDefault->postToTumblr = POST_TO_TUMBLR;
$dreamDefault->timezone = TIME_ZONE;
$dreamDefault->tumblrPostEmail = TUMBLR_POST_EMAIL;
$dreamDefault->date = $date->format($date_format);
if (false) {
    $testValues = array('age' => '33', 'color' => '#ff3300', 'date' => '19/1/2013', 'description' => 'I am in a car with my friend Mark. Mark is totally blind and so am I. The interesting thing about this is that I am driving the car. I am driving the car from somewhere to my house. I don\'t know how I seem to know where to go, but I seem to know. I told him that I am going to drive us home and I\'m doing it. I always wished that I could drive although this is the first dream I have ever had where I\'m doing it. The main senses I used in this were hearing because I could listen to him and hear what he was saying, I could hear the other traffic around me. And feeling. I could feel the upholstery around me in the car, the steering wheel. I was driving the car, that\'s all there is to that dream.', 'email' => '*****@*****.**', 'gender' => 'female', 'feelings' => array('6', '5'), 'tags' => 'blind,driving,Mark,hearing,upholstery', 'title' => 'me and mark');
    $dreamDefault->setValues($testValues);
}
$dream = $dreamDefault;
//	whether or not to disable fields other than those related to tour retrieval
$disable_fields = true;
//	record fact that user has visited this page (graph.json.php)
if (!isset($_SESSION['submission'])) {
    $_SESSION['submission'] = 1;
}
$formData = EMBEDDED ? $_GET : $_POST;
//	process form submit
if (isset($formData['submit'])) {
    $path = parse_url($_SERVER["REQUEST_URI"]);
    $url = "http://" . $_SERVER['HTTP_HOST'] . (isset($path['path']) ? substr($path['path'], 0, strrpos($path['path'], '/')) : '') . "/api/dream/" . (isset($formData['id']) ? $formData['id'] : '');
    foreach ($_FILES as $key => $file) {
        if ($file['tmp_name']) {
예제 #2
0
$date = new DateTime('now', new DateTimeZone(TIME_ZONE));
$date->sub(new DateInterval("P01D"));
switch ($resource) {
    case "dream":
        include_once "includes/dream.class.php";
        switch ($_SERVER['REQUEST_METHOD']) {
            case "POST":
                $dream = new Dream($resourceId);
                $dream->alchemyApiKey = ALCHEMY_API_KEY;
                $dream->dateFormat = $date_format;
                $dream->origin = isset($_SESSION['origin']) ? $_SESSION['origin'] : null;
                $dream->postToTumblr = POST_TO_TUMBLR;
                $dream->timezone = TIME_ZONE;
                $dream->tumblrPostEmail = TUMBLR_POST_EMAIL;
                //	set values to what user submitted in case there are errors
                $dream->setValues($_POST, isset($_FILES['image_file']) ? $_FILES['image_file'] : null, isset($_FILES['audio_file']) ? $_FILES['audio_file'] : null);
                //	save
                $success = $dream->save();
                if (!$success) {
                    $response->success = 0;
                    $response->error = $dream->status;
                    $response->errors = $dream->getLog();
                } else {
                    $response->result = $dream;
                }
                break;
        }
        break;
    case "graph":
        switch ($_SERVER['REQUEST_METHOD']) {
            case "GET":