示例#1
0
文件: forum.php 项目: Areadrill/ltw
<?
session_start();
if(!isset($_GET['id'])){
  header('Location: index.php');
}
require_once('database/get_forum.php');
?>

<!DOCTYPE html>
<html>
  <head>
    <?require_once('includes.php');?>
  </head>
  <body>
    <?require_once('templates/header.php');?>
    <?getEventThreads($_GET['id']);?>
  </body>
</html>
示例#2
0
function getEvent($id){

  $db = new PDO('sqlite:database/db/EventagerDB.db');
  $stmt = $db->prepare('SELECT * FROM Event WHERE eid=?');
  $stmt->execute(array($id));
  $res = $stmt->fetch();

  $stmt = $db->prepare('SELECT fpath FROM Image WHERE iid=?');
  $stmt->execute(array($res['eimage']));
  $imgPath = $stmt->fetch();

  $stmt = $db->prepare('SELECT uid FROM EventFollower WHERE eid=?');
  $stmt->execute(array($res['eid']));
  $following = $stmt->fetchAll();

  $stmt = $db->prepare('SELECT uid FROM EventOwner WHERE eid=?');
  $stmt->execute(array($id));
  $owner = $stmt->fetch();

  $stmt = $db->prepare('SELECT uname FROM User WHERE uid=?');
  $stmt->execute(array($owner['uid']));
  $creatorName = $stmt->fetch();

  $stmt = $db->prepare('SELECT count(uid) AS attendees FROM EventFollower WHERE eid=?');
  $stmt->execute(array($id));

  $attendeeCount = $stmt->fetch();
  //print_r($attendeeCount);
?>
<input id="eventIdField" type="text" value="<?echo $res["eid"];?>" hidden="hidden"/>
<section id="event">
<div id="coverImage">
<img src="<?echo $imgPath['fpath']?>" id="mainimage"/>
<h1 id="eventTitle"><span id="nameAndauthor"><?echo $res['ename']?> <br> <div id="author"> created by <?echo $creatorName['uname']?></div></span></h1>
</div>

<p class="eventInfo"><?echo $attendeeCount['attendees']?> attending</p>
<? $alreadyFollowing = FALSE;
foreach($following as $follower){
  if($_SESSION['id'] === $follower['uid']){
    $alreadyFollowing = TRUE;
    break;
  }
}
if(!$alreadyFollowing){
  ?><button id="followButton" class="eventInfo"> Follow </button>
<?//<a href="database/action_addFollower.php?eventId=<?echo $res['eid']\?\>">?>
<?}
else{
  ?><button id="unfollowButton" class="eventInfo"> Unfollow </button><?
}?>

<p id="date" class="eventInfo">When: <?echo $res['edate']?></p>

<div id="description">
<h1>Description:</h1>
  <p><?echo $res['description']?></p>
</div>


<div id="albums">
<h2>Albums</h2>
<ul>
<?
  require_once("database/album.php");
  $albums = getAlbums($id);
  foreach($albums as $album){
    $thumbPath = getAlbumThumbPath($album);
    ?>
    <li>
      <div class="album">
        <a href="view_album.php?id=<?echo $album['aid']?>" target="_blank">
          <img class="albumDisplay" src="<? print($thumbPath); ?>" alt="<? echo $album['nome']?>" width="110" height="90"/>
          <span class="albumName albumDisplay"> <? echo $album['nome']; ?> </span>
        </a>
      </div>
    </li>
    <?
  }
?>
  <a id="createAlbumButton" href="javascript:;">Add Album</a>
</ul>
</div>

<div id="albumCreation" class="hiddenForm">
  <form id="albumCreationForm" action="database/action_createAlbum.php" method="post" enctype="multipart/form-data">
    <input type="hidden" id="csrf" name="csrf" value="<?echo $_SESSION['tok']?>" />
    <label>Album Name:</label>
    <input type="text" name="albumName"/>
    <br>
    <input type="submit" value="Create album!"/>
   </form>
</div>

<?
getEventThreads($res['eid']);?>
</section>
<?
//ainda falta meter o forum funcional, opçoes pro owner, ...
}