-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcron.php
More file actions
47 lines (40 loc) · 1.67 KB
/
cron.php
File metadata and controls
47 lines (40 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
// مهمة كرون لمعالجة المنشورات المجدولة - CRON task for processing scheduled posts
require_once 'config.php';
require_once 'functions.php';
require_once 'content_generator.php';
require_once 'scheduler.php';
// تسجيل الخطأ في حالة وجود استثناء - Log error in case of exception
set_exception_handler(function($e) {
logError('استثناء غير معالج في كرون', $e->getMessage() . ' في ' . $e->getFile() . ':' . $e->getLine());
exit(1);
});
/**
* الوظيفة الرئيسية لعملية كرون - Main function for CRON job
*/
function runCronJob() {
try {
// معالجة المنشورات المجدولة - Process scheduled posts
$processed = processScheduledPosts();
// جدولة منشورات جديدة حسب الحاجة - Schedule new posts as needed
$settings = getSettings();
if ($settings['active']) {
$created = schedulePostsForToday();
if ($created !== false) {
echo "تم إنشاء $created منشورات جديدة.\n";
}
}
if ($processed) {
echo "تم معالجة المنشورات المجدولة بنجاح.\n";
} else {
echo "لم يتم العثور على منشورات جاهزة للنشر.\n";
}
} catch (Exception $e) {
logError('فشلت عملية كرون', $e->getMessage());
echo "حدث خطأ: " . $e->getMessage() . "\n";
exit(1);
}
}
// التنفيذ الرئيسي - Main execution
runCronJob();
?>