implemented admin control panel with the ability to delete articles/users in bulk, and open user panels with the standard options to reset passwords, change email/usernames, or delete. additionally, updated SQL schema, created dummy data, and fixed some bugs.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
require 'db_functions.php';
|
||||
require_once 'db_functions.php';
|
||||
|
||||
function article_ids_by_recency()
|
||||
{
|
||||
@@ -14,6 +14,19 @@ function article_ids_by_recency()
|
||||
return $ids;
|
||||
}
|
||||
|
||||
function articles_ids_by_author($author_id)
|
||||
{
|
||||
$query = 'SELECT article_id FROM article ORDER BY published_at DESC WHERE author_id = ' . $author_id . ';';
|
||||
$results = query_one_or_more_results($query);
|
||||
|
||||
$ids = [];
|
||||
|
||||
while ($row = mysqli_fetch_array($results))
|
||||
$ids[] = $row['article_id'];
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
function article_tags()
|
||||
{
|
||||
$query = 'SELECT * FROM tags;';
|
||||
@@ -63,7 +76,7 @@ function article_page_from_markdown($article_id)
|
||||
<p>Published on ' . $article['published_at'] . '</p>
|
||||
</div>
|
||||
<div class="card_pic_box">
|
||||
<img src="' . $_ENV['PROFILE_IMAGES_PQ_PATH'] . '"' . $author['profile_picture'] . '" class="card_profile_picture" />
|
||||
<img src="' . $_ENV['PROFILE_IMAGES_PQ_PATH'] . $author['profile_picture'] . '" class="card_profile_picture" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="line" style="margin-bottom: 15px;"></div>
|
||||
@@ -129,8 +142,10 @@ function create_article($author_id, $title, $excerpt, $tags, $markdown_file_cont
|
||||
$stmt = 'INSERT INTO article (author_id, title, excerpt, published_at) VALUES (' . $author_id . ', "' . $title . '", "' . $excerpt . '", CURRENT_TIMESTAMP);';
|
||||
$id = exec_statement($stmt, 0);
|
||||
|
||||
$path = $_ENV['ARTICLES_PQ_PATH'] . $id . '/';
|
||||
$path = $_ENV['ARTICLES_FQ_PATH'] . $id . '/';
|
||||
mkdir($path);
|
||||
echo '<p>created ' . $path . '</p>';
|
||||
|
||||
$fs = fopen($path . 'article.md', 'a');
|
||||
fwrite($fs, $markdown_file_contents);
|
||||
fclose($fs);
|
||||
@@ -146,8 +161,6 @@ function create_article($author_id, $title, $excerpt, $tags, $markdown_file_cont
|
||||
$stmt .= ';';
|
||||
}
|
||||
|
||||
echo $stmt;
|
||||
pretty_dump($tags);
|
||||
if (count($tags) > 0)
|
||||
exec_statement($stmt, 0);
|
||||
|
||||
@@ -156,8 +169,13 @@ function create_article($author_id, $title, $excerpt, $tags, $markdown_file_cont
|
||||
|
||||
function delete_article($article_id)
|
||||
{
|
||||
$stmt = 'DELETE FROM article_tags WHERE article_id = ' . $article_id . ';';
|
||||
exec_statement($stmt, 1);
|
||||
|
||||
$stmt = 'DELETE FROM article WHERE article_id = ' . $article_id . ';';
|
||||
return exec_statement($stmt, 1);
|
||||
exec_statement($stmt, 1);
|
||||
|
||||
delete_dir($_ENV['ARTICLES_FQ_PATH'] . $article_id . '/');
|
||||
}
|
||||
|
||||
function delete_articles_by_author($author_id)
|
||||
@@ -165,3 +183,9 @@ function delete_articles_by_author($author_id)
|
||||
$stmt = 'DELETE FROM article WHERE author_id = "' . $author_id . '";';
|
||||
return exec_statement($stmt, 1);
|
||||
}
|
||||
|
||||
function increment_read_counter($article_id)
|
||||
{
|
||||
$stmt = 'UPDATE article SET read_count = read_count + 1 WHERE article_id = ' . $article_id . ';';
|
||||
return exec_statement($stmt, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user