-
Notifications
You must be signed in to change notification settings - Fork 2
/
methods.php
executable file
·40 lines (30 loc) · 924 Bytes
/
methods.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
<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
function getDOM($link){
libxml_use_internal_errors(true);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec($ch);
$dom = new DOMDocument;
$dom->loadHTML($html);
curl_close($ch);
return $dom;
}
function saveJSON($folder, $filename, $content){
$fh = fopen($folder . "/" . $filename, 'w+') or die("Can't open file");
$stringData = json_encode($content, JSON_PRETTY_PRINT);
fwrite($fh, $stringData);
fclose($fh);
//chmod($folder . "/" . $filename, 0777);
}
function createFolder($folder){
if (!file_exists($folder))
mkdir($folder);
//chmod($folder, 0777);
}
function trimRemoveTab($string){
return trim(str_replace("\t","", $string), chr(0xC2).chr(0xA0));
}
?>