- .htaccess yoinked from Drupal
[scuttle] / index.php
1 <?php
2 /***************************************************************************
3 Copyright (c) 2004 - 2006 Scuttle project
4 http://sourceforge.net/projects/scuttle/
5 http://scuttle.org/
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20 ***************************************************************************/
21
22 require_once('header.inc.php');
23 $bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
24 $templateservice =& ServiceFactory::getServiceInstance('TemplateService');
25 $userservice =& ServiceFactory::getServiceInstance('UserService');
26 $cacheservice =& ServiceFactory::getServiceInstance('CacheService');
27
28 $tplvars = array();
29 if (isset($_GET['action'])){
30     if ($_GET['action'] == "logout") {
31         $userservice->logout($path);
32         $tplvars['msg'] = T_('You have now logged out');
33     }
34 }
35
36 // Header variables
37 $tplVars['loadjs'] = true;
38 $tplVars['rsschannels'] = array(
39     array(sprintf(T_('%s: Recent bookmarks'), $sitename), createURL('rss'))
40 );
41
42 if ($usecache) {
43     // Generate hash for caching on
44     $hashtext = $_SERVER['REQUEST_URI'];
45     if ($userservice->isLoggedOn()) {
46         $hashtext .= $userservice->getCurrentUserID();
47     }
48     $hash = md5($hashtext);
49
50     // Cache for 15 minutes
51     $cacheservice->Start($hash, 900);
52 }
53
54 // Pagination
55 $perpage = getPerPageCount();
56 if (isset($_GET['page']) && intval($_GET['page']) > 1) {
57     $page = $_GET['page'];
58     $start = ($page - 1) * $perpage;
59 } else {
60     $page = 0;
61     $start = 0;
62 }
63
64 $dtend = date('Y-m-d H:i:s', strtotime('tomorrow'));
65 $dtstart = date('Y-m-d H:i:s', strtotime($dtend .' -'. $defaultRecentDays .' days'));
66
67 $tplVars['page'] = $page;
68 $tplVars['start'] = $start;
69 $tplVars['popCount'] = 30;
70 $tplVars['sidebar_blocks'] = array('recent');
71 $tplVars['range'] = 'all';
72 $tplVars['pagetitle'] = T_('Store, share and tag your favourite links');
73 $tplVars['subtitle'] = T_('Recent Bookmarks');
74 $tplVars['bookmarkCount'] = $start + 1;
75 $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, NULL, NULL, NULL, getSortOrder(), NULL, $dtstart, $dtend);
76 $tplVars['total'] = $bookmarks['total'];
77 $tplVars['bookmarks'] =& $bookmarks['bookmarks'];
78 $tplVars['cat_url'] = createURL('tags', '%2$s');
79 $tplVars['nav_url'] = createURL('index', '%3$s');
80
81 $templateservice->loadTemplate('bookmarks.tpl', $tplVars);
82
83 if ($usecache) {
84     // Cache output if existing copy has expired
85     $cacheservice->End($hash);
86 }
87 ?>

Benjamin Mako Hill || Want to submit a patch?