Example #1
0
function message_user_shout()
{
    // hanya menerima $_POST
    // variable yg diterima:
    //	- session_id: diproses hanya jika session_id masih valid & aktif, meskipun nanti yg disimpan di db adalah user_id
    //	- circle: '', 'public', [circle_name_1], [circle_name_2]
    //	- shout_text = text status
    extract($_REQUEST);
    $session_id = $_SESSION['session_id'];
    $user_id = $_SESSION['user_id'];
    $shout = trim($shout);
    if ($shout == '') {
        die("Your shout should not be empty.");
        //		$_SESSION['pop_error_msg'][] = "ERROR - Shout should not be empty.";
        //		header("Location: " . $_SESSION['basepath'] . "social");
        //		exit;
    }
    $mentioned_friends = message_guest_mentionedfriends($shout);
    if (strlen($shout) > 500) {
        $shout = substr($shout, 0, 500);
    }
    $shout = htmlspecialchars($shout);
    $shout = message_guest_shoutlinktomentioneduser($shout);
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Social');
    $lilo_mongo->selectCollection('Shout');
    $shout_data = array('user_id' => $user_id, 'shout_time' => date("Y-m-d - H:i:s"), 'shout' => $shout, 'circle' => $circle, 'mentioned_friends' => $mentioned_friends, 'mentioned_friends_notified' => 0, 'time' => time(), 'ingame' => $ingame);
    // die(print_r($shout_data, true));
    // notify mentioned friends dengan CRON
    $lilo_id = $lilo_mongo->insert($shout_data);
    $lilo_mongo->update($shout_data, array_merge($shout_data, array('lilo_id' => (string) $lilo_id)), array("multiple" => false));
    return "OK";
}
Example #2
0
function message_guest_shout($session_id = NULL, $shout = NULL, $circle = '')
{
    // hanya menerima $_POST
    // variable yg diterima:
    //	- session_id: diproses hanya jika session_id masih valid & aktif, meskipun nanti yg disimpan di db adalah user_id
    //	- circle: '', 'public', [circle_name_1], [circle_name_2]
    //	- shout = text status
    if (!isset($session_id) || trim($session_id) == '') {
        // dapatkan $session_id dari $_POST
        $session_id = $_POST['session_id'];
    }
    if (!isset($session_id) || trim($session_id) == '') {
        $session_id = $_SESSION['session_id'];
    }
    if (!isset($shout) || trim($shout) == '') {
        $shout = $_POST['shout'];
    }
    if (!isset($circle) || trim($circle) == '') {
        $circle = $_POST['circle'];
    }
    // cek apakah $session_id masih berlaku: Users.Session.time_end == '' || strtotime() - strtotime(Users.Session.time_end) < 3 * 60;
    $user_id = message_guest_sessionvalidation($session_id);
    if (!$user_id || trim($user_id) == '') {
        write_log(array('log_text' => "Invalid session_id: {$session_id}"));
        return "ERROR - Validation failed.";
    }
    $shout = trim($shout);
    if ($shout == '') {
        return "ERROR - Shout should not be empty.";
    }
    $mentioned_friends = message_guest_mentionedfriends($shout);
    if (strlen($shout) > 500) {
        $shout = substr($shout, 0, 500);
    }
    $shout = htmlspecialchars($shout);
    $shout = message_guest_shoutlinktomentioneduser($shout);
    $lilo_mongo = new LiloMongo();
    $lilo_mongo->selectDB('Social');
    $lilo_mongo->selectCollection('Shout');
    $shout_data = array('user_id' => $user_id, 'shout_time' => date("Y-m-d - H:i:s"), 'shout' => $shout, 'circle' => $circle, 'mentioned_friends' => $mentioned_friends, 'mentioned_friends_notified' => 0);
    // notify mentioned friends dengan CRON
    $lilo_id = $lilo_mongo->insert($shout_data);
    $lilo_mongo->update($shout_data, array_merge($shout_data, array('lilo_id' => (string) $lilo_id)), array("multiple" => false));
    return "OK";
}