forked from nhodges/neighbr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new.php
151 lines (130 loc) · 6.88 KB
/
new.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
149
150
151
<?php
require_once "./include/config.php";
require_once "./include/inursql.php";
$db = new inursql();
$c = $db->connect($hostname, $username, $password, $database);
include "./templates/header.php";
$sql = "SELECT title,note FROM posts WHERE neighbr = 'neighbrhood' ORDER BY timestamp DESC LIMIT 0,1";
$result = $db->query($sql);
echo "\t\t<div id=\"bulletin\"><div style=\"padding: 10px;\">\r\n";
while($bulletin = $db->grab($result)) {
echo "\t\t\t<div style=\"font-weight: bold; margin-bottom: 5px;\"><a href=\"/neighbrhood/\">$bulletin[title]</a></div>\r\n";
echo "\t\t\t<div style=\"color: #979797;\">$bulletin[note]</div>\r\n";
}
echo "\t\t</div></div>\r\n";
// mysql_free_result($result);
?>
<div style="padding: 10px;">
<?php
if(isset($_GET['pg'])) {
if(!is_numeric($_GET['pg'])) { header("Location: http://neighbr.net/"); }
$pg = $_GET['pg'];
} else {
$pg = 1;
}
$sql = "SELECT * FROM posts WHERE objectionable = 0";
$result = $db->query($sql);
$numrows = mysql_num_rows($result);
// echo $numrows;
$perPage = 15;
$limit = ' LIMIT '.($pg - 1)*$perPage.', '.$perPage;
$lastpage = ceil($numrows/$perPage);
if($pg < 1) { $pg = 1; }
if($pg > $lastpage) { $pg = $lastpage; }
// echo $pg;
if($pg==1) {
$pages .= '<div class="pages">«</div><div class="pages">‹</div>';
} else {
$pages .= "<div class=\"pages\"><a href=\"http://neighbr.net/\">«</a></div>";
$prevpage=$pg-1;
$pages .= "<div class=\"pages\"><a href=\"http://neighbr.net/$prevpage\">‹</a></div>";
}
$pages .= '<div class="pages">' . $pg . '</div>';
if($pg==$lastpage) {
$pages .= '<div class="pages">›</div><div class="pages">»</div>';
} else {
$nextpage = $pg+1;
$pages .= "<div class=\"pages\"><a href=\"http://neighbr.net/$nextpage\">›</a></div>";
$pages .= "<div class=\"pages\"><a href=\"http://neighbr.net/$lastpage\">»</a></div>";
}
$sql = "SELECT id, neighbr, type, source, title, note FROM posts WHERE objectionable = 0 ORDER BY id DESC" . $limit;
$result = $db->query($sql);
while($post = $db->grab($result)) {
if(file_exists("./img/avatars/$post[neighbr].jpg")) {
$avatar = "<img src=\"./img/avatars/$post[neighbr].jpg\" alt=\"neighbr: $post[neighbr]\" style=\"width: 50px; height: 50px; border: 0px;\" />";
} else {
$avatar = "<img src=\"./img/avatar.jpg\" alt=\"neighbr: $post[neighbr]\" style=\"width: 50px; height: 50px; border: 0px;\" />";
}
if($post['type'] == 'image') {
list($width, $height, $type, $attr) = getimagesize("./images/$post[title]");
if($width > 490) {
$div = "<div style=\"padding: 5px; text-align: center;\">";
$image = "<a href=\"$post[source]\" title=\"$post[title]\"><img src=\"$post[source]\" alt=\"$post[title]\" style=\"width: 490px; border: 0px;\" /></a>";
} else {
$padding = ceil((500 - $width) / 2);
$div = "<div style=\"padding: " . $padding . "px; text-align: center;\">";
$image = "<img src=\"$post[source]\" alt=\"$post[title]\" />";
}
echo "\t\t\t<div style=\"float: left; width: 50px;\"><a href=\"./$post[neighbr]/\">$avatar</a></div>\r\n";
echo "\t\t\t<div style=\"float: right; width: 500px;\">\r\n";
echo "\t\t\t<div>\r\n";
echo "\t\t\t\t<div class=\"post-header\"><div style=\"padding: 5px;\"><a href=\"./view/$post[id]\" title=\"$post[title]\">$post[title]</a></div></div>\r\n";
echo "\t\t\t\t<div class=\"post-content\">\r\n";
echo "\t\t\t\t\t$div\r\n";
echo "\t\t\t\t\t\t$image\r\n";
echo "\t\t\t\t\t\t<div>$post[note]</div>\r\n";
echo "\t\t\t\t\t</div>\r\n";
echo "\t\t\t\t</div>\r\n";
echo "\t\t\t</div>\r\n";
echo "\t\t\t</div><div style=\"clear: both;\"></div><br />\r\n";
} elseif($post['type'] == 'video') {
$text = nl2br($post['note']);
echo "\t\t\t<div style=\"float: left; width: 50px;\"><a href=\"./$post[neighbr]/\">$avatar</a></div>\r\n";
echo "\t\t\t<div style=\"float: right; width: 500px;\">\r\n";
echo "\t\t\t<div>\r\n";
echo "\t\t\t\t<div class=\"post-header\"><div style=\"padding: 5px;\"><a href=\"./view/$post[id]\" title=\"$post[title]\">$post[title]</a></div></div>\r\n";
echo "\t\t\t\t<div class=\"post-content\"><object width=\"500\" height=\"303\"><param value=\"http://www.youtube.com/v/$post[source]\" name=\"movie\" /><param value=\"window\" name=\"wmode\" /><param value=\"true\" name=\"allowFullScreen\" /><embed width=\"500\" height=\"303\" wmode=\"window\" allowfullscreen=\"true\" type=\"application/x-shockwave-flash\" src=\"http://www.youtube.com/v/$post[source]\"></embed></object>\r\n<div style=\"padding: 5px;\">$text</div></div>\r\n";
echo "\t\t\t</div>\r\n";
echo "\t\t\t</div><div style=\"clear: both;\"></div><br />\r\n";
} elseif($post['type'] == 'code') {
echo "\t\t\t<div style=\"float: left; width: 50px;\"><a href=\"./$post[neighbr]/\">$avatar</a></div>\r\n";
echo "\t\t\t<div style=\"float: right; width: 500px;\">\r\n";
echo "\t\t\t<div>\r\n";
echo "\t\t\t\t<div class=\"post-header\"><div style=\"padding: 5px;\"><a href=\"./view/$post[id]\" title=\"$post[title]\">$post[title]</a></div></div>\r\n";
echo "\t\t\t\t<div class=\"post-content\"><div style=\"padding: 5px;\">\r\n";
echo "<pre><code>$post[note]</code></pre>\r\n";
echo "\t\t\t\t</div></div>\r\n";
echo "\t\t\t</div>\r\n";
echo "\t\t\t</div><div style=\"clear: both;\"></div><br />\r\n";
} elseif($post['type'] == 'link') {
if(strlen($post[note]) > 65) {
$note = substr($post[note], 0, 65) . " ...";
} else {
$note = $post[note];
}
$linkcolor = $colors[rand(0,4)];
echo "\t\t\t<div style=\"float: left; width: 50px;\"><a href=\"./$post[neighbr]/\">$avatar</a></div>\r\n";
echo "\t\t\t<div style=\"float: right; width: 500px;\">\r\n";
echo "\t\t\t<div>\r\n";
echo "\t\t\t\t<div class=\"post-header\"><div style=\"padding: 5px;\"><a href=\"./view/$post[id]\" title=\"$post[title]\">$post[title]</a></div></div>\r\n";
echo "\t\t\t\t<div class=\"post-content\"><div style=\"padding: 5px;\"><a href=\"$post[note]\" target=\"_blank\" class=\"$linkcolor\">$note</a></div></div>\r\n";
echo "\t\t\t</div>\r\n";
echo "\t\t\t</div><div style=\"clear: both;\"></div><br />\r\n";
} else {
$text = nl2br($post['note']);
echo "\t\t\t<div style=\"float: left; width: 50px;\"><a href=\"./$post[neighbr]/\">$avatar</a></div>\r\n";
echo "\t\t\t<div style=\"float: right; width: 500px;\">\r\n";
echo "\t\t\t<div>\r\n";
echo "\t\t\t\t<div class=\"post-header\"><div style=\"padding: 5px;\"><a href=\"./view/$post[id]\" title=\"$post[title]\">$post[title]</a></div></div>\r\n";
echo "\t\t\t\t<div class=\"post-content\"><div style=\"padding: 5px;\">$text</div></div>\r\n";
echo "\t\t\t</div>\r\n";
echo "\t\t\t</div><div style=\"clear: both;\"></div><br />\r\n";
}
}
// mysql_free_result($result);
?>
</div>
</div>
<div style="clear: both; text-align: right; padding-right: 15px; padding-bottom: 15px;"><?php echo $pages;?></div>
</div>
<?php include "./templates/footer.php"; ?>