-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathface_save.php
58 lines (51 loc) · 1.55 KB
/
face_save.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
<?php
// DB Import : Ali Can Gönüllü
// xxx.php?pic=pics/file_name.jpg OR xxx.php?pic=file_name.jpg
include "class/yuz_tanilama.php";
$get = $_GET["pic"];
$getcurl = $_GET["curl"];
if($getcurl == "1"){
if (filter_var($get, FILTER_VALIDATE_URL) === FALSE) {
die('Not a valid URL');
} else {
//Devam
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $get);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
$s = curl_exec($ch);
}
if(empty($get)) {
echo 'Yüz Tanımlanamadı!';
} else {
$detector = new alicangonullu\YuzTanila('class/algila.dat');
if($getcurl == "1"){
$detector->faceDetect($s);
} else {
$detector->faceDetect($get);
}
$tojson = $detector->toJson();
include ("conn.php");
if($getcurl == "1"){
$base64 = base64_encode($s);
} else {
$type = pathinfo($get, PATHINFO_EXTENSION); //If use cURL, Delete this code
$data = file_get_contents($get); //If use cURL, Delete this code
$base64 = base64_encode($data);
}
$update = $db->prepare("INSERT INTO face_table(face_title, face_json, face_data) VALUES (:title, :json, :data) ");
$update->bindValue(':title', $get);
$update->bindValue(':json', $tojson);
$update->bindValue(':data', $base64);
$update->execute();
if($update){
echo '<script>window.location.href="face_query.php?gor='.$db->lastInsertId().'";</script>';
if($getcurl == "1"){
curl_close($ch);
}
}
}
?>