-
Notifications
You must be signed in to change notification settings - Fork 3
/
cron_checkusers.php
38 lines (32 loc) · 1.1 KB
/
cron_checkusers.php
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
<?php
require_once 'util.php';
function makeActiveEmail($to, $from, $subject) {
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= "To: $to \r\n";
// $headers .= "Cc: [email protected] \r\n";
$headers .= "From: $from" . "\r\n";
$subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
$content = 'Check Cron Job,from Cron';
$result = mail ( $to, $subject, $content, $headers );
if ($result) {
return TRUE;
} else {
return FALSE;
}
}
#$check_time = date_create ();
#date_sub ( $check_time, new DateInterval ( "P30D" ) );
#$time_str = $check_time->format ( 'Y-m-d' );
$time_str = date("Y-m-d",strtotime("-30 days"));
$sql = "update users set active=1 where account_type='normal' and active=0 and register!=0 and create_time < '$time_str';";
$db = getDBInstance ();
$db->query ( $sql );
$total = $db->rows_affected;
$result = makeActiveEmail ( "[email protected]", "[email protected]", "Total $total records are changed to inactive!" );
if ($result) {
echo 'OK,from cron';
} else {
echo 'Error';
}
?>