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