1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Puerari\Cwp; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @trait Cronjob |
7
|
|
|
* @package Puerari\Cwp |
8
|
|
|
* @author Leandro Puerari <[email protected]> |
9
|
|
|
*/ |
10
|
|
|
trait Cronjob |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @param string $user : User owners of the scheduled tasks |
14
|
|
|
* @param string $execute : Frequency with which to execute the cron Example: * * * * * * |
15
|
|
|
* @param string $command : Command to execute, Example: /usr/bin/php test.php |
16
|
|
|
* @return string|bool: false on failure, result on success (JSON / XML) |
17
|
|
|
* status -> OK |
18
|
|
|
* status -> Error -> user does not exist |
19
|
|
|
*/ |
20
|
|
|
public function createCronJob(string $user, string $execute, string $command) |
21
|
|
|
{ |
22
|
|
|
$this->data = compact('user', 'execute', 'command'); |
|
|
|
|
23
|
|
|
$this->data['debug'] = $this->debug; |
24
|
|
|
$this->data['action'] = 'add'; |
25
|
|
|
$this->cwpuri = 'cronjobsusers'; |
|
|
|
|
26
|
|
|
return $this->execCurl(); |
|
|
|
|
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param string $user : User owners of the scheduled tasks |
31
|
|
|
* @param string $execute : Frequency with which to execute the cron Example: * * * * * * |
32
|
|
|
* @param string $command : Command to execute, Example: /usr/bin/php test.php |
33
|
|
|
* @return string|bool: false on failure, result on success (JSON / XML) |
34
|
|
|
* status -> OK |
35
|
|
|
* status -> Error -> user does not exist |
36
|
|
|
* status -> Error -> domain does not exist |
37
|
|
|
*/ |
38
|
|
|
public function deleteCronJob(string $user, string $execute, string $command) |
39
|
|
|
{ |
40
|
|
|
$this->data = compact('user', 'execute', 'command'); |
|
|
|
|
41
|
|
|
$this->data['debug'] = $this->debug; |
42
|
|
|
$this->data['action'] = 'del'; |
43
|
|
|
$this->cwpuri = 'cronjobsusers'; |
|
|
|
|
44
|
|
|
return $this->execCurl(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param string $user : Account user name |
49
|
|
|
* @return string|bool: false on failure, result on success (JSON / XML) |
50
|
|
|
* status -> OK |
51
|
|
|
* status -> Error -> user does not exist |
52
|
|
|
*/ |
53
|
|
|
public function listCronJobs(string $user) |
54
|
|
|
{ |
55
|
|
|
$this->data = compact('user'); |
|
|
|
|
56
|
|
|
$this->data['debug'] = $this->debug; |
57
|
|
|
$this->data['action'] = 'list'; |
58
|
|
|
$this->cwpuri = 'cronjobsusers'; |
|
|
|
|
59
|
|
|
return $this->execCurl(); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|