Example #1
0
  </header>
  <?php 
$authors = getAuthorsArchive();
if ($authors->count() > 0) {
    ?>
    <ul>
    <?php 
    foreach ($authors as $author) {
        ?>
      <li>
        <a href="<?php 
        echo $author->url();
        ?>
">
          <?php 
        echo getAuthorName($author->name());
        ?>
 (<?php 
        echo $author->results();
        ?>
)
        </a>
      </li>
    <?php 
    }
    ?>
    </ul>
  <?php 
} else {
    ?>
    <p><strong>No authors found.</strong></p>
                ?>
">
													<?php 
                echo $result->title()->html();
                ?>
												</a>
											</h2>
											<div class="meta">
												<span class="author">Posted by <a href="<?php 
                echo $site->url();
                ?>
/author/<?php 
                echo urlencode($result->author());
                ?>
"><?php 
                echo getAuthorName((string) $result->author());
                ?>
</a></span> on <time datetime="<?php 
                echo $result->date('Y-m-d');
                ?>
"><?php 
                echo $result->date(c::get('posts-date-format'));
                ?>
</time>
											</div>
										</header>
										<div class="post-content col-xs-12">
											<?php 
                echo getPostExcerpt($result);
                ?>
										</div>
    ?>
">
							<?php 
    echo $post->title()->html();
    ?>
						</a>
					</h2>
					<div class="meta">
						<span class="author">Posted by <a href="<?php 
    echo $site->url();
    ?>
/author/<?php 
    echo urlencode($post->author());
    ?>
"><?php 
    echo getAuthorName((string) $post->author());
    ?>
</a></span> on <time datetime="<?php 
    echo $post->date('Y-m-d');
    ?>
"><?php 
    echo $post->date(c::get('posts-date-format'));
    ?>
</time>
					</div>
					<?php 
    echo getCoverImage($post, array('class' => 'img-responsive'));
    ?>
				</header>
				<div class="post-content col-xs-12">
					<?php 
include 'create-recipe-form.php';
include 'db-credentials.php';
//check if valid url or logged in
if (!isset($_GET['recipe_id']) || !isset($_SESSION['loggedin'])) {
    header('Location: fail.php');
}
//get recipe id
$recipeId = $_GET['recipe_id'];
//get logged username
$user = $_SESSION["username"];
//connect to db
$conn = connectToDb($servername, $username, $password, $dbname);
//get recipe name
$recipeName = getRecipeNameFromDB($conn, $recipeId);
//get author name
$authorName = getAuthorName($conn, $recipeId);
//check if valid id or not original author
if ($recipeName == '' || $authorName != $user) {
    header('Location: fail.php');
}
//if submit
if ($_SERVER['REQUEST_METHOD'] == "POST") {
    //delete everything
    removeRecipe($conn, $recipeId);
    header('Location: my-recipes.php');
}
?>

<!DOCTYPE html>
<html>
	
<?php

return function ($site, $pages, $page, $data) {
    // get all posts
    $posts = $site->find(c::get('posts-page'))->children()->visible()->flip();
    $archiveTitle = null;
    // filter by author
    if (isset($data['author'])) {
        $author = urldecode($data['author']);
        $posts = $posts->filterBy('author', $author);
        $archiveTitle = ' for author "' . getAuthorName($author) . ' (' . $author . ')"';
    }
    // filter by tag
    if (isset($data['tag'])) {
        $tag = urldecode($data['tag']);
        $posts = $posts->filterBy('tags', $tag, ',');
        $archiveTitle = ' for tag "' . $tag . '"';
    }
    // filter by category
    if (isset($data['category'])) {
        $category = urldecode($data['category']);
        $posts = $posts->filterBy('category', $category);
        $archiveTitle = ' for category "' . $category . '"';
    }
    // filter by year
    if (isset($data['year'])) {
        $year = $data['year'];
        $postsYear = new Pages();
        foreach ($posts as $a) {
            if ($a->date('Y') == $year) {
                $postsYear->add($a);
Example #6
0
 $GLOBALS['star'] = new \Fr\Star(array());
 function getAuthorName($id = 1)
 {
     $sql = \Lobby\DB::getDBH()->prepare("SELECT `name` FROM `users` WHERE `id` = ?");
     $sql->execute(array($id));
     return $sql->fetchColumn();
 }
 function getRating($id)
 {
     $GLOBALS['star']->id = "app-{$id}";
     return $GLOBALS['star']->getRating("", "rate_value");
 }
 $i = 0;
 foreach ($results as $r) {
     $response['apps'][$i] = $r;
     $response['apps'][$i]['author'] = getAuthorName($r['author']);
     $response['apps'][$i]['author_page'] = \Lobby::u("/u/{$r['author']}");
     $response['apps'][$i]['description'] = $Parsedown->text(htmlspecialchars($r['description']));
     $response['apps'][$i]['image'] = L_URL . "/api/app/{$r['id']}/logo";
     $response['apps'][$i]['permalink'] = L_URL . "/apps/{$r['id']}";
     $response['apps'][$i]['rating'] = getRating($r['id']) . "/5";
     $response['apps'][$i]['requires'] = json_decode($r['requires'], true);
     /**
      * If `lobby` param is not present then,
      * client is using Lobby < 0.6
      */
     if (!isset($_POST["lobby"])) {
         $response['apps'][$i]['requires']["lobby"] = array(">=", "0.6");
     }
     /**
      * Recommended : Singular word