-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
29 lines (26 loc) · 1.08 KB
/
Copy pathfunctions.php
File metadata and controls
29 lines (26 loc) · 1.08 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
function makeUnixFilename($string)
{
$replace=""; //what you want to replace the bad characters with
$pattern="/([[:alnum:]_\-]*)/"; //basically all the filename-safe characters
$bad_chars=preg_replace($pattern,$replace,$string); //leaves only the "bad" characters
$bad_arr=str_split($bad_chars); //split them up into an array for the str_replace() func.
$string=str_replace($bad_arr,$replace,$string);
return $string;
}
function getfromurl($url="",$attachment=null,$timeout=10){//function to make curl request.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
curl_setopt($ch,CURLOPT_TIMEOUT,$timeout);
if(isset($attachment) && is_array($attachment)){
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result = curl_exec($ch);
curl_close ($ch);
return $result;
}