-
Notifications
You must be signed in to change notification settings - Fork 0
/
postar.php
59 lines (42 loc) · 2.21 KB
/
postar.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
<?php
include 'ligar_db.php';
$data_atual = date("Y-m-d H:i:s");
if (isset($_POST['post'])) {
$id_perfil = $_SESSION['user'][5];
$id_user = $_SESSION['user'][5];
$post = htmlspecialchars(mysqli_real_escape_string($link, $_POST['post']));
$len_post = strlen($post);
if (!empty($post)) {
if ($len_post > 0) {
if (strpos($post, 'youtube.com') !== false) {
$id_link = preg_replace("#youtube\.com/watch?v=#" , "", $post);
$post = preg_replace("/\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i","<iframe class=\"text-center embed-responsive embed-responsive-21by9\" width=\"425\" height=\"344\" src=\"//www.youtube.com/embed/$1\" frameborder=\"0\" allowfullscreen></iframe>", $post);
//$post = preg_replace('"\b(https?://\S+)"', '<div class="text-center embed-responsive embed-responsive-21by9"><iframe class="embed-responsive-item" width="425" height="344" src="https://www.youtube.com/embed/'.$id_link.'" frameborder="0" title="Video" allowfullscreen></iframe></div></a>', $post);
}
mysqli_query($link, "INSERT INTO posts (id_user_postou, id_perfil, post, data) VALUES ('$id_user', '$id_perfil', '$post', '$data_atual')") or die(mysqli_error($link));
mysqli_query($link, "INSERT INTO notificacoes (sender, receiver, tipo) VALUES ('$id_user', '$id_perfil', 'post')") or die (mysqli_error($link));
/*
$existe = "imagens/utilizadores/".$id."/galeria";
if (!is_dir($existe)) {
mkdir($existe);
}
$file_name = $_FILES['file']['name'];
$file_type = $_FILES['file']['type'];
$file_size = $_FILES['file']['size'];
$file_tem_loc = $_FILES['file']['tmp_name'];
$file_store = "imagens/utilizadores/".$id."/galeria/".$file_name;
if (!empty($file_name)) {
$busca_post_id = mysqli_query($link, "SELECT id FROM posts WHERE post='$post' AND id_user_postou='$id_user' AND id_perfil='$id_perfil' LIMIT 1");
$info_post = mysqli_fetch_assoc($busca_post_id);
$id_post = $info_post['id'];
move_uploaded_file($file_tem_loc, $file_store);
mysqli_query($link, "INSERT INTO galeria (id_user, foto, id_post) VALUES ('$id_user', '$file_store', '$id_post')");
}
*/
}
echo "Post Published!";
} else {
echo "Fill the Postbox!";
}
}
?>