-
Notifications
You must be signed in to change notification settings - Fork 37
/
th_jobs.php
86 lines (74 loc) · 3.28 KB
/
th_jobs.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
<?php
class jobThai {
public $return = array();
function __construct($spell_checked, $req) {
if ($spell_checked == "job" || $spell_checked == "jobs") {
echo $url = "http://th.tiptopjob.com/search/tiptopresults.asp";
$field_string = "country=THA&sub_location=&srchtype=0&Keyword=&btnSearch=Search+Jobs";
$this->job($url, $field_string);
} elseif (preg_match("~^jobs? (.+)~", $spell_checked, $matches)) {
echo $url = "http://th.tiptopjob.com/search/tiptopresults.asp";
$field_string = "country=THA&sub_location=&srchtype=0&Keyword=" . urlencode(trim($matches[1])) . "&btnSearch=Search+Jobs";
$this->job($url, $field_string);
} elseif (preg_match("~__thailandjob__(.+)__~", $req, $matches)) {
echo $url = trim($matches[1]);
$this->jobdetails($url);
}
}
function job($url, $field_string) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $field_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: th.tiptopjob.com", 'Referer: http://th.tiptopjob.com/'));
$result = curl_exec($ch);
curl_close($ch);
if (preg_match_all('~<a href="/search/jobs/(.+)" onclick=".+" class=tl>(.+)</a>~Usi', $result, $match)) {
if (count($match[1]) > 1) {
$this->return["job"] = "Your query matches more than one result";
for ($i = 1; $i < count($match[1]); $i++) {
$link = trim(strip_tags($match[1][$i]));
$title = trim(strip_tags($match[2][$i]));
$this->return["options"][] = $title;
$this->return["list"][] = array("content" => "__thailandjob__" . $link . "__");
}
}
} else {
$this->return["job"] = "No data found";
}
}
function jobdetails($url) {
$url_next = "http://th.tiptopjob.com/search/jobs/" . $url;
$content = file_get_contents($url_next);
if (preg_match('~<td class="frmlbl nowrap">(.+)<td class=hs_m colspan=2>~Usi', $content, $match)) {
$data = $match[1];
$data = preg_replace('~[\s]+~', " ", $data);
$data = str_replace('</td></tr>', "***", $data);
$data = strip_tags($data);
$data = str_replace('***', "\n", $data);
$data = str_replace("\n ", "\n", $data);
$this->return["job"] = $data;
} else {
$this->return["job"] = "No data found";
}
}
}
$obj = new jobThai($spell_checked, $req);
var_dump($obj->return);
if (!empty($obj->return["job"])) {
$total_return = $obj->return["job"];
if (!empty($obj->return["options"])) {
$options_list = array_merge($options_list, $obj->return["options"]);
$list = array_merge($list, $obj->return["list"]);
}
$source_machine = $machine_id;
$current_file = "/temp/$numbers";
file_put_contents(DATA_PATH . $current_file, $total_return);
$to_logserver['source'] = 'jobthai';
include 'allmanip.php';
putOutput($total_return);
exit();
}
?>