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": include_once "includes/graph.class.json.php"; if (!isset($_GET['date_from'])) { die; } $dateFrom = DateTime::createFromFormat($date_format, $_GET['date_from'], new DateTimeZone(TIME_ZONE)); $graph = new Graph();
$dream->timezone = TIME_ZONE; $dream->tumblrPostEmail = TUMBLR_POST_EMAIL; $dream->postToTumblr = false; $dream->email = "*****@*****.**"; $dream->date = $data[0]; $dream->title = $data[1]; $dream->description = $data[2]; $dream->age = $data[4]; $dream->gender = strtolower($data[5]) == "f" ? "female" : "male"; $dream->country = $data[6]; if ($dream->save()) { $successes++; } else { $errors++; } $output = $line . " - " . implode("; ", $dream->getLog()) . "\r"; echo $output; flush(); ob_flush(); if ($log) { error_log($output, 3, "import_log"); } $line++; } fclose($handle); } else { echo "Problem reading file"; } echo "</pre>"; $time_end = microtime(true); echo "<br/><br/>";