예제 #1
0
        exit;
    }
} else {
    if (isset($_POST) && count($_POST) > 0) {
        // push 模式 part 2:從手機上傳送資料給伺服器
        if (isset($_POST["logs"]) && isset($_POST["uuid"])) {
            $uuid = $_POST["uuid"];
            $logs_ary = json_decode($_POST["logs"]);
        } else {
            exit;
        }
        //print_r($logs_ary);
        if (count($logs_ary) > 1) {
            $log_beans = R::dispense("log", count($logs_ary));
            foreach ($logs_ary as $i => $log) {
                $log_beans[$i]->uuid = $uuid;
                $log_beans[$i]->import($log);
            }
            R::storeAll($log_beans);
        } else {
            if (count($logs_ary) === 1) {
                $log_bean = R::dispense("log");
                $log_bean->uuid = $uuid;
                $log_bean->import($logs_ary);
                R::store($log_bean);
            }
        }
        //sync_complete($uuid, "push");
        jsonp_callback(true);
    }
}
예제 #2
0
include_once '../helper/javascript_helper.php';
include_once '../helper/log_helper.php';
$sync_file_name = "db_log.js";
$sync_function_name = "sync_complete()";
if (isset($_GET) && count($_GET) > 0 && isset($_GET["q"]) && isset($_GET["uuid"])) {
    $uuid = $_GET["uuid"];
    $q = $_GET["q"];
    //$sql =
    $notes = R::getRow('SELECT uuid, name, note FROM note WHERE q=? AND uuid !=?', [$q, $uuid]);
    if (is_null($notes)) {
        $notes = array();
    }
    //    $notes = array(
    //        array(
    //            "uuid"=> 1,
    //            "name"=> "模擬同學A",
    //            "note"=> "心得A\n\n\n\n\n\n心得心得"
    //        ),
    //        array(
    //            "uuid"=> 2,
    //            "name"=> "模擬同學B",
    //            "note"=> "心得B\n\n\n\n\n\n心得心得"
    //        ),
    //        array(
    //            "uuid"=> 3,
    //            "name"=> "模擬同學C",
    //            "note"=> "心得C\n\n\n\n\n\n心得心得"
    //        )
    //    );
    jsonp_callback($notes);
}