Repository navigation
Expand file tree
/
Copy pathloadFeedRev.php
More file actions
153 lines (123 loc) · 8.55 KB
/
Copy pathloadFeedRev.php
File metadata and controls
153 lines (123 loc) · 8.55 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
<?php
require_once('config.php');
session_start();
if(!isset($_SESSION['userName']))
{
header("Location:login.php");
exit();
}
$userName=$_SESSION['userName'];
$sql="SELECT * FROM users WHERE userName=?";
$stmt=mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt,$sql))
{
header('location: login.php?error=sqlerror');
exit();
}
else
{
mysqli_stmt_bind_param($stmt,"s",$_SESSION['userName']);
mysqli_stmt_execute($stmt);
$result=mysqli_stmt_get_result($stmt);
if($row=mysqli_fetch_assoc($result))
{
$city=$row['city'];
}
}
$newFeedCount=$_POST['newFeedCount'];
$sql="SELECT * from posts WHERE paid=0 AND isDeleted='0' ORDER BY revenue DESC LIMIT $newFeedCount";
$result=$conn-> query($sql);
if($result->num_rows>0)
{
$i=1;
while($row=$result->fetch_assoc())
{
echo '
<li>
<div class="contact-cont">
<div class="pull-left user-img m-r-10">
<a href="" title=""><img src=
'.$row['profilePic'].'
alt="" class="w-40 rounded-circle"><span class="status online"></span></a>
</div>
<div class="contact-info">
<span class="contact-name text-ellipsis">
' .
$row['userName'].'<br>'.getDateDiff($row['date'])
.'
</span>
<span class="contact-date">
עיר:
<strong>
'.
$row['city'].'</strong>.'
.' '.
' רחוב: '.
'<strong>'
. $row['street'].'</strong>'.
'
</span><br>
<span class="contact-date">
שווי
<strong>
'.
$row['revenue'].'</strong>
</span>
<span class="contact-date">
רווח צפוי:
<strong>
'.$row['revenue']/2 .'</strong>
</span>
';
if($row['userName']!=$userName)
{
echo '
<span class="contact-date">
<form method="post" action="post.php">
<input type="hidden" name="postId" value='.$row['id'].'>
<button style="position: relative;float:left; bottom:30px;display:inline;" class="btn btn-primary" type="submit" name="pay" id="pay">שלם
<i class="fas fa-wine-bottle"></i>
</button> </span>
</form>
';
}
echo' </div>';
if($row['userName']==$userName)
{
echo '
<ul class="contact-action">
<li class="dropdown dropdown-action">
<a href="" class="dropdown-toggle action-icon" data-toggle="dropdown" aria-expanded="false"><i class="fa fa-ellipsis-v"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="myPosts.php">ערוך\מחק</a>
</div>
</li>
</ul>
' ;
}
echo ' <br>
</div> ';
}
}
function getDateDiff($dateRecive)
{
$day=(strtotime(date("Y-m-d"))-strtotime($dateRecive))/(60*60*24);
$yesterday=strtotime((date("Y-m-d", time() - 60 * 60 * 24)));
if((strtotime($dateRecive)-$yesterday)/(60*60*24)==0)
{
$isYesterday=true;
}
if($day==0 && $isYesterday!=true )
{
return 'היום';
}
if($isYesterday==true)
{
return 'אתמול';
}
else
{
return $dateRecive;
}
}
?>