Example #1
0
 /**
  * 助力数据
  * GET api/activity/dream/{dreamId}/vote 
  */
 public function actionRestlist()
 {
     $this->checkRestAuth();
     $dream = Dream::model()->findByPk($_GET['dreamId']);
     if ($dream == null || $dream->nickname == null) {
         $this->sendResponse(404, 'not found');
     }
     $criteria = new CDbCriteria();
     $take = 100;
     $criteria->compare('dream_id', $dream->id);
     $criteria->limit = $take;
     $criteria->offset = 0;
     $criteria->order = 'created_time DESC';
     $result = Vote::model()->findAll($criteria);
     $json = new JsonData();
     $json->limit = $take;
     $json->total = (int) Vote::model()->count($criteria);
     $json->result = $this->JSONArrayMapper($result);
     echo CJSON::encode($json);
 }
Example #2
0
include_once "config/config.php";
include_once "includes/db.class.php";
include_once "includes/dream.class.php";
include_once "includes/media.class.php";
$formDatabase = new Database();
//	set up 'tour not found' text, appending tag artwork call to action
$errorText = "<p>Oops, we had trouble locating your tour information. Please make sure you correctly typed the email address you used when recording your tour via The O. We use this only to link your dream to your tour information, and it will not be disclosed to anyone.</p>";
//	set up date format
$date_format = DATE_FORMAT;
$date_format = preg_replace('/{{date}}/', 'j', $date_format);
$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)
Example #3
0
 public function actionRestupdate()
 {
     $this->checkRestAuth();
     //判断是否全部填写
     if (!isset($_POST['subOpenId']) || !isset($_POST['headimgurl']) || !isset($_POST['nickname'])) {
         return $this->sendResponse(400, 'missed required properties');
     }
     // 查询是否已经生成
     $dream = Dream::model()->findByPk($_GET['dreamId']);
     if ($dream == null) {
         return $this->sendResponse(404, 'not found');
     }
     $dream->sub_open_id = $_POST['subOpenId'];
     $dream->headimgurl = $_POST['headimgurl'];
     $dream->nickname = $_POST['nickname'];
     if (!$dream->save()) {
         return $this->sendResponse(500, 'faild to save dream');
     }
     echo CJSON::encode($this->JSONMapper($dream));
 }
Example #4
0
$response = (object) array("success" => 1);
$items = array();
//	set up date format
$date_format = DATE_FORMAT;
$date_format = preg_replace('/{{date}}/', 'j', $date_format);
$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"));
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 {
Example #5
0
$tags_total = 0;
$successes = 0;
$errors = 0;
if (($handle = fopen("../dummy_data/dreams.csv", "r")) !== FALSE) {
    $date_format = DATE_FORMAT;
    $date_format = preg_replace("/{{date}}/", "j", $date_format);
    $date_format = preg_replace("/{{month}}/", "n", $date_format);
    $date_format = preg_replace("/{{year}}/", "Y", $date_format);
    $line = 0;
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        //	skip header
        if ($line == 0) {
            $line++;
            continue;
        }
        $dream = new Dream();
        $dream->alchemyApiKey = ALCHEMY_API_KEY;
        $dream->dateFormat = $date_format;
        $dream->origin = "mona";
        $dream->postToTumblr = POST_TO_TUMBLR;
        $dream->timezone = TIME_ZONE;
        $dream->tumblrPostEmail = TUMBLR_POST_EMAIL;
        $dream->date = array_shift($data);
        $dream->description = array_shift($data);
        $dream->color = array_shift($data);
        $dream->email = array_shift($data);
        $dream->age = array_shift($data);
        $dream->gender = array_shift($data);
        if ($dream->save()) {
            $successes++;
        } else {
 while (($data = fgetcsv($handle)) !== FALSE && $valid) {
     //	skip header
     if ($line == 0) {
         $line++;
         continue;
     }
     if ($line < $start) {
         $line++;
         continue;
     }
     if ($size > -1 && $line > $start + $size) {
         $valid = false;
         continue;
     }
     //"Date","Title","Text","User","Age","Gender","Location"
     $dream = new Dream(null, $db);
     $dream->alchemyApiKey = ALCHEMY_API_KEY;
     $dream->useAlchemy = true;
     $dream->dateFormat = $date_format;
     $dream->origin = "dreambank";
     $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()) {