-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfotohistoria.php
51 lines (48 loc) · 1.98 KB
/
fotohistoria.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
<?php
include "key.inc.php";
$referer = $_SERVER['HTTP_REFERER'];
$referer_parse = parse_url($referer);
//The $referer_parse will give some more, let's say, security
//$wwwUrlHost = "www.".$urlHost;
//if($referer_parse['host'] == $urlHost || $referer_parse['host'] == $wwwUrlHost) {
if(isset($_POST['historyphoto'])){
$name = $_FILES['pic']['name'];
$extension = explode('.', $name);
$extension = end($extension);
$type = $_FILES['pic']['type'];
$size = $_FILES['pic']['size'] /1024/1024;
$random_name = rand();
$tmp = $_FILES['pic']['tmp_name'];
if(!empty($name)){
if ((strtolower($type) != "image/jpeg") && (strtolower($type) != "image/jpg") && (strtolower($type) != "image/gif") && (strtolower ($type) != "image/png")){
$message= "Formato de imagem não suportado";
echo "<script type='text/javascript'>alert('$message'); location.href = '$urlHost/site.php'; </script>";
//this else if command can be deleted. We are just testing it.
}else{
/*
if(!empty($row['profilepiclocation'])){
$profilepiclocation = $row['profilepiclocation'];
unlink('profilepics/'.$profilepiclocation);
}
*/
$filename = $random_name.'.'.$extension;
move_uploaded_file($tmp, 'fotos/historia/'.$filename);
$inserirfoto = $pdo->prepare("UPDATE usuarios_cadastrados SET nossahistoriafoto = ? WHERE id = ?");
$inserirfoto->execute(array($filename, $row['id']));
$message="Foto adicionada com sucesso"; #Esta linha também pode ser deletada.
/*echo "<script type='text/javascript'>alert('$message\\nFoto enviada: $name\\nTamanho: $size\\nTipo: $type\\nArmazenada em: profilepics/$location');</script>";*/
header('Location: ' . $_SERVER['HTTP_REFERER']);
exit;
}
}else{
echo "<script type='text/javascript'>alert('Por favor escolha uma foto do seu computador'); location.href = '$urlHost/site.php';</script>";
}
}else{
header('Location: '.$urlHost.'/site.php');
exit;
}
//}else {
//header('Location: '.$urlHost);
//exit;
//}
?>