_< */ include ('general.php3'); require ('mysql.pdo.php'); include ('dotomlette/userdata.php3'); /***************************************************************************/ function remove_tag ($text, $tag, $what = '') { return preg_replace("/<\\/?" . $tag . "(.|\\s)*?>/", $what, $text); } /***************************************************************************/ function filter ($text) { $temp = $text; $temp = remove_tag ($temp, 'script', '**FILTERED**'); $temp = remove_tag ($temp, 'object', '**FILTERED**'); $temp = remove_tag ($temp, 'embed', '**FILTERED**'); $temp = remove_tag ($temp, 'applet', '**FILTERED**'); $temp = remove_tag ($temp, 'head', ''); //$temp = preg_replace ('/\[([^\|\]]*)\|([^]]+)\]/', "\\2", $temp); $temp = SubUrlTagsWithLinks ($temp); return $temp; } /***************************************************************************/ /** * Must be called BEFORE filter is called! */ function find_header ($text) { $rtnval = ''; $pichu = preg_match ("]*>(.*)", $text, $matches); if ($pichu) { $rtnval = trim($matches[1]); } return $rtnval; } /***************************************************************************/ // variable setup. $title = 'Documents'; $header = ''; $documentid = array_key_exists ('did', $_GET) ? $_GET['did'] : 0; $printpage = array_key_exists ('printable', $_GET); $template = $printpage ? 'printable.tpl' : $template = 'document.tpl'; if (0 == $documentid) { $template = 'documentlist.tpl'; } /***************************************************************************/ // there's quite a bit of data that needs to be passed to Smarty. $hash = array(); $timestamp = 0; if (0 == $documentid) { //list them all! $stmt = $pdo->prepare ("SELECT `DID`, `title`, `category`, `user`, UNIX_TIMESTAMP(`updated`) AS updatd, UNIX_TIMESTAMP(`created`) AS creatd FROM `documents` ORDER BY `category` Asc, `title` Asc"); if ($stmt->execute()) { $oldcat = ''; while ($row = $stmt->fetch()) { if ($row['category'] != $oldcat) { $oldcat = $row['category']; $hash['cats'][] = $oldcat; } $ts_create = $row['creatd']; $ts_update = $row['updatd']; if ($ts_create > time() - (60 * 60 * 24 * 7)) $date = date ("Y-m-d B \B\M\T", $ts_create) .' NEW!'; else if ($ts_update > time() - (60 * 60 * 24 * 7)) $date = date ("Y-m-d B \B\M\T", $ts_update) .' UPDATED!'; else $date = date ("Y-m-d B \B\M\T", $ts_update); $entry = "$oldcat - " .htmlspecialchars ($row['title']) .""; $entry .= " by $row[user] ($date)"; $hash['links'][] = $entry; } } } else { //listing single $stmt = $pdo->prepare ("SELECT *, UNIX_TIMESTAMP(`updated`) AS updatd, UNIX_TIMESTAMP(`created`) AS creatd FROM `documents` WHERE `DID`=:documentid LIMIT 1"); $stmt->bindValue(':documentid', $documentid); if ($stmt->execute()) { $row = $stmt->fetch(); $timestamp = $row['updatd']; header ("Last-Modified: " .gmdate ("D, d M Y H:i:s", $timestamp) ." GMT"); $header = find_header ($row['body']); $hash['DocTitle'] = $row['title']; $hash['DocAuthor'] = $row['user']; $hash['DocCreated'] = date ("Y-m-d B \B\M\T", $row['creatd']); $hash['DocUpdated'] = date ("Y-m-d B \B\M\T", $row['updatd']); $hash['DocBody'] = filter ($row['body']); $hash['DocYear'] = date ('Y', $row['updatd']); $hash['DocID'] = $documentid; $hash['haloscan'] = GetUserData ($row['user'], NLJ_HS); $title = $row['title']; } } include ('do304.php'); do304($timestamp); BeginPage(); EndPage ("$header\n$title", $template, 0, $hash); ?>