-
-
Notifications
You must be signed in to change notification settings - Fork 37
Update post.class.php #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
el-choco
wants to merge
44
commits into
m1k1o:master
Choose a base branch
from
el-choco:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 30 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
48bffc6
Update post.class.php
el-choco e97ff1f
file to delete not deleted Posts in DB
el-choco c3adfdc
Update post.class.php
el-choco fdbd589
integrate some functions
el-choco 7886cbe
Update config.ini
el-choco c437364
Update README.md
el-choco 67955c5
Update README.md
el-choco 194aeea
Update README.md
el-choco a0023a7
Update README.md
el-choco 658a8c4
Update README.md
el-choco 88155cf
Update README.md
el-choco 2625541
Update README.md
el-choco 5ccd8b7
added some functionality
el-choco 327b865
Update config.ini
el-choco 15d1b09
Update README.md
el-choco addb373
Update README.md
el-choco 49cee29
Update README.md
el-choco 1dc88ae
Update README.md
el-choco 6f3b15e
added Toggle-Button functionality
el-choco cf5d371
added Toggle-Button functionality
el-choco 8cb89a5
added collapse/ expand Animation
el-choco 5996831
added Show Less = "Show Less"
el-choco 425fdd9
Update config.ini
el-choco 1441ade
Delete convert_bbcode_to_markdown.php
el-choco 8952382
Delete app/convert_bbcode_to_markdown.php
el-choco f643549
added function to upload more the 1 image!
el-choco 301680e
added function to Upload more then 1 image.
el-choco 1182e4a
added function to Upload more then 1 image.
el-choco 83ef3a5
Bugfix Toggle Button.
el-choco 9ff530b
Update blog service image and port configuration
el-choco 0058d0f
changed comments language to english
el-choco d5a25bf
changed comments language to english
el-choco 7270351
changed comments language to english
el-choco ed6e73b
Add files via upload
el-choco 744954f
Add files via upload
el-choco 7d9892f
Add files via upload
el-choco 5006f0c
Add files via upload
el-choco 67c222f
update all Files
el-choco daba15f
Add files via upload
el-choco 3c3d993
update all Files
el-choco 1dab724
Add files via upload
el-choco 727eb0c
Add files via upload
el-choco a65f494
Add files via upload
el-choco b1a06a7
Add files via upload
el-choco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| <?php | ||
| /** | ||
| * Cleanup Posts Script | ||
| * Run this script periodically to clean up orphaned images and old data | ||
| * | ||
| * Usage: php cleanup_posts.php | ||
| * Or set up as a cron job: 0 2 * * * php /path/to/cleanup_posts.php | ||
| */ | ||
|
|
||
| // Include required files | ||
| require_once __DIR__ . '/config.class.php'; | ||
| require_once __DIR__ . '/db.class.php'; | ||
| require_once __DIR__ . '/image.class.php'; | ||
| require_once __DIR__ . '/log.class.php'; | ||
|
|
||
| // Only allow CLI execution | ||
| if (php_sapi_name() !== 'cli') { | ||
| die('This script can only be run from command line'); | ||
| } | ||
|
|
||
| // Initialize | ||
| try { | ||
| echo "Starting cleanup process...\n"; | ||
| echo "----------------------------\n\n"; | ||
|
|
||
| // Load configuration | ||
| $config = new Config(); | ||
| echo "✓ Configuration loaded\n"; | ||
|
|
||
| // Connect to database | ||
| $db = DB::getInstance($config); | ||
| echo "✓ Database connected\n"; | ||
|
|
||
| // Initialize classes | ||
| $image = new Image($config); | ||
| $log = new Log($config); | ||
| echo "✓ Classes initialized\n\n"; | ||
|
|
||
| // 1. Clean up orphaned images | ||
| echo "1. Cleaning up orphaned images...\n"; | ||
| $deleted_images = $image->cleanupOrphanedImages($db->getPDO()); | ||
| echo " Deleted $deleted_images orphaned image(s)\n\n"; | ||
|
|
||
| // 2. Clean up old log files | ||
| echo "2. Cleaning up old log files...\n"; | ||
| $log_retention_days = $config->get('log_retention_days', 30); | ||
| $deleted_logs = $log->cleanOldLogs($log_retention_days); | ||
| echo " Deleted $deleted_logs old log file(s)\n\n"; | ||
|
|
||
| // 3. Rotate large log files | ||
| echo "3. Rotating large log files...\n"; | ||
| $log_files = $log->getLogFiles(); | ||
| $rotated_count = 0; | ||
| foreach ($log_files as $log_file) { | ||
| if ($log->rotateLog($log_file)) { | ||
| $rotated_count++; | ||
| echo " Rotated: $log_file\n"; | ||
| } | ||
| } | ||
| echo " Rotated $rotated_count log file(s)\n\n"; | ||
|
|
||
| // 4. Clean up deleted user data | ||
| echo "4. Cleaning up deleted user data...\n"; | ||
| $stmt = $db->prepare(" | ||
| DELETE FROM posts | ||
| WHERE user_id NOT IN (SELECT id FROM users) | ||
| "); | ||
| $stmt->execute(); | ||
| $deleted_posts = $stmt->rowCount(); | ||
| echo " Deleted $deleted_posts orphaned post(s)\n\n"; | ||
|
|
||
| // 5. Optimize database (SQLite only) | ||
| if ($db->getType() === 'sqlite') { | ||
| echo "5. Optimizing database...\n"; | ||
| $db->exec('VACUUM'); | ||
| $db->exec('ANALYZE'); | ||
| echo " Database optimized\n\n"; | ||
| } | ||
|
|
||
| // 6. Database statistics | ||
| echo "6. Database statistics:\n"; | ||
| $stmt = $db->query("SELECT COUNT(*) FROM users"); | ||
| $user_count = $stmt->fetchColumn(); | ||
| echo " Total users: $user_count\n"; | ||
|
|
||
| $stmt = $db->query("SELECT COUNT(*) FROM posts"); | ||
| $post_count = $stmt->fetchColumn(); | ||
| echo " Total posts: $post_count\n"; | ||
|
|
||
| $stmt = $db->query("SELECT COUNT(*) FROM posts WHERE is_sticky = 1"); | ||
| $sticky_count = $stmt->fetchColumn(); | ||
| echo " Sticky posts: $sticky_count\n\n"; | ||
|
|
||
| // Log cleanup completion | ||
| $log->log("Cleanup completed: $deleted_images images, $deleted_logs logs, $deleted_posts orphaned posts"); | ||
|
|
||
| echo "----------------------------\n"; | ||
| echo "Cleanup completed successfully!\n"; | ||
|
|
||
| } catch (Exception $e) { | ||
| echo "ERROR: " . $e->getMessage() . "\n"; | ||
| if (isset($log)) { | ||
| $log->error("Cleanup failed: " . $e->getMessage()); | ||
| } | ||
| exit(1); | ||
| } | ||
|
|
||
| exit(0); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The comment is in German while the rest of the codebase uses English comments. For consistency, consider:
// IMPORTANT: JSON_UNESCAPED_UNICODE ensures emojis are transmitted correctlyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it should be in EN.