-
Notifications
You must be signed in to change notification settings - Fork 0
/
funciones.php
148 lines (132 loc) · 4.86 KB
/
funciones.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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?
// Codigo de muestra de Mexabtc.mx
// Hector Atalo Ramos Gomez
// https://www.mexabtc.mx/index.php
//
function changeStatusTrade($idTrade){
global $mysqli;
$idTrade = $mysqli->real_escape_string($idTrade);
$resp = $mysqli->query("SELECT activo FROM trades WHERE id = '$idTrade' LIMIT 1");
$dt = $resp->fetch_array(MYSQLI_BOTH);
if($dt[activo] == 0)
$newStatus = 1;
else if($dt[activo] == 1)
$newStatus = 0;
$mysqli->query("UPDATE trades SET activo = '$newStatus' WHERE id = '$idTrade' LIMIT 1");
}
function blockUser($uid, $uidDestiny){
global $mysqli;
$uid = $mysqli->real_escape_string($uid);
$uidDestiny = $mysqli->real_escape_string($uidDestiny);
unTrustzone($uid, $uidDestiny);
if(!banChecked($uid, $uidDestiny)){
$hoy = time();
$mysqli->query("INSERT INTO `bloqueos` (
`id` ,
`user_bloquea` ,
`user_destino` ,
`fecha_bloqueo`
)
VALUES (
NULL , $uid , $uidDestiny , $hoy
);
");
return true;
} else
return false;
}
function getGoodFeedbacks($uid){
global $mysqli;
$uid = $mysqli->real_escape_string($uid);
$resp = $mysqli->query("SELECT id FROM feedback WHERE user_destino='$uid' and calificacion > 0");
$row_cont = $resp->num_rows;
return $row_cont;
}
function addBlockWithoutFeedback($uid, $uidDestiny){
global $mysqli;
$uid = $mysqli->real_escape_string($uid);
$uidDestiny = $mysqli->real_escape_string($uidDestiny);
$resp = $mysqli->query("SELECT uid, trades_count FROM users WHERE uid='$uidDestiny' LIMIT 1");
$datos = $resp->fetch_array(MYSQLI_BOTH);
$tradeCount = $datos[trades_count];
$tradeCount++;
$mysqli->query("UPDATE users SET trades_count = '$tradeCount' WHERE uid = '$uidDestiny' LIMIT 1");
}
function addDistrustBlockFeedback($uid, $uidDestiny){
global $mysqli;
$uid = $mysqli->real_escape_string($uid);
$uidDestiny = $mysqli->real_escape_string($uidDestiny);
$resp = $mysqli->query("SELECT uid, trades_count,feedback_score FROM users WHERE uid='$uidDestiny' LIMIT 1");
$datos = $resp->fetch_array(MYSQLI_BOTH);
$tradeCount = $datos[trades_count];
$tradeCount++;
if($datos[feedback_score] == 0)
$feedbackScoreCount = 0;
else {
$respFeedscore = $mysqli->query("SELECT id FROM feedback WHERE user_destino ='$uidDestiny' AND calificacion IN ('0','-2')");
$numFeedscore = $respFeedscore->num_rows;
$tradeCountFeedback = $tradeCount - $numFeedscore;
$goodTrades = getGoodFeedbacks($uidDestiny);
$feedbackScoreCount = $goodTrades / $tradeCountFeedback;
$feedbackScoreCount = $feedbackScoreCount * 100;
}
$mysqli->query("UPDATE users SET trades_count = '$tradeCount', feedback_score = '$feedbackScoreCount' WHERE uid = '$uidDestiny' LIMIT 1");
}
function addNeutralFeedback($uid, $uidDestiny){
global $mysqli;
$uid = $mysqli->real_escape_string($uid);
$uidDestiny = $mysqli->real_escape_string($uidDestiny);
$resp = $mysqli->query("SELECT uid, trades_count FROM users WHERE uid='$uidDestiny' LIMIT 1");
$datos = $resp->fetch_array(MYSQLI_BOTH);
$tradeCount = $datos[trades_count];
$tradeCount++;
$mysqli->query("UPDATE users SET trades_count = '$tradeCount' WHERE uid = '$uidDestiny' LIMIT 1");
}
function addPositiveFeedback($uid, $uidDestiny){
global $mysqli;
$uid = $mysqli->real_escape_string($uid);
$uidDestiny = $mysqli->real_escape_string($uidDestiny);
$resp = $mysqli->query("SELECT uid, trades_count, feedback_score FROM users WHERE uid='$uidDestiny' LIMIT 1");
$datos = $resp->fetch_array(MYSQLI_BOTH);
$tradeCount = $datos[trades_count];
$tradeCount++;
if($datos[feedback_score] == 0)
$feedbackScoreCount = 100;
else if($datos[feedback_score] == 100){
$feedbackScoreCount = 100;
} else {
$respFeedscore = $mysqli->query("SELECT id FROM feedback WHERE user_destino ='$uidDestiny' AND calificacion IN ('0','-2')");
$numFeedscore = $respFeedscore->num_rows;
$tradeCountFeedback = $tradeCount - $numFeedscore;
$goodTrades = getGoodFeedbacks($uidDestiny);
$feedbackScoreCount = $goodTrades / $tradeCountFeedback;
$feedbackScoreCount = $feedbackScoreCount * 100;
}
$mysqli->query("UPDATE users SET trades_count = '$tradeCount', feedback_score = '$feedbackScoreCount' WHERE uid = '$uidDestiny' LIMIT 1");
}
function addTrustZone($uid, $uidDestiny){
global $mysqli;
$uid = $mysqli->real_escape_string($uid);
$uidDestiny = $mysqli->real_escape_string($uidDestiny);
if(!trustChecked($uid, $uidDestiny)){
$hoy = time();
$mysqli->query("INSERT INTO `mexabtc_portal`.`trusts` (
`id` ,
`user_califica` ,
`user_destino` ,
`fecha_trust`
)
VALUES (
NULL , $uid , $uidDestiny , $hoy
);
");
$resp = $mysqli->query("SELECT trust_count FROM users WHERE uid='$uidDestiny' LIMIT 1");
$datos = $resp->fetch_array(MYSQLI_BOTH);
$trustCount = $datos[trust_count];
$trustCount++;
$mysqli->query("UPDATE users SET trust_count = '$trustCount' WHERE uid = '$uidDestiny' LIMIT 1");
return true;
} else {
return false;
}
}