Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:tovanor/colorhackathon

  • Loading branch information...
commit 9b2b11ae9cf4c3734ac3e508c377718c9ad5b4b6 2 parents 779a446 + 5f95c30
Golf Sinteppadon minigolf2000 authored
Showing with 17 additions and 78 deletions.
  1. +2 −2 createthread.php
  2. +15 −76 createthreadtest.php
4 createthread.php
View
@@ -6,9 +6,9 @@
if($act == '') { // Form for user to enter
// Check if user is logged in
- if($_c['fb_user'] == NULL) {
+ if(!$_c['fb_user']) {
echo "You must be logged in to view this page!<br />";
- echo "<a href='$facebook->loginUrl'>Log in to Facebook here</a>";
+ echo "<a href='".$_c['fb']->getLoginUrl()."'>Log in to Facebook here</a>";
require_once('inc/header.inc.php');
die();
}
91 createthreadtest.php
View
@@ -5,6 +5,14 @@
$act = (isset($_POST['act']))? $_POST['act'] : '';
if($act == '') { // Form for user to enter
+ // Check if user is logged in
+ if(!$_c['fb_user']) {
+ echo "You must be logged in to view this page!<br />";
+ echo "<a href='".$_c['fb']->getLoginUrl()."'>Log in to Facebook here</a>";
+ require_once('inc/header.inc.php');
+ die();
+ }
+
?>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<input type="hidden" name="act" value="new" />
@@ -23,6 +31,13 @@
<?php
}
+ // Check if user is logged in
+ if($_c['fb_user'] == NULL) {
+ echo "You must be logged in to view this page!";
+ require_once('inc/header.inc.php');
+ die();
+ }
+
// Create a new thread
$c_mysqli->query("INSERT INTO `threads` (`num_turns`) VALUES ('1')") or die($c_mysqli->error);
$thread_id = $c_mysqli->insert_id;
@@ -37,82 +52,6 @@
// User has successfully created a new thread; redirect them to their thread's main page
?>
<meta http-equiv="REFRESH" content="0;url=showthread.php?id=<?php echo $thread_id; ?>"></HEAD>
-
-
-
-
-
-
-
-if($_SERVER['DOCUMENT_ROOT'] != "/var/www") {
- // Create our Application instance (replace this with your appId and secret).
- // Login or logout url will be needed depending on current user state.
-
- $user = $_c['fb_user'];
- $facebook = $_c['fb'];
-
- if ($user) {
- $logoutUrl = $facebook->getLogoutUrl();
- } else {
- $loginUrl = $facebook->getLoginUrl();
- }
-}
-
- ?>
-
-<p>
-Welcome to the index page!<br /><br />
-<a href="createthread.php">Create a new thread!</a>
-</p><br />
-<p>
-Search for a thread:
-</p>
-<?php
-include('search.php');
-
-echo "<br /><br />";
-
-// find and display all completed threads
-echo "Completed Threads:<br />\n";
-$completed_threads = $c_mysqli->query("SELECT * FROM `threads` WHERE `num_turns` = 10");
-while($t = $completed_threads->fetch_object()) {
- $first_thread = $c_mysqli->query("SELECT * FROM `turns` WHERE `thread_id` = '$t->id' AND `turn_number` = '1' LIMIT 1");
- $ft = $first_thread->fetch_object();
- echo '<a href="showthread.php?id=' . $t->id . '">' . $ft->content . '</a><br />';
-}
-<?php
-if($_SERVER['DOCUMENT_ROOT'] != "/var/www") {
- ?>
-
- <h1>php-sdk</h1>
-
- <?php if ($user): ?>
- <a href="<?php echo $logoutUrl; ?>">Logout</a>
- <?php else: ?>
- <div>
- Login using OAuth 2.0 handled by the PHP SDK:
- <a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
- </div>
- <?php endif ?>
-
- <?php if ($user): ?>
- <h3>You</h3>
- <img src="https://graph.facebook.com/<?php echo $user; ?>/picture">
- <?php else: ?>
- <strong><em>You are not Connected.</em></strong>
- <?php endif ?>
-<?php
-}
-?>
-
-
-
-
- <textarea id="select_friend">
- </textarea>
- <script type="text/javascript">
- $("#select_friend").autoComplete("http://graph.facebook.com/<%=$user%>/friends",);
- </script>
<?php
}
Please sign in to comment.
Something went wrong with that request. Please try again.