ajax
3 years ago
config
3 years ago
cron
3 years ago
css
3 years ago
fonts
3 years ago
img
3 years ago
include
3 years ago
js
3 years ago
templates
3 years ago
backups.php
3 years ago
boot.php
3 years ago
cloud.php
3 years ago
dashboardWidget.php
3 years ago
pagesContent.php
3 years ago
proFeatures.php
3 years ago
restore_wordpress.php
3 years ago
schedule.php
3 years ago
settings.php
3 years ago
support.php
3 years ago
systemInfo.php
3 years ago
videoTutorials.php
3 years ago
dashboardWidget.php
109 lines
| 1 | <?php |
| 2 | require_once SG_BACKUP_PATH . 'SGBackup.php'; |
| 3 | // Function that outputs the contents of the dashboard widget |
| 4 | function backup_guard_dashboard_widget_function($post, $callback_args) |
| 5 | { |
| 6 | $backups = SGBackup::getAllBackups(); |
| 7 | $allBackupsCount = count($backups); |
| 8 | $successBackups = 0; |
| 9 | $faildBackups = 0; |
| 10 | $inprogress = 0; |
| 11 | $warningBackups = 0; |
| 12 | $canceledBackups = 0; |
| 13 | |
| 14 | for ($i = 0; $i < $allBackupsCount; $i++) { |
| 15 | if (empty($backups[$i])) { |
| 16 | continue; |
| 17 | } |
| 18 | switch ($backups[$i]['status']) { |
| 19 | case SG_ACTION_STATUS_IN_PROGRESS_DB: |
| 20 | case SG_ACTION_STATUS_IN_PROGRESS_FILES: |
| 21 | $inprogress++; |
| 22 | break; |
| 23 | case SG_ACTION_STATUS_FINISHED_WARNINGS: |
| 24 | $warningBackups++; |
| 25 | break; |
| 26 | case SG_ACTION_STATUS_CANCELLED: |
| 27 | $canceledBackups++; |
| 28 | break; |
| 29 | case SG_ACTION_STATUS_ERROR: |
| 30 | $faildBackups++; |
| 31 | break; |
| 32 | default: |
| 33 | $successBackups++; |
| 34 | } |
| 35 | } |
| 36 | if (strpos(SG_PRODUCT_IDENTIFIER, "silver") !== false || strpos(SG_PRODUCT_IDENTIFIER, "gold") !== false) { |
| 37 | $sgb = new SGBackup(); |
| 38 | $scheduleParams = $sgb->getScheduleParamsById(SG_SCHEDULER_DEFAULT_ID); |
| 39 | $scheduleParams = backupGuardParseBackupOptions($scheduleParams); |
| 40 | $schedulesCount = strlen($scheduleParams['label']) ? 1 : 0; |
| 41 | } else if (strpos(SG_PRODUCT_IDENTIFIER, "free") === false) { // platinum |
| 42 | include_once SG_BACKUP_PATH . 'SGBackupSchedule.php'; |
| 43 | $allSchedules = SGBackupSchedule::getAllSchedules(); |
| 44 | $schedulesCount = count($allSchedules); |
| 45 | } |
| 46 | ?> |
| 47 | <div id="canvas-holder" style="width:100%"> |
| 48 | <canvas id="chart-area"></canvas> |
| 49 | </div> |
| 50 | <script> |
| 51 | function backupGuardLoadChart() { |
| 52 | var config = { |
| 53 | type: 'pie', |
| 54 | data: { |
| 55 | datasets: [{ |
| 56 | data: [ |
| 57 | <?php echo $successBackups ?>, |
| 58 | <?php echo $faildBackups ?>, |
| 59 | <?php echo $warningBackups ?>, |
| 60 | <?php echo $canceledBackups ?>, |
| 61 | <?php echo $inprogress ?> |
| 62 | |
| 63 | |
| 64 | ], |
| 65 | backgroundColor: [ |
| 66 | "#2b8b3a", |
| 67 | "#f96868", |
| 68 | "#ffb848", |
| 69 | "#7C858E", |
| 70 | "#64aed9" |
| 71 | |
| 72 | ], |
| 73 | label: 'Dataset 1' |
| 74 | }], |
| 75 | labels: [ |
| 76 | "Success (<?php echo $successBackups ?>)", |
| 77 | "Failed (<?php echo $faildBackups ?>)", |
| 78 | "Warning (<?php echo $warningBackups ?>)", |
| 79 | "Canceled (<?php echo $canceledBackups ?>)", |
| 80 | "In progress (<?php echo $inprogress ?>)", |
| 81 | ] |
| 82 | }, |
| 83 | options: { |
| 84 | responsive: true, |
| 85 | legend: { |
| 86 | labels: { |
| 87 | // This more specific font property overrides the global property |
| 88 | fontFamily: "'Source Sans Pro', 'Calibri', 'Candara', 'Arial', 'sans-serif'" |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | }; |
| 93 | <?php |
| 94 | if (isset($schedulesCount)) { |
| 95 | ?> |
| 96 | config.data.datasets[0].data.push(<?php echo $schedulesCount ?>); |
| 97 | config.data.datasets[0].backgroundColor.push("#cecece"); |
| 98 | config.data.labels.push("Schedules (<?php echo $schedulesCount ?>)"); |
| 99 | <?php } |
| 100 | ?> |
| 101 | var ctx = document.getElementById("chart-area").getContext("2d"); |
| 102 | window.backupGuardPieChart = new Chart(ctx, config); |
| 103 | } |
| 104 | |
| 105 | backupGuardLoadChart(); |
| 106 | </script> |
| 107 | <?php |
| 108 | } |
| 109 |