-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreviews.php
More file actions
199 lines (177 loc) · 5.75 KB
/
reviews.php
File metadata and controls
199 lines (177 loc) · 5.75 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
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
//============================================================+
// File name : reviews.php
//
// Description : This file displays all reviews of both poster and worker and also performs delete reviews operation.
//
// Author: Aditya Mathur
//
// (c) Copyright:
// Aditya Mathur
// eztasker.com
//
// License:
// Copyright (C) 2014 Aditya Mathur - eztasker.com
//============================================================+
session_start();
if(isset($_SESSION['li_uname111'])){
$e=$_SESSION['li_uname111'];
$type=1;
}
elseif(isset($_SESSION['li_uname222'])){
$e=$_SESSION['li_uname222'];
$type=2;
$title="Task Poster";
require_once './includes/db_config.php';
connect();
$r8 = mysql_query("SELECT poster_id FROM poster_profile WHERE email = '$e' ")or die(mysql_error());
$row8 =mysql_fetch_array($r8);
$pid=$row8['poster_id'];
}
elseif(isset($_SESSION['li_uname333'])){
$e=$_SESSION['li_uname333'];
$type=3;
$title="Task Worker";
require_once './includes/db_config.php';
connect();
$r8 = mysql_query("SELECT worker_id FROM worker_profile WHERE email = '$e' ")or die(mysql_error());
$row8 =mysql_fetch_array($r8);
$wid=$row8['worker_id'];
}
else{
$e='';
$type=0;
header('location:login.php');die;//redirect to login page
}
?>
<?php include('./includes/header.php');?>
<div class="">
<!-- Menus -->
<?php include './includes/menu.php';?>
</div>
<div class="spacer"></div>
</div>
<table class="main-table"><tr><td>
<a href='javascript:history.go(-1)'><img src="images/back4.png" width="8%" height="4%"></a><br/><br/>
</td></tr></table>
<?php
require_once './includes/db_config.php';
connect();
//poster to worker
if(isset($_REQUEST['wi'])) {
$wid=$_REQUEST['wi'];
$wid=trim($wid);
$r2 = mysql_query("SELECT fname FROM worker_profile WHERE worker_id = '$wid' ")or die(mysql_error());
$row2 =mysql_fetch_array($r2);
$wn=$row2['fname'];
$q ="SELECT * FROM reviews, poster_profile
WHERE reviews.poster_id=poster_profile.poster_id
AND type=3
AND worker_id='".$wid."'";
$r=mysql_query($q) or die(mysql_error());
$count=mysql_num_rows($r);
echo "<table class='main-table'>";
if ($count > 0){
if($count==1){$str="Review";}else{$str="Reviews";} //grammar
echo"<tr>";
echo"<td colspan=4><br><h2>Total $count $str. </h2></br></td>";
echo "</tr>";
echo"<tr><td colspan=4><div class='hr'><hr /></td></tr>";
$c=1;
while($row=mysql_fetch_array($r))
{
echo"<tr>";
$worker_id=$row['worker_id'];
$rid=$row['rid'];
echo"<td>{$c}.</td>";
$name=$row['fname']." ".$row['lname'];
//if($worker_id==$wid ){$wn="You";}
echo"<td><strong>{$name}</strong> wrote @{$wn}<br/><br/>";
echo"<textarea disabled rows=4 cols=100>{$row['review']}-{$row['date']}</textarea></td>";
echo "</tr>";
if($worker_id==$wid ){
echo"<tr>";
?><td><a href='reviews.php?wi=<?php echo $wid;?>&f2=delreview&v3=<?php echo $rid;?>' onclick="return confirm('Are you sure?');"><img src='images/del.png' width='51px' height='16px'></a></td><?php
echo "</tr>";
}
echo"<tr><td colspan=4><div class='hr'><hr /></td></tr>";
$c++;
}
echo '</table>';
}else{
echo "<script> alert('No Reviews.') </script>" ;
echo"<script> function goBack(){window.history.back()} goBack(); </script>";
die;
}
}
//Worker to poster
elseif(isset($_REQUEST['pi'])){
$pid=(int)$_REQUEST['pi'];
$pid=trim($pid);
$r2 = mysql_query("SELECT * FROM poster_profile WHERE poster_id = '$pid' ")or die(mysql_error());
$row2 =mysql_fetch_array($r2);
$pn=$row2['fname'];
$q ="SELECT * FROM reviews, worker_profile
WHERE reviews.worker_id=worker_profile.worker_id
AND type=2
AND poster_id='".$pid."'";
$r=mysql_query($q) or die(mysql_error());
$count=mysql_num_rows($r);
echo "<table class='main-table'>";
if ($count > 0){
if($count==1){$str="Review";}else{$str="Reviews";} //grammar
echo"<tr>";
echo"<td colspan=4><br><h2>Total $count $str. </h2></br></td>";
echo "</tr>";
echo"<tr><td colspan=4><div class='hr'><hr /></td></tr>";
$c=1;
while($row=mysql_fetch_array($r))
{
echo"<tr>";
$poster_id=$row['poster_id'];
$rid=$row['rid'];
echo"<td>{$c}.</td>";
$name=$row['fname']." ".$row['lname'];
//if($poster_id==$pid ){$pn="You";}
echo"<td><strong>{$name}</strong> wrote @{$pn}<br/><br/>";
echo"<textarea disabled rows=4 cols=100>{$row['review']}-{$row['date']}</textarea></td>";
echo "</tr>";
if($poster_id==$pid ){
echo"<tr>";
?><td><a href='reviews.php?pi=<?php echo $pid;?>&f2=delreview&v3=<?php echo $rid;?>' onclick="return confirm('Are you sure?');"><img src='images/del.png' width='51px' height='16px'></a></td><?php
echo "</tr>";
}
echo"<tr><td colspan=4><div class='hr'><hr /></td></tr>";
$c++;
}
echo '</table>';
}else{
echo "<script> alert('No Reviews.') </script>" ;
echo"<script> function goBack(){window.history.back()} goBack(); </script>";
die;
}
}
else{
echo"<script> function goBack(){window.history.back()} goBack(); </script>";
die;
}
?>
<?php //delete review
if(isset($_GET['f2']) && isset($_GET['v3'])){
$v3=$_GET['v3']; // getting value from url
$_GET['f2']($v3); // call to function del with parameter.
}
function delreview($id2){ //function definition
require_once './includes/db_config.php';
$id2=trim($id2);
$r2 = mysql_query("DELETE from reviews where rid = '".$id2."' ")or die(mysql_error());
if($r2){
echo "<script> alert('Review Deleted.') </script>" ;
echo"<script> function goBack(){window.history.back()} goBack(); </script>";
}else{
echo "<script> alert('Error deleting this review.') </script>" ;
echo"<script> function goBack(){window.history.back()} goBack(); </script>";
}
}
?>
<?php include('./includes/footer.php');?>