PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 6.0.6
Taskbuilder – Project Management & Task Management Tool With Kanban Board v6.0.6
6.0.6 6.0.5 6.0.2 6.0.3 6.0.4 6.0.1 6.0.0 5.0.8 5.0.9 4.0.9 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 All 58 releases
← All changes | includes/actions/wppm_check_cron_attachment.php +48 -38 1.0.16.0.6 View file →
@@ -1,38 +1,48 @@
1 -<?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - exit; // Exit if accessed directly
4 -}
5 -global $wpdb;
6 -$garbage_collection_time = get_option('wppm_garbage_collection_time' ,'');
7 -$check_flag = false;
8 -$now = time();
9 -$ago = strtotime($garbage_collection_time);
10 -$diff = $now - $ago;
11 -if($diff >= 86400){
12 - $check_flag = true;
13 -}
14 -if(!$check_flag){
15 - return;
16 -}
17 -$attachments=$wpdb->get_results("select * from {$wpdb->prefix}wppm_attachments where is_active=0");
18 -if($attachments){
19 - foreach($attachments as $attachment){
20 - $created_time = $attachment->date_created;
21 - $upload_dir = wp_upload_dir();
22 - $time = strtotime($created_time);
23 - $month = date("m",$time);
24 - $year = date("Y",$time);
25 - $filepath = $upload_dir['basedir'] . '/wppm/'.'/'.$year.'/'.$month.'/'. $attachment->name;
26 - $attachment_updated_time = strtotime($created_time);
27 - $now = time();
28 - $diff = $now - $attachment_updated_time;
29 - if($diff > 86400){
30 - $wpdb->delete($wpdb->prefix.'wppm_attachments', array( 'id' => $attachment->id));
31 - if(file_exists($filepath)){
32 - unlink($filepath);
33 - }
34 - }
35 - }
36 -}
37 -update_option('wppm_garbage_collection_time', date("Y-m-d H:i:s"));
38 -
1 +<?php
2 +if ( ! defined( 'ABSPATH' ) ) {
3 + exit; // Exit if accessed directly
4 +}
5 +global $wpdb;
6 +$garbage_collection_time = get_option('wppm_garbage_collection_time' ,'');
7 +if ( empty( $garbage_collection_time ) ) {
8 + update_option( 'wppm_garbage_collection_time', current_time( 'mysql' ) );
9 + return;
10 +}
11 +$check_flag = false;
12 +$now = current_time( 'timestamp' );
13 +$ago = strtotime($garbage_collection_time);
14 +$diff = $now - $ago;
15 +if($diff >= DAY_IN_SECONDS){
16 + $check_flag = true;
17 +}
18 +if(!$check_flag){
19 + return;
20 +}
21 +$attachments=$wpdb->get_results(("select id,name,date_created from {$wpdb->prefix}wppm_attachments where is_active=0"));
22 +if($attachments){
23 + foreach($attachments as $attachment){
24 + $created_time = $attachment->date_created;
25 + $upload_dir = wp_upload_dir();
26 + $time = strtotime($created_time);
27 + $month = wp_date("m",$time);
28 + $year = wp_date("Y",$time);
29 + $filename = sanitize_file_name( $attachment->name );
30 + $filepath = $upload_dir['basedir'] . '/wppm/'.'/'.$year.'/'.$month.'/'. $filename;
31 + $attachment_updated_time = strtotime($created_time);
32 + $diff = $now - $attachment_updated_time;
33 + if($diff > DAY_IN_SECONDS){
34 + $attachment_id = absint( $attachment->id );
35 + $wpdb->delete(
36 + $wpdb->prefix . 'wppm_attachments',
37 + array( 'id' => $attachment_id ),
38 + array( '%d' )
39 + );
40 + if(file_exists($filepath)){
41 + //unlink($filepath);
42 + wp_delete_file($filepath);
43 + }
44 + }
45 + }
46 +}
47 +update_option('wppm_garbage_collection_time', current_time( 'mysql' ) );
48 +