-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathclass-rop-cron-core.php
More file actions
156 lines (129 loc) · 3.69 KB
/
class-rop-cron-core.php
File metadata and controls
156 lines (129 loc) · 3.69 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
namespace RopCronSystem;
use RopCronSystem\Curl_Helpers\Rop_Curl_Methods;
use RopCronSystem\Endpoint_Ping_Server\Rop_Debug_Ping;
use RopCronSystem\Endpoint_Ping_Server\Rop_Ping_System;
use RopCronSystem\Endpoint_Ping_Server\Rop_Registration_Check;
use RopCronSystem\Pages\Debug_Page;
use RopCronSystem\ROP_Helpers\Rop_Helpers;
if ( ! defined( 'ABSPATH' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit;
}
// ROP Cron System Server URL, no "/" slash a t the end.
define( 'ROP_CRON_DOMAIN', 'https://app.revive.social' );
/**
* Handles the load of the new Cron System.
*
* Class Rop_Cron_Core
*
* @package RopCronSystem
* @since 8.5.5
*/
class Rop_Cron_Core {
/**
* Rop_Cron_Core constructor.
*/
public function __construct() {
/**
* Register to ROP Cron the share start.
*/
add_action( 'rop_process_start_share', array( &$this, 'server_start_share' ) );
/**
* Register to ROP Cron the share stop.
*/
add_action( 'rop_process_stop_share', array( &$this, 'server_stop_share' ) );
/**
* Register to ROP Cron the next valid time to share from queue.
*/
add_action( 'rop_process_update_share_time', array( &$this, 'server_update_time_to_share' ) );
/**
* Register to ROP Cron a new account.
*/
add_action( 'rop_process_do_register', array( &$this, 'server_register_client' ) );
/**
* Register local end-points used by ROP Cron Service.
*/
add_action( 'init', array( &$this, 'init_endpoint_items' ) );
}
/**
* Register local end-points used by ROP Cron Service.
*
* @access public
* @since 8.5.5
*/
public function init_endpoint_items() {
// Share now function.
$share_now = new Rop_Ping_System();
$share_now->init_rest_api_route();
$debug = new Rop_Debug_Ping();
$debug->init_rest_api_route();
$registration_check = new Rop_Registration_Check();
$registration_check->init_rest_api_route();
new Debug_Page();
}
/**
* Register to ROP Cron the share start.
*
* @access public
* @since 8.5.5
*/
public function server_start_share() {
$time_to_share = current_time( 'timestamp' ) + 30; // phpcs:ignore
$request_call = new Rop_Curl_Methods();
$arguments = array(
'type' => 'POST',
'request_path' => ':activate_account:',
'time_to_share' => date( 'Y-m-d H:i:s', $time_to_share ),// phpcs:ignore
);
$call_response = $request_call->create_call_process( $arguments );
// TODO add to log.
}
/**
* Register to ROP Cron the share stop.
*
* @access public
* @since 8.5.5
*/
public function server_stop_share() {
$request_call = new Rop_Curl_Methods();
$arguments = array(
'type' => 'POST',
'request_path' => ':disable_account:',
);
$call_response = $request_call->create_call_process( $arguments );
// TODO add to log.
}
/**
* Register to ROP Cron the next valid time to share from queue.
*
* @access public
* @since 8.5.5
*/
public function server_update_time_to_share() {
$time_to_share = Rop_Helpers::extract_time_to_share();// This will be in UNIX time from the database queue.
$request_call = new Rop_Curl_Methods();
$arguments = array(
'type' => 'POST',
'request_path' => ':share_time:',
'time_to_share' => date( 'Y-m-d H:i:s', $time_to_share ),// phpcs:ignore
);
$call_response = $request_call->create_call_process( $arguments );
// TODO add to log.
}
/**
* Register to ROP Cron a new account.
*
* @access public
* @since 8.5.5
*/
public function server_register_client() {
$request_call = new Rop_Curl_Methods();
$arguments = array(
'type' => 'POST',
'request_path' => ':register_account:',
);
$call_response = $request_call->create_call_process( $arguments );
}
}