summaryrefslogtreecommitdiff
path: root/index.php
blob: 9fde6521aa98a25da7f5cedc4d2eb17222c6ecbb (plain)
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
<?PHP

include "functions.inc";

### Log valid referers:
if (($url) && (strstr(getenv("HTTP_REFERER"), $url))) {
  addRefer($url);
}

include "theme.inc";
$theme->header();

dbconnect();

### Initialize variables:
$number = ($user->storynum) ? $user->storynum : 10;
$date = ($date) ? $date : time();

### Perform query:
$result = mysql_query("SELECT * FROM stories WHERE time <= $date ORDER BY sid DESC LIMIT $number");

### Display stories:
while ($story = mysql_fetch_object($result)) {
  ### Compose more-link:
  $morelink = "[ ";
  if ($story->article) {
    $morelink .= "<A HREF=\"article.php?sid=$story->sid";
    if (isset($user->umode)) { $morelink .= "&mode=$user->umode"; } else { $morelink .= "&mode=threaded"; }
    if (isset($user->uorder)) { $morelink .= "&order=$user->uorder"; } else { $morelink .= "&order=0"; }
    $bytes = strlen($story->article);
    $morelink .= "\"><FONT COLOR=\"$theme->hlcolor2\"><B>read more</B></FONT></A> | $bytes bytes in body | "; 
  }
  $query = mysql_query("SELECT sid FROM comments WHERE sid = $story->sid");
  if (!$query) { $count = 0; } else { $count = mysql_num_rows($query); }
  $morelink .= "<A HREF=\"article.php?sid=$story->sid";
  if (isset($user->umode)) { $morelink .= "&mode=$user->umode"; } else { $morelink .= "&mode=threaded"; }
  if (isset($user->uorder)) { $morelink .= "&order=$user->uorder"; } else { $morelink .= "&order=0"; }
  if (isset($user->thold)) { $morelink .= "&thold=$user->thold"; } else { $morelink .= "&thold=0"; }
  $morelink .= "\"><FONT COLOR=\"$theme->hlcolor2\">$count comments</FONT></A> ]";

  ### Display story:
  $theme->abstract($story->aid, $story->informant, $story->time, stripslashes($story->subject), stripslashes($story->abstract), stripslashes($story->comments), $story->category, $story->department, $morelink);
}

mysql_free_result($result);

$theme->footer();

?>