Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 07:06 pm EDT

Geeklog Forums

Enhanced Siteindex


Status: offline

Creator

Forum User
Full Member
Registered: 07/11/02
Posts: 181
Location:Austin, TX
Because I felt like it, I've taken the siteindex.php "drop-in" developed by Tom (I think) and expanded on it to display story hits.

I have also included indexing of staticpages in much the same manner, though it will only work with Tom's Staticpages 1.2 (since it uses the same security calls as with stories, and the 1.1 version of staticpages isn't security-aware). Any older versions of staticpages will result in mySQL errors.

In any case, you can see it working here, and you can download the zipped package here. The zipped package contains three files; siteindex.php (the main file), storyindex.php (for stories), and pageindex.php (for staticpages). The extra files are there to cover the paging function if so desired.

I'm sure there's probably a better way to do what I did, but I'll leave that to better coders than I. Enjoy.


L. Whitworth
 Quote

Anonymous

Anonymous
I don't know what you have on this page, but after waiting over 2.5 minutes nothing displayed. I tried it a few times -- nothing. It just hangs.
 Quote

Status: offline

Creator

Forum User
Full Member
Registered: 07/11/02
Posts: 181
Location:Austin, TX
Hmm the server must have been down. It's showing up for me with no problems, and the execution time at the bottom of the page says 15 seconds. Perhaps try it again and let me know if the problem persists?

---
L. Whitworth
www.finiserv.com


L. Whitworth
 Quote

Status: offline

Creator

Forum User
Full Member
Registered: 07/11/02
Posts: 181
Location:Austin, TX
I wasn't completely satisfied with my initial release of the enhanced site index. I didn't feel that the index really covered the entire site as is, so I came up with version 1.2!

This version will now index all stories, comments, polls, static pages, links, events, and files within a GeekLogged site!

Note that Tom's Static Pages 1.2 and the Filemgmt plugin are REQUIRED if this index is to work. However, I've included separate index files for each item, so you will have storyindex.php, commentindex.php, voteindex.php, pageindex.php, linkindex.php, eventindex.php, and fileindex.php in addition to the main siteindex.php.

Each file in the package works as a stand-alone file, so you can link to any one of those with no trouble (pageindex.php still requires static pages 1.2, and fileindex.php requires the filemgmt plugin).

View siteindex.php in action here, and download the 1.2 zipped distro here. Note I'll also be uploading the file here on geeklog.net and on Squatty's when he's done changing hosts.

---
L. Whitworth
www.finiserv.com


L. Whitworth
 Quote

Status: offline

lenz

Forum User
Newbie
Registered: 02/20/03
Posts: 7
Does not seem to work for me I get an " 1054: Unknown column 'owner_id' in 'where clause' " error. There are not docs - This is just supposed to work if you drop it into public_html for your site? I have both filemanagement and the stock static pages...
 Quote

tek

Anonymous
I am having the same problem with the siteindex.php file. The storyindex.php works and I like it! Are you taking additional requests? How about a topicindex.php? If it could be made into a phpblock like the sections block that would be excellent. I would like to replace the sectionsblock query results with an index of links per topic. It would make navigation ten times easier.
 Quote

Status: offline

emagin

Forum User
Regular Poster
Registered: 08/05/03
Posts: 92
I\'ve made some slight modifications to the original SiteIndex V 1.2 to make the display simpler and tighter. I moved the Title part to the far left, and made the links directly on the title where possible. File is here The thing I\'m not clear on yet is how to add SECURITY. If you lock down various sections from ANONYMOUS users in Config.php, how do you make sure that the Index hides those sections from ANON users as well?
 Quote


hhop

Anonymous
 Quote

Status: offline

mrb42

Forum User
Junior
Registered: 10/15/04
Posts: 20
Here is what I use on my site... Site index @ NEOHMUSIC.COM
Text Formatted Code
<?php
// +---------------------------------------------------------------------------+
// | siteindex.php                                                            |
// | This is a event index page made especially for googlebots.                |
// +---------------------------------------------------------------------------|
// | Copyright (C) 2002 by the following authors:                              |
// | Tom Willett                 -    twillett@users.sourceforge.net           |
// | Lee Whitworth               -    lwhitworth@users.sourceforge.net         |
// +---------------------------------------------------------------------------|
// | This program is free software; you can redistribute it and/or             |
// | modify it under the terms of the GNU General Public License               |
// | as published by the Free Software Foundation; either version 2            |
// | of the License, or (at your option) any later version.                    |
// |                                                                           |
// | This program is distributed in the hope that it will be useful,           |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
// | GNU General Public License for more details.                              |
// |                                                                           |
// | You should have received a copy of the GNU General Public License         |
// | along with this program; if not, write to the Free Software               |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA|
// |                                                                           |
// +---------------------------------------------------------------------------|
require_once('lib-common.php');


$perpage = 75;

$display = COM_siteHeader('none');

$display .= '<h1>Site Index</h1>';

$sql = "SELECT *,unix_timestamp(date) AS day FROM {$_TABLES['stories']} WHERE (date <= NOW()) AND (draft_flag = 0)";
$sql .= " AND (";
if (!empty ($_USER['uid'])) {
    $groupList = '';
    foreach ($_GROUPS as $grp) {
        $groupList .= $grp . ',';
    }
    $groupList = substr ($groupList, 0, -1);
    $sql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
    $sql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
    $sql .= "(perm_members >= 2) OR ";
}
$sql .= "(perm_anon >= 2))";

if (empty($page)) {
   
    $page = 1;
}

$offset = ($page -1) * $perpage;

$order = " ORDER BY sid DESC LIMIT $offset, $perpage";

$recs = DB_query($sql . $order);
$nrows = DB_numRows($recs);

$display .= '<table width="100%"><tr><td>Date</td><td>Topic</td><td>Title</td></tr>';

for ($x = 0; $x < $nrows; $x++) {
    $A = DB_fetchArray($recs);
    $display .= '<tr><td>' . $A['date'] . '</td>';
    $display .= '<td>' . $A['tid'] . '</td>';
    $display .= '<td>';
    $display .= '<a href="' . $_CONF['site_url'] . '/article.php?story=' . $A['sid'] . '">'
             . stripslashes($A['title']) . '</a>';
    $display .='</td></tr>';    

}
                           
$display .= '</table><p>';

$countsql = "SELECT count(*) as count FROM {$_TABLES['stories']} WHERE (date <= NOW()) AND (draft_flag = 0)";
$countsql .= " AND (";
if (!empty ($_USER['uid'])) {
   
    $countsql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
    $countsql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
    $countsql .= "(perm_members >= 2) OR ";
}
$countsql .= "(perm_anon >= 2))";

$data = DB_query($countsql);
$D = DB_fetchArray($data);
$num_pages = ceil($D['count'] / $perpage);

$base_url = $_CONF['site_url'] . '/siteindex.php';
$display .= COM_printPageNavigation($base_url,$page, $num_pages);
$display .= '</p>';

// +---------------------------------------------------------------------------+
// | eventindex.php                                                            |
// | This is a event index page made especially for googlebots.                |
// +---------------------------------------------------------------------------|
// | Copyright (C) 2002 by the following authors:                              |
// | Tom Willett                 -    twillett@users.sourceforge.net           |
// | Lee Whitworth               -    lwhitworth@users.sourceforge.net         |
// +---------------------------------------------------------------------------|
// | This program is free software; you can redistribute it and/or             |
// | modify it under the terms of the GNU General Public License               |
// | as published by the Free Software Foundation; either version 2            |
// | of the License, or (at your option) any later version.                    |
// |                                                                           |
// | This program is distributed in the hope that it will be useful,           |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
// | GNU General Public License for more details.                              |
// |                                                                           |
// | You should have received a copy of the GNU General Public License         |
// | along with this program; if not, write to the Free Software               |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA|
// |                                                                           |
// +---------------------------------------------------------------------------|

$display .= '<h1>Event Index</h1>';

$sql = "SELECT *,unix_timestamp(eid) AS day FROM {$_TABLES['events']} WHERE (datestart >= NOW())";
$sql .= " AND (";
if (!empty ($_USER['uid'])) {
    $groupList = '';
    foreach ($_GROUPS as $grp) {
        $groupList .= $grp . ',';
    }
    $groupList = substr ($groupList, 0, -1);
    $sql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
    $sql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
    $sql .= "(perm_members >= 2) OR ";
}
$sql .= "(perm_anon >= 2))";

if (empty($page)) {
    // If no page sent then assume the first.
    $page = 1;
}

$offset = ($page -1) * $perpage;

$order = " ORDER BY eid DESC LIMIT $offset, $perpage";

$recs = DB_query($sql . $order);
$nrows = DB_numRows($recs);

$display .= '<table width="100%"><tr><td><b>EID</b></td><td><b>Title</b></td><td><b>Type</b></td><td><b>Start</b></td><td><b>End</b></td></tr>';

for ($x = 0; $x < $nrows; $x++) {
    $A = DB_fetchArray($recs);
    $display .= '<tr><td>' . $A['eid'] . '</td>';
    $display .= '<td>';
    $display .= '<a href="' . $_CONF['site_url'] . '/calendar_event.php?mode=&eid=' . $A['eid'] . '">'
             . stripslashes($A['title']) . '</a>';
        $display .= '</td>' . '<td>' . $A['event_type'] . '</td>';
    $display .= '<td>' . $A['datestart'] . '<br>' . $A['timestart'] . '</td>';
        $display .= '<td>' . $A['dateend'] . '<br>' . $A['timeend'] . '</td></tr>';
}
                           
$display .= '</table><p>';

$countsql = "SELECT count(*) as count FROM {$_TABLES['events']} WHERE (datestart >= NOW())";
$countsql .= " AND (";
if (!empty ($_USER['uid'])) {
    // Note: $groupList re-used from above
    $countsql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
    $countsql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
    $countsql .= "(perm_members >= 2) OR ";
}
$countsql .= "(perm_anon >= 2))";

$data = DB_query($countsql);
$D = DB_fetchArray($data);
$num_pages = ceil($D['count'] / $perpage);

 // Print Google-like paging navigation
$base_url = $_CONF['site_url'] . '/eventindex.php';
$display .= COM_printPageNavigation($base_url,$page, $num_pages);
$display .= '</p>';

// +---------------------------------------------------------------------------+
// | linkindex.php                                                             |
// | This is a link index page made especially for googlebots.                 |
// +---------------------------------------------------------------------------|
// | Copyright (C) 2002 by the following authors:                              |
// | Tom Willett                 -    twillett@users.sourceforge.net           |
// | Lee Whitworth               -    lwhitworth@users.sourceforge.net         |
// +---------------------------------------------------------------------------|
// | This program is free software; you can redistribute it and/or             |
// | modify it under the terms of the GNU General Public License               |
// | as published by the Free Software Foundation; either version 2            |
// | of the License, or (at your option) any later version.                    |
// |                                                                           |
// | This program is distributed in the hope that it will be useful,           |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
// | GNU General Public License for more details.                              |
// |                                                                           |
// | You should have received a copy of the GNU General Public License         |
// | along with this program; if not, write to the Free Software               |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA|
// |                                                                           |
// +---------------------------------------------------------------------------|

$display .= '<h1>Link Index</h1>';

$sql = "SELECT *,unix_timestamp(date) AS day FROM {$_TABLES['links']} WHERE (date <= NOW())";
$sql .= " AND (";
if (!empty ($_USER['uid'])) {
    $groupList = '';
    foreach ($_GROUPS as $grp) {
        $groupList .= $grp . ',';
    }
    $groupList = substr ($groupList, 0, -1);
    $sql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
    $sql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
    $sql .= "(perm_members >= 2) OR ";
}
$sql .= "(perm_anon >= 2))";

if (empty($page)) {
    // If no page sent then assume the first.
    $page = 1;
}

$offset = ($page -1) * $perpage;

$order = " ORDER BY lid DESC LIMIT $offset, $perpage";

$recs = DB_query($sql . $order);
$nrows = DB_numRows($recs);

$display .= '<table width="100%"><tr><td><b>Date</b></td><td><b>Title</b></td><td><b>Link</b></td><td><b>Hits</b></td></tr>';

for ($x = 0; $x < $nrows; $x++) {
    $A = DB_fetchArray($recs);
    $display .= '<tr><td>' . $A['date'] . '</td>';
    $display .= '<td>' . $A['title'] . '</td>';
    $display .= '<td>';
    $display .= '<a href="' . $_CONF['site_url'] . '/portal.php?what=link&item=' . $A['lid'] . '">'
             . $A['url'] . '</a>';
    $display .='</td>' . '<td>' . $A['hits'] . '</td></tr>';    

}
                           
$display .= '</table><p>';

$countsql = "SELECT count(*) as count FROM {$_TABLES['links']} WHERE (date <= NOW())";
$countsql .= " AND (";
if (!empty ($_USER['uid'])) {
    // Note: $groupList re-used from above
    $countsql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
    $countsql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
    $countsql .= "(perm_members >= 2) OR ";
}
$countsql .= "(perm_anon >= 2))";

$data = DB_query($countsql);
$D = DB_fetchArray($data);
$num_pages = ceil($D['count'] / $perpage);

 // Print Google-like paging navigation
$base_url = $_CONF['site_url'] . '/linkindex.php';
$display .= COM_printPageNavigation($base_url,$page, $num_pages);
$display .= '</p>';

// +---------------------------------------------------------------------------+
// | pageindex.php                                                             |
// | This is a index page for Tom's Staticpages 1.2 made especially for        |
// | googlebots. Only works with Staticpages 1.2!                              |
// +---------------------------------------------------------------------------|
// | Copyright (C) 2002 by the following authors:                              |
// | Tom Willett                 -    twillett@users.sourceforge.net           |
// | Lee Whitworth                               -    lwhitworth@users.sourceforge.net         |
// +---------------------------------------------------------------------------|
// | This program is free software; you can redistribute it and/or             |
// | modify it under the terms of the GNU General Public License               |
// | as published by the Free Software Foundation; either version 2            |
// | of the License, or (at your option) any later version.                    |
// |                                                                           |
// | This program is distributed in the hope that it will be useful,           |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
// | GNU General Public License for more details.                              |
// |                                                                           |
// | You should have received a copy of the GNU General Public License         |
// | along with this program; if not, write to the Free Software               |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA|
// |                                                                           |
// +---------------------------------------------------------------------------|

$display .= '<div align="center"><p><h1>Page Index<h1></div>';

$sql = "SELECT *,unix_timestamp(sp_date) AS day FROM {$_TABLES['staticpage']} WHERE (sp_date <= NOW())";
$sql .= " AND (";
if (!empty ($_USER['uid'])) {
    $groupList = '';
    foreach ($_GROUPS as $grp) {
        $groupList .= $grp . ',';
    }
    $groupList = substr ($groupList, 0, -1);
    $sql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
    $sql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
    $sql .= "(perm_members >= 2) OR ";
}
$sql .= "(perm_anon >= 2))";

if (empty($page)) {
    // If no page sent then assume the first.
    $page = 1;
}

$offset = ($page -1) * $perpage;

$order = " ORDER BY sp_id DESC LIMIT $offset, $perpage";

$recs = DB_query($sql . $order);
$nrows = DB_numRows($recs);

$display .= '<table width="100%"><tr><td><b>Date</b></td><td><b>Label</b></td><td><b>Title</b></td><td><b>Views</b></td></tr>';

for ($x = 0; $x < $nrows; $x++) {
    $A = DB_fetchArray($recs);
    $display .= '<tr><td>' . $A['sp_date'] . '</td>';
    $display .= '<td>' . $A['sp_label'] . '</td>';
    $display .= '<td>';
    $display .= '<a href="' . $_CONF['site_url'] . '/staticpages/index.php?page=' . $A['sp_id'] . '">'
             . stripslashes($A['sp_title']) . '</a>';
    $display .='</td>' . '<td>' . $A['sp_hits'] . '</td></tr>';    

}
                           
$display .= '</table><p>';

$countsql = "SELECT count(*) as count FROM {$_TABLES['staticpage']} WHERE (sp_date <= NOW())";
$countsql .= " AND (";
if (!empty ($_USER['uid'])) {
    // Note: $groupList re-used from above
    $countsql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
    $countsql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
    $countsql .= "(perm_members >= 2) OR ";
}
$countsql .= "(perm_anon >= 2))";

$data = DB_query($countsql);
$D = DB_fetchArray($data);
$num_pages = ceil($D['count'] / $perpage);

 // Print Google-like paging navigation
$base_url = $_CONF['site_url'] . '/pageindex.php';
$display .= COM_printPageNavigation($base_url,$page, $num_pages);
$display .= '</p>';

// +---------------------------------------------------------------------------+
// | voteindex.php                                                             |
// | This is a poll index page made especially for googlebots.                 |
// +---------------------------------------------------------------------------|
// | Copyright (C) 2002 by the following authors:                              |
// | Tom Willett                 -    twillett@users.sourceforge.net           |
// | Lee Whitworth               -    lwhitworth@users.sourceforge.net         |
// +---------------------------------------------------------------------------|
// | This program is free software; you can redistribute it and/or             |
// | modify it under the terms of the GNU General Public License               |
// | as published by the Free Software Foundation; either version 2            |
// | of the License, or (at your option) any later version.                    |
// |                                                                           |
// | This program is distributed in the hope that it will be useful,           |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
// | GNU General Public License for more details.                              |
// |                                                                           |
// | You should have received a copy of the GNU General Public License         |
// | along with this program; if not, write to the Free Software               |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA|
// |                                                                           |
// +---------------------------------------------------------------------------|

$display .= '<h1>Poll Index</h1>';

$sql = "SELECT *,unix_timestamp(date) AS day FROM {$_TABLES['pollquestions']} WHERE (date <= NOW())";
$sql .= " AND (";
if (!empty ($_USER['uid'])) {
    $groupList = '';
    foreach ($_GROUPS as $grp) {
        $groupList .= $grp . ',';
    }
    $groupList = substr ($groupList, 0, -1);
    $sql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
    $sql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
    $sql .= "(perm_members >= 2) OR ";
}
$sql .= "(perm_anon >= 2))";

if (empty($page)) {
    // If no page sent then assume the first.
    $page = 1;
}

$offset = ($page -1) * $perpage;

$order = " ORDER BY date DESC LIMIT $offset, $perpage";

$recs = DB_query($sql . $order);
$nrows = DB_numRows($recs);

$display .= '<table width="100%"><tr><td><b>Date</b></td><td><b>Question</b></td><td><b>Votes</b></td></tr>';

for ($x = 0; $x < $nrows; $x++) {
    $A = DB_fetchArray($recs);
    $display .= '<tr><td>' . $A['date'] . '</td>';
    $display .= '<td>';
    $display .= '<a href="' . $_CONF['site_url'] . '/pollbooth.php?qid=' . $A['qid'] . '">'
             . $A['question'] . '</a>';
    $display .='</td>' . '<td>' . $A['voters'] . '</td></tr>';
}
                           
$display .= '</table><p>';

$countsql = "SELECT count(*) as count FROM {$_TABLES['pollquestions']} WHERE (date <= NOW())";
$countsql .= " AND (";
if (!empty ($_USER['uid'])) {
    // Note: $groupList re-used from above
    $countsql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
    $countsql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
    $countsql .= "(perm_members >= 2) OR ";
}
$countsql .= "(perm_anon >= 2))";

$data = DB_query($countsql);
$D = DB_fetchArray($data);
$num_pages = ceil($D['count'] / $perpage);

 // Print Google-like paging navigation
$base_url = $_CONF['site_url'] . '/voteindex.php';
$display .= COM_printPageNavigation($base_url,$page, $num_pages);
$display .= '</p>';

$display .= COM_siteFooter();
echo $display;
?>

 
 Quote

All times are EDT. The time is now 07:06 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content