-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.php
More file actions
108 lines (78 loc) · 3.4 KB
/
Copy pathscript.php
File metadata and controls
108 lines (78 loc) · 3.4 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
$mysqli= new mysqli('localhost','root','','ucm_verse') or die($mysqli->connect_error);
$table ='posts';
$u_table = 'users';
$phpFileUploadErrors = array(
0=>'Succes',
1=>'Too big for upload_max_filesize in php.ini',
2=>'Too big for MAX_FILE_SIZE in HTML form',
3=>'Podarila sa nahrat iba časť',
4=>'No file was uploaded',
6=>'Missing temporary folder',
7=>'Failed writing file to disk',
8=>'A PHP extension stopped file upload',
);
if (!strlen(trim(@$_POST['msg'])))
{
header("location:home.php");
exit();
}
if(isset($_POST['submit'])){
$file_array=reArrayFiles($_FILES['userfile']);
for ($i=0;$i<count($file_array);$i++){
/* if($file_array[$i]['error']){
echo $file_array[$i]['name'].' - '.$phpFileUploadErrors[$file_array[$i]['error']];
}
else {*/echo"1";
$extensions=array('jpg','png','gif','jpeg');
$file_ext = explode('.',$file_array[$i]['name']);
$user_id=@$_POST['user_id'];
echo $user_id;
$msg = filter_var(@$_POST['msg'], FILTER_SANITIZE_STRING);
$a_name=@$_POST['a_name'];
$a_l_name=@$_POST['a_l_name'];
$a_photo=@$_POST['a_photo'];
/* NEPOTREBNE $name=$file_ext[0];
$name= preg_replace("!-!"," ",$name);
$name= preg_replace("!_!"," ",$name);
$name = ucfirst($name);*/
$mysqli->query("UPDATE IGNORE $u_table SET usersPoststoday=usersPoststoday+1 WHERE usersId LIKE '%$user_id%'");
$file_ext = end($file_ext);
/*if (!in_array($file_ext,$extensions))
{
echo "$file_array[$i]['name'] - Invalid file extension!";
}
else{*/
$img_dir='images/web/'.$file_array[$i]['name'];
move_uploaded_file($file_array[$i]['tmp_name'],$img_dir);
$sql = "INSERT INTO $table(author_user_id,author_name,author_last_name,author_photo_dir,img_dir,msg,time) VALUES('$user_id','$a_name','$a_l_name','$a_photo','$img_dir','$msg',now())";
$mysqli->query($sql) or die($mysqli->error);
echo $file_array[$i]['name'].' - '.$phpFileUploadErrors[$file_array[$i]['error']];
/* echo '
<script type="text/javascript">
location.reload();
</script>';*/
// $page = $_SERVER['PHP_SELF'];
//}
//}
}
header("location:home.php");
}
function reArrayFiles(&$file_post) {
$file_ary = array();
$file_count = count($file_post['name']);
$file_keys = array_keys($file_post);
for ($i=0; $i<$file_count; $i++) {
foreach ($file_keys as $key) {
$file_ary[$i][$key] = $file_post[$key][$i];
}
}
return $file_ary;
}
//$search= "SELECT * FROM skuska";
//$query = mysqli_query($connect, $search);
//$num = mysqli_num_rows($query);
//echo "<meta http-equiv='refresh' content='0'>";
?>