Create PHP news site with admin dashboard and Shopee ad flow#34
Create PHP news site with admin dashboard and Shopee ad flow#34
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!$post) { | ||
| $stmt = $pdo->prepare('SELECT * FROM articles WHERE slug = :slug LIMIT 1'); | ||
| $stmt->execute([':slug' => $slug]); | ||
| $post = $stmt->fetch(); |
There was a problem hiding this comment.
Restrict draft posts from public access
The post page loads any article by slug without checking status, so unpublished drafts are rendered to anyone who knows or guesses the slug. Because new articles default to draft, a public request to /some-slug will reveal the draft content even though it was never published. Filter by status='public' or require authentication before serving the article.
Useful? React with 👍 / 👎.
| $id = (int)($_GET['id'] ?? 0); | ||
| $stmt = $pdo->prepare('DELETE FROM articles WHERE id = :id'); | ||
| $stmt->execute([':id' => $id]); |
There was a problem hiding this comment.
Add CSRF protection to post deletion
The delete endpoint deletes articles on a GET request without validating a CSRF token. A malicious page can therefore embed an image or link to /admin/post_delete.php?id=… and, if an admin is logged in, their browser will delete the post without consent. Destructive actions should be POST-only with CSRF verification to prevent cross-site deletes.
Useful? React with 👍 / 👎.
| 'CACHE_TTL' => 60, | ||
| 'TELEGRAM_BOT_TOKEN' => '', | ||
| 'TELEGRAM_ADMIN_CHAT_ID' => '', | ||
| 'APP_DEBUG' => true, | ||
| 'LOG_PATH' => __DIR__ . '/logs/app.log', |
There was a problem hiding this comment.
Move error log out of the public web root
Error logging is configured to write to public_html/logs/app.log, which sits under the publicly served web root and is not blocked by .htaccess, so anyone can download server error logs (including stack traces and DB errors) via /logs/app.log when APP_DEBUG is off. Store logs outside the document root or deny HTTP access to that path to avoid leaking sensitive information.
Useful? React with 👍 / 👎.
Summary
Testing
Codex Task