$redirect_after_login = false; if ($_POST) { // if we have a form being submitted, handle the login if (@$_POST['email'] && @$_POST['password']) { $POD = new PeoplePod(array('authSecret' => md5($_POST['email'] . $_POST['password']))); if (!$POD->success()) { $POD->addMessage($POD->error()); } if (!$POD->isAuthenticated()) { $POD->addMessage("Oops! We could not log you in using that email address and password."); } else { $days = 15; if ($_POST['remember_me']) { $days = 100; } setcookie('pp_auth', $POD->currentUser()->get('authSecret'), time() + 86400 * $days, "/"); $redirect_after_login = true; } } } if ($redirect_after_login) { // if we logged in correctly, we redirect to the homepage of the site, or to any url passed in as a parameter if ($_POST['redirect']) { header("Location: " . $_POST['redirect']); } else { header("Location: " . $POD->siteRoot(false)); } } else { $POD->header("Login"); $p = $POD->getPerson(); // create an empty person record
echo json_encode($doc->asArray()); } else { echo json_encode(array('error' => $doc->error(), 'id' => $_GET['docId'])); } } else { echo json_encode(array('error' => $doc->error(), 'id' => $_GET['docId'])); } } else { echo json_encode(array('error' => 'PERMISSION DENIED', 'id' => $_GET['docId'])); } } if ($method == "addWatch") { if ($POD->isAuthenticated()) { $doc = $POD->getContent(array('id' => $_GET['docId'])); if ($doc->success()) { $POD->currentUser()->addWatch($doc); if ($POD->currentUser()->success()) { echo json_encode($doc->asArray()); } else { echo json_encode(array('error' => $POD->currentUser()->error(), 'id' => $_GET['docId'])); } } else { echo json_encode(array('error' => $doc->error(), 'id' => $_GET['docId'])); } } else { echo json_encode(array('error' => 'PERMISSION DENIED', 'id' => $_GET['docId'])); } } if ($method == "removeWatch") { if ($POD->isAuthenticated()) { $doc = $POD->getContent(array('id' => $_GET['docId']));
if ($POD->hasAdminUser()) { echo "Yes"; } else { echo "No"; } echo "</p>"; echo "<P>Authentication: "; if ($POD->isAuthenticated()) { echo "Success"; } else { echo "Fail"; } echo "</p>"; if ($POD->isAuthenticated()) { echo "<P>Super User: "******"Success"; } else { echo "Fail"; } echo "</p>"; } } echo 'Please refer to the <a href="http://peoplepods.net/readme">PeoplePods documentation.</a>'; } } } } } ?>
/*********************************************** * This file is part of PeoplePods * (c) xoxco, inc * http://peoplepods.net http://xoxco.com * * core_profiles/profile.php * Handles requests to user profiles * * Documentation for this pod can be found here: * http://peoplepods.net/readme/messaging /**********************************************/ include_once "../../PeoplePods.php"; $POD = new PeoplePod(array('debug' => 0, 'authSecret' => @$_COOKIE['pp_auth'])); if (!$POD->libOptions('enable_core_profiles')) { header("Location: " . $POD->siteRoot(false)); exit; } $profile_username = $_GET['username']; $PROFILE_PERSON = $POD->getPerson(array('stub' => $profile_username)); if ($POD->isAuthenticated()) { $POD->currentUser()->expireAlertsAbout($PROFILE_PERSON); } if ($PROFILE_PERSON->success()) { $POD->header($PROFILE_PERSON->get('nick'), $POD->siteRoot(false) . '/feeds/person/' . $PROFILE_PERSON->get('stub')); $PROFILE_PERSON->output(); $POD->footer(); } else { header("Status: 404 Not Found"); echo "404 Not Found"; }
$POD = new PeoplePod(array('debug'=>0,'lockdown'=>$lockdown,'authSecret'=>@$_COOKIE['pp_auth'])); if (!$POD->libOptions('enable_core_groups')) { header("Location: " . $POD->siteRoot(false)); exit; } $group = $POD->getGroup(array('stub'=>$_GET['stub'])); if (!$group->success()) { header("Status: 404 Not Found"); echo "404 Not Found"; exit; } if ($group->get('type')=="private") { if (!$POD->isAuthenticated() || !$group->isMember($POD->currentUser())) { header("Status: 404 Not Found"); echo "404 Not Found"; exit; } } if ($POD->isAuthenticated()) { $POD->currentUser()->expireAlertsAbout($group); } $template = "output"; if (isset($_GET['command'])) { // do something here. // join // quit
function Test_flags() { $POD = new PeoplePod(); $user = $POD->getPerson(); $user->email = '*****@*****.**'; //create user $user->password = '******'; $user->nick = 'test'; $user->save(); $POD->changeActor(array('id' => $user->id)); $content = $POD->getContent(); $content->set('headline', 'this is the headline'); $content->set('type', 'this is the type'); $content->save(); $flag = 'awesome'; //test addFlag, hasFlag $this->assertFalse($POD->currentUser()->hasFlag($flag, $user)); $user->addFlag($flag, $user); $this->assertTrue($POD->currentUser()->hasFlag($flag, $user)); //test toggleFlag $flag = FALSE; $this->assertFalse($content->hasFlag($flag, $user)); $content->toggleFlag($flag, $user); $this->assertTrue($content->hasFlag($flag, $user)); $content->toggleFlag($flag, $user); $this->assertFalse($content->hasFlag($flag, $user)); $content->toggleFlag($flag, $user); $this->assertTrue($content->hasFlag($flag, $user)); //test RemoveFlag, both boolean flag and string flag $content->removeFlag($flag, $user); $this->assertFalse($content->hasFlag($flag, $user)); $flag = 'awesome'; $user->removeFlag($flag, $user); $this->assertFalse($POD->currentUser()->hasFlag($flag, $user)); $content->delete(); $user->delete(); }
* http://peoplepods.net http://xoxco.com * * core_profiles/editprofile.php * Handles requests to /editprofile * * Documentation for this pod can be found here: * http://peoplepods.net/readme/messaging /**********************************************/ include_once "../../PeoplePods.php"; $POD = new PeoplePod(array('debug' => 0, 'lockdown' => 'login', 'authSecret' => @$_COOKIE['pp_auth'])); if (!$POD->libOptions('enable_core_profiles')) { header("Location: " . $POD->libOptions('serverRoot')); exit; } if (@$_POST['account'] != '') { $POD->currentUser()->set('nick', $_POST['nick']); //$POD->currentUser()->set('email',$_POST['email']); $POD->currentUser()->save(); if (!$POD->currentUser()->success()) { $POD->addMessage($POD->currentUser()->error()); } else { $POD->addMessage("Your settings have been updated."); foreach ($_FILES as $filename => $file) { $POD->currentUser()->addFile($filename, $file); if (!$POD->currentUser()->success()) { $POD->addMessage('An error occured while attaching your file: ' . $POD->currentUser()->error()); } } $POD->currentUser()->files()->fill(); // now we'll add any meta fields that have been passed in. // we do this by looking for anything with a field name starting with meta_
<?php include_once "../../PeoplePods.php"; $POD = new PeoplePod(array('debug' => 0, 'authSecret' => @$_COOKIE['pp_auth'])); // this page is only available to facebook users. if (!$POD->isAuthenticated() || !$POD->currentUser()->facebook_token) { header("Location: /facebook"); exit; } $POD->header("Facebook Friends"); $friends = $POD->currentUser()->getFacebookFriends(); $friends->output('short', 'header', 'footer', 'Facebook Friends', 'None of your Facebook friends are members of this site.'); $POD->footer();
header("Location: " . $POD->siteRoot(false)); exit; } if ($_GET['stub']) { $doc = $POD->getContent(array('stub' => $_GET['stub'])); } else { if ($_GET['id']) { $doc = $POD->getContent(array('id' => $_GET['id'])); } else { if ($_POST['id']) { $doc = $POD->getContent(array('id' => $_POST['id'])); } } } if ($POD->isAuthenticated()) { $POD->currentUser()->expireAlertsAbout($doc); } if (!$doc->success()) { header("Status: 404 Not Found"); echo "404 Not Found"; exit; } if (isset($_POST['comment'])) { // this is a request to post a comment $comment = $doc->addComment($_POST['comment']); if (!$comment || !$comment->success()) { $POD->addMessage("Couldn't add comment! " . $doc->error()); } else { header("Location: " . $doc->get('permalink') . "#" . $comment->get('id')); exit; }
* core_authentication/verify.php * Handles requests to /verify * * Documentation for this pod can be found here: * http://peoplepods.net/readme /**********************************************/ include_once "../../lib/Core.php"; $POD = new PeoplePod(array('lockdown' => 'login', 'authSecret' => @$_COOKIE['pp_auth'])); if (!$POD->libOptions('enable_core_authentication_creation')) { header("Location: " . $POD->siteRoot(false)); exit; } if (@$_GET['key'] != '') { // we've got a key to verify. // user does not have to be logged in - we match by key and set cookies for login. $POD->currentUser()->verify($_GET['key']); if ($POD->currentUser()->success()) { $status = 'ok'; } else { $status = 'bad_key'; } } else { if (@$_GET['resend']) { $POD->currentUser()->welcomeEmail(); $status = 'key_resent'; } else { // no key specified. user may need a reminder mail, or may need to enter key manually. $status = 'no_key'; } } $POD->header('Verify Your Account');
* Displays a welcome page for non-members * as defined in my_theme/people/welcome.php * Documentation for this pod can be found here: * http://peoplepods.net/readme /**********************************************/ include_once "../../PeoplePods.php"; if ($_POST) { $lockdown = 'verified'; } else { $lockdown = null; } $POD = new PeoplePod(array('debug' => 0, 'lockdown' => $lockdown, 'authSecret' => @$_COOKIE['pp_auth'])); if (!$POD->libOptions('enable_core_dashboard')) { header("Location: " . $POD->siteRoot(false)); exit; } if (@$_GET['msg']) { $POD->addMessage(htmlspecialchars(strip_tags($_GET['msg']))); } $POD->header(); if ($POD->isAuthenticated()) { if (!isset($_GET['replies'])) { $POD->currentUser()->output('dashboard'); } else { $POD->currentUser()->output('dashboard_replies'); } } else { $POD->getPerson()->output('welcome'); } $POD->footer();
<? // in this pod we must output JSON only // include the peoplepods library and instantiate a pod object require_once("../../PeoplePods.php"); $POD = new PeoplePod(array('authSecret'=>@$_COOKIE['pp_auth'],'debug'=>2)); $id=0; if (isset($_GET['id'])) { $id=$_GET['id']; } $alerts = $POD->getAlerts(array( 'id:gt' => $id, 'targetUserId'=>$POD->currentUser()->get('id') )); $secCount = 0; while ($alerts->count() == 0) { usleep(1000000 * 1); $secCount++; if ($secCount >=3) { echo json_encode(array('count'=>0)); exit; } $alerts = $POD->getAlerts(array( 'id:gt' => $id, 'targetUserId'=>$POD->currentUser()->get('id') )); }
<?php include_once "../../PeoplePods.php"; $POD = new PeoplePod(array('debug' => 0, 'authSecret' => @$_COOKIE['pp_auth'])); $key = $POD->libOptions('fb_connect_api'); $secret = $POD->libOptions('fb_connect_secret'); // we need to make sure sessions are on so we can store the twitter codes session_start(); if (isset($_GET['rfb'])) { $POD->currentUser()->removeMeta('facebook_token'); $POD->currentUser()->removeMeta('fbuid'); $POD->addMessage("Your Facebook account has been removed."); } $display = 'page'; if (strpos($_SERVER['HTTP_USER_AGENT'], "iPhone") || strpos($_SERVER['HTTP_USER_AGENT'], "Android")) { // $display='touch'; } if (!($key && $secret)) { $POD->header('Configuration Required'); echo '<div class="info">Configuration required!</div>'; echo '<p>To enable Facebook login, please set the Facebook API key and secret via the PeoplePods command center.</p>'; echo '<P>To obtain the necessary details from Facebook, <a href="http://www.facebook.com/developers/">register your app</a>.</p>'; $POD->footer(); exit; } $user = null; if (isset($_GET['code'])) { $code = $_GET['code']; $oauth_token = file_get_contents("https://graph.facebook.com/oauth/access_token?client_id=" . $key . "&redirect_uri=" . $POD->siteRoot(false) . "/facebook&client_secret=" . urlencode($secret) . "&code=" . urlencode($code)); list($junk, $oauth_token) = explode("=", $oauth_token); // if authenticated, add to user
<?php include_once "../../PeoplePods.php"; $POD = new PeoplePod(array('debug' => 0, 'authSecret' => @$_COOKIE['pp_auth'])); // this page is only available to facebook users. if (!$POD->isAuthenticated() || !$POD->currentUser()->twitter_token) { header("Location: /twitter"); exit; } $POD->header("Twitter Friends"); $friends = $POD->currentUser()->getTwitterFriends(); $friends->output('short', 'header', 'footer', 'Twitter Friends', 'None of your Twitter friends are members of this site.'); $POD->footer();
function testPersonInheritedFunctions() { $POD = new PeoplePod(); $user = $POD->getPerson(); $user->email = '*****@*****.**'; //create user $user->password = '******'; $user->set('nick', 'test'); $user->save(); $this->assertTrue($user->success()); $this->assertFalse($user->error()); $POD->changeActor(array('id' => $user->id)); // tests get/set $testget = $user->get('nick'); $this->assertIdentical($testget, 'test'); //below tests inherited meta functions $user->addMeta('about me', 'I live in Austin'); $new_meta = $POD->getContents(array('type' => 'about me')); $this->assertIsA($new_meta, 'stack'); $meta = $user->getMeta(); $test_this = $meta['about me']; $this->assertEqual($test_this, 'I live in Austin'); $user->removeMeta('about me'); $test_meta = $user->get('about me'); $this->assertNull($test_meta); //below tests inherited flag functions $user->addFlag('block', $POD->currentUser()); $this->assertTrue($POD->currentUser()->hasFlag('block', $user)); $user->removeFlag('block', $user); $this->assertFalse($POD->currentUser()->hasFlag('block', $user)); $flag = FALSE; $this->assertFalse($user->hasFlag($flag, $user)); $user->toggleFlag($flag, $user); $this->assertTrue($user->hasFlag($flag, $user)); $user->delete(); }
<? // include the peoplepods library and instantiate a pod object require_once("../../PeoplePods.php"); $POD = new PeoplePod(array('authSecret'=>@$_COOKIE['pp_auth'],'debug'=>2)); // create an empty piece of content $doc = $POD->getContent(); if (isset($_POST['selected_wiki'])) { $selWiki=$POD->getContent(array('stub'=>$_POST['selected_wiki'])); $selWiki->addFlag('username',$POD->currentUser(),$_POST['user_name']); } $doc->headline = 'My Wikis'; // print the header $POD->header($doc->headline); // output the sample content using a custom template that is included with the pod. $doc->output('custom.template',dirname(__FILE__)); // print the footer. $POD->footer();
$access = 'http://twitter.com/oauth/access_token'; $auth = 'http://twitter.com/oauth/authorize'; $key = $POD->libOptions('twitter_api'); $secret = $POD->libOptions('twitter_secret'); if (!($key && $secret)) { $POD->header('Configuration Required'); echo '<div class="info">Configuration required!</div>'; echo '<p>To enable Twitter login, please set the Twitter API key and secret via the PeoplePods command center.</p>'; echo '<P>To obtain the necessary details from Twitter, <a href="https://dev.twitter.com/apps">register your app</a>.</p>'; $POD->footer(); exit; } // we need to make sure sessions are on so we can store the twitter codes session_start(); if (isset($_GET['remove'])) { $POD->currentUser()->addMeta('twitter_name', null); $POD->currentUser()->addMeta('twitter_secret', null); $POD->currentUser()->addMeta('twitter_token', null); $POD->currentUser()->addMeta('twitter_id', null); $POD->addMessage("Your Twitter account has been removed."); } $access_token_info = array(); if (@$_GET['mode'] == 'verify') { if ($_SESSION['twitter_state'] == 1 && !isset($_GET['oauth_token'])) { $_SESSION['twitter_state'] = 0; } try { $oauth = new OAuth($key, $secret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI); $oauth->enableDebug(); // This will generate debug output in your error_log if ($_SESSION['twitter_state'] == 0) {
* * Documentation for this pod can be found here: * http://peoplepods.net/readme /**********************************************/ include_once "../../PeoplePods.php"; $POD = new PeoplePod(array('lockdown' => 'verified', 'authSecret' => @$_COOKIE['pp_auth'])); if (!$POD->libOptions('enable_core_invite')) { header("Location: " . $POD->siteRoot(false)); exit; } $max_allowed_invites = 5; if ($_POST) { // send invites. for ($i = 1; $i <= $max_allowed_invites; $i++) { if (isset($_POST["email{$i}"]) && $_POST["email{$i}"] != '') { $POD->currentUser()->sendInvite($_POST["email{$i}"], $_POST['message'], @$_POST['group']); $POD->addMessage("Invites sent!"); } } } $POD->header('Send Invites'); ?> <form method="post" action="<?php $POD->siteRoot(); ?> /invite" class="valid" id="invite"> <div class="column_6"> <h1>Send Invites</h1>
$group->set('description', $_POST['description']); $group->set('type', $_POST['type']); $group->save(); if (!$group->success()) { $POD->addMessage("Your group was not created! " . $group->error()); } else { $POD->addMessage("Your new group, " . $group->permalink('groupname', true) . " is ready! "); } } if (isset($_GET['q'])) { $header = "Group Search"; $groups = $POD->getGroups(array('or' => array('groupname:like' => '%' . $_GET['q'] . '%', 'description:like' => '%' . $_GET['q'] . '%')), 'g.date DESC', $max, $offset); } else { if ($POD->isAuthenticated()) { $header = "My Groups"; $groups = $POD->getGroups(array('mem.userId' => $POD->currentUser()->get('id')), 'mem.date DESC', $max, $offset); if ($groups->totalCount() == 0) { $header = "Newish Groups"; $groups = $POD->getGroups(array('type' => 'public'), 'g.date DESC', $max, $offset); } } else { $header = "Newish Groups"; $groups = $POD->getGroups(array('type' => 'public'), 'g.date DESC', $max, $offset); } } if (!$groups->success()) { $POD->addMessage($groups->error()); } $POD->header('My Groups'); ?> <div class="column_8">
if (!$POD->libOptions("enable_contenttype_{$content_type}_list")) { header("Location: " . $POD->siteRoot(false)); exit; } $offset = 0; if (isset($_GET['offset'])) { $offset = $_GET['offset']; } $wikis = $POD->getContents(array('type' => $content_type)); $POD->header('List of supported wikis!'); ?> <div class="column_8"> <? if ($POD->libOptions("enable_contenttype_wiki_add")) if($POD->isAuthenticated() && $POD->currentUser()->get('adminUser')){ ?> <p>Add a new wiki now! <a href="<? $POD->siteRoot(); echo $edit_pattern; ?>">Click here!</a></p> <? } else { ?><p>This software is under developement. Adding new wikis by users will be enabled in coming releases inshalla!</p><? } ?><p>To connect your account on one of the wikis below, please add it <a href="wikiman">here</a></p><? $wikis->output('short_wiki','header','pager','List of supported wikis','Nothing has been posted on this site yet. Wow, it must be brand new!'); ?> </div> <div class="column_4 structure_only"> <? $POD->output('sidebars/search'); ?>
if (isset($_POST['id'])) { $doc = $POD->getContent(array('id' => $_POST['id'])); } } } if (!$doc->success()) { header("Status: 404 Not Found"); echo "404 Not Found"; exit; } if (isset($_POST['comment'])) { // this is a request to post a comment $comment = $doc->addComment($_POST['comment']); if (!$comment || !$comment->success()) { $POD->addMessage("Couldn't add comment! " . $doc->error()); } else { header("Location: " . $doc->get('permalink') . "#" . $comment->get('id')); exit; } } if (isset($_GET['vote'])) { // this is a request to vote if ($POD->isAuthenticated()) { if (!$POD->currentUser()->getVote($doc)) { $doc->vote($_GET['vote']); } } } $POD->header($doc->get('headline')); $doc->output($output_template); $POD->footer();
$POD = new PeoplePod(array('lockdown' => 'login', 'authSecret' => @$_COOKIE['pp_auth'], 'debug' => 0)); if (!$POD->libOptions('enable_core_friends')) { header("Location: " . $POD->siteRoot(false)); exit; } $max_friends = 20; $offset = 0; if (isset($_GET['offset'])) { $offset = $_GET['offset']; } $mode = "friends"; if (isset($_GET['mode'])) { $mode = $_GET['mode']; } if ($mode == "friends") { $people = $POD->currentUser()->friends($max_friends, $offset); $title = "My Friends"; $header = "You have " . $people->totalCount() . " " . $POD->pluralize($people->totalCount(), 'friend', 'friends'); } if ($mode == "followers") { $people = $POD->currentUser()->followers($max_friends, $offset); $title = "My Followers"; $header = "You have " . $people->totalCount() . " " . $POD->pluralize($people->totalCount(), 'follower', 'followers'); } if ($mode == "recommended") { $people = $POD->currentUser()->recommendFriends(2); $title = "Recommended Friends"; $header = "You might like these folks"; } $POD->header($header); ?>