-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaction.php
56 lines (44 loc) · 1.09 KB
/
action.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/* se llama a traves de consola para ejecutar acciones largas en segundo plano */
include("./conf.inc.php");
include('./modules/common.inc.php');
class GUI {
function debug($txt) {
if($txt == '') return;
echo "D: ".print_r($txt, true)." \n";
}
function debuga($txt) {
if($txt == '') return;
echo "D: ".print_r($txt, true)." \n";
}
function session_info($txt) {
$this->debug("SESSION INFO: ".$txt);
}
function session_error($txt) {
$this->debug("SESSION ERROR:".$txt);
}
}
$gui = new GUI();
$args=ParseCMDArgs();
if (! isset($args['ip'])) {
die("no ip\n");
}
if (! isset($args['action'])) {
die("no action\n");
}
include("./classes/ldap.class.php");
include("./classes/winexe.class.php");
$ldap=new LDAP();
if ( checkIP($args['ip']) != $args['ip']) {
$computers=$ldap->get_computers($args['ip']. '$');
$computer=$computers[0];
}
else {
$computer=$ldap->get_computer_by_ip($args['ip']);
}
if ( ! $computer->action($args['action'], $computer->macAddress)) {
echo ("error");
}
else {
echo ("ok");
}