Beispiel #1
0
    $ud = new UserDAO($db);
    $owner = $od->getByEmail($_SESSION['user']);
    $i = $id->getByUserId($fb_user);
    if (isset($i)) {
        echo "Instance exists<br />";
        $oi = $oid->get($owner->id, $i->id);
        if ($oi == null) {
            //Instance already exists, owner instance doesn't
            $oid->insert($owner->id, $i->id, $session_key);
            //Add owner instance with session key
            echo "Created owner instance.<br />";
        }
    } else {
        //Instance does not exist
        echo "Instance does not exist<br />";
        $id->insert($fb_user, $fb_username, 'facebook');
        echo "Created instance";
        $i = $id->getByUserId($fb_user);
        $oid->insert($owner->id, $i->id, $session_key);
        echo "Created owner instance.<br />";
    }
    if (!$ud->isUserInDB($fb_user)) {
        $r = array('user_id' => $fb_user, 'user_name' => $fb_username, 'full_name' => $fb_username, 'avatar' => '', 'location' => '', 'description' => '', 'url' => '', 'is_protected' => '', 'follower_count' => 0, 'friend_count' => 0, 'post_count' => 0, 'last_updated' => '', 'last_post' => '', 'joined' => '', 'last_post_id' => '', 'network' => 'facebook');
        $u = new User($r, 'Owner info');
        $ud->updateUser($u);
    }
} else {
    echo "No session key or logged in Facebook user.";
}
# clean up
$db->closeConnection($conn);
Beispiel #2
0
$twitter_id = $api->doesAuthenticate();
if ($twitter_id > 0) {
    echo "Twitter authentication successful.<br />";
    $id = new InstanceDAO($db);
    $i = $id->getByUsername($tu);
    $oid = new OwnerInstanceDAO($db);
    if (isset($i)) {
        echo "Instance already exists.<br />";
        $id->updatePassword($tu, $tp);
        echo "Updated existing instance's password.<br />";
        $oi = $oid->get($owner->id, $i->id);
        if ($oi != null) {
            echo "Owner already has this instance, no insert or update.<br />";
        } else {
            $oid->insert($owner->id, $i->id);
            echo "Added owner instance.<br />";
        }
    } else {
        echo "Instance does not exist.<br />";
        $id->insert($twitter_id, $tu, $tp);
        echo "Created instance with password.<br />";
        $i = $id->getByUsername($tu);
        $oid->insert($owner->id, $i->id);
        echo "Created an owner_instance.<br />";
    }
} else {
    echo 'Twitter authentication failed.';
}
# clean up
$db->closeConnection($conn);
echo '<br /> <a href="' . $THINKTANK_CFG['site_root_path'] . 'account/">Back to your account</a>.';
Beispiel #3
0
    $db = new Database($THINKTANK_CFG);
    $conn = $db->getConnection();
    $od = new OwnerDAO($db);
    $owner = $od->getByEmail($_SESSION['user']);
    if ($twitter_id > 0) {
        echo "Twitter authentication successful.<br />";
        $id = new InstanceDAO($db);
        $i = $id->getByUsername($tu);
        $oid = new OwnerInstanceDAO($db);
        if (isset($i)) {
            echo "Instance already exists.<br />";
            $oi = $oid->get($owner->id, $i->id);
            if ($oi != null) {
                echo "Owner already has this instance, no insert or update.<br />";
            } else {
                $oid->insert($owner->id, $i->id, $tok['oauth_token'], $tok['oauth_token_secret']);
                echo "Added owner instance.<br />";
            }
        } else {
            echo "Instance does not exist.<br />";
            $id->insert($twitter_id, $tu);
            echo "Created instance.<br />";
            $i = $id->getByUsername($tu);
            $oid->insert($owner->id, $i->id, $tok['oauth_token'], $tok['oauth_token_secret']);
            echo "Created an owner_instance.<br />";
        }
    }
    # clean up
    $db->closeConnection($conn);
}
echo '<br /> <a href="' . $THINKTANK_CFG['site_root_path'] . 'account/">Back to your account</a>.';