plugins/Decir.php
author Dan
Thu, 29 Nov 2007 21:48:02 -0500
changeset 11 5585ac341820
parent 7 37387f84fe25
permissions -rwxr-xr-x
SECURITY: fix stupid XSS vulnerability on initial post submit; add in support for the new search API
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     1
<?php
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     2
/*
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     3
Plugin Name: Decir
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     4
Plugin URI: javascript: // No URL yet, stay tuned!
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     5
Description: Decir is an advanced bulletin board system (forum) for Enano. 
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     6
Author: Dan Fuhry
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     7
Version: 0.1
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     8
Author URI: http://www.enanocms.org/
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     9
*/
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    10
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    11
/*
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    12
 * Decir
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    13
 * Version 0.1
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    14
 * Copyright (C) 2007 Dan Fuhry
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    15
 *
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    16
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    17
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    18
 *
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    19
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    20
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    21
 */
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    22
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    23
define('ENANO_DECIR_VERSION', '0.1');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    24
define('DECIR_ROOT', ENANO_ROOT . '/decir');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    25
 
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    26
$plugins->attachHook('acl_rule_init', 'decir_early_init($this, $session);');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    27
$plugins->attachHook('base_classes_initted', '
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    28
    $paths->add_page(Array(
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    29
      \'name\'=>\'Forum\',
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    30
      \'urlname\'=>\'Forum\',
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    31
      \'namespace\'=>\'Special\',
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    32
      \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    33
      ));
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    34
  ');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    35
6
3f66ec435f08 Some basic admin implemented
Dan
parents: 5
diff changeset
    36
require( DECIR_ROOT . '/admincp/admin_base.php' );
11
5585ac341820 SECURITY: fix stupid XSS vulnerability on initial post submit; add in support for the new search API
Dan
parents: 7
diff changeset
    37
require( DECIR_ROOT . '/search.php' );
6
3f66ec435f08 Some basic admin implemented
Dan
parents: 5
diff changeset
    38
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    39
function decir_early_init(&$paths, &$session)
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    40
{
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    41
  $paths->addAdminNode('Decir forum configuration', 'General settings', 'DecirGeneral');
7
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    42
  $paths->create_namespace('DecirForum', $paths->nslist['Special'] . 'Forum/ViewForum/');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    43
  $paths->create_namespace('DecirPost',  $paths->nslist['Special'] . 'Forum/Post/');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    44
  $paths->create_namespace('DecirTopic', $paths->nslist['Special'] . 'Forum/Topic/');
3
88b85b9b9272 What can I say? More progress. Mostly bugfixes and ACL stuff now. Which reminds me - don't use this release, there are quite a few access bugs in it right now.
Dan
parents: 2
diff changeset
    45
  
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    46
  $session->register_acl_type('decir_see_forum',  AUTH_ALLOW, 'See forum in index', Array('read'),             'DecirForum');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    47
  $session->register_acl_type('decir_view_forum', AUTH_ALLOW, 'View forum',         Array('decir_see_forum'),  'DecirForum');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    48
  $session->register_acl_type('decir_post',       AUTH_ALLOW, 'Post new topics',    Array('decir_view_forum'), 'DecirForum');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    49
  $session->register_acl_type('decir_reply',      AUTH_ALLOW, 'Reply to topics',    Array('decir_post'),       'DecirTopic');
7
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    50
  $session->register_acl_type('decir_edit_own',   AUTH_ALLOW, 'Edit own posts',     Array('decir_post'),       'DecirPost');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    51
  $session->register_acl_type('decir_edit_other', AUTH_DISALLOW, 'Edit others\' posts', Array('decir_post'),   'DecirPost');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    52
  $session->register_acl_type('decir_delete_own_post_soft', AUTH_ALLOW, 'Delete own posts (soft)', Array('decir_edit_own'), 'DecirPost');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    53
  $session->register_acl_type('decir_delete_own_post_hard', AUTH_DISALLOW, 'Delete own posts (hard)', Array('decir_delete_own_post_soft'), 'DecirPost');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    54
  $session->register_acl_type('decir_delete_other_post_soft', AUTH_DISALLOW, 'Delete others\' posts (soft)', Array('decir_edit_other'), 'DecirPost');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    55
  $session->register_acl_type('decir_delete_other_post_hard', AUTH_DISALLOW, 'Delete others\' posts (hard)', Array('decir_delete_other_post_soft'), 'DecirPost');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    56
  $session->register_acl_type('decir_undelete_own_post', AUTH_DISALLOW, 'Undelete own posts', Array('decir_edit_own'), 'DecirPost');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    57
  $session->register_acl_type('decir_undelete_other_post', AUTH_DISALLOW, 'Undelete others\' posts', Array('decir_edit_other'), 'DecirPost');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    58
  $session->register_acl_type('decir_undelete_own_topic', AUTH_DISALLOW, 'Undelete own topics', Array('read'), 'DecirTopic');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    59
  $session->register_acl_type('decir_undelete_other_topic', AUTH_DISALLOW, 'Undelete others\' topics', Array('read'), 'DecirTopic');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    60
  $session->register_acl_type('decir_see_deleted_post', AUTH_ALLOW, 'See placeholders for deleted posts', Array('read'), 'Special|DecirPost|DecirTopic|DecirForum');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    61
  $session->register_acl_type('decir_see_deleted_post_full', AUTH_DISALLOW, 'Read the full contents of deleted posts', Array('decir_see_deleted_post'), 'Special|DecirPost|DecirTopic|DecirForum');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    62
  $session->register_acl_type('decir_see_deleted_topic', AUTH_ALLOW, 'See placeholders for deleted topics', Array('read'), 'DecirTopic|DecirForum');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    63
  $session->register_acl_type('decir_see_deleted_topic_full', AUTH_DISALLOW, 'Read the full contents of deleted topics', Array('decir_see_deleted_topic'), 'Special|DecirTopic|DecirForum');
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    64
}
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    65
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    66
function page_Special_Forum()
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    67
{
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    68
  global $db, $session, $paths, $template, $plugins; // Common objects
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    69
  
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    70
  if ( getConfig('decir_version') != ENANO_DECIR_VERSION || isset($_POST['do_install_finish']) )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    71
  {
6
3f66ec435f08 Some basic admin implemented
Dan
parents: 5
diff changeset
    72
    chdir(DECIR_ROOT);
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    73
    require(DECIR_ROOT . '/install.php');
1
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
    74
    return false;
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    75
  }
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    76
  
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    77
  $act = strtolower( ( $n = $paths->getParam(0) ) ? $n : 'Index' );
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    78
  
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    79
  $curdir = getcwd();
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    80
  chdir(DECIR_ROOT);
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    81
  
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    82
  switch($act)
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    83
  {
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    84
    case 'index':
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    85
    default:
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    86
      require('forum_index.php');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    87
      break;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    88
    case 'viewforum':
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    89
      require('viewforum.php');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    90
      break;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    91
    case 'topic':
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    92
    case 'post':
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    93
    case 'viewtopic':
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    94
      require('viewtopic.php');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    95
      break;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    96
    case 'new':
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    97
      require('posting.php');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    98
      break;
7
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
    99
    case 'edit':
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
   100
      require('edit.php');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
   101
      break;
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
   102
    case 'delete':
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
   103
      require('delete.php');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
   104
      break;
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
   105
    case 'restoretopic':
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
   106
      require('restoretopic.php');
37387f84fe25 Add edit functionality to forum management and implemented a sick drag-and-drop reordering system for forums
Dan
parents: 6
diff changeset
   107
      break;
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   108
  }
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   109
  
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   110
  chdir($curdir);
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   111
  
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   112
}
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   113
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   114
?>