forked from eduardocruz/WhatsApp-Tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperfil.php
132 lines (97 loc) · 3.22 KB
/
perfil.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
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
<html>
<head>
<title>WA Tools</title>
</head>
<body>
<div>
<div>
<div>
<div>
<div>
<div></div>
<div>
<div>
<h2>WA Tools</h2>
<ol>
<li>
<div>
<h3>Información del contacto / Contact information</h3>
<ul>
</ul>
<?php
$username = '';
$password = '';
$debug = false;
$contacts = $_POST["pais"].$_POST["numero"];
$msg = $_POST["mensaje"];
set_time_limit(10);
require_once '/src/whatsprot.class.php';
$nickname = "WA Tools";
$target = $contacts;
$w = new WhatsProt($username, $identity, $nickname, $debug);
$w->connect();
$w->loginWithPassword($password);
if($msg!=""){
echo "<b>El mensaje:</b> ".$msg." <b>Ha sido enviado con éxito.</b><br><br>";
$w->sendMessage($contacts , $msg);
$w->sendMessage($contacts , "Mensaje enviado desde http://watools.es");
}
function onGetRequestLastSeen($username, $msgid, $seconds)
{
//echo "Received last seen seconds: '$seconds'";
//$now = time();
//$lastSeen = $now - $seconds;
$secondsInAMinute = 60;
$secondsInAnHour = 60 * $secondsInAMinute;
$secondsInADay = 24 * $secondsInAnHour;
// extract days
$days = floor($seconds / $secondsInADay);
// extract hours
$hourSeconds = $seconds % $secondsInADay;
$hours = floor($hourSeconds / $secondsInAnHour);
// extract minutes
$minuteSeconds = $hourSeconds % $secondsInAnHour;
$minutes = floor($minuteSeconds / $secondsInAMinute);
// extract the remaining seconds
$remainingSeconds = $minuteSeconds % $secondsInAMinute;
$seconds = ceil($remainingSeconds);
// return the value
if (($seconds==null) & ($minutes==null) & ($hours==null) & ($days==null))
echo "El contacto tiene desactivado esta función";
else if (($seconds==0) & ($minutes==0) & ($hours==0) & ($days==0))
echo "En línea";
else
echo $days . " días " . $hours . " horas " . $minutes . " minutos";
}
$w->eventManager()->bind('onGetRequestLastSeen', 'onGetRequestLastSeen');
$w->sendGetRequestLastSeen($contacts);
//This function only needed to show how eventmanager works.
function onGetProfilePicture($from, $target, $type, $data)
{
if ($type == "preview") {
$filename = "preview_" . $target . ".jpg";
} else {
$filename = $target . ".jpg";
}
$filename = WhatsProt::PICTURES_FOLDER."/" . $filename;
$fp = @fopen($filename, "w");
if ($fp) {
fwrite($fp, $data);
fclose($fp);
}
echo '<a href="'.$filename.'"><center><img src="'.$filename.'" height="250" width="250"></center></a><br><br>';
echo '<center><b>Pulsa en la imagen para verlo a tamaño completo</b></center>';
}
$w->eventManager()->bind("onGetProfilePicture", "onGetProfilePicture");
$w->sendGetProfilePicture($target, true);
?>
<ul>
<li>
</li>
</ul>
<div>
</div>
</div>
</li>
</ol>
</html>