Version 1.0.1

This commit is contained in:
Neo committed 2025-12-19 00:15:26 -08:00
1 parent 227753f492
commit aabfdc1f57
341 files changed
+55517

No files matched your search

+696
View File
@@ -0,0 +1,696 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Admin Category functions
| > Module written by Matt Mecham
| > Date started: 1st march 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new ad_cat();
class ad_cat {
var $base_url;
function ad_cat() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
switch($IN['code'])
{
case 'new':
$this->new_form();
break;
case 'donew':
$this->do_new();
break;
//+-------------------------
case 'edit':
$this->show_cats();
break;
case 'doeditform':
$this->edit_form();
break;
case 'doedit':
$this->do_edit();
break;
//+-------------------------
case 'remove':
$this->remove_form();
break;
case 'doremove':
$this->do_remove();
break;
//+-------------------------
case 'reorder':
$this->reorder_form(); //Get it? No... ok.
break;
case 'doreorder':
$this->do_reorder();
break;
default:
$this->show_cats();
break;
}
}
//+---------------------------------------------------------------------------------
//
// RE-ORDER CATEGORY
//
//+---------------------------------------------------------------------------------
function reorder_form() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$ADMIN->page_title = "Category Re Order";
$ADMIN->page_detail = "To re-order the categories, simply choose the position number from the drop down box next to each category title, when you are satisfied with the ordering, simply hit the submit button at the bottom of the form";
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'doreorder'),
2 => array( 'act' , 'cat' ),
) );
$SKIN->td_header[] = array( "&nbsp;" , "10%" );
$SKIN->td_header[] = array( "Forum Name" , "60%" );
$SKIN->td_header[] = array( "Posts" , "15%" );
$SKIN->td_header[] = array( "Topics" , "15%" );
$ADMIN->html .= $SKIN->start_table( "Your Categories and Forums" );
$cats = array();
$forums = array();
$DB->query("SELECT * from ibf_categories WHERE id > 0 ORDER BY position ASC");
while ($r = $DB->fetch_row())
{
$cats[] = $r;
}
$DB->query("SELECT * from ibf_forums ORDER BY position ASC");
while ($r = $DB->fetch_row())
{
$forums[] = $r;
}
// Build up the drop down box
$form_array = array();
for ($i = 1 ; $i <= count($cats) ; $i++ )
{
$form_array[] = array( $i , $i );
}
$last_cat_id = -1;
foreach ($cats as $c)
{
$ADMIN->html .= $SKIN->add_td_row( array( $SKIN->form_dropdown( 'POS_'.$c['id'], $form_array, $c['position'] ),
$c['name'],
'&nbsp;',
'&nbsp;',
), 'catrow' );
$last_cat_id = $c['id'];
foreach($forums as $r)
{
if ($r['category'] == $last_cat_id)
{
$ADMIN->html .= $SKIN->add_td_row( array(
'&nbsp;',
"<b>".$r['name']."</b><br>".$r['description'],
$r['posts'],
$r['topics'],
) );
}
}
}
$ADMIN->html .= $SKIN->end_form("Adjust Category Ordering");
$ADMIN->html .= $SKIN->end_table();
$ADMIN->output();
}
//+---------------------------------------------------------------------------------
function do_reorder() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$cat_query = $DB->query("SELECT id from ibf_categories");
while ( $r = $DB->fetch_row($cat_query) )
{
$order_query = $DB->query("UPDATE ibf_categories SET position='".$IN[ 'POS_' . $r['id'] ]."' WHERE id='".$r['id']."'");
}
$ADMIN->done_screen("Category Ordering Adjusted", "Category Control", "act=cat" );
}
//+---------------------------------------------------------------------------------
//
// REMOVE CATEGORY
//
//+---------------------------------------------------------------------------------
function remove_form() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$form_array = array();
if ($IN['c'] == "")
{
$ADMIN->error("Could not determine the category ID to update.");
}
$DB->query("SELECT id, name FROM ibf_categories WHERE id > 0 ");
//+-------------------------------
// Make sure we have more than 1
// category..
//+-------------------------------
if ($DB->get_num_rows() < 2)
{
$ADMIN->error("Can not remove this category, please create another before attempting to remove this one");
}
while ( $r = $DB->fetch_row() )
{
if ($r['id'] == $IN['c'])
{
continue;
}
$form_array[] = array( $r['id'] , $r['name'] );
}
//+-------------------------------
// Get the details for this category...
//+-------------------------------
$DB->query("SELECT * FROM ibf_categories WHERE id='".$IN['c']."'");
$cat = $DB->fetch_row();
//+-------------------------------
$ADMIN->page_title = "Removing category '{$cat['name']}'";
$ADMIN->page_detail = "Before we remove this category, we need to determine what to do with any forums you may have left in this category.";
//+-------------------------------
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'doremove'),
2 => array( 'act' , 'cat' ),
3 => array( 'c' , $IN['c'] ),
) );
//+-------------------------------
$SKIN->td_header[] = array( "&nbsp;" , "40%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( "Required" );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Category to remove: </b>" , $cat['name'] ) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Move all <i>existing forums in this category</i> to which category?</b>" ,
$SKIN->form_dropdown( "MOVE_ID", $form_array )
) );
$ADMIN->html .= $SKIN->end_form("Move forums and delete this category");
$ADMIN->html .= $SKIN->end_table();
$ADMIN->output();
}
//+---------------------------------------------------------------------------------
function do_remove() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ($IN['c'] == "")
{
$ADMIN->error("Could not determine the source category ID.");
}
if ($IN['MOVE_ID'] == "")
{
$ADMIN->error("Could not determine the destination category ID.");
}
$DB->query("UPDATE ibf_forums SET category='".$IN['MOVE_ID']."' WHERE category='".$IN['c']."'");
$DB->query("DELETE FROM ibf_categories WHERE id='".$IN['c']."'");
$ADMIN->done_screen("Category Removed", "Category Control", "act=cat" );
}
//+---------------------------------------------------------------------------------
//
// EDIT CATEGORY
//
//+---------------------------------------------------------------------------------
function edit_form() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$subcats = array();
$DB->query("SELECT id, name FROM ibf_categories WHERE id > 0");
while ( $r = $DB->fetch_row() )
{
if ($r['id'] == $IN['c'])
{
continue;
}
$subcats[] = array( $r['id'] , $r['name'] );
}
$DB->query("SELECT * FROM ibf_categories WHERE id='".$IN['c']."'");
$cat = $DB->fetch_row();
$ADMIN->page_title = "Edit a category";
$ADMIN->page_detail = "This section will allow you to edit a new category. If you wish to add a category 'sponsor', simply enter the image URL and website URL
in the appropriate section.";
//+-------------------------------
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'doedit'),
2 => array( 'VIEW' , '*' ),
3 => array( 'act' , 'cat' ),
4 => array( 'c' , $IN['c'] ),
) );
//+-------------------------------
$SKIN->td_header[] = array( "&nbsp;" , "30%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( "Required" );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Category Name</b>" ,
$SKIN->form_input("CAT_NAME", $cat['name'])
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Category State</b>" ,
$SKIN->form_dropdown( "CAT_STATE",
array(
0 => array( 1, 'Visible' ),
1 => array( 0, 'Hidden' ),
),
$cat['state']
)
) );
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
$SKIN->td_header[] = array( "&nbsp;" , "30%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
$ADMIN->html .= $SKIN->start_table( "Optional" );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Category Sponsor Image</b><br>(Example: http://www.domain.com/image.gif)" ,
$SKIN->form_input("IMAGE", $cat['image'])
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Category Sponsor Link</b><br>(Example: http://www.domain.com/)" ,
$SKIN->form_input("URL", $cat['url'])
) );
$ADMIN->html .= $SKIN->end_form("Amend this category");
$ADMIN->html .= $SKIN->end_table();
$ADMIN->output();
}
//+---------------------------------------------------------------------------------
function do_edit() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$IN['CAT_NAME'] = trim($IN['CAT_NAME']);
if ($IN['CAT_NAME'] == "")
{
$ADMIN->error("You must enter a category title");
}
if ($IN['c'] == "")
{
$ADMIN->error("Could not determine the category ID to update.");
}
$db_string = $DB->compile_db_update_string( array (
'state' => $IN['CAT_STATE'],
'name' => $IN['CAT_NAME'],
'description' => $IN['CAT_DESC'],
'image' => $IN['IMAGE'],
'url' => $IN['URL'],
) );
$DB->query("UPDATE ibf_categories SET $db_string WHERE id='".$IN['c']."'");
$ADMIN->done_screen("Category '{$IN['CAT_NAME']}' Edited", "Category Control", "act=cat" );
}
//+---------------------------------------------------------------------------------
//
// SHOW CATS
// Renders a complete listing of all the forums and categories.
//
//+---------------------------------------------------------------------------------
function show_cats() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$ADMIN->page_title = "Category and Forums Overview";
$ADMIN->page_detail = "This section will provide you with a category and forums overview allowing you to make fast changes to the category/forums set up and information.".
"<br><table cellpadding='3' cellspacing='0' border='0' align='left' width='100%'>".
"<tr><td><b>Edit Settings</b></td><td>This allows you to edit the forum settings</td></tr>".
"<tr><td><b>Delete</b></td><td>This will remove the forum and move the posts and topics to a forum of your choice</td></tr>".
"<tr><td><b>Empty</b></td><td>This will remove all topics and posts in this forum - a confirmation screen is displayed</td></tr>".
"<tr><td><b>Edit Permissions</b></td><td>This allows you to edit the forum access abilities for all groups in this forum</td></tr>".
"<tr><td><img src='{$SKIN->img_url}/acp_rules.gif' border='0' align='absmiddle'></td><td><b>Forum Rules</b> This allows you to add/edit or remove rules for this forum</td></tr>".
"<tr><td><img src='{$SKIN->img_url}/acp_edit.gif' border='0' align='absmiddle'></td><td><b>Skin Options</b> This allows you to add/edit or remove a skin for this forum</td></tr>".
"<tr><td><img src='{$SKIN->img_url}/acp_resync.gif' border='0' align='absmiddle'></td><td><b>Resynchronise</b> This allows you to recount the forum posts, topics and last post information</td></tr>".
"</table>";
$cats = array();
$forums = array();
$children = array();
$skins = array();
$DB->query("SELECT * from ibf_categories WHERE id > 0 ORDER BY position ASC");
while ($r = $DB->fetch_row())
{
$cats[$r['id']] = $r;
}
$DB->query("SELECT * from ibf_forums ORDER BY position ASC");
while ($r = $DB->fetch_row())
{
if ($r['parent_id'] > 0)
{
$children[ $r['parent_id'] ][] = $r;
}
else
{
$forums[] = $r;
}
}
$DB->query("SELECT uid, sname, sid FROM ibf_skins");
while ($s = $DB->fetch_row())
{
$skins[$s['sid']] = $s['sname'];
}
$SKIN->td_header[] = array( "&nbsp;" , "5%" );
$SKIN->td_header[] = array( "Forum Name" , "30%" );
$SKIN->td_header[] = array( "Posts" , "10%" );
$SKIN->td_header[] = array( "Topics" , "10%" );
$SKIN->td_header[] = array( "&nbsp;" , "15%" );
$SKIN->td_header[] = array( "&nbsp;" , "15%" );
$SKIN->td_header[] = array( "&nbsp;" , "15%" );
$ADMIN->html .= $SKIN->start_table("Your Categories and Forums");
$last_cat_id = -1;
foreach ($cats as $c)
{
$ADMIN->html .= $SKIN->add_td_row( array(
array($c['name'], 2),
'&nbsp;',
'&nbsp;',
"<a href='{$ADMIN->base_url}&act=cat&code=doeditform&c={$c['id']}'>Edit</a>",
'&nbsp;',
"<a href='{$ADMIN->base_url}&act=cat&code=remove&c={$c['id']}'>Delete</a>",
), 'catrow' );
$last_cat_id = $c['id'];
foreach($forums as $r)
{
if ($r['category'] == $last_cat_id)
{
if ( ($r['skin_id'] != "") and ($r['skin_id'] >= 0) )
{
$skin_stuff = "<br>[ "."Using Skin Set: ".$skins[$r['skin_id']]." ]";
}
else
{
$skin_stuff = "";
}
if ($r['subwrap'] == 1)
{
$ADMIN->html .= $SKIN->add_td_row( array(
"&nbsp;&gt;",
"<b>".$r['name']."</b>$skin_stuff",
"-",
"-",
"<a href='{$ADMIN->base_url}&act=forum&code=subedit&f={$r['id']}'>Edit</a>",
"<a href='{$ADMIN->base_url}&act=forum&code=skinedit&f={$r['id']}'>Skin Options</a>",
"<a href='{$ADMIN->base_url}&act=forum&code=subdelete&f={$r['id']}'>Delete</a>",
) , 'catrow2' );
}
else
{
$ADMIN->html .= $SKIN->add_td_row( array(
array("<b>".$r['name']."</b>$skin_stuff<br>".$r['description'], 2),
$r['posts'],
$r['topics'],
"<a href='{$ADMIN->base_url}&act=forum&code=edit&f={$r['id']}'>Edit Settings</a><br><br>".
"<a href='{$ADMIN->base_url}&act=forum&code=pedit&f={$r['id']}'>Edit Permissions</a>",
"<center><a href='{$ADMIN->base_url}&act=forum&code=frules&f={$r['id']}'><img src='{$SKIN->img_url}/acp_rules.gif' border='0' title='Forum Rules'></a>&nbsp;&nbsp;".
"<a href='{$ADMIN->base_url}&act=forum&code=skinedit&f={$r['id']}'><img src='{$SKIN->img_url}/acp_edit.gif' border='0' title='Skin Options'></a>&nbsp;&nbsp;".
"<a href='{$ADMIN->base_url}&act=forum&code=recount&f={$r['id']}'><img src='{$SKIN->img_url}/acp_resync.gif' border='0' title='Resynchronise'></a></center>",
"<a href='{$ADMIN->base_url}&act=forum&code=delete&f={$r['id']}'>Delete</a><br><br>".
"<a href='{$ADMIN->base_url}&act=forum&code=empty&f={$r['id']}'>Empty Forum</a>",
) );
}
if ( ( isset($children[ $r['id'] ]) ) and ( count ($children[ $r['id'] ]) > 0 ) )
{
foreach($children[ $r['id'] ] as $idx => $rd)
{
if ( ($rd['skin_id'] != "") and ($rd['skin_id'] >= 0) )
{
$skin_stuff = "<br>[ "."Using Skin Set: ".$skins[$rd['skin_id']]." ]";
}
else
{
$skin_stuff = "";
}
$ADMIN->html .= $SKIN->add_td_row( array(
"&nbsp;&gt;",
"<b>".$rd['name']."</b>$skin_stuff<br>".$rd['description'],
$rd['posts'],
$rd['topics'],
"<a href='{$ADMIN->base_url}&act=forum&code=edit&f={$rd['id']}'>Edit Settings</a><br><br>".
"<a href='{$ADMIN->base_url}&act=forum&code=pedit&f={$rd['id']}'>Edit Permissions</a>",
"<center><a href='{$ADMIN->base_url}&act=forum&code=frules&f={$rd['id']}'><img src='{$SKIN->img_url}/acp_rules.gif' border='0' title='Forum Rules'></a>&nbsp;&nbsp;".
"<a href='{$ADMIN->base_url}&act=forum&code=skinedit&f={$rd['id']}'><img src='{$SKIN->img_url}/acp_edit.gif' border='0' title='Skin Options'></a>&nbsp;&nbsp;".
"<a href='{$ADMIN->base_url}&act=forum&code=recount&f={$rd['id']}'><img src='{$SKIN->img_url}/acp_resync.gif' border='0' title='Resynchronise'></a></center>",
"<a href='{$ADMIN->base_url}&act=forum&code=delete&f={$rd['id']}'>Delete</a><br><br>".
"<a href='{$ADMIN->base_url}&act=forum&code=empty&f={$rd['id']}'>Empty Forum</a>",
) , 'subforum' );
}
}
}
}
}
$ADMIN->html .= $SKIN->end_table();
$ADMIN->output();
}
//+---------------------------------------------------------------------------------
//
// NEW CATEGORY
//
//+---------------------------------------------------------------------------------
function new_form() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_GET_VARS;
$cat_name = "";
if ($HTTP_GET_VARS['name'] != "")
{
$cat_name = stripslashes(urldecode($HTTP_GET_VARS['name']));
}
$ADMIN->page_title = "Add a new category";
$ADMIN->page_detail = "This section will allow you to add a new category to your forums. If you wish to add a category 'sponsor', simply enter the image URL and website URL
in the appropriate section.";
//+-------------------------------
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'donew'),
2 => array( 'act' , 'cat' ),
) );
//+-------------------------------
$SKIN->td_header[] = array( "&nbsp;" , "30%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( "Required" );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Category Name</b>" ,
$SKIN->form_input("CAT_NAME", $cat_name)
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Category State</b>" ,
$SKIN->form_dropdown( "CAT_STATE",
array(
0 => array( 1, 'Visible' ),
1 => array( 0, 'Hidden' ),
),
"1"
)
) );
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
$SKIN->td_header[] = array( "&nbsp;" , "30%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
$ADMIN->html .= $SKIN->start_table( "Optional" );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Category Sponsor Image</b><br>(Example: http://www.domain.com/image.gif)" ,
$SKIN->form_input("IMAGE")
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Category Sponsor Link</b><br>(Example: http://www.domain.com/)" ,
$SKIN->form_input("URL")
) );
$ADMIN->html .= $SKIN->end_form("Create this category");
$ADMIN->html .= $SKIN->end_table();
$ADMIN->output();
}
//+---------------------------------------------------------------------------------
function do_new() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$IN['CAT_NAME'] = trim($IN['CAT_NAME']);
if ($IN['CAT_NAME'] == "")
{
$ADMIN->error("You must enter a category title");
}
// Get the new cat id. We could use auto_incrememnt, but we need the ID to use as the default
// category position...
$DB->query("SELECT MAX(id) as top_cat FROM ibf_categories"); //ooh, top cat - he's the leader of our gang..
$row = $DB->fetch_row();
if ($row['top_cat'] < 1) $row['top_cat'] = 0;
$row['top_cat']++;
$db_string = $DB->compile_db_insert_string( array (
'id' => $row['top_cat'],
'position' => $row['top_cat'],
'state' => $IN['CAT_STATE'],
'name' => $IN['CAT_NAME'],
'description' => $IN['CAT_DESC'],
'image' => $IN['IMAGE'],
'url' => $IN['URL'],
) );
$DB->query("INSERT INTO ibf_categories (".$db_string['FIELD_NAMES'].") VALUES (".$db_string['FIELD_VALUES'].")");
$ADMIN->done_screen("Category {$IN['CAT_NAME']} created", "Category Control", "act=cat" );
}
}
?>
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+273
View File
@@ -0,0 +1,273 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Help Control functions
| > Module written by Matt Mecham
| > Date started: 2nd April 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new ad_settings();
class ad_settings {
var $base_url;
function ad_settings() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
switch($IN['code'])
{
case 'edit':
$this->show_form('edit');
break;
case 'new':
$this->show_form('new');
break;
case 'doedit':
$this->doedit();
break;
case 'donew':
$this->doadd();
break;
case 'remove':
$this->remove();
break;
//-------------------------
default:
$this->list_files();
break;
}
}
//-------------------------------------------------------------
// HELP FILE FUNCTIONS
//-------------------------------------------------------------
function doedit()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
if ($IN['id'] == "")
{
$ADMIN->error("You must pass a valid emoticon id, silly!");
}
$text = preg_replace( "/\n/", "<br>", stripslashes($HTTP_POST_VARS['text'] ) );
$title = preg_replace( "/\n/", "<br>", stripslashes($HTTP_POST_VARS['title'] ) );
$desc = preg_replace( "/\n/", "<br>", stripslashes($HTTP_POST_VARS['description'] ) );
$db_string = $DB->compile_db_update_string( array( 'title' => $title,
'text' => $text,
'description' => $desc,
) );
$DB->query("UPDATE ibf_faq SET $db_string WHERE id='".$IN['id']."'");
$std->boink_it($SKIN->base_url."&act=help");
exit();
}
//=====================================================
function show_form($type='new')
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$ADMIN->page_detail = "You may add/edit and remove help files below.";
$ADMIN->page_title = "Help File Management";
//+-------------------------------
if ($type != 'new')
{
if ($IN['id'] == "")
{
$ADMIN->error("You must pass a valid help file id, silly!");
}
//+-------------------------------
$DB->query("SELECT * FROM ibf_faq WHERE id='".$IN['id']."'");
if ( ! $r = $DB->fetch_row() )
{
$ADMIN->error("We could not find that help file in the database");
}
//+-------------------------------
$button = 'Edit this Help File';
$code = 'doedit';
}
else
{
$r = array();
$button = 'Add this Help File';
$code = 'donew';
}
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , $code ),
2 => array( 'act' , 'help' ),
3 => array( 'id' , $IN['id'] ),
) );
$SKIN->td_header[] = array( "&nbsp;" , "20%" );
$SKIN->td_header[] = array( "&nbsp;" , "80%" );
$r['text'] = preg_replace( "/<br>/i", "\n", stripslashes($r['text']) );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( $button );
$ADMIN->html .= $SKIN->add_td_row( array( "Help File Title",
$SKIN->form_input('title' , stripslashes($r['title']) ),
) );
$ADMIN->html .= $SKIN->add_td_row( array( "Help File Description",
$SKIN->form_textarea('description', stripslashes($r['description']) ),
) );
$ADMIN->html .= $SKIN->add_td_row( array( "Help File Text",
$SKIN->form_textarea('text', $r['text'], "60", "10" ),
) );
$ADMIN->html .= $SKIN->end_form($button);
$ADMIN->html .= $SKIN->end_table();
$ADMIN->output();
}
//=====================================================
function remove()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ($IN['id'] == "")
{
$ADMIN->error("You must pass a valid help file id, silly!");
}
$DB->query("DELETE FROM ibf_faq WHERE id='".$IN['id']."'");
$std->boink_it($SKIN->base_url."&act=help");
exit();
}
//=====================================================
function doadd()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
if ($IN['title'] == "")
{
$ADMIN->error("You must enter a title, silly!");
}
$text = preg_replace( "/\n/", "<br>", stripslashes($HTTP_POST_VARS['text'] ) );
$title = preg_replace( "/\n/", "<br>", stripslashes($HTTP_POST_VARS['title'] ) );
$desc = preg_replace( "/\n/", "<br>", stripslashes($HTTP_POST_VARS['description'] ) );
$db_string = $DB->compile_db_insert_string( array( 'title' => $title,
'text' => $text,
'description' => $desc,
) );
$DB->query("INSERT INTO ibf_faq (".$db_string['FIELD_NAMES'].") VALUES(".$db_string['FIELD_VALUES'].")");
$std->boink_it($SKIN->base_url."&act=help");
exit();
}
//=====================================================
function list_files()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$ADMIN->page_detail = "You may add/edit and remove help files below.";
$ADMIN->page_title = "Help File Management";
//+-------------------------------
$SKIN->td_header[] = array( "Title" , "50%" );
$SKIN->td_header[] = array( "Edit" , "30%" );
$SKIN->td_header[] = array( "Remove" , "20%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( "Current Help Files" );
$DB->query("SELECT * from ibf_faq ORDER BY id ASC");
if ( $DB->get_num_rows() )
{
while ( $r = $DB->fetch_row() )
{
$ADMIN->html .= $SKIN->add_td_row( array( "<b>".stripslashes($r['title'])."</b><br>".stripslashes($r['description']),
"<center><a href='".$SKIN->base_url."&act=help&code=edit&id={$r['id']}'>Edit</a></center>",
"<center><a href='".$SKIN->base_url."&act=help&code=remove&id={$r['id']}'>Remove</a></center>",
) );
}
}
$ADMIN->html .= $SKIN->add_td_basic("<a href='".$SKIN->base_url."&act=help&code=new'>Add New Help File</a>", "center", "title" );
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
$ADMIN->output();
}
}
?>
+605
View File
@@ -0,0 +1,605 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Skin -> Image Macro functions
| > Module written by Matt Mecham
| > Date started: 4th April 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new ad_settings();
class ad_settings {
var $base_url;
function ad_settings() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
switch($IN['code'])
{
case 'wrapper':
$this->list_current();
break;
case 'add':
$this->add_images();
break;
case 'edit':
$this->do_form('edit');
break;
case 'doadd':
$this->save_wrapper('add');
break;
case 'doedit':
$this->save_wrapper('edit');
break;
case 'remove':
$this->remove();
break;
case 'export':
$this->export();
//-------------------------
default:
$this->list_current();
break;
}
}
function export()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing image set ID, go back and try again");
}
//+-------------------------------
$DB->query("SELECT * from ibf_images WHERE imid='".$IN['id']."'");
if ( ! $row = $DB->fetch_row() )
{
$ADMIN->error("Could not query the information from the database");
}
//+-------------------------------
$archive_dir = $INFO['base_dir']."/archive_out";
$images_dir = $INFO['base_dir']."/style_images/".$row['imid'];
require $root_dir."sources/lib/tar.php";
if (!is_dir($archive_dir))
{
$ADMIN->error("Could not locate $archive_dir, is the directory there?");
}
if (!is_writeable($archive_dir))
{
$ADMIN->error("Cannot write in $archive_dir, CHMOD via FTP to 0755 or 0777 to enable this script to write into it. IBF cannot do this for you");
}
if (!is_dir($images_dir))
{
$ADMIN->error("Could not locate $images_dir, is the directory there?");
}
//+-------------------------------
// Attempt to copy the files to the
// working directory...
//+-------------------------------
$l_name = preg_replace( "/\s{1,}/", "_", $row['setname'] );
$new_dir = "image-".$l_name;
if ( ! $ADMIN->copy_dir($images_dir, $archive_dir."/".$new_dir) )
{
$ADMIN->error( $ADMIN->errors );
}
// Generate the config file..
$file_content = "<?php\n\n";
foreach($row as $k => $v)
{
$v = preg_replace( "#style_images/".$row['imid']."/#", "style_images/%img_dir%/", $v );
$file_content .= "\n\$config['$k'] = \"".addslashes($v)."\";";
}
$file_content .= "\n\n?".">";
$FH = fopen($archive_dir."/".$new_dir."/"."conf.inc", 'w');
fwrite($FH, $file_content, strlen($file_content));
fclose($FH);
// Add files and write tarball
$tar = new tar();
$tar->new_tar( $archive_dir, $new_dir.".tar" );
$tar->add_directory( $archive_dir."/".$new_dir );
$tar->write_tar();
// Check for errors.
if ($tar->error != "")
{
$ADMIN->error($tar->error);
}
// remove original unarchived directory
$ADMIN->rm_dir($archive_dir."/".$new_dir);
$ADMIN->done_screen("Template Pack Export Created<br><br>You can download the tar-chive <a href='archive_out/{$new_dir}.tar' target='_blank'>here</a>", "Manage Template Sets", "act=templ" );
}
//-------------------------------------------------------------
// Add images..
//-------------------------------------------------------------
function add_images()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing image set ID, go back and try again");
}
//-------------------------------------
if ( ! is_writeable($root_path.'style_images') )
{
$ADMIN->error("The directory 'style_images' is not writeable by this script. Please check the permissions on that directory. CHMOD to 0777 if in doubt and try again");
}
//-------------------------------------
if ( ! is_dir($root_path.'style_images/'.$IN['id']) )
{
$ADMIN->error("Could not locate the original image set to copy, please check and try again");
}
//-------------------------------------
$DB->query("SELECT * FROM ibf_images WHERE imid='".$IN['id']."'");
//-------------------------------------
if ( ! $row = $DB->fetch_row() )
{
$ADMIN->error("Could not query that image set from the DB, so there");
}
//-------------------------------------
$row['setname'] = $row['setname'].".2";
// Insert a new row into the DB...
$final = array();
foreach($row as $k => $v)
{
if ($k == 'imid')
{
continue;
}
else
{
$final[ $k ] = $v;
}
}
$db_string = $DB->compile_db_insert_string( $final );
$DB->query("INSERT INTO ibf_images (".$db_string['FIELD_NAMES'].") VALUES(".$db_string['FIELD_VALUES'].")");
$new_id = $DB->get_insert_id();
//-------------------------------------
if ( ! $ADMIN->copy_dir( $INFO['base_dir'].'style_images/'.$IN['id'] , $INFO['base_dir'].'style_images/'.$new_id ) )
{
$DB->query("DELETE FROM ibf_images WHERE imid='$new_id'");
$ADMIN->error( $ADMIN->errors );
}
//-------------------------------------
// Pass to edit / add form...
//-------------------------------------
$this->do_form('add', $new_id);
}
//-------------------------------------------------------------
// REMOVE WRAPPERS
//-------------------------------------------------------------
function remove()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
//+-------------------------------
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing image set ID, go back and try again");
}
$dir_to_remove = $INFO['base_dir']."style_images/".$IN['id'];
if ( SAFE_MODE_ON == 0 )
{
if ( $ADMIN->rm_dir( $dir_to_remove ) )
{
$DB->query("DELETE FROM ibf_images WHERE imid='".$IN['id']."'");
$std->boink_it($SKIN->base_url."&act=image");
exit();
}
else
{
$ADMIN->error("Could not remove the image pack files, please check the CHMOD permissions to ensure that this script has the correct permissions to allow this");
}
}
else
{
$DB->query("DELETE FROM ibf_images WHERE imid='".$IN['id']."'");
$ADMIN->info_screen("Safe mode has been detected and this script cannot remove the images and directories for you, please remove the directory '$dir_to_remove' via FTP. The data has been removed from the database successfully");
}
}
//-------------------------------------------------------------
// ADD / EDIT IMAGE SETS
//-------------------------------------------------------------
function save_wrapper()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
//+-------------------------------
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing image set ID, go back and try again");
}
if ($IN['setname'] == "")
{
$ADMIN->error("You must specify a name for this image and macro set");
}
$barney = array();
foreach ($IN as $k => $v)
{
if ( preg_match( "/^XX_(\S+)$/", $k, $match ) )
{
if ( isset($IN[ $match[0] ]) )
{
$v = preg_replace( "/&#39;/", "'", stripslashes($HTTP_POST_VARS[ $match[0] ]) );
$barney[ $match[1] ] = $v;
}
}
}
if ( count($barney) < 10 )
{
$ADMIN->error("Oopsie, something has gone wrong - did you leave all the fields blank?");
}
$barney['setname'] = $IN['setname'];
$db_string = $DB->compile_db_update_string( $barney );
$DB->query("UPDATE ibf_images SET $db_string WHERE imid='".$IN['id']."'");
$ADMIN->done_screen("Set updated", "Manage Image and Macro Sets", "act=image" );
}
//-------------------------------------------------------------
// ADD / EDIT MACRO SETS
//-------------------------------------------------------------
function do_form( $type='add', $id="" )
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
//+-------------------------------
if ($id != "")
{
$IN['id'] = $id;
}
//+-------------------------------
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing image set ID, go back and try again");
}
//+-------------------------------
$DB->query("SELECT * from ibf_images WHERE imid='".$IN['id']."'");
if ( ! $row = $DB->fetch_row() )
{
$ADMIN->error("Could not query the information from the database");
}
if ($type == 'add')
{
$button = 'Update Image & Macro set';
foreach( $row as $k => $v )
{
$v = preg_replace( "#style_images/(\d+)/#", "style_images/".$IN['id']."/", $v );
$row[$k] = $v;
}
}
else
{
$button = 'Edit Image & Macro set';
}
//+-------------------------------
$ADMIN->page_detail = "You may use edit the macros that power the images. You do not have to use an image, you may use text, flash or other objects.";
$ADMIN->page_title = "Manage Image & Macro sets";
//+-------------------------------
$ADMIN->html .= $SKIN->js_no_specialchars();
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'doedit' ),
2 => array( 'act' , 'image' ),
3 => array( 'id' , $IN['id'] ),
), "theAdminForm", "onSubmit=\"return no_specialchars('images')\"" );
//+-------------------------------
$SKIN->td_header[] = array( "&nbsp;" , "20%" );
$SKIN->td_header[] = array( "&nbsp;" , "80%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( "Image & Macro set title" );
$ADMIN->html .= $SKIN->add_td_row( array(
"Image & Macro Set Title",
$SKIN->form_input('setname', $row['setname']),
) );
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
$SKIN->td_header[] = array( "Macro" , "20%" );
$SKIN->td_header[] = array( "Source" , "60%" );
$SKIN->td_header[] = array( "Current" , "20%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( "Current Macros" );
foreach($row as $k => $v)
{
if ($k != 'imid' && $k != 'setname')
{
if ( ! preg_match( "/^\d+$/", $k ) )
{
$real = preg_replace( "/'/", "&#39;", $v );
$ADMIN->html .= $SKIN->add_td_row( array(
"$k",
$SKIN->form_input('XX_'.$k, $real),
"$v",
) );
}
}
}
$ADMIN->html .= $SKIN->end_form($button);
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
//+-------------------------------
$ADMIN->output();
}
//-------------------------------------------------------------
// SHOW WRAPPERS
//-------------------------------------------------------------
function list_current()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$form_array = array();
$ADMIN->page_detail = "Images and Macros are used in the skin templates as shorthand for an image or other style information. This enables you to use text links instead of buttons or flash movies for certain images. An image and macro set contains the actual images and the macros to power them.";
$ADMIN->page_title = "Manage Image and Macros";
//+-------------------------------
$SKIN->td_header[] = array( "Title" , "40%" );
$SKIN->td_header[] = array( "Allocation" , "30%" );
$SKIN->td_header[] = array( "Export" , "10%" );
$SKIN->td_header[] = array( "Edit" , "10%" );
$SKIN->td_header[] = array( "Remove" , "10%" );
//+-------------------------------
$DB->query("SELECT DISTINCT(s.img_id), i.imid, i.setname, s.sname from ibf_images i, ibf_skins s WHERE s.img_id=i.imid ORDER BY i.setname ASC");
$used_ids = array();
$show_array = array();
if ( $DB->get_num_rows() )
{
$ADMIN->html .= $SKIN->start_table( "Current Image & Macro sets In Use" );
while ( $r = $DB->fetch_row() )
{
$show_array[ $r['imid'] ] .= stripslashes($r['sname'])."<br>";
if ( in_array( $r['imid'], $used_ids ) )
{
continue;
}
$ADMIN->html .= $SKIN->add_td_row( array( "<b>".stripslashes($r['setname'])."</b>",
"<#X-{$r['imid']}#>",
"<center><a href='".$SKIN->base_url."&act=image&code=export&id={$r['imid']}'>Export</a></center>",
"<center><a href='".$SKIN->base_url."&act=image&code=edit&id={$r['imid']}'>Edit</a></center>",
"<i>Deallocate before removing</i>",
) );
$used_ids[] = $r['imid'];
$form_array[] = array( $r['imid'], $r['setname'] );
}
foreach( $show_array as $idx => $string )
{
$string = preg_replace( "/<br>$/", "", $string );
$ADMIN->html = preg_replace( "/<#X-$idx#>/", "$string", $ADMIN->html );
}
$ADMIN->html .= $SKIN->end_table();
}
if ( count($used_ids) > 0 )
{
$DB->query("SELECT imid, setname FROM ibf_images WHERE imid NOT IN(".implode(",",$used_ids).")");
if ( $DB->get_num_rows() )
{
$SKIN->td_header[] = array( "Title" , "70%" );
$SKIN->td_header[] = array( "Export" , "10%" );
$SKIN->td_header[] = array( "Edit" , "10%" );
$SKIN->td_header[] = array( "Remove" , "10%" );
$ADMIN->html .= $SKIN->start_table( "Current Unallocated Image & Macro sets" );
$ADMIN->html .= $SKIN->js_checkdelete();
while ( $r = $DB->fetch_row() )
{
$ADMIN->html .= $SKIN->add_td_row( array( "<b>".stripslashes($r['setname'])."</b>",
"<center><a href='".$SKIN->base_url."&act=image&code=export&id={$r['imid']}'>Export</a></center>",
"<center><a href='".$SKIN->base_url."&act=image&code=edit&id={$r['imid']}'>Edit</a></center>",
"<center><a href='javascript:checkdelete(\"act=image&code=remove&id={$r['imid']}\")'>Remove</a></center>",
) );
$form_array[] = array( $r['imid'], $r['setname'] );
}
$ADMIN->html .= $SKIN->end_table();
}
}
//+-------------------------------
//+-------------------------------
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'add' ),
2 => array( 'act' , 'image' ),
) );
$SKIN->td_header[] = array( "&nbsp;" , "40%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
$ADMIN->html .= $SKIN->start_table( "Create New Image & Macro Set" );
//+-------------------------------
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Base new Image & Macro set on...</b><br>(Note: This will also copy the images)" ,
$SKIN->form_dropdown( "id", $form_array)
) );
$ADMIN->html .= $SKIN->end_form("Create new Image & Macro set");
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
//+-------------------------------
$ADMIN->output();
}
}
?>
+204
View File
@@ -0,0 +1,204 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Admin "welcome" screen functions
| > Module written by Matt Mecham
| > Date started: 1st march 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new index_page();
class index_page {
function index_page() {
global $DB, $IN, $INFO, $ADMIN, $SKIN, $std;
$DB->query("SELECT * FROM ibf_stats");
$row = $DB->fetch_row();
if ($row['TOTAL_REPLIES'] < 0) $row['TOTAL_REPLIES'] = 0;
if ($row['TOTAL_TOPICS'] < 0) $row['TOTAL_TOPICS'] = 0;
if ($row['MEM_COUNT'] < 0) $row['MEM_COUNT'] = 0;
$DB->query("SELECT COUNT(*) as reg FROM ibf_members WHERE mgroup='".$INFO['auth_group']."' AND (new_pass='' or new_pass IS NULL)");
$reg = $DB->fetch_row();
if ($reg['reg'] < 1 ) $reg['reg'] = 0;
//-------------------------------------------------
// Make sure the uploads path is correct
//-------------------------------------------------
$uploads_size = 0;
if ($dh = opendir( $INFO['upload_dir'] ))
{
while ( $file = readdir( $dh ) )
{
if ( !preg_match( "/^..?$|^index/i", $file ) )
{
$uploads_size += @filesize( $INFO['upload_dir'] . "/" . $file );
}
}
closedir( $dh );
}
// This piece of code from Jesse's (jesse@jess.on.ca) contribution
// to the PHP manual @ php.net
if ($uploads_size >= 1048576)
{
$uploads_size = round($uploads_size / 1048576 * 100 ) / 100 . " mb";
}
else if ($uploads_size >= 1024)
{
$uploads_size = round($uploads_size / 1024 * 100 ) / 100 . " k";
}
else
{
$uploads_size = $uploads_size . " bytes";
}
//+-----------------------------------------------------------
$ADMIN->html .= $SKIN->start_table( "Administrators using the CP" );
$t_time = time() - 60*10;
$DB->query("SELECT DISTINCT(MEMBER_NAME) FROM ibf_admin_sessions WHERE RUNNING_TIME > $t_time");
$mem_array = array();
while ( $r = $DB->fetch_row() )
{
$mem_array[] = $r['MEMBER_NAME'];
}
$ADMIN->html .= $SKIN->add_td_basic( implode(", ", $mem_array ) );
$ADMIN->html .= $SKIN->end_table();
//+-----------------------------------------------------------
$ADMIN->html .= $SKIN->add_td_spacer();
//+-----------------------------------------------------------
$SKIN->td_header[] = array( "Definition", "25%" );
$SKIN->td_header[] = array( "Value" , "25%" );
$SKIN->td_header[] = array( "Definition", "25%" );
$SKIN->td_header[] = array( "Value" , "25%" );
$ADMIN->html .= $SKIN->start_table( "System Overview" );
$ADMIN->html .= $SKIN->add_td_row( array( "Total Unique Topics" , $row['TOTAL_TOPICS'],
"Total Replies to topics" , $row['TOTAL_REPLIES']
) );
$ADMIN->html .= $SKIN->add_td_row( array( "Total Members" , $row['MEM_COUNT'], "Public Upload Folder Size", $uploads_size ) );
$ADMIN->html .= $SKIN->add_td_row( array( "<a href='{$SKIN->base_url}&act=mem&code=mod'>Users awaiting validation</a>" , $reg['reg'],
"&nbsp;", "&nbsp;",
) );
$ADMIN->html .= $SKIN->end_table();
//+-----------------------------------------------------------
$ADMIN->html .= $SKIN->add_td_spacer();
//+-----------------------------------------------------------
$ADMIN->html .= $SKIN->start_form();
$SKIN->td_header[] = array( "&nbsp;" , "40%" );
$SKIN->td_header[] = array( "&nbsp;" , "30%" );
$SKIN->td_header[] = array( "&nbsp;" , "30%" );
$ADMIN->html .= $SKIN->start_table( "Quick Clicks" );
$ADMIN->html .= "
<script language='javascript'>
<!--
function edit_member() {
if (document.forms[0].username.value == \"\") {
alert(\"You must enter a username!\");
} else {
window.parent.body.location = '{$SKIN->base_url}' + '&act=mem&code=stepone&USER_NAME=' + escape(document.forms[0].username.value);
}
}
function new_cat() {
if (document.forms[0].cat_name.value == \"\") {
alert(\"You must enter a category name!\");
} else {
window.parent.body.location = '{$SKIN->base_url}' + '&act=cat&code=new&name=' + escape(document.forms[0].cat_name.value);
}
}
function new_forum() {
if (document.forms[0].forum_name.value == \"\") {
alert(\"You must enter a forum name!\");
} else {
window.parent.body.location = '{$SKIN->base_url}' + '&act=forum&code=new&name=' + escape(document.forms[0].forum_name.value);
}
}
//-->
</script>
<form name='DOIT' action=''>
";
$ADMIN->html .= $SKIN->add_td_row( array( "Edit Member:",
"<input type='text' style='width:100%' id='textinput' name='username' value='Enter name here' onfocus='this.value=\"\"'>",
"<input type='button' value='Find Member' id='button' onClick='edit_member()'>"
) );
$ADMIN->html .= $SKIN->add_td_row( array( "Add New Category:",
"<input type='text' style='width:100%' name='cat_name' id='textinput' value='Category title here' onfocus='this.value=\"\"'>",
"<input type='button' value='Add Category' id='button' onClick='new_cat()'>"
) );
$ADMIN->html .= $SKIN->add_td_row( array( "Add New Forum:",
"<input type='text' style='width:100%' name='forum_name' id='textinput' value='Forum title here' onfocus='this.value=\"\"'>",
"<input type='button' value='Add Forum' id='button' onClick='new_forum()'>"
) );
$ADMIN->html .= "</form>";
$ADMIN->html .= $SKIN->end_table();
$ADMIN->output();
}
}
?>
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+766
View File
@@ -0,0 +1,766 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Admin Category functions
| > Module written by Matt Mecham
| > Date started: 1st march 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new ad_mod();
class ad_mod {
var $base_url;
function ad_mod() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
switch($IN['code'])
{
case 'add':
$this->add_one();
break;
case 'add_two':
$this->add_two();
break;
case 'add_final':
$this->mod_form('add');
break;
case 'doadd':
$this->add_mod();
break;
case 'edit':
$this->mod_form('edit');
break;
case 'doedit':
$this->do_edit();
break;
case 'remove':
$this->do_delete();
break;
default:
$this->show_list();
break;
}
}
//+---------------------------------------------------------------------------------
//
// DELETE MODERATOR
//
//+---------------------------------------------------------------------------------
function do_delete()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ($IN['mid'] == "")
{
$ADMIN->error("You did not choose a valid moderator ID");
}
$DB->query("DELETE FROM ibf_moderators WHERE mid='".$IN['mid']."'");
$ADMIN->done_screen("Moderator Removed", "Moderator Control", "act=mod" );
}
//+---------------------------------------------------------------------------------
//
// EDIT MODERATOR
//
//+---------------------------------------------------------------------------------
function do_edit()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ($IN['mid'] == "")
{
$ADMIN->error("You did not choose a valid moderator ID");
}
//--------------------------------------
// Build Mr Hash
//--------------------------------------
$mr_hash = array(
'forum_id' => $IN['forum_id'],
'edit_post' => $IN['edit_post'],
'edit_topic' => $IN['edit_topic'],
'delete_post' => $IN['delete_post'],
'delete_topic' => $IN['delete_topic'],
'view_ip' => $IN['view_ip'],
'open_topic' => $IN['open_topic'],
'close_topic' => $IN['close_topic'],
'mass_move' => $IN['mass_move'],
'mass_prune' => $IN['mass_prune'],
'move_topic' => $IN['move_topic'],
'pin_topic' => $IN['pin_topic'],
'unpin_topic' => $IN['unpin_topic'],
'post_q' => $IN['post_q'],
'topic_q' => $IN['topic_q'],
'allow_warn' => $IN['allow_warn'],
'edit_user' => $IN['edit_user']
);
$db_string = $DB->compile_db_update_string( $mr_hash );
$DB->query("UPDATE ibf_moderators SET $db_string WHERE mid='".$IN['mid']."'");
$ADMIN->done_screen("Moderator Edited", "Moderator Control", "act=mod" );
}
//+---------------------------------------------------------------------------------
//
// ADD MODERATOR
//
//+---------------------------------------------------------------------------------
function add_mod()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ($IN['fid'] == "")
{
$ADMIN->error("You did not choose any forums to add this member to");
}
if ($IN['mem'] == "")
{
$ADMIN->error("You did not choose a member to add as a moderator");
}
$DB->query("SELECT id, name from ibf_members WHERE id='".$IN['mem']."'");
if ( ! $mem = $DB->fetch_row() )
{
$ADMIN->error("Could not match that member name so there.");
}
//--------------------------------------
// Check for legal forums
//--------------------------------------
$forum_ids = array();
$DB->query("SELECT id FROM ibf_forums WHERE id IN(".$IN['fid'].")");
while( $i = $DB->fetch_row() )
{
$forum_ids[] = $i['id'];
}
if ( count($forum_ids) == 0)
{
$ADMIN->error("We could not match any forums with those IDS");
}
//--------------------------------------
// Build Mr Hash
//--------------------------------------
$mr_hash = array(
'member_name' => $mem['name'],
'member_id' => $mem['id'],
'edit_post' => $IN['edit_post'],
'edit_topic' => $IN['edit_topic'],
'delete_post' => $IN['delete_post'],
'delete_topic' => $IN['delete_topic'],
'view_ip' => $IN['view_ip'],
'open_topic' => $IN['open_topic'],
'close_topic' => $IN['close_topic'],
'mass_move' => $IN['mass_move'],
'mass_prune' => $IN['mass_prune'],
'move_topic' => $IN['move_topic'],
'pin_topic' => $IN['pin_topic'],
'unpin_topic' => $IN['unpin_topic'],
'post_q' => $IN['post_q'],
'topic_q' => $IN['topic_q'],
'allow_warn' => $IN['allow_warn'],
'edit_user' => $IN['edit_user']
);
//--------------------------------------
// Loopy loopy
//--------------------------------------
foreach ($forum_ids as $cartman)
{
$mr_hash['forum_id'] = $cartman;
$kenny = $DB->compile_db_insert_string( $mr_hash );
$DB->query("INSERT INTO ibf_moderators (" .$kenny['FIELD_NAMES']. ") VALUES (". $kenny['FIELD_VALUES'] .")");
}
$ADMIN->done_screen("Moderator Added", "Moderator Control", "act=mod" );
}
//+---------------------------------------------------------------------------------
//
// ADD FINAL, display the add / edit form
//
//+---------------------------------------------------------------------------------
function mod_form( $type='add' ) {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ($type == 'add')
{
if ($IN['fid'] == "")
{
$ADMIN->error("You did not choose any forums to add this member to");
}
$mod = array();
$names = array();
//--------------------------------------
$DB->query("SELECT name FROM ibf_forums WHERE id IN(".$IN['fid'].")");
while ( $r = $DB->fetch_row() )
{
$names[] = $r['name'];
}
$thenames = implode( ", ", $names );
//--------------------------------------
$button = "Add this moderator";
$form_code = 'doadd';
if ($IN['MEMBER_ID'] == "")
{
$ADMIN->error("Could not resolve the member id bucko");
}
else
{
$DB->query("SELECT name, id FROM ibf_members WHERE id='".$IN['MEMBER_ID']."'");
if ( ! $mem = $DB->fetch_row() )
{
$ADMIN->error("That member ID does not resolve");
}
$member_id = $mem['id'];
$member_name = $mem['name'];
}
$ADMIN->page_detail = "Adding a $member_name as a moderator to: $thenames";
$ADMIN->page_title = "Add a moderator";
}
else
{
if ($IN['mid'] == "")
{
$ADMIN->error("You must choose a valid moderator to edit.");
}
$button = "Edit this moderator";
$form_code = "doedit";
$ADMIN->page_title = "Editing a moderator";
$ADMIN->page_detail = "Please check the information carefully before submitting the form";
$DB->query("SELECT * from ibf_moderators WHERE mid='".$IN['mid']."'");
if ( ! $mod = $DB->fetch_row() )
{
$ADMIN->error("Could not retrieve that moderators record");
}
$member_id = $mod['member_id'];
$member_name = $mod['member_name'];
}
//+-------------------------------
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , $form_code ),
2 => array( 'act' , 'mod' ),
3 => array( 'mid' , $mod['mid']),
4 => array( 'fid' , $IN['fid'] ),
5 => array( 'mem' , $member_id ),
) );
//+-------------------------------
$SKIN->td_header[] = array( "&nbsp;" , "40%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( "General Settings" );
//+-------------------------------
if ($type == 'edit')
{
$forums = array();
$DB->query("SELECT id, name FROM ibf_forums ORDER BY position");
while ( $r = $DB->fetch_row() )
{
$forums[] = array( $r['id'], $r['name'] );
}
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Moderates forum...</b>" ,
$SKIN->form_dropdown( "forum_id", $forums, $mod['forum_id'] )
) );
}
//+-------------------------------
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can edit others posts/polls?</b>" ,
$SKIN->form_yes_no("edit_post", $mod['edit_post'] )
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can edit others topic titles?</b>" ,
$SKIN->form_yes_no("edit_topic", $mod['edit_topic'] )
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can delete others posts?</b>" ,
$SKIN->form_yes_no("delete_post", $mod['delete_post'] )
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can delete others topics/polls?</b>" ,
$SKIN->form_yes_no("delete_topic", $mod['delete_topic'] )
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can view posters IP addresses?</b>" ,
$SKIN->form_yes_no("view_ip", $mod['view_ip'] )
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can open locked topics?</b>" ,
$SKIN->form_yes_no("open_topic", $mod['open_topic'] )
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can close open topics?</b>" ,
$SKIN->form_yes_no("close_topic", $mod['close_topic'] )
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can move topics?</b>" ,
$SKIN->form_yes_no("move_topic", $mod['move_topic'] )
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can pin topics?</b>" ,
$SKIN->form_yes_no("pin_topic", $mod['pin_topic'] )
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can unpin topics?</b>" ,
$SKIN->form_yes_no("unpin_topic", $mod['unpin_topic'] )
) );
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
$SKIN->td_header[] = array( "&nbsp;" , "40%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( "Moderator Control Panel Settings" );
//+-------------------------------
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can mass move topics?</b>" ,
$SKIN->form_yes_no("mass_move", $mod['mass_move'] )
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can mass prune topics?</b>" ,
$SKIN->form_yes_no("mass_prune", $mod['mass_prune'] )
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can manage queued topics?</b>" ,
$SKIN->form_yes_no("topic_q", $mod['topic_q'] )
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can manage queued posts?</b>" ,
$SKIN->form_yes_no("post_q", $mod['post_q'] )
) );
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
$SKIN->td_header[] = array( "&nbsp;" , "40%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( "Advanced Settings" );
//+-------------------------------
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can warn other users?</b>" ,
$SKIN->form_yes_no("allow_warn", $mod['allow_warn'] )
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Can edit user avatars and signatures?</b>" ,
$SKIN->form_yes_no("edit_user", $mod['edit_user'] )
) );
//+-------------------------------
$ADMIN->html .= $SKIN->end_form($button);
$ADMIN->html .= $SKIN->end_table();
$ADMIN->output();
}
//+---------------------------------------------------------------------------------
//
// ADD step one: Look up a member
//
//+---------------------------------------------------------------------------------
function add_one() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
//-----------------------------
// Grab and serialize the input
//-----------------------------
$fid = "";
$fidarray = array();
foreach ($IN as $k => $v)
{
if ( preg_match( "/^add_(\d+)$/", $k, $match ) )
{
if ($IN[ $match[0] ])
{
$fidarray[] = $match[1];
}
}
}
if ( count($fidarray) < 1 )
{
$ADMIN->error("You must select a forum, or forums to add a moderator to. You can do this by checking the checkboxes to the left of the forum name");
}
$fid = implode( "," ,$fidarray );
$ADMIN->page_title = "Add a moderator";
$ADMIN->page_detail = "Please find a member to moderate the forums you previously selected.";
//+-------------------------------
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'add_two' ),
2 => array( 'act' , 'mod' ),
3 => array( 'fid' , $fid ),
) );
//+-------------------------------
$SKIN->td_header[] = array( "&nbsp;" , "40%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( "Search for a member" );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Enter part or all of the usersname</b>" ,
$SKIN->form_input( "USER_NAME" )
) );
$ADMIN->html .= $SKIN->end_form("Find Member");
$ADMIN->html .= $SKIN->end_table();
$ADMIN->output();
}
//+---------------------------------------------------------------------------------
//
// REFINE MEMBER SEARCH
//
//+---------------------------------------------------------------------------------
function add_two() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ($IN['USER_NAME'] == "")
{
$ADMIN->error("You didn't choose a member name to look for!");
}
$DB->query("SELECT id, name FROM ibf_members WHERE name LIKE '".$IN['USER_NAME']."%'");
if (! $DB->get_num_rows() )
{
$ADMIN->error("Sorry, we could not find any members that matched the search string you entered");
}
$form_array = array();
while ( $r = $DB->fetch_row() )
{
$form_array[] = array( $r['id'] , $r['name'] );
}
$ADMIN->page_title = "Add a moderator";
$ADMIN->page_detail = "Please select the correct member name from the selection below to add as a moderator to the previously selected forums.";
//+-------------------------------
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'add_final' ),
2 => array( 'act' , 'mod' ),
3 => array( 'fid' , $IN['fid']),
) );
//+-------------------------------
$SKIN->td_header[] = array( "&nbsp;" , "40%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( "Search for a member" );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Choose from the matches...</b>" ,
$SKIN->form_dropdown( "MEMBER_ID", $form_array )
) );
$ADMIN->html .= $SKIN->end_form("Choose Member");
$ADMIN->html .= $SKIN->end_table();
$ADMIN->output();
}
//+---------------------------------------------------------------------------------
//
// SHOW LIST
// Renders a complete listing of all the forums and categories w/mods.
//
//+---------------------------------------------------------------------------------
function show_list() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$ADMIN->page_title = "Moderator Control Overview";
$ADMIN->page_detail = "This section allows you to edit, remove and add new moderators to your forums";
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'add' ),
2 => array( 'act' , 'mod' ),
) );
$SKIN->td_header[] = array( "Add" , "5%" );
$SKIN->td_header[] = array( "Forum Name" , "30%" );
$SKIN->td_header[] = array( "Posts" , "10%" );
$SKIN->td_header[] = array( "Topics" , "10%" );
$SKIN->td_header[] = array( "Current Moderators" , "45%" );
$ADMIN->html .= $SKIN->start_table( "Your Categories and Forums" );
//------------------------------------
$cats = array();
$forums = array();
$mods = array();
$children = array();
$DB->query("SELECT * from ibf_categories where id > 0 ORDER BY position ASC");
while ($r = $DB->fetch_row())
{
$cats[$r['id']] = $r;
}
$DB->query("SELECT * from ibf_forums ORDER BY position ASC");
while ($r = $DB->fetch_row())
{
if ($r['parent_id'] > 0)
{
$children[ $r['parent_id'] ][] = $r;
}
else
{
$forums[] = $r;
}
}
$DB->query("SELECT * from ibf_moderators");
while ($r = $DB->fetch_row())
{
$mods[] = $r;
}
//------------------------------------
$last_cat_id = -1;
foreach ($cats as $c)
{
$ADMIN->html .= $SKIN->add_td_row( array(
'&nbsp;',
"<a href='{$ADMIN->base_url}&act=cat&code=doeditform&c={$c['id']}'>".$c['name']."</a>",
'&nbsp;',
'&nbsp;',
'&nbsp;',
), 'catrow' );
$last_cat_id = $c['id'];
foreach($forums as $r)
{
if ($r['category'] == $last_cat_id)
{
$mod_string = "";
foreach( $mods as $phpid => $data )
{
if ($data['forum_id'] == $r['id'])
{
$mod_string .= "<tr>
<td width='60%'>{$data['member_name']}</td>
<td width='20%'><a href='{$ADMIN->base_url}&act=mod&code=remove&mid={$data['mid']}'>Remove</a></td>
<td width='20%'><a href='{$ADMIN->base_url}&act=mod&code=edit&mid={$data['mid']}'>Edit</a></td>
</tr>";
}
}
if ($mod_string != "")
{
$these_mods = "<table cellpadding='3' cellspacing='0' width='100%' align='center'>".$mod_string."</table>";
}
else
{
$these_mods = "<center><i>Unmoderated</i></center>";
}
if ($r['subwrap'] == 1)
{
$ADMIN->html .= $SKIN->add_td_row( array(
'&nbsp;',
$c['name'],
'&nbsp;',
'&nbsp;',
'&nbsp;',
), 'catrow2' );
}
else
{
$ADMIN->html .= $SKIN->add_td_row( array(
"<center><input type='checkbox' name='add_{$r['id']}' value='1'></center>",
"<b>".$r['name']."</b><br>".$r['description'],
$r['posts'],
$r['topics'],
$these_mods
) );
}
if ( ( isset($children[ $r['id'] ]) ) and ( count ($children[ $r['id'] ]) > 0 ) )
{
foreach($children[ $r['id'] ] as $idx => $rd)
{
$mod_string = "";
foreach( $mods as $phpid => $data )
{
if ($data['forum_id'] == $rd['id'])
{
$mod_string .= "<tr>
<td width='60%'>{$data['member_name']}</td>
<td width='20%'><a href='{$ADMIN->base_url}&act=mod&code=remove&mid={$data['mid']}'>Remove</a></td>
<td width='20%'><a href='{$ADMIN->base_url}&act=mod&code=edit&mid={$data['mid']}'>Edit</a></td>
</tr>";
}
}
if ($mod_string != "")
{
$these_mods = "<table cellpadding='3' cellspacing='0' width='100%' align='center'>".$mod_string."</table>";
}
else
{
$these_mods = "<center><i>Unmoderated</i></center>";
}
$ADMIN->html .= $SKIN->add_td_row( array(
"<center><input type='checkbox' name='add_{$rd['id']}' value='1'></center>",
"<b>".$rd['name']."</b><br>".$rd['description'],
$rd['posts'],
$rd['topics'],
$these_mods
) ,'subforum' );
}
}
}
}
}
$ADMIN->html .= $SKIN->end_form("Add a moderator to the selected forums");
$ADMIN->html .= $SKIN->end_table();
$ADMIN->output();
}
}
?>
+282
View File
@@ -0,0 +1,282 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Import functions
| > Module written by Matt Mecham
| > Date started: 22nd April 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
// Ensure we've not accessed this script directly:
$idx = new ad_modlogs();
class ad_modlogs {
var $base_url;
function ad_modlogs() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
switch($IN['code'])
{
case 'view':
$this->view();
break;
case 'remove':
$this->remove();
break;
//-------------------------
default:
$this->list_current();
break;
}
}
//---------------------------------------------
// Remove archived files
//---------------------------------------------
function view()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$start = $IN['st'] ? $IN['st'] : 0;
$ADMIN->page_detail = "Viewing all actions by a moderator";
$ADMIN->page_title = "Moderator Logs Manager";
if ($IN['search_string'] == "")
{
$DB->query("SELECT COUNT(id) as count FROM ibf_moderator_logs WHERE member_id='".$IN['mid']."'");
$row = $DB->fetch_row();
$row_count = $row['count'];
$query = "&act=modlog&mid={$IN['mid']}&code=view";
$DB->query("SELECT m.*, f.id as forum_id, f.name FROM ibf_moderator_logs m, ibf_forums f WHERE m.member_id='".$IN['mid']."' AND f.id=m.forum_id ORDER BY m.ctime DESC LIMIT $start, 20");
}
else
{
$IN['search_string'] = urldecode($IN['search_string']);
if ( ($IN['search_type'] == 'topic_id') or ($IN['search_type'] == 'forum_id') )
{
$dbq = "m.".$IN['search_type']."='".$IN['search_string']."'";
}
else
{
$dbq = "m.".$IN['search_type']." LIKE '%".$IN['search_string']."%'";
}
$DB->query("SELECT COUNT(m.id) as count FROM ibf_moderator_logs m WHERE $dbq");
$row = $DB->fetch_row();
$row_count = $row['count'];
$query = "&act=modlog&code=view&search_type={$IN['search_type']}&search_string=".urlencode($IN['search_string']);
$DB->query("SELECT m.*, f.id as forum_id, f.name FROM ibf_moderator_logs m, ibf_forums f WHERE $dbq AND f.id=m.forum_id ORDER BY m.ctime DESC LIMIT $start, 20");
}
$links = $std->build_pagelinks( array( 'TOTAL_POSS' => $row_count,
'PER_PAGE' => 20,
'CUR_ST_VAL' => $start,
'L_SINGLE' => "Single Page",
'L_MULTI' => "Pages: ",
'BASE_URL' => $ADMIN->base_url.$query,
)
);
$ADMIN->page_detail = "You may view and remove actions performed by your moderators";
$ADMIN->page_title = "Moderator Logs Manager";
//+-------------------------------
$SKIN->td_header[] = array( "Member Name" , "15%" );
$SKIN->td_header[] = array( "Action Perfomed" , "15%" );
$SKIN->td_header[] = array( "Forum" , "15%" );
$SKIN->td_header[] = array( "Topic Title" , "25%" );
$SKIN->td_header[] = array( "Time of action" , "20%" );
$SKIN->td_header[] = array( "IP address" , "10%" );
$ADMIN->html .= $SKIN->start_table( "Saved Moderator Logs" );
$ADMIN->html .= $SKIN->add_td_basic($links, 'center', 'catrow');
if ( $DB->get_num_rows() )
{
while ( $row = $DB->fetch_row() )
{
$row['ctime'] = $std->get_date( $row['ctime'], 'LONG' );
$sess_id = preg_replace( "/^.+?s=(\w{32}).+?$/" , "\\1", $row['http_referer'] );
$row['http_referer'] = preg_replace( "/s=(\w){32}/" , "" , $row['http_referer'] );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>{$row['member_name']}</b>",
"<span style='font-weight:bold;color:red'><a href='#' onClick=\"alert('HTTP REFERRER OF ACTION:\\n{$row['http_referer']}\\nSESSION ID OF ACTION:\\n$sess_id')\">{$row['action']}</a></span>",
"<b>{$row['name']}</b>",
"{$row['topic_title']}",
"{$row['ctime']}",
"{$row['ip_address']}",
) );
}
}
else
{
$ADMIN->html .= $SKIN->add_td_basic("<center>No results</center>");
}
$ADMIN->html .= $SKIN->add_td_basic($links, 'center', 'tdtop');
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
//+-------------------------------
$ADMIN->output();
}
//---------------------------------------------
// Remove archived files
//---------------------------------------------
function remove()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ($IN['mid'] == "")
{
$ADMIN->error("You did not select a member ID to remove by!");
}
$DB->query("DELETE FROM ibf_moderator_logs WHERE member_id='".$IN['mid']."'");
$std->boink_it($ADMIN->base_url."&act=modlog");
exit();
}
//-------------------------------------------------------------
// SHOW ALL LANGUAGE PACKS
//-------------------------------------------------------------
function list_current()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$form_array = array();
$ADMIN->page_detail = "You may view and remove actions performed by your moderators";
$ADMIN->page_title = "Moderator Logs Manager";
//+-------------------------------
$SKIN->td_header[] = array( "Member Name" , "30%" );
$SKIN->td_header[] = array( "Actions Perfomed" , "20%" );
$SKIN->td_header[] = array( "View all by member" , "20%" );
$SKIN->td_header[] = array( "Remove all by member" , "30%" );
$ADMIN->html .= $SKIN->start_table( "Saved Moderator Logs" );
$DB->query("SELECT m.*, count(m.id) as act_count from ibf_moderator_logs m GROUP BY m.member_id ORDER BY act_count DESC");
while ( $r = $DB->fetch_row() )
{
$ADMIN->html .= $SKIN->add_td_row( array( "<b>{$r['member_name']}</b>",
"<center>{$r['act_count']}</center>",
"<center><a href='".$SKIN->base_url."&act=modlog&code=view&mid={$r['member_id']}'>View</a></center>",
"<center><a href='".$SKIN->base_url."&act=modlog&code=remove&mid={$r['member_id']}'>Remove</a></center>",
) );
}
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
//+-------------------------------
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'view' ),
2 => array( 'act' , 'modlog' ),
) );
$SKIN->td_header[] = array( "&nbsp;" , "40%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
$ADMIN->html .= $SKIN->start_table( "Search Moderator Logs" );
$form_array = array(
0 => array( 'topic_title', 'Topic Title' ),
1 => array( 'ip_address', 'IP Address' ),
2 => array( 'member_name', 'Member Name' ),
3 => array( 'topic_id' , 'Topic ID' ),
4 => array( 'forum_id' , 'Forum ID' )
);
//+-------------------------------
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Search for...</b>" ,
$SKIN->form_input( "search_string")
) );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Search in...</b>" ,
$SKIN->form_dropdown( "search_type", $form_array)
) );
$ADMIN->html .= $SKIN->end_form("Search");
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
//+-------------------------------
$ADMIN->output();
}
}
?>
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+862
View File
@@ -0,0 +1,862 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Help Control functions
| > Module written by Matt Mecham
| > Date started: 2nd April 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new ad_settings();
class ad_settings {
var $base_url;
function ad_settings() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
switch($IN['code'])
{
case 'wrapper':
$this->list_wrappers();
break;
case 'add':
$this->do_form('add');
break;
case 'edit':
$this->do_form('edit');
break;
case 'doadd':
$this->save_skin('add');
break;
case 'doedit':
$this->save_skin('edit');
break;
case 'remove':
$this->remove();
break;
//-------------------------
case 'memskins':
$this->mem_skins();
break;
case 'export':
$this->export();
break;
default:
$this->list_sets();
break;
}
}
//----------------------------------------------------
function export()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing skin set ID, go back and try again");
}
//+-------------------------------
$DB->query("SELECT * from ibf_skins WHERE uid='".$IN['id']."'");
if ( ! $row = $DB->fetch_row() )
{
$ADMIN->error("Could not query the information from the database");
}
//+-------------------------------
$DB->query("SELECT * from ibf_images WHERE imid='".$row['img_id']."'");
if ( ! $img = $DB->fetch_row() )
{
$ADMIN->error("Could not query the information from the database");
}
//+-------------------------------
$DB->query("SELECT * from ibf_css WHERE cssid='".$row['css_id']."'");
if ( ! $css = $DB->fetch_row() )
{
$ADMIN->error("Could not query the information from the database");
}
//+-------------------------------
$DB->query("SELECT * from ibf_tmpl_names WHERE skid='".$row['set_id']."'");
if ( ! $tmpl = $DB->fetch_row() )
{
$ADMIN->error("Could not query the information from the database");
}
//+-------------------------------
$DB->query("SELECT * from ibf_templates WHERE tmid='".$row['tmpl_id']."'");
if ( ! $wrap = $DB->fetch_row() )
{
$ADMIN->error("Could not query the information from the database");
}
//+-------------------------------
if ($INFO['base_dir'] == './')
{
$INFO['base_dir'] = str_replace( '\\', '/', getcwd() ) . '/';
}
$archive_dir = $INFO['base_dir']."archive_out";
$images_dir = $INFO['base_dir']."style_images/".$img['imid'];
$css_file = $INFO['base_dir']."style_sheets/stylesheet_{$css['cssid']}.css";
$templates_dir = $INFO['base_dir']."style_templates/".$tmpl['skid'];
require $root_dir."sources/lib/tar.php";
if (!is_dir($archive_dir))
{
$ADMIN->error("Could not locate $archive_dir, is the directory there?");
}
if (!is_writeable($archive_dir))
{
$ADMIN->error("Cannot write in $archive_dir, CHMOD via FTP to 0755 or 0777 to enable this script to write into it. IBF cannot do this for you");
}
if (!file_exists($css_file))
{
$ADMIN->error("Could not locate $css_file, is the directory there?");
}
if (!is_dir($templates_dir))
{
$ADMIN->error("Could not locate $templates_dir, is the directory there?");
}
if (!is_dir($images_dir))
{
$ADMIN->error("Could not locate $images_dir, is the directory there?");
}
//+-------------------------------
// Set up the dir structure
//+-------------------------------
$css_name = "stylesheet.css";
$wrap_name = "wrapper.html";
$img_dir = 'images';
$templ_dir = 'templates';
$pack_name = preg_replace( "/\s{1,}/", "_", $row['sname'] );
$new_dir = "set-".$pack_name;
//+-------------------------------
if ( ! mkdir($archive_dir."/".$new_dir, 0777) )
{
$ADMIN->error("Directory creation failed, cannot export skin set. Please check the permission in 'archive_out'");
}
//+-------------------------------
if ( ! mkdir($archive_dir."/".$new_dir."/".$img_dir, 0777) )
{
$ADMIN->error("Directory creation failed, cannot export skin set. Please check the permission in 'archive_out'");
}
//+-------------------------------
if ( ! mkdir($archive_dir."/".$new_dir."/".$templ_dir, 0777) )
{
$ADMIN->error("Directory creation failed, cannot export skin set. Please check the permission in 'archive_out'");
}
//+-------------------------------
// Make the wrapper file...
//+-------------------------------
$wrap['template'] = preg_replace("/\r/", "\n", $wrap['template'] );
$FH = fopen($archive_dir."/".$new_dir."/".$wrap_name, 'w');
fwrite($FH, $wrap['template'], strlen($wrap['template']));
fclose($FH);
@chmod($archive_dir."/".$new_dir."/".$wrap_name, 0777);
//+-------------------------------
// Make the css file...
//+-------------------------------
if ( ! copy($css_file, $archive_dir."/".$new_dir."/".$css_name) )
{
$ADMIN->error("COPY FAILED ON STYLE SHEET $css_name, maybe the script has insufficient permissions?");
}
@chmod($archive_dir."/".$new_dir."/".$css_name, 0777);
//+-------------------------------
// Copy over the images...
//+-------------------------------
if ( ! $ADMIN->copy_dir($images_dir, $archive_dir."/".$new_dir."/".$img_dir) )
{
$ADMIN->error( $ADMIN->errors );
}
// Generate the config file..
$file_content = "<?php\n\n";
foreach($img as $k => $v)
{
$v = preg_replace( "#style_images/".$img['imid']."/#", "style_images/%img_dir%/", $v );
$file_content .= "\n\$config['$k'] = \"".addslashes($v)."\";";
}
$file_content .= "\n\n?".">";
$FH = fopen($archive_dir."/".$new_dir."/"."img_conf.inc", 'w');
fwrite($FH, $file_content, strlen($file_content));
fclose($FH);
//+-------------------------------
// Copy over the skin templates...
//+-------------------------------
if ( ! $ADMIN->copy_dir($templates_dir, $archive_dir."/".$new_dir."/".$templ_dir) )
{
$ADMIN->error( $ADMIN->errors );
}
// Generate the config file..
$file_content = "<?php\n\n".
"\$config=array('author' => \"".addslashes($tmpl['author'])."\", ".
"'email'=>\"".addslashes($tmpl['email'])."\", ".
"'tbl_border'=>\"".addslashes($row['tbl_border'])."\", ".
"'tbl_width'=>\"".addslashes($row['tbl_width'])."\", ".
"'url'=>\"".addslashes($tmpl['url'])."\")\n\n?".">";
$FH = fopen($archive_dir."/".$new_dir."/"."templates_conf.inc", 'w');
fwrite($FH, $file_content, strlen($file_content));
fclose($FH);
//+-------------------------------
// Add files and write tarball
//+-------------------------------
$tar = new tar();
$tar->new_tar( $archive_dir, $new_dir.".tar" );
$tar->add_directory( $archive_dir."/".$new_dir );
$tar->write_tar();
// Check for errors.
if ($tar->error != "")
{
$ADMIN->error($tar->error);
}
// remove original unarchived directory
$ADMIN->rm_dir($archive_dir."/".$new_dir);
$ADMIN->done_screen("Skin Pack Export Created<br><br>You can download the tar-chive <a href='archive_out/{$new_dir}.tar' target='_blank'>here</a>", "Manage Skin Sets", "act=sets" );
}
//----------------------------------------------
function mem_skins()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
$DB->query("SELECT sid FROM ibf_skins WHERE uid='".$IN['oid']."'");
$old = $DB->fetch_row();
if ($IN['nid'] == 'n')
{
$DB->query("UPDATE ibf_members SET skin=NULL WHERE skin='".$old['sid']."'");
}
else
{
$DB->query("SELECT sid FROM ibf_skins WHERE uid='".$IN['nid']."'");
$new = $DB->fetch_row();
$DB->query("UPDATE ibf_members SET skin='".$new['sid']."' WHERE skin='".$old['sid']."'");
}
$ADMIN->done_screen("Member Skin Choices Updated", "Manage Skin Sets", "act=sets" );
}
//-------------------------------------------------------------
// REMOVE WRAPPERS
//-------------------------------------------------------------
function remove()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
//+-------------------------------
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing skin set ID, go back and try again");
}
//+-------------------------------
$DB->query("SELECT * FROM ibf_skins WHERE uid='".$IN['id']."'");
if (! $skin = $DB->fetch_row() )
{
$ADMIN->error("Could not query that skin set information from the DB");
}
//+-------------------------------
if ($skin['default_set'] == 1)
{
$ADMIN->error("You can not remove this skin set as it is set as the default. Set another skin as default and try again");
}
//+-------------------------------
// Update the members skins..
$DB->query("UPDATE ibf_members SET skin='' WHERE skin='".$skin['sid']."'");
// Update the forums DB
$DB->query("SELECT id FROM ibf_forums WHERE skin_id='".$skin['sid']."'");
if ( $DB->get_num_rows() )
{
$arr = array();
while ( $i = $DB->fetch_row() )
{
$arr['forum_skin_'.$i['id']] = '';
}
$DB->query("UPDATE ibf_forums SET skin_id='' WHERE skin_id='".$skin['sid']."'");
// Remove it from the config file..
$ADMIN->rebuild_config($arr);
}
// Remove skin from the DB
$DB->query("DELETE FROM ibf_skins WHERE uid='".$IN['id']."'");
$std->boink_it($SKIN->base_url."&act=sets");
exit();
}
//-------------------------------------------------------------
// ADD / EDIT SKIN SETS
//-------------------------------------------------------------
function save_skin( $type='add' )
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
//+-------------------------------
if ($type == 'edit')
{
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing skin set ID, go back and try again");
}
}
if ($IN['sname'] == "")
{
$ADMIN->error("You must specify a name for this skin pack ID");
}
if ($IN['tbl_width'] == "")
{
$ADMIN->error("You must specify a table width");
}
$barney = array( 'sname' => stripslashes($HTTP_POST_VARS['sname']),
'set_id' => $IN['template'],
'tmpl_id' => $IN['wrapper'],
'img_id' => $IN['image'],
'css_id' => $IN['css'],
'tbl_border' => $IN['tbl_border'],
'tbl_width' => $IN['tbl_width'],
'hidden' => $IN['hidden'],
'default_set'=> $IN['default_set'],
);
if ($type == 'add')
{
$DB->query("SELECT MAX(sid) as new_id FROM ibf_skins");
$row = $DB->fetch_row();
$barney['sid'] = $row['new_id'] + 1;
$db_string = $DB->compile_db_insert_string( $barney );
$DB->query("INSERT INTO ibf_skins (".$db_string['FIELD_NAMES'].") VALUES(".$db_string['FIELD_VALUES'].")");
if ($IN['default_set'] == 1)
{
$DB->query("UPDATE ibf_skins SET default_set=0 WHERE sid <> '".$barney['sid']."'");
}
$std->boink_it($SKIN->base_url."&act=sets");
exit();
}
else
{
$db_string = $DB->compile_db_update_string( $barney );
$DB->query("UPDATE ibf_skins SET $db_string WHERE uid='".$IN['id']."'");
if ($IN['default_set'] == 1)
{
$DB->query("UPDATE ibf_skins SET default_set=0 WHERE uid <> '".$IN['id']."'");
}
$ADMIN->done_screen("Skin Set Updated", "Manage Skin Sets", "act=sets" );
}
}
//-------------------------------------------------------------
// ADD / EDIT SETS
//-------------------------------------------------------------
function do_form( $type='add' )
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
//+-------------------------------
$css = array();
$wrappers = array();
$templates = array();
$images = array();
//+-------------------------------
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing wrapper ID, go back and try again");
}
//+-------------------------------
$DB->query("SELECT * from ibf_skins WHERE uid='".$IN['id']."'");
if ( ! $row = $DB->fetch_row() )
{
$ADMIN->error("Could not query the information from the database");
}
//+-------------------------------
$DB->query("SELECT imid, setname FROM ibf_images");
while( $img = $DB->fetch_row() )
{
$images[] = array( $img['imid'], $img['setname'] );
}
//+-------------------------------
$DB->query("SELECT cssid, css_name FROM ibf_css");
while ( $c = $DB->fetch_row() )
{
$css[] = array( $c['cssid'], $c['css_name'] );
}
//+-------------------------------
$DB->query("SELECT tmid, name FROM ibf_templates");
while ( $t = $DB->fetch_row() )
{
$wrappers[] = array( $t['tmid'], $t['name'] );
}
//+-------------------------------
$DB->query("SELECT skid, skname FROM ibf_tmpl_names");
while ( $s = $DB->fetch_row() )
{
$templates[] = array( $s['skid'], $s['skname'] );
}
//+-------------------------------
if ($type == 'add')
{
$code = 'doadd';
$button = 'Create Skin Set';
$row['sname'] = $row['sname'].".2";
$row['default_set'] = 0;
}
else
{
$code = 'doedit';
$button = 'Edit Skin Set';
}
//+-------------------------------
$ADMIN->page_detail = "You may mix n' match which skin resources you wish to apply to this skin set.";
$ADMIN->page_title = "Manage Skin Sets";
//+-------------------------------
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , $code ),
2 => array( 'act' , 'sets' ),
3 => array( 'id' , $IN['id'] ),
), "theAdminForm", "onSubmit=\"return no_specialchars('sets')\"" );
//+-------------------------------
$SKIN->td_header[] = array( "&nbsp;" , "40%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( $button );
$ADMIN->html .= $SKIN->js_no_specialchars();
$ADMIN->html .= $SKIN->add_td_row( array(
"<b>Skin Set Title</b>",
$SKIN->form_input('sname', $row['sname']),
) );
$ADMIN->html .= $SKIN->add_td_row( array(
"<b>Use Templates:</b>",
$SKIN->form_dropdown('template', $templates, $row['set_id']),
) );
$ADMIN->html .= $SKIN->add_td_row( array(
"<b>Use Image & Macro Set:</b>",
$SKIN->form_dropdown('image', $images, $row['img_id']),
) );
$ADMIN->html .= $SKIN->add_td_row( array(
"<b>Use Stylesheet:</b>",
$SKIN->form_dropdown('css', $css, $row['css_id']),
) );
$ADMIN->html .= $SKIN->add_td_row( array(
"<b>Use Wrapper:</b>",
$SKIN->form_dropdown('wrapper', $wrappers, $row['tmpl_id']),
) );
$ADMIN->html .= $SKIN->add_td_row( array(
"<b>Basic Table Width:</b>",
$SKIN->form_input('tbl_width', $row['tbl_width']),
) );
$ADMIN->html .= $SKIN->add_td_row( array(
"<b>Basic Table Border Colour:</b>",
$SKIN->form_input('tbl_border', $row['tbl_border']),
) );
$ADMIN->html .= $SKIN->add_td_row( array(
"<b>Hide from Members?</b><br>Useful if you want to make a forum only skin",
$SKIN->form_yes_no('hidden', $row['hidden']),
) );
$ADMIN->html .= $SKIN->add_td_row( array(
"<b>Set as default skin set?</b><br>Used for unallocted forum and member skins",
$SKIN->form_yes_no('default_set', $row['default_set']),
) );
$ADMIN->html .= $SKIN->end_form($button);
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
//+-------------------------------
$ADMIN->output();
}
//-------------------------------------------------------------
// SHOW WRAPPERS
//-------------------------------------------------------------
function list_sets()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$form_array = array();
$forums = array();
$forum_skins = array();
$ADMIN->page_detail = "You may add/edit and remove skin sets.<br><br>Skin sets are groups of style resources. You can mix n' match board wrappers, image and macro sets, stylesheets and skin templates. If you wish to edit any of the resources, please choose the resource you wish to manage from the menu bar on the left.";
$ADMIN->page_title = "Manage Skin Sets";
//+-------------------------------
$DB->query("SELECT id, name FROM ibf_forums");
while ( $f = $DB->fetch_row() )
{
$forums[ $f['id'] ] = $f['name'];
if ($INFO['forum_skin_'.$f['id']] != "")
{
$forum_skins[ $INFO['forum_skin_'.$f['id']] ][] = $f['name'];
}
}
$SKIN->td_header[] = array( "Title" , "40%" );
$SKIN->td_header[] = array( "No. Members" , "20%" );
$SKIN->td_header[] = array( "Export" , "10%" );
$SKIN->td_header[] = array( "Edit" , "10%" );
$SKIN->td_header[] = array( "Remove" , "10%" );
$SKIN->td_header[] = array( "Hidden" , "5%" );
$SKIN->td_header[] = array( "Default" , "5%" );
//+-------------------------------
$DB->query("select ibf_skins.*, count(ibf_members.id) as mcount from ibf_skins left join ibf_members on(ibf_members.skin=ibf_skins.sid) where (ibf_members.skin is not null or ibf_skins.default_set = 1) group by ibf_skins.sid order by ibf_skins.sname");
$used_ids = array();
if ( $DB->get_num_rows() )
{
$ADMIN->html .= $SKIN->start_table( "Current Skins Used by Members" );
while ( $r = $DB->fetch_row() )
{
$extra = "";
if ( is_array($forum_skins[ $r['sid'] ]) )
{
if ( count($forum_skins[ $r['sid'] ]) > 0 )
{
$extra = "<br>(Used in forums: ".implode( ",", $forum_skins[ $r['sid'] ] )." )";
}
}
$default = '&nbsp;';
$hidden = '&nbsp;';
if ($r['hidden'] == 1)
{
$hidden = "<span style='color:red;font-weight:bold'>X</span>";
}
if ($r['default_set'] == 1)
{
$default = "<span style='color:red;font-weight:bold'>X</span>";
}
$ADMIN->html .= $SKIN->add_td_row( array( "<b>".stripslashes($r['sname'])."</b>$extra",
"<center>".$r['mcount']."</center>",
"<center><a href='".$SKIN->base_url."&act=sets&code=export&id={$r['uid']}'>Export</a></center>",
"<center><a href='".$SKIN->base_url."&act=sets&code=edit&id={$r['uid']}'>Edit</a></center>",
"<center><a href='".$SKIN->base_url."&act=sets&code=remove&id={$r['uid']}'>Remove</a></center>",
"<center>$hidden</center>",
"<center>$default</center>",
) );
$used_ids[] = $r['uid'];
$form_array[] = array( $r['uid'], $r['sname'] );
}
$ADMIN->html .= $SKIN->end_table();
}
if ( count($used_ids) > 0 )
{
$DB->query("SELECT * FROM ibf_skins WHERE uid NOT IN(".implode(",",$used_ids).")");
if ( $DB->get_num_rows() )
{
$SKIN->td_header[] = array( "Title" , "60%" );
$SKIN->td_header[] = array( "Export" , "10%" );
$SKIN->td_header[] = array( "Edit" , "10%" );
$SKIN->td_header[] = array( "Remove" , "10%" );
$SKIN->td_header[] = array( "Hidden" , "5%" );
$SKIN->td_header[] = array( "Default", "5%" );
$ADMIN->html .= $SKIN->start_table( "Skin Sets not used by Members" );
while ( $r = $DB->fetch_row() )
{
$extra = "";
if ( is_array($forum_skins[ $r['sid'] ]) )
{
if ( count($forum_skins[ $r['sid'] ]) > 0 )
{
$extra = "<br>(Used in forums: ".implode( ",", $forum_skins[ $r['sid'] ] )." )";
}
}
$default = '&nbsp;';
$hidden = '&nbsp;';
if ($r['hidden'] == 1)
{
$hidden = "<span style='color:red;font-weight:bold'>X</span>";
}
if ($r['default_set'] == 1)
{
$default = "<span style='color:red;font-weight:bold'>X</span>";
}
$ADMIN->html .= $SKIN->js_checkdelete();
$ADMIN->html .= $SKIN->add_td_row( array( "<b>".stripslashes($r['sname'])."</b>$extra",
"<center><a href='".$SKIN->base_url."&act=sets&code=export&id={$r['uid']}'>Export</a></center>",
"<center><a href='".$SKIN->base_url."&act=sets&code=edit&id={$r['uid']}'>Edit</a></center>",
"<center><a href='javascript:checkdelete(\"act=sets&code=remove&id={$r['uid']}\")'>Remove</a></center>",
"<center>$hidden</center>",
"<center>$default</center>",
) );
$form_array[] = array( $r['uid'], $r['sname'] );
}
$ADMIN->html .= $SKIN->end_table();
}
}
//+-------------------------------
//+-------------------------------
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'add' ),
2 => array( 'act' , 'sets' ),
) );
$SKIN->td_header[] = array( "&nbsp;" , "40%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
$ADMIN->html .= $SKIN->start_table( "Create New Skin Set" );
//+-------------------------------
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Base new skin set on...</b>" ,
$SKIN->form_dropdown( "id", $form_array)
) );
$ADMIN->html .= $SKIN->end_form("Create new Skin Set");
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
//+-------------------------------
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'memskins' ),
2 => array( 'act' , 'sets' ),
) );
$SKIN->td_header[] = array( "&nbsp;" , "40%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
$ADMIN->html .= $SKIN->start_table( "Swop members skin choice" );
//+-------------------------------
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Where members use skin...</b>",
$SKIN->form_dropdown( "oid", $form_array)
) );
$form_array[] = array( 'n', 'None (Will use whatever is set as default)' );
$ADMIN->html .= $SKIN->add_td_row( array( "<b>update to use skin...</b>",
$SKIN->form_dropdown( "nid", $form_array)
) );
$ADMIN->html .= $SKIN->end_form("Update members skin choice");
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
//+-------------------------------
$ADMIN->output();
}
}
?>
+502
View File
@@ -0,0 +1,502 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > CSS management functions
| > Module written by Matt Mecham
| > Date started: 4th April 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new ad_settings();
class ad_settings {
var $base_url;
function ad_settings() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
switch($IN['code'])
{
case 'wrapper':
$this->list_sheets();
break;
case 'add':
$this->do_form('add');
break;
case 'edit':
$this->do_form('edit');
break;
case 'doadd':
$this->save_wrapper('add');
break;
case 'doedit':
$this->save_wrapper('edit');
break;
case 'remove':
$this->remove();
break;
case 'export':
$this->export();
break;
//-------------------------
default:
$this->list_sheets();
break;
}
}
function export()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing CSS ID, go back and try again");
}
//+-------------------------------
$DB->query("SELECT * from ibf_css WHERE cssid='".$IN['id']."'");
if ( ! $row = $DB->fetch_row() )
{
$ADMIN->error("Could not query the information from the database");
}
//+-------------------------------
$archive_dir = $INFO['base_dir']."/archive_out";
$css_file = $INFO['base_dir']."/style_sheets/stylesheet_{$row['cssid']}.css";
if (!is_dir($archive_dir))
{
$ADMIN->error("Could not locate $archive_dir, is the directory there?");
}
if (!is_writeable($archive_dir))
{
$ADMIN->error("Cannot write in $archive_dir, CHMOD via FTP to 0755 or 0777 to enable this script to write into it. IBF cannot do this for you");
}
if (!file_exists($css_file))
{
$ADMIN->error("Cannot locate $css_file, please ensure that the file is in the proper directory");
}
//+-------------------------------
// Attempt to copy the files to the
// working directory...
//+-------------------------------
$l_name = preg_replace( "/\s{1,}/", "_", $row['css_name'] );
$file_name = "css-".$l_name.".css";
if ( ! copy($css_file, $archive_dir."/".$file_name) )
{
$ADMIN->error("COPY FAILED ON STYLE SHEET $file_name, maybe the script has insufficient permissions?");
}
@chmod($archive_dir."/".$file_name, 0777);
$ADMIN->done_screen("Style Sheet Export Created<br><br>You can download the CSS resource <a href='archive_out/$file_name' target='_blank'>here</a>", "Manage Style Sheets", "act=style" );
}
//-------------------------------------------------------------
// REMOVE WRAPPERS
//-------------------------------------------------------------
function remove()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
//+-------------------------------
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing stylesheet ID, go back and try again");
}
$DB->query("DELETE FROM ibf_css WHERE cssid='".$IN['id']."'");
@unlink( $root_path."style_sheets/stylesheet_{$IN['id']}.css" );
$std->boink_it($SKIN->base_url."&act=style");
exit();
}
//-------------------------------------------------------------
// ADD / EDIT WRAPPERS
//-------------------------------------------------------------
function save_wrapper( $type='add' )
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
//+-------------------------------
if ($type == 'edit')
{
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing CSS ID, go back and try again");
}
$file = $root_path."style_sheets/stylesheet_".$IN['id'].".css";
if ( ! is_writeable($file) )
{
$ADMIN->error("IBF does not have permission to write to that file. Try setting the CHMOD on $file to 0777 and try again. You can do this via FTP");
}
}
if ($IN['name'] == "")
{
$ADMIN->error("You must specify a name for this stylesheet");
}
if ($IN['css'] == "")
{
$ADMIN->error("You can't have an empty stylesheet, can you?");
}
$css = stripslashes($HTTP_POST_VARS['css']);
$barney = array( 'css_name' => stripslashes($HTTP_POST_VARS['name']),
'css_text' => $css,
);
if ($type == 'add')
{
$db_string = $DB->compile_db_insert_string( $barney );
$DB->query("INSERT INTO ibf_css (".$db_string['FIELD_NAMES'].") VALUES(".$db_string['FIELD_VALUES'].")");
$new_id = $DB->get_insert_id();
$nfile = $root_path."style_sheets/stylesheet_".$new_id.".css";
if ($fh = fopen( $nfile, 'w' ) )
{
fwrite( $fh, $css, strlen($css) );
fclose( $fh );
@chmod( $nfile, 0777 );
}
else
{
$DB->query("DELETE FROM ibf_css WHERE cssid='$new_id'");
$ADMIN->error("Could not prepare $file for creation - please check the CHMOD value of the 'style_sheets' directory and where possible CHMOD to 0777 via FTP");
}
$std->boink_it($SKIN->base_url."&act=style");
exit();
}
else
{
$db_string = $DB->compile_db_update_string( $barney );
if ($fh = fopen( $file, 'w' ) )
{
fwrite( $fh, $css, strlen($css) );
fclose( $fh );
@chmod( $file, 0777 );
$DB->query("UPDATE ibf_css SET $db_string WHERE cssid='".$IN['id']."'");
$ADMIN->done_screen("Stylesheet updated", "Manage Style Sheets", "act=style" );
}
else
{
$ADMIN->error("Could not prepare $file for writing - please check the CHMOD value of the 'style_sheets' directory");
}
}
}
//-------------------------------------------------------------
// ADD / EDIT WRAPPERS
//-------------------------------------------------------------
function do_form( $type='add' )
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
//+-------------------------------
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing wrapper ID, go back and try again");
}
//+-------------------------------
$DB->query("SELECT cssid, css_name FROM ibf_css WHERE cssid='".$IN['id']."'");
if ( ! $cssinfo = $DB->fetch_row() )
{
$ADMIN->error("Could not query the CSS details from the database");
}
//+-------------------------------
$file = $root_path."style_sheets/stylesheet_".$IN['id'].".css";
if ( ! file_exists($file) )
{
$ADMIN->error("Could not load the stylesheet. No file found at $file");
}
if ( ! is_readable($file) )
{
$ADMIN->error("IBF does not have permission to read from that file. Try setting the CHMOD on $file to 0777 and try again. You can do this via FTP");
}
//+-------------------------------
$fh = fopen( $file, 'r' );
$css = fread( $fh, filesize($file) );
fclose($fh);
if ($type == 'add')
{
$code = 'doadd';
$button = 'Create StyleSheet';
$cssinfo['css_name'] = $cssinfo['css_name'].".2";
}
else
{
// Availability test
if ( ! is_writeable($file) )
{
$ADMIN->error("IBF does not have permission to write to that file. Try setting the CHMOD on $file to 0777 and try again. You can do this via FTP");
}
$code = 'doedit';
$button = 'Edit Stylesheet';
}
//+-------------------------------
$ADMIN->page_detail = "You may use CSS fully when adding or editing stylesheets.";
$ADMIN->page_title = "Manage Style Sheets";
//+-------------------------------
$ADMIN->html .= $SKIN->js_no_specialchars();
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , $code ),
2 => array( 'act' , 'style' ),
3 => array( 'id' , $IN['id'] ),
), "theAdminForm", "onSubmit=\"return no_specialchars('csssheet')\"" );
//+-------------------------------
$SKIN->td_header[] = array( "&nbsp;" , "20%" );
$SKIN->td_header[] = array( "&nbsp;" , "80%" );
//+-------------------------------
$ADMIN->html .= $SKIN->start_table( $button );
$ADMIN->html .= $SKIN->add_td_row( array(
"Stylesheet Title",
$SKIN->form_input('name', $cssinfo['css_name']),
) );
$ADMIN->html .= $SKIN->add_td_row( array(
"Content",
$SKIN->form_textarea('css', $css, "70", "30"),
) );
$ADMIN->html .= $SKIN->end_form($button);
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
//+-------------------------------
$ADMIN->output();
}
//-------------------------------------------------------------
// SHOW STYLE SHEETS
//-------------------------------------------------------------
function list_sheets()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$form_array = array();
$show_array = array();
$ADMIN->page_detail = "You may add/edit and remove stylesheets.<br><br>Style Sheets are CSS files. This is where you can change the colours, fonts and font sizes throughout the board.";
$ADMIN->page_title = "Manage Stylesheets";
//+-------------------------------
$SKIN->td_header[] = array( "Title" , "40%" );
$SKIN->td_header[] = array( "Allocation" , "30%" );
$SKIN->td_header[] = array( "Export" , "10%" );
$SKIN->td_header[] = array( "Edit" , "10%" );
$SKIN->td_header[] = array( "Remove" , "10%" );
//+-------------------------------
$DB->query("SELECT DISTINCT(c.cssid), c.css_name, s.sname from ibf_css c, ibf_skins s WHERE s.css_id=c.cssid ORDER BY c.css_name ASC");
$used_ids = array();
if ( $DB->get_num_rows() )
{
$ADMIN->html .= $SKIN->start_table( "Current Stylesheets In Use" );
while ( $r = $DB->fetch_row() )
{
$show_array[ $r['cssid'] ] .= stripslashes($r['sname'])."<br>";
if ( in_array( $r['cssid'], $used_ids ) )
{
continue;
}
$ADMIN->html .= $SKIN->add_td_row( array( "<b>".stripslashes($r['css_name'])."</b>",
"<#X-{$r['cssid']}#>",
"<center><a href='".$SKIN->base_url."&act=style&code=export&id={$r['cssid']}'>Export</a></center>",
"<center><a href='".$SKIN->base_url."&act=style&code=edit&id={$r['cssid']}'>Edit</a></center>",
"<i>Deallocate before removing</i>",
) );
$used_ids[] = $r['cssid'];
$form_array[] = array( $r['cssid'], $r['css_name'] );
}
foreach( $show_array as $idx => $string )
{
$string = preg_replace( "/<br>$/", "", $string );
$ADMIN->html = preg_replace( "/<#X-$idx#>/", "$string", $ADMIN->html );
}
$ADMIN->html .= $SKIN->end_table();
}
if ( count($used_ids) > 0 )
{
$DB->query("SELECT cssid, css_name FROM ibf_css WHERE cssid NOT IN(".implode(",",$used_ids).")");
if ( $DB->get_num_rows() )
{
$SKIN->td_header[] = array( "Title" , "70%" );
$SKIN->td_header[] = array( "Export" , "10%" );
$SKIN->td_header[] = array( "Edit" , "10%" );
$SKIN->td_header[] = array( "Remove" , "10%" );
$ADMIN->html .= $SKIN->start_table( "Current Unallocated Stylesheets" );
$ADMIN->html .= $SKIN->js_checkdelete();
while ( $r = $DB->fetch_row() )
{
$ADMIN->html .= $SKIN->add_td_row( array( "<b>".stripslashes($r['css_name'])."</b>",
"<center><a href='".$SKIN->base_url."&act=style&code=export&id={$r['cssid']}'>Export</a></center>",
"<center><a href='".$SKIN->base_url."&act=style&code=edit&id={$r['cssid']}'>Edit</a></center>",
"<center><a href='javascript:checkdelete(\"act=style&code=remove&id={$r['cssid']}\")'>Remove</a></center>",
) );
$form_array[] = array( $r['cssid'], $r['css_name'] );
}
$ADMIN->html .= $SKIN->end_table();
}
}
//+-------------------------------
//+-------------------------------
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'add' ),
2 => array( 'act' , 'style' ),
) );
$SKIN->td_header[] = array( "&nbsp;" , "40%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
$ADMIN->html .= $SKIN->start_table( "Create New Stylesheet" );
//+-------------------------------
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Base new stylesheet on...</b>" ,
$SKIN->form_dropdown( "id", $form_array)
) );
$ADMIN->html .= $SKIN->end_form("Create new stylesheet");
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
//+-------------------------------
$ADMIN->output();
}
}
?>
File diff suppressed because it is too large. Load diff
+436
View File
@@ -0,0 +1,436 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Help Control functions
| > Module written by Matt Mecham
| > Date started: 2nd April 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new ad_settings();
class ad_settings {
var $base_url;
function ad_settings() {
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
switch($IN['code'])
{
case 'wrapper':
$this->list_wrappers();
break;
case 'add':
$this->do_form('add');
break;
case 'edit':
$this->do_form('edit');
break;
case 'doadd':
$this->save_wrapper('add');
break;
case 'doedit':
$this->save_wrapper('edit');
break;
case 'remove':
$this->remove();
break;
case 'export':
$this->export();
//-------------------------
default:
$this->list_wrappers();
break;
}
}
function export()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing wrapper ID, go back and try again");
}
//+-------------------------------
$DB->query("SELECT * from ibf_templates WHERE tmid='".$IN['id']."'");
if ( ! $row = $DB->fetch_row() )
{
$ADMIN->error("Could not query the information from the database");
}
//+-------------------------------
$archive_dir = $INFO['base_dir']."/archive_out";
require $root_dir."sources/lib/tar.php";
if (!is_dir($archive_dir))
{
$ADMIN->error("Could not locate $archive_dir, is the directory there?");
}
if (!is_writeable($archive_dir))
{
$ADMIN->error("Cannot write in $archive_dir, CHMOD via FTP to 0755 or 0777 to enable this script to write into it. IBF cannot do this for you");
}
//+-------------------------------
// Attempt to copy the files to the
// working directory...
//+-------------------------------
$l_name = preg_replace( "/\s{1,}/", "_", $row['name'] );
$file_name = "wrap-".$l_name.".html";
$row['template'] = preg_replace("/\r/", "\n", $row['template'] );
$FH = fopen($archive_dir."/".$file_name, 'w');
fwrite($FH, $row['template'], strlen($row['template']));
fclose($FH);
$ADMIN->done_screen("Wrapper Export Created<br><br>You can download the html resource <a href='archive_out/$file_name' target='_blank'>here</a>", "Manage Board Wrappers", "act=wrap" );
}
//-------------------------------------------------------------
// REMOVE WRAPPERS
//-------------------------------------------------------------
function remove()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
//+-------------------------------
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing wrapper ID, go back and try again");
}
$DB->query("DELETE FROM ibf_templates WHERE tmid='".$IN['id']."'");
$std->boink_it($SKIN->base_url."&act=wrap");
exit();
}
//-------------------------------------------------------------
// ADD / EDIT WRAPPERS
//-------------------------------------------------------------
function save_wrapper( $type='add' )
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP, $HTTP_POST_VARS;
//+-------------------------------
if ($type == 'edit')
{
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing wrapper ID, go back and try again");
}
}
if ($IN['name'] == "")
{
$ADMIN->error("You must specify a name for this wrapper");
}
if ($IN['template'] == "")
{
$ADMIN->error("You can't have an empty template, can you?");
}
$tmpl = preg_replace( "!&lt/textarea>!", "/textarea>", stripslashes($HTTP_POST_VARS['template']) );
if ( ! preg_match( "/<% BOARD %>/", $tmpl ) )
{
$ADMIN->error("You cannot remove the &lt% BOARD %> tag silly!");
}
if ( ! preg_match( "/<% COPYRIGHT %>/", $tmpl ) )
{
$ADMIN->error("You cannot remove the &lt% COPYRIGHT %> tag silly!");
}
$barney = array( 'name' => stripslashes($HTTP_POST_VARS['name']),
'template' => $tmpl
);
if ($type == 'add')
{
$db_string = $DB->compile_db_insert_string( $barney );
$DB->query("INSERT INTO ibf_templates (".$db_string['FIELD_NAMES'].") VALUES(".$db_string['FIELD_VALUES'].")");
$std->boink_it($SKIN->base_url."&act=wrap");
exit();
}
else
{
$db_string = $DB->compile_db_update_string( $barney );
$DB->query("UPDATE ibf_templates SET $db_string WHERE tmid='".$IN['id']."'");
$ADMIN->done_screen("Wrapper updated", "Manage Board Wrappers", "act=wrap" );
}
}
//-------------------------------------------------------------
// ADD / EDIT WRAPPERS
//-------------------------------------------------------------
function do_form( $type='add' )
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
//+-------------------------------
if ($IN['id'] == "")
{
$ADMIN->error("You must specify an existing wrapper ID, go back and try again");
}
$DB->query("SELECT * from ibf_templates WHERE tmid='".$IN['id']."'");
if ( ! $row = $DB->fetch_row() )
{
$ADMIN->error("Could not query the information from the database");
}
if ($type == 'add')
{
$code = 'doadd';
$button = 'Create Wrapper';
$row['name'] = $row['name'].".2";
}
else
{
$code = 'doedit';
$button = 'Edit Wrapper';
}
//+-------------------------------
$ADMIN->page_detail = "You may use HTML fully when adding or editing wrappers.";
$ADMIN->page_title = "Manage Board Wrappers";
//+-------------------------------
$ADMIN->html .= $SKIN->js_no_specialchars();
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , $code ),
2 => array( 'act' , 'wrap' ),
3 => array( 'id' , $IN['id'] ),
), "theAdminForm", "onSubmit=\"return no_specialchars('wrapper')\"" );
//+-------------------------------
$SKIN->td_header[] = array( "&nbsp;" , "20%" );
$SKIN->td_header[] = array( "&nbsp;" , "80%" );
//+-------------------------------
$row['template'] = preg_replace( "/\/textarea>/", "&lt/textarea>", $row['template'] ); // Stop html killing the text area
$ADMIN->html .= $SKIN->start_table( $button );
$ADMIN->html .= $SKIN->add_td_row( array(
"Wrapper Title",
$SKIN->form_input('name', $row['name']),
) );
$ADMIN->html .= $SKIN->add_td_row( array(
"Content",
$SKIN->form_textarea('template', $row['template'], "60", "15"),
) );
$ADMIN->html .= $SKIN->end_form($button);
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
//+-------------------------------
$ADMIN->output();
}
//-------------------------------------------------------------
// SHOW WRAPPERS
//-------------------------------------------------------------
function list_wrappers()
{
global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
$form_array = array();
$ADMIN->page_detail = "You may add/edit and remove the board wrapper templates.<br><br>Board wrapper refers to the main board template which allows additional HTML to be added to the header and footer of the board";
$ADMIN->page_title = "Manage Board Wrappers";
//+-------------------------------
$SKIN->td_header[] = array( "Title" , "40%" );
$SKIN->td_header[] = array( "Allocation" , "30%" );
$SKIN->td_header[] = array( "Export" , "10%" );
$SKIN->td_header[] = array( "Edit" , "10%" );
$SKIN->td_header[] = array( "Remove" , "10%" );
//+-------------------------------
$DB->query("SELECT DISTINCT(w.tmid), w.name, s.sname from ibf_templates w, ibf_skins s WHERE s.tmpl_id=w.tmid ORDER BY w.name ASC");
$used_ids = array();
$show_array = array();
if ( $DB->get_num_rows() )
{
$ADMIN->html .= $SKIN->start_table( "Current Wrappers In Use" );
while ( $r = $DB->fetch_row() )
{
$show_array[ $r['tmid'] ] .= stripslashes($r['sname'])."<br>";
if ( in_array( $r['tmid'], $used_ids ) )
{
continue;
}
$ADMIN->html .= $SKIN->add_td_row( array( "<b>".stripslashes($r['name'])."</b>",
"<#X-{$r['tmid']}#>",
"<center><a href='".$SKIN->base_url."&act=wrap&code=export&id={$r['tmid']}'>Export</a></center>",
"<center><a href='".$SKIN->base_url."&act=wrap&code=edit&id={$r['tmid']}'>Edit</a></center>",
"<i>Deallocate before removing</i>",
) );
$used_ids[] = $r['tmid'];
$form_array[] = array( $r['tmid'], $r['name'] );
}
foreach( $show_array as $idx => $string )
{
$string = preg_replace( "/<br>$/", "", $string );
$ADMIN->html = preg_replace( "/<#X-$idx#>/", "$string", $ADMIN->html );
}
$ADMIN->html .= $SKIN->end_table();
}
if ( count($used_ids) > 0 )
{
$DB->query("SELECT tmid, name FROM ibf_templates WHERE tmid NOT IN(".implode(",",$used_ids).")");
if ( $DB->get_num_rows() )
{
$SKIN->td_header[] = array( "Title" , "70%" );
$SKIN->td_header[] = array( "Export" , "10%" );
$SKIN->td_header[] = array( "Edit" , "10%" );
$SKIN->td_header[] = array( "Remove" , "10%" );
$ADMIN->html .= $SKIN->start_table( "Current Unallocated Wrappers" );
$ADMIN->html .= $SKIN->js_checkdelete();
while ( $r = $DB->fetch_row() )
{
$ADMIN->html .= $SKIN->add_td_row( array( "<b>".stripslashes($r['name'])."</b>",
"<center><a href='".$SKIN->base_url."&act=wrap&code=export&id={$r['tmid']}'>Export</a></center>",
"<center><a href='".$SKIN->base_url."&act=wrap&code=edit&id={$r['tmid']}'>Edit</a></center>",
"<center><a href='javascript:checkdelete(\"act=wrap&code=remove&id={$r['tmid']}\")'>Remove</a></center>",
) );
$form_array[] = array( $r['tmid'], $r['name'] );
}
$ADMIN->html .= $SKIN->end_table();
}
}
//+-------------------------------
//+-------------------------------
$ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code' , 'add' ),
2 => array( 'act' , 'wrap' ),
) );
$SKIN->td_header[] = array( "&nbsp;" , "40%" );
$SKIN->td_header[] = array( "&nbsp;" , "60%" );
$ADMIN->html .= $SKIN->start_table( "Create New Wrapper" );
//+-------------------------------
$ADMIN->html .= $SKIN->add_td_row( array( "<b>Base new wrapper on...</b>" ,
$SKIN->form_dropdown( "id", $form_array)
) );
$ADMIN->html .= $SKIN->end_form("Create new wrapper");
$ADMIN->html .= $SKIN->end_table();
//+-------------------------------
//+-------------------------------
$ADMIN->output();
}
}
?>
+532
View File
@@ -0,0 +1,532 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Admin functions library
| > Script written by Matt Mecham
| > Date started: 1st march 2002
|
+--------------------------------------------------------------------------
*/
class admin_functions {
var $img_url;
var $page_title = "Welcome to the Invision Board Administration CP";
var $page_detail = "You can set up and customize your board from within this control panel.<br><br>Clicking on one of the links in the left menu pane will show you the relevant options for that administration category. Each option will contain further information on configuration, etc.";
var $html;
var $errors = "";
function admin_functions() {
global $INFO, $IN;
$this->img_url = $INFO['html_url'].'/sys-img';
$this->base_url = $INFO['board_url']."/admin.".$INFO['php_ext']."?adsess=".$IN['AD_SESS'];
}
//**********************************************/
// get_tar_names
//
// Simply returns a list of tarballs that start
// with the given filename
//**********************************************/
function get_tar_names($start='lang-')
{
global $INFO;
// Remove trailing slashes..
$files = array();
$dir = $INFO['base_dir']."archive_in";
if ( is_dir($dir) )
{
$handle = opendir($dir);
while (($filename = readdir($handle)) !== false)
{
if (($filename != ".") && ($filename != ".."))
{
if (preg_match("/^$start.+?\.tar$/", $filename))
{
$files[] = $filename;
}
}
}
closedir($handle);
}
return $files;
}
//**********************************************/
// copy_dir
//
// Copies to contents of a dir to a new dir, creating
// destination dir if needed.
//
//**********************************************/
function copy_dir($from_path, $to_path, $mode = 0777)
{
global $INFO;
// Strip off trailing slashes...
$from_path = preg_replace( "#/$#", "", $from_path);
$to_path = preg_replace( "#/$#", "", $to_path);
if ( ! is_dir($from_path) )
{
$this->errors = "Could not locate directory '$from_path'";
return FALSE;
}
if ( ! is_dir($to_path) )
{
if ( ! @mkdir($to_path, $mode) )
{
$this->errors = "Could not create directory '$to_path' please check the CHMOD permissions and re-try";
return FALSE;
}
else
{
@chmod($to_path, $mode);
}
}
$this_path = getcwd();
if (is_dir($from_path))
{
chdir($from_path);
$handle=opendir('.');
while (($file = readdir($handle)) !== false)
{
if (($file != ".") && ($file != ".."))
{
if (is_dir($file))
{
$this->copy_dir($from_path."/".$file, $to_path."/".$file);
chdir($from_path);
}
if ( is_file($file) )
{
copy($from_path."/".$file, $to_path."/".$file);
@chmod($to_path."/".$file, 0777);
}
}
}
closedir($handle);
}
if ($this->errors == "")
{
return TRUE;
}
}
//**********************************************/
// rm_dir
//
// Removes directories, if non empty, removes
// content and directories
// (Code based on annotations from the php.net
// manual by pal@degerstrom.com)
//**********************************************/
function rm_dir($file)
{
global $INFO;
$errors = 0;
// Remove trailing slashes..
$file = preg_replace( "#/$#", "", $file );
if ( file_exists($file) )
{
// Attempt CHMOD
@chmod($file, 0777);
if ( is_dir($file) )
{
$handle = opendir($file);
while (($filename = readdir($handle)) !== false)
{
if (($filename != ".") && ($filename != ".."))
{
$this->rm_dir($file."/".$filename);
}
}
closedir($handle);
if ( ! @rmdir($file) )
{
$errors++;
}
}
else
{
if ( ! @unlink($file) )
{
$errors++;
}
}
}
if ($errors == 0)
{
return TRUE;
}
else
{
return FALSE;
}
}
//**********************************************/
// rebuild_config:
//
// Er, rebuilds the config file
//
//**********************************************/
function rebuild_config( $new = "" )
{
global $IN, $std, $root_path;
//-----------------------------------------
// Check to make sure this is a valid array
//-----------------------------------------
if (! is_array($new) )
{
$ADMIN->error("Error whilst attempting to rebuild the board config file, attempt aborted");
}
//-----------------------------------------
// Do we have anything to save out?
//-----------------------------------------
if ( count($new) < 1 )
{
return "";
}
//-----------------------------------------
// Get an up to date copy of the config file
// (Imports $INFO)
//-----------------------------------------
require $root_path.'conf_global.php';
//-----------------------------------------
// Rebuild the $INFO hash
//-----------------------------------------
foreach( $new as $k => $v )
{
// Update the old...
$v = preg_replace( "/'/", "\\'" , $v );
$v = preg_replace( "/\r/", "" , $v );
$INFO[ $k ] = $v;
}
//-----------------------------------------
// Rename the old config file
//-----------------------------------------
@rename( $root_path.'conf_global.php', $root_path.'conf_global-bak.php' );
@chmod( $root_path.'conf_global-bak.php', 0777);
//-----------------------------------------
// Rebuild the old file
//-----------------------------------------
$file_string = "<?php\n";
foreach( $INFO as $k => $v )
{
if ($k == 'skin' or $k == 'languages')
{
// Protect serailized arrays..
$v = stripslashes($v);
$v = addslashes($v);
}
$file_string .= '$INFO['."'".$k."'".']'."\t\t\t=\t'".$v."';\n";
}
$file_string .= "\n".'?'.'>'; // Question mark + greater than together break syntax hi-lighting in BBEdit 6 :p
if ( $fh = fopen( $root_path.'conf_global.php', 'w' ) )
{
fputs ($fh, $file_string, strlen($file_string) );
fclose($fh);
}
else
{
$ADMIN->error("Fatal Error: Could not open conf_global for writing - no changes applied. Try changing the CHMOD to 0777");
}
// Pass back the new $INFO array to anyone who cares...
return $INFO;
}
//**********************************************/
// compile_forum_perms:
//
// Returns the READ/REPLY/START DB strings
//
//**********************************************/
function compile_forum_perms() {
global $DB, $IN;
$r_array = array( 'READ' => '', 'REPLY' => '', 'START' => '' );
if ($IN['READ_ALL'] == 1)
{
$r_array['READ'] = '*';
}
if ($IN['REPLY_ALL'] == 1)
{
$r_array['REPLY'] = '*';
}
if ($IN['START_ALL'] == 1)
{
$r_array['START'] = '*';
}
$DB->query("SELECT g_id, g_title FROM ibf_groups ORDER BY g_id");
while ( $data = $DB->fetch_row() )
{
if ($r_array['READ'] != '*')
{
if ($IN[ 'READ_'.$data['g_id'] ] == 1)
{
$r_array['READ'] .= $data['g_id'].",";
}
}
//+----------------------------
if ($r_array['REPLY'] != '*')
{
if ($IN[ 'REPLY_'.$data['g_id'] ] == 1)
{
$r_array['REPLY'] .= $data['g_id'].",";
}
}
//+----------------------------
if ($r_array['START'] != '*')
{
if ($IN[ 'START_'.$data['g_id'] ] == 1)
{
$r_array['START'] .= $data['g_id'].",";
}
}
}
$r_array['START'] = preg_replace( "/,$/", "", $r_array['START'] );
$r_array['REPLY'] = preg_replace( "/,$/", "", $r_array['REPLY'] );
$r_array['READ'] = preg_replace( "/,$/", "", $r_array['READ'] );
return $r_array;
}
//+------------------------------------------------
//+------------------------------------------------
// OUTPUT FUNCTIONS
//+------------------------------------------------
//+------------------------------------------------
function output() {
global $IN, $INFO, $DB, $std, $SKIN, $use_gzip;
$html = $SKIN->print_top($this->page_title, $this->page_detail);
$html .= $this->html;
$html .= $SKIN->print_foot();
$DB->close_db();
if ($use_gzip == 1)
{
ob_start ('ob_gzhandler');
}
//@header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
//@header("Cache-Control: no-cache, must-revalidate");
//@header("Pragma: no-cache");
print $html;
exit();
}
//**********************************************/
// Error:
//
// Displays an error
//
//**********************************************/
function error($error="") {
global $IN, $INFO, $DB, $std, $SKIN, $HTTP_REFERER;
$this->page_title = "An Error Occured...";
$this->page_detail = "The error message returned is displayed below.";
$this->html .= "<tr><td><span style='font-size:14px'>$error</span><br><br><center><a href='$HTTP_REFERER'>Go Back</a></center></td></tr>";
$this->output();
}
//**********************************************/
// Done Screen:
//
// Displays the "done" screen. Really? Yes.
//
//**********************************************/
function done_screen($title, $link_text="", $link_url="") {
global $IN, $INFO, $DB, $std, $SKIN;
$this->page_title = $title;
$this->page_detail = "The action was executed successfully";
$SKIN->td_header[] = array( "&nbsp;" , "100%" );
$this->html .= $SKIN->start_table("Result");
$this->html .= $SKIN->add_td_basic( "<a href='{$this->base_url}&{$link_url}' target='body'>Go to: $link_text</a>", "center" );
$this->html .= $SKIN->add_td_basic( "<a href='{$this->base_url}&act=index' target='body'>Go to: Administration Home</a>", "center" );
$this->html .= $SKIN->end_table();
$this->output();
}
function info_screen($text="", $title='Safe Mode Restriction Warning') {
global $IN, $INFO, $DB, $std, $SKIN;
$this->page_title = $title;
$this->page_detail = "Please note the following:";
$SKIN->td_header[] = array( "&nbsp;" , "100%" );
$this->html .= $SKIN->start_table("Result");
$this->html .= $SKIN->add_td_basic( $text );
$this->html .= $SKIN->add_td_basic( "<a href='{$this->base_url}&act=index' target='body'>Go to: Administration Home</a>", "center" );
$this->html .= $SKIN->end_table();
$this->output();
}
//**********************************************/
// MENU:
//
// Build the collapsable menu trees
//
//**********************************************/
function menu() {
global $IN, $std, $PAGES, $CATS, $SKIN;
$links = $this->build_tree();
$html = $SKIN->menu_top() . $links . $SKIN->menu_foot();
print $html;
exit();
}
//+------------------------------------------------
function build_tree() {
global $IN, $std, $PAGES, $CATS, $SKIN, $DESC;
$html = "";
$links = "";
foreach($CATS as $cid => $name)
{
if ( preg_match( "/(?:^|,)$cid(?:,|$)/", $IN['show'] ) )
{
foreach($PAGES[ $cid ] as $pid => $pdata)
{
$links .= $SKIN->menu_cat_link($pdata[1], $pdata[0]);
}
$html .= $SKIN->menu_cat_expanded( $name, $links, $cid );
unset($links);
}
else
{
$html .= $SKIN->menu_cat_collapsed( $name, $cid, $DESC[ $cid ] );
}
}
return $html;
}
}
?>
+95
View File
@@ -0,0 +1,95 @@
<?php
// Simple library that holds all the links for the admin cp
// CAT_ID => array( PAGE_ID => (PAGE_NAME, URL ) )
// $PAGES[ $cat_id ][$page_id][0] = Page name
// $PAGES[ $cat_id ][$page_id][1] = Url
$PAGES = array(
0 => array (
1 => array( 'Basic Config', 'act=op&code=url' ),
2 => array( 'Security & Privacy' , 'act=op&code=secure' ),
3 => array( 'Topics & Posts', 'act=op&code=post' ),
4 => array( 'User Profiles' , 'act=op&code=avatars' ),
5 => array( 'Date Formats' , 'act=op&code=dates' ),
6 => array( 'CPU Saving' , 'act=op&code=cpu' ),
7 => array( 'Cookies' , 'act=op&code=cookie' ),
8 => array( 'PM Set up' , 'act=op&code=pm' ),
9 => array( 'Board on/off' , 'act=op&code=board' ),
10 =>array( 'News Set-up' , 'act=op&code=news' ),
),
1 => array (
1 => array( 'New Category' , 'act=cat&code=new' ),
2 => array( 'New Forum' , 'act=forum&code=newsp' ),
3 => array( 'Manage' , 'act=cat&code=edit' ),
4 => array( 'Re-Order Categories' , 'act=cat&code=reorder'),
5 => array( 'Re-Order Forums', 'act=forum&code=reorder'),
6 => array( 'Moderators' , 'act=mod' ),
),
3 => array (
1 => array ( 'Pre-Register' , 'act=mem&code=add' ),
2 => array ( 'Edit User' , 'act=mem&code=edit' ),
3 => array ( 'Delete User(s)' , 'act=mem&code=del' ),
4 => array ( 'Ban Settings' , 'act=mem&code=ban' ),
5 => array ( 'User Title/Ranks' , 'act=mem&code=title'),
6 => array ( 'Manage User Groups' , 'act=group' ),
7 => array ( 'Manage Registrations', 'act=mem&code=mod' ),
),
4 => array (
1 => array( 'Manage Word Filters', 'act=op&code=bw' ),
2 => array( 'Manage Emoticons', 'act=op&code=emo' ),
3 => array( 'Manage Help Files', 'act=help' ),
4 => array( 'Recount Statistics', 'act=op&code=count' ),
5 => array( 'View Moderator Logs', 'act=modlog' ),
),
5 => array (
1 => array( 'Manage Board Wrappers' , 'act=wrap' ),
2 => array( 'Manage Skin Templates' , 'act=templ' ),
3 => array( 'Manage Style Sheets' , 'act=style' ),
4 => array( 'Manage Image&Macros' , 'act=image' ),
5 => array( '<b>Manage Skin Sets</b>' , 'act=sets' ),
6 => array( 'Import Skin files' , 'act=import' ),
),
6 => array (
1 => array( 'Manage Languages' , 'act=lang' ),
2 => array( 'Import a Language', 'act=lang&code=import' ),
),
);
$CATS = array (
0 => "Board Settings",
1 => 'Forum Control',
3 => 'Users and Groups',
4 => 'Administration',
5 => 'Skins & Templates',
6 => 'Languages',
);
$DESC = array (
0 => "Edit forum settings such as cookie paths, security features, posting abilities, etc",
1 => "Create, edit, remove and re-order categories, forums and moderators",
3 => "Edit, register, remove and ban members. Set up member titles and ranks. Manage User Groups and moderated registrations",
4 => "Manage Help Files, Bad Word Filters and Emoticons",
5 => "Manage templates, skins, colours and images.",
6 => "Manage language sets",
);
?>
+920
View File
@@ -0,0 +1,920 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Admin HTML stuff library
| > Script written by Matt Mecham
| > Date started: 1st march 2002
|
+--------------------------------------------------------------------------
*/
class admin_skin {
var $base_url;
var $img_url;
var $has_title;
var $td_widths = array();
var $td_header = array();
var $td_colspan;
function admin_skin() {
global $INFO, $IN;
$this->base_url = $INFO['board_url']."/admin.".$INFO['php_ext']."?adsess=".$IN['AD_SESS'];
$this->img_url = $INFO['html_url'].'/sys-img';
}
//+--------------------------------------------------------------------
//+--------------------------------------------------------------------
// Javascript elements
//+--------------------------------------------------------------------
//+--------------------------------------------------------------------
function js_checkdelete()
{
return "
<script language='javascript'>
<!--
function checkdelete(theURL) {
final_url = \"{$this->base_url}&\" + theURL;
if ( confirm('Are you sure you wish to remove this?\\nIt cannot be undone!') )
{
document.location.href=final_url;
}
else
{
alert('Ok, remove cancelled!');
}
}
//-->
</script>
";
}
function js_no_specialchars()
{
return "
<script language='javascript'>
<!--
function no_specialchars(type) {
var name;
if (type == 'sets')
{
var field = document.theAdminForm.sname;
name = 'Skin Set Title';
}
if (type == 'wrapper')
{
var field = document.theAdminForm.name;
name = 'Wrapper Title';
}
if (type == 'csssheet')
{
var field = document.theAdminForm.name;
name = 'StyleSheet Title';
}
if (type == 'templates')
{
var field = document.theAdminForm.skname;
name = 'Template Set Name';
}
if (type == 'images')
{
var field = document.theAdminForm.setname;
name = 'Image & Macro Set Title';
}
var valid = 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.():;~+-_';
var ok = 1;
var temp;
for (var i=0; i < field.value.length; i++) {
temp = \"\" + field.value.substring(i,i+1);
if (valid.indexOf(temp) == \"-1\")
{
ok = 0;
}
}
if (ok == 0)
{
alert('Invalid entry for: ' + name + ', you can only use alphanumerics and the following special characters.\\n. ( ) : ; ~ + - _');
return false;
} else {
return true;
}
}
//-->
</script>
";
}
//+--------------------------------------------------------------------
//+--------------------------------------------------------------------
// FORM ELEMENTS
//+--------------------------------------------------------------------
//+--------------------------------------------------------------------
function start_form($hiddens="", $name='theAdminForm', $js="") {
global $IN, $INFO;
$form = "<form action='{$this->base_url}' method='post' name='$name' $js>
<input type='hidden' name='adsess' value='{$IN['AD_SESS']}'>";
if (is_array($hiddens))
{
foreach ($hiddens as $k => $v) {
$form .= "\n<input type='hidden' name='{$v[0]}' value='{$v[1]}'>";
}
}
return $form;
}
//+--------------------------------------------------------------------
function form_hidden($hiddens="") {
if (is_array($hiddens))
{
foreach ($hiddens as $k => $v) {
$form .= "\n<input type='hidden' name='{$v[0]}' value='{$v[1]}'>";
}
}
return $form;
}
//+--------------------------------------------------------------------
function end_form($text = "", $js = "")
{
// If we have text, we print another row of TD elements with a submit button
$html = "";
$colspan = "";
if ($text != "")
{
if ($this->td_colspan > 0)
{
$colspan = " colspan='".$this->td_colspan."' ";
}
$html .= "<tr><td align='center' id='tdrow2'".$colspan."><input type='submit' value='$text'".$js." id='button' accesskey='s'></td></tr>\n";
}
$html .= "</form>";
return $html;
}
//+--------------------------------------------------------------------
function form_input($name, $value="", $type='text', $js="") {
if ($js != "")
{
$js = ' '.$js.' ';
}
return "<input type='$type' name='$name' value='$value' style='width:95%'".$js." id='textinput'>";
}
//+--------------------------------------------------------------------
function form_textarea($name, $value="", $cols='60', $rows='5', $wrap='soft') {
return "<textarea name='$name' cols='$cols' rows='$rows' wrap='$wrap' id='multitext'>$value</textarea>";
}
//+--------------------------------------------------------------------
function form_dropdown($name, $list=array(), $default_val="", $js="") {
if ($js != "")
{
$js = ' '.$js.' ';
}
$html = "<select name='$name'".$js." id='dropdown'>\n";
foreach ($list as $k => $v)
{
$selected = "";
if ( ($default_val != "") and ($v[0] == $default_val) )
{
$selected = ' selected';
}
$html .= "<option value='".$v[0]."'".$selected.">".$v[1]."</option>\n";
}
$html .= "</select>\n\n";
return $html;
}
//+--------------------------------------------------------------------
function form_yes_no( $name, $default_val="" ) {
$yes = "Yes &nbsp; <input type='radio' name='$name' value='1' id='green'>";
$no = "<input type='radio' name='$name' value='0' id='red'> &nbsp; No";
if ($default_val == 1)
{
$yes = "Yes &nbsp; <input type='radio' name='$name' value='1' checked id='green'>";
}
else
{
$no = "<input type='radio' name='$name' value='0' checked id='red'> &nbsp; No";
}
return $yes.'&nbsp;&nbsp;&nbsp;'.$no;
}
//+--------------------------------------------------------------------
function build_group_perms( $read='*', $write='*', $reply='*' ) {
global $DB;
$html = "
<script language='Javascript1.1'>
<!--
function check_all(str_part) {
var f = document.theAdminForm;
for (var i = 0 ; i < f.elements.length; i++)
{
var e = f.elements[i];
if ( (e.name != 'READ_ALL') && (e.name != 'REPLY_ALL') && (e.name != 'START_ALL') && (e.type == 'checkbox') && (! e.disabled) )
{
s = e.name;
a = s.substring(0, 4);
if (a == str_part)
{
e.checked = true;
}
}
}
}
function obj_checked(IDnumber) {
var f = document.theAdminForm;
str_part = '';
if (IDnumber == 1) { str_part = 'READ' }
if (IDnumber == 2) { str_part = 'REPL' }
if (IDnumber == 3) { str_part = 'STAR' }
totalboxes = 0;
total_on = 0;
for (var i = 0 ; i < f.elements.length; i++)
{
var e = f.elements[i];
if ( (e.name != 'READ_ALL') && (e.name != 'REPLY_ALL') && (e.name != 'START_ALL') && (e.type == 'checkbox') )
{
s = e.name;
a = s.substring(0, 4);
if (a == str_part)
{
totalboxes++;
if (e.checked)
{
total_on++;
}
}
}
}
if (totalboxes == total_on)
{
if (IDnumber == 1) { f.READ_ALL.checked = true; }
if (IDnumber == 2) { f.REPLY_ALL.checked = true; }
if (IDnumber == 3) { f.START_ALL.checked = true; }
}
else
{
if (IDnumber == 1) { f.READ_ALL.checked = false; }
if (IDnumber == 2) { f.REPLY_ALL.checked = false; }
if (IDnumber == 3) { f.START_ALL.checked = false; }
}
}
//-->
</script>
";
$html .= "<table cellspacing='0' cellpadding='2' width='100%' border='0' align='center' border='0'>
<tr>
<td width='40%'><b><i>Member Group</i></b></td>
<td width='30%'><b>Read Topics</b></td>
<td width='30%'><b>Reply to Topics</b></td>
<td width='30%'><b>Start Topics</b></td>
</tr>
<tr>
<td align='left'><span style='color:red'>ALL MEMBER GROUPS</span><br>(current and future)</td>\n";
//+-------------------------------------------------------------------------
if ($read == '*')
{
$html .= "<td align='center' id='memgroup'><input type='checkbox' onClick='check_all(\"READ\")' name='READ_ALL' value='1' checked></td>\n";
}
else
{
$html .= "<td align='center' id='memgroup'><input type='checkbox' onClick='check_all(\"READ\")' name='READ_ALL' value='1'></td>\n";
}
//+-------------------------------------------------------------------------
if ($reply == '*')
{
$html .= "<td align='center' id='mggreen'><input type='checkbox' onClick='check_all(\"REPL\")' name='REPLY_ALL' value='1' checked></td>\n";
}
else
{
$html .= "<td align='center' id='mggreen'><input type='checkbox' onClick='check_all(\"REPL\")' name='REPLY_ALL' value='1'></td>\n";
}
//+-------------------------------------------------------------------------
if ($write == '*')
{
$html .= "<td align='center' id='mgred'><input type='checkbox' onClick='check_all(\"STAR\")' name='START_ALL' value='1' checked></td>\n";
}
else
{
$html .= "<td align='center' id='mgred'><input type='checkbox' onClick='check_all(\"STAR\")' name='START_ALL' value='1'></td>\n";
}
//+-------------------------------------------------------------------------
$html .= "</tr>
<tr>
<td colspan='4'><br><b><i>OR</i> adjust the member groups individually below</b><br>&nbsp;</td>
</tr>
<tr>\n";
$DB->query("SELECT g_id, g_title FROM ibf_groups ORDER BY g_title ASC");
while ( $data = $DB->fetch_row() )
{
$html .= "<tr>
<td align='right'><b>{$data['g_title']}</b></td>\n";
if ($read == '*')
{
$html .= "<td align='center' id='memgroup'>Read&nbsp;<input type='checkbox' name='READ_{$data['g_id']}' value='1' checked onclick=\"obj_checked(1)\"></td>";
}
else if ( preg_match( "/(^|,)".$data['g_id']."(,|$)/", $read ) )
{
$html .= "<td align='center' id='memgroup'>Read&nbsp;<input type='checkbox' name='READ_{$data['g_id']}' value='1' checked onclick=\"obj_checked(1)\"></td>";
}
else
{
$html .= "<td align='center' id='memgroup'>Read&nbsp;<input type='checkbox' name='READ_{$data['g_id']}' value='1' onclick=\"obj_checked(1)\"></td>";
}
//+----------------------------------------------------------------------------------------
if ($reply == '*')
{
$html .= "<td align='center' id='mggreen'>Reply&nbsp;<input type='checkbox' name='REPLY_{$data['g_id']}' value='1' checked onclick=\"obj_checked(2)\"></td>";
}
else if ( preg_match( "/(?:^|,)".$data['g_id']."(?:,|$)/", $reply ) )
{
$html .= "<td align='center' id='mggreen'>Reply&nbsp;<input type='checkbox' name='REPLY_{$data['g_id']}' value='1' onclick=\"obj_checked(2)\" checked></td>";
}
else
{
$html .= "<td align='center' id='mggreen'>Reply&nbsp;<input type='checkbox' name='REPLY_{$data['g_id']}' value='1' onclick=\"obj_checked(2)\"></td>";
}
//+----------------------------------------------------------------------------------------
if ($write == '*')
{
$html .= "<td align='center' id='mgred'>Start&nbsp;<input type='checkbox' name='START_{$data['g_id']}' value='1' checked onclick=\"obj_checked(3)\"></td>";
}
else if ( preg_match( "/(?:^|,)".$data['g_id']."(?:,|$)/", $write ) )
{
$html .= "<td align='center' id='mgred'>Start&nbsp;<input type='checkbox' name='START_{$data['g_id']}' value='1' checked onclick=\"obj_checked(3)\"></td>";
}
else
{
$html .= "<td align='center' id='mgred'>Start&nbsp;<input type='checkbox' name='START_{$data['g_id']}' value='1' onclick=\"obj_checked(3)\"></td>";
}
$html .= "</tr><tr><td colspan='4' style='height:3px'>&nbsp;</td></tr>\n\n";
}
$html .= "</table>\n\n";
return $html;
}
//+--------------------------------------------------------------------
//+--------------------------------------------------------------------
// SCREEN ELEMENTS
//+--------------------------------------------------------------------
//+--------------------------------------------------------------------
function add_subtitle($title="",$id="subtitle", $colspan="") {
if ($colspan != "")
{
$colspan = " colspan='$colspan' ";
}
return "\n<tr><td id='$id'".$colspan.">$title</td><tr>\n";
}
//+--------------------------------------------------------------------
function start_table( $title="") {
if ($title != "")
{
$this->has_title = 1;
$html .= "<tr>
<td id='subtitle'>&#149;&nbsp;$title</td>
<tr>
<td>
<table cellpadding='8' cellspacing='0' width='100%' align='center' border='0' id='tablewrap'>
";
}
$html .= "<tr>
<td>
<table width='100%' cellspacing='1' cellpadding='0' align='center' border='0' id='table1'>
<tr>
<td>
<table width='100%' cellspacing='2' cellpadding='3' align='center' border='0'>";
if (isset($this->td_header[0]))
{
$html .= "<tr>\n";
foreach ($this->td_header as $td)
{
if ($td[1] != "")
{
$width = " width='{$td[1]}' ";
}
else
{
$width = "";
}
$html .= "<td id='tdtop'".$width."align='center'>{$td[0]}</td>\n";
$this->td_colspan++;
}
$html.= "</tr>\n";
}
return $html;
}
//+--------------------------------------------------------------------
function add_td_row( $array, $css="" ) {
if (is_array($array))
{
$html = "<tr>\n";
$count = count($array);
$this->td_colspan = $count;
for ($i = 0; $i < $count ; $i++ )
{
$td_col = $i % 2 ? 'tdrow2' : 'tdrow1';
if ($css != "")
{
$td_col = $css;
}
if (is_array($array[$i]))
{
$text = $array[$i][0];
$colspan = $array[$i][1];
$html .= "<td id='$td_col' colspan='$colspan' id='$css'>".$text."</td>\n";
}
else
{
$html .= "<td id='$td_col'>".$array[$i]."</td>\n";
}
}
$html .= "</tr>\n";
return $html;
}
}
//+--------------------------------------------------------------------
function add_td_basic($text="",$align="left",$id="tdrow1") {
$html = "";
$colspan = "";
if ($text != "")
{
if ($this->td_colspan > 0)
{
$colspan = " colspan='".$this->td_colspan."' ";
}
$html .= "<tr><td align='$align' id='$id'".$colspan.">$text</td></tr>\n";
}
return $html;
}
//+--------------------------------------------------------------------
function add_td_spacer() {
if ($this->td_colspan > 0)
{
$colspan = " colspan='".$this->td_colspan."' ";
}
return "<tr><td".$colspan."><img src='html/sys-img/blank.gif' height='7' width='1'></td></tr>";
}
//+--------------------------------------------------------------------
function end_table() {
$this->td_header = array(); // Reset TD headers
if ($this->has_title == 1)
{
$this->has_title = 0;
return "</table></td></tr></table></td></tr></table></td></tr>";
}
else
{
return "</table></td></tr></table></td></tr>";
}
}
//+--------------------------------------------------------------------
//+--------------------------------------------------------------------
//+--------------------------------------------------------------------
function print_top($title="",$desc="") {
return "<html>
<head><title>Menu</title>
<meta http-equiv=\"Cache-Control\" content=\"no-cache, must-revalidate\">
<meta http-equiv=\"Pragma\" content=\"no-cache\">
<meta http-equiv=\"Expires\" content=\"Mon, 26 Jul 1997 05:00:00 GMT\">
<style type='text/css'>
TABLE, TR, TD { font-family:Verdana, Arial;font-size: 10px; color:#333333 }
BODY { font: 10px Verdana; color:#333333 }
a:link, a:visited, a:active { color:#000055 }
a:hover { color:#333377;text-decoration:underline }
#title { font-size:10px; font-weight:bold; line-height:150%; color:#FFFFFF; height: 26px; background-image: url({$this->img_url}/tile_back.gif); }
#title a:link, #title a:visited, #title a:active { text-decoration: underline; color : #FFFFFF; font-size:11px }
#detail { font-family: Arial; font-size:11px; color: #333333 }
#large { font-family: verdana, arial; font-size:20px; color:#4C77B6; font-weight:bold; letter-spacing:-1px }
#subtitle { font-family: Arial,Verdana; font-size:18px; color:#FF9900; font-weight:bold }
#table1 { background-color:#FFFFFF; width:100%; align:center; border:1px solid black }
#tdrow1 { background-color:#EEF2F7 }
#subforum { background-color:#DFE6EF }
#tdrow2 { background-color:#F5F9FD }
#catrow { font-weight:bold; height:24px; line-height:150%; color:#4C77B6; background-image: url({$this->img_url}/tile_sub.gif); }
#catrow2 { font-size:10px; font-weight:bold; line-height:150%; color:#4C77B6; background-color:#D3DFEF; }
#tablewrap { border:1px dashed #777777; background-color:#F5F9FD }
#copy { color:#555555; font-size:9px }
#tdtop { font-weight:bold; height:24px; line-height:150%; color:#FFFFFF; background-image: url({$this->img_url}/tile_back.gif); }
#memgroup { border:1px solid #777777 }
#mgred { border:1px solid #777777; background-color: #f5cdcd }
#mggreen { border:1px solid #777777; background-color: #caf2d9 }
#green { background-color: #caf2d9 }
#red { background-color: #f5cdcd }
#button { background-color: #4C77B6; color: #FFFFFF; font-family:Verdana, Arial; font-size:11px }
#textinput { background-color: #FFFFFF; color:Ê#000000; font-family:Verdana, Arial; font-size:10px }
#dropdown { background-color: #F5F9FD; color:Ê#000000; font-family:Verdana, Arial; font-size:10px }
#multitext { background-color: #F5F9FD; color:Ê#000000; font-family:Verdana, Arial; font-size:10px }
</style>
</head>
<body marginheight='0' marginwidth='0' leftmargin='0' topmargin='0' bgcolor='#E7E7E7'>
<table cellspacing='3' cellpadding='2' width='100%' align='center' border='0' bgcolor='#E7E7E7'>
<tr>
<td>
<table cellspacing='3' cellpadding='2' width='100%' align='center' border='0' bgcolor='#FFFFFF' style='border:thin solid black'>
<tr>
<td align='center' id='title'>Invision Board Administration</td>
</tr>
<tr>
<td valign='top' bgcolor='#FFFFFF'>
<table cellspacing='0' cellpadding='2' border='0' align='center' width='100%' height='100%' bgcolor='#FFFFFF'>
<tr>
<td id='large'>$title</td>
</tr>
<td>$desc<br>&nbsp;</td>
</tr>";
}
//+--------------------------------------------------------------------
function print_foot() {
return " </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr><td align='center' id='copy'>&copy 2002 Invision Board (www.invisionboard.com)</td></tr>
</table>
</body>
</html>";
}
//+--------------------------------------------------------------------
//{ background-color:#C2CFDF; font-weight:bold; font-size:12px; color:#000055 }
function menu_top() {
global $INFO;
return "<html>
<head><title>Menu</title>
<style type='text/css'>
TABLE, TR, TD { font-family:Verdana, Arial;font-size: 9px; color:#333333 }
BODY { font: 9px Verdana; color:#333333 }
a:link, a:visited, a:active { color:#333355 }
a:hover { color:#333355;text-decoration:underline }
#title { font-size:10px; font-weight:bold; line-height:150%; color:#FFFFFF; height: 24px; background-image: url({$this->img_url}/tile_back.gif); }
#title a:link, #title a:visited, #title a:active { text-decoration: none; color : #555555 }
#detail { font-family: Arial; font-size:7.5pt; color: #333333; background-color:#EEF2F7 }
#cattitle { font-size:10px; font-weight:bold; line-height:150%; color:#4C77B6; background-color:#C4DCF7; height: 24px; background-image: url({$this->img_url}/tile_sub.gif); }
#cattitle a:link, #cattitle a:visited, #cattitle a:active { text-decoration: underline; color : #4C77B6; }
</style>
</head>
<body marginheight='0' marginwidth='0' leftmargin='0' topmargin='0' bgcolor='#E7E7E7'>
<table cellspacing='3' cellpadding='2' width='100%' align='center' border='0' bgcolor='#E7E7E7'>
<tr>
<td>
<table cellspacing='1' cellpadding='2' width='100%' align='center' border='0' bgcolor='#FFFFFF' style='border:thin solid black'>
<tr>
<td align='center'>
<table cellspacing='0' cellpadding='0' width='100%' align='center' border='0' bgcolor='#FFFFFF'>
<tr>
<td align='center' id='title'><img src='{$this->img_url}/ad-logo.jpg' border='0'></td>
</tr>
<tr>
<td align='center' id='cattitle'>Administration Menu</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign='top' bgcolor='#FFFFFF' align='center'>
<a href='{$this->base_url}&act=menu&show=all' target='menu'>Expand All</a> | <a href='{$this->base_url}&act=menu&show=none' target='menu'>Reduce All</a>
<br>
<a href='{$this->base_url}&act=index' target='body'>ACP Home</a> | <a href='{$INFO['board_url']}/index.{$INFO['php_ext']}' target='_blank'>Board Home</a>
</td>
</tr>
<tr>
<td valign='top' bgcolor='#FFFFFF'>
<table cellspacing='0' cellpadding='2' border='0' align='center' width='100%' height='100%' bgcolor='#FFFFFF'>
<tr>
<td>";
}
//+--------------------------------------------------------------------
function menu_foot() {
return " </td>
</tr>
</table>
</td>
</tr>
</table>
</tr>
</td>
</table>
</body>
</html>";
}
//+--------------------------------------------------------------------
function menu_cat_expanded($name="", $links="", $id = "") {
global $IN;
return "<a name='cat$id'></a>
<table cellpadding='0 cellspacing='0' width='100%' border='0' align='center' style='border:1px solid #333333'>
<tr>
<td id='cattitle'>
<table cellspacing='1' cellpadding='3' border='0' width='100%'>
<tr>
<td align='left' valign='middle' id='cattitle'>&nbsp;&nbsp;<a href='{$this->base_url}&act=menu&show={$IN['show']}&out=$id' target='menu'><img src='{$this->img_url}/minus.gif' border='0' alt='Collapse Category' title='Collapse Category'></a></td>
<td align='left' valign='middle' id='cattitle'>&nbsp;&nbsp;<a href='{$this->base_url}&act=menu&show={$IN['show']}&out=$id' target='menu'><span style='color:#000000'>$name</span></a></td>
</tr>
</table>
</td>
</tr>
$links
</table>
<br>";
}
//+--------------------------------------------------------------------
function menu_cat_collapsed($name="", $id = "", $desc="") {
global $IN;
return "<table cellpadding='0 cellspacing='2' width='100%' border='0' align='center' style='border:1px solid #777777'>
<tr>
<td id='cattitle'>
<table cellspacing='0' cellpadding='3' border='0' width='100%'>
<tr>
<td align='left' valign='middle' id='cattitle'>&nbsp;&nbsp;<a href='{$this->base_url}&act=menu&show=,{$IN['show']},$id' target='menu'><img src='{$this->img_url}/plus.gif' border='0' alt='Expand Category' title='Expand Category'></a></td>
<td align='left' valign='middle' id='cattitle'>&nbsp;&nbsp;<a href='{$this->base_url}&act=menu&show=,{$IN['show']},$id#cat$id' target='menu'>$name</a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td id='detail'>$desc</td>
</tr>
</table>
<br>";
}
//+--------------------------------------------------------------------
function menu_cat_link($url="", $name="") {
return "<tr><td bgcolor='#EEF2F7' valign='middle' style='height:16px'>&nbsp;&nbsp;<img src='{$this->img_url}/item.gif' border='0' alt='' valign='absmiddle'>&nbsp;<a href='{$this->base_url}&$url' target='body' style='text-decoration:none'>$name</a></td></tr>";
}
//+--------------------------------------------------------------------
function frame_set() {
global $IN, $ibforums;
$frames = "<html>
<head><title>Invision Board Administration Center</title></head>
<frameset cols='185, *' frameborder='no' border='0' framespacing='0'>
<frameset rows='*, 80' frameborder='no' border='0' framespacing='0'>
<frame name='menu' noresize scrolling='auto' src='{$this->base_url}&act=menu'>
<frame name='acp' noresize scrolling='no' src='http://www.invisionboard.com/offsite/?version={$ibforums->version}'>
</frameset>
<frame name='body' noresize scrolling='auto' src='{$this->base_url}&act=index'>
</frameset>
</html>";
return $frames;
}
}
?>
+708
View File
@@ -0,0 +1,708 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Board index module
| > Module written by Matt Mecham
| > Date started: 17th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new Boards;
class Boards {
var $output = "";
var $base_url = "";
var $html = "";
var $output = "";
var $forums = array();
var $mods = array();
var $cats = array();
var $children = array();
var $nav;
var $news_topic_id = "";
var $news_forum_id = "";
var $news_title = "";
function Boards() {
global $ibforums, $DB, $std, $print, $skin_universal;
require "./Skin/".$ibforums->skin_id."/skin_boards.php";
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
// Get more words for this invocation!
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_boards', $ibforums->lang_id);
$this->html = new skin_boards();
if (! $ibforums->member['id'] )
{
$ibforums->input['last_visit'] = time();
}
$this->output .= $this->html->PageTop( $std->get_date( $ibforums->input['last_visit'], 'LONG' ) );
// Get the forums and category info from the DB
$last_c_id = -1;
$DB->query("SELECT f.*, c.id as cat_id, c.position as cat_position, c.state as cat_state, c.name as cat_name, c.description as cat_desc, ".
"c.image, c.url from ibf_forums f, ibf_categories c order by c.position, f.position");
while ( $r = $DB->fetch_row() )
{
if ($last_c_id != $r['cat_id'])
{
$this->cats[ $r['cat_id'] ] = array( 'id' => $r['cat_id'],
'position' => $r['cat_position'],
'state' => $r['cat_state'],
'name' => $r['cat_name'],
'description' => $r['cat_desc'],
'image' => $r['image'],
'url' => $r['url'],
);
$last_c_id = $r['cat_id'];
}
if ($r['parent_id'] > 0)
{
$this->children[ $r['parent_id'] ][$r['id']] = $r;
}
else
{
$this->forums[ $r['id'] ] = $r;
}
}
$DB->query("SELECT forum_id, member_name, member_id FROM ibf_moderators");
while ( $mod = $DB->fetch_row() )
{
$this->mods[ $mod['forum_id'] ][] = array( 'name' => $mod['member_name'],
'id' => $mod['member_id'],
);
}
//-----------------------------------
// What are we doing?
//-----------------------------------
if ($ibforums->input['c'] != "")
{
$this->show_single_cat();
$this->nav[] = $this->cats[ $ibforums->input['c'] ]['name'];
}
else if ($ibforums->input['sub'] == 1)
{
$this->show_subforum();
$this->nav[] = $this->forums[ $ibforums->input['f'] ]['name'];
}
else
{
$this->process_all_cats();
}
//*********************************************/
// Add in show online users
//*********************************************/
$active = array( 'TOTAL' => 0 ,
'NAMES' => "",
'GUESTS' => 0 ,
'MEMBERS' => 0 ,
'ANON' => 0 ,
);
$stats_html = "";
if ($ibforums->vars['show_active'])
{
// Get the users from the DB
$time = time() - 900;
$DB->query("SELECT s.member_id, s.member_name, s.login_type, g.suffix, g.prefix FROM ibf_sessions s, ibf_groups g WHERE running_time > '$time' AND g.g_id=s.member_group ORDER BY running_time DESC");
// cache all printed members so we don't double print them
$cached = array();
while ($result = $DB->fetch_row() )
{
if ($result['member_id'] == 0)
{
$active['GUESTS']++;
}
else
{
if (empty( $cached[ $result['member_id'] ] ) )
{
$cached[ $result['member_id'] ] = 1;
if ($result['login_type'] == 1)
{
$active['ANON']++;
}
else
{
$active['MEMBERS']++;
$active['NAMES'] .= " <span id='highlight'>&gt;</span><a href='{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}&act=Profile&MID={$result['member_id']}'>{$result['prefix']}{$result['member_name']}{$result['suffix']}</a>";
}
}
}
}
$active['TOTAL'] = $active['MEMBERS'] + $active['GUESTS'] + $active['ANON'];
// Show a link?
if ($ibforums->vars['allow_online_list'])
{
$active['LINK'] = '[ '."<a href='".$this->base_url."&act=Online&CODE=listall'>".$ibforums->lang['browser_user_list']."</a>".' ]';
}
$stats_html .= $this->html->ActiveUsers($active);
//-----------------------------------------------
// Are we viewing the calendar?
//-----------------------------------------------
if ($ibforums->vars['show_birthdays'])
{
$user_time = time() + ($ibforums->vars['TIME_ZONE'] * 3600) + ($ibforums->member['TIME_ADJUST'] * 3600 );
$date = getdate($user_time);
$day = $date['mday'];
$month = $date['mon'];
$year = $date['year'];
$birthstring = "";
$count = 0;
$DB->query("SELECT id, name, bday_day as DAY, bday_month as MONTH, bday_year as YEAR from ibf_members WHERE bday_day='$day' and bday_month='$month'");
while ($user = $DB->fetch_row())
{
$birthstring .= "<span id='highlight'>&gt;</span><a href='{$this->base_url}&act=Profile&CODE=03&MID={$user['id']}'>{$user['name']}</a> ";
if ($user['YEAR'])
{
$pyear = $year - $user['YEAR']; // $year = 2002 and $user['YEAR'] = 1976
$birthstring .= "(<b>$pyear</b>) ";
}
$count++;
}
$lang = $ibforums->lang['no_birth_users'];
if ($count > 0) {
$lang = ($count > 1) ? $ibforums->lang['birth_users'] : $ibforums->lang['birth_user'];
}
else
{
$count = "";
}
$stats_html .= $this->html->birthdays( $birthstring, $count, $lang );
}
}
//*********************************************/
// Add in show stats
//*********************************************/
if ($ibforums->vars['show_totals'])
{
$DB->query("SELECT * FROM ibf_stats");
$stats = $DB->fetch_row();
// Update the most active count if needed
if ($active['TOTAL'] > $stats['MOST_COUNT'])
{
$DB->query("UPDATE ibf_stats SET MOST_DATE='".time()."', MOST_COUNT='".$active[TOTAL]."'");
$stats['MOST_COUNT'] = $active[TOTAL];
$stats['MOST_DATE'] = time();
}
$most_time = $std->get_date( $stats['MOST_DATE'], 'LONG' );
$ibforums->lang['most_online'] = preg_replace( "/<#NUM#>/" , $stats['MOST_COUNT'] , $ibforums->lang['most_online'] );
$ibforums->lang['most_online'] = preg_replace( "/<#DATE#>/", $most_time , $ibforums->lang['most_online'] );
$total_posts = $stats['TOTAL_REPLIES']+$stats['TOTAL_TOPICS'];
$ibforums->lang['total_word_string'] = preg_replace( "/<#posts#>/" , "$total_posts" , $ibforums->lang['total_word_string'] );
$ibforums->lang['total_word_string'] = preg_replace( "/<#reg#>/" , $stats['MEM_COUNT'] , $ibforums->lang['total_word_string'] );
$ibforums->lang['total_word_string'] = preg_replace( "/<#mem#>/" , $stats['LAST_MEM_NAME'] , $ibforums->lang['total_word_string'] );
$stats_html .= $this->html->ShowStats($ibforums->lang['total_word_string']);
}
if ($stats_html != "")
{
$this->output .= $this->html->stats_header();
$this->output .= $stats_html;
$this->output .= $this->html->stats_footer();
}
// Add in board info footer
$this->output .= $this->html->BoardInformation();
// Check for news forum.
if ($this->news_title and $this->news_topic_id and $this->news_forum_id)
{
$t_html = $this->html->newslink( $this->news_forum_id, stripslashes($this->news_title) , $this->news_topic_id);
$this->output = preg_replace( "/<!-- IBF\.NEWSLINK -->/" , "$t_html" , $this->output );
}
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." (Powered by Invision Board)", 'JS' => 0, 'NAV' => $this->nav ) );
}
//*********************************************/
//
// SHOW A SUB FORUM
//
//*********************************************/
function show_subforum() {
global $std, $DB, $ibforums;
$fid = $ibforums->input['f'];
if (!is_array( $this->forums[ $fid ] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
}
if ( (isset($this->children[ $fid ])) and (count($this->children[ $fid ]) > 0 ) )
{
foreach ($this->children[ $fid ] as $idx => $data)
{
$temp_html .= $this->process_forum($data['id'], $data);
}
}
else
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
}
if ($temp_html != "")
{
$this->output .= $this->html->subheader();
$this->output .= $temp_html;
$this->output .= $this->html->end_this_cat();
}
else
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
}
unset($temp_html);
$this->output .= $this->html->end_all_cats();
}
//*********************************************/
//
// PROCESS ALL CATEGORIES
//
//*********************************************/
function process_all_cats() {
global $std, $DB, $ibforums;
foreach ($this->cats as $cat_id => $cat_data)
{
//----------------------------
// Is this category turned on?
//----------------------------
if (! $cat_data['state'] )
{
continue;
}
foreach ($this->forums as $forum_id => $forum_data)
{
if ($forum_data['category'] == $cat_id)
{
//-----------------------------------
// We store the HTML in a temp var so
// we can make sure we have cats for
// this forum, or hidden forums with a
// cat will show the cat strip - we don't
// want that, no - we don't.
//-----------------------------------
$temp_html .= $this->process_forum($forum_id, $forum_data);
}
}
if ($temp_html != "")
{
$this->output .= $this->html->CatHeader_Expanded($cat_data);
$this->output .= $temp_html;
$this->output .= $this->html->end_this_cat();
}
unset($temp_html);
}
$this->output .= $this->html->end_all_cats();
}
//*********************************************/
//
// SHOW A SINGLE CATEGORY
//
//*********************************************/
function show_single_cat() {
global $std, $DB, $ibforums;
$cat_id = $ibforums->input['c'];
if (!is_array( $this->cats[ $cat_id ] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
}
$cat_data = $this->cats[ $cat_id ];
//----------------------------
// Is this category turned on?
//----------------------------
if (! $cat_data['state'] )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
}
foreach ($this->forums as $forum_id => $forum_data)
{
if ($forum_data['category'] == $cat_id)
{
//-----------------------------------
// We store the HTML in a temp var so
// we can make sure we have cats for
// this forum, or hidden forums with a
// cat will show the cat strip - we don't
// want that, no - we don't.
//-----------------------------------
$temp_html .= $this->process_forum($forum_id, $forum_data);
}
}
if ($temp_html != "")
{
$this->output .= $this->html->CatHeader_Expanded($cat_data);
$this->output .= $temp_html;
$this->output .= $this->html->end_this_cat();
}
else
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
}
unset($temp_html);
$this->output .= $this->html->end_all_cats();
}
//*********************************************/
//
// RENDER A FORUM
//
//*********************************************/
function process_forum($forum_id="", $forum_data="")
{
global $std, $ibforums;
if ($forum_data['subwrap'] == 1)
{
$printed_children = 0;
//--------------------------------------
// This is a sub cat forum...
//--------------------------------------
// Do we have any sub forums here?
if ( (isset($this->children[ $forum_data['id'] ])) and (count($this->children[ $forum_data['id'] ]) > 0 ) )
{
$newest = array();
foreach($this->children[ $forum_data['id'] ] as $idx => $data)
{
//--------------------------------------
// Check permissions...
//--------------------------------------
if ($data['read_perms'] != '*')
{
if ( ! preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|$)/", $data['read_perms'] ) )
{
continue;
}
}
// Do the news stuff first
if (isset($data['last_title']) and $data['last_id'] != "")
{
if ( ( $ibforums->vars['index_news_link'] == 1 ) and (! empty($ibforums->vars['news_forum_id']) ) and ($ibforums->vars['news_forum_id'] == $data['id']) )
{
$this->news_topic_id = $data['last_id'];
$this->news_forum_id = $data['id'];
$this->news_title = $data['last_title'];
}
}
if ($data['last_post'] > $newest['last_post'])
{
$newest['last_post'] = $data['last_post'];
$newest['fid'] = $data['id'];
if (strlen($data['last_title']) > 30)
{
$data['last_title'] = str_replace( "&#33;" , "!", $data['last_title'] );
$data['last_title'] = str_replace( "&quot;", "\"", $data['last_title'] );
$data['last_title'] = substr($data['last_title'],0,27) . "...";
$data['last_title'] = preg_replace( '/&(#(\d+;?)?)?\.\.\.$/', '...', $data['last_title'] );
}
if ($data['password'] != "")
{
$newest['last_topic'] = $ibforums->lang['f_protected'];
}
else
{
$newest['last_topic'] = "<a href='{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}&act=ST&f={$data['id']}&t={$data['last_id']}&view=getlastpost'>{$data['last_title']}</a>";
}
if ( isset($data['last_poster_name']))
{
$newest['last_poster'] = $data['last_poster_id'] ? "<a href='{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}&act=Profile&CODE=03&MID={$data['last_poster_id']}'>{$data['last_poster_name']}</a>"
: $data['last_poster_name'];
}
}
$newest['posts'] += $data['posts'];
$newest['topics'] += $data['topics'];
$newest['status'] = $data['status'];
$printed_children++;
}
if ($printed_children < 1)
{
// If we don't have permission to view any forums
// then simply return and the row won't be printed
return "";
}
// Fix up the last of the data
$newest['img_new_post'] = $this->new_posts($newest, 1);
$newest['last_post'] = $std->get_date($newest['last_post'], 'LONG');
$newest['last_topic'] = $newest['last_topic'] ? $newest['last_topic'] : $ibforums->lang['f_none'];
$newest['last_poster'] = $newest['last_poster'] ? $newest['last_poster'] : $ibforums->lang['f_none'];
foreach($newest as $k => $v)
{
$forum_data[$k] = $v;
}
return $this->html->ForumRow($forum_data);
}
else
{
return "";
}
}
else
{
//--------------------------------------
// Check permissions...
//--------------------------------------
if ($forum_data['read_perms'] != '*')
{
if ( ! preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|$)/", $forum_data['read_perms'] ) )
{
return "";
}
}
$forum_data['img_new_post'] = $this->new_posts($forum_data);
$forum_data['last_post'] = $std->get_date($forum_data['last_post'], 'LONG');
$forum_data['last_topic'] = $ibforums->lang['f_none'];
if (isset($forum_data['last_title']) and $forum_data['last_id'] != "")
{
if ( ( $ibforums->vars['index_news_link'] == 1 ) and (! empty($ibforums->vars['news_forum_id']) ) and ($ibforums->vars['news_forum_id'] == $forum_data['id']) )
{
$this->news_topic_id = $forum_data['last_id'];
$this->news_forum_id = $forum_data['id'];
$this->news_title = $forum_data['last_title'];
}
$forum_data['last_title'] = str_replace( "&#33;" , "!", $forum_data['last_title'] );
$forum_data['last_title'] = str_replace( "&quot;", "\"", $forum_data['last_title'] );
if (strlen($forum_data['last_title']) > 30)
{
$forum_data['last_title'] = substr($forum_data['last_title'],0,27) . "...";
$forum_data['last_title'] = preg_replace( '/&(#(\d+;?)?)?\.\.\.$/', '...', $forum_data['last_title'] );
}
if ($forum_data['password'] != "")
{
$forum_data['last_topic'] = $ibforums->lang['f_protected'];
}
else
{
$forum_data['last_topic'] = "<a href='{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}&act=ST&f={$forum_data['id']}&t={$forum_data['last_id']}&view=getlastpost'>{$forum_data['last_title']}</a>";
}
}
if ( isset($forum_data['last_poster_name']))
{
$forum_data['last_poster'] = $forum_data['last_poster_id'] ? "<a href='{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}&act=Profile&CODE=03&MID={$forum_data['last_poster_id']}'>{$forum_data['last_poster_name']}</a>"
: $forum_data['last_poster_name'];
}
else
{
$forum_data['last_poster'] = $ibforums->lang['f_none'];
}
//---------------------------------
// Moderators
//---------------------------------
$forum_data['moderator'] = "";
if (isset($this->mods[ $forum_data['id'] ] ) )
{
$forum_data['moderator'] = $ibforums->lang['forum_leader'].' ';
if (is_array($this->mods[ $forum_data['id'] ]) )
{
foreach ($this->mods[ $forum_data['id'] ] as $moderator)
{
$forum_data['moderator'] .= "<a href='{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}&act=Profile&CODE=03&MID={$moderator['id']}'>{$moderator['name']}</a>, ";
}
$forum_data['moderator'] = preg_replace( "!,\s+$!", "", $forum_data['moderator'] );
}
else
{
$forum_data['moderator'] .= "<a href='{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}&act=Profile&CODE=03&MID={$this->mods[$forum_data['id']]['id']}'>{$this->mods[$forum_data['id']]['name']}</a>";
}
}
return $this->html->ForumRow($forum_data);
}
}
function new_posts($forum_data, $sub=0) {
global $ibforums, $std;
$rtime = $ibforums->input['last_visit'];
$fid = $forum_data['fid'] == "" ? $forum_data['id'] : $forum_data['fid'];
if ( $ftime = $std->my_getcookie('fread_'.$fid ) )
{
$rtime = $ftime > $rtime ? $ftime : $rtime;
}
if ($sub == 0)
{
if ( ! $forum_data['status'] )
{
return $ibforums->skin['C_LOCKED'];
}
$sub_cat_img = '';
}
else
{
$sub_cat_img = '_CAT';
}
if ($forum_data['password'] and $sub == 0)
{
return $forum_data['last_post'] > $rtime ? $ibforums->skin['C_ON_RES']
: $ibforums->skin['C_OFF_RES'];
}
return $forum_data['last_post'] > $rtime ? $ibforums->skin['C_ON'.$sub_cat_img]
: $ibforums->skin['C_OFF'.$sub_cat_img];
}
}
?>
+244
View File
@@ -0,0 +1,244 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > mySQL DB abstraction module
| > Module written by Matt Mecham
| > Date started: 14th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
class db_driver {
var $obj = array ( "sql_database" => "" ,
"sql_user" => "root" ,
"sql_pass" => "" ,
"sql_host" => "localhost",
"sql_port" => "" ,
"persistent" => "0" ,
"sql_tbl_prefix" => "ibf_" ,
"cached_queries" => array(),
);
var $query_id = "";
var $connection_id = "";
var $query_count = 0;
var $record_row = array();
/*========================================================================*/
// Connect to the database
/*========================================================================*/
function connect() {
if ($this->obj['persistent'])
{
$this->connection_id = mysql_pconnect( $this->obj['sql_host'] ,
$this->obj['sql_user'] ,
$this->obj['sql_pass']
);
}
else
{
$this->connection_id = mysql_connect( $this->obj['sql_host'] ,
$this->obj['sql_user'] ,
$this->obj['sql_pass']
);
}
if ( !mysql_select_db($this->obj['sql_database'], $this->connection_id) )
{
echo ("ERROR: Cannot find database ".$this->obj['sql_database']);
}
}
/*========================================================================*/
// Process a query
/*========================================================================*/
function query($the_query) {
//--------------------------------------
// Change the table prefix if needed
//--------------------------------------
if ($this->obj['sql_tbl_prefix'] != "ibf_")
{
$the_query = preg_replace("/ibf_(\S+?)([\s\.,]|$)/", $this->obj['sql_tbl_prefix']."\\1\\2", $the_query);
}
$this->query_id = mysql_query($the_query, $this->connection_id);
if (! $this->query_id )
{
$this->fatal_error("mySQL query error: $the_query");
}
$this->query_count++;
$this->obj['cached_queries'][] = $the_query;
return $this->query_id;
}
/*========================================================================*/
// Fetch a row based on the last query
/*========================================================================*/
function fetch_row($query_id = "") {
if ($query_id == "")
{
$query_id = $this->query_id;
}
$this->record_row = mysql_fetch_array($query_id, MYSQL_ASSOC);
return $this->record_row;
}
/*========================================================================*/
// Fetch the number of rows affected by the last query
/*========================================================================*/
function get_affected_rows() {
return mysql_affected_rows($this->connection_id);
}
/*========================================================================*/
// Fetch the number of rows in a result set
/*========================================================================*/
function get_num_rows() {
return mysql_num_rows($this->query_id);
}
/*========================================================================*/
// Fetch the last insert id from an sql autoincrement
/*========================================================================*/
function get_insert_id() {
return mysql_insert_id($this->connection_id);
}
/*========================================================================*/
// Return the amount of queries used
/*========================================================================*/
function get_query_cnt() {
return $this->query_count;
}
/*========================================================================*/
// Free the result set from mySQLs memory
/*========================================================================*/
function free_result($query_id="") {
if ($query_id == "") {
$query_id = $this->query_id;
}
@mysql_free_result($query_id);
}
/*========================================================================*/
// Shut down the database
/*========================================================================*/
function close_db() {
return mysql_close($this->connection_id);
}
/*========================================================================*/
// Basic error handler
/*========================================================================*/
function fatal_error($the_error) {
global $INFO;
$the_error .= "\n\nmySQL error: ".mysql_error()."\n";
$the_error .= "mySQL error code: ".mysql_errno()."\n";
$the_error .= "Date: ".date("l dS of F Y h:i:s A");
$out = "<html><head><title>Invision Board Database Error</title>
<style>P,BODY{ font-family:arial,sans-serif; font-size:11px; }</style></head><body>
&nbsp;<br><br><blockquote><b>There appears to be an error with the {$INFO['board_name']} database.</b><br>
You can try to refresh the page by clicking <a href=\"javascript:window.location=window.location;\">here</a>, if this
does not fix the error, you can contact the board administrator by clicking <a href='mailto:{$INFO['email_in']}?subject=SQL+Error'>here</a>
<br><br><b>Error Returned</b><br>
<form name='mysql'><textarea rows=\"15\" cols=\"60\">".htmlspecialchars($the_error)."</textarea></form><br>We apologise for any inconvenience</blockquote></body></html>";
echo($out);
die("");
}
/*========================================================================*/
// Create an array from a multidimensional array returning formatted
// strings ready to use in an INSERT query, saves having to manually format
// the (INSERT INTO table) ('field', 'field', 'field') VALUES ('val', 'val')
/*========================================================================*/
function compile_db_insert_string($data) {
$field_names = "";
$field_values = "";
foreach ($data as $k => $v) {
$v = preg_replace( "/'/", "\\'", $v );
$field_names .= "$k,";
$field_values .= "'$v',";
}
$field_names = preg_replace( "/,$/" , "" , $field_names );
$field_values = preg_replace( "/,$/" , "" , $field_values );
return array( 'FIELD_NAMES' => $field_names,
'FIELD_VALUES' => $field_values,
);
}
/*========================================================================*/
// Create an array from a multidimensional array returning a formatted
// string ready to use in an UPDATE query, saves having to manually format
// the FIELD='val', FIELD='val', FIELD='val'
/*========================================================================*/
function compile_db_update_string($data) {
$return_string = "";
foreach ($data as $k => $v) {
$v = preg_replace( "/'/", "\\'", $v );
$return_string .= $k . "='".$v."',";
}
$return_string = preg_replace( "/,$/" , "" , $return_string );
return $return_string;
}
} // end class
?>
+653
View File
@@ -0,0 +1,653 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Forum topic index module
| > Module written by Matt Mecham
| > Date started: 14th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new Forums;
class Forums {
var $output = "";
var $base_url = "";
var $html = "";
var $moderator = array();
var $forum = array();
var $show_dots = "";
var $nav_extra = "";
var $read_array = array();
//+----------------------------------------------------------------
//
// Our constructor, load words, load skin, get DB forum/cat data
//
//+----------------------------------------------------------------
function Forums() {
global $ibforums, $DB, $std, $print, $skin_universal;
require "./Skin/".$ibforums->skin_id."/skin_forum.php";
$ibforums->input['f'] = intval($ibforums->input['f']);
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_forum', $ibforums->lang_id);
$this->html = new skin_forum();
// Get the forum info based on the forum ID, and get the category name, ID, etc.
$DB->query("SELECT f.*, c.id as cat_id, c.name as cat_name from ibf_forums f, ibf_categories c WHERE f.id=".$ibforums->input['f']." and c.id=f.category");
$this->forum = $DB->fetch_row();
//----------------------------------------
// Error out if we can not find the forum
//----------------------------------------
if (!$this->forum['id'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//----------------------------------------
// If this is a sub forum, we need to get
// the cat details, and parent details
//----------------------------------------
if ($this->forum['parent_id'] > 0)
{
$DB->query("SELECT f.id as forum_id, f.name as forum_name, c.id, c.name FROM ibf_forums f, ibf_categories c WHERE f.id='".$this->forum['parent_id']."' AND c.id=f.category");
$row = $DB->fetch_row();
$this->forum['cat_id'] = $row['id'];
$this->forum['cat_name'] = $row['name'];
$this->nav_extra = "<a href='".$ibforums->base_url."&act=SF&f={$row['forum_id']}'>{$row['forum_name']}</a>";
}
//----------------------------------------
//
// If this is a sub forum, bounce back.
//
//----------------------------------------
if ($this->forum['subwrap'] == 1)
{
$std->boink_it($ibforums->base_url."&sub=1&f=".$this->forum['id']);
exit();
}
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
$this->forum['FORUM_JUMP'] = $std->build_forum_jump();
$this->forum['FORUM_JUMP'] = preg_replace( "!#Forum Jump#!", $ibforums->lang['forum_jump'], $this->forum['FORUM_JUMP']);
// Are we viewing the forum, or viewing the forum rules?
if ($ibforums->input['act'] == 'SR')
{
$this->show_rules();
} else {
$this->show_forum();
}
}
//+----------------------------------------------------------------
//
// Show the forum rules on a seperate page
//
//+----------------------------------------------------------------
function show_rules() {
global $DB, $ibforums, $std, $print;
//+--------------------------------------------
// Do we have permission to view these rules?
//+--------------------------------------------
$bad_entry = $this->check_access();
if ($bad_entry == 1)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_view_topic') );
}
//+--------------------------------------------
// Get the rules from the DB
//+--------------------------------------------
$DB->query("SELECT * FROM ibf_rules WHERE fid='".$ibforums->input['f']."'");
if ( $rules = $DB->fetch_row() )
{
$rules['title'] = stripslashes($rules['title']);
$rules['body'] = stripslashes($rules['body']);
$this->output .= $this->html->show_rules($rules);
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => "IBForums -> ".$this->forum['name'],
'JS' => 0,
'NAV' => array(
"<a href='".$this->base_url."&act=SC&c={$this->forum['cat_id']}'>{$this->forum['cat_name']}</a>",
),
) );
}
else
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_view_topic') );
}
}
//+----------------------------------------------------------------
//
// Forum view check for authentication
//
//+----------------------------------------------------------------
function show_forum() {
global $ibforums;
// are we checking for user authentication via the log in form
// for a private forum w/password protection?
$ibforums->input['L'] == 1 ? $this->authenticate_user() : $this->render_forum();
}
//+----------------------------------------------------------------
//
// Authenicate the log in for a password protected forum
//
//+----------------------------------------------------------------
function authenticate_user() {
global $std, $ibforums, $print;
if ($ibforums->input['f_password'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'pass_blank' ) );
}
if ($ibforums->input['f_password'] != $this->forum['password'])
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'wrong_pass' ) );
}
$std->my_setcookie( "iBForum".$this->forum['id'], $ibforums->input['f_password'] );
$print->redirect_screen( $ibforums->lang['logged_in'] , "act=SF&f=".$this->forum['id'] );
}
//+----------------------------------------------------------------------------------
function check_access() {
global $ibforums, $HTTP_COOKIE_VARS;
$return = 1;
if ($this->forum['read_perms'] == '*')
{
$return = 0;
}
else if (preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|$)/", $this->forum['read_perms'] ) )
{
$return = 0;
}
if ($this->forum['password'])
{
if ($HTTP_COOKIE_VARS[ $ibforums->vars['cookie_id'].'iBForum'.$this->forum['id'] ] == $this->forum['password'])
{
$return = 0;
}
else
{
$this->forum_login();
}
}
return $return;
}
//+----------------------------------------------------------------------------------
function forum_login() {
global $ibforums, $std, $DB, $HTTP_COOKIE_VARS, $print;
if (empty($ibforums->member['id']))
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_guests' ) );
}
$this->output = $this->html->Forum_log_in( $this->forum['id'] );
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->forum['name'],
'JS' => 0,
'NAV' => array(
"<a href='".$this->base_url."&act=SC&c={$this->forum['cat_id']}'>{$this->forum['cat_name']}</a>",
"<a href='".$this->base_url."&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>",
),
) );
}
//+----------------------------------------------------------------
//
// Main render forum engine
//
//+----------------------------------------------------------------
function render_forum() {
global $ibforums, $DB, $std, $print, $HTTP_COOKIE_VARS;
$bad_entry = $this->check_access();
if ($bad_entry == 1)
{
$std->Error( array( LEVEL => 1, MSG => 'no_permission') );
}
if ( $read = $std->my_getcookie('topicsread') )
{
$this->read_array = unserialize(stripslashes($read));
}
if ( $forum = $std->my_getcookie('fread_'.$ibforums->input['f']) )
{
$ibforums->input['last_visit'] = $forum > $ibforums->input['last_visit'] ? $forum : $ibforums->input['last_visit'];
}
$prune_value = $std->select_var( array(
1 => $ibforums->input['prune_day'],
2 => $this->forum['prune'] ,
3 => '100' )
);
$sort_key = $std->select_var( array(
1 => $ibforums->input['sort_key'],
2 => $this->forum['sort_key'] ,
3 => 'last_post' )
);
$sort_by = $std->select_var( array(
1 => $ibforums->input['sort_by'],
2 => $this->forum['sort_order'] ,
3 => 'Z-A' )
);
$First = $std->select_var( array(
1 => $ibforums->input['st'],
2 => 0 )
);
// Figure out sort order, day cut off, etc
$Prune = $prune_value != 100 ? (time() - ($prune_value * 60 * 60 * 24)) : 0;
$sort_keys = array( 'last_post' => 'sort_by_date',
'title' => 'sort_by_topic',
'starter_name' => 'sort_by_poster',
'posts' => 'sort_by_replies',
'views' => 'sort_by_views',
'start_date' => 'sort_by_start',
'last_poster_name' => 'sort_by_last_poster',
);
$prune_by_day = array( '1' => 'show_today',
'5' => 'show_5_days',
'7' => 'show_7_days',
'10' => 'show_10_days',
'15' => 'show_15_days',
'20' => 'show_20_days',
'25' => 'show_25_days',
'30' => 'show_30_days',
'60' => 'show_60_days',
'90' => 'show_90_days',
'100' => 'show_all',
);
$sort_by_keys = array( 'Z-A' => 'descending_order',
'A-Z' => 'ascending_order',
);
//+----------------------------------------------------------------
// check for any form funny business by wanna-be hackers
//+----------------------------------------------------------------
if ( (!isset($sort_keys[$sort_key])) and (!isset($prune_by_day[$prune_value])) and (!isset($sort_by_keys[$sort_by])) )
{
$std->Error( array( LEVEL=> 5, MSG =>'incorrect_use') );
}
$r_sort_by = $sort_by == 'A-Z' ? 'ASC' : 'DESC';
//+----------------------------------------------------------------
// Query the database to see how many topics there are in the forum
//+----------------------------------------------------------------
$DB->query("SELECT COUNT(tid) as max FROM ibf_topics WHERE forum_id='".$this->forum['id']."' and approved='1' and (last_post > $Prune or pinned=1)");
$total_possible = $DB->fetch_row();
//+----------------------------------------------------------------
// Generate the forum page span links
//+----------------------------------------------------------------
$this->forum['SHOW_PAGES']
= $std->build_pagelinks( array( TOTAL_POSS => $total_possible[max],
PER_PAGE => $ibforums->vars['display_max_topics'],
CUR_ST_VAL => $ibforums->input['st'],
L_SINGLE => $ibforums->lang['single_page_forum'],
L_MULTI => $ibforums->lang['multi_page_forum'],
BASE_URL => $this->base_url."&act=SF&f=".$this->forum['id']."&prune_day=$prune_value&sort_by=$sort_by&sort_order=$sort_order",
)
);
//+----------------------------------------------------------------
// Do we have any rules to show?
//+----------------------------------------------------------------
if ($this->forum['show_rules'])
{
$DB->query("SELECT * from ibf_rules WHERE fid='".$this->forum['id']."'");
if ( $rules = $DB->fetch_row() )
{
$rules['title'] = stripslashes($rules['title']);
$rules['body'] = stripslashes($rules['body']);
$this->output .= $rules['show_all'] ? $this->html->show_rules_full($rules) : $this->html->show_rules_link($rules);
}
}
//+----------------------------------------------------------------
// Generate the poll button
//+----------------------------------------------------------------
$this->forum['POLL_BUTTON'] = $this->forum['allow_poll']
? "<a href='".$this->base_url."&act=Post&CODE=10&f=".$this->forum['id']."'>{$ibforums->skin['A_POLL']}</a>"
: '';
//+----------------------------------------------------------------
// Start printing the page
//+----------------------------------------------------------------
$this->output .= $this->html->PageTop($this->forum);
//+----------------------------------------------------------------
// Do we have any topics to show?
//+----------------------------------------------------------------
if ($total_possible['max'] < 1)
{
$this->output .= $this->html->show_no_matches();
}
$total_topics_printed = 0;
if ( ($ibforums->vars['show_user_posted'] == 1) and ($ibforums->member['id']) )
{
$query = "SELECT DISTINCT ibf_posts.author_id, ibf_topics.* from ibf_topics LEFT JOIN ibf_posts ON (ibf_topics.tid = ibf_posts.topic_id AND ibf_posts.author_id = '".$ibforums->member['id']."') WHERE ibf_topics.forum_id='".$this->forum['id']."' and (ibf_topics.last_post > '$Prune' OR ibf_topics.pinned='1') and ibf_topics.approved='1'";
}
else
{
$query = "SELECT * from ibf_topics WHERE forum_id='".$this->forum['id']."' and approved='1' and (last_post > '$Prune' OR pinned='1')";
}
//+----------------------------------------------------------------
// Do we have permission to view other posters topics?
//+----------------------------------------------------------------
if (!$ibforums->member['g_other_topics'])
{
$query .= " and starter_id='".$ibforums->member['id']."'";
}
//+----------------------------------------------------------------
// Finish off the query
//+----------------------------------------------------------------
$First = $First ? $First : 0;
$query .= " ORDER BY pinned DESC, $sort_key $r_sort_by LIMIT $First,".$ibforums->vars['display_max_topics'];
$DB->query($query);
//+----------------------------------------------------------------
// Grab the rest of the topics and print them
//+----------------------------------------------------------------
while ( $topic = $DB->fetch_row() )
{
$this->output .= $this->render_entry( $topic );
$total_topics_printed++;
}
//+----------------------------------------------------------------
// Finish off the rest of the page
//+----------------------------------------------------------------
$ibforums->lang['showing_text'] = preg_replace( "/<#MATCHED_TOPICS#>/", $total_topics_printed , $ibforums->lang['showing_text'] );
$ibforums->lang['showing_text'] = preg_replace( "/<#TOTAL_TOPICS#>/" , $total_possible['max'] , $ibforums->lang['showing_text'] );
$sort_key_html = "<select name='sort_key' class='forminput'>\n";
$prune_day_html = "<select name='prune_day' class='forminput'>\n";
$sort_by_html = "<select name='sort_by' class='forminput'>\n";
foreach ($sort_by_keys as $k => $v) {
$sort_by_html .= $k == $sort_by ? "<option value='$k' selected>" . $ibforums->lang[ $sort_by_keys[ $k ] ] . "\n"
: "<option value='$k'>" . $ibforums->lang[ $sort_by_keys[ $k ] ] . "\n";
}
foreach ($sort_keys as $k => $v) {
$sort_key_html .= $k == $sort_key ? "<option value='$k' selected>" . $ibforums->lang[ $sort_keys[ $k ] ] . "\n"
: "<option value='$k'>" . $ibforums->lang[ $sort_keys[ $k ] ] . "\n";
}
foreach ($prune_by_day as $k => $v) {
$prune_day_html .= $k == $prune_value ? "<option value='$k' selected>" . $ibforums->lang[ $prune_by_day[ $k ] ] . "\n"
: "<option value='$k'>" . $ibforums->lang[ $prune_by_day[ $k ] ] . "\n";
}
$ibforums->lang['sort_text'] = preg_replace( "!<#SORT_KEY_HTML#>!", "$sort_key_html</select>" , $ibforums->lang['sort_text'] );
$ibforums->lang['sort_text'] = preg_replace( "!<#ORDER_HTML#>!" , "$sort_by_html</select>" , $ibforums->lang['sort_text'] );
$ibforums->lang['sort_text'] = preg_replace( "!<#PRUNE_HTML#>!" , "$prune_day_html</select>" , $ibforums->lang['sort_text'] );
$this->output .= $this->html->TableEnd($this->forum);
//+----------------------------------------------------------------
// Are we a moderator?
//+----------------------------------------------------------------
if ( ($ibforums->member['id']) and ($ibforums->member['g_is_supmod'] != 1) )
{
$DB->query("SELECT mid FROM ibf_moderators WHERE forum_id='".$this->forum['id']."' and member_id='".$ibforums->member['id']."'");
$this->moderator = $DB->fetch_row();
}
//+----------------------------------------------------------------
// Do we have to print the moderators CP link?
//+----------------------------------------------------------------
if ($ibforums->member['g_is_supmod'] or $this->moderator['mid'])
{
$this->output .= $this->html->Mod_Panel( $this->forum['id'] );
}
//+----------------------------------------------------------------
// Print it
//+----------------------------------------------------------------
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->forum['name'],
'JS' => 0,
'NAV' => array(
"<a href='".$this->base_url."&act=SC&c={$this->forum['cat_id']}'>{$this->forum['cat_name']}</a>",
$this->nav_extra,
"<a href='".$this->base_url."&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>",
),
) );
}
//+----------------------------------------------------------------
//
// Crunches the data into pwetty html
//
//+----------------------------------------------------------------
function render_entry($topic) {
global $DB, $std, $ibforums;
$topic['last_text'] = $ibforums->lang['last_post_by'];
$topic['last_poster'] = ($topic['last_poster_id'] != 0)
? "<b><a href='{$this->base_url}&act=Profile&CODE=03&MID={$topic['last_poster_id']}'>{$topic['last_poster_name']}</a></b>"
: "-".$topic['last_poster_name']."-";
$topic['starter'] = ($topic['starter_id'] != 0)
? "<a href='{$this->base_url}&act=Profile&CODE=03&MID={$topic['starter_id']}'>{$topic['starter_name']}</a>"
: "-".$topic['starter_name']."-";
if ($topic['poll_state'])
{
$topic['prefix'] = $ibforums->vars['pre_polls'].' ';
}
if ( ($ibforums->member['id']) and ($topic['author_id']) )
{
$show_dots = 1;
}
$topic['folder_img'] = $std->folder_icon($topic, $show_dots, $this->read_array[$topic['tid']]);
$topic['topic_icon'] = $topic['icon_id'] ? '<img src="'.$ibforums->vars['img_url'] . '/icon' . $topic['icon_id'] . '.gif" border="0" alt="">'
: '&nbsp;';
$topic['start_date'] = $std->get_date( $topic['start_date'], 'LONG' );
$pages = 1;
if ($topic['posts'])
{
if ( (($topic['posts'] + 1) % $ibforums->vars['display_max_posts']) == 0 )
{
$pages = ($topic['posts'] + 1) / $ibforums->vars['display_max_posts'];
}
else
{
$number = ( ($topic['posts'] + 1) / $ibforums->vars['display_max_posts'] );
$pages = ceil( $number);
}
}
if ($pages > 1) {
$topic['PAGES'] = "<span id='small'>({$ibforums->lang['topic_sp_pages']} ";
for ($i = 0 ; $i < $pages ; ++$i ) {
$real_no = $i * $ibforums->vars['display_max_posts'];
$page_no = $i + 1;
if ($page_no == 4) {
$topic['PAGES'] .= "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&st=" . ($pages - 1) * $ibforums->vars['display_max_posts'] . "'>...$pages </a>";
break;
} else {
$topic['PAGES'] .= "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&st=$real_no'>$page_no </a>";
}
}
$topic['PAGES'] .= ")</span>";
}
if ($topic['posts'] < 0) $topic['posts'] = 0;
$last_time = $this->read_array[ $topic['tid'] ] > $ibforums->input['last_visit'] ? $this->read_array[ $topic['tid'] ] : $ibforums->input['last_visit'];
if ($last_time && ($topic['last_post'] > $last_time))
{
$topic['go_last_page'] = "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&view=getlastpost'>" . $ibforums->skin['GO_LAST_ON'] . "</a>";
$topic['go_new_post'] = "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&view=getnewpost'>" . $ibforums->skin['NEW_POST'] . "</a>";
}
else
{
$topic['go_last_page'] = "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&view=getlastpost'>" . $ibforums->skin['GO_LAST_OFF'] . "</a>";
$topic['go_new_post'] = "";
}
$topic['last_post'] = $std->get_date( $topic['last_post'], 'SHORT' );
//+----------------------------------------------------------------
if ($topic['state'] == 'link')
{
$t_array = explode("&", $topic['moved_to']);
$topic['tid'] = $t_array[0];
$topic['forum_id'] = $t_array[1];
$topic['title'] = $topic['title'];
$topic['views'] = '--';
$topic['posts'] = '--';
$topic['prefix'] = $ibforums->vars['pre_moved']." ";
$topic['go_new_post'] = "";
}
if ($topic['pinned'] == 1)
{
$topic['prefix'] = $ibforums->vars['pre_pinned'];
$topic['topic_icon'] = $ibforums->skin['B_PIN'];
}
return $this->html->RenderRow( $topic );
}
//+----------------------------------------------------------------
//
// Returns the last action date
//
//+----------------------------------------------------------------
function get_last_date($topic) {
global $ibforums, $std;
return $std->get_date( $topic['last_post'], 'SHORT' );
}
}
?>
+183
View File
@@ -0,0 +1,183 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Access the help files
| > Module written by Matt Mecham
| > Date started: 24th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new Help;
class Help {
var $output = "";
var $page_title = "";
var $nav = array();
var $html = "";
function Help() {
global $ibforums, $DB, $std, $print;
if ($ibforums->input['CODE'] == "") $ibforums->input['CODE'] = '00';
//--------------------------------------------
// Require the HTML and language modules
//--------------------------------------------
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_help', $ibforums->lang_id );
require "./Skin/".$ibforums->skin_id."/skin_help.php";
$this->html = new skin_help();
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
//--------------------------------------------
// What to do?
//--------------------------------------------
switch($ibforums->input['CODE']) {
case '01':
$this->show_section();
break;
case '02':
$this->do_search();
break;
default:
$this->show_titles();
break;
}
// If we have any HTML to print, do so...
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
}
function show_titles() {
global $ibforums, $DB, $std;
$seen = array();
$this->output = $this->html->start( $ibforums->lang['page_title'], $ibforums->lang['help_txt'], $ibforums->lang['choose_file'] );
$DB->query("SELECT id, title, description from ibf_faq ORDER BY title ASC");
$cnt = 0;
while ($row = $DB->fetch_row() ) {
if (isset($seen[ $row['title'] ]) ) {
continue;
} else {
$seen[ $row['title'] ] = 1;
}
$row['CELL_COLOUR'] = $cnt % 2 ? 'row1' : 'row2';
$cnt++;
$this->output .= $this->html->row($row);
}
$this->output .= $this->html->end();
$this->page_title = $ibforums->lang['page_title'];
$this->nav = array( $ibforums->lang['page_title'] );
}
function show_section() {
global $ibforums, $DB, $std;
$id = $ibforums->input['HID'];
if (! preg_match( "/^(\d+)$/" , $id ) ) {
$std->Error( array( LEVEL => 1, MSG => 'no_search_id') );
}
$DB->query("SELECT id, title, text from ibf_faq WHERE ID='$id'");
$topic = $DB->fetch_row();
$this->output = $this->html->start( $ibforums->lang['help_topic'], $ibforums->lang['topic_text'], $topic['title'] );
$this->output .= $this->html->display( $std->text_tidy( $topic['text'] ) );
$this->output .= $this->html->end();
$this->page_title = $ibforums->lang['help_topic'];
$this->nav = array( "<a href='{$this->base_url}&act=Help'>{$ibforums->lang['help_topics']}</a>", $ibforums->lang['help_topic'] );
}
function do_search() {
global $ibforums, $DB, $std;
if (empty( $ibforums->input['search_q'] ) ) {
$std->Error( array( LEVEL => 1, MSG => 'search_no_input') );
}
$search_string = strtolower( str_replace( "*" , "%", $ibforums->input['search_q'] ) );
$search_string = preg_replace( "/[<>\!\@£\$\^&\+\=\=\[\]\{\}\(\)\"':;\.,\/]/", "", $search_string );
$seen = array();
$this->output = $this->html->start( $ibforums->lang['search_results'], $ibforums->lang['results_txt'], $ibforums->lang['search_results'] );
$DB->query("SELECT id, title from ibf_faq WHERE LOWER(title) LIKE '%$search_string%' or LOWER(text) LIKE '%$search_string%' ORDER BY title ASC");
$cnt = 0;
while ($row = $DB->fetch_row() ) {
if (isset($seen[ $row['title'] ]) ) {
continue;
} else {
$seen[ $row['title'] ] = 1;
}
$row['CELL_COLOUR'] = $cnt % 2 ? 'row1' : 'row2';
$cnt++;
$this->output .= $this->html->row($row);
}
if ($cnt == 0) {
$this->output .= $this->html->no_results();
}
$this->output .= $this->html->end();
$this->page_title = $ibforums->lang['page_title'];
$this->nav = array( "<a href='{$this->base_url}&act=Help'>{$ibforums->lang['help_topics']}</a>", $ibforums->lang['results_title'] );
}
}
?>
+427
View File
@@ -0,0 +1,427 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Log in / log out module
| > Module written by Matt Mecham
| > Date started: 14th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new Login;
class Login {
var $output = "";
var $page_title = "";
var $nav = array();
var $login_html = "";
function Login() {
global $ibforums, $DB, $std, $print;
// Make sure our code number is numerical only
//$ibforums->input['CODE'] = preg_replace("/^([0-9]+)$/", "$1", $ibforums->input[CODE]);
// Require the HTML and language modules
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_login', $ibforums->lang_id);
require "./Skin/".$ibforums->skin_id."/skin_login.php";
$this->login_html = new skin_login();
// Are we enforcing log ins?
if ($ibforums->vars['force_login'] == 1)
{
$msg = 'admin_force_log_in';
}
else
{
$msg = "";
}
// What to do?
switch($ibforums->input['CODE']) {
case '01':
$this->do_log_in();
break;
case '02':
$this->log_in_form();
break;
case '03':
$this->do_log_out();
break;
case '04':
$this->markforum();
break;
case '05':
$this->markboard();
break;
case '06':
$this->delete_cookies();
break;
default:
$this->log_in_form($msg);
break;
}
// If we have any HTML to print, do so...
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
}
function delete_cookies()
{
global $ibforums, $DB, $std, $HTTP_COOKIE_VARS;
if (is_array($HTTP_COOKIE_VARS))
{
foreach( $HTTP_COOKIE_VARS as $cookie => $value)
{
if (preg_match( "/^(".$ibforums->vars['cookie_id']."fread.*$)/", $cookie, $match))
{
$std->my_setcookie( str_replace( $ibforums->vars['cookie_id'], "", $match[0] ) , '-1', -1 );
}
if (preg_match( "/^(".$ibforums->vars['cookie_id']."ibforum.*$)/i", $cookie, $match))
{
$std->my_setcookie( str_replace( $ibforums->vars['cookie_id'], "", $match[0] ) , '-', -1 );
}
}
}
$std->my_setcookie('pass_hash' , '-1');
$std->my_setcookie('member_id' , '-1');
$std->my_setcookie('session_id', '-1');
$std->my_setcookie('topicsread', '-1');
$std->my_setcookie('anonlogin' , '-1');
$std->boink_it($ibforums->base_url);
exit();
}
function markboard()
{
global $ibforums, $DB, $std;
if(! $ibforums->member['id'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_guests') );
}
$DB->query("UPDATE ibf_members SET last_visit='".time()."', last_activity='".time()."' WHERE id='".$ibforums->member['id']."'");
$std->boink_it($ibforums->base_url);
exit();
}
function markforum() {
global $ibforums, $DB, $std;
$ibforums->input['f'] = preg_replace( "/^(\d+)$/", "\\1", $ibforums->input['f'] );
if ($ibforums->input['f'] == "")
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files' ) );
}
$std->my_setcookie( "fread_".$ibforums->input['f'], time() );
$std->boink_it($ibforums->base_url);
exit();
}
function log_in_form($message="") {
global $ibforums, $DB, $std, $print, $HTTP_REFERER;
//+--------------------------------------------
//| Are they banned?
//+--------------------------------------------
if ($ibforums->vars['ban_ip'])
{
$ips = explode( "|", $ibforums->vars['ban_ip'] );
foreach ($ips as $ip)
{
$ip = preg_replace( "/\*/", '.*' , $ip );
if (preg_match( "/$ip/", $ibforums->input['IP_ADDRESS'] ))
{
$std->Error( array( LEVEL => 1, MSG => 'you_are_banned' ) );
}
}
}
//+--------------------------------------------
if ($message != "")
{
$message = $ibforums->lang[ $message ];
$message = preg_replace( "/<#NAME#>/", "<b>{$ibforums->input[UserName]}</b>", $message );
$this->output .= $this->login_html->errors($message);
}
$this->login_html->IN[REFERER] = $HTTP_REFERER;
$this->output .= $this->login_html->ShowForm( $ibforums->lang['please_log_in'] );
$this->nav = array( $ibforums->lang['log_in'] );
$this->page_title = $ibforums->lang['log_in'];
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
exit();
}
function do_log_in() {
global $DB, $ibforums, $std, $print, $sess, $HTTP_USER_AGENT, $HTTP_POST_VARS;
$url = "";
//-------------------------------------------------
// Make sure the username and password were entered
//-------------------------------------------------
if ($HTTP_POST_VARS['UserName'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_username' ) );
}
if ($HTTP_POST_VARS['PassWord'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'pass_blank' ) );
}
//-------------------------------------------------
// Check for input length
//-------------------------------------------------
if (strlen($ibforums->input['UserName']) > 32)
{
$std->Error( array( LEVEL => 1, MSG => 'username_long' ) );
}
if (strlen($ibforums->input['PassWord']) > 32)
{
$std->Error( array( LEVEL => 1, MSG => 'pass_too_long' ) );
}
$username = strtolower($ibforums->input['UserName']);
$password = md5( $ibforums->input['PassWord'] );
//-------------------------------------------------
// Attempt to get the user details
//-------------------------------------------------
$DB->query("SELECT id, name, mgroup, password, new_pass FROM ibf_members WHERE LOWER(name)='$username'");
if ($DB->get_num_rows())
{
$member = $DB->fetch_row();
if ( empty($member['id']) or ($member['id'] == "") )
{
$this->log_in_form( 'wrong_name' );
}
if ($member['password'] != $password)
{
$this->log_in_form( 'wrong_pass' );
}
//------------------------------
if ($ibforums->input['CookieDate'])
{
$std->my_setcookie("member_id" , $member['id'], 1);
$std->my_setcookie("pass_hash" , $password, 1);
}
//------------------------------
if ($ibforums->input['s'])
{
$session_id = $ibforums->input['s'];
// Delete any old sessions with this users IP addy that doesn't match our
// session ID.
$DB->query("DELETE FROM ibf_sessions WHERE ip_address='".$ibforums->input['IP_ADDRESS']."' AND id <> '$session_id'");
$db_string = $DB->compile_db_update_string( array (
'member_name' => $member['name'],
'member_pass' => "",
'member_id' => $member['id'],
'running_time' => time(),
'member_group' => $member['mgroup'],
'login_type' => $ibforums->input['Privacy'] ? 1 : 0
) );
$db_query = "UPDATE ibf_sessions SET $db_string WHERE id='".$ibforums->input['s']."'";
}
else
{
$session_id = md5( uniqid(microtime()) );
// Delete any old sessions with this users IP addy.
$DB->query("DELETE FROM ibf_sessions WHERE ip_address='".$ibforums->input['IP_ADDRESS']."'");
$db_string = $DB->compile_db_insert_string( array (
'id' => $session_id,
'member_name' => $member['name'],
'member_pass' => "",
'member_id' => $member['id'],
'running_time' => time(),
'member_group' => $member['mgroup'],
'ip_address' => substr($ibforums->input['IP_ADDRESS'], 0, 50),
'browser' => substr($HTTP_USER_AGENT, 0, 50),
'start_session'=> time(),
'login_type' => $ibforums->input['Privacy'] ? 1 : 0
) );
$db_query = "INSERT INTO ibf_sessions (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")";
}
$DB->query( $db_query );
//-----------------------------------
// If a bogus reset passy action occured,
// and we managed to log in, we'll assume
// that the user did nothing, so we remove
// this new pass setting.
//-----------------------------------
if ($member['new_pass'] != "")
{
$DB->query("UPDATE ibf_members SET new_pass='' WHERE id='".$member['id']."'");
}
$ibforums->member = $member;
$ibforums->session_id = $session_id;
if ($ibforums->input['referer'] && ($ibforums->input['act'] != 'Reg'))
{
$url = $ibforums->input['referer'];
$url = preg_replace( "!^\?!" , "" , $url );
$url = preg_replace( "!s=(\w){32}!", "" , $url );
$url = preg_replace( "!act=(login|reg|lostpass)!i", "", $url );
}
//-----------------------------------
// set our privacy cookie
//-----------------------------------
if ($ibforums->input['Privacy'] == 1)
{
$std->my_setcookie( "anonlogin", 1 );
}
//-----------------------------------
// Redirect them to either the board
// index, or where they came from
//-----------------------------------
$print->redirect_screen( "{$ibforums->lang[thanks_for_login]} {$ibforums->member['name']}", $url );
}
else
{
$this->log_in_form( 'wrong_name' );
}
}
function do_log_out() {
global $std, $ibforums, $DB, $print, $sess, $HTTP_COOKIE_VARS;
/*if(! $ibforums->member['id'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_guests') );
}*/
// Update the DB
$DB->query("UPDATE ibf_sessions SET ".
"member_name='',".
"member_id='0',".
"member_pass='',".
"login_type='0' ".
"WHERE id='". $sess->session_id ."'");
$DB->query("UPDATE ibf_members SET last_visit='".time()."', last_activity='".time()."' WHERE id='".$ibforums->member['id']."'");
// Set some cookies
$std->my_setcookie( "member_id" , "0" );
$std->my_setcookie( "pass_hash" , "0" );
$std->my_setcookie( "anonlogin" , "-1" );
if (is_array($HTTP_COOKIE_VARS))
{
foreach( $HTTP_COOKIE_VARS as $cookie => $value )
{
if (preg_match( "/^(".$ibforums->vars['cookie_id']."fread.*$)/", $cookie, $match))
{
$std->my_setcookie( str_replace( $ibforums->vars['cookie_id'], "", $match[0] ) , '-1', -1 );
}
if (preg_match( "/^(".$ibforums->vars['cookie_id']."ibforum.*$)/i", $cookie, $match))
{
$std->my_setcookie( str_replace( $ibforums->vars['cookie_id'], "", $match[0] ) , '-', -1 );
}
}
}
// Redirect...
$print->redirect_screen( $ibforums->lang['thanks_for_logout'], "" );
}
}
?>
+290
View File
@@ -0,0 +1,290 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Show all the members
| > Module written by Matt Mecham
| > Date started: 20th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new Memberlist;
class Memberlist {
var $output = "";
var $page_title = "";
var $nav = array();
var $html = "";
var $base_url = "";
var $first = 0;
var $max_results = 10;
var $sort_key = 'name';
var $sort_order = 'asc';
var $filter = 'ALL';
var $mem_titles = array();
var $mem_groups = array();
function Memberlist() {
global $ibforums, $DB, $std, $print;
if ($ibforums->input['CODE'] == "") $ibforums->input['CODE'] = 'listall';
//--------------------------------------------
// Require the HTML and language modules
//--------------------------------------------
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_mlist', $ibforums->lang_id );
require "./Skin/".$ibforums->skin_id."/skin_mlist.php";
$this->html = new skin_mlist();
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
if ($ibforums->member['g_mem_info'] != 1)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission' ) );
}
//--------------------------------------------
// Get the member groups, member titles stuff
//--------------------------------------------
$DB->query("SELECT g_title, g_id, g_icon from ibf_groups ORDER BY g_title");
while ($row = $DB->fetch_row() )
{
$this->mem_groups[ $row['g_id'] ] = array( 'TITLE' => $row['g_title'],
'ICON' => $row['g_icon'],
);
}
unset($row);
$DB->free_result();
$DB->query("SELECT title, id, posts, pips from ibf_titles ORDER BY posts DESC");
while ($row = $DB->fetch_row() )
{
$this->mem_titles[ $row['id'] ] = array( 'TITLE' => $row['title'],
'POSTS' => $row['posts'],
'PIPS' => $row['pips'],
);
}
unset($row);
$DB->free_result();
$the_filter = array( 'ALL' => $ibforums->lang['show_all'] );
foreach($this->mem_groups as $id => $data)
{
if ($id == $ibforums->vars['guest_group']) continue;
if ($id == $ibforums->vars['auth_group']) continue;
if ($id == $ibforums->vars['ban_group']) continue;
$the_filter[$id] = $data['TITLE'];
}
if (isset($ibforums->input['st'])) $this->first = $ibforums->input['st'];
if (isset($ibforums->input['max_results'])) $this->max_results = $ibforums->input['max_results'];
if (isset($ibforums->input['sort_key'])) $this->sort_key = $ibforums->input['sort_key'];
if (isset($ibforums->input['sort_order'])) $this->sort_order = $ibforums->input['sort_order'];
if (isset($ibforums->input['filter'])) $this->filter = $ibforums->input['filter'];
$the_sort_key = array( 'name' => 'sort_by_name',
'posts' => 'sort_by_posts',
'joined' => 'sort_by_joined',
);
$the_max_results = array( 10 => '10',
20 => '20',
30 => '30',
40 => '40',
50 => '50',
);
$the_sort_order = array( 'desc' => 'descending_order',
'asc' => 'ascending_order',
);
$filter_html = "<select name='filter' class='forminput'>\n";
$sort_key_html = "<select name='sort_key' class='forminput'>\n";
$max_results_html = "<select name='max_results' class='forminput'>\n";
$sort_order_html = "<select name='sort_order' class='forminput'>\n";
foreach ($the_sort_order as $k => $v) {
$sort_order_html .= $k == $this->sort_order ? "<option value='$k' selected>" . $ibforums->lang[ $the_sort_order[ $k ] ] . "\n"
: "<option value='$k'>" . $ibforums->lang[ $the_sort_order[ $k ] ] . "\n";
}
foreach ($the_filter as $k => $v) {
$filter_html .= $k == $this->filter ? "<option value='$k' selected>" . $the_filter[ $k ] . "\n"
: "<option value='$k'>" . $the_filter[ $k ] . "\n";
}
foreach ($the_sort_key as $k => $v) {
$sort_key_html .= $k == $this->sort_key ? "<option value='$k' selected>" . $ibforums->lang[ $the_sort_key[ $k ] ] . "\n"
: "<option value='$k'>" . $ibforums->lang[ $the_sort_key[ $k ] ] . "\n";
}
foreach ($the_max_results as $k => $v) {
$max_results_html .= $k == $this->max_results ? "<option value='$k' selected>". $the_max_results[ $k ] . "\n"
: "<option value='$k'>" . $the_max_results[ $k ] . "\n";
}
$ibforums->lang['sorting_text'] = preg_replace( "/<#FILTER#>/" , $filter_html."</select>" , $ibforums->lang['sorting_text'] );
$ibforums->lang['sorting_text'] = preg_replace( "/<#SORT_KEY#>/" , $sort_key_html."</select>" , $ibforums->lang['sorting_text'] );
$ibforums->lang['sorting_text'] = preg_replace( "/<#SORT_ORDER#>/" , $sort_order_html."</select>" , $ibforums->lang['sorting_text'] );
$ibforums->lang['sorting_text'] = preg_replace( "/<#MAX_RESULTS#>/" , $max_results_html."</select>", $ibforums->lang['sorting_text'] );
$error = 0;
if (! isset($the_sort_key[ $this->sort_key ]) ) $error = 1;
if (! isset($the_sort_order[ $this->sort_order ]) ) $error = 1;
if (! isset($the_filter[ $this->filter ]) ) $error = 1;
if (! isset($the_max_results[ $this->max_results ]) ) $error = 1;
if ($error == 1 )
{
$std->Error( array( LEVEL=> 5, MSG =>'incorrect_use') );
}
//---------------------------------------------
// Find out how many members match our criteria
//---------------------------------------------
$q_extra = $this->filter == 'ALL' ? '' : " and mgroup='".$this->filter."' ";
$DB->query("SELECT COUNT(id) as total_members FROM ibf_members WHERE id > 0".$q_extra);
$max = $DB->fetch_row();
$DB->free_result();
$links = $std->build_pagelinks( array( 'TOTAL_POSS' => $max['total_members'],
'PER_PAGE' => $this->max_results,
'CUR_ST_VAL' => $this->first,
'L_SINGLE' => "",
'L_MULTI' => $ibforums->lang['pages'],
'BASE_URL' => $this->base_url."&act=Members&max_results={$this->max_results}&filter={$this->filter}&sort_order={$this->sort_order}&sort_key={$this->sort_key}"
)
);
$this->output = $this->html->start();
$this->output .= $this->html->Page_header( array( 'SHOW_PAGES' => $links) );
//-----------------------------
// START THE LISTING
//-----------------------------
$DB->query("SELECT name, id, posts, joined, mgroup, email,title, hide_email, location, aim_name, icq_number "
."FROM ibf_members WHERE id > 0".$q_extra." ORDER BY ".$this->sort_key." ".$this->sort_order." LIMIT ".$this->first.",".$this->max_results);
while($member = $DB->fetch_row() )
{
$pips = 0;
foreach($this->mem_titles as $k => $v)
{
if ($member['posts'] >= $v['POSTS']) {
if (!$member['title'])
{
$member['title'] = $this->mem_titles[ $k ]['TITLE'];
}
$pips = $v['PIPS'];
break;
}
}
if ($this->mem_groups[ $member['mgroup'] ]['ICON'])
{
$member[MEMBER_PIPS_IMG] = "<img src='{$ibforums->vars[TEAM_ICON_URL]}/{$this->mem_groups[ $member['mgroup'] ][ICON]}' border='0'>";
}
else
{
if ($pips)
{
if (preg_match( "/^\d+$/", $pips ) )
{
for ($i = 1; $i <= $pips; ++$i)
{
$member['MEMBER_PIPS_IMG'] .= $ibforums->skin['A_STAR'];
}
}
else
{
$member['MEMBER_PIPS_IMG'] = "<img src='{$ibforums->vars[TEAM_ICON_URL]}/$pips' border='0'>";
}
}
}
$member['MEMBER_JOINED'] = $std->get_date( $member['joined'], 'JOINED' );
$member['MEMBER_GROUP'] = $this->mem_groups[ $member['mgroup'] ]['TITLE'];
if (!$member['hide_email']) {
$member['MEMBER_EMAIL'] = "<a href='{$this->base_url}&act=Mail&CODE=00&MID={$member['id']}'>{$ibforums->skin[P_EMAIL]}</a>&nbsp;";
} else {
$member['MEMBER_EMAIL'] = '&nbsp;';
}
if ($member['icq_number']) {
$member['ICQNUMBER'] = "<a href=\"javascript:PopUp('{$this->base_url}&act=ICQ&MID={$member['id']}','Pager','450','330','0','1','1','1')\">{$ibforums->skin[P_ICQ]}</a>&nbsp;";
} else {
$member['ICQNUMBER'] = '&nbsp;';
}
if ($member['aim_name']) {
$member[AOLNAME] = "<a href=\"javascript:PopUp('{$this->base_url}&act=AOL&MID={$member['id']}','Pager','450','330','0','1','1','1')\">{$ibforums->skin[P_AOL]}</a>&nbsp;";
} else {
$member['AOLNAME'] = '&nbsp;';
}
$member['password'] = "";
$member['MEMBER_NAME'] = $member['name'];
$member['MEMBER_POSTS'] = $member['posts'];
$member['MEMBER_ID'] = $member['id'];
$this->output .= $this->html->show_row($member);
}
$this->output .= $this->html->Page_end();
$this->output .= $this->html->end( array( 'SHOW_PAGES' => $links) );
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $ibforums->lang['page_title'], 'JS' => 0, NAV => array( $ibforums->lang['page_title'] ) ) );
}
}
?>
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+281
View File
@@ -0,0 +1,281 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Show online users
| > Module written by Matt Mecham
| > Date started: 12th March 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new Online;
class Online {
var $output = "";
var $page_title = "";
var $nav = array();
var $html = "";
var $first = 0;
var $perpage = 25;
var $forums = array();
var $cats = array();
var $sessions = array();
var $where = array();
var $seen_name = array();
function Online() {
global $ibforums, $DB, $std, $print;
if ($ibforums->input['CODE'] == "") $ibforums->input['CODE'] = 'listall';
//--------------------------------------------
// Require the HTML and language modules
//--------------------------------------------
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_online', $ibforums->lang_id);
require "./Skin/".$ibforums->skin_id."/skin_online.php";
$this->html = new skin_online();
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
//--------------------------------------------
// Build up our language hash
//--------------------------------------------
foreach ($ibforums->lang as $k => $v) {
if ( preg_match( "/^WHERE_(\w+)$/", $k, $match ) ) {
$this->where[ $match[1] ] = $ibforums->lang[$k];
}
}
unset($match);
//--------------------------------------------
// What to do?
//--------------------------------------------
switch($ibforums->input['CODE']) {
case 'listall':
$this->list_all();
break;
case '02':
$this->list_forum();
break;
default:
$this->list_all();
break;
}
// If we have any HTML to print, do so...
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
}
/*****************************************************/
// list_all
// ------------------
// List all online users
/*****************************************************/
function list_all() {
global $ibforums, $DB, $std;
$this->first = 0;
if (!empty($ibforums->input['st']))
{
$this->first = $ibforums->input['st'];
}
$last_cat_id = -1;
$DB->query("SELECT f.id, f.name, f.read_perms, f.password, c.id as cat_id, c.name as cat_name from ibf_forums f, ibf_categories c where c.id=f.category ORDER BY c.position, f.position");
while ( $i = $DB->fetch_row() )
{
if ($last_cat_id != $i['cat_id'])
{
// Print the category
$last_cat_id = $i['cat_id'];
$this->cats[ $i['cat_id'] ] = $this->cats['cat_name'];
}
$this->forums[ $i['id'] ] = array( 'name' => $i['name'],
'read_perms' => $i['read_perms'],
'password' => $i['password'],
);
}
$DB->free_result();
$t_time = time() - 900;
$DB->query("SELECT COUNT(id) as total_sessions FROM ibf_sessions WHERE login_type <> 1 AND running_time > $t_time");
$max = $DB->fetch_row();
$DB->free_result();
$links = $std->build_pagelinks( array( 'TOTAL_POSS' => $max['total_sessions'],
'PER_PAGE' => 25,
'CUR_ST_VAL' => $this->first,
'L_SINGLE' => "",
'L_MULTI' => $ibforums->lang['pages'],
'BASE_URL' => $this->base_url."&act=Online&CODE=listall"
)
);
$this->output = $this->html->Page_header($links);
// Grab all the current sessions.
$DB->query("SELECT s.id, s.member_name, s.member_id, s.running_time, s.location, s.member_group, g.prefix, g.suffix FROM ibf_sessions s, ibf_groups g WHERE login_type <> 1 AND running_time > $t_time AND s.member_group=g.g_id ORDER BY running_time DESC LIMIT ".$this->first.",25");
while( $sess = $DB->fetch_row() ) {
//----------------------------------------------------
// Is this a member, and have we seen them before?
// Proxy servers, etc can confuse the session handler,
// creating duplicate session IDs for the same user when
// their IP address changes.
//----------------------------------------------------
if (! empty($sess['member_name']) )
{
if (isset($this->seen_name[ $sess['member_name'] ]) )
{
continue;
}
else
{
$this->seen_name[ $sess['member_name'] ] = 1;
}
}
if (isset($sess['location']))
{
$line = "";
list($act, $fid, $tid, $pid) = explode( ",", $sess['location'] );
if (isset($act))
{
$line = isset($this->where[ $act ]) ? $this->where[ $act ] : $ibforums->lang['board_index'];
}
if ($fid != "")
{
$pass = 0;
if ($this->forums[ $fid ]['read_perms'] == '*')
{
$pass = 1;
}
else if (preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|$)/", $this->forums[ $fid ]['read_perms']) )
{
$pass = 1;
}
if ($pass == 1)
{
if ($tid != "")
{
$line .= " <a href='{$this->base_url}&act=ST&f=$fid&t=$tid'>{$this->forums[ $fid ]['name']}</a>";
}
else
{
$line .= " <a href='{$this->base_url}&act=SF&f=$fid'>{$this->forums[ $fid ]['name']}</a>";
}
}
else
{
$line .= " ".$ibforums->lang['n_a'];
}
}
}
else
{
$line .= " <a href='{$this->base_url}'>{$ibforums->lang['board_index']}</a>";
}
$sess['where_line'] = $line;
if (isset($sess['member_id']))
{
$sess['member_name'] = "<a href='{$this->base_url}&act=Profile&CODE=03&MID={$sess['member_id']}'>{$sess['prefix']}{$sess['member_name']}{$sess['suffix']}</a>";
}
$sess['running_time'] = $std->get_date( $sess['running_time'], 'LONG' );
$this->output .= $this->do_html_row($sess);
}
$this->output .= $this->html->Page_end($links);
$this->page_title = $ibforums->lang['page_title'];
$this->nav = array( $ibforums->lang['page_title']);
}
function do_html_row($sess) {
global $ibforums;
if ($sess['member_name'] and $sess['member_id'])
{
$sess['msg_icon'] = "<a href='{$this->base_url}&act=Msg&CODE=04&MID={$sess['member_id']}'>{$ibforums->skin['P_MSG']}</a>";
}
else
{
$sess['member_name'] = $sess['prefix'].$ibforums->lang['guest'].$sess['suffix'];
$sess['msg_icon'] = '&nbsp;';
}
return $this->html->show_row($sess);
}
function list_forum() { }
}
?>
+930
View File
@@ -0,0 +1,930 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Post core module
| > Module written by Matt Mecham
| > Date started: 14th February 2002
|
| > Module Version 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new Post;
class Post {
var $output = "";
var $base_url = "";
var $html = "";
var $parser = "";
var $moderator = array();
var $forum = array();
var $topic = array();
var $category = array();
var $mem_groups = array();
var $mem_titles = array();
var $obj = array();
var $email = "";
/***********************************************************************************/
//
// Our constructor, load words, load skin, print the topic listing
//
/***********************************************************************************/
function Post() {
global $ibforums, $DB, $std, $print, $skin_universal;
require "./Skin/".$ibforums->skin_id."/skin_post.php";
require "./sources/lib/post_parser.php";
$this->parser = new post_parser(1);
//--------------------------------------
// Compile the language file
//--------------------------------------
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_post', $ibforums->lang_id);
$this->html = new skin_post();
//--------------------------------------
// Check the input
//--------------------------------------
if ($ibforums->input['t'])
{
$ibforums->input['t'] = $std->is_number($ibforums->input['t']);
if (! $ibforums->input['t'] )
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
}
if ($ibforums->input['p'])
{
$ibforums->input['p'] = $std->is_number($ibforums->input['p']);
if (! $ibforums->input['p'] )
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
}
$ibforums->input['f'] = $std->is_number($ibforums->input['f']);
if (! $ibforums->input['f'] )
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
$ibforums->input['st'] = $ibforums->input['st'] ? $std->is_number($ibforums->input['st']) : 0;
// Did the user press the "preview" button?
$this->obj['preview_post'] = $ibforums->input['preview'];
//--------------------------------------
// Get the forum info based on the forum ID, get the category name, ID, and get the topic details
//--------------------------------------
$DB->query("SELECT f.*, c.id as cat_id, c.name as cat_name from ibf_forums f, ibf_categories c WHERE f.id=".$ibforums->input[f]." and c.id=f.category");
$this->forum = $DB->fetch_row();
if ($this->forum['read_perms'] != '*')
{
if (! preg_match("/(^|,)".$ibforums->member['mgroup']."(,|$)/", $this->forum['read_perms'] ) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_view_topic') );
}
}
// Is this forum switched off?
if ( ! $this->forum['status'] )
{
$std->Error( array( LEVEL => 1, MSG => 'forum_read_only') );
}
//--------------------------------------
// Is this a password protected forum?
//--------------------------------------
$pass = 0;
if ($this->forum['password'] != "")
{
if ( ! $c_pass = $std->my_getcookie('iBForum'.$this->forum['id']) )
{
$pass = 0;
}
if ( $c_pass == $this->forum['password'] )
{
$pass = 1;
}
else
{
$pass = 0;
}
}
else
{
$pass = 1;
}
if ($pass == 0)
{
$std->Error( array( LEVEL => 1, MSG => 'no_view_topic') );
}
//--------------------------------------
if ($this->forum['parent_id'] > 0)
{
$DB->query("SELECT f.id as forum_id, f.name as forum_name, c.id, c.name FROM ibf_forums f, ibf_categories c WHERE f.id='".$this->forum['parent_id']."' AND c.id=f.category");
$row = $DB->fetch_row();
$this->forum['cat_id'] = $row['id'];
$this->forum['cat_name'] = $row['name'];
}
//--------------------------------------
// Error out if we can not find the forum
//--------------------------------------
if (!$this->forum['id'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
//--------------------------------------
// Is this forum moderated?
//--------------------------------------
$this->obj['moderate'] = $this->forum['preview_posts'] ? 1 : 0;
// Can we bypass it?
if ($ibforums->member['g_avoid_q'])
{
$this->obj['moderate'] = 0;
}
//--------------------------------------
// Are we allowed to post at all?
//--------------------------------------
if ($ibforums->member['id'])
{
if (!$ibforums->member['allow_post'])
{
$std->Error( array( LEVEL => 1, MSG => 'posting_off') );
}
// Flood check..
if ( $ibforums->input['CODE'] != "08" and $ibforums->input['CODE'] != "09" )
{
if ( $ibforums->vars['flood_control'] > 0 )
{
if ($ibforums->member['g_avoid_flood'] != 1)
{
if ( time() - $ibforums->member['last_post'] < $ibforums->vars['flood_control'] )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'flood_control' , 'EXTRA' => $ibforums->vars['flood_control'] ) );
}
}
}
}
}
if ($ibforums->member['id'] != 0 and $ibforums->member['g_is_supmod'] == 0)
{
$DB->query("SELECT * from ibf_moderators WHERE member_id='".$ibforums->member['id']."' AND forum_id='".$this->forum['id']."'");
$this->moderator = $DB->fetch_row();
}
//--------------------------------------
// Convert the code ID's into something
// use mere mortals can understand....
//--------------------------------------
$this->obj['action_codes'] = array ( '00' => array( '0' , 'new_post' ),
'01' => array( '1' , 'new_post' ),
'02' => array( '0' , 'reply_post' ),
'03' => array( '1' , 'reply_post' ),
'06' => array( '0' , 'q_reply_post' ),
'07' => array( '1' , 'q_reply_post' ),
'08' => array( '0' , 'edit_post' ),
'09' => array( '1' , 'edit_post' ),
'10' => array( '0' , 'poll' ),
'11' => array( '1' , 'poll' ),
);
// Make sure our input CODE element is legal.
if (! isset($this->obj['action_codes'][ $ibforums->input['CODE'] ]) )
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
// Require and run our associated library file for this action.
// this imports an extended class for this Post class.
require "./sources/lib/post_" . $this->obj['action_codes'][ $ibforums->input['CODE'] ][1] . ".php";
$post_functions = new post_functions(&$this);
// If the first CODE array bit is set to "0" - show the relevant form.
// If it's set to "1" process the input.
// We pass a reference to this classes object so we can manipulate this classes
// data from our sub class.
if ($this->obj['action_codes'][ $ibforums->input['CODE'] ][0])
{
// Make sure we have a "Guest" Name..
if (!$ibforums->member['id'])
{
$ibforums->input['UserName'] = trim($ibforums->input['UserName']);
$ibforums->input['UserName'] = str_replace( "<br>", "", $ibforums->input['UserName']);
$ibforums->input['UserName'] = $ibforums->input['UserName'] ? $ibforums->input['UserName'] : 'Guest';
if ($ibforums->input['UserName'] != 'Guest')
{
$DB->query("SELECT id FROM ibf_members WHERE LOWER(name)='".trim(strtolower($ibforums->input['UserName']))."'");
if ( $DB->get_num_rows() )
{
$ibforums->input['UserName'] = $ibforums->vars['guest_name_pre'].$ibforums->input['UserName'].$ibforums->vars['guest_name_suf'];
}
}
}
//-------------------------------------------------------------------------
// Stop the user hitting the submit button in the hope that multiple topics
// or replies will be added. Or if the user accidently hits the button
// twice.
//-------------------------------------------------------------------------
if ( $this->obj['preview_post'] == "" )
{
if ( preg_match( "/Post,.*,(01|03|07|11)$/", $ibforums->location ) )
{
if ( time() - $ibforums->lastclick < 2 )
{
if ( $ibforums->input['CODE'] == '01' or $ibforums->input['CODE'] == '11' )
{
// Redirect to the newest topic in the forum
$DB->query("SELECT tid from ibf_topics WHERE forum_id='".$this->forum['id']."' AND approved=1 "
."ORDER BY last_post DESC LIMIT 0,1");
$topic = $DB->fetch_row();
$std->boink_it($ibforums->base_url."&act=ST&f=".$this->forum['id']."&t=".$topic['tid']);
exit();
}
else
{
// It's a reply, so simply show the topic...
$std->boink_it($ibforums->base_url."&act=ST&f=".$this->forum['id']."&t=".$ibforums->input['t']."&view=getlastpost");
exit();
}
}
}
}
//----------------------------------
$post_functions->process(&$this);
}
else
{
$post_functions->show_form(&$this);
}
}
/*****************************************************/
// topic tracker
// ------------------
// Checks and sends out the emails as needed.
/*****************************************************/
function topic_tracker($tid="", $post="", $poster="")
{
global $ibforums, $DB, $std;
require "./sources/lib/emailer.php";
$this->email = new emailer();
//--------------------------
if ($tid == "")
{
return TRUE;
}
// Configure the date
$getdate = time() - (60*60*24);
// Get the email addy's, topic ids and email_full stuff - oh yeah.
$DB->query("SELECT tr.trid, tr.topic_id, m.name, m.email, m.id, m.email_full, m.language, t.title, t.forum_id FROM ibf_tracker tr, ibf_topics t,ibf_members m WHERE tr.topic_id='$tid' AND tr.member_id=m.id AND t.tid=tr.topic_id AND (tr.last_sent < '$getdate' or tr.last_sent=0)");
if ( $DB->get_num_rows() )
{
$trids = array();
while ( $r = $DB->fetch_row() )
{
$r['language'] = $r['language'] ? $r['language'] : 'en';
// We don't want to be notified of our own posts, so..
if ($r['id'] == $ibforums->member['id'])
{
continue;
}
//-----------------------------------------------------
if ($r['email_full'] == 1)
{
$this->email->get_template("subs_with_post", $r['language']);
$this->email->build_message( array(
'TOPIC_ID' => $r['topic_id'],
'FORUM_ID' => $r['forum_id'],
'TITLE' => $r['title'],
'NAME' => $r['name'],
'POSTER' => $poster,
'POST' => $post,
)
);
$this->email->subject = $ibforums->lang['tt_subject'];
$this->email->to = $r['email'];
$this->email->send_mail();
}
else
{
$this->email->get_template("subs_no_post", $r['language']);
$this->email->build_message( array(
'TOPIC_ID' => $r['topic_id'],
'FORUM_ID' => $r['forum_id'],
'TITLE' => $r['title'],
'NAME' => $r['name'],
'POSTER' => $poster,
)
);
$this->email->subject = $ibforums->lang['tt_subject'];
$this->email->to = $r['email'];
$this->email->send_mail();
}
$trids[] = $r['trid'];
}
// Update the DB wid' da new time, innit.
$trid_string = implode( ",", $trids );
if ( count($trids) > 0 )
{
$DB->query("UPDATE ibf_tracker SET last_sent='".time()."' WHERE trid IN(".$trid_string.")");
}
}
return TRUE;
}
/*****************************************************/
// compile post
// ------------------
// Compiles all the incoming information into an array
// which is returned to the accessor
/*****************************************************/
function compile_post() {
global $ibforums, $std, $REQUEST_METHOD, $HTTP_POST_VARS;
$ibforums->vars['max_post_length'] = $ibforums->vars['max_post_length'] ? $ibforums->vars['max_post_length'] : 2140000;
// sort out some of the form data, check for posting length, etc.
// THIS MUST BE CALLED BEFORE CHECKING ATTACHMENTS
$ibforums->input['enablesig'] = $ibforums->input['enablesig'] == 'yes' ? 1 : 0;
$ibforums->input['enableemo'] = $ibforums->input['enableemo'] == 'yes' ? 1 : 0;
// Do we have a valid post?
if (strlen( trim($HTTP_POST_VARS['Post']) ) < 1) {
$std->Error( array( LEVEL => 1, MSG => 'no_post') );
}
if (strlen( $HTTP_POST_VARS['Post'] ) > ($ibforums->vars['max_post_length']*1024)) {
$std->Error( array( LEVEL => 1, MSG => 'post_too_long') );
}
$post = array(
'author_id' => $ibforums->member['id'] ? $ibforums->member['id'] : 0,
'use_sig' => $ibforums->input['enablesig'],
'use_emo' => $ibforums->input['enableemo'],
'ip_address' => $ibforums->input['IP_ADDRESS'],
'post_date' => time(),
'icon_id' => $ibforums->input['iconid'],
'post' => $this->parser->convert( array( TEXT => $ibforums->input['Post'],
SMILIES => $ibforums->input['enableemo'],
CODE => $this->forum['use_ibc'],
HTML => $this->forum['use_html']
)
),
'author_name' => $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'],
'forum_id' => $this->forum['id'],
'topic_id' => "",
'queued' => $this->obj['moderate'],
'attach_id' => "",
'attach_hits' => "",
'attach_type' => "",
);
// If we had any errors, parse them back to this class
// so we can track them later.
$this->obj['post_errors'] = $this->parser->error;
return $post;
}
/*****************************************************/
// process upload
// ------------------
// checks for an entry in the upload field, and uploads
// the file if it meets our criteria. This also inserts
// a new row into the attachments database if successful
/*****************************************************/
function process_upload() {
global $ibforums, $std, $HTTP_POST_FILES, $DB, $FILE_UPLOAD;
//-------------------------------------------------
// Set up some variables to stop carpals developing
//-------------------------------------------------
$FILE_NAME = $HTTP_POST_FILES['FILE_UPLOAD']['name'];
$FILE_SIZE = $HTTP_POST_FILES['FILE_UPLOAD']['size'];
$FILE_TYPE = $HTTP_POST_FILES['FILE_UPLOAD']['type'];
// Naughty Opera adds the filename on the end of the
// mime type - we don't want this.
$FILE_TYPE = preg_replace( "/^(.+?);.*$/", "\\1", $FILE_TYPE );
$attach_data = array( 'attach_id' => "",
'attach_hits' => "",
'attach_type' => "",
'attach_file' => "",
);
//-------------------------------------------------
// Return if we don't have a file to upload
//-------------------------------------------------
// Naughty Mozilla likes to use "none" to indicate an empty upload field.
// I love universal languages that aren't universal.
if ($HTTP_POST_FILES['FILE_UPLOAD']['name'] == "" or !$HTTP_POST_FILES['FILE_UPLOAD']['name'] or ($HTTP_POST_FILES['FILE_UPLOAD']['name'] == "none") ) return $attach_data;
//-------------------------------------------------
// Return empty handed if we don't have permission to use
// uploads
//-------------------------------------------------
if ( (!$this->forum['use_attach']) and ($ibforums->member['g_attach_max'] < 1) ) return $attach_data;
//-------------------------------------------------
// Load our mime types config file.
//-------------------------------------------------
require "./conf_mime_types.php";
//-------------------------------------------------
// Are we allowing this type of file?
//-------------------------------------------------
if ($mime_types[ $FILE_TYPE ][0] != 1)
{
$this->obj['post_errors'] = 'invalid_mime_type';
return $attach_data;
}
//-------------------------------------------------
// Check the file size
//-------------------------------------------------
if ($FILE_SIZE > ($ibforums->member['g_attach_max']*1024))
{
$std->Error( array( LEVEL => 1, MSG => 'upload_to_big') );
}
//-------------------------------------------------
// Make the uploaded file safe
//-------------------------------------------------
$FILE_NAME = preg_replace( "/[^\w\.]/", "_", $FILE_NAME );
$real_file_name = "post-".$this->forum['id']."-".time(); // Note the lack of extension!
if (preg_match( "/\.(cgi|pl|js|asp|php|html|htm|jsp|jar)/", $FILE_NAME ))
{
$FILE_TYPE = 'text/plain';
}
//-------------------------------------------------
// Add on the extension...
//-------------------------------------------------
$ext = '.ibf';
switch($FILE_TYPE)
{
case 'image/gif':
$ext = '.gif';
break;
case 'image/jpeg':
$ext = '.jpg';
break;
case 'image/pjpeg':
$ext = '.jpg';
break;
case 'image/x-png':
$ext = '.png';
break;
default:
$ext = '.ibf';
break;
}
$real_file_name .= $ext;
//-------------------------------------------------
// If we are previewing the post, we don't want to
// add the attachment to the database, so we return
// the array with the filename. We would have returned
// earlier if there was an error
//-------------------------------------------------
if ($this->obj['preview_post'])
{
return array( 'FILE_NAME' => $FILE_NAME );
}
//-------------------------------------------------
// Copy the upload to the uploads directory
//-------------------------------------------------
if (! @move_uploaded_file( $HTTP_POST_FILES['FILE_UPLOAD']['tmp_name'], $ibforums->vars['upload_dir']."/".$real_file_name) )
{
$this->obj['post_errors'] = 'upload_failed';
return $attach_data;
}
//-------------------------------------------------
// set the array, and enter the info into the DB
// We don't have an extension on the file in the
// hope that it make it more difficult to execute
// a script on our server.
//-------------------------------------------------
$attach_data['attach_id'] = $real_file_name;
$attach_data['attach_hits'] = 0;
$attach_data['attach_type'] = $FILE_TYPE;
$attach_data['attach_file'] = $FILE_NAME;
return $attach_data;
}
/*****************************************************/
// check_upload_ability
// ------------------
// checks to make sure the requesting browser can accept
// file uploads, also checks if the member group can
// accept uploads and returns accordingly.
/*****************************************************/
function check_upload_ability() {
global $ibforums;
if ($this->forum['use_attach'] and $ibforums->member['g_attach_max'] > 0)
{
$this->obj['can_upload'] = 1;
$this->obj['form_extra'] = " enctype='multipart/form-data'";
$this->obj['hidden_field'] = "<input type='hidden' name='MAX_FILE_SIZE' value='".($ibforums->member['g_attach_max']*1024)."'>";
}
}
/*****************************************************/
// HTML: mod_options.
// ------------------
// Returns the HTML for the mod options drop down box
/*****************************************************/
function mod_options() {
global $ibforums, $DB;
$can_close = 0;
$can_pin = 0;
$html = "<select id='forminput' name='mod_options' class='forminput'>\n<option value='nowt'>".$ibforums->lang['mod_nowt']."</option>\n";
if ($ibforums->member['g_is_supmod'])
{
$can_close = 1;
$can_pin = 1;
}
else if ($ibforums->member['id'] != 0)
{
if ($this->moderator['mid'] != "" )
{
if ($this->moderator['close_topic'])
{
$can_close = 1;
}
if ($this->moderator['pin_topic'])
{
$can_pin = 1;
}
}
}
else
{
return "";
}
if ($can_pin == 0 and $can_close == 0)
{
return "";
}
if ($can_pin)
{
$html .= "<option value='pin'>".$ibforums->lang['mod_pin']."</option>";
}
if ($can_close)
{
$html .= "<option value='close'>".$ibforums->lang['mod_close']."</option>";
}
return $this->html->mod_options($html);
}
/*****************************************************/
// HTML: start form.
// ------------------
// Returns the HTML for the <FORM> opening tag
/*****************************************************/
function html_start_form($additional_tags=array()) {
global $ibforums;
$form = "<form action='{$this->base_url}' method='POST' name='REPLIER' onSubmit='return ValidateForm()'".$this->obj['form_extra'].">".
"<input type='hidden' name='st' value='".$ibforums->input[st]."'>".
"<input type='hidden' name='act' value='Post'>".
"<input type='hidden' name='s' value='".$ibforums->session_id."'>".
"<input type='hidden' name='f' value='".$this->forum['id']."'>".
$this->obj['hidden_field'];
// Any other tags to add?
if (isset($additional_tags)) {
foreach($additional_tags as $k => $v) {
$form .= "\n<input type='hidden' name='{$v[0]}' value='{$v[1]}'>";
}
}
return $form;
}
/*****************************************************/
// HTML: name fields.
// ------------------
// Returns the HTML for either text inputs or membername
// depending if the member is a guest.
/*****************************************************/
function html_name_field() {
global $ibforums;
return $ibforums->member['id'] ? $this->html->nameField_reg() : $this->html->nameField_unreg( $ibforums->input[UserName] );
}
/*****************************************************/
// HTML: Post body.
// ------------------
// Returns the HTML for post area, code buttons and
// post icons
/*****************************************************/
function html_post_body($raw_post="") {
global $ibforums;
$ibforums->lang['the_max_length'] = $ibforums->vars['max_post_length'] * 1024;
return $this->html->postbox_buttons($raw_post);
}
/*****************************************************/
// HTML: Post Icons
// ------------------
// Returns the HTML for post area, code buttons and
// post icons
/*****************************************************/
function html_post_icons($post_icon="") {
global $ibforums;
if ($ibforums->input['iconid'])
{
$post_icon = $ibforums->input['iconid'];
}
$ibforums->lang['the_max_length'] = $ibforums->vars['max_post_length'] * 1024;
$html = $this->html->PostIcons();
if ($post_icon) {
$html = preg_replace( "/name=[\"']iconid[\"']\s*value=[\"']$post_icon\s?[\"']/", "name='iconid' value='$post_icon' checked", $html );
$html = preg_replace( "/name=[\"']iconid[\"']\s*value=[\"']0[\"']\s*checked/i" , "name='iconid' value='0'", $html );
}
return $html;
}
/*****************************************************/
// HTML: add smilie box.
// ------------------
// Inserts the clickable smilies box
/*****************************************************/
function html_add_smilie_box() {
global $ibforums, $DB;
$show_table = 0;
$count = 0;
$smilies = "<tr align='center'>\n";
// Get the smilies from the DB
$DB->query("SELECT * FROM ibf_emoticons WHERE clickable='1'");
while ($elmo = $DB->fetch_row() ) {
$show_table++;
$count++;
$smilies .= "<td><a href=\"javascript:emoticon('".$elmo['typed']."')\"><img src=\"".$ibforums->vars['EMOTICONS_URL']."/".$elmo['image']."\" alt='smilie' border='0'></a>&nbsp;</td>\n";
if ($count == $ibforums->vars['emo_per_row']) {
$smilies .= "</tr>\n\n<tr align='center'>";
$count = 0;
}
}
if ($count != $ibforums->vars['emo_per_row']) {
for ($i = $count ; $i < $ibforums->vars['emo_per_row'] ; ++$i) {
$smilies .= "<td>&nbsp;</td>\n";
}
$smilies .= "</tr>";
}
$table = $this->html->smilie_table();
if ($show_table != 0) {
$table = preg_replace( "/<!--THE SMILIES-->/", $smilies, $table );
$this->output = preg_replace( "/<!--SMILIE TABLE-->/", $table, $this->output );
}
}
/*****************************************************/
// HTML: topic summary.
// ------------------
// displays the last 10 replies to the topic we're
// replying in.
/*****************************************************/
function html_topic_summary($topic_id) {
global $ibforums, $std, $DB;
if (! $topic_id ) return;
$cached_members = array();
$this->output .= $this->html->TopicSummary_top();
//--------------------------------------------------------------
// Get the posts
// This section will probably change at some point
//--------------------------------------------------------------
$post_query = $DB->query("SELECT post, pid, post_date, author_id, author_name FROM ibf_posts WHERE topic_id='$topic_id' and queued <> 1 ORDER BY pid DESC LIMIT 0,10");
while ( $row = $DB->fetch_row($post_query) )
{
$row['author'] = $row['author_name'];
$row['date'] = $std->get_date( $row['post_date'], 'LONG' );
$this->output .= $this->html->TopicSummary_body( $row );
}
$this->output .= $this->html->TopicSummary_bottom();
}
/*****************************************************/
// Moderators log
// ------------------
// Simply adds the last action to the mod logs
/*****************************************************/
function moderate_log($title = 'unknown', $topic_title) {
global $std, $ibforums, $DB, $HTTP_REFERER, $QUERY_STRING;
$db_string = $std->compile_db_string( array (
'forum_id' => $ibforums->input['f'],
'topic_id' => $ibforums->input['t'],
'post_id' => $ibforums->input['p'],
'member_id' => $ibforums->member['id'],
'member_name' => $ibforums->member['name'],
'ip_address' => $ibforums->input['IP_ADDRESS'],
'http_referer'=> $HTTP_REFERER,
'ctime' => time(),
'topic_title' => $topic_title,
'action' => $title,
'query_string'=> $QUERY_STRING,
)
);
$DB->query("INSERT INTO ibf_moderator_logs (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
}
}
?>
+301
View File
@@ -0,0 +1,301 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > User Profile functions
| > Module written by Matt Mecham
| > Date started: 28th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new Profile;
class Profile {
var $output = "";
var $page_title = "";
var $nav = array();
var $html = "";
var $parser;
var $member = array();
var $m_group = array();
var $jump_html = "";
var $parser = "";
var $links = array();
var $bio = "";
var $notes = "";
var $size = "m";
var $lib;
function Profile() {
global $ibforums, $DB, $std, $print;
require "./sources/lib/post_parser.php";
$this->parser = new post_parser();
//--------------------------------------------
// Make sure our code number is numerical only
//--------------------------------------------
//$ibforums->input['CODE'] = preg_replace("/^([0-9]+)$/", "$1", $ibforums->input['CODE']);
if ($ibforums->input['CODE'] == "") $ibforums->input['CODE'] = 00;
//--------------------------------------------
// Require the HTML and language modules
//--------------------------------------------
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_profile' , $ibforums->lang_id );
require "./Skin/".$ibforums->skin_id."/skin_profile.php";
$this->html = new skin_profile;
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
$this->base_url_nosess = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}";
//--------------------------------------------
// Check viewing permissions, etc
//--------------------------------------------
$this->member = $ibforums->member;
$this->m_group = $ibforums->member;
//--------------------------------------------
// What to do?
//--------------------------------------------
switch($ibforums->input['CODE']) {
case '03':
$this->view_profile();
break;
//------------------------------
default:
$this->view_profile();
break;
}
// If we have any HTML to print, do so...
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 1, NAV => $this->nav ) );
}
function view_profile() {
global $ibforums, $DB, $std, $print;
$info = array();
if ($ibforums->member['g_mem_info'] != 1)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission' ) );
}
//--------------------------------------------
// Check input..
//--------------------------------------------
$id = preg_replace( "/^(\d+)$/", "\\1", $ibforums->input['MID'] );
if ( empty($id) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'incorrect_use' ) );
}
//--------------------------------------------
// Prepare Query...
//--------------------------------------------
$DB->query("SELECT m.*, g.g_id, g.g_title as group_title FROM ibf_members m, ibf_groups g WHERE m.id='$id' and m.mgroup=g.g_id");
$member = $DB->fetch_row();
if (empty($member['id']))
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'incorrect_use' ) );
}
// Play it safe
$member['password'] = "";
//--------------------------------------------
// Find the most posted in forum that the viewing
// member has access to by this members profile
//--------------------------------------------
$DB->query("SELECT id, read_perms FROM ibf_forums");
$forum_ids = array('0');
while ( $r = $DB->fetch_row() )
{
if ($r['read_perms'] == '*')
{
$forum_ids[] = $r['id'];
}
else if ( preg_match( "/(^|,)".$this->member['mgroup']."(,|$)/", $r['read_perms']) )
{
$forum_ids[] = $r['id'];
}
}
$forum_id_str = implode( ",", $forum_ids );
$percent = 0;
$DB->query("SELECT DISTINCT(p.forum_id), f.name, COUNT(p.author_id) as f_posts FROM ibf_posts p, ibf_forums f ".
"WHERE p.forum_id IN ($forum_id_str) AND p.author_id='".$member['id']."' AND p.forum_id=f.id GROUP BY p.forum_id ORDER BY f_posts DESC");
$favourite = $DB->fetch_row();
$DB->query("SELECT COUNT(pid) as total_posts FROM ibf_posts WHERE author_id='".$member['id']."'");
$total_posts = $DB->fetch_row();
$DB->query("SELECT TOTAL_TOPICS, TOTAL_REPLIES FROM ibf_stats");
$stats = $DB->fetch_row();
$board_posts = $stats['TOTAL_TOPICS'] + $stats['TOTAL_REPLIES'];
if ($total_posts['total_posts'] > 0)
{
$percent = round( $favourite['f_posts'] / $total_posts['total_posts'] * 100 );
}
if ($member['posts'])
{
$info['posts_day'] = round( $member['posts'] / (((time() - $member['joined']) / 86400)), 1);
$info['total_pct'] = sprintf( '%.2f', ( $member['posts'] / $board_posts * 100 ) );
}
if ($info['posts_day'] > $member['posts'])
{
$info['posts_day'] = $member['posts'];
}
$info['posts'] = $member['posts'] ? $member['posts'] : 0;
$info['name'] = $member['name'];
$info['mid'] = $member['id'];
$info['fav_forum'] = $favourite['name'];
$info['fav_id'] = $favourite['forum_id'];
$info['fav_posts'] = $favourite['f_posts'];
$info['percent'] = $percent;
$info['group_title'] = $member['group_title'];
$info['board_posts'] = $board_posts;
$info['joined'] = $std->get_date( $member['joined'], 'LONG' );
$info['member_title'] = $member['title'] ? $member['title'] : $ibforums->lang['no_info'];
$info['aim_name'] = $member['aim_name'] ? $member['aim_name'] : $ibforums->lang['no_info'];
$info['icq_number'] = $member['icq_number'] ? $member['icq_number'] : $ibforums->lang['no_info'];
$info['yahoo'] = $member['yahoo'] ? $member['yahoo'] : $ibforums->lang['no_info'];
$info['location'] = $member['location'] ? $member['location'] : $ibforums->lang['no_info'];
$info['interests'] = $member['interests'] ? $member['interests'] : $ibforums->lang['no_info'];
$info['msn_name'] = $member['msnname'] ? $member['msnname'] : $ibforums->lang['no_info'];
$ibforums->vars['time_adjust'] = $ibforums->vars['time_adjust'] == "" ? 0 : $ibforums->vars['time_adjust'];
if ($member['dst_in_use'] == 1)
{
$member['time_offset'] += 1;
}
$info['local_time'] = $member['time_offset'] != "" ? gmdate( "h:i A", time() + ($member['time_offset']*3600) + ($ibforums->vars['time_adjust'] * 60) ) : $ibforums->lang['no_info'];
$info['avatar'] = $std->get_avatar( $member['avatar'] , 1, $member['avatar_size'] );
$info['signature'] = $member['signature'];
if ( $member['website'] and preg_match( "/^http:\/\/\S+$/", $member['website'] ) ) {
$info['homepage'] = "<a href='{$member['website']}' target='_blank'>{$member['website']}</a>";
}
else
{
$info['homepage'] = $ibforums->lang['no_info'];
}
if ($member['bday_month'])
{
$info['birthday'] = $member['bday_day']." ".$ibforums->lang[ 'M_'.$member['bday_month'] ]." ".$member['bday_year'];
}
else
{
$info['birthday'] = $ibforums->lang['no_info'];
}
if (!$member['hide_email']) {
$info['email'] = "<a href='{$this->base_url}&act=Mail&CODE=00&MID={$member['id']}'>{$ibforums->lang['click_here']}</a>";
}
else
{
$info['email'] = $ibforums->lang['private'];
}
$info['base_url'] = $this->base_url;
$this->output .= $this->html->show_profile( $info );
// Is this our profile?
if ($member['id'] == $this->member['id'])
{
$this->output = preg_replace( "/<!--MEM OPTIONS-->/e", "\$this->html->user_edit(\$info)", $this->output );
}
// Can mods edit this profile?
if ($ibforums->member['id'])
{
if ($ibforums->member['g_is_supmod'] == 1)
{
$pass = 1;
}
else
{
$DB->query("SELECT * FROM ibf_moderators WHERE edit_user=1 AND member_id='".$ibforums->member['id']."'");
if ( $this->moderator = $DB->fetch_row() )
{
$pass = 1;
}
}
}
$this->page_title = $ibforums->lang['page_title'];
$this->nav = array( $ibforums->lang['page_title'] );
}
}
?>
+710
View File
@@ -0,0 +1,710 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Registration functions
| > Module written by Matt Mecham
| > Date started: 16th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new Register;
class Register {
var $output = "";
var $page_title = "";
var $nav = array();
var $html = "";
var $email = "";
function Register() {
global $ibforums, $DB, $std, $print;
//--------------------------------------------
// Make sure our code number is numerical only
//--------------------------------------------
//$ibforums->input['CODE'] = preg_replace("/^([0-9]+)$/", "$1", $ibforums->input['CODE']);
if ($ibforums->input['CODE'] == "") $ibforums->input['CODE'] = 00;
//--------------------------------------------
// Require the HTML and language modules
//--------------------------------------------
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_register', $ibforums->lang_id );
require "./Skin/".$ibforums->skin_id."/skin_register.php";
$this->html = new skin_register();
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
$this->base_url_nosess = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}";
//--------------------------------------------
// Get the emailer module
//--------------------------------------------
require "./sources/lib/emailer.php";
$this->email = new emailer();
//--------------------------------------------
// What to do?
//--------------------------------------------
switch($ibforums->input['CODE']) {
case '00':
$this->show_reg_form();
break;
case '02':
$this->create_account();
break;
case '03':
$this->validate_user();
break;
case '05':
$this->show_manual_form();
break;
case '06':
$this->show_manual_form('lostpass');
break;
case '07':
$this->show_manual_form('newemail');
break;
case '10':
$this->lost_password_start();
break;
case '11':
$this->lost_password_end();
break;
default:
$this->show_reg_form();
break;
}
// If we have any HTML to print, do so...
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
}
/*****************************************************/
// lost_password_start
// ------------------
// Simply shows the lostpassword form
// What do you want? Blood?
/*****************************************************/
function lost_password_start()
{
global $ibforums, $DB, $std;
$this->page_title = $ibforums->lang['lost_pass_form'];
$this->nav = array( $ibforums->lang['lost_pass_form'] );
$this->output .= $this->html->lost_pass_form();
}
function lost_password_end()
{
global $ibforums, $DB, $std, $HTTP_POST_VARS, $print;
if ($HTTP_POST_VARS['member_name'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_username' ) );
}
//------------------------------------------------------------
// Check for input and it's in a valid format.
//------------------------------------------------------------
$member_name = trim(strtolower($ibforums->input['member_name']));
if ($member_name == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_username' ) );
}
//------------------------------------------------------------
// Attempt to get the user details from the DB
//------------------------------------------------------------
$DB->query("SELECT name, id, email, mgroup, validate_key FROM ibf_members WHERE LOWER(name)='$member_name'");
if ( !$DB->get_num_rows() )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_such_user' ) );
}
else
{
$member = $DB->fetch_row();
//------------------------------------------------------------
// Is there a validation key? If so, we'd better not touch it
//------------------------------------------------------------
if ($member['mgroup'] == $ibforums->vars['auth_group'])
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'val_key_present' ) );
}
if ($member['id'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_such_user' ) );
}
$new_pass = $std->make_password();
$validate_key = $std->make_password();
$md5_pass = md5($new_pass);
//------------------------------------------------------------
// Update the DB for this member.
//------------------------------------------------------------
$DB->query("UPDATE ibf_members SET new_pass='$md5_pass', validate_key='$validate_key' WHERE id='".$member['id']."'");
//------------------------------------------------------------
// Send out the email.
//------------------------------------------------------------
$this->email->get_template("lost_pass");
$this->email->build_message( array(
'NAME' => $member['name'],
'PASSWORD' => $new_pass,
'MAN_LINK' => $this->base_url_nosess."?act=Reg&CODE=06",
'EMAIL' => $member['email'],
'ID' => $member['id'],
'CODE' => $validate_key,
)
);
$this->email->subject = $ibforums->lang['lp_subject'].' '.$ibforums->vars['BOARDNAME'];
$this->email->to = $member['email'];
$this->email->send_mail();
$std->my_setcookie( 'pass_hash' , '-1', 0 );
$print->redirect_screen( $ibforums->lang['lp_redirect'], 'act=Reg&CODE=06' );
}
}
/*****************************************************/
// show_reg_form
// ------------------
// Simply shows the registration form, no - really! Thats
// all it does. It doesn't make the tea or anything.
// Just the registration form, no more - no less.
// Unless your server went down, then it's just useless.
/*****************************************************/
function show_reg_form() {
global $ibforums, $DB, $std;
if ($ibforums->vars['no_reg'] == 1)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'reg_off' ) );
}
if ($ibforums->vars['reg_auth_type'])
{
$ibforums->lang['std_text'] .= "<br>" . $ibforums->lang['email_validate_text'];
}
$this->page_title = $ibforums->lang['registration_form'];
$this->nav = array( $ibforums->lang['registration_form'] );
$this->output .= $this->html->ShowForm( array( 'TEXT' => $ibforums->lang['std_text'], 'RULES' => $ibforums->lang['click_wrap'] ) );
}
/*****************************************************/
// create_account
// ------------------
// Now this is a really good subroutine. It adds the member
// to the members table in the database. Yes, really fancy
// this one. It also finds the time to see if we need to
// check any email verification type malarky before we
// can use this brand new account. It's like buying a new
// car and getting it towed home and being told the keys
// will be posted later. Although you can't polish this
// routine while you're waiting.
/*****************************************************/
function create_account() {
global $ibforums, $std, $DB, $print;
if ($ibforums->vars['no_reg'] == 1)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'reg_off' ) );
}
// Trim off the username and password
$in_username = trim($ibforums->input['UserName']);
$in_password = trim($ibforums->input['PassWord']);
$in_email = strtolower( trim($ibforums->input['EmailAddress']) );
$ibforums->input['EmailAddress_two'] = strtolower( trim($ibforums->input['EmailAddress_two']) );
if ($ibforums->input['EmailAddress_two'] != $in_email)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'email_addy_mismatch' ) );
}
//+--------------------------------------------
//| Check for errors in the input.
//+--------------------------------------------
if (empty($in_username)) $std->Error( array( LEVEL => 1, MSG => 'no_username' ) );
if (strlen($in_username) < 3) $std->Error( array( LEVEL => 1, MSG => 'username_short' ) );
if (strlen($in_username) > 32) $std->Error( array( LEVEL => 1, MSG => 'username_long' ) );
if (empty($in_password)) $std->Error( array( LEVEL => 1, MSG => 'pass_blank' ) );
if (strlen($in_password) < 3) $std->Error( array( LEVEL => 1, MSG => 'pass_too_short' ) );
if (strlen($in_password) > 32) $std->Error( array( LEVEL => 1, MSG => 'pass_too_long' ) );
if ($ibforums->input['PassWord_Check'] != $in_password) $std->Error( array( LEVEL => 1, MSG => 'pass_no_match' ) );
if (strlen($in_email) < 6) $std->Error( array( LEVEL => 1, MSG => 'invalid_email' ) );
//+--------------------------------------------
//| Check the email address
//+--------------------------------------------
$in_email = $std->clean_email($in_email);
if (! $in_email )
{
$std->Error( array( LEVEL => 1, MSG => 'invalid_email' ) );
}
//+--------------------------------------------
//| Is this name already taken?
//+--------------------------------------------
$DB->query("SELECT id FROM ibf_members WHERE LOWER(name)='".strtolower($in_username)."'");
$name_check = $DB->fetch_row();
if ($name_check['id'])
{
$std->Error( array( LEVEL => 1, MSG => 'user_exists' ) );
}
if (strtolower($in_username) == 'guest')
{
$std->Error( array( LEVEL => 1, MSG => 'user_exists' ) );
}
//+--------------------------------------------
//| Is this email addy taken?
//+--------------------------------------------
if (! $ibforums->vars['allow_dup_email'] )
{
$DB->query("SELECT id FROM ibf_members WHERE email='".$in_email."'");
$email_check = $DB->fetch_row();
if ($email_check['id'])
{
$std->Error( array( LEVEL => 1, MSG => 'email_exists' ) );
}
}
//+--------------------------------------------
//| Are they in the reserved names list?
//+--------------------------------------------
if ($ibforums->vars['ban_names'])
{
$names = explode( "|" , $ibforums->vars['ban_names'] );
foreach ($names as $n)
{
if (preg_match( "/$n/i", $in_username ))
{
$std->Error( array( LEVEL => 1, MSG => 'user_exists' ) );
break;
}
}
}
//+--------------------------------------------
//| Are they banned?
//+--------------------------------------------
if ($ibforums->vars['ban_ip'])
{
$ips = explode( "|", $ibforums->vars['ban_ip'] );
foreach ($ips as $ip)
{
$ip = preg_replace( "/\*/", '.*' , $ip );
if (preg_match( "/$ip/", $ibforums->input['IP_ADDRESS'] ))
{
$std->Error( array( LEVEL => 1, MSG => 'you_are_banned' ) );
}
}
}
if ($ibforums->vars['ban_email'])
{
$ips = explode( "|", $ibforums->vars['ban_email'] );
foreach ($ips as $ip)
{
$ip = preg_replace( "/\*/", '.*' , $ip );
if (preg_match( "/$ip/", $in_email ))
{
$std->Error( array( LEVEL => 1, MSG => 'you_are_banned' ) );
}
}
}
//+--------------------------------------------
//| Build up the hashes
//+--------------------------------------------
$mem_group = $ibforums->vars['member_group'];
//+--------------------------------------------
//| Are we asking the member or admin to preview?
//+--------------------------------------------
if ($ibforums->vars['reg_auth_type'])
{
$mem_group = $ibforums->vars['auth_group'];
}
//+--------------------------------------------
//| Find the highest member id, and increment it
//| auto_increment not used for guest id 0 val.
//+--------------------------------------------
$DB->query("SELECT MAX(id) as new_id FROM ibf_members");
$r = $DB->fetch_row();
$member_id = $r['new_id'] + 1;
$member = array(
'id' => $member_id,
'name' => $in_username,
'password' => $in_password,
'email' => $in_email,
'mgroup' => $mem_group,
'posts' => 0,
'avatar' => 'noavatar',
'joined' => time(),
'ip_address' => $ibforums->input['IP_ADDRESS'],
'time_offset' => $ibforums->vars['time_offset'],
'view_sigs' => 1,
'email_pm' => 1,
'view_img' => 1,
'view_avs' => 1,
'allow_post' => 1,
'view_pop' => 1,
'vdirs' => "in:Inbox|sent:Sent Items",
'msg_total' => 0,
'new_msg' => 0,
);
//+--------------------------------------------
//| Insert into the DB
//+--------------------------------------------
$member['password'] = md5( $member['password'] );
$db_string = $std->compile_db_string( $member );
$DB->query("INSERT INTO ibf_members (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
unset($db_string);
$validate_key = $std->make_password();
$time = time();
if ( ($ibforums->vars['reg_auth_type'] == 'user') or ($ibforums->vars['reg_auth_type'] == 'admin') ) {
// We want to validate all reg's via email, after email verificiation has taken place,
// we restore their previous group and remove the validate_key
$DB->query("UPDATE ibf_members SET validate_key='$validate_key', prev_group='".$ibforums->vars['member_group']."' "
."WHERE id='$member_id'");
if ( $ibforums->vars['reg_auth_type'] == 'user' )
{
$this->email->get_template("reg_validate");
$this->email->build_message( array(
'THE_LINK' => $this->base_url_nosess."?act=Reg&CODE=03&uid=".urlencode($member_id)."&aid=".urlencode($validate_key),
'NAME' => $member['name'],
'PASSWORD' => $in_password,
'MAN_LINK' => $this->base_url_nosess."?act=Reg&CODE=05",
'EMAIL' => $member['email'],
'ID' => $member_id,
'CODE' => $validate_key,
)
);
$this->email->subject = "Registration at ".$ibforums->vars['board_name'];
$this->email->to = $member['email'];
$this->email->send_mail();
$this->output = $this->html->show_authorise( $member );
}
else if ( $ibforums->vars['reg_auth_type'] == 'admin' )
{
$this->output = $this->html->show_preview( $member );
}
$this->page_title = $ibforums->lang['reg_success'];
$this->nav = array( $ibforums->lang['nav_reg'] );
}
else
{
// We don't want to preview, or get them to validate via email.
$DB->query("UPDATE ibf_stats SET ".
"MEM_COUNT=MEM_COUNT+1, ".
"LAST_MEM_NAME='" . $member['name'] . "', ".
"LAST_MEM_ID='" . $member['id'] . "'");
if ($ibforums->vars['new_reg_notify']) {
$date = $std->get_date( time(), 'LONG' );
$this->email->get_template("admin_newuser");
$this->email->build_message( array(
'DATE' => $date,
'MEMBER_NAME' => $member['name'],
)
);
$this->email->subject = "New Registration at ".$ibforums->vars['board_name'];
$this->email->to = $ibforums->vars['email_in'];
$this->email->send_mail();
}
$text = $ibforums->lang['done_reg_2'];
$url = 'act=Login&CODE=00';
$print->redirect_screen( $text, $url );
}
}
/*****************************************************/
// validate_user
// ------------------
// Leave a message after the tone, and I'll amuse myself
// by pulling faces when hearing the message later.
/*****************************************************/
function validate_user() {
global $ibforums, $std, $DB, $print;
//------------------------------------------------------------
// Check for input and it's in a valid format.
//------------------------------------------------------------
$in_user_id = trim(urldecode($ibforums->input['uid']));
$in_validate_key = trim(urldecode($ibforums->input['aid']));
$in_type = trim($ibforums->input['type']);
if ($in_type == "")
{
$in_type = 'reg';
}
//------------------------------------------------------------
if (! preg_match( "/^(?:[\d\w]){6,14}$/", $in_validate_key ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'data_incorrect' ) );
}
//------------------------------------------------------------
if (! preg_match( "/^(?:\d){1,}$/", $in_user_id ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'data_incorrect' ) );
}
//------------------------------------------------------------
// Attempt to get the profile of the requesting user
//------------------------------------------------------------
$DB->query("SELECT id, name, validate_key, prev_group, mgroup, email, new_pass FROM ibf_members WHERE id='$in_user_id'");
if ( !$DB->get_num_rows() )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'auth_no_mem' ) );
}
//------------------------------------------------------------
$member = $DB->fetch_row();
//------------------------------------------------------------
if ( $member['id'] == "" )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'auth_no_mem' ) );
}
//------------------------------------------------------------
if ( $member['validate_key'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'auth_no_key' ) );
}
else if ($member['validate_key'] != $in_validate_key)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'auth_key_wrong' ) );
}
else
{
//------------------------------------------------------------
// Update the member...
//------------------------------------------------------------
if ($in_type == 'reg')
{
if (empty($member['prev_group']))
{
$member['prev_group'] = $ibforums->vars['member_group'];
}
$DB->query("UPDATE ibf_members SET mgroup='".$member['prev_group']."', prev_group='', validate_key='', new_pass='' WHERE id='".$member['id']."'");
//------------------------------------------------------------
// Update the stats...
//------------------------------------------------------------
$DB->query("UPDATE ibf_stats SET ".
"MEM_COUNT=MEM_COUNT+1, ".
"LAST_MEM_NAME='" . $member['name'] . "', ".
"LAST_MEM_ID='" . $member['id'] . "'");
if ($ibforums->vars['new_reg_notify']) {
$date = $std->get_date( time(), 'LONG' );
$this->email->get_template("admin_newuser");
$this->email->build_message( array(
'DATE' => $date,
'MEMBER_NAME' => $member['name'],
)
);
$this->email->subject = "New Registration at ".$ibforums->vars['board_name'];
$this->email->to = $ibforums->vars['email_in'];
$this->email->send_mail();
}
}
else if ($in_type == 'lostpass')
{
if ($member['new_pass'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'lp_no_pass' ) );
}
$DB->query("UPDATE ibf_members SET password='".$member['new_pass']."', prev_group='', validate_key='', new_pass='' WHERE id='".$member['id']."'");
}
else if ($in_type == 'newemail')
{
if (empty($member['prev_group']))
{
$member['prev_group'] = $ibforums->vars['member_group'];
}
$DB->query("UPDATE ibf_members SET mgroup='".$member['prev_group']."', prev_group='', validate_key='', new_pass='' WHERE id='".$member['id']."'");
}
$text = $ibforums->lang['done_reg_2'];
$url = 'act=Login&CODE=00';
$print->redirect_screen( $text, $url );
}
}
/*****************************************************/
// show_board_rules
// ------------------
// o_O ^^
/*****************************************************/
function show_board_rules() {
global $ibforums, $DB;
$DB->query("SELECT RULES_TEXT from ib_forum_rules WHERE ID='00'");
$rules = $DB->fetch_row();
$this->output = $this->html->show_rules($rules);
$this->page_title = $ibforums->lang['board_rules'];
$this->nav = array( $ibforums->lang['board_rules'] );
}
/*****************************************************/
// show_manual_form
// ------------------
// This feature is not available in an auto option
/*****************************************************/
function show_manual_form($type='reg') {
global $ibforums;
$this->output = $this->html->show_dumb_form($type);
$this->page_title = $ibforums->lang['activation_form'];
$this->nav = array( $ibforums->lang['activation_form'] );
}
}
?>
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+174
View File
@@ -0,0 +1,174 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Add POLL module
| > Module written by Matt Mecham
|
+--------------------------------------------------------------------------
|
| QUOTE OF THE MODULE: (Taken from BtVS)
| --------------------
| Drusilla: I'm naming all the stars...
| Spike: You can't see the stars love, That's the ceiling. Also, it's day.
|
+--------------------------------------------------------------------------
*/
$idx = new Poll;
class Poll {
var $topic = array();
var $poll = array();
var $upload = array();
var $poll_count = 0;
var $poll_choices = "";
function Poll() {
global $ibforums, $std, $DB, $print;
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_post', $ibforums->lang_id);
// Lets do some tests to make sure that we are allowed to start a new topic
if (! $ibforums->member['g_vote_polls'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_reply_polls') );
}
// Did we choose a choice?
if (!$ibforums->input['nullvote'])
{
if (! isset($ibforums->input['poll_vote']) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_vote') );
}
}
// Make sure we have a valid poll id
$ibforums->input[t] = $std->is_number($ibforums->input[t]);
if (! $ibforums->input[t] ) {
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
// Load the topic and poll
$DB->query("SELECT t.*, p.pid as poll_id,p.choices,p.starter_id,p.votes from ibf_polls p, ibf_topics t WHERE t.tid='".$ibforums->input['t']."' and p.tid=t.tid");
$this->topic = $DB->fetch_row();
if (! $this->topic['tid'] )
{
$std->Error( array( LEVEL => 1, MSG => 'poll_none_found') );
}
if ($this->topic['state'] != 'open')
{
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
}
// Have we voted before?
$DB->query("SELECT member_id from ibf_voters WHERE tid='".$this->topic['tid']."' and member_id='".$ibforums->member['id']."'");
if ( $DB->get_num_rows() )
{
$std->Error( array( LEVEL => 1, MSG => 'poll_you_voted') );
}
// If we're here, lets add the vote
$db_string = $std->compile_db_string(
array (
'member_id' => $ibforums->member['id'],
'ip_address' => $ibforums->input['IP_ADDRESS'],
'tid' => $this->topic['tid'],
'forum_id' => $this->topic['forum_id'],
'vote_date' => time(),
)
);
$DB->query("INSERT INTO ibf_voters (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
// If this isn't a null vote...
if (!$ibforums->input['nullvote'])
{
$poll_answers = unserialize(stripslashes($this->topic['choices']));
reset($poll_answers);
$new_poll_array = array();
foreach ($poll_answers as $entry)
{
$id = $entry[0];
$choice = $entry[1];
$votes = $entry[2];
if ($id == $ibforums->input['poll_vote'])
{
$votes++;
}
$new_poll_array[] = array( $id, $choice, $votes);
}
$this->topic['choices'] = addslashes(serialize($new_poll_array));
$DB->query("UPDATE ibf_polls SET ".
"votes=votes+1, ".
"choices='" . $this->topic['choices'] . "' ".
"WHERE pid='" . $this->topic['poll_id'] . "'");
if ($ibforums->vars['allow_poll_bump'])
{
$this->topic['last_vote'] = time();
$this->topic['last_post'] = time();
$DB->query("UPDATE ibf_topics SET ".
"last_vote='" . $this->topic['last_vote'] . "', ".
"last_post='" . $this->topic['last_post'] . "' ".
"WHERE tid='" . $this->topic['tid'] . "'");
}
else
{
$this->topic['last_vote'] = time();
$DB->query("UPDATE ibf_topics SET ".
"last_vote='" . $this->topic['last_vote'] . "', ".
"last_post='" . $this->topic['last_post'] . "' ".
"WHERE tid='" . $this->topic['tid'] . "'");
}
}
$lang = $ibforums->input['nullvote'] ? $ibforums->lang['poll_viewing_results'] : $ibforums->lang['poll_vote_added'];
$print->redirect_screen( $lang , "act=ST&f={$this->topic['forum_id']}&t={$this->topic['tid']}" );
}
}
?>
+292
View File
@@ -0,0 +1,292 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Sending email module
| > Module written by Matt Mecham
| > Date started: 26th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
|
| QUOTE OF THE MODULE: (Taken from "Shrek" (c) Dreamworks Pictures)
| --------------------
| DONKEY: We can stay up late, swap manly stories and in the morning,
| I'm making waffles!
|
+--------------------------------------------------------------------------
*/
// This module is fairly basic, more functionality is expected in future
// versions (such as MIME attachments, SMTP stuff, etc)
class emailer {
var $from = "";
var $to = "";
var $subject = "";
var $message = "";
var $header = "";
var $footer = "";
var $template = "";
var $error = "";
var $parts = array();
var $bcc = "";
var $mail_headers = array();
var $multipart = "";
var $boundry = "";
var $temp_dump = 0;
function emailer() {
global $ibforums;
// Assign $from as the admin out email address, this can be
// over-riden at any time.
$this->from = $ibforums->vars['email_out'];
// Temporarily assign $header and $footer, this can be over-riden
// also
$this->header = $ibforums->vars['email_header'];
$this->footer = $ibforums->vars['email_footer'];
$this->boundry = "----=_NextPart_000_0022_01C1BD6C.D0C0F9F0"; //"b".md5(uniqid(time()));
}
function add_attachment($data = "", $name = "", $ctype='application/octet-stream') {
$this->parts[] = array( 'ctype' => $ctype,
'data' => $data,
'encode' => 'base64',
'name' => $name
);
}
function build_headers() {
$this->mail_headers = "From: ".$this->from. "\n";
$this->mail_headers .= "X-Priority: 3\n";
$this->mail_headers .= "X-Mailer: IBForums PHP Mailer\n";
if (is_array( $this->bcc ) )
{
$this->mail_headers .= "BCC: ".implode( "," , $this->bcc ) . "\n";
}
if ( count ($this->parts) > 0 )
{
$this->mail_headers .= "MIME-Version: 1.0\n";
$this->mail_headers .= "Content-Type: multipart/mixed;\n\tboundary=\"".$this->boundry."\"\n\nThis is a MIME encoded message.\n\n--".$this->boundry;
$this->mail_headers .= "\nContent-Type: text/plain;\n\tcharset=\"iso-8859-1\"\nContent-Transfer-Encoding: quoted-printable\n\n".$this->message."\n\n--".$this->boundry;
$this->mail_headers .= $this->build_multipart();
$this->message = "";
}
}
function encode_attachment($part) {
$msg = chunk_split(base64_encode($part['data']));
return "Content-Type: ".$part['ctype']. ($part['name'] ? ";\n\tname =\"".$part['name']."\"" : "").
"\nContent-Transfer-Encoding: ".$part['encode']."\nContent-Disposition: attachment;\n\tfilename=\"".$part['name']."\"\n\n".$msg."\n";
}
function build_multipart() {
$multipart = "";
for ($i = sizeof($this->parts) - 1 ; $i >= 0 ; $i--)
{
$multipart .= "\n".$this->encode_attachment($this->parts[$i]) . "--".$this->boundry;
}
return $multipart . "--\n";
}
//+--------------------------------------------------------------------------
// send_mail:
// Physically sends the email
//+--------------------------------------------------------------------------
function send_mail() {
$this->to = preg_replace( "/[ \t]+/" , " " , $this->to );
$this->from = preg_replace( "/[ \t]+/" , " " , $this->from );
$this->to = preg_replace( "/,,/" , "," , $this->to );
$this->from = preg_replace( "/,,/" , "," , $this->from );
$this->to = preg_replace( "#\#\[\]'\"\(\):;/\$!£%\^&\*\{\}#" , "", $this->to );
$this->from = preg_replace( "#\#\[\]'\"\(\):;/\$!£%\^&\*\{\}#" , "", $this->from);
$this->subject = $this->clean_message($this->subject);
$this->build_headers();
if ( ($this->from) and ($this->subject) )
{
if ($this->temp_dump == 1)
{
$blah = $this->to."\n".$this->from."\n".$this->subject."\n".$this->mail_headers."\n\n".$this->message;
$pathy = '/Library/WebServer/Documents/mail/'.date("js.F.Y.h:i.A"); // OS X rules!
$fh = fopen ($pathy, 'w');
fputs ($fh, $blah, strlen($blah) );
fclose($fh);
}
else
{
if ( ! @mail( $this->to, $this->subject, $this->message, $this->mail_headers ) )
{
$this->fatal_error("Could not sent the email", "Failed at 'mail' command");
}
}
}
else
{
return FALSE;
}
}
//+--------------------------------------------------------------------------
// get_template:
// Queries the database, and stores the template we wish to use in memory
//+--------------------------------------------------------------------------
function get_template($name="", $language="en") {
global $IB, $DB;
if ($name == "")
{
$this->error++;
$this->fatal_error("A valid email template ID was not passed to the email library during template parsing", "");
}
if (! file_exists("./lang/$language/email_content.php") )
{
require "./lang/en/email_content.php";
}
else
{
require "./lang/$language/email_content.php";
}
if (! isset($EMAIL[ $name ]) ) {
$this->fatal_error("Could not find an email template with an ID of '$name'", "");
}
$this->template = $EMAIL[ $name ];
}
//+--------------------------------------------------------------------------
// build_message:
// Swops template tags into the corresponding string held in $words array.
// Also joins header and footer to message and cleans the message for sending
//+--------------------------------------------------------------------------
function build_message($words) {
global $ibforums;
if ($this->template == "") {
$this->error++;
$this->fatal_error("Could not build the email message, no template assigned", "Make sure a template is assigned first.");
}
$this->message = $this->template;
// Add some default words
$words['BOARD_ADDRESS'] = $ibforums->vars['board_url'] . '/index.' . $ibforums->vars['php_ext'];
$words['WEB_ADDRESS'] = $ibforums->vars['home_url'];
$words['BOARD_NAME'] = $ibforums->vars['board_name'];
$words['SIGNATURE'] = $ibforums->vars['signature'];
// Swop the words
$this->message = preg_replace( "/<#(.+?)#>/e", "\$words[\\1]", $this->message );
$this->message = $this->clean_message( $this->message );
}
//+--------------------------------------------------------------------------
// clean_message: (Mainly used internally)
// Ensures that \n and <br> are converted into CRLF (\r\n)
// Also unconverts some iB_CODE.
//+--------------------------------------------------------------------------
function clean_message($message = "" ) {
$message = preg_replace( "#<b>(.+?)</b>#" , "\\1", $message );
$message = preg_replace( "#<i>(.+?)</i>#" , "\\1", $message );
$message = preg_replace( "#<s>(.+?)</s>#" , "--\\1--", $message );
$message = preg_replace( "#<u>(.+?)</u>#" , "-\\1-" , $message );
$message = preg_replace( "#<!--emo&(.+?)-->.+?<!--endemo-->#", "\\1" , $message );
$message = preg_replace( "#<!--c1-->(.+?)<!--ec1-->#", "\n\n------------ CODE SAMPLE ----------\n" , $message );
$message = preg_replace( "#<!--c2-->(.+?)<!--ec2-->#", "\n-----------------------------------\n\n" , $message );
$message = preg_replace( "#<!--QuoteBegin-->(.+?)<!--QuoteEBegin-->#" , "\n\n------------ QUOTE ----------\n" , $message );
$message = preg_replace( "#<!--QuoteBegin--(.+?)\+(.+?)-->(.+?)<!--QuoteEBegin-->#" , "\n\n------------ QUOTE ----------\n" , $message );
$message = preg_replace( "#<!--QuoteEnd-->(.+?)<!--QuoteEEnd-->#" , "\n-----------------------------\n\n" , $message );
$message = preg_replace( "#<!--Flash (.+?)-->.+?<!--End Flash-->#e" , "(FLASH MOVIE)" , $message );
$message = preg_replace( "#<img src=[\"'](\S+?)['\"].+?".">#" , "(IMAGE: \\1)" , $message );
$message = preg_replace( "#<a href=[\"'](http|https|ftp|news)://(\S+?)['\"].+?".">(.+?)</a>#" , "(URL: \\1)" , $message );
$message = preg_replace( "#<a href=[\"']mailto:(.+?)['\"]>(.+?)</a>#" , "(EMAIL: \\2)" , $message );
$message = preg_replace( "#<!--sql-->(.+?)<!--sql1-->(.+?)<!--sql2-->(.+?)<!--sql3-->#e" , "\n\n--------------- SQL -----------\n\\2\n----------------\n\n", $message);
$message = preg_replace( "#<!--html-->(.+?)<!--html1-->(.+?)<!--html2-->(.+?)<!--html3-->#e", "\n\n-------------- HTML -----------\n\\2\n----------------\n\n", $message);
$message = preg_replace( "#<!--EDIT\|.+?\|.+?-->#" , "" , $message );
$message = preg_replace( "#<.+?".">#" , "" , $message );
$message = preg_replace( "/(<br>|\n)/" , "\r\n", $message );
$message = str_replace( "&quot;", "\"", $message );
$message = str_replace( "&#092;", "\\", $message );
$message = str_replace( "&#036;", "\$", $message );
$message = str_replace( "&#33;" , "!", $message );
$message = str_replace( "&#39;" , "'", $message );
$message = str_replace( "&lt;" , "<", $message );
$message = str_replace( "&gt;" , ">", $message );
$message = str_replace( "&amp;" , "&", $message );
return $message;
}
function fatal_error($msg, $help="")
{
echo("<h1>Mail Error!</h1><br><b>$msg</b><br>$help");
exit();
}
}
?>
+280
View File
@@ -0,0 +1,280 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Edit post library
| > Module written by Matt Mecham
| > Date started: 19th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $moderator = array( 'member_id' => 0, 'member_name' => "", 'edit_post' => 0 );
var $orig_post = array();
function post_functions($class) {
global $ibforums, $std, $DB;
// Lets load the topic from the database before we do anything else.
$DB->query("SELECT * FROM ibf_topics WHERE tid='".$ibforums->input['t']."'");
$this->topic = $DB->fetch_row();
// Is it legitimate?
if (! $this->topic['tid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
// Load the old post
$DB->query("SELECT * FROM ibf_posts WHERE pid='".$ibforums->input['p']."'");
$this->orig_post = $DB->fetch_row();
if (! $this->orig_post['pid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
// Load the moderator
if ($ibforums->member['id'])
{
$DB->query("SELECT member_id, member_name, mid, edit_post FROM ibf_moderators WHERE member_id='".$ibforums->member['id']."' and forum_id='".$class->forum['id']."'");
$this->moderator = $DB->fetch_row();
}
//-------------------------------------------------
// Lets do some tests to make sure that we are
// allowed to edit this topic
//-------------------------------------------------
$can_edit = 0;
if ($ibforums->member['g_is_supmod'])
{
$can_edit = 1;
}
if ($this->moderator['edit_post'])
{
$can_edit = 1;
}
if ( ($this->orig_post['author_id'] == $ibforums->member['id']) and ($ibforums->member['g_edit_posts']) )
{
$can_edit = 1;
}
if ($can_edit != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'not_op') );
}
// Is the topic locked?
if (($this->topic['state'] != 'open') and (!$ibforums->member['g_is_supmod']))
{
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
}
}
function process($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Parse the post, and check for any errors.
// overwrites saved post intentionally
//-------------------------------------------------
$this->post = $class->compile_post();
if ($class->obj['post_errors'] == "")
{
$this->upload = $class->process_upload();
}
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") )
{
// Show the form again
$this->show_form($class);
}
else
{
$this->complete_edit($class);
}
}
function complete_edit($class) {
global $ibforums, $std, $DB, $print;
$time = $std->get_date( time(), 'LONG' );
//-------------------------------------------------
// Reset some data
//-------------------------------------------------
$this->post['attach_id'] = $this->orig_post['attach_id'];
$this->post['attach_type'] = $this->orig_post['attach_type'];
$this->post['attach_hits'] = $this->orig_post['attach_hits'];
$this->post['ip_address'] = $this->orig_post['ip_address'];
$this->post['topic_id'] = $this->orig_post['topic_id'];
$this->post['author_id'] = $this->orig_post['author_id'];
$this->post['pid'] = $this->orig_post['pid'];
$this->post['post_date'] = $this->orig_post['post_date'];
$this->post['author_name'] = $this->orig_post['author_name'];
// If the post icon has changed, update the topic post icon
if ($this->orig_post['new_topic'] == 1)
{
if ($this->post['icon_id'] != $this->orig_post['icon_id'])
{
$DB->query("UPDATE ibf_topics SET icon_id='".$this->post['icon_id']."' WHERE tid='".$this->topic['tid']."'");
}
}
//-------------------------------------------------
// Update the database (ib_forum_post)
//-------------------------------------------------
if ($ibforums->member['g_append_edit'])
{
$this->post['post'] .= "\n\n<br><br><!--EDIT|".$ibforums->member['name']."|".$time."-->";
}
$db_string = $DB->compile_db_update_string( $this->post );
$DB->query("UPDATE ibf_posts SET $db_string WHERE pid='".$this->post['pid']."'");
//-------------------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
$print->redirect_screen( $ibforums->lang['post_edited'], "act=ST&f={$class->forum['id']}&t={$this->topic['tid']}&st={$ibforums->input['st']}#entry{$this->post['pid']}");
}
function show_form($class) {
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
//-------------------------------------------------
// Sort out the "raw" textarea input and make it safe incase
// we have a <textarea> tag in the raw post var.
//-------------------------------------------------
$raw_post = isset($HTTP_POST_VARS['Post']) ? $HTTP_POST_VARS['Post'] : $class->parser->unconvert($this->orig_post['post'], $class->forum['use_ibc'], $class->forum['use_html']);
if (isset($raw_post)) {
$raw_post = preg_replace( "/<\/textarea>/", "&lt;/textarea>", $raw_post );
$raw_post = str_replace( '$', "&#036;", $raw_post );
$raw_post = str_replace( '<%', "&lt;%" , $raw_post );
$raw_post = stripslashes($raw_post);
}
//-------------------------------------------------
// Do we have any posting errors?
//-------------------------------------------------
if ($class->obj['post_errors'])
{
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
}
if ($class->obj['preview_post'])
{
$class->output .= $class->html->preview( $class->parser->convert( array( 'TEXT' => $this->post['post'], 'CODE' => $class->forum['use_ibc'], 'SMILIES' => $ibforums->input['enableemo'], 'HTML' => $class->forum['use_html']) ) );
}
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '09' ),
2 => array( 't' , $this->topic['tid']),
3 => array( 'p' , $ibforums->input['p'] ),
4 => array( 'st' , $ibforums->input['st'] ),
) );
//---------------------------------------
// START TABLE
//---------------------------------------
$class->output .= $class->html->table_structure();
//---------------------------------------
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_edit']} {$this->topic['title']}");
$name_fields = $class->html_name_field();
$post_box = $class->html_post_body( $raw_post );
$end_form = $class->html->EndForm( $ibforums->lang['submit_edit'] );
$post_icons = $class->html_post_icons($this->orig_post['icon_id']);
//---------------------------------------
$class->output = preg_replace( "/<!--START TABLE-->/" , "$start_table" , $class->output );
$class->output = preg_replace( "/<!--NAME FIELDS-->/" , "$name_fields" , $class->output );
$class->output = preg_replace( "/<!--POST BOX-->/" , "$post_box" , $class->output );
$class->output = preg_replace( "/<!--POST ICONS-->/" , "$post_icons" , $class->output );
$class->output = preg_replace( "/<!--END TABLE-->/" , "$end_form" , $class->output );
//---------------------------------------
$class->html_add_smilie_box();
$class->html_topic_summary($this->topic['tid']);
$this->nav = array( "<a href='{$class->base_url}&act=SC&c={$class->forum['cat_id']}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}&act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
"<a href='{$class->base_url}&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>",
);
$this->title = $ibforums->lang['editing_post'].' '.$this->topic['title'];
$print->add_output("$class->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
'JS' => 1,
'NAV' => $this->nav,
) );
}
}
?>
+372
View File
@@ -0,0 +1,372 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > New Post module
| > Module written by Matt Mecham
| > Date started: 17th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $mod_topic = array();
var $m_group = "";
function post_functions($class) {
global $ibforums, $std, $DB;
// Lets do some tests to make sure that we are allowed to start a new topic
$this->m_group = $ibforums->member['mgroup'];
if (! $ibforums->member['g_post_new_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_starting') );
}
if ($class->forum['start_perms'] != '*')
{
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['start_perms'] ) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_starting') );
}
}
}
function process($class) {
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
//-------------------------------------------------
// Parse the post, and check for any errors.
//-------------------------------------------------
$this->post = $class->compile_post();
//-------------------------------------------------
// check to make sure we have a valid topic title
//-------------------------------------------------
$ibforums->input['TopicTitle'] = str_replace( "<br>", "", $ibforums->input['TopicTitle'] );
$ibforums->input['TopicTitle'] = trim(stripslashes($ibforums->input['TopicTitle']));
if ( (strlen($ibforums->input['TopicTitle']) < 2) or (!$ibforums->input['TopicTitle']) )
{
$class->obj['post_errors'] = 'no_topic_title';
}
if ( strlen($HTTP_POST_VARS['TopicTitle']) > 64 )
{
$class->obj['post_errors'] = 'topic_title_long';
}
//-------------------------------------------------
// If we don't have any errors yet, parse the upload
//-------------------------------------------------
if ($class->obj['post_errors'] == "")
{
$this->upload = $class->process_upload();
}
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") ) {
// Show the form again
$this->show_form($class);
} else {
$this->add_new_topic($class);
}
}
function add_new_topic($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Fix up the topic title
//-------------------------------------------------
if ($ibforums->vars['etfilter_punct'])
{
$ibforums->input['TopicTitle'] = preg_replace( "/\?{1,}/" , "?" , $ibforums->input['TopicTitle'] );
$ibforums->input['TopicTitle'] = preg_replace( "/(&#33;){1,}/" , "&#33;", $ibforums->input['TopicTitle'] );
}
if ($ibforums->vars['etfilter_shout'])
{
$ibforums->input['TopicTitle'] = ucwords(strtolower($ibforums->input['TopicTitle']));
}
$ibforums->input['TopicTitle'] = $class->parser->bad_words( $ibforums->input['TopicTitle'] );
$ibforums->input['TopicDesc'] = $class->parser->bad_words( $ibforums->input['TopicDesc'] );
$pinned = 0;
$state = 'open';
if ( ($ibforums->input['mod_options'] != "") or ($ibforums->input['mod_options'] != 'nowt') )
{
if ($ibforums->input['mod_options'] == 'pin')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['pin_topic'] == 1)
{
$pinned = 1;
$class->moderate_log('Pinned topic from post form', $ibforums->input['TopicTitle']);
}
}
else if ($ibforums->input['mod_options'] == 'close')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['close_topic'] == 1)
{
$state = 'closed';
$class->moderate_log('Closed topic from post form', $ibforums->input['TopicTitle']);
}
}
}
//-------------------------------------------------
// Build the master array
//-------------------------------------------------
$this->topic = array(
'title' => $ibforums->input['TopicTitle'],
'description' => $ibforums->input['TopicDesc'] ,
'state' => $state,
'posts' => 0,
'starter_id' => $ibforums->member['id'],
'starter_name' => $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'],
'start_date' => time(),
'last_poster_id' => $ibforums->member['id'],
'last_poster_name' => $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'],
'last_post' => time(),
'icon_id' => $ibforums->input['iconid'],
'author_mode' => $ibforums->member['id'] ? 1 : 0,
'poll_state' => 0,
'last_vote' => 0,
'views' => 0,
'forum_id' => $class->forum['id'],
'approved' => $class->obj['moderate'] ? 0 : 1,
'pinned' => $pinned,
);
//-------------------------------------------------
// Insert the topic into the database to get the
// last inserted value of the auto_increment field
// follow suit with the post
//-------------------------------------------------
$db_string = $DB->compile_db_insert_string( $this->topic );
$DB->query("INSERT INTO ibf_topics (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['topic_id'] = $DB->get_insert_id();
$this->topic['tid'] = $this->post['topic_id'];
/*---------------------------------------------------*/
// Update the post info with the upload array info
$this->post['attach_id'] = $this->upload['attach_id'];
$this->post['attach_type'] = $this->upload['attach_type'];
$this->post['attach_hits'] = $this->upload['attach_hits'];
$this->post['attach_file'] = $this->upload['attach_file'];
$this->post['new_topic'] = 1;
$db_string = $DB->compile_db_insert_string( $this->post );
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['pid'] = $DB->get_insert_id();
if ($class->obj['moderate'])
{
// Redirect them with a message telling them the post has to be previewed first
$print->redirect_screen( $ibforums->lang['moderate_topic'], "act=SF&f={$class->forum['id']}" );
}
//-------------------------------------------------
// If we are still here, lets update the
// board/forum stats
//-------------------------------------------------
$class->forum['last_title'] = $this->topic['title'];
$class->forum['last_id'] = $this->topic['tid'];
$class->forum['last_post'] = time();
$class->forum['last_poster_name'] = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
$class->forum['last_poster_id'] = $ibforums->member['id'];
$class->forum['topics']++;
// Update the database
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
"last_id='" .$class->forum['last_id'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"topics='" .$class->forum['topics'] ."' ".
"WHERE id='" .$class->forum['id'] ."'");
$DB->query("UPDATE ibf_stats SET TOTAL_TOPICS=TOTAL_TOPICS+1");
//-------------------------------------------------
// If we are a member, lets update thier last post
// date and increment their post count.
//-------------------------------------------------
$pcount = "";
if ($ibforums->member['id'])
{
if ($class->forum['inc_postcount'])
{
// Increment the users post count
$pcount = "posts=posts+1, ";
}
$ibforums->member['last_post'] = time();
$DB->query("UPDATE ibf_members SET ".$pcount.
"last_post='" .$ibforums->member['last_post'] ."'".
"WHERE id='" .$ibforums->member['id']."'");
}
//-------------------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
$std->boink_it($class->base_url."&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}");
}
function show_form(&$class) {
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
// Sort out the "raw" textarea input and make it safe incase
// we have a <textarea> tag in the raw post var.
$raw_post = isset($HTTP_POST_VARS['Post']) ? $HTTP_POST_VARS['Post'] : "";
$topic_title = isset($HTTP_POST_VARS['TopicTitle']) ? $ibforums->input['TopicTitle'] : "";
$topic_desc = isset($HTTP_POST_VARS['TopicDesc']) ? $ibforums->input['TopicDesc'] : "";
if (isset($raw_post))
{
$raw_post = preg_replace( "/<textarea>/", "&lt;textarea>", $raw_post );
$raw_post = str_replace( '$' , "&#036;" , $raw_post );
$raw_post = str_replace( '<%', "&lt;%" , $raw_post );
$raw_post = stripslashes($raw_post);
}
// Do we have any posting errors?
if ($class->obj['post_errors'])
{
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
}
if ($class->obj['preview_post'])
{
$class->output .= $class->html->preview( $class->parser->convert( array( 'TEXT' => $this->post['post'], 'CODE' => $class->forum['use_ibc'], 'SMILIES' => $ibforums->input['enableemo'], 'HTML' => $class->forum['use_html']) ) );
}
$class->check_upload_ability();
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '01' ) ) );
//---------------------------------------
// START TABLE
//---------------------------------------
$class->output .= $class->html->table_structure();
//---------------------------------------
$topic_title = $class->html->topictitle_fields( array( TITLE => $topic_title, DESC => $topic_desc ) );
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_new']} {$class->forum['name']}");
$name_fields = $class->html_name_field();
$post_box = $class->html_post_body( $raw_post );
$mod_options = $class->mod_options();
$end_form = $class->html->EndForm( $ibforums->lang['submit_new'] );
$post_icons = $class->html_post_icons();
if ($class->obj['can_upload'])
{
$upload_field = $class->html->Upload_field( $ibforums->member['g_attach_max'] * 1024 );
}
//---------------------------------------
$class->output = preg_replace( "/<!--START TABLE-->/" , "$start_table" , $class->output );
$class->output = preg_replace( "/<!--NAME FIELDS-->/" , "$name_fields" , $class->output );
$class->output = preg_replace( "/<!--POST BOX-->/" , "$post_box" , $class->output );
$class->output = preg_replace( "/<!--POST ICONS-->/" , "$post_icons" , $class->output );
$class->output = preg_replace( "/<!--UPLOAD FIELD-->/", "$upload_field" , $class->output );
$class->output = preg_replace( "/<!--MOD OPTIONS-->/" , "$mod_options" , $class->output );
$class->output = preg_replace( "/<!--END TABLE-->/" , "$end_form" , $class->output );
$class->output = preg_replace( "/<!--TOPIC TITLE-->/" , "$topic_title" , $class->output );
//---------------------------------------
$class->html_add_smilie_box();
$this->nav = array( "<a href='{$class->base_url}&act=SC&c={$class->forum['cat_id']}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}&act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
);
$this->title = $ibforums->lang['posting_new_topic'];
$print->add_output("$class->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
'JS' => 1,
'NAV' => $this->nav,
) );
}
}
?>
+972
View File
@@ -0,0 +1,972 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Text processor module
| > Module written by Matt Mecham
|
+--------------------------------------------------------------------------
*/
class post_parser {
var $error = "";
var $image_count = 0;
var $emoticon_count = 0;
var $quote_html = array();
var $quote_open = 0;
var $quote_closed = 0;
var $quote_error = 0;
var $emoticons = "";
var $badwords = "";
function smilie_length_sort($a, $b)
{
if ( strlen($a['typed']) == strlen($b['typed']) )
{
return 0;
}
return ( strlen($a['typed']) > strlen($b['typed']) ) ? -1 : 1;
}
function word_length_sort($a, $b)
{
if ( strlen($a['type']) == strlen($b['type']) )
{
return 0;
}
return ( strlen($a['type']) > strlen($b['type']) ) ? -1 : 1;
}
function post_parser($load=0)
{
global $ibforums, $DB;
if ($load != 0)
{
// Pre-load the bad words
$DB->query("SELECT * from ibf_badwords");
if ( $DB->get_num_rows() )
{
while ( $r = $DB->fetch_row() )
{
$this->badwords[] = array( 'type' => stripslashes($r['type']),
'swop' => stripslashes($r['swop']),
'm_exact' => $r['m_exact'],
);
}
}
// Pre-load the smilies
$this->emoticons = array();
$DB->query("SELECT typed, image from ibf_emoticons");
if ( $DB->get_num_rows() )
{
while ( $r = $DB->fetch_row() )
{
$this->emoticons[] = array( 'typed' => stripslashes($r['typed']),
'image' => stripslashes($r['image']),
'clickable' => $r['clickable'],
);
}
}
}
}
/**************************************************/
// convert:
// Parses raw text into smilies, HTML and iB CODE
/**************************************************/
function convert($in=array( 'TEXT' => "", 'SMILIES' => 0, 'CODE' => 0, 'SIGNATURE' => 0, 'HTML' => 0)) {
global $ibforums, $DB;
$txt = $in['TEXT'];
//--------------------------------------
// Returns any errors as $this->error
//--------------------------------------
// Remove session id's from any post
$txt = preg_replace( "#[?&;]s=([0-9][a-z][A-Z]){32}#", "", $txt );
//--------------------------------------
// convert <br> to \n
//--------------------------------------
$txt = preg_replace( "/<br>|<br\s*\/>/", "\n", $txt );
//--------------------------------------
// Are we parsing iB_CODE and do we have either '[' or ']' in the
// text we are processing?
//--------------------------------------
if ( $in['CODE'] == 1 ) {
//--------------------------------------
// Auto parse URLs
//--------------------------------------
$txt = preg_replace( "#(^|\s)((http|https|news|ftp)://\w+\S+)#ie" , "\$this->regex_build_url(array('html' => '\\2', 'show' => '\\2', 'st' => '\\1'))", $txt );
//---------------------------------
// Do [CODE] tag
//---------------------------------
$txt = preg_replace( "#\[code\](.+?)\[/code\]#ies", "\$this->regex_code_tag('\\1')", $txt );
//---------------------------------
// Do [QUOTE(name,date)] tags
//---------------------------------
// Find the first, and last quote tag (greedy match)...
$txt = preg_replace( "#(\[quote.*\].*\[/quote\])#ies" , "\$this->regex_parse_quotes('\\1')" , $txt );
/***********************************************/
// If we are not parsing a siggie, lets have a bash
// at the [PHP] [SQL] and [HTML] tags.
/***********************************************/
if ($in['SIGNATURE'] != 1) {
$txt = preg_replace( "#\[sql\](.+?)\[/sql\]#ies" , "\$this->regex_sql_tag('\\1')" , $txt );
$txt = preg_replace( "#\[html\](.+?)\[/html\]#ies" , "\$this->regex_html_tag('\\1')" , $txt );
// [LIST] [*] [/LIST]
//-------------------------
$txt = preg_replace( "#\[list\]#i" , "<ul>" , $txt );
$txt = preg_replace( "#\[\*\]#" , "<li>" , $txt );
$txt = preg_replace( "#\[/list\]#i" , "</ul>", $txt );
}
//---------------------------------
// Do [IMG] [FLASH] tags
//---------------------------------
if ($ibforums->vars['allow_images'])
{
$txt = preg_replace( "#\[img\](.+?)\[/img\]#ie" , "\$this->regex_check_image('\\1')" , $txt );
$txt = preg_replace( "#(\[flash=)(\S+?)(\,)(\S+?)(\])(\S+?)(\[\/flash\])#ie", "\$this->regex_check_flash('\\2','\\4','\\6')", $txt );
}
// Start off with the easy stuff
$txt = preg_replace( "#\[b\](.+?)\[/b\]#is", "<b>\\1</b>", $txt );
$txt = preg_replace( "#\[i\](.+?)\[/i\]#is", "<i>\\1</i>", $txt );
$txt = preg_replace( "#\[u\](.+?)\[/u\]#is", "<u>\\1</u>", $txt );
$txt = preg_replace( "#\[s\](.+?)\[/s\]#is", "<s>\\1</s>", $txt );
// (c) (r) and (tm)
$txt = preg_replace( "#\(c\)#i" , "&copy;" , $txt );
$txt = preg_replace( "#\(tm\)#i" , "&#153;" , $txt );
$txt = preg_replace( "#\(r\)#i" , "&reg;" , $txt );
// font size, colour and font style
// [font=courier]Text here[/font] [size=6]Text here[/size] [color=red]Text here[/color]
while ( preg_match( "#\[size=([^\]]+)\](.+?)\[/size\]#ies", $txt ) )
{
$txt = preg_replace( "#\[size=([^\]]+)\](.+?)\[/size\]#ies" , "\$this->regex_font_attr(array('s'=>'size','1'=>'\\1','2'=>'\\2'))", $txt );
}
while ( preg_match( "#\[font=([^\]]+)\](.*?)\[/font\]#ies", $txt ) )
{
$txt = preg_replace( "#\[font=([^\]]+)\](.*?)\[/font\]#ies" , "\$this->regex_font_attr(array('s'=>'font','1'=>'\\1','2'=>'\\2'))", $txt );
}
while( preg_match( "#\[color=([^\]]+)\](.+?)\[/color\]#ies", $txt ) )
{
$txt = preg_replace( "#\[color=([^\]]+)\](.+?)\[/color\]#ies" , "\$this->regex_font_attr(array('s'=>'col' ,'1'=>'\\1','2'=>'\\2'))", $txt );
}
// email tags
// [email]matt@index.com[/email] [email=matt@index.com]Email me[/email]
$txt = preg_replace( "#\[email\](\S+?)\[/email\]#i" , "<a href='mailto:\\1'>\\1</a>", $txt );
$txt = preg_replace( "#\[email\s*=\s*\&quot\;([\.\w\-]+\@[\.\w\-]+\.[\.\w\-]+)\s*\&quot\;\s*\](.*?)\[\/email\]#i" , "<a href='mailto:\\1'>\\2</a>", $txt );
$txt = preg_replace( "#\[email\s*=\s*([\.\w\-]+\@[\.\w\-]+\.[\w\-]+)\s*\](.*?)\[\/email\]#i" , "<a href='mailto:\\1'>\\2</a>", $txt );
// url tags
// [url]http://www.index.com[/url] [url=http://www.index.com]ibforums![/url]
$txt = preg_replace( "#\[url\](\S+?)\[/url\]#ie" , "\$this->regex_build_url(array('html' => '\\1', 'show' => '\\1'))", $txt );
$txt = preg_replace( "#\[url\s*=\s*\&quot\;\s*(\S+?)\s*\&quot\;\s*\](.*?)\[\/url\]#ie" , "\$this->regex_build_url(array('html' => '\\1', 'show' => '\\2'))", $txt );
$txt = preg_replace( "#\[url\s*=\s*(\S+?)\s*\](.*?)\[\/url\]#ie" , "\$this->regex_build_url(array('html' => '\\1', 'show' => '\\2'))", $txt );
}
// Swop \n back to <br>
$txt = preg_replace( "/\n/", "<br>", $txt );
//+---------------------------------------------------------------------------------------------------
// Parse smilies (disallow smilies in siggies, or we'll have to query the DB for each post
// and each signature when viewing a topic, not something that we really want to do.
//+---------------------------------------------------------------------------------------------------
if ($in['SMILIES'] != 0 and $in['SIGNATURE'] == 0) {
if ( ! is_array($this->emoticons) )
{
$DB->query("SELECT typed, image from ibf_emoticons");
$this->emoticons = array();
if ( $DB->get_num_rows() )
{
while ( $r = $DB->fetch_row() )
{
$this->emoticons[] = array( 'typed' => stripslashes($r['typed']),
'image' => stripslashes($r['image']),
'clickable' => $r['clickable'],
);
}
}
}
usort($this->emoticons, array( 'post_parser', 'smilie_length_sort' ) );
if ( count($this->emoticons) > 0 )
{
foreach($this->emoticons as $a_id => $row)
{
$code = $row['typed'];
$image = $row['image'];
/*$code = str_replace( "&", "&amp;", $code );
$code = str_replace( "<", "&lt;" , $code );
$code = str_replace( ">", "&gt;" , $code );
$code = str_replace( "\"", "&quot;", $code);
$code = str_replace( "'", "&#039;" , $code);
$code = str_replace( "!", "&#033;" , $code);
$code = str_replace( "|", "&#124;" , $code);*/
// Make safe for regex
$code = preg_quote($code, "/");
$txt = preg_replace( "!(?<=[^\w&])$code(?=.\W|\W.|\W$)!ei", "\$this->convert_emoticon('$code', '$image')", ' '.$txt.' ' );
}
}
if ($ibforums->vars['max_emos'])
{
if ($this->emoticon_count > $ibforums->vars['max_emos'])
{
$this->error = 'too_many_emoticons';
}
}
}
$txt = $this->bad_words($txt);
if ($in['HTML'] == 1)
{
$txt = str_replace( "&lt;" ,"<" , $txt );
$txt = str_replace( "&gt;" ,">" , $txt );
$txt = str_replace( "&quot;" ,"\"", $txt);
$txt = str_replace( "&#039;" ,"'" , $txt);
$txt = str_replace( "&amp;" ,"&" , $txt );
}
return $txt; //trim($txt);
}
/**************************************************/
// Badwords:
// Swops naughty, naugty words and stuff
/**************************************************/
function bad_words($text = "")
{
global $DB, $ibforums;
if ($text == "")
{
return "";
}
//--------------------------------
if ( ! is_array($this->badwords) )
{
$DB->query("SELECT * from ibf_badwords");
$this->badwords = array();
if ( $DB->get_num_rows() )
{
while ( $r = $DB->fetch_row() )
{
$this->badwords[] = array( 'type' => stripslashes($r['type']),
'swop' => stripslashes($r['swop']),
'm_exact' => $r['m_exact'],
);
}
}
}
usort($this->badwords, array( 'post_parser', 'word_length_sort' ) );
if ( count($this->badwords) > 0 )
{
foreach($this->badwords as $idx => $r)
{
if ($r['swop'] == "")
{
$replace = '######';
}
else
{
$replace = $r['swop'];
}
//---------------------------
$r['type'] = preg_quote($r['type'], "/");
//---------------------------
if ($r['m_exact'] == 1)
{
$text = preg_replace( "/(^|\b)".$r['type']."(\b|!|\?|\.|,|$)/i", "$replace", $text );
}
else
{
$text = preg_replace( "/".$r['type']."/i", "$replace", $text );
}
}
}
return $text;
}
/**************************************************/
// unconvert:
// Parses the HTML back into plain text
/**************************************************/
function unconvert($txt="", $code=1, $html=0) {
if ($code == 1)
{
$txt = preg_replace( "#<!--emo&(.+?)-->.+?<!--endemo-->#", "\\1" , $txt );
$txt = preg_replace( "#<!--sql-->(.+?)<!--sql1-->(.+?)<!--sql2-->(.+?)<!--sql3-->#e" , "\$this->unconvert_sql(\"\\2\")", $txt);
$txt = preg_replace( "#<!--html-->(.+?)<!--html1-->(.+?)<!--html2-->(.+?)<!--html3-->#e", "\$this->unconvert_htm(\"\\2\")", $txt);
$txt = preg_replace( "#<!--Flash (.+?)-->.+?<!--End Flash-->#e" , "\$this->unconvert_flash('\\1')", $txt );
$txt = preg_replace( "#<img src=[\"'](\S+?)['\"].+?".">#" , "\[IMG\]\\1\[/IMG\]" , $txt );
$txt = preg_replace( "#<a href=[\"'](http://|https://|ftp://|news://)?(\S+?)['\"].+?".">(.+?)</a>#" , "\[URL=\\1\\2\]\\3\[/URL\]" , $txt );
$txt = preg_replace( "#<a href=[\"']mailto:(.+?)['\"]>(.+?)</a>#" , "\[EMAIL=\\1\]\\2\[/EMAIL\]" , $txt );
$txt = preg_replace( "#<i>(.+?)</i>#" , "\[i\]\\1\[/i\]" , $txt );
$txt = preg_replace( "#<b>(.+?)</b>#" , "\[b\]\\1\[/b\]" , $txt );
$txt = preg_replace( "#<s>(.+?)</s>#" , "\[s\]\\1\[/s\]" , $txt );
$txt = preg_replace( "#<u>(.+?)</u>#" , "\[u\]\\1\[/u\]" , $txt );
$txt = preg_replace( "#<ul>#" , "\[LIST\]" , $txt );
$txt = preg_replace( "#<li>#" , "\[*\]" , $txt );
$txt = preg_replace( "#</ul>#", "\[/LIST\]" , $txt );
$txt = preg_replace( "#<!--me&(.+?)-->(.+?)<!--e--me-->#e" , "\$this->unconvert_me('\\1', '\\2')", $txt );
$txt = preg_replace( "#<span style=['\"]font-size:(.+?)pt;line-height:100%['\"]>(.+?)</span>#e" , "\$this->unconvert_size('\\1', '\\2')", $txt );
$txt = preg_replace( "#<span style=['\"]color:(.+?)['\"]>(.+?)</span>#" , "\[color=\\1\]\\2\[/color\]", $txt );
$txt = preg_replace( "#<span style=['\"]font-family:(.+?)['\"]>(.+?)</span>#" , "\[font=\\1\]\\2\[/font\]" , $txt );
$txt = preg_replace( "#<!--c1-->(.+?)<!--ec1-->#", '[CODE]' , $txt );
$txt = preg_replace( "#<!--c2-->(.+?)<!--ec2-->#", '[/CODE]' , $txt );
$txt = preg_replace( "#<!--QuoteBegin-->(.+?)<!--QuoteEBegin-->#" , '[QUOTE]' , $txt );
$txt = preg_replace( "#<!--QuoteBegin--(.+?)\+(.+?)-->(.+?)<!--QuoteEBegin-->#" , "[QUOTE=\\1,\\2]" , $txt );
$txt = preg_replace( "#<!--QuoteEnd-->(.+?)<!--QuoteEEnd-->#" , '[/QUOTE]' , $txt );
// Tidy up the end quote stuff
$txt = preg_replace( "#(\[/QUOTE\])\s*?<br>\s*#si", "\\1\n", $txt );
$txt = preg_replace( "#<!--EDIT\|.+?\|.+?-->#" , "" , $txt );
}
if ($html == 1)
{
$txt = str_replace( "&#39;", "'", $txt);
}
$txt = preg_replace( "#<br>#", "\n", $txt );
return trim(stripslashes($txt));
}
//+-----------------------------------------------------------------------------------------
//+-----------------------------------------------------------------------------------------
// UNCONVERT FUNCTIONS
//+-----------------------------------------------------------------------------------------
//+-----------------------------------------------------------------------------------------
function unconvert_size($size="", $text="") {
$size -= 7;
return '[SIZE='.$size.']'.$text.'[/SIZE]';
}
function unconvert_flash($flash="") {
$f_arr = explode( "+", $flash );
return '[FLASH='.$f_arr[0].','.$f_arr[1].']'.$f_arr[2].'[/FLASH]';
}
function unconvert_me($name="", $text="") {
$text = preg_replace( "#<span id='ME'><center>(.+?)</center></span>#", "\\1" , $text );
$text = preg_replace( "#$name#", "", $text );
return '[ME='.$name.']'.$text.'[/ME]';
}
function unconvert_sql($sql="") {
$sql = stripslashes($sql);
$sql = preg_replace( "#<span style='.+?'>(.+?)</span>#", "\\1", $sql );
$sql = preg_replace( "#\s*$#" , "", $sql );
return '[SQL]'.$sql.'[/SQL]';
}
function unconvert_htm($html="") {
$html = stripslashes($html);
$html = preg_replace( "#<span style='.+?'>(.+?)</span>#", "\\1", $html );
$html = preg_replace( "#\s*$#" , "", $html );
return '[HTML]'.$html.'[/HTML]';
}
//+-----------------------------------------------------------------------------------------
//+-----------------------------------------------------------------------------------------
// CONVERT FUNCTIONS
//+-----------------------------------------------------------------------------------------
//+-----------------------------------------------------------------------------------------
/**************************************************/
// convert_emoticon:
// replaces the text with the emoticon image
/**************************************************/
function convert_emoticon($code="", $image="") {
global $ibforums;
if (!$code or !$image) return;
// Remove slashes added by preg_quote
$code = stripslashes($code);
$this->emoticon_count++;
return "<!--emo&$code--><img src='{$ibforums->vars['EMOTICONS_URL']}/$image' border='0' valign='absmiddle' alt='$image'><!--endemo-->";
}
/**************************************************/
// wrap style:
// code and quote table HTML generator
/**************************************************/
function wrap_style( $in=array() ) {
global $ibforums;
if (! isset($in['TYPE']) ) $in['TYPE'] = 'id';
if (! isset($in['CSS']) ) $in['CSS'] = 'postcolor';
if (! isset($in['STYLE']) ) $in['STYLE'] = 'QUOTE';
//-----------------------------
// This returns two array elements:
// START: Contains the HTML code for the start wrapper
// END : Contains the HTML code for the end wrapper
//-----------------------------
$possible_use = array( 'CODE' => array( 'CODE', 'CODE' ),
'QUOTE' => array( 'QUOTE', 'QUOTE' ),
'SQL' => array( 'CODE' , 'SQL'),
'HTML' => array( 'CODE' , 'HTML'),
'PHP' => array( 'CODE' , 'PHP')
);
return array( 'START' => "</span><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><b>{$possible_use[$in[STYLE]][1]}</b> {$in[EXTRA]}</td></tr><tr><td id='{$possible_use[ $in[STYLE] ][0]}'>",
'END' => "</td></tr></table><span {$in[TYPE]}='{$in[CSS]}'>"
);
}
/**************************************************/
// regex_html_tag: HTML syntax highlighting
//
/**************************************************/
function regex_html_tag($html="") {
if ($html == "") return;
// Ensure that spacing is preserved
// Too many embedded code/quote/html/sql tags can crash Opera and Moz
if (preg_match( "/\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\]/i", $html) ) {
return $default;
}
//$html = preg_replace( "#\s{2}#", " &nbsp;", $html );
// Knock off any preceeding newlines (which have
// since been converted into <br>)
//$html = nl2br($html);
$html = preg_replace( "/^<br>/", "", $html );
$html = preg_replace( "/^\s+/" , "", $html );
$html = preg_replace( "#&lt;([^&<>]+)&gt;#" , "&lt;<span style='color:blue'>\\1</span>&gt;" , $html ); //Matches <tag>
$html = preg_replace( "#&lt;([^&<>]+)=#" , "&lt;<span style='color:blue'>\\1</span>=" , $html ); //Matches <tag
$html = preg_replace( "#&lt;/([^&]+)&gt;#" , "&lt;/<span style='color:blue'>\\1</span>&gt;" , $html ); //Matches </tag>
$html = preg_replace( "!=(&quot;|&#39;)(.+?)(&quot;|&#39;)(\s|&gt;)!" , "=\\1<span style='color:orange'>\\2</span>\\3\\4" , $html ); //Matches ='this'
$html = preg_replace( "!&#60;&#33;--(.+?)--&#62;!" , "&lt;&#33;<span style='color:red'>--\\1--</span>&gt;", $html );
$wrap = $this->wrap_style( array( 'STYLE' => 'HTML' ) );
return "<!--html-->{$wrap['START']}<!--html1-->$html<!--html2-->{$wrap['END']}<!--html3-->";
}
/**************************************************/
// regex_sql_tag: SQL syntax highlighting
//
/**************************************************/
function regex_sql_tag($sql="") {
if ($sql == "") return;
// Too many embedded code/quote/html/sql tags can crash Opera and Moz
if (preg_match( "/\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\]/i", $sql) ) {
return $default;
}
// Knock off any preceeding newlines (which have
// since been converted into <br>)
$sql = preg_replace( "/^<br>/", "", $sql );
$sql = preg_replace( "/^\s+/" , "", $sql );
// Make certain regex work..
if (! preg_match( "/\s+$/" , $sql) )
{
$sql = $sql.' ';
}
$sql = preg_replace( "#(=|\+|\-|&gt;|&lt;|~|==|\!=|LIKE|NOT LIKE|REGEXP)#i" , "<span style='color:orange'>\\1</span>", $sql );
$sql = preg_replace( "#(MAX|AVG|SUM|COUNT|MIN)\(#i" , "<span style='color:blue'>\\1</span>(" , $sql );
$sql = preg_replace( "!(&quot;|&#39;|&#039;)(.+?)(&quot;|&#39;|&#039;)!i" , "<span style='color:red'>\\1\\2\\3</span>" , $sql );
$sql = preg_replace( "#\s{1,}(AND|OR)\s{1,}#i" , " <span style='color:blue'>\\1</span> " , $sql );
$sql = preg_replace( "#(WHERE|MODIFY|CHANGE|AS|DISTINCT|IN|ASC|DESC|ORDER BY)\s{1,}#i" , "<span style='color:green'>\\1</span> " , $sql );
$sql = preg_replace( "#LIMIT\s*(\d+)\s*,\s*(\d+)#i" , "<span style='color:green'>LIMIT</span> <span style='color:orange'>\\1, \\2</span>" , $sql );
$sql = preg_replace( "#(FROM|INTO)\s{1,}(\S+?)\s{1,}#i" , "<span style='color:green'>\\1</span> <span style='color:orange'>\\2</span> ", $sql );
$sql = preg_replace( "#(SELECT|INSERT|UPDATE|DELETE|ALTER TABLE|DROP)#i" , "<span style='color:blue;font-weight:bold'>\\1</span>" , $sql );
$html = $this->wrap_style( array( 'STYLE' => 'SQL' ) );
return "<!--sql-->{$html['START']}<!--sql1-->{$sql}<!--sql2-->{$html['END']}<!--sql3-->";
}
/**************************************************/
// regex_code_tag: Builds this code tag HTML
//
/**************************************************/
function regex_code_tag($txt="") {
global $ibforums;
$default = "\[code\]$txt\[/code\]";
if ($txt == "") return;
// Too many embedded code/quote/html/sql tags can crash Opera and Moz
if (preg_match( "/\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\]/i", $txt) ) {
return $default;
}
// Take a stab at removing most of the common
// smilie characters.
$txt = preg_replace( "#&lt;#" , "&#60;", $txt );
$txt = preg_replace( "#&gt;#" , "&#62;", $txt );
$txt = preg_replace( "#&quot;#" , "&#34;", $txt );
$txt = preg_replace( "#\s{1};#" , "&#59;", $txt );
$txt = preg_replace( "#:#" , "&#58;", $txt );
$txt = preg_replace( "#\[#" , "&#91;", $txt );
$txt = preg_replace( "#\]#" , "&#93;", $txt );
$txt = preg_replace( "#\)#" , "&#41;", $txt );
$txt = preg_replace( "#\(#" , "&#40;", $txt );
$txt = preg_replace( "#\r#" , "<br>", $txt );
$txt = preg_replace( "#\n#" , "<br>", $txt );
// Ensure that spacing is preserved
$txt = preg_replace( "#\s{2}#", " &nbsp;", $txt );
$html = $this->wrap_style( array( 'STYLE' => 'CODE' ) );
return "<!--c1-->{$html['START']}<!--ec1-->$txt<!--c2-->{$html['END']}<!--ec2-->";
}
/****************************************************************************************************/
// regex_parse_quotes: Builds this quote tag HTML
// [QUOTE] .. [/QUOTE] - allows for embedded quotes
/**************************************************/
function regex_parse_quotes($the_txt="") {
if ($the_txt == "") return;
$txt = $the_txt;
// Too many embedded code/quote/html/sql tags can crash Opera and Moz
/*if (preg_match( "/\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\].+?\[(quote|code|html|sql)\]/is", $txt) ) {
$this->quote_error++;
return $txt;
}*/
$this->quote_html = $this->wrap_style( array( 'STYLE' => 'QUOTE' ) );
$txt = preg_replace( "#\[quote\]#ie" , "\$this->regex_simple_quote_tag()" , $txt );
$txt = preg_replace( "#\[quote=(.+?),\s*(.+?)\]#ie" , "\$this->regex_quote_tag('\\1', '\\2')" , $txt );
$txt = preg_replace( "#\[/quote\]#ie" , "\$this->regex_close_quote()" , $txt );
$txt = preg_replace( "/\n/", "<br>", $txt );
if ( ($this->quote_open == $this->quote_closed) and ($this->quote_error == 0) ) {
// Preserve spacing
$txt = preg_replace( "#(<!--QuoteEBegin-->.+?<!--QuoteEnd-->)#es", "\$this->regex_preserve_spacing('\\1')", trim($txt) );
return $txt;
} else {
return $the_txt;
}
}
/**************************************************/
// regex_preserve_spacing: keeps double spaces
// without CSS killing <pre> tags
/**************************************************/
function regex_preserve_spacing($txt="") {
$txt = preg_replace( "#\s{2}#", " &nbsp;", trim($txt) );
return $txt;
}
/**************************************************/
// regex_simple_quote_tag: Builds this quote tag HTML
// [QUOTE] .. [/QUOTE]
/**************************************************/
function regex_simple_quote_tag() {
global $ibforums;
$this->quote_open++;
return "<!--QuoteBegin-->{$this->quote_html['START']}<!--QuoteEBegin-->";
}
/**************************************************/
// regex_close_quote: closes a quote tag
//
/**************************************************/
function regex_close_quote() {
if ($this->quote_open == 0) {
$this->quote_error++;
return;
}
$this->quote_closed++;
return "<!--QuoteEnd-->{$this->quote_html['END']}<!--QuoteEEnd-->";
}
/**************************************************/
// regex_quote_tag: Builds this quote tag HTML
// [QUOTE=Matthew,14 February 2002]
/**************************************************/
function regex_quote_tag($name="", $date="") {
global $ibforums;
$default = "\[quote=$name,$date\]";
$this->quote_open++;
$html = $this->wrap_style( array( 'STYLE' => 'QUOTE', 'EXTRA' => "($name @ $date)" ) );
$extra = "--$name+$date";
return "<!--QuoteBegin".$extra."-->{$html['START']}<!--QuoteEBegin-->";
}
/****************************************************************************************************/
// regex_check_flash: Checks, and builds the <object>
// html.
/**************************************************/
function regex_check_flash($width="", $height="", $url="") {
global $ibforums;
$default = "\[flash=$width,$height\]$url\[/flash\]";
if (!$ibforums->vars['allow_flash']) {
return $default;
}
if ($width > $ibforums->vars['max_w_flash']) {
$this->error = 'flash_too_big';
return $default;
}
if ($height > $ibforums->vars['max_h_flash']) {
$this->error = 'flash_too_big';
return $default;
}
if (!preg_match( "/^http:\/\/(\S+)\.swf$/i", $url) ) {
$this->error = 'flash_url';
return $default;
}
return "<!--Flash $width+$height+$url--><OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' WIDTH=$width HEIGHT=$height><PARAM NAME=MOVIE VALUE=$url><PARAM NAME=PLAY VALUE=TRUE><PARAM NAME=LOOP VALUE=TRUE><PARAM NAME=QUALITY VALUE=HIGH><EMBED SRC=$url WIDTH=$width HEIGHT=$height PLAY=TRUE LOOP=TRUE QUALITY=HIGH></EMBED></OBJECT><!--End Flash-->";
}
/**************************************************/
// regex_check_image: Checks, and builds the <img>
// html.
/**************************************************/
function regex_check_image($url="") {
global $ibforums;
if (!$url) return;
$url = trim($url);
$default = "[img]".$url."[/img]";
++$this->image_count;
// Make sure we've not overriden the set image # limit
if ($ibforums->vars['max_images'])
{
if ($this->image_count > $ibforums->vars['max_images'])
{
$this->error = 'too_many_img';
return $default;
}
}
// Are they attempting to post a dynamic image, or JS?
if ($ibforums->vars['allow_dynamic_img'] != 1)
{
if (preg_match( "/[?&;]/", $url))
{
$this->error = 'no_dynamic';
return $default;
}
if (preg_match( "/javascript(\:|\s)/i", $url ))
{
$this->error = 'no_dynamic';
return $default;
}
}
// Is the img extension allowed to be posted?
if ($ibforums->vars['img_ext'])
{
$extension = preg_replace( "/^.*\.(\S+)$/", "\\1", $url );
$extension = strtolower($extension);
$ibforums->vars['img_ext'] = strtolower($ibforums->vars['img_ext']);
if (!preg_match( "/$extension(\||$)/", $ibforums->vars['img_ext'] ))
{
$this->error = 'invalid_ext';
return $default;
}
}
// Is it a legitimate image?
if (!preg_match( "/^(http|https|ftp):\/\//i", $url )) {
$this->error = 'no_dynamic';
return $default;
}
// If we are still here....
return "<img src='$url' border='0' alt='user posted image'>";
}
/**************************************************/
// regex_font_attr:
// Returns a string for an /e regexp based on the input
/**************************************************/
function regex_font_attr($IN) {
if (!is_array($IN)) return "";
if ($IN['s'] == 'size')
{
$IN['1'] = $IN['1'] + 7;
if ($IN['1'] > 30)
{
$IN['1'] = 30;
}
return "<span style='font-size:".$IN['1']."pt;line-height:100%'>".$IN['2']."</span>";
}
else if ($IN['s'] == 'col')
{
return "<span style='color:".$IN['1']."'>".$IN['2']."</span>";
}
else if ($IN['s'] == 'font')
{
return "<span style='font-family:".$IN['1']."'>".$IN['2']."</span>";
}
}
/**************************************************/
// regex_build_url: Checks, and builds the a href
// html
/**************************************************/
function regex_build_url($url=array()) {
$skip_it = 0;
// Make sure the last character isn't punctuation.. if it is, remove it and add it to the
// end array
if ( preg_match( "/([\.,\?]|&#33;)$/", $url['html'], $match) )
{
$url['end'] .= $match[1];
$url['html'] = preg_replace( "/([\.,\?]|&#33;)$/", "", $url['html'] );
$url['show'] = preg_replace( "/([\.,\?]|&#33;)$/", "", $url['show'] );
}
// Make sure it's not being used in a closing code/quote/html or sql block
if (preg_match( "/\[\/(html|quote|code|sql)/i", $url['html']) )
{
return $url['html'];
}
// clean up the ampersands
$url['html'] = preg_replace( "/&amp;/" , "&" , $url['html'] );
// Make sure we don't have a JS link
$url['html'] = preg_replace( "/javascript:/i", "java script&#58; ", $url['html'] );
// Do we have http:// at the front?
if ( ! preg_match("#^(http|news|https|ftp|aim)://#", $url['html'] ) )
{
$url['html'] = 'http://'.$url['html'];
}
//-------------------------
// Tidy up the viewable URL
//-------------------------
if (preg_match( "/^<img src/i", $url['show'] )) $skip_it = 1;
$url['show'] = preg_replace( "/&amp;/" , "&" , $url['show'] );
$url['show'] = preg_replace( "/javascript:/i", "javascript&#58; ", $url['show'] );
if (strlen($url['show']) < 55) $skip_it = 1;
// Make sure it's a "proper" url
if (!preg_match( "/^(http|ftp|https|news):\/\//i", $url['show'] )) $skip_it = 1;
$show = $url['show'];
if ($skip_it != 1) {
$stripped = preg_replace( "#^(http|ftp|https|news)://(\S+)$#i", "\\2", $url['show'] );
$uri_type = preg_replace( "#^(http|ftp|https|news)://(\S+)$#i", "\\1", $url['show'] );
$show = $uri_type.'://'.substr( $stripped , 0, 35 ).'...'.substr( $stripped , -15 );
}
return $url['st'] . "<a href='".$url['html']."' target='_blank'>".$show."</a>" . $url['end'];
}
}
?>
+425
View File
@@ -0,0 +1,425 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > New Post module
| > Module written by Matt Mecham
|
+--------------------------------------------------------------------------
*/
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $mod_topic = array();
var $poll_count = 0;
var $poll_choices = "";
var $m_group = "";
function post_functions($class) {
global $ibforums, $std, $DB;
// Lets do some tests to make sure that we are allowed to start a new topic
if (! $ibforums->member['g_post_polls'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
}
if ( ! $class->forum['allow_poll'] )
{
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
}
$this->m_group = $ibforums->member['mgroup'];
if ($class->forum['start_perms'] != '*')
{
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['start_perms'] ) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_start_polls') );
}
}
}
function process($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Parse the post, and check for any errors.
//-------------------------------------------------
$this->post = $class->compile_post();
//-------------------------------------------------
// check to make sure we have a valid topic title
//-------------------------------------------------
if ( (strlen($ibforums->input['TopicTitle']) < 2) or (!$ibforums->input['TopicTitle']) ) {
$class->obj['post_errors'] = 'no_topic_title';
}
if ( strlen($ibforums->input['TopicTitle']) > 64 ) {
$class->obj['post_errors'] = 'topic_title_long';
}
//-------------------------------------------------
// check to make sure we have a correct # of choices
//-------------------------------------------------
$this->poll_choices = $ibforums->input['PollAnswers'];
$this->poll_choices = preg_replace( "/<br><br>/" , "" , $this->poll_choices );
$this->poll_choices = preg_replace( "/<br>/e" , "\$this->regex_count_choices()" , $this->poll_choices );
if ($this->poll_count > 10) {
$class->obj['post_errors'] = 'poll_to_many';
}
if ($this->poll_count < 1) {
$class->obj['post_errors'] = 'poll_not_enough';
}
//-------------------------------------------------
// If we don't have any errors yet, parse the upload
//-------------------------------------------------
if ($class->obj['post_errors'] == "")
{
$this->upload = $class->process_upload();
}
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") ) {
// Show the form again
$this->show_form($class);
} else {
$this->add_new_poll($class);
}
}
function add_new_poll($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Sort out the poll stuff
// This is somewhat contrived, but it has to be
// compatible with the current perl version.
//-------------------------------------------------
$poll_array = array();
$count = 0;
$polls = explode( "<br>", $this->poll_choices );
foreach ($polls as $polling)
{
if ( $polling == "" )
{
continue;
}
$poll_array[] = array( $count , $polling, 0 );
$count++;
}
//-------------------------------------------------
// Fix up the topic title
//-------------------------------------------------
if ($ibforums->vars['etfilter_punct'])
{
$ibforums->input['TopicTitle'] = preg_replace( "/\?{1,}/" , "?" , $ibforums->input['TopicTitle'] );
$ibforums->input['TopicTitle'] = preg_replace( "/(&#33;){1,}/", "&#33;" , $ibforums->input['TopicTitle'] );
}
if ($ibforums->vars['etfilter_shout'])
{
$ibforums->input['TopicTitle'] = ucwords($ibforums->input['TopicTitle']);
}
$ibforums->input['TopicTitle'] = $class->parser->bad_words( $ibforums->input['TopicTitle'] );
$ibforums->input['TopicDesc'] = $class->parser->bad_words( $ibforums->input['TopicDesc'] );
//-------------------------------------------------
// Build the master array
//-------------------------------------------------
$this->topic = array(
'title' => $ibforums->input['TopicTitle'],
'description' => $ibforums->input['TopicDesc'] ,
'state' => 'open',
'posts' => 0,
'starter_id' => $ibforums->member['id'],
'starter_name' => $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'],
'start_date' => time(),
'last_poster_id' => $ibforums->member['id'],
'last_poster_name' => $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'],
'last_post' => time(),
'icon_id' => $ibforums->input['iconid'],
'author_mode' => $ibforums->member['id'] ? 1 : 0,
'poll_state' => $ibforums->input['allow_disc'] == 0 ? 'open' : 'closed',
'last_vote' => 0,
'views' => 0,
'forum_id' => $class->forum['id'],
'approved' => $class->obj['moderate'] ? 0 : 1,
'pinned' => 0,
);
//-------------------------------------------------
// Insert the topic into the database to get the
// last inserted value of the auto_increment field
// follow suit with the post
//-------------------------------------------------
$db_string = $DB->compile_db_insert_string( $this->topic );
$DB->query("INSERT INTO ibf_topics (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['topic_id'] = $DB->get_insert_id();
$this->topic['tid'] = $this->post['topic_id'];
/*---------------------------------------------------*/
// Update the post info with the upload array info
$this->post['attach_id'] = $this->upload['attach_id'];
$this->post['attach_type'] = $this->upload['attach_type'];
$this->post['attach_hits'] = $this->upload['attach_hits'];
$this->post['new_topic'] = 1;
$db_string = $DB->compile_db_insert_string( $this->post );
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['pid'] = $DB->get_insert_id();
//-------------------------------------------------
// Add the poll to the forum_polls table
// if we are moderating this post
//-------------------------------------------------
$db_string = $std->compile_db_string(
array (
'tid' => $this->topic['tid'],
'forum_id' => $class->forum['id'],
'start_date' => time(),
'choices' => addslashes(serialize($poll_array)),
'starter_id' => $ibforums->member['id'],
'votes' => 0,
)
);
$DB->query("INSERT INTO ibf_polls (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
if ($class->obj['moderate'])
{
// Redirect them with a message telling them the post has to be previewed first
$print->redirect_screen( $ibforums->lang['moderate_topic'], "act=SF&f={$class->forum['id']}" );
}
//-------------------------------------------------
// If we are still here, lets update the
// board/forum stats
//-------------------------------------------------
$class->forum['last_title'] = $this->topic['title'];
$class->forum['last_id'] = $this->topic['tid'];
$class->forum['last_post'] = time();
$class->forum['last_poster_name'] = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
$class->forum['last_poster_id'] = $ibforums->member['id'];
$class->forum['topics']++;
// Update the database
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
"last_id='" .$class->forum['last_id'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"topics='" .$class->forum['topics'] ."' ".
"WHERE id='" .$class->forum['id'] ."'");
// At this point in time, we'll scan the database for the correct number
// of topics - if this proves to database intensive, we'll simply increment
// the value stored in the ibf_stats database.
$DB->query("SELECT COUNT(tid) as topic_cnt FROM ibf_topics");
$stats = $DB->fetch_row();
$DB->query("UPDATE ibf_stats SET TOTAL_TOPICS='".$stats['topic_cnt']."'");
//-------------------------------------------------
// If we are a member, lets update thier last post
// date and increment their post count.
//-------------------------------------------------
$pcount = "";
if ($ibforums->member['id'])
{
if ($class->forum['inc_postcount'])
{
// Increment the users post count
$pcount = "posts=posts+1, ";
}
$ibforums->member['last_post'] = time();
$DB->query("UPDATE ibf_members SET ".$pcount.
"last_post='" .$ibforums->member['last_post'] ."'".
"WHERE id='" .$ibforums->member['id']."'");
}
//-------------------------------------------------
// Set a last post time cookie
//-------------------------------------------------
$std->my_setcookie( "LPid", time() );
//-------------------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
$std->boink_it($class->base_url."&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}");
}
function show_form($class) {
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
// Sort out the "raw" textarea input and make it safe incase
// we have a <textarea> tag in the raw post var.
$raw_post = isset($HTTP_POST_VARS['Post']) ? $HTTP_POST_VARS['Post'] : "";
$topic_title = isset($HTTP_POST_VARS['TopicTitle']) ? $HTTP_POST_VARS['TopicTitle'] : "";
$topic_desc = isset($HTTP_POST_VARS['TopicDesc']) ? $HTTP_POST_VARS['TopicDesc'] : "";
$poll = isset($HTTP_POST_VARS['PollAnswers']) ? stripslashes($HTTP_POST_VARS['PollAnswers']) : "";
if (isset($raw_post)) {
$raw_post = preg_replace( "/<textarea>/", "&lt;textarea>", $raw_post );
$raw_post = str_replace( '$', "&#036;", $raw_post );
$raw_post = str_replace( '<%', "&lt;%" , $raw_post );
$raw_post = stripslashes($raw_post);
}
// Do we have any posting errors?
if ($class->obj['post_errors']) {
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
}
if ($class->obj['preview_post']) {
$class->output .= $class->html->preview( $class->parser->convert( array( 'TEXT' => $this->post['post'], 'CODE' => $class->forum['use_ibc'], 'SMILIES' => $ibforums->input['enableemo'], 'HTML' => $class->forum['use_html']) ) );
}
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '11' ), 2 => array( 'f', $class->forum['id']) ) );
//---------------------------------------
// START TABLE
//---------------------------------------
$class->output .= $class->html->table_structure();
//---------------------------------------
$topic_title = $class->html->topictitle_fields( array( TITLE => $topic_title, DESC => $topic_desc ) );
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_poll']} {$class->forum['name']}");
$name_fields = $class->html_name_field();
$post_box = $class->html_post_body( $raw_post );
$mod_options = $class->mod_options();
$poll_box = $class->html->poll_box($poll);
$end_form = $class->html->EndForm( $ibforums->lang['submit_poll'] );
$post_icons = $class->html_post_icons();
if ($class->obj['can_upload'])
{
$upload_field = $class->html->Upload_field( $ibforums->member['g_attach_max'] * 1024 );
}
//---------------------------------------
$class->output = preg_replace( "/<!--START TABLE-->/" , "$start_table" , $class->output );
$class->output = preg_replace( "/<!--NAME FIELDS-->/" , "$name_fields" , $class->output );
$class->output = preg_replace( "/<!--POST BOX-->/" , "$post_box" , $class->output );
$class->output = preg_replace( "/<!--POST ICONS-->/" , "$post_icons" , $class->output );
$class->output = preg_replace( "/<!--UPLOAD FIELD-->/", "$upload_field" , $class->output );
//$class->output = preg_replace( "/<!--MOD OPTIONS-->/" , "$mod_options" , $class->output );
$class->output = preg_replace( "/<!--END TABLE-->/" , "$end_form" , $class->output );
$class->output = preg_replace( "/<!--TOPIC TITLE-->/" , "$topic_title" , $class->output );
$class->output = preg_replace( "/<!--POLL BOX-->/" , "$poll_box" , $class->output );
//---------------------------------------
$class->html_add_smilie_box();
$this->nav = array( "<a href='{$class->base_url}&act=SC&c={$class->forum['cat_id']}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}&act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
);
$this->title = $ibforums->lang['posting_new_topic'];
$print->add_output("$class->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
'JS' => 1,
'NAV' => $this->nav,
) );
}
function regex_count_choices() {
++$this->poll_count;
return "<br>";
}
}
?>
+425
View File
@@ -0,0 +1,425 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Reply with quote library
| > Module written by Matt Mecham
|
+--------------------------------------------------------------------------
*/
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $mod_topic = array();
var $quoted_post = array();
var $quoted_post_author = array();
var $m_group = "";
function post_functions($class) {
global $ibforums, $std, $DB;
// Lets load the topic from the database before we do anything else.
$DB->query("SELECT * FROM ibf_topics WHERE forum_id='".$class->forum['id']."' AND tid='".$ibforums->input['t']."'");
$this->topic = $DB->fetch_row();
// Is it legitimate?
if (! $this->topic['tid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-------------------------------------------------
// Lets do some tests to make sure that we are
// allowed to reply to this topic
//-------------------------------------------------
if ($this->topic['poll_state'] == 'closed' and $ibforums->member['g_is_supadmin'] != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
if ($this->topic['starter_id'] == $ibforums->member['id'])
{
if (! $ibforums->member['g_reply_own_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
if ($this->topic['starter_id'] != $ibforums->member['id'])
{
if (! $ibforums->member['g_reply_own_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
$this->m_group = $ibforums->member['mgroup'];
if ($class->forum['reply_perms'] != '*')
{
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['reply_perms'] ) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
// Is the topic locked?
if ($this->topic['state'] != 'open')
{
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
}
}
function process($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Parse the post, and check for any errors.
//-------------------------------------------------
$this->post = $class->compile_post();
//-------------------------------------------------
// If we have a post to quote, lets sort that now
//-------------------------------------------------
if ($ibforums->input['QPost']) {
$this->quoted_post['post'] = $class->parser->convert( array( 'TEXT' => $ibforums->input['QPost'],
'SMILIES' => 1,
'CODE' => 1,
'HTML' => 0,
) );
$this->quoted_post['AUTHOR']['name'] = $ibforums->input['QAuthorN'];
$this->quoted_post['DATE'] = $std->get_date( $ibforums->input['QDate'], 'LONG' );
// add it to the post
$html = $class->parser->wrap_style( array( 'STYLE' => 'QUOTE',
'EXTRA' => '(' . $this->quoted_post['AUTHOR']['name'] . ' @ ' . $this->quoted_post['DATE'] . ')'
) );
if ( $class->obj['preview_post'] == "" )
{
$this->post['post'] = "<!--QuoteBegin--{$this->quoted_post['AUTHOR']['name']}+{$this->quoted_post['DATE']}-->"
. "{$html['START']}<!--QuoteEBegin-->".trim($this->quoted_post['post'])."<!--QuoteEnd-->"
. "{$html['END']}<!--QuoteEEnd--><br>"
. $this->post['post'];
}
else
{
$class->dump_quote = '[QUOTE='.$this->quoted_post['AUTHOR']['name'].','.$this->quoted_post['DATE'].']'.$ibforums->input['QPost'].'[/QUOTE]'."\n";
}
}
if ($class->obj['post_errors'] == "") {
$this->upload = $class->process_upload();
}
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") ) {
// Show the form again
$this->show_form($class);
} else {
$this->add_reply($class);
}
}
function add_reply($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Update the post info with the upload array info
//-------------------------------------------------
$this->post['attach_id'] = $this->upload['attach_id'];
$this->post['attach_type'] = $this->upload['attach_type'];
$this->post['attach_hits'] = $this->upload['attach_hits'];
$this->post['attach_file'] = $this->upload['attach_file'];
//-------------------------------------------------
// Insert the post into the database to get the
// last inserted value of the auto_increment field
//-------------------------------------------------
$this->post['topic_id'] = $this->topic['tid'];
if ( ($ibforums->input['mod_options'] != "") or ($ibforums->input['mod_options'] != 'nowt') )
{
if ($ibforums->input['mod_options'] == 'pin')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['pin_topic'] == 1)
{
$this->topic['pinned'] = 1;
$class->moderate_log('Pinned topic from post form', $this->topic['title']);
}
}
else if ($ibforums->input['mod_options'] == 'close')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['close_topic'] == 1)
{
$this->topic['state'] = 'closed';
$class->moderate_log('Closed topic from post form', $this->topic['title']);
}
}
}
$db_string = $std->compile_db_string( $this->post );
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['pid'] = $DB->get_insert_id();
if ($class->obj['moderate']) {
$print->redirect_screen( $ibforums->lang['moderate_post'], "act=ST&f={$class->forum['id']}&t={$this->topic['tid']}" );
}
//-------------------------------------------------
// If we are still here, lets update the
// board/forum/topic stats
//-------------------------------------------------
$class->forum['last_title'] = $this->topic['title'];
$class->forum['last_id'] = $this->topic['tid'];
$class->forum['last_post'] = time();
$class->forum['last_poster_name'] = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
$class->forum['last_poster_id'] = $ibforums->member['id'];
$class->forum['posts']++;
if (strlen($class->forum['last_title']) > 30)
{
$class->forum['last_title'] = substr($class->forum['last_title'],0,27) . "...";
}
// Update the database
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
"last_id='" .$class->forum['last_id'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"posts='" .$class->forum['posts'] ."' ".
"WHERE id='" .$class->forum['id'] ."'");
// Update the database
//+------------------------------------------------------------------------------------------------------
$DB->query("UPDATE ibf_topics SET last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"last_poster_name='" .$class->forum['last_poster_name'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"pinned='" .$this->topic['pinned'] ."', ".
"state='" .$this->topic['state'] ."', ".
"posts=posts+1 ".
"WHERE tid='" .$this->topic['tid'] ."'");
//+------------------------------------------------------------------------------------------------------
$DB->query("UPDATE ibf_stats SET TOTAL_REPLIES=TOTAL_REPLIES+1");
//-------------------------------------------------
// If we are a member, lets update thier last post
// date and increment their post count.
//-------------------------------------------------
$pcount = "";
if ($ibforums->member['id'])
{
if ($class->forum['inc_postcount'])
{
// Increment the users post count
$pcount = "posts=posts+1, ";
}
$ibforums->member['last_post'] = time();
$DB->query("UPDATE ibf_members SET ".$pcount.
"last_post='" .$ibforums->member['last_post'] ."'".
"WHERE id='" .$ibforums->member['id']."'");
}
//-------------------------------------------------
// Check for subscribed topics
//-------------------------------------------------
$class->topic_tracker( $this->topic['tid'], $this->post['post'], $class->forum['last_poster_name'] );
//-------------------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
$page = floor( ($this->topic['posts'] + 1) / $ibforums->vars['display_max_posts']);
$page = $page * $ibforums->vars['display_max_posts'];
$std->boink_it($class->base_url."&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}&st=$page#entry{$this->post['pid']}");
}
function show_form($class) {
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
//-------------------------------------------------
// Sort out the "raw" textarea input and make it safe incase
// we have a <textarea> tag in the raw post var.
//-------------------------------------------------
$raw_post = isset($HTTP_POST_VARS['Post']) ? $HTTP_POST_VARS['Post'] : "";
if (isset($raw_post)) {
$raw_post = preg_replace( "/<textarea>/", "&lt;textarea>", $raw_post );
$raw_post = str_replace( '$', "&#036;", $raw_post );
$raw_post = str_replace( '<%', "&lt;%" , $raw_post );
$raw_post = stripslashes($raw_post);
if ($class->dump_quote != "")
{
$raw_post = str_replace( "<br>", "\n", $class->dump_quote ) . $raw_post;
}
}
//-------------------------------------------------
// Get the old post
//-------------------------------------------------
$DB->query("SELECT post, author_id, author_name, post_date, pid FROM ibf_posts WHERE pid='".$ibforums->input['p']."'");
$this->quoted_post = $DB->fetch_row();
//-------------------------------------------------
// Unconvert the smilies, HTML and iB_Code
//-------------------------------------------------
$this->quoted_post['post'] = trim($class->parser->unconvert( $this->quoted_post['post'] ));
//-------------------------------------------------
// Do we have any posting errors?
//-------------------------------------------------
if ($class->obj['post_errors'])
{
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
}
if ($class->obj['preview_post'])
{
$class->output .= $class->html->preview( $class->parser->convert( array( 'TEXT' => $class->dump_quote . $this->post['post'], 'CODE' => $class->forum['use_ibc'], 'SMILIES' => $ibforums->input['enableemo'], 'HTML' => $class->forum['use_html']) ) );
}
$class->check_upload_ability();
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '07' ),
2 => array( 't' , $this->topic['tid']),
3 => array( 'p' , $ibforums->input['p'] )
) );
//---------------------------------------
// START TABLE
//---------------------------------------
$class->output .= $class->html->table_structure();
//---------------------------------------
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_reply']} {$this->topic['title']}");
$name_fields = $class->html_name_field();
if (! $class->obj['preview_post'])
{
$quote_box = $class->html->quote_box( $this->quoted_post );
}
$post_box = $class->html_post_body( $raw_post );
$mod_options = $class->mod_options();
$end_form = $class->html->EndForm( $ibforums->lang['submit_reply'] );
$post_icons = $class->html_post_icons();
if ($class->obj['can_upload'])
{
$upload_field = $class->html->Upload_field( $ibforums->member['g_attach_max'] * 1024 );
}
//---------------------------------------
$class->output = preg_replace( "/<!--START TABLE-->/" , "$start_table" , $class->output );
$class->output = preg_replace( "/<!--NAME FIELDS-->/" , "$name_fields" , $class->output );
$class->output = preg_replace( "/<!--POST BOX-->/" , "$post_box" , $class->output );
$class->output = preg_replace( "/<!--POST ICONS-->/" , "$post_icons" , $class->output );
$class->output = preg_replace( "/<!--UPLOAD FIELD-->/", "$upload_field" , $class->output );
$class->output = preg_replace( "/<!--MOD OPTIONS-->/" , "$mod_options" , $class->output );
$class->output = preg_replace( "/<!--END TABLE-->/" , "$end_form" , $class->output );
$class->output = preg_replace( "/<!--QUOTE BOX-->/" , "$quote_box" , $class->output );
//---------------------------------------
$class->html_add_smilie_box();
$class->html_topic_summary($this->topic['tid']);
$this->nav = array( "<a href='{$class->base_url}&act=SC&c={$class->forum[cat_id]}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}&act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
"<a href='{$class->base_url}&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>",
);
$this->title = $ibforums->lang['quoting_post'].' '.$this->topic['title'];
$print->add_output("$class->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
'JS' => 1,
'NAV' => $this->nav,
) );
}
}
?>
+360
View File
@@ -0,0 +1,360 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Reply post module
| > Module written by Matt Mecham
|
+--------------------------------------------------------------------------
*/
class post_functions extends Post {
var $nav = array();
var $title = "";
var $post = array();
var $topic = array();
var $upload = array();
var $mod_topic = array();
var $m_group = "";
function post_functions($class) {
global $ibforums, $std, $DB;
// Lets load the topic from the database before we do anything else.
$DB->query("SELECT * FROM ibf_topics WHERE forum_id='".$class->forum['id']."' AND tid='".$ibforums->input['t']."'");
$this->topic = $DB->fetch_row();
// Is it legitimate?
if (! $this->topic['tid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-------------------------------------------------
// Lets do some tests to make sure that we are
// allowed to reply to this topic
//-------------------------------------------------
if ($this->topic['poll_state'] == 'closed' and $ibforums->member['g_is_supadmin'] != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
if ($this->topic['starter_id'] == $ibforums->member['id'])
{
if (! $ibforums->member['g_reply_own_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
if ($this->topic['starter_id'] != $ibforums->member['id'])
{
if (! $ibforums->member['g_reply_own_topics'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
$this->m_group = $ibforums->member['mgroup'];
if ($class->forum['reply_perms'] != '*')
{
if (! preg_match( "/(^|,)$this->m_group(,|$)/", $class->forum['reply_perms'] ) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_replies') );
}
}
// Is the topic locked?
if ($this->topic['state'] != 'open')
{
$std->Error( array( LEVEL => 1, MSG => 'locked_topic') );
}
}
function process($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Parse the post, and check for any errors.
//-------------------------------------------------
$this->post = $class->compile_post();
if ($class->obj['post_errors'] == "")
{
$this->upload = $class->process_upload();
}
if ( ($class->obj['post_errors'] != "") or ($class->obj['preview_post'] != "") )
{
// Show the form again
$this->show_form($class);
}
else
{
$this->add_reply($class);
}
}
function add_reply($class) {
global $ibforums, $std, $DB, $print;
//-------------------------------------------------
// Update the post info with the upload array info
//-------------------------------------------------
$this->post['attach_id'] = $this->upload['attach_id'];
$this->post['attach_type'] = $this->upload['attach_type'];
$this->post['attach_hits'] = $this->upload['attach_hits'];
$this->post['attach_file'] = $this->upload['attach_file'];
//-------------------------------------------------
// Insert the post into the database to get the
// last inserted value of the auto_increment field
//-------------------------------------------------
$this->post['topic_id'] = $this->topic['tid'];
//-------------------------------------------------
// Are we a mod, and can we change the topic state?
//-------------------------------------------------
if ( ($ibforums->input['mod_options'] != "") or ($ibforums->input['mod_options'] != 'nowt') )
{
if ($ibforums->input['mod_options'] == 'pin')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['pin_topic'] == 1)
{
$this->topic['pinned'] = 1;
$class->moderate_log('Pinned topic from post form', $this->topic['title']);
}
}
else if ($ibforums->input['mod_options'] == 'close')
{
if ($ibforums->member['g_is_supmod'] == 1 or $class->moderator['close_topic'] == 1)
{
$this->topic['state'] = 'closed';
$class->moderate_log('Closed topic from post form', $this->topic['title']);
}
}
}
$db_string = $std->compile_db_string( $this->post );
$DB->query("INSERT INTO ibf_posts (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
$this->post['pid'] = $DB->get_insert_id();
if ($class->obj['moderate']) {
$print->redirect_screen( $ibforums->lang['moderate_post'], "act=ST&f={$class->forum['id']}&t={$this->topic['tid']}" );
}
//-------------------------------------------------
// If we are still here, lets update the
// board/forum/topic stats
//-------------------------------------------------
$class->forum['last_title'] = $this->topic['title'];
$class->forum['last_id'] = $this->topic['tid'];
$class->forum['last_post'] = time();
$class->forum['last_poster_name'] = $ibforums->member['id'] ? $ibforums->member['name'] : $ibforums->input['UserName'];
$class->forum['last_poster_id'] = $ibforums->member['id'];
$class->forum['posts']++;
// Update the database
$DB->query("UPDATE ibf_forums SET last_title='" .$class->forum['last_title'] ."', ".
"last_id='" .$class->forum['last_id'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"last_poster_name='".$class->forum['last_poster_name'] ."', ".
"last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"posts='" .$class->forum['posts'] ."' ".
"WHERE id='" .$class->forum['id'] ."'");
// Update the database
//+------------------------------------------------------------------------------------------------------
$DB->query("UPDATE ibf_topics SET last_poster_id='" .$class->forum['last_poster_id'] ."', ".
"last_poster_name='" .$class->forum['last_poster_name'] ."', ".
"last_post='" .$class->forum['last_post'] ."', ".
"pinned='" .$this->topic['pinned'] ."', ".
"state='" .$this->topic['state'] ."', ".
"posts=posts+1 ".
"WHERE tid='" .$this->topic['tid'] ."'");
//+------------------------------------------------------------------------------------------------------
$DB->query("UPDATE ibf_stats SET TOTAL_REPLIES=TOTAL_REPLIES+1");
//-------------------------------------------------
// If we are a member, lets update thier last post
// date and increment their post count.
//-------------------------------------------------
$pcount = "";
if ($ibforums->member['id'])
{
if ($class->forum['inc_postcount'])
{
// Increment the users post count
$pcount = "posts=posts+1, ";
}
$ibforums->member['last_post'] = time();
$DB->query("UPDATE ibf_members SET ".$pcount.
"last_post='" .$ibforums->member['last_post'] ."'".
"WHERE id='" .$ibforums->member['id']."'");
}
//-------------------------------------------------
// Check for subscribed topics
//-------------------------------------------------
$class->topic_tracker( $this->topic['tid'], $this->post['post'], $class->forum['last_poster_name'] );
//-------------------------------------------------
// Redirect them back to the topic
//-------------------------------------------------
$page = floor( ($this->topic['posts'] + 1) / $ibforums->vars['display_max_posts']);
$page = $page * $ibforums->vars['display_max_posts'];
$std->boink_it($class->base_url."&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}&st=$page&#entry{$this->post['pid']}");
}
function show_form($class) {
global $ibforums, $std, $DB, $print, $HTTP_POST_VARS;
// Sort out the "raw" textarea input and make it safe incase
// we have a <textarea> tag in the raw post var.
$raw_post = isset($HTTP_POST_VARS['Post']) ? $HTTP_POST_VARS['Post'] : "";
if (isset($raw_post)) {
$raw_post = preg_replace( "/<textarea>/", "&lt;textarea>", $raw_post );
$raw_post = str_replace( '$', "&#036;", $raw_post );
$raw_post = str_replace( '<%', "&lt;%" , $raw_post );
$raw_post = stripslashes($raw_post);
}
// Do we have any posting errors?
if ($class->obj['post_errors']) {
$class->output .= $class->html->errors( $ibforums->lang[ $class->obj['post_errors'] ]);
}
if ($class->obj['preview_post']) {
$class->output .= $class->html->preview( $class->parser->convert( array( 'TEXT' => $this->post['post'], 'CODE' => $class->forum['use_ibc'], 'SMILIES' => $ibforums->input['enableemo'], 'HTML' => $class->forum['use_html']) ) );
}
$class->check_upload_ability();
$class->output .= $class->html_start_form( array( 1 => array( 'CODE', '03' ),
2 => array( 't' , $this->topic['tid'])
) );
//---------------------------------------
// START TABLE
//---------------------------------------
$class->output .= $class->html->table_structure();
//---------------------------------------
$start_table = $class->html->table_top( "{$ibforums->lang['top_txt_reply']} {$this->topic['title']}");
$name_fields = $class->html_name_field();
$post_box = $class->html_post_body( $raw_post );
$mod_options = $class->mod_options();
$end_form = $class->html->EndForm( $ibforums->lang['submit_reply'] );
$post_icons = $class->html_post_icons();
if ($class->obj['can_upload'])
{
$upload_field = $class->html->Upload_field( $ibforums->member['g_attach_max'] * 1024 );
}
//---------------------------------------
$class->output = preg_replace( "/<!--START TABLE-->/" , "$start_table" , $class->output );
$class->output = preg_replace( "/<!--NAME FIELDS-->/" , "$name_fields" , $class->output );
$class->output = preg_replace( "/<!--POST BOX-->/" , "$post_box" , $class->output );
$class->output = preg_replace( "/<!--POST ICONS-->/" , "$post_icons" , $class->output );
$class->output = preg_replace( "/<!--UPLOAD FIELD-->/", "$upload_field" , $class->output );
$class->output = preg_replace( "/<!--MOD OPTIONS-->/" , "$mod_options" , $class->output );
$class->output = preg_replace( "/<!--END TABLE-->/" , "$end_form" , $class->output );
//---------------------------------------
$class->html_add_smilie_box();
$class->html_topic_summary($this->topic['tid']);
$this->nav = array( "<a href='{$class->base_url}&act=SC&c={$class->forum[cat_id]}'>{$class->forum['cat_name']}</a>",
"<a href='{$class->base_url}&act=SF&f={$class->forum['id']}'>{$class->forum['name']}</a>",
"<a href='{$class->base_url}&act=ST&f={$class->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>",
);
$this->title = $ibforums->lang['replying_in'].' '.$this->topic['title'];
$print->add_output("$class->output");
$print->do_output( array( 'TITLE' => $ibforums->vars['board_name']." -> ".$this->title,
'JS' => 1,
'NAV' => $this->nav,
) );
}
}
?>
+844
View File
@@ -0,0 +1,844 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > GNU Tar creation and extraction module
| > Module written by Matt Mecham
| > Usage style based on the C and Perl GNU modules
| > Will only work with PHP 4+
|
| > Date started: 15th Feb 2002
|
| > Module Version Number: 1.0.0
| > Module Author: Matthew Mecham
+--------------------------------------------------------------------------
|
| QUOTE OF THE MODULE:
| If you can't find a program the does what you want it to do, write your
| own.
|
+--------------------------------------------------------------------------
*/
/*************************************************************
|
| EXTRACTION USAGE:
|
| $tar = new tar();
| $tar->new_tar("/foo/bar", "myTar.tar");
| $files = $tar->list_files();
| $tar->extract_files( "/extract/to/here/dir" );
|
| CREATION USAGE:
|
| $tar = new tar();
| $tar->new_tar("/foo/bar" , "myNewTar.tar");
| $tar->current_dir("/foo" ); //Optional - tells the script which dir we are in
| to syncronise file creation from the tarball
| $tar->add_files( $file_names_with_path_array );
| (or $tar->add_directory( "/foo/bar/myDir" ); to archive a complete dir)
| $tar->write_tar();
|
*************************************************************/
class tar {
var $tar_header_length = '512';
var $tar_unpack_header = 'a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8chksum/a1typeflag/a100linkname/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155/prefix';
var $tar_pack_header = 'A100 A8 A8 A8 A12 A12 A8 A1 A100 A6 A2 A32 A32 A8 A8 A155';
var $current_dir = "";
var $unpack_dir = "";
var $pack_dir = "";
var $error = "";
var $work_dir = array();
var $tar_in_mem = array();
var $tar_filename = "";
var $filehandle = "";
var $warnings = array();
var $attributes = array();
var $tarfile_name = "";
var $tarfile_path = "";
var $tarfile_path_name = "";
var $workfiles = array();
//+--------------------------------------------------------------------------
// CONSTRUCTOR: Attempt to guess the current working dir.
//+--------------------------------------------------------------------------
function tar() {
global $HTTP_SERVER_VARS;
if ($this_dir = getcwd())
{
$this->current_dir = $this_dir;
}
else if (isset($HTTP_SERVER_VARS['DOCUMENT_ROOT']))
{
$this->current_dir = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
}
else
{
$this->current_dir = './';
}
// Set some attributes, these can be overriden later
$this->attributes = array( 'over_write_existing' => 0,
'over_write_newer' => 0,
'remove_tar_file' => 0,
'remove_original_files' => 0,
);
}
//+--------------------------------------------------------------------------
// Set the tarname. If we are extracting a tarball, then it must be the
// path to the tarball, and it's name (eg: $tar->new_tar("/foo/bar" ,'myTar.tar')
// or if we are creating a tar, then it must be the path and name of the tar file
// to create.
//+--------------------------------------------------------------------------
function new_tar($tarpath, $tarname) {
$this->tarfile_name = $tarname;
$this->tarfile_path = $tarpath;
// Make sure there isn't a trailing slash on the path
$this->tarfile_path = preg_replace( "#[/\\\]$#" , "" , $this->tarfile_path );
$this->tarfile_path_name = $this->tarfile_path .'/'. $this->tarfile_name;
}
//+--------------------------------------------------------------------------
// Easy way to overwrite defaults
//+--------------------------------------------------------------------------
function over_write_existing() {
$this->attributes['over_write_existing'] = 1;
}
function over_write_newer() {
$this->attributes['over_write_newer'] = 1;
}
function remove_tar_file() {
$this->attributes['remove_tar_file'] = 1;
}
function remove_original_files() {
$this->attributes['remove_original_files'] = 1;
}
//+--------------------------------------------------------------------------
// User assigns the root directory for the tar ball creation/extraction
//+--------------------------------------------------------------------------
function current_dir($dir = "") {
$this->current_dir = $dir;
}
//+--------------------------------------------------------------------------
// list files: returns an array with all the filenames in the tar file
//+--------------------------------------------------------------------------
function list_files($advanced="") {
// $advanced == "" - return name only
// $advanced == 1 - return name, size, mtime, mode
$data = $this->read_tar();
$final = array();
foreach($data as $d)
{
if ($advanced == 1)
{
$final[] = array ( 'name' => $d['name'],
'size' => $d['size'],
'mtime' => $d['mtime'],
'mode' => substr(decoct( $d['mode'] ), -4),
);
}
else
{
$final[] = $d['name'];
}
}
return $final;
}
//+--------------------------------------------------------------------------
// Add a directory to the tar files.
// $tar->add_directory( str(TO DIRECTORY) )
// Can be used in the following methods.
// $tar->add_directory( "/foo/bar" );
// $tar->write_tar( "/foo/bar" );
//+--------------------------------------------------------------------------
function add_directory( $dir ) {
$this->error = "";
// Make sure the $to_dir is pointing to a valid dir, or we error
// and return
if (! is_dir($dir) )
{
$this->error = "Extract files error: Destination directory ($to_dir) does not exist";
return FALSE;
}
$cur_dir = getcwd();
chdir($dir);
$this->get_dir_contents("./");
$this->add_files($this->workfiles, $dir);
chdir($cur_dir);
}
//-------------------------------------
function get_dir_contents( $dir )
{
$dir = preg_replace( "#/$#", "", $dir );
if ( file_exists($dir) )
{
if ( is_dir($dir) )
{
$handle = opendir($dir);
while (($filename = readdir($handle)) !== false)
{
if (($filename != ".") && ($filename != ".."))
{
if (is_dir($dir."/".$filename))
{
$this->get_dir_contents($dir."/".$filename);
}
else
{
$this->workfiles[] = $dir."/".$filename;
}
}
}
closedir($handle);
}
else
{
$this->error = "$dir is not a directory";
return FALSE;
}
}
else
{
$this->error = "Could not locate $dir";
return;
}
}
//+--------------------------------------------------------------------------
// Extract the tarball
// $tar->extract_files( str(TO DIRECTORY), [ array( FILENAMES ) ] )
// Can be used in the following methods.
// $tar->extract( "/foo/bar" , $files );
// This will seek out the files in the user array and extract them
// $tar->extract( "/foo/bar" );
// Will extract the complete tar file into the user specified directory
//+--------------------------------------------------------------------------
function extract_files( $to_dir, $files="" ) {
$this->error = "";
// Make sure the $to_dir is pointing to a valid dir, or we error
// and return
if (! is_dir($to_dir) )
{
$this->error = "Extract files error: Destination directory ($to_dir) does not exist";
return;
}
//---------------------------------------------
// change into the directory chosen by the user.
//---------------------------------------------
chdir($to_dir);
$cur_dir = getcwd();
$to_dir_slash = $to_dir . "/";
//+------------------------------
// Get the file info from the tar
//+------------------------------
$in_files = $this->read_tar();
if ($this->error != "") {
return;
}
foreach ($in_files as $k => $file) {
//---------------------------------------------
// Are we choosing which files to extract?
//---------------------------------------------
if (is_array($files))
{
if (! in_array($file['name'], $files) )
{
continue;
}
}
chdir($cur_dir);
//---------------------------------------------
// GNU TAR format dictates that all paths *must* be in the *nix
// format - if this is not the case, blame the tar vendor, not me!
//---------------------------------------------
if ( preg_match("#/#", $file['name']) )
{
$path_info = explode( "/" , $file['name'] );
$file_name = array_pop($path_info);
} else
{
$path_info = array();
$file_name = $file['name'];
}
//---------------------------------------------
// If we have a path, then we must build the directory tree
//---------------------------------------------
if (count($path_info) > 0)
{
foreach($path_info as $dir_component)
{
if ($dir_component == "")
{
continue;
}
if ( (file_exists($dir_component)) && (! is_dir($dir_component)) )
{
$this->warnings[] = "WARNING: $dir_component exists, but is not a directory";
continue;
}
if (! is_dir($dir_component))
{
mkdir( $dir_component, 0777);
chmod( $dir_component, 0777);
}
if (! @chdir($dir_component))
{
$this->warnings[] = "ERROR: CHDIR to $dir_component FAILED!";
}
}
}
//---------------------------------------------
// check the typeflags, and work accordingly
//---------------------------------------------
if (($file['typeflag'] == 0) or (!$file['typeflag']) or ($file['typeflag'] == ""))
{
if ( $FH = fopen($file_name, "wb") )
{
fputs( $FH, $file['data'], strlen($file['data']) );
fclose($FH);
}
else
{
$this->warnings[] = "Could not write data to $file_name";
}
}
else if ($file['typeflag'] == 5)
{
if ( (file_exists($file_name)) && (! is_dir($file_name)) )
{
$this->warnings[] = "$file_name exists, but is not a directory";
continue;
}
if (! is_dir($file_name))
{
mkdir( $file_name, 0777);
}
}
else if ($file['typeflag'] == 6)
{
$this->warnings[] = "Cannot handle named pipes";
continue;
}
else if ($file['typeflag'] == 1)
{
$this->warnings[] = "Cannot handle system links";
}
else if ($file['typeflag'] == 4)
{
$this->warnings[] = "Cannot handle device files";
}
else if ($file['typeflag'] == 3)
{
$this->warnings[] = "Cannot handle device files";
}
else
{
$this->warnings[] = "Unknown typeflag found";
}
if (! @chmod( $file_name, $file['mode'] ) )
{
$this->warnings[] = "ERROR: CHMOD $mode on $file_name FAILED!";
}
@touch( $file_name, $file['mtime'] );
}
// Return to the "real" directory the scripts are in
@chdir($this->current_dir);
}
//+--------------------------------------------------------------------------
// add files:
// Takes an array of files, and adds them to the tar file
// Optionally takes a path to use as root for the tar file - if omitted, it
// assumes the current working directory is the tarball root. Be careful with
// this, or you may get unexpected results -especially when attempting to read
// and add files to the tarball.
// EXAMPLE DIR STRUCTURE
// /usr/home/somedir/forums/sources
// BRIEF: To tar up the sources directory
// $files = array( 'sources/somescript.php', 'sources/anothersscript.php' );
// If CWD is 'somedir', you'll need to use $tar->add_files( $files, "/usr/home/somedir/forums" );
// or it'll attempt to open /usr/home/somedir/sources/somescript.php - which would result
// in an error. Either that, or use:
// chdir("/usr/home/somedir/forums");
// $tar->add_files( $files );
//+--------------------------------------------------------------------------
function add_files( $files, $root_path="" ) {
// Do we a root path to change into?
if ($root_path != "") {
chdir($root_path);
}
$count = 0;
foreach ($files as $file) {
// is it a Mac OS X work file?
if ( preg_match("/\.ds_store/i", $file ) )
{
continue;
}
$typeflag = 0;
$data = "";
$linkname = "";
$stat = stat($file);
// Did stat fail?
if (! is_array($stat) ) {
$this->warnings[] = "Error: Stat failed on $file";
continue;
}
$mode = fileperms($file);
$uid = $stat[4];
$gid = $stat[5];
$rdev = $stat[6];
$size = filesize($file);
$mtime = filemtime($file);
if (is_file($file)) {
// It's a plain file, so lets suck it up
$typeflag = 0;
if ( $FH = fopen($file, 'rb') ) {
$data = fread( $FH, filesize($file) );
fclose($FH);
} else {
$this->warnings[] = "ERROR: Failed to open $file";
continue;
}
}
else if (is_link($file)) {
$typeflag = 1;
$linkname = @readlink($file);
}
else if (is_dir($file)) {
$typeflag = 5;
}
else {
// Sockets, Pipes and char/block specials are not
// supported, so - lets use a silly value to keep the
// tar ball legitimate.
$typeflag = 9;
}
// Add this data to our in memory tar file
$this->tar_in_mem[] = array (
'name' => $file,
'mode' => $mode,
'uid' => $uid,
'gid' => $gid,
'size' => strlen($data),
'mtime' => $mtime,
'chksum' => " ",
'typeflag' => $typeflag,
'linkname' => $linkname,
'magic' => "ustar\0",
'version' => '00',
'uname' => 'unknown',
'gname' => 'unknown',
'devmajor' => "",
'devminor' => "",
'prefix' => "",
'data' => $data
);
// Clear the stat cache
@clearstatcache();
$count++;
}
@chdir($this->current_dir);
//Return the number of files to anyone who's interested
return $count;
}
//+--------------------------------------------------------------------------
// write_tar:
// Writes the tarball into the directory specified in new_tar with a filename
// specified in new_tar
//+--------------------------------------------------------------------------
function write_tar() {
if ($this->tarfile_path_name == "") {
$this->error = 'No filename or path was specified to create a new tar file';
return;
}
if ( count($this->tar_in_mem) < 1 ) {
$this->error = 'No data to write to the new tar file';
return;
}
$tardata = "";
foreach ($this->tar_in_mem as $file) {
$prefix = "";
$tmp = "";
$last = "";
// make sure the filename isn't longer than 99 characters.
if (strlen($file['name']) > 99) {
$pos = strrpos( $file['name'], "/" );
if (is_string($pos) && !$pos) {
// filename alone is longer than 99 characters!
$this->error[] = "Filename {$file['name']} exceeds the length allowed by GNU Tape ARchives";
continue;
}
$prefix = substr( $file['name'], 0 , $pos ); // Move the path to the prefix
$file['name'] = substr( $file['name'], ($pos+1));
if (strlen($prefix) > 154) {
$this->error[] = "File path exceeds the length allowed by GNU Tape ARchives";
continue;
}
}
// BEGIN FORMATTING (a8a1a100)
$mode = sprintf("%6s ", decoct($file['mode']));
$uid = sprintf("%6s ", decoct($file['uid']));
$gid = sprintf("%6s ", decoct($file['gid']));
$size = sprintf("%11s ", decoct($file['size']));
$mtime = sprintf("%11s ", decoct($file['mtime']));
$tmp = pack("a100a8a8a8a12a12",$file['name'],$mode,$uid,$gid,$size,$mtime);
$last = pack("a1" , $file['typeflag']);
$last .= pack("a100" , $file['linkname']);
$last .= pack("a6", "ustar"); // magic
$last .= pack("a2", "" ); // version
$last .= pack("a32", $file['uname']);
$last .= pack("a32", $file['gname']);
$last .= pack("a8", ""); // devmajor
$last .= pack("a8", ""); // devminor
$last .= pack("a155", $prefix);
//$last .= pack("a12", "");
$test_len = $tmp . $last . "12345678";
$last .= $this->internal_build_string( "\0" , ($this->tar_header_length - strlen($test_len)) );
// Here comes the science bit, handling
// the checksum.
$checksum = 0;
for ($i = 0 ; $i < 148 ; $i++ ) {
$checksum += ord( substr($tmp, $i, 1) );
}
for ($i = 148 ; $i < 156 ; $i++) {
$checksum += ord(' ');
}
for ($i = 156, $j = 0 ; $i < 512 ; $i++, $j++) {
$checksum += ord( substr($last, $j, 1) );
}
$checksum = sprintf( "%6s ", decoct($checksum) );
$tmp .= pack("a8", $checksum);
$tmp .= $last;
$tmp .= $file['data'];
// Tidy up this chunk to the power of 512
if ($file['size'] > 0)
{
if ($file['size'] % 512 != 0)
{
$homer = $this->internal_build_string( "\0" , (512 - ($file['size'] % 512)) );
$tmp .= $homer;
}
}
$tardata .= $tmp;
}
// Add the footer
$tardata .= pack( "a512", "" );
// print it to the tar file
$FH = fopen( $this->tarfile_path_name, 'wb' );
fputs( $FH, $tardata, strlen($tardata) );
fclose($FH);
@chmod( $this->tarfile_path_name, 0777);
// Done..
}
//+--------------------------------------------------------------------------
// Read the tarball - builds an associative array
//+--------------------------------------------------------------------------
function read_tar() {
$filename = $this->tarfile_path_name;
if ($filename == "") {
$this->error = 'No filename specified when attempting to read a tar file';
return array();
}
if (! file_exists($filename) ) {
$this->error = 'Cannot locate the file '.$filename;
return array();
}
$tar_info = array();
$this->tar_filename = $filename;
// Open up the tar file and start the loop
if (! $FH = fopen( $filename , 'rb' ) ) {
$this->error = "Cannot open $filename for reading";
return array();
}
// Grrr, perl allows spaces, PHP doesn't. Pack strings are hard to read without
// them, so to save my sanity, I'll create them with spaces and remove them here
$this->tar_unpack_header = preg_replace( "/\s/", "" , $this->tar_unpack_header);
while (!feof($FH)) {
$buffer = fread( $FH , $this->tar_header_length );
// check the block
$checksum = 0;
for ($i = 0 ; $i < 148 ; $i++) {
$checksum += ord( substr($buffer, $i, 1) );
}
for ($i = 148 ; $i < 156 ; $i++) {
$checksum += ord(' ');
}
for ($i = 156 ; $i < 512 ; $i++) {
$checksum += ord( substr($buffer, $i, 1) );
}
$fa = unpack( $this->tar_unpack_header, $buffer);
$name = trim($fa[filename]);
$mode = OctDec(trim($fa[mode]));
$uid = OctDec(trim($fa[uid]));
$gid = OctDec(trim($fa[gid]));
$size = OctDec(trim($fa[size]));
$mtime = OctDec(trim($fa[mtime]));
$chksum = OctDec(trim($fa[chksum]));
$typeflag = trim($fa[typeflag]);
$linkname = trim($fa[linkname]);
$magic = trim($fa[magic]);
$version = trim($fa[version]);
$uname = trim($fa[uname]);
$gname = trim($fa[gname]);
$devmajor = OctDec(trim($fa[devmajor]));
$devminor = OctDec(trim($fa[devminor]));
$prefix = trim($fa[prefix]);
if ( ($checksum == 256) && ($chksum == 0) ) {
//EOF!
break;
}
if ($prefix) {
$name = $prefix.'/'.$name;
}
// Some broken tars don't set the type flag
// correctly for directories, so we assume that
// if it ends in / it's a directory...
if ( (preg_match( "#/$#" , $name)) and (! $name) ) {
$typeflag = 5;
}
// If it's the end of the tarball...
$test = $this->internal_build_string( '\0' , 512 );
if ($buffer == $test) {
break;
}
// Read the next chunk
$data = fread( $FH, $size );
if (strlen($data) != $size) {
$this->error = "Read error on tar file";
fclose( $FH );
return array();
}
$diff = $size % 512;
if ($diff != 0) {
// Padding, throw away
$crap = fread( $FH, (512-$diff) );
}
// Protect against tarfiles with garbage at the end
if ($name == "") {
break;
}
$tar_info[] = array (
'name' => $name,
'mode' => $mode,
'uid' => $uid,
'gid' => $gid,
'size' => $size,
'mtime' => $mtime,
'chksum' => $chksum,
'typeflag' => $typeflag,
'linkname' => $linkname,
'magic' => $magic,
'version' => $version,
'uname' => $uname,
'gname' => $gname,
'devmajor' => $devmajor,
'devminor' => $devminor,
'prefix' => $prefix,
'data' => $data
);
}
fclose($FH);
return $tar_info;
}
//+------------------------------------------------------------------------------
// INTERNAL FUNCTIONS - These should NOT be called outside this module
//+------------------------------------------------------------------------------
//+--------------------------------------------------------------------------
// build_string: Builds a repititive string
//+--------------------------------------------------------------------------
function internal_build_string($string="", $times=0) {
$return = "";
for ($i=0 ; $i < $times ; ++$i ) {
$return .= $string;
}
return $return;
}
}
?>
+584
View File
@@ -0,0 +1,584 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > UserCP functions library
| > Module written by Matt Mecham
| > Date started: 20th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
class usercp_functions {
var $class;
function usercp_functions($class) {
$this->class = $class;
}
function do_skin_langs() {
global $ibforums, $DB, $std, $print, $HTTP_POST_VARS;
// Check input for 1337 h/\x0r nonsense
if ($HTTP_POST_VARS['act'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//+----------------------------------------
if ( preg_match( "/\.\./", $ibforums->input['u_skin'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//+----------------------------------------
if ( preg_match( "/\.\./", $ibforums->input['u_language'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//+----------------------------------------
$DB->query("SELECT sid FROM ibf_skins WHERE hidden <> 1 AND sid='".$ibforums->input['u_skin']."'");
if (! $DB->get_num_rows() )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'skin_not_found' ) );
}
//+----------------------------------------
$db_string = $DB->compile_db_update_string( array (
'language' => $ibforums->input['u_language'],
'skin ' => $ibforums->input['u_skin'],
) );
$DB->query("UPDATE ibf_members SET $db_string WHERE id='".$this->class->member['id']."'");
$print->redirect_screen( $ibforums->lang['set_updated'], "act=UserCP&CODE=06" );
}
function do_board_prefs() {
global $ibforums, $DB, $std, $print, $HTTP_POST_VARS;
// Check the input for naughties :D
if ($HTTP_POST_VARS['act'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//+----------------------------------------
if ( ! preg_match( "/^[\-\d\.]+$/", $ibforums->input['u_timezone'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//+----------------------------------------
if ( ! preg_match( "/^\d+$/", $ibforums->input['VIEW_IMG'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//+----------------------------------------
if ( ! preg_match( "/^\d+$/", $ibforums->input['VIEW_SIGS'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//+----------------------------------------
if ( ! preg_match( "/^\d+$/", $ibforums->input['VIEW_AVS'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//+----------------------------------------
if ( ! preg_match( "/^\d+$/", $ibforums->input['DO_POPUP'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
if ( ! preg_match( "/^\d+$/", $ibforums->input['HIDE_SESS'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'poss_hack_attempt' ) );
}
//+----------------------------------------
$db_string = $DB->compile_db_update_string( array (
'time_offset' => $ibforums->input['u_timezone'],
'view_avs' => $ibforums->input['VIEW_AVS'],
'view_sigs' => $ibforums->input['VIEW_SIGS'],
'view_img' => $ibforums->input['VIEW_IMG'],
'view_pop' => $ibforums->input['DO_POPUP'],
'dst_in_use' => $ibforums->input['DST'],
) );
$DB->query("UPDATE ibf_members SET $db_string WHERE id='".$this->class->member['id']."'");
if ($ibforums->input['HIDE_SESS'] == 1)
{
$std->my_setcookie('hide_sess', '1');
}
else
{
$std->my_setcookie('hide_sess', '0');
}
$print->redirect_screen( $ibforums->lang['set_updated'], "act=UserCP&CODE=04" );
}
function do_email_settings() {
global $ibforums, $DB, $std, $print, $HTTP_POST_VARS;
if ($HTTP_POST_VARS['act'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//+----------------------------------------
//check and set the rest of the info
foreach ( array('hide_email', 'admin_send', 'send_full_msg', 'pm_reminder') as $v )
{
$ibforums->input[ $v ] = $std->is_number( $ibforums->input[ $v ] );
if ( $ibforums->input[ $v ] < 1 )
{
$ibforums->input[ $v ] = 0;
}
}
$db_string = $DB->compile_db_update_string( array (
'hide_email' => $ibforums->input['hide_email'],
'email_full' => $ibforums->input['send_full_msg'],
'email_pm' => $ibforums->input['pm_reminder'],
'allow_admin_mails' => $ibforums->input['admin_send'],
) );
$DB->query("UPDATE ibf_members SET $db_string WHERE id='".$this->class->member['id']."'");
$print->redirect_screen( "Email Settings updated", "act=UserCP&CODE=02" );
}
function do_avatar() {
global $ibforums, $DB, $std, $print, $HTTP_POST_VARS, $HTTP_POST_FILES, $FILE_UPLOAD;
if ($HTTP_POST_VARS['act'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//+----------------------------------------
$real_choice = 'noavatar';
$real_dims = '';
if ($ibforums->input['choice'] == 'gallery')
{
$avatar_gallery = array();
$dh = opendir( $ibforums->vars['html_dir'].'avatars' );
while ( $file = readdir( $dh ) )
{
if ( !preg_match( "/^..?$|^index/i", $file ) )
{
$avatar_gallery[] = $file;
}
}
closedir( $dh );
if (!in_array( $HTTP_POST_VARS['gallery_list'], $avatar_gallery ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_avatar_selected' ) );
}
$real_choice = $ibforums->input['gallery_list'];
}
else if ($ibforums->input['choice'] == 'url')
{
//-----------------------------------
// Check to make sure we don't just have
// http:// in the URL box..
//------------------------------------
if ( preg_match( "/^http:\/\/$/i", $ibforums->input['url_avatar'] ) )
{
$ibforums->input['url_avatar'] = "";
}
if (empty($ibforums->input['url_avatar']) )
{
//------------------------------------
// Lets check for an uploaded avatar..
//------------------------------------
if ($HTTP_POST_FILES['FILE_UPLOAD']['name'] != "" and ($HTTP_POST_FILES['FILE_UPLOAD']['name'] != "none") )
{
$FILE_NAME = $HTTP_POST_FILES['FILE_UPLOAD']['name'];
$FILE_SIZE = $HTTP_POST_FILES['FILE_UPLOAD']['size'];
$FILE_TYPE = $HTTP_POST_FILES['FILE_UPLOAD']['type'];
if ($HTTP_POST_FILES['FILE_UPLOAD']['name'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_av_name' ) );
}
// Naughty Opera adds the filename on the end of the
// mime type - we don't want this.
$FILE_TYPE = preg_replace( "/^(.+?);.*$/", "\\1", $FILE_TYPE );
// Are we allowed to upload or has the admin stopped us?
if ( ($ibforums->member['g_avatar_upload'] != 1) or ($ibforums->vars['avup_size_max'] < 1) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_av_upload' ) );
}
// Check to make sure it's the correct content type.
// Naughty Nominell won't be able to use PNG :P
require "./conf_mime_types.php";
if ($mime_types[ $FILE_TYPE ][3] != 1)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_av_type' ) );
}
//-------------------------------------------------
// Check the file size
//-------------------------------------------------
if ($FILE_SIZE > ($ibforums->vars['avup_size_max']*1024))
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'upload_to_big' ) );
}
$ext = '.gif';
switch($FILE_TYPE)
{
case 'image/gif':
$ext = '.gif';
break;
case 'image/jpeg':
$ext = '.jpg';
break;
case 'image/pjpeg':
$ext = '.jpg';
break;
case 'image/x-png':
$ext = '.png';
break;
default:
$ext = '.gif';
break;
}
$real_name = 'av-'.$this->class->member['id'].$ext;
//-------------------------------------------------
// Copy the upload to the uploads directory
//-------------------------------------------------
if (! @move_uploaded_file( $HTTP_POST_FILES['FILE_UPLOAD']['tmp_name'], $ibforums->vars['upload_dir']."/".$real_name) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'upload_failed' ) );
}
// Set the "real" avatar..
$real_choice = 'upload:'.$real_name;
$w = $ibforums->input['Avatar_width'];
$h = $ibforums->input['Avatar_height'];
list($aw, $ah) = explode( "x", $ibforums->vars['avatar_dims'] );
$w = $w > $aw ? $aw : $w;
$h = $h > $ah ? $ah : $h;
$real_dims = $w.'x'.$h;
}
else if ( preg_match( "/^upload:/", $this->class->member['avatar'] ) )
{
// Keep the current avatar
$real_choice = $this->class->member['avatar'];
$w = $ibforums->input['Avatar_width'];
$h = $ibforums->input['Avatar_height'];
list($aw, $ah) = explode( "x", $ibforums->vars['avatar_dims'] );
$w = $w > $aw ? $aw : $w;
$h = $h > $ah ? $ah : $h;
$real_dims = $w.'x'.$h;
}
else
{
// URL field and upload field left blank.
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_avatar_selected' ) );
}
}
else
{
// Non empty URL field, upload box is empty.
if (!preg_match( "/^http:\/\//i", $ibforums->input['url_avatar'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'avatar_invalid_url' ) );
}
$ext = explode ( "|", $ibforums->vars['avatar_ext'] );
$checked = 0;
$av_ext = preg_replace( "/^.*\.(\S+)$/", "\\1", $ibforums->input['url_avatar'] );
foreach ($ext as $v )
{
if (strtolower($v) == strtolower($av_ext))
{
$checked = 1;
}
}
if ($checked != 1)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'avatar_invalid_ext' ) );
}
$w = $ibforums->input['Avatar_width'];
$h = $ibforums->input['Avatar_height'];
list($aw, $ah) = explode( "x", $ibforums->vars['avatar_dims'] );
$w = $w > $aw ? $aw : $w;
$h = $h > $ah ? $ah : $h;
$real_dims = $w.'x'.$h;
$real_choice = $ibforums->input['url_avatar'];
}
}
else
{
$real_choice = 'noavatar';
}
// Update the DB
$DB->query("UPDATE ibf_members SET avatar='$real_choice', avatar_size='$real_dims' WHERE id='".$this->class->member['id']."'");
$print->redirect_screen( "Avatar choice updated", "act=UserCP&CODE=24" );
}
function do_profile() {
global $ibforums, $DB, $std, $print, $HTTP_POST_VARS;
//----------------------------------
// Check for bad entry
//----------------------------------
if ($HTTP_POST_VARS['act'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//+----------------------------------------
if ( (strlen($HTTP_POST_VARS['Interests']) > $ibforums->vars['max_interest_length']) and ($ibforums->vars['max_interest_length']) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'int_too_long' ) );
}
//+--------------------
if ( (strlen($HTTP_POST_VARS['Location']) > $ibforums->vars['max_location_length']) and ($ibforums->vars['max_location_length']) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'loc_too_long' ) );
}
//+--------------------
if (strlen($HTTP_POST_VARS['WebSite']) > 150)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'web_too_long' ) );
}
//+--------------------
if (strlen($HTTP_POST_VARS['Photo']) > 150)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'photo_too_long' ) );
}
//+--------------------
if ( ($HTTP_POST_VARS['ICQNumber']) && (!preg_match( "/^(?:\d+)$/", $HTTP_POST_VARS['ICQNumber'] ) ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'not_icq_number' ) );
}
//+--------------------
if ( empty($ibforums->vars['allow_dynamic_img']) )
{
if ( preg_match( "/[?&;]/", $HTTP_POST_VARS['Photo'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'not_url_photo' ) );
}
}
//----------------------------------
// make sure that either we entered
// all calendar fields, or we left them
// all blank
//----------------------------------
$c_cnt = 0;
foreach ( array('day','month','year') as $v )
{
if (!empty($ibforums->input[$v]))
{
$c_cnt++;
}
}
if ( ($c_cnt > 0) and ($c_cnt != 3) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'calendar_not_all' ) );
}
if ( ! preg_match( "#^http://#", $ibforums->input['WebSite'] ) )
{
$ibforums->input['WebSite'] = 'http://'.$ibforums->input['WebSite'];
}
//----------------------------------
// Start off our array
//----------------------------------
$set = array( 'website' => $ibforums->input['WebSite'],
'icq_number' => $ibforums->input['ICQNumber'],
'aim_name' => $ibforums->input['AOLName'],
'yahoo' => $ibforums->input['YahooName'],
'msnname' => $ibforums->input['MSNName'],
'location' => $ibforums->input['Location'],
'interests' => $ibforums->input['Interests'],
'photo' => $ibforums->input['Photo'],
'bday_day' => $ibforums->input['day'],
'bday_month' => $ibforums->input['month'],
'bday_year' => $ibforums->input['year'],
);
//----------------------------------
// check to see if we can enter a member title
// and if one is entered, update it.
//----------------------------------
if ( ($ibforums->input['member_title']) and ($ibforums->vars['post_titlechange']) and ( $this->class->member['posts'] > $ibforums->vars['post_titlechange']) )
{
$set['title'] = $ibforums->input['member_title'];
}
//----------------------------------
// Update the DB
//----------------------------------
$set_string = $DB->compile_db_update_string($set);
$DB->query("UPDATE ibf_members SET $set_string WHERE id='".$this->class->member['id']."'");
// Return us!
$print->redirect_screen( $ibforums->lang['profile_edited'], "act=UserCP&CODE=01" );
}
function do_signature() {
global $ibforums, $DB, $std, $print, $HTTP_POST_VARS;
if ($HTTP_POST_VARS['act'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'complete_form' ) );
}
//+----------------------------------------
//----------------------------------
// Check for bad entry
//----------------------------------
if ( (strlen($HTTP_POST_VARS['Post']) > $ibforums->vars['max_sig_length']) and ($ibforums->vars['max_sig_length']) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'sig_too_long' ) );
}
//----------------------------------
// Check for valid IB CODE
//----------------------------------
//
// For efficiency, we convert the IBF code into HTML and store it in the DB
// Otherwise we'll have to parse the siggies each time we view a post - that
// gets boring after a while.
//
// We will adjust raw HTML on the fly, as some admins may allow it until it's abused
// then switch it off. If we pre-compile HTML in siggies, we'd have to edit everyones
// siggies to remove it. We don't want that.
//
// I'm going to stick my neck out again and say that most admins will allow IBF Code
// in siggies, so it's not much of a bother.
$ibforums->input['Post'] = $this->class->parser->convert( array( 'TEXT' => $ibforums->input['Post'],
'SMILIES' => 0,
'CODE' => $ibforums->vars['sig_allow_ibc'],
'HTML' => $ibforums->vars['sig_allow_html'],
'SIGNATURE' => 1
) );
if ($this->class->parser->error != "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => $this->class->parser->error) );
}
//Write it to the DB.
$ibforums->input['Post'] = preg_replace( "/'/", "\\'", $ibforums->input['Post'] );
$DB->query("UPDATE ibf_members SET signature='".$ibforums->input['Post']."' WHERE id ='".$this->class->member['id']."'");
// Buh BYE:
$std->boink_it($this->class->base_url."&act=UserCP&CODE=22");
exit;
}
}
?>
+94
View File
@@ -0,0 +1,94 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Attachment Handler module
| > Module written by Matt Mecham
| > Date started: 10th March 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new attach;
class attach {
function attach()
{
global $ibforums, $DB, $std, $print, $skin_universal;
$ibforums->input['id'] = preg_replace( "/^(\d+)$/", "\\1", $ibforums->input['id'] );
if ($ibforums->input['id'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
}
if ($ibforums->input['type'] == 'post')
{
// Handle post attachments.
$DB->query("SELECT pid, attach_id, attach_type, attach_file FROM ibf_posts WHERE pid='".$ibforums->input['id']."'");
if ( !$DB->get_num_rows() )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
}
$post = $DB->fetch_row();
if ( $post['attach_id'] == "" )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
}
$file = $ibforums->vars['upload_dir']."/".$post['attach_id'];
if ( file_exists( $file ) and ( $post['attach_type'] != "" ) )
{
// Update the "hits"..
$DB->query("UPDATE ibf_posts SET attach_hits=attach_hits+1 WHERE pid='".$post['pid']."'");
// Set up the headers..
@header( "Content-Type: ".$post['attach_type']."\nContent-Disposition: inline; filename=\"".$post['attach_file']."\"\nContent-Length: ".(string)(filesize( $file ) ) );
// Open and display the file..
$fh = fopen( $file, 'rb' ); // Set binary for Win even if it's an ascii file, it won't hurt.
fpassthru( $fh );
@fclose( $fh );
}
else
{
// File does not exist..
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files' ) );
}
}
}
}
?>
+375
View File
@@ -0,0 +1,375 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > ICQ / AIM / EMAIL functions
| > Module written by Matt Mecham
| > Date started: 28th February 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new Contact;
class Contact {
var $output = "";
var $base_url = "";
var $html = "";
var $nav = array();
var $page_title= "";
var $email = "";
/***********************************************************************************/
//
// Our constructor, load words, load skin
//
/***********************************************************************************/
function Contact() {
global $ibforums, $DB, $std, $print, $skin_universal;
// What to do?
switch($ibforums->input['act']) {
case 'Mail':
$this->mail_member();
break;
case 'AOL':
$this->show_aim();
break;
case 'ICQ':
$this->show_icq();
break;
case 'Invite':
$this->invite_member();
break;
default:
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
break;
}
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
}
//****************************************************************/
// AOL CONSOLE:
//
//****************************************************************/
function show_aim() {
global $ibforums, $DB, $std, $print;
require "./Skin/".$ibforums->skin_id."/skin_emails.php";
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_emails', $ibforums->lang_id );
$this->html = new skin_emails();
//----------------------------------
if (empty($ibforums->member['id']))
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_guests' ) );
}
if ( empty($ibforums->input['MID']) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
}
//----------------------------------
if (! preg_match( "/^(\d+)$/" , $ibforums->input['MID'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
}
//----------------------------------
$DB->query("SELECT name, id, aim_name from ibf_members WHERE id='".$ibforums->input['MID']."'");
$member = $DB->fetch_row();
//----------------------------------
if (! $member['id'] )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_such_user' ) );
}
//----------------------------------
if (! $member['aim_name'] )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_aol' ) );
}
$member['aim_name'] = str_replace(" ", "", $member['aim_name']);
//----------------------------------
$print->pop_up_window( "AOL CONSOLE", $this->html->aol_body( array( 'AOLNAME' => $member['aim_name'] ) ) );
}
//****************************************************************/
// ICQ CONSOLE:
//
//****************************************************************/
function show_icq() {
global $ibforums, $DB, $std, $print;
require "./Skin/".$ibforums->skin_id."/skin_emails.php";
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_emails', $ibforums->lang_id);
$this->html = new skin_emails();
//----------------------------------
if (empty($ibforums->member['id'])) {
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_guests' ) );
}
if ( empty($ibforums->input['MID']) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
}
//----------------------------------
if (! preg_match( "/^(\d+)$/" , $ibforums->input['MID'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
}
//----------------------------------
$DB->query("SELECT name, id, icq_number from ibf_members WHERE id='".$ibforums->input['MID']."'");
$member = $DB->fetch_row();
//----------------------------------
if (! $member['id'] )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_such_user' ) );
}
//----------------------------------
if (! $member['icq_number'] )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_icq' ) );
}
//----------------------------------
$html = $this->html->pager_header( array( $ibforums->lang['icq_title'] ) );
$html .= $this->html->icq_body( array( 'UIN' => $member['icq_number'] ) );
$html .= $this->html->end_table();
$print->pop_up_window( "ICQ CONSOLE", $html );
}
//****************************************************************/
// MAIL MEMBER:
//
// Handles the routines called by clicking on the "email" button when
// reading topics
//****************************************************************/
function mail_member() {
global $ibforums, $DB, $std, $print;
require "./sources/lib/emailer.php";
$this->email = new emailer();
//----------------------------------
require "./Skin/".$ibforums->skin_id."/skin_emails.php";
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_emails', $ibforums->lang_id );
$this->html = new skin_emails();
//----------------------------------
if (empty($ibforums->member['id']))
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_guests' ) );
}
//----------------------------------
if ($ibforums->input['CODE'] == '01')
{
// Send the email, yippee
if ( empty($ibforums->input['to']) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
}
//----------------------------------
if (! preg_match( "/^(\d+)$/" , $ibforums->input['to'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
}
//----------------------------------
$DB->query("SELECT name, id, email, hide_email from ibf_members WHERE id='".$ibforums->input['to']."'");
$member = $DB->fetch_row();
//----------------------------------
if (! $member['id'] )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_such_user' ) );
}
/*if ($member['id'] == 1)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'private_email' ) );
}*/
//----------------------------------
$check_array = array (
'message' => 'no_message',
'subject' => 'no_subject'
);
foreach ($check_array as $input => $msg)
{
if (empty($ibforums->input[$input]))
{
$std->Error( array( LEVEL => 1, MSG => $msg) );
}
}
$this->email->get_template("email_member");
$this->email->build_message( array(
'MESSAGE' => $ibforums->input['message'],
'MEMBER_NAME' => $member['name'],
'FROM_NAME' => $ibforums->member['name']
)
);
$this->email->subject = $ibforums->input['subject'];
$this->email->to = $member['email'];
$this->email->from = $ibforums->member['email'];
$this->email->send_mail();
$forum_jump = $std->build_forum_jump();
$forum_jump = preg_replace( "!#Forum Jump#!", $ibforums->lang['forum_jump'], $forum_jump);
$this->output = $this->html->sent_screen($member['name']);
$this->output .= $this->html->forum_jump($forum_jump);
$this->page_title = $ibforums->lang['email_sent'];
$this->nav = array( $ibforums->lang['email_sent'] );
}
else
{
// Show the form, booo...
if ( empty($ibforums->input['MID']) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
}
//----------------------------------
if (! preg_match( "/^(\d+)$/" , $ibforums->input['MID'] ) )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_use' ) );
}
//----------------------------------
$DB->query("SELECT name, id, email, hide_email from ibf_members WHERE id='".$ibforums->input['MID']."'");
$member = $DB->fetch_row();
//----------------------------------
if (! $member['id'] )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_such_user' ) );
}
if ($member['hide_email'] == 1)
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'private_email' ) );
}
//----------------------------------
$this->output = $ibforums->vars['use_mail_form']
? $this->html->send_form(
array(
'NAME' => $member['name'],
'TO' => $member['id'],
)
)
: $this->html->show_address(
array(
'NAME' => $member['name'],
'ADDRESS' => $member['email'],
)
);
$this->page_title = $ibforums->lang['member_address_title'];
$this->nav = array( $ibforums->lang['member_address_title'] );
}
}
}
?>
+285
View File
@@ -0,0 +1,285 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Forward topic to a friend module
| > Module written by Matt Mecham
| > Date started: 21st March 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new Forward;
class Forward {
var $output = "";
var $base_url = "";
var $html = "";
var $forum = array();
var $topic = array();
var $category = array();
/***********************************************************************************/
//
// Our constructor, load words, load skin, print the topic listing
//
/***********************************************************************************/
function Forward() {
global $ibforums, $DB, $std, $print, $skin_universal;
require "./Skin/".$ibforums->skin_id."/skin_emails.php";
//-------------------------------------
// Compile the language file
//-------------------------------------
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_emails', $ibforums->lang_id);
$this->html = new skin_emails();
//-------------------------------------
// Check the input
//-------------------------------------
$ibforums->input['t'] = $std->is_number($ibforums->input['t']);
$ibforums->input['f'] = $std->is_number($ibforums->input['f']);
if ($ibforums->input['t'] < 0 or $ibforums->input['f'] < 0)
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-------------------------------------
// Get the forum info based on the forum ID, get the category name, ID, and get the topic details
//-------------------------------------
$DB->query("SELECT t.*, f.name as forum_name, f.id as forum_id, f.read_perms, f.reply_perms, f.start_perms, f.allow_poll, f.posts as forum_posts, f.topics as forum_topics, f.use_attach, c.name as cat_name, c.id as cat_id FROM ibf_topics t, ibf_forums f , ibf_categories c where t.tid='".$ibforums->input[t]."' and f.id = t.forum_id and f.category=c.id");
$this->topic = $DB->fetch_row();
$this->forum = array( 'id' => $this->topic['forum_id'] ,
'name' => $this->topic['forum_name'] ,
'posts' => $this->topic['forum_posts'] ,
'topics' => $this->topic['forum_topics'] ,
'read_perms' => $this->topic['read_perms'] ,
'allow_poll' => $this->topic['allow_poll'] ,
'use_attach' => $this->topic['use_attach']
);
$this->category = array( 'name' => $this->topic['cat_name'],
'id' => $this->topic['cat_id'] ,
);
//-------------------------------------
// Error out if we can not find the forum
//-------------------------------------
if (!$this->forum['id'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-------------------------------------
// Error out if we can not find the topic
//-------------------------------------
if (!$this->topic['tid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
$this->base_url_NS = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}";
//-------------------------------------
// Check viewing permissions, private forums,
// password forums, etc
//-------------------------------------
if (! $ibforums->member['id'] )
{
$std->Error( array( LEVEL => 1, MSG => 'no_guests') );
}
$bad_entry = $this->check_access();
if ($bad_entry == 1)
{
$std->Error( array( LEVEL => 1, MSG => 'no_view_topic') );
}
// What to do?
if ($ibforums->input['CODE'] == '01')
{
$this->send_email();
}
else
{
$this->show_form();
}
}
function send_email() {
global $std, $ibforums, $DB, $print;
require "./sources/lib/emailer.php";
$this->email = new emailer();
$lang_to_use = 'en';
$DB->query("SELECT lid, ldir, lname FROM ibf_languages");
while ( $l = $DB->fetch_row() )
{
if ($ibforums->input['lang'] == $l['ldir'])
{
$lang_to_use = $l['ldir'];
}
}
$check_array = array ( 'to_name' => 'stf_no_name',
'to_email' => 'stf_no_email',
'message' => 'stf_no_msg',
'subject' => 'stf_no_subject'
);
foreach ($check_array as $input => $msg)
{
if (empty($ibforums->input[$input]))
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => $msg) );
}
}
$to_email = $std->clean_email($ibforums->input['to_email']);
if (! $to_email )
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'invalid_email' ) );
}
$this->email->get_template("forward_page", $lang_to_use);
$this->email->build_message( array(
'THE_MESSAGE' => str_replace( "<br>", "\n", $ibforums->input['message'] ),
'TO_NAME' => $ibforums->input['to_name'],
'FROM_NAME' => $ibforums->member['name'],
)
);
$this->email->subject = $ibforums->input['subject'];
$this->email->to = $ibforums->input['to_email'];
$this->email->from = $ibforums->member['email'];
$this->email->send_mail();
$print->redirect_screen( $ibforums->lang['redirect'], "act=ST&f=".$this->forum['id']."&t=".$this->topic['tid']."&st=".$ibforums->input['st'] );
}
function show_form() {
global $std, $ibforums, $DB, $print, $root_path;
require $root_path."lang/".$ibforums->lang_id."/email_content.php";
$ibforums->lang['send_text'] = $EMAIL['send_text'];
$lang_array = unserialize(stripslashes($ibforums->vars['languages']));
$lang_select = "<select name='lang' class='forminput'>\n";
$DB->query("SELECT lid, ldir, lname FROM ibf_languages");
while ( $l = $DB->fetch_row() )
{
$lang_select .= $l['ldir'] == $ibforums->member['language'] ? "<option value='{$l['ldir']}' selected>{$l['lname']}</option>"
: "<option value='{$l['ldir']}'>{$l['lname']}</option>";
}
$lang_select .= "</select>";
$ibforums->lang['send_text'] = preg_replace( "/<#THE LINK#>/" , $this->base_url_NS."?act=ST&f=".$this->forum['id']."&t=".$this->topic['tid'], $ibforums->lang['send_text'] );
$ibforums->lang['send_text'] = preg_replace( "/<#USER NAME#>/", $ibforums->member['name'], $ibforums->lang['send_text'] );
$this->output = $this->html->forward_form( $this->topic['title'], $ibforums->lang ['send_text'], $lang_select );
$this->page_title = $ibforums->lang['title'];
$this->nav = array ( "<a href='{$this->base_url}&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>", "<a href='".$this->base_url."&act=ST&f={$this->forum['id']}&t={$this->topic['tid']}'>{$this->topic['title']}</a>", $ibforums->lang['title'] );
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
}
//+----------------------------------------------------------------------------------
function check_access() {
global $ibforums, $HTTP_COOKIE_VARS;
$return = 1;
$this->m_group = $ibforums->member['mgroup'];
if ($this->forum['read_perms'] == '*') {
$return = 0;
}
else if (preg_match( "/(^|,)$this->m_group(,|$)/", $this->forum['read_perms'] ) ) {
$return = 0;
}
if ($this->forum['password']) {
if ($HTTP_COOKIE_VARS[ $ibforums->vars['cookie_id'].'iBForum'.$this->forum['id'] ] == $this->forum['password']) {
$return = 0;
} else {
$return = 1;
}
}
return $return;
}
}
?>
+368
View File
@@ -0,0 +1,368 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Log in / log out module
| > Module written by Matt Mecham
| > Date started: 12th December 2001
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new Login;
class Login {
var $output = "";
var $page_title = "";
var $nav = array();
var $login_html = "";
function Login() {
global $ibforums, $DB, $std, $print;
// Make sure our code number is numerical only
//$ibforums->input[CODE] = preg_replace("/^([0-9]+)$/", "$1", $ibforums->input[CODE]);
// Require the HTML and language modules
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_login', $ibforums->lang_id);
require "./Skin/".$ibforums->skin_id."/skin_login.php";
$this->login_html = new skin_login();
// What to do?
switch($ibforums->input[CODE]) {
case '01':
$this->do_log_in();
break;
case '02':
$this->log_in_form();
break;
case '03':
$this->do_log_out();
break;
default:
$this->log_in_form();
break;
}
// If we have any HTML to print, do so...
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
}
function log_in_form($message="") {
global $ibforums, $DB, $std, $print, $HTTP_REFERER;
//+--------------------------------------------
//| Are they banned?
//+--------------------------------------------
if ($message != "")
{
$this->output .= $this->login_html->errors( $ibforums->lang[ $message ] );
}
$html = <<<EOF
<script language='JavaScript'>
<!--
function ValidateForm() {
var Check = 0;
if (document.LOGIN.UserName.value == '') { Check = 1; }
if (document.LOGIN.PassWord.value == '') { Check = 1; }
if (Check == 1) {
alert("{$ibforums->lang[blank_fields]}");
return false;
} else {
document.LOGIN.submit.disabled = true;
return true;
}
}
//-->
</script>
<br>
<table cellpadding='3' cellspacing='1' border='0' align='center' width='{$ibforums->skin['tbl_width']}'>
<tr>
<td align='left'>{$ibforums->lang['login_text']}</td>
</tr>
<tr>
<td align='left'><b>{$ibforums->lang[forgot_pass]} <a href='{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?act=Reg&CODE=10'>{$ibforums->lang[pass_link]}</a></b></td>
</tr>
</table>
<form action="{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}" method="post" name='LOGIN' onSubmit='return ValidateForm()'>
<input type='hidden' name='act' value='ib3'>
<input type='hidden' name='CODE' value='01'>
<input type='hidden' name='s' value='{$ibforums->session_id}'>
<input type='hidden' name='referer' value="">
<table cellpadding='0' cellspacing='0' border='0' width='{$ibforums->skin['tbl_width']}' bgcolor='{$ibforums->skin['tbl_border']}' align='center'>
<tr>
<td>
<table cellpadding='3' cellspacing='1' border='0' width='100%'>
<tr>
<td align='left' colspan='2' id='titlemedium'>Please enter your old Ikonboard 3 Username and Password</td>
</tr>
<tr>
<td id='row1' width='40%'>Your Ikonboard 3 Username</td>
<td id='row1'><input type='text' size='20' maxlength='64' name='UserName' class='forminput'></td>
</tr>
<tr>
<td id='row1' width='40%'>Your Ikonboard 3 Password</td>
<td id='row1'><input type='password' size='20' name='PassWord' class='forminput'></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<table cellpadding='0' cellspacing='0' border='0' width='{$ibforums->skin['tbl_width']}' bgcolor='{$ibforums->skin['tbl_border']}' align='center'>
<tr>
<td>
<table cellpadding='3' cellspacing='1' border='0' width='100%'>
<tr>
<td align='left' colspan='2' id='titlemedium'>{$ibforums->lang[options]}</td>
</tr>
<tr>
<td id='row1' width='40%' align='left' valign='top'>{$ibforums->lang[cookies]}</td>
<td id='row1' width='40%'><input type="radio" name="CookieDate" value="1" checked>{$ibforums->lang[cookie_yes]}<br><input type="radio" name="CookieDate" value="0">{$ibforums->lang[cookie_no]}</td>
</tr>
<tr>
<td id='row1' width='40%' align='left' valign='top'>{$ibforums->lang[privacy]}</td>
<td id='row1' width='40%'><input type="checkbox" name="Privacy" value="1">{$ibforums->lang[anon_name]}</td>
</tr>
<tr>
<td id='row2' align='center' colspan='2'>
<input type="submit" name='submit' value="{$ibforums->lang[log_in_submit]}" class='forminput'>
</td></tr></table>
</td></tr></table>
</form>
EOF;
$this->output .= $html;
$this->nav = array( "Upgrade my old Ikonboard Account" );
$this->page_title = "Upgrade my old Ikonboard Account";
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
exit();
}
function do_log_in() {
global $DB, $ibforums, $std, $print, $sess, $HTTP_USER_AGENT, $HTTP_POST_VARS;
$url = "";
//-------------------------------------------------
// Make sure the username and password were entered
//-------------------------------------------------
if ($HTTP_POST_VARS['UserName'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'no_username' ) );
}
if ($HTTP_POST_VARS['PassWord'] == "")
{
$std->Error( array( 'LEVEL' => 1, 'MSG' => 'pass_blank' ) );
}
//-------------------------------------------------
// Check for input length
//-------------------------------------------------
if (strlen($ibforums->input['UserName']) > 32)
{
$std->Error( array( LEVEL => 1, MSG => 'username_long' ) );
}
if (strlen($ibforums->input['PassWord']) > 32)
{
$std->Error( array( LEVEL => 1, MSG => 'pass_too_long' ) );
}
$username = strtolower($ibforums->input['UserName']);
$password = crypt( $ibforums->input['PassWord'], substr( strtolower($ibforums->input['UserName']), 0, 2) );
//-------------------------------------------------
// Attempt to get the user details
//-------------------------------------------------
$DB->query("SELECT id, name, mgroup, password, new_pass FROM ibf_members WHERE LOWER(name)='$username'");
if ($DB->get_num_rows())
{
$member = $DB->fetch_row();
if ( empty($member['id']) or ($member['id'] == "") )
{
$this->log_in_form( 'wrong_name' );
}
if ($member['password'] != $password)
{
$this->log_in_form( 'wrong_pass' );
}
// SET REAL PASSY
$real_pass = md5($ibforums->input['PassWord']);
//------------------------------
if ($ibforums->input['s'])
{
$session_id = $ibforums->input['s'];
// Delete any old sessions with this users IP addy that doesn't match our
// session ID.
$DB->query("DELETE FROM ibf_sessions WHERE ip_address='".$ibforums->input['IP_ADDRESS']."' AND id <> '$session_id'");
$db_string = $DB->compile_db_update_string( array (
'member_name' => $member['name'],
'member_pass' => $real_pass,
'member_id' => $member['id'],
'running_time' => time(),
'member_group' => $member['mgroup']
) );
$db_query = "UPDATE ibf_sessions SET $db_string WHERE id='".$ibforums->input['s']."'";
}
else
{
$session_id = md5( uniqid(microtime()) );
// Delete any old sessions with this users IP addy.
$DB->query("DELETE FROM ibf_sessions WHERE ip_address='".$ibforums->input['IP_ADDRESS']."'");
$db_string = $DB->compile_db_insert_string( array (
'id' => $session_id,
'member_name' => $member['name'],
'member_pass' => $real_pass,
'member_id' => $member['id'],
'running_time' => time(),
'member_group' => $member['mgroup'],
'ip_address' => substr($ibforums->input['IP_ADDRESS'], 0, 50),
'browser' => substr($HTTP_USER_AGENT, 0, 50),
'start_session'=> time(),
) );
$db_query = "INSERT INTO ibf_sessions (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")";
}
$DB->query( $db_query );
//-----------------------------------
// RESET PASS IN MD5
//-----------------------------------
$DB->query("UPDATE ibf_members SET password='$real_pass' WHERE id='".$member['id']."'");
$ibforums->member = $member;
$ibforums->session_id = $session_id;
//------------------------------
if ($ibforums->input['CookieDate'])
{
$std->my_setcookie("pass_hash" , $real_pass, 1);
$std->my_setcookie("member_id" , $member['id'], 1);
}
//-----------------------------------
// set our privacy cookie
//-----------------------------------
if ($ibforums->input[Privacy] == 1)
{
$std->my_setcookie( "anonlogin", 1 );
}
//-----------------------------------
// Redirect them to either the board
// index, or where they came from
//-----------------------------------
$print->redirect_screen( "{$ibforums->lang[thanks_for_login]} {$ibforums->member['name']}", $url );
}
else
{
$this->log_in_form( 'wrong_name' );
}
}
function do_log_out() {
global $std, $ibforums, $DB, $print;
if(! $ibforums->member['id'])
{
$std->Error( array( LEVEL => 1, MSG => 'no_guests') );
}
// Update the DB
$DB->query("UPDATE ibf_sessions SET ".
"member_name='NULL',".
"member_id='0',".
"member_pass='NULL',".
"login_type='0' ".
"WHERE id='". $ibforums->session_id ."'");
// Set some cookies
$std->my_setcookie( "member_id" , "0" );
$std->my_setcookie( "pass_hash" , "0" );
$std->my_setcookie( "skin" , "-1" );
// Redirect...
$print->redirect_screen( $ibforums->lang['thanks_for_logout'], "" );
}
}
?>
+108
View File
@@ -0,0 +1,108 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Show all emo's / BB Tags module
| > Module written by Matt Mecham
| > Date started: 18th April 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new legends;
class legends {
var $output = "";
var $base_url = "";
var $html = "";
function legends() {
//------------------------------------------------------
// $is_sub is a boolean operator.
// If set to 1, we don't show the "topic subscribed" page
// we simply end the subroutine and let the caller finish
// up for us.
//------------------------------------------------------
global $ibforums, $DB, $std, $print, $skin_universal;
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_legends', $ibforums->lang_id );
require "./Skin/".$ibforums->skin_id."/skin_legends.php";
$this->html = new skin_legends();
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
//--------------------------------------------
// What to do?
//--------------------------------------------
switch($ibforums->input['CODE'])
{
case 'emoticons':
$this->show_emoticons();
break;
default:
$this->show_emoticons();
break;
}
// If we have any HTML to print, do so...
$print->pop_up_window( $this->page_title, $this->output );
}
function show_emoticons()
{
global $ibforums, $DB, $std;
$this->page_title = $ibforums->lang['emo_title'];
$this->output .= $this->html->emoticon_javascript();
$this->output .= $this->html->page_header( $ibforums->lang['emo_title'], $ibforums->lang['emo_type'], $ibforums->lang['emo_img'] );
$DB->query("SELECT typed, image from ibf_emoticons");
if ( $DB->get_num_rows() )
{
while ( $r = $DB->fetch_row() )
{
$this->output .= $this->html->emoticons_row( stripslashes($r['typed']), stripslashes($r['image']) );
}
}
$this->output .= $this->html->page_footer();
}
}
?>
+390
View File
@@ -0,0 +1,390 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Topic display in printable format module
| > Module written by Matt Mecham
| > Date started: 25th March 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new Printable;
class Printable {
var $output = "";
var $base_url = "";
var $html = "";
var $moderator = array();
var $forum = array();
var $topic = array();
var $category = array();
var $mem_groups = array();
var $mem_titles = array();
var $mod_action = array();
var $poll_html = "";
/***********************************************************************************/
//
// Our constructor, load words, load skin, print the topic listing
//
/***********************************************************************************/
function Printable() {
global $ibforums, $DB, $std, $print, $skin_universal;
require "./Skin/".$ibforums->skin_id."/skin_printpage.php";
/***********************************/
// Compile the language file
/***********************************/
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_printpage', $ibforums->lang_id);
$this->html = new skin_printpage();
/***********************************/
// Check the input
/***********************************/
$ibforums->input['t'] = $std->is_number($ibforums->input['t']);
$ibforums->input['f'] = $std->is_number($ibforums->input['f']);
if ($ibforums->input['t'] < 0 or $ibforums->input['f'] < 0)
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-------------------------------------
// Get the forum info based on the forum ID, get the category name, ID, and get the topic details
//-------------------------------------
$DB->query("SELECT t.*, f.name as forum_name, f.id as forum_id, f.read_perms, f.password, f.reply_perms, f.start_perms, f.allow_poll, f.posts as forum_posts, f.topics as forum_topics, f.use_attach, c.name as cat_name, c.id as cat_id FROM ibf_topics t, ibf_forums f , ibf_categories c where t.tid='".$ibforums->input[t]."' and f.id = t.forum_id and f.category=c.id");
$this->topic = $DB->fetch_row();
$this->forum = array( 'id' => $this->topic['forum_id'] ,
'name' => $this->topic['forum_name'] ,
'posts' => $this->topic['forum_posts'] ,
'topics' => $this->topic['forum_topics'] ,
'read_perms' => $this->topic['read_perms'] ,
'allow_poll' => $this->topic['allow_poll'] ,
'use_attach' => $this->topic['use_attach'] ,
'password' => $this->topic['password']
);
$this->category = array( 'name' => $this->topic['cat_name'],
'id' => $this->topic['cat_id'] ,
);
//-------------------------------------
// Error out if we can not find the forum
//-------------------------------------
if (!$this->forum['id'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
//-------------------------------------
// Error out if we can not find the topic
//-------------------------------------
if (!$this->topic['tid'])
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
/***********************************/
// Check viewing permissions, private forums,
// password forums, etc
/***********************************/
if ( (!$this->topic['pin_state']) and (!$ibforums->member['g_other_topics']) )
{
$std->Error( array( LEVEL => 1, MSG => 'no_view_topic') );
}
$bad_entry = $this->check_access();
if ($bad_entry == 1) {
$std->Error( array( LEVEL => 1, MSG => 'no_view_topic') );
}
/***********************************/
// Render the page top
/***********************************/
$this->output .= $this->html->pp_header( $this->forum['name'], $this->topic['title'], $this->topic['starter_name'] );
/*******************************************************************************************/
// Grab the posts we'll need
/*******************************************************************************************/
// Set a prohibitive limit delibrately for long topics.
$max_posts = 300;
$DB->query( "SELECT * FROM ibf_posts WHERE topic_id='".$this->topic['tid']."'".
" and queued !='1' ORDER BY pid LIMIT 0, ".$max_posts);
// Loop through to pick out the correct member IDs.
// and push the post info into an array - maybe in the future
// we can add page spans, or maybe save to a PDF file?
$the_posts = array();
$mem_ids = "";
$member_array = array();
$cached_members = array();
while ($i = $DB->fetch_row() )
{
$the_posts[] = $i;
if ($i['author_id'] != 0)
{
if (preg_match( "/'".$i['author_id']."',/", $mem_ids) )
{
continue;
}
else
{
$mem_ids .= "'".$i['author_id']."',";
}
}
}
// Fix up the member_id string
$mem_ids = preg_replace( "/,$/", "", $mem_ids);
// Get the member profiles needed for this topic
if ($mem_ids != "")
{
$DB->query("SELECT id,name,mgroup,email,joined,ip_address,avatar,avatar_size,posts,aim_name,icq_number,signature,
website,yahoo,title,hide_email,msnname from ibf_members WHERE id in ($mem_ids)");
while ( $m = $DB->fetch_row() )
{
if ($m['id'] and $m['name'])
{
if (isset($member_array[ $m['id'] ]))
{
continue;
}
else
{
$member_array[ $m['id'] ] = $m;
}
}
}
}
/***********************************/
// Format and print out the topic list
/***********************************/
$td_col_cnt = 0;
foreach ($the_posts as $row) {
$poster = array();
// Get the member info. We parse the data and cache it.
// It's likely that the same member posts several times in
// one page, so it's not efficient to keep parsing the same
// data
if ($row['author_id'] != 0)
{
// Is it in the hash?
if ( isset($cached_members[ $row['author_id'] ]) )
{
// Ok, it's already cached, read from it
$poster = $cached_members[ $row['author_id'] ];
$row['name_css'] = 'normalname';
}
else
{
// Ok, it's NOT in the cache, is it a member thats
// not been deleted?
if ($member_array[ $row['author_id'] ])
{
$row['name_css'] = 'normalname';
$poster = $member_array[ $row['author_id'] ];
// Add it to the cached list
$cached_members[ $row['author_id'] ] = $poster;
}
else
{
// It's probably a deleted member, so treat them as a guest
$poster = $std->set_up_guest( $row['author_id'] );
$row['name_css'] = 'unreg';
}
}
}
else
{
// It's definately a guest...
$poster = $std->set_up_guest( $row['author_name'] );
$row['name_css'] = 'unreg';
}
//--------------------------------------------------------------
$row['post_css'] = $td_col_count % 2 ? 'post1' : 'post2';
++$td_col_count;
//--------------------------------------------------------------
if (!$ibforums->skin[EDIT_FONT_SIZE]) $ibforums->skin[EDIT_FONT_SIZE] = 7;
$row['post'] = preg_replace( "/<!--EDIT\|(.+?)\|(.+?)-->/", "<span style='font-size:$ibforums->skin[EDIT_FONT_SIZE]pt'>Edited by \\1 on \\2</span>", $row['post'] );
//--------------------------------------------------------------
if (!$ibforums->member['view_img'])
{
$row['post'] = preg_replace( "/<img src[\"'](.+?)[\"'].+?".">/", "(IMG:<a href='\\1' target='_blank'>\\1</a>)", $row['post'] );
}
$row['post_date'] = $std->get_date( $row['post_date'], 'LONG' );
$row['post'] = $this->parse_message($row['post']);
//--------------------------------------------------------------
// Siggie stuff
//--------------------------------------------------------------
if (!$ibforums->vars[SIG_SEP]) $ibforums->vars[SIG_SEP] = "<br><br>--------------------<br>";
if ($poster['signature'] and $ibforums->member['view_sigs'])
{
if ($row['use_sig'] == 1)
{
$row['signature'] = "<!--Signature-->{$ibforums->vars[SIG_SEP]}<span id='signature'>{$poster['signature']}</span><!--E-Signature-->";
}
}
$this->output .= $this->html->pp_postentry( $poster, $row );
}
/***********************************/
// Print the footer
/***********************************/
$this->output .= $this->html->pp_end();
/***********************************/
// Print all the output
/***********************************/
$this->output .= "<br><br><font size='1'><center>Powered by Invision Board<br>&copy; 2002 Invision PS</center></font></body></html>";
echo($this->output);
exit;
}
function parse_message($message="") {
$message = preg_replace( "#<!--emo&(.+?)-->.+?<!--endemo-->#", "\\1" , $message );
$message = preg_replace( "#<!--c1-->(.+?)<!--ec1-->#", "\n\n------------ CODE SAMPLE ----------\n" , $message );
$message = preg_replace( "#<!--c2-->(.+?)<!--ec2-->#", "\n-----------------------------------\n\n" , $message );
$message = preg_replace( "#<!--QuoteBegin-->(.+?)<!--QuoteEBegin-->#" , "\n\n------------ QUOTE ----------\n" , $message );
$message = preg_replace( "#<!--QuoteBegin--(.+?)\+(.+?)-->(.+?)<!--QuoteEBegin-->#" , "\n\n------------ QUOTE ----------\n" , $message );
$message = preg_replace( "#<!--QuoteEnd-->(.+?)<!--QuoteEEnd-->#" , "\n-----------------------------\n\n" , $message );
$message = preg_replace( "#<!--Flash (.+?)-->.+?<!--End Flash-->#e" , "(FLASH MOVIE)" , $message );
$message = preg_replace( "#<img src=[\"'](\S+?)['\"].+"."?".">#" , "(IMAGE: \\1)" , $message );
$message = preg_replace( "#<a href=[\"'](http|https|ftp|news)://(\S+?)['\"].+?".">(.+?)</a>#" , "(URL: \\1://\\2)" , $message );
$message = preg_replace( "#<a href=[\"']mailto:(.+?)['\"]>(.+?)</a>#" , "(EMAIL: \\2)" , $message );
$message = preg_replace( "#<!--sql-->(.+?)<!--sql1-->(.+?)<!--sql2-->(.+?)<!--sql3-->#e" , "\n\n--------------- SQL -----------\n\\2\n----------------\n\n", $message);
$message = preg_replace( "#<!--html-->(.+?)<!--html1-->(.+?)<!--html2-->(.+?)<!--html3-->#e", "\n\n-------------- HTML -----------\n\\2\n----------------\n\n", $message);
return $message;
}
function check_access() {
global $ibforums, $std, $HTTP_COOKIE_VARS;
$return = 1;
$this->m_group = $ibforums->member['mgroup'];
if ($this->forum['read_perms'] == '*')
{
$return = 0;
}
else if (preg_match( "/(^|,)$this->m_group(,|$)/", $this->forum['read_perms'] ) )
{
$return = 0;
}
if ($this->forum['password'] != "")
{
if ( ! $c_pass = $std->my_getcookie('iBForum'.$this->forum['id']) )
{
return 1;
}
if ( $c_pass == $this->forum['password'] )
{
return 0;
}
else
{
return 1;
}
}
return $return;
}
}
?>
+336
View File
@@ -0,0 +1,336 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Topic Tracker module
| > Module written by Matt Mecham
| > Date started: 6th March 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new stats;
class stats {
var $output = "";
var $base_url = "";
var $html = "";
function stats() {
//------------------------------------------------------
// $is_sub is a boolean operator.
// If set to 1, we don't show the "topic subscribed" page
// we simply end the subroutine and let the caller finish
// up for us.
//------------------------------------------------------
global $ibforums, $DB, $std, $print, $skin_universal;
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_stats', $ibforums->lang_id );
require "./Skin/".$ibforums->skin_id."/skin_stats.php";
$this->html = new skin_stats();
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
//--------------------------------------------
// What to do?
//--------------------------------------------
switch($ibforums->input['CODE'])
{
case 'leaders':
$this->show_leaders();
break;
case '02':
$this->do_search();
break;
case 'id':
$this->show_queries();
break;
default:
$this->show_today_posters();
break;
}
// If we have any HTML to print, do so...
$print->add_output("$this->output");
$print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
}
function show_leaders()
{
global $ibforums, $DB, $std;
$this->output .= $this->html->page_title( $ibforums->lang['forum_leaders'] );
//--------------------------------------------
// Work out where our super mods are at
//--------------------------------------------
$sup_ids = array();
$DB->query("SELECT g_id from ibf_groups WHERE g_is_supmod = 1");
if ( $DB->get_num_rows() )
{
while ( $i = $DB->fetch_row() )
{
$sup_ids[] = $i['g_id'];
}
}
//--------------------------------------------
// Get our admins
//--------------------------------------------
$admin_ids = array();
$DB->query("SELECT id, name, email, hide_email, location, aim_name, icq_number from ibf_members WHERE mgroup='".$ibforums->vars['admin_group']."'");
$this->output .= $this->html->group_strip( $ibforums->lang['leader_admins'] );
while ( $member = $DB->fetch_row() )
{
$this->output .= $this->html->leader_row( $this->parse_member( $member ), $ibforums->lang['leader_all_forums'] );
$admin_ids[] = $member['id'];
}
$this->output .= $this->html->close_strip();
//--------------------------------------------
// Do the bizz with the super men, er mods.
//--------------------------------------------
$admin_ids[] = '0';
if ( count($sup_ids) > 0 )
{
$DB->query("SELECT id, name, email, hide_email, location, aim_name, icq_number from ibf_members WHERE mgroup IN (".implode( ',', $sup_ids ).") and id NOT IN(".implode(',', $admin_ids).")");
if ( $DB->get_num_rows() )
{
$this->output .= $this->html->group_strip( $ibforums->lang['leader_global'] );
while ( $member = $DB->fetch_row() )
{
$this->output .= $this->html->leader_row( $this->parse_member( $member ), $ibforums->lang['leader_all_forums'] );
}
$this->output .= $this->html->close_strip();
}
}
//--------------------------------------------
// Do we have any moderators?.
//--------------------------------------------
$DB->query("SELECT m.id, m.name, m.email, m.hide_email, m.location, m.aim_name, m.icq_number, f.id as forum_id, f.read_perms, f.name as forum_name FROM ibf_members m, ibf_forums f, ibf_moderators mod "
."WHERE m.id=mod.member_id and f.id=mod.forum_id");
$data = array();
while ( $i = $DB->fetch_row() )
{
if ( preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|$)/", $i['read_perms'] ) )
{
$data[] = $i;
}
else if ( $i['read_perms'] == '*' )
{
$data[] = $i;
}
}
//------------------------
if ( count($data) > 0 )
{
$mod_array = array();
$this->output .= $this->html->group_strip( $ibforums->lang['leader_mods'] );
foreach ( $data as $idx => $i )
{
if ( !isset( $mod_array['member'][ $i['id'] ][ 'name' ] ) )
{
// Member is not already set, lets add the member...
$mod_array['member'][ $i['id'] ] = array( 'name' => $i['name'],
'email' => $i['email'],
'hide_email' => $i['hide_email'],
'location' => $i['location'],
'aim_name' => $i['aim_name'],
'icq_number' => $i['icq_number'],
'id' => $i['id']
);
}
// Add forum..
$mod_array['forums'][ $i['id'] ][] = "<a href='".$ibforums->base_url."&act=SF&f=".$i['forum_id']."'>".$i['forum_name']."</a>";
}
foreach( $mod_array['member'] as $id => $data )
{
$this->output .= $this->html->leader_row(
$this->parse_member( $mod_array['member'][ $id ] ),
implode( "<br>", $mod_array['forums'][ $id ] )
);
}
$this->output .= $this->html->close_strip();
}
$this->page_title = $ibforums->lang['forum_leaders'];
$this->nav = array( $ibforums->lang['forum_leaders'] );
}
function show_queries()
{
global $ibforums, $DB, $std;
// show DB queries in graphic format(depreciated)
// left here to stop other functions breaking
flush();
header("Content-type: image/gif");
echo base64_decode("R0lGODlhhgAfAMQAAAAAAP///+/v79/f38/Pz7+/v6+vr5+fn4+Pj4CAgHBwcGBgYFBQUEBAQDAwMCAgIBAQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAhgAfAAAF/2AgjmRpnmiqrmzrvnAsz3Rt33iu7/x8mL8AgcEgiBINg2i4EAiJxtEhmlKYrCpCY5uYYXurQ8GUGAQeB8NDYFgU1oFkwopWO4/jrImKKrgLDXkwDWAsCyICC0VCCARYCQUKRggGAgwiDY54I5ABBwpFBVEGAz+AWD+JiwUGDV0FXQGwAapGia4iBwwGWgeEhSq/CwgHDpgkCwO/sLNxyGabEAgJCwSHAcaEDn4/hMPFAUhvA80KP9/GCgoFDkYApA5tv8AnBLHGAUoBlyKAzrKQYs3zx2kMPm1CDhF6UECAE4QBqiVQAqkAgIsQnOCrpm8dtoQBlNHrI7DELwJwlv8FPCYETsF/hBQYmOjsAIAHRgj9CjimYqxP/yANAQBhDKFm80aSaIZPHyEB7UQk83RgwLWnUUl0+kXIgAIHD0MKQHAJ4rpOPkeYLbArnFFZVgQkVSpiAJYiKEVcWpRLgVwzDga02cdnE1dM/LQJGOKsCFS3bpsdOOQ4G4EBDP+BRTCX7r4lDyDoK3LxYsMGAFBBwEmgNABBW1kOO3Zgdc6WEH6gLWDxYgMzKHPnW72gWy4ICzrTbWLCQBDP0KP3eT7Cr/Tr2PuZEJS9u/fv4MOLH1/3DowBTgrLQK9CALQR7lewnxEfTKcRh8SoYAD4xpQs1AkRIBncwdBMDxXdQcj/fQIU6IxVO1yWQoPmLfFeg3g0NIKESwiyGC28xTKChiCS8OEA6pWQgAMNPBCHa4A04IAVnUA4WRde5YNLjq3gaMVMGcoIgTVRbJMAVDICFMBXosXBgAOXrJjkkg40qcADLIaTJYsOiIhNAxAMgJkD+GD5wFcPIKBCAl244cxWP4AlhZrVxHSJJHYuqcWSd0ZRESEHTPTjWbMgQM6RxjwWyBnhWCHTY4qKYEwCauaogIg5HvCJEjIFkJEAnyr3UmyxQSaCJI3t4xche636GQOuZvhKF8ZUA8sAyI3BTEmHdbIrSzNBAJmvIt73zyyH/YPCbm++ZepHcgWAAFuaXjIt6wPVSkutLgXNMksRxsxiTVG/OtOrriuZy8CKw6L7EkvIsiTqJqQaZQQDd0QLpBaGNqAmv8r862/A3c7qyQKH3FppQAPwk80xCfxATMOS/uNiJweoOc2cniBQjbTGwbRmT2PklgB/Wyhw1KGmDukpNC6HKULMYpLsbRegKjHLAyuGGAcoXfTKc0pAn6GysJ0IMHQXqfAcJjsJpCSvCgWYUXU+BwhQRiYIOFH11c8FEXYuUpBNjiw1h5RH1mqHVOMYY4lNtihlIEJMXZCQcrXbBIwRxAD33Uq2J4PPMC95iNdweOKMN+7445BfFwIAOw==");
exit();
}
function show_today_posters()
{
global $ibforums, $DB, $std;
$this->output .= $this->html->page_title( $ibforums->lang['todays_posters'] );
$this->output .= $this->html->top_poster_header();
$time_high = time();
$time_low = $time_high - (60*60*24);
//--------------------------------------------
// Query the DB
//--------------------------------------------
$DB->query("SELECT COUNT(pid) as count FROM ibf_posts WHERE post_date < $time_high and post_date > $time_low");
$todays_posts = $DB->fetch_row();
if ($todays_posts['count'] > 0)
{
$DB->query("SELECT COUNT(p.pid) as tpost, m.id, m.name, m.joined, m.posts FROM ibf_posts p, ibf_members m "
."WHERE m.id > 0 AND m.id=p.author_id and post_date < $time_high and post_date > $time_low GROUP BY p.author_id ORDER BY tpost DESC LIMIT 0,10");
if ( $DB->get_num_rows() )
{
while ($info = $DB->fetch_row())
{
$info['total_today_posts'] = $todays_posts['count'];
if ($todays_posts['count'] > 0 and $info['tpost'] > 0)
{
$info['today_pct'] = sprintf( '%.2f', ( $info['tpost'] / $todays_posts['count'] ) * 100 );
}
$info['joined'] = $std->get_date( $info['joined'], 'JOINED' );
$this->output .= $this->html->top_poster_row( $info );
}
}
else
{
$this->output .= $this->html->top_poster_no_info();
}
}
else
{
$this->output .= $this->html->top_poster_no_info();
}
$this->output .= $this->html->top_poster_footer( $todays_posts['count'] );
$this->page_title = $ibforums->lang['top_poster_title'];
$this->nav = array( $ibforums->lang['top_poster_title'] );
}
//------------------------------------------------------------------------------------------------
function parse_member( $member )
{
global $ibforums, $std;
$member['msg_icon'] = "<a href='{$this->base_url}&act=Msg&CODE=04&MID={$member['id']}'>{$ibforums->skin['P_MSG']}</a>";
if (!$member['hide_email'])
{
$member['email_icon'] = "<a href='{$this->base_url}&act=Mail&CODE=00&MID={$member['id']}'>{$ibforums->skin['P_EMAIL']}</a>";
}
else
{
$member['email_icon'] = '&nbsp;';
}
if ($member['icq_number'])
{
$member['icq_icon'] = "<a href=\"javascript:PopUp('{$this->base_url}&act=ICQ&MID={$member['id']}','Pager','450','330','0','1','1','1')\">{$ibforums->skin[P_ICQ]}</a>";
}
else
{
$member['icq_iconn'] = '&nbsp;';
}
if ($member['aim_name'])
{
$member['aol_icon'] = "<a href=\"javascript:PopUp('{$this->base_url}&act=AOL&MID={$member['id']}','Pager','450','330','0','1','1','1')\">{$ibforums->skin[P_AOL]}</a>";
}
else
{
$member['aol_icon'] = '&nbsp;';
}
return $member;
}
}
?>
+210
View File
@@ -0,0 +1,210 @@
<?php
/*
+--------------------------------------------------------------------------
| IBFORUMS v1
| ========================================
| by Matthew Mecham and David Baxter
| (c) 2001,2002 IBForums
| http://www.ibforums.com
| ========================================
| Web: http://www.ibforums.com
| Email: phpboards@ibforums.com
| Licence Info: phpib-licence@ibforums.com
+---------------------------------------------------------------------------
|
| > Topic Tracker module
| > Module written by Matt Mecham
| > Date started: 5th March 2002
|
| > Module Version Number: 1.0.0
+--------------------------------------------------------------------------
*/
$idx = new tracker;
class tracker {
var $output = "";
var $base_url = "";
var $html = "";
var $forum = array();
var $topic = array();
var $category = array();
function tracker($is_sub=0) {
//------------------------------------------------------
// $is_sub is a boolean operator.
// If set to 1, we don't show the "topic subscribed" page
// we simply end the subroutine and let the caller finish
// up for us.
//------------------------------------------------------
global $ibforums, $DB, $std, $print, $skin_universal;
$ibforums->lang = $std->load_words($ibforums->lang, 'lang_emails', $ibforums->lang_id);
//------------------------------------------------------
// Check the input
//------------------------------------------------------
$ibforums->input['t'] = $std->is_number($ibforums->input['t']);
$ibforums->input['f'] = $std->is_number($ibforums->input['f']);
if ($ibforums->input['t'] < 0 or $ibforums->input['f'] < 0)
{
if ($is_sub != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
else
{
return;
}
}
//------------------------------------------------------
// Get the forum info based on the forum ID, get the category name, ID, and get the topic details
//------------------------------------------------------
$DB->query("SELECT t.tid, f.id as fid, f.read_perms, f.password FROM ibf_topics t, ibf_forums f WHERE t.tid='".$ibforums->input['t']."' AND t.forum_id=f.id");
$this->topic = $DB->fetch_row();
//------------------------------------------------------
// Error out if we can not find the forum
//------------------------------------------------------
if (!$this->topic['fid'])
{
if ($is_sub != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
else
{
return;
}
}
//------------------------------------------------------
// Error out if we can not find the topic
//------------------------------------------------------
if (!$this->topic['tid'])
{
if ($is_sub != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'missing_files') );
}
else
{
return;
}
}
$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
$this->base_url_NS = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}";
//------------------------------------------------------
// Check viewing permissions, private forums,
// password forums, etc
//------------------------------------------------------
if (! $ibforums->member['id'] ) {
if ($is_sub != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'no_guests') );
}
else
{
return;
}
}
if ($this->topic['read_perms'] != '*')
{
if (! preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|$)/", $this->topic['read_perms'] ) )
{
if ($is_sub != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'forum_no_access') );
}
else
{
return;
}
}
}
if ($this->topic['password'] != "")
{
if ( ! $c_pass = $std->my_getcookie('iBForum'.$this->topic['fid']) )
{
$std->Error( array( LEVEL => 1, MSG => 'forum_no_access') );
}
if ( $c_pass != $this->topic['password'] )
{
$std->Error( array( LEVEL => 1, MSG => 'forum_no_access') );
}
}
//------------------------------------------------------
// Have we already subscribed?
//------------------------------------------------------
$DB->query("SELECT trid from ibf_tracker WHERE topic_id='".$this->topic['tid']."' AND member_id='".$ibforums->member['id']."'");
if ( $DB->get_num_rows() )
{
if ($is_sub != 1)
{
$std->Error( array( LEVEL => 1, MSG => 'already_sub') );
}
else
{
return;
}
}
//------------------------------------------------------
// Add it to the DB
//------------------------------------------------------
$db_string = $DB->compile_db_insert_string( array (
'member_id' => $ibforums->member['id'],
'topic_id' => $this->topic['tid'],
'start_date' => time(),
) );
$DB->query("INSERT INTO ibf_tracker (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
if ($is_sub != 1)
{
$print->redirect_screen( $ibforums->lang['sub_added'], "act=ST&f={$this->topic['fid']}&t={$this->topic['tid']}&st={$ibforums->input['st']}" );
}
else
{
return;
}
}
}
?>
File diff suppressed because it is too large. Load diff