Repository navigation
Expand file tree
/
Copy pathfunctions.php
More file actions
64 lines (52 loc) · 1.73 KB
/
Copy pathfunctions.php
File metadata and controls
64 lines (52 loc) · 1.73 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
<?php
/** this function stripslashes and encodes html entities for security purposes **/
function security($value)
{
if(is_array($value)) {
$value = array_map('security', $value);
} else {
if(!get_magic_quotes_gpc()) {
$value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
} else {
$value = htmlspecialchars(stripslashes($value), ENT_QUOTES, 'UTF-8');
}
$value = str_replace("\\", "\\\\", $value);
}
return $value;
}
/** this function sends a tweet **/
function send_tweet($msg, $name)
{
/** set globals **/
global $twitter_use_DM, $twitter_username, $twitter_passwd;
/** initiate curl **/
$curl = curl_init();
/** format tweet **/
$tweet = urlencode(stripslashes(urldecode("@".$twitter_username." ".$msg." -".$name)));
/** set host **/
$twitterHost = 'http://twitter.com/statuses/update.xml';
/** set params **/
$params = "status=$tweet";
/** decide on type **/
if($twitter_use_DM === true)
{
$twitterHost = 'http://twitter.com/direct_messages/new.xml';
$params = "text=$tweet&user=$twitter_username";
}
/** set curl params **/
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $twitterHost);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
curl_setopt($curl, CURLOPT_USERPWD, "$twitter_username:$twitter_passwd");
/** result **/
$result = curl_exec($curl);
$re = curl_getinfo($curl);
/** close curl connection **/
curl_close($curl);
/** get status **/
if($re['http_code'] == 200){ return true; }else{ return false; }
}
?>