comparison php/read/updateLink.php @ 6:077b0a0a3e6d

remaining originals according to dependency walk
author Robert Boland <robert@markup.co.uk>
date Thu, 16 Feb 2017 22:29:02 +0000
parents
children 385ddd7c4b55 84a412b8122c
comparison
equal deleted inserted replaced
5:55445b456ad0 6:077b0a0a3e6d
1 <?PHP
2
3 $linkID = strval($_GET['linkID']);
4 echo $linkID;
5 $change = strval($_GET['change']);
6 echo $change;
7 $dir = strval($_GET['dir']);
8 echo $dir;
9 $userID = strval($_GET['userID']);
10 echo $userID;
11
12 include "../../../private/db.php";
13
14 $pos = 0;
15 $neg = 0;
16
17 if($change == "pos")
18 {
19 if($dir == "pos")
20 {
21 $state = 1;
22 $pos = 1;
23 }
24 else
25 {
26 $state = 0;
27 $pos = -1;
28 }
29 }
30 else
31 {
32 if($dir == "pos")
33 {
34 $state = -1;
35 $neg = 1;
36 }
37 else
38 {
39 $state = 0;
40 $neg = -1;
41 }
42 }
43
44 if($userID == "")
45 {
46 $updateQuery = 'CALL b_changeLink('. $linkID . ',' . $pos .',0,' . $neg .',0)';
47 echo $updateQuery;
48 $dataFinal = mysqli_query($link, $updateQuery);
49 }
50 else
51 {
52 $check = 'CALL b_getStateID('. $userID .','. $linkID .')'; //select StateID from thumbstate where UserID = ' . $userID . ' and linkID = ' . $linkID;
53 echo $check;
54 $result = mysqli_query($link, $check) or exit( mysqli_error( $link ));
55 $count=mysqli_num_rows($result);
56 if($count==1){
57 $rows=mysqli_fetch_array($result, MYSQLI_ASSOC);
58 $stateID=$rows['StateID'];
59 $stateQuery = "CALL b_updateThumbState($stateID,$state)";
60 }
61 else
62 {
63 $stateQuery = "CALL b_insertThumbState($userID,$linkID,$state)";
64 }
65 echo $stateQuery;
66
67 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop
68 include "../../../private/db.php";
69 $stateFinal = mysqli_query($link, $stateQuery) or exit( mysqli_error( $link ));
70 }
71
72 //if email not zero, select userid from user where email=email
73 //insert into thumbstate null,userid,linkid,state (1,0,-1)
74
75 mysqli_close($link);
76
77 ?>