⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 200_beta_1.php

📁 CMS系统
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php

// this function is used to revert articles back to HTML since we are now using a WYSIWYG editor
function FormatText($text)
{
  $text = ereg_replace("\\[URL=([^\\[]*)\]([^\\[]*)\\[/URL\\]","<a href=\"\\1\" target=\"_blank\">\\2</a>", $text);
  $text = ereg_replace("\\[URL\]([^\\[]*)\\[/URL\\]","<a href=\"\\1\" target=\"_blank\">\\1</a>", $text);

  $text = str_replace("[IMG]","<img src=\"", $text);
  $text = str_replace("[/IMG]","\" border=\"0\" alt=\"\" />", $text);
  $text = str_replace("[B]","<b>", $text);
  $text = str_replace("[/B]","</b>", $text);
  $text = str_replace("[I]","<i>", $text);
  $text = str_replace("[/I]","</i>", $text);
  $text = str_replace("[U]","<u>", $text);
  $text = str_replace("[/U]","</u>", $text);
  $text = str_replace("[HTML]","", $text);
  $text = str_replace("[/HTML]","", $text);

  return nl2br($text);
}

// invision and simple machines forum integration
$DB->query("INSERT INTO " . TABLE_PREFIX . "usersystems VALUES ('0', 'Invision Power Board 2',  '0', '', 'ipb2.php', '', '') ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "usersystems VALUES ('0', 'Simple Machines Forum 1', '0', '', 'smf1.php', '', '') ");

// smilie system settings
$DB->query("INSERT INTO " . TABLE_PREFIX . "mainsettings VALUES ('0', 'smiliesystem', 'Smilies', '', 'Smilie System', '', 'Subdreamer') ");

// we're going to update the Latest News to labrekke's latest news, so lets delete the old version's settings:
$DB->query("DELETE FROM " . TABLE_PREFIX . "pluginsettings WHERE pluginid = 3 AND title = 'Latest News Limit'");
$DB->query("DELETE FROM " . TABLE_PREFIX . "pluginsettings WHERE pluginid = 3 AND title = 'Latest News Category Targeting'");

// but first correct the news plugins ID setting (since it used to be 3 which was the latest news pluginid, don't ask...)
$DB->query("UPDATE " . TABLE_PREFIX . "pluginsettings SET pluginid = 2 WHERE pluginid = 3");

// now lets installs lab's latest news plugins settings
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Limit',                         'The Latest News plugin will display links to the most recent news on your site. Enter the number of links to be shown:', 'text',  '10',  1) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Category Targeting',            'Only display the latest news of the category which the latest news plugin resides in. Include Categories or Matching Categories will not work if targeting is on.',                                  'yesno', '0',   2) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Include Categories',            'Enter the ID\'s of the categories you want to select latest news from, separate values with comma. Leave empty to select news from all categories. It can also be used together with the Matching Categories option.',  'text',  '',    3) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Matching Categories',           'This option makes it possible to to select latest news from the category of your choice, separate values with comma. This will only work together with the Include Categories option. If the Include Categories has the value \'1, 3\' and this field has the value \'2, 6\' it means: If this plugin is placed in category 1, display latest news from category 2. If the plugin is placed in category 3, display latest news from category 6. Leave this field empty if you don\'t want to use this option.',  'text',  '',    4) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Sorting',                       'How would you like your articles to be sorted (the latest news plugin always selects the latest news, but this option makes it possible to sort within those articles and within groups if you are using the Grouping option below)?', '<select name=\\\\\"settings[\$setting[settingid]]\\\\\">\r\n<option value=\\\\\"newest\\\\\" \".iif(\$setting[value]==\"newest\", \"selected\", \"\").\">Newest First</option>\r\n<option value=\\\\\"oldest\\\\\" \".iif(\$setting[value]==\"oldest\", \"selected\", \"\").\">Oldest First</option>\r\n<option value=\\\\\"alphaAZ\\\\\" \".iif(\$setting[value]==\"alphaAZ\", \"selected\", \"\").\">Alphabetically A-Z</option>\r\n<option value=\\\\\"alphaZA\\\\\" \".iif(\$setting[value]==\"alphaZA\", \"selected\", \"\").\">Alphabetically Z-A</option>\r\n<option value=\\\\\"authornameAZ\\\\\" \".iif(\$setting[value]==\"authornameAZ\", \"selected\", \"\").\">Author Name A-Z</option>\r\n<option value=\\\\\"authornameZA\\\\\" \".iif(\$setting[value]==\"authornameZA\", \"selected\", \"\").\">Author Name Z-A</option>\r\n</select>', 'newest', 5) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Display Category Name',         'Display category name to the right of each news title?',                                                                 'yesno', '0',   6) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Display Description',           'Display description under each news title?',                                                                             'yesno', '0',   7) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Read More',                     'Display \'Read more...\' link for each news article (it will use the language settings for the news plugin)?',           'yesno', '0',   8) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Display Author',                'Display author name under each news article?',                                                                           'yesno', '0',  9) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Display Creation Date',         'Display creation date under each news article?',                                                                         'yesno', '0',  10) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Display Print Article Option',  'Display the print article option for your readers?',                                                                     'yesno', '0',  11) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Display Email Article Option',  'Display the email article option for your readers?',                                                                     'yesno', '0',  12) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Bold Title',                    'Do you want the title of each news article to be bold?',                                                                 'yesno', '0',  13) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Title Link',                    'Do you want to convert the title of each news article into a link?',                                                     'yesno', '1',  14) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Grouping',                      'How would you like your articles to be grouped?', '<select name=\\\\\"settings[\$setting[settingid]]\\\\\">\r\n<option value=\\\\\"category\\\\\" \".iif(\$setting[value]==\"category\", \"selected\", \"\").\">Category Name</option>\r\n<option value=\\\\\"author\\\\\" \".iif(\$setting[value]==\"author\", \"selected\", \"\").\">Author Name</option>\r\n<option value=\\\\\"date\\\\\" \".iif(\$setting[value]==\"date\", \"selected\", \"\").\">Creation Date</option>\r\n<option value=\\\\\"nothing\\\\\" \".iif(\$setting[value]==\"nothing\", \"selected\", \"\").\">Nothing</option>\r\n</select>', 'nothing', 15) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Category Link',                 'Do you want to use the category name as a link to the category? This will only work if you group articles by category name or if you choose do display category names to the right of each article.',      'yesno', '0',  16) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Group Separator',               'Add or remove tags if you want change the space between groups of articles.',                                            'text',  '<br />', 17) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'Group/Article Separator',       'Add or remove tags if you want to change the space between group header and articles.',                                  'text',  '<br />', 18) ");
$DB->query("INSERT INTO " . TABLE_PREFIX . "pluginsettings VALUES ('0', '3',  'Options',  'News Article Separator',        'Add or remove tags if you want to change the space between news articles (only works when grouping is off).',            'text',  '<br />', 19) ");

// create the usergroups table
$DB->query("CREATE TABLE " . TABLE_PREFIX . "usergroups (
  usergroupid           smallint(5)  unsigned NOT NULL auto_increment,
  forumusergroupid      smallint(5)  unsigned NOT NULL default '0',
  name                  varchar(100)          NOT NULL default '',
  adminaccess           tinyint(1)            NOT NULL default '0',
  commentaccess         tinyint(1)            NOT NULL default '0',
  offlinecategoryaccess tinyint(1)            NOT NULL default '0',
  categoryviewids       varchar(250)          NOT NULL default '',
  categorymenuids       varchar(250)          NOT NULL default '',
  pluginviewids         varchar(250)          NOT NULL default '',
  pluginsubmitids       varchar(250)          NOT NULL default '',
  plugindownloadids     varchar(250)          NOT NULL default '',
  plugincommentids      varchar(250)          NOT NULL default '',
  pluginadminids        varchar(250)          NOT NULL default '',
  PRIMARY KEY (usergroupid),
  KEY forumusergroupid (forumusergroupid)
  ) ");

// insert four usergroups
// first get categoryviewids
$getcategories = $DB->query("SELECT categoryid, membersonly, menuitem FROM " . TABLE_PREFIX . "categories ORDER BY categoryid");
while($category = $DB->fetch_array($getcategories))
{
  $categoryviewids .= $category['categoryid'] . ',';

  if($category['membersonly'] == 0)
    $categoryguestviewids .= $category['categoryid'] . ',';

  if($category['menuitem'] == 1)
    $categorymenuids .= $category['categoryid'] . ',';
}
// remove the last comma
$categoryviewids      = substr($categoryviewids, 0, -1);
$categoryguestviewids = substr($categoryguestviewids, 0, -1);
$categorymenuids      = substr($categorymenuids, 0, -1);

// remove the category menuitem and membersonly
$DB->query("ALTER TABLE " . TABLE_PREFIX . "categories DROP menuitem");
$DB->query("ALTER TABLE " . TABLE_PREFIX . "categories DROP membersonly");

$DB->query("INSERT INTO " . TABLE_PREFIX . "usergroups
            VALUES (1, '', 'Administrators', '1', '1', '1', '$categoryviewids', '$categorymenuids',
                    '2,3,4,6,7,8,9,10,11,12,16,17', '2,4,6,7,10,16,17', '', '2,16,17', '2,3,4,6,7,8,9,10,11,12,16,17') "); // admins have access to all plugin settings, so it's not even entered

$DB->query("INSERT INTO " . TABLE_PREFIX . "usergroups
            VALUES (2, '', 'Moderators', '0', '1', '1', '$categoryviewids', '$categorymenuids',
                    '2,3,4,6,7,8,9,10,11,12,16,17', '2,4,6,7,10,16,17', '', '2,16,17', '2,3,4,6,7,8,9,10,11,12,16,17') ");

$DB->query("INSERT INTO " . TABLE_PREFIX . "usergroups
            VALUES (3, '', 'Registered Users', '0', '0', '0', '$categoryviewids', '$categorymenuids',
                    '2,3,4,6,7,8,9,10,11,12,16,17', '2,4,6,7,10,16,17', '', '2,16,17', '') ");

$DB->query("INSERT INTO " . TABLE_PREFIX . "usergroups
            VALUES (4, '', 'Guests', '0', '0', '0', '$categoryguestviewids', '$categorymenuids',
                    '2,3,4,6,7,8,9,10,11,12,16,17', '', '', '', '') ");


// add the usergroupid to the users table
$DB->query("ALTER TABLE " . TABLE_PREFIX . "users ADD usergroupid SMALLINT( 5 ) UNSIGNED NOT NULL AFTER userid");
$DB->query("ALTER TABLE " . TABLE_PREFIX . "users ADD INDEX ( usergroupid )");

$getprivileges = $DB->query("SELECT privilegeid, username, privilegetype, pluginaccess, usersystem FROM " . TABLE_PREFIX . "userprivileges");
while($privilege = $DB->fetch_array($getprivileges))
{
  if( ($privilege['usersystem'] == 'Subdreamer') && ($privilege['privilegetype'] == 'Administrator') )
  {                                                              // 1 = administrator
    $DB->query("UPDATE " . TABLE_PREFIX . "users SET usergroupid = '1' WHERE username = '" . $privilege['username'] . "'");
  }
}

// no longer need the privileges table
$DB->query("DROP TABLE " . TABLE_PREFIX . "userprivileges");


// update the plugins table to user usergroups bitfield
$DB->query("ALTER TABLE " . TABLE_PREFIX . "plugins ADD settings INT( 10 ) UNSIGNED NOT NULL AFTER authorlink");

/* THIS IS HOW THE BITFIELD LOOKS LIKE
// plugin bitfield data
$pluginbitfield = array('canview'          => 1,
                        'cansubmit'        => 2,
                        'candownload'      => 4,
                        'cancomment'       => 8,
                        'canadmin'         => 16);

2  - 27 - News:              1 2   8 16
3  - 17 - Latest News:       1       16
4  - 19 - Guestbook:         1 2     16
6  - 19 - Contact Form:      1 2     16
7  - 19 - Chatterbox:        1 2     16
8  - 17 - Latest Posts:      1       16
9  - 17 - Top Posters:       1       16
10 - 19 - MI - Login Panel:  1 2     16
11 - 17 - MI - User CP:      1       16
12 - 17 - MI - Registration: 1       16
16 - 27 - Link Directory:    1 2   8 16
17 - 27 - Image Gallery:     1 2   8 16
*/

// Subdreamer 2.0 changed the settingpath filenames for many plugin, so lets update the values in the database:
// Also update all the plugin versions to 2.0
$DB->query("UPDATE " . TABLE_PREFIX . "plugins SET version = '2.0', settings = '27', settingspath = 'p2_news/p2_settings.php'              WHERE pluginid = 2");
$DB->query("UPDATE " . TABLE_PREFIX . "plugins SET version = '2.0', settings = '17', settingspath = 'p3_latestnews/p3_settings.php'        WHERE pluginid = 3");
$DB->query("UPDATE " . TABLE_PREFIX . "plugins SET version = '2.0', settings = '19', settingspath = 'p4_guestbook/p4_settings.php'         WHERE pluginid = 4");
$DB->query("UPDATE " . TABLE_PREFIX . "plugins SET version = '2.0', settings = '19', settingspath = 'p6_contact_form/p6_settings.php'      WHERE pluginid = 6");
$DB->query("UPDATE " . TABLE_PREFIX . "plugins SET version = '2.0', settings = '19', settingspath = 'p7_chatterbox/p7_settings.php'        WHERE pluginid = 7");
$DB->query("UPDATE " . TABLE_PREFIX . "plugins SET version = '2.0', settings = '17', settingspath = 'p8_latest_posts/p8_settings.php'      WHERE pluginid = 8");
$DB->query("UPDATE " . TABLE_PREFIX . "plugins SET version = '2.0', settings = '17', settingspath = 'p9_top_posters/p9_settings.php'       WHERE pluginid = 9");
$DB->query("UPDATE " . TABLE_PREFIX . "plugins SET version = '2.0', settings = '19', settingspath = 'p10_mi_loginpanel/p10_settings.php'   WHERE pluginid = 10");
$DB->query("UPDATE " . TABLE_PREFIX . "plugins SET version = '2.0', settings = '17', settingspath = 'p11_mi_usercp/p11_settings.php'       WHERE pluginid = 11");
$DB->query("UPDATE " . TABLE_PREFIX . "plugins SET version = '2.0', settings = '17', settingspath = 'p12_mi_registration/p12_settings.php' WHERE pluginid = 12");
$DB->query("UPDATE " . TABLE_PREFIX . "plugins SET version = '2.0', settings = '27', settingspath = 'p16_link_directory/p16_settings.php'  WHERE pluginid = 16");
$DB->query("UPDATE " . TABLE_PREFIX . "plugins SET version = '2.0', settings = '27', settingspath = 'p17_image_gallery/p17_settings.php'   WHERE pluginid = 17");

// change all included Subdreamer plugin to author = Subdreamer
$DB->query("UPDATE " . TABLE_PREFIX . "plugins SET authorname = 'subdreamer' WHERE authorname = 'subduck' OR pluginid = 1");

// now lets fix subduck author name
$DB->query("UPDATE " . TABLE_PREFIX . "plugins SET authorname = 'subduck' WHERE authorname = ' subduck'");

// fix the activated root bug (default 0, should be 1) for the image gallery
$DB->query("UPDATE " . TABLE_PREFIX . "p17_sections SET activated = 1 WHERE sectionid = 1");


// delete logo settings since the logo is now created via the wysiwyg editor
// but first fix up the current logo
$currentlogo = $DB->query_first("SELECT value FROM " . TABLE_PREFIX . "mainsettings WHERE varname = 'currentlogo'");

// remove logo slashes
$currentlogo = stripslashes($currentlogo['value']);

// fix logo image
$imagesurl = preg_replace("'/install(.*)'", "", $_SERVER['HTTP_REFERER']) . '/images/';
$currentlogo = str_replace('images/', $imagesurl, $currentlogo);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -