Exemplo n.º 1
0
    }
    ?>
><a href="articles.php">Articles</a></li>
                    <li <?php 
    if ($page == 'blog') {
        echo 'class="active"';
    }
    ?>
><a href="blog.php">Categories et Tags</a></li>
                </ul>
            </li>
            <?php 
}
?>
            <?php 
if (haveRole('admin')) {
    ?>
            <li>
                <p><i class="fa fa-files-o"></i> <span class="nav-label">CMS</span></p>
                <ul class="nav nav-second-level collapse in">
                    <li <?php 
    if ($page == 'carousel') {
        echo 'class="active"';
    }
    ?>
><a href="carousel.php">Accueil</a></li>
                    <li <?php 
    if ($page == 'hardware') {
        echo 'class="active"';
    }
    ?>
Exemplo n.º 2
0
    ?>
						<tr>
							<td><?php 
    echo $article['title'];
    ?>
</td>
							<td><?php 
    echo date('d/m/Y', $article['timestamp']);
    ?>
</td>
							<td><?php 
    echo $article['category'];
    ?>
</td>
							<td><?php 
    echo haveRole('moderator') ? '<a href="articles.php?comments=' . $article['id'] . '">' . $article['nb_comments'] . '</a>' : $article['nb_comments'];
    ?>
</td>
							<td>
								<a href="articles.php?edit=<?php 
    echo $article['id'];
    ?>
" title="Editer l'article" data-toggle="modal" class="btn btn-warning"><span class="fa fa-edit"></span></a>
								<a href="articles.php?delete=<?php 
    echo $article['id'];
    ?>
" title="Supprimer l'article" class="btn btn-danger"><span class="fa fa-trash-o"></span></a>
							</td>
						</tr>
					<?php 
}
Exemplo n.º 3
0
<?php

require 'init.php';
if (!isLogged() || !haveRole('admin')) {
    header('Location: login.php');
}
// File upload failed
$error = false;
if (getVar('badfile') || getVar('upfail')) {
    $id = getVar('badfile') + getVar('upfail');
    $deleteUserQuery = $dbh->prepare("DELETE FROM name WHERE id = :id");
    $deleteUserQuery->execute(array(':id' => $id));
    $deleteUserQuery->closeCursor();
    if (getVar('badfile')) {
        $error = 'Mauvais fichier!';
    } else {
        $error = 'Erreur d\'upload';
    }
}
if (getVar('add')) {
    $addUserQuery = $dbh->prepare("INSERT INTO tools (name, smalldesc, description) VALUES (:name, :smalldesc, :description)");
    $addUserQuery->execute(array(':name' => getVar('name'), ':smalldesc' => getVar('smalldesc'), ':description' => getVar('description')));
    $addUserQuery->closeCursor();
    $elementId = $dbh->lastInsertId();
    $newname = $_SERVER["DOCUMENT_ROOT"] . '/fablab/img/tools/' . $elementId . '.jpg';
    //debug($_FILES);
    if (!empty($_FILES['picture']) && $_FILES['picture']['error'] == 0) {
        $filename = basename($_FILES['picture']['name']);
        $ext = substr($filename, strrpos($filename, '.') + 1);
        if (getimagesize($_FILES['picture']['tmp_name']) && $_FILES["picture"]["size"] < 4000000) {
            if (!file_exists($newname) && move_uploaded_file($_FILES['picture']['tmp_name'], $newname)) {
Exemplo n.º 4
0
    $articleQuery = $dbh->prepare("SELECT title, description, category_id, content FROM blog_articles WHERE id = :id");
    $articleQuery->execute(array(':id' => getVar('edit')));
    $article = $articleQuery->fetch();
    $articleQuery->closeCursor();
    $articleTagsQuery = $dbh->prepare("SELECT tag_id FROM blog_articles_tags WHERE article_id = :article_id");
    $articleTagsQuery->execute(array(':article_id' => getVar('edit')));
    $articleTagsRaw = $articleTagsQuery->fetchAll();
    $articleTagsQuery->closeCursor();
    $articleTags = array();
    foreach ($articleTagsRaw as $articleTag) {
        $articleTags[$i++] = $articleTag['tag_id'];
    }
    render('editor', array('action' => 'edit', 'categories' => $categories, 'tags' => $tags, 'article' => $article, 'articleTags' => $articleTags));
}
if (getVar('comments')) {
    if (!haveRole('moderator')) {
        header('Location: articles.php');
    }
    // Delete the comment
    if (getVar('delete')) {
        $deleteArticleQuery = $dbh->prepare("DELETE FROM blog_comments WHERE id = :id");
        $deleteArticleQuery->execute(array(':id' => getVar('delete')));
        $deleteArticleQuery->closeCursor();
        header('Location: articles.php?comments=' . getVar('comments'));
    }
    // Else, render the list
    $commentsQuery = $dbh->prepare("SELECT id, nickname, email, content FROM blog_comments WHERE article_id = :article_id ORDER BY id DESC");
    $commentsQuery->execute(array(':article_id' => getVar('comments')));
    $comments = $commentsQuery->fetchAll();
    $commentsQuery->closeCursor();
    render('comments', array('comments' => $comments));