module.php
来自「php 开发的内容管理系统」· PHP 代码 · 共 382 行 · 第 1/2 页
PHP
382 行
<?PHP
// $Id: xoops_version.php,v 1.8 2005/06/03 01:35:02 phppp Exp $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <http://www.xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author: phppp (D.J.) //
// URL: http://xoopsforge.com, http://xoops.org.cn //
// ------------------------------------------------------------------------- //
function wp_update_convert_encoding(&$text)
{
$to = $GLOBALS["update_convert_encoding_to"];
$from = $GLOBALS["update_convert_encoding_from"];
require_once(ABSPATH."wp-admin/upgrade-functions.php");
$text = addslashes(deslash(XoopsLocal::convert_encoding($text, $to, $from)));
return $text;
}
function xoops_module_pre_update_wordpress(&$module)
{
return true;
}
function xoops_module_update_wordpress(&$module, $oldversion)
{
wp_setModuleConfig($module);
//$oldversion = $module->getVar('version');
global $wpdb,$wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles;
require_once(XOOPS_ROOT_PATH."/modules/".$module->getVar('dirname').'/wp-config.php');
require_once(ABSPATH."wp-admin/upgrade-functions.php");
wp_cache_flush();
make_db_current_silent();
upgrade_all();
wp_cache_flush();
if ($oldversion < 150):
$result = $GLOBALS['xoopsDB']->queryF("CREATE TABLE ".$GLOBALS['xoopsDB']->prefix("wp_views")."(
`post_id` bigint(20) NOT NULL default '0',
`post_views` bigint(20) NOT NULL default '0'
)");
if (!$result) {
$module->setMessage("Could not create wp_views");
}
$drop_list = array("backlist");
foreach($drop_list as $drop){
$result = $GLOBALS['xoopsDB']->queryF("DROP TABLE IF EXISTS ".$GLOBALS['xoopsDB']->prefix("wp_".$drop));
if (!$result) {
$module->setMessage("Could not drop wp_".$drop);
}else{
$module->setMessage("Dropped wp_".$drop);
}
}
update_option('fileupload_minlevel', '3');
update_option('ping_sites', 'http://rpc.pingomatic.com/\nhttp://ping.xoopsforge.com/');
update_option('rss_language', _LANGCODE);
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/');");
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/');");
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://xoopsforge.com/', 'XForge', 1, 'http://xoopsforge.com/modules/wordpress/wp-rss.php');");
// posts encoding and views update
$sql = "SELECT * FROM ".$GLOBALS['xoopsDB']->prefix('wp_posts');
$result = $GLOBALS['xoopsDB']->query($sql);
while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) {
$ID = $row["ID"];
$post_views = empty($row["post_views"])?0 : $row["post_views"];
$GLOBALS['xoopsDB']->queryF("INSERT INTO ".$GLOBALS['xoopsDB']->prefix("wp_views")." (post_id, post_views) VALUES ($ID, $post_views);");
}
@$GLOBALS['xoopsDB']->queryF("ALERT TABLE $wpdb->posts DROP `post_views`");
wp_content_encoding(wp_blog_charset(), _CHARSET, $module);
endif;
if ($oldversion < 152):
/* add missing option */
update_option('gmt_offset', $GLOBALS['xoopsConfig']['default_TZ'], '', false);
endif;
if ($oldversion < 201):
/* add new option for uploads */
update_option('uploads_use_yearmonth_folders', 1);
update_option('upload_path', $module->getVar("dirname"));
endif;
if ($oldversion < 205):
$request = "SELECT ID, post_content FROM {$wpdb->posts} WHERE post_status = 'publish' ";
if($lposts = $wpdb->get_results($request)){
include_once dirname(__FILE__)."/functions.tag.php";
global $post;
foreach($lposts as $lpost){
$post = $lpost;
onaction_set_tags();
}
}
endif;
return true;
}
function xoops_module_pre_install_wordpress(&$module)
{
wp_setModuleConfig($module);
return true;
}
function xoops_module_install_WordPress(&$module)
{
/* Set post permissions */
$module_id = $module->getVar("mid") ;
$gperm_handler =& xoops_gethandler("groupperm");
// user can post draft
$gperm_handler->addRight("global", 1, XOOPS_GROUP_USERS, $module->getVar("mid"));
// user can publish
$gperm_handler->addRight("global", 2, XOOPS_GROUP_USERS, $module->getVar("mid"));
$ori_error_level = ini_get('error_reporting');
define("ERROR_REPORTING_WORDPRESS", E_ERROR);
define("WP_INSTALLING", true);
ob_start();
global $wpdb,$wp_rewrite, $wp_queries, $table_prefix, $wp_db_version, $wp_roles;
require_once(XOOPS_ROOT_PATH."/modules/".$module->getVar('dirname').'/wp-config.php');
require_once(ABSPATH."wp-admin/upgrade-functions.php");
wp_cache_flush();
make_db_current_silent();
populate_options();
populate_roles();
ob_end_clean();
error_reporting($ori_error_level);
update_option('blogname', _MI_WORDPRESS_NAME);
update_option('blogdescription', _MI_WORDPRESS_DESC);
update_option("gmt_offset", $GLOBALS['xoopsConfig']['default_TZ']);
update_option("rss_language", _LANGCODE);
update_option("blog_charset", wp_blog_charset());
update_option("siteurl", XOOPS_URL."/modules/".$module->getVar('dirname'));
update_option("admin_email", $GLOBALS["xoopsConfig"]['adminmail']);
update_option("fileupload_realpath", XOOPS_UPLOAD_PATH . '/'.$module->getVar('dirname'));
update_option("fileupload_url", XOOPS_URL . '/uploads/'. $module->getVar('dirname'));
update_option("ping_sites", 'http://rpc.pingomatic.com/\nhttp://ping.xoopsforge.com/');
/* add new option for uploads */
update_option('uploads_use_yearmonth_folders', 1);
update_option('upload_path', $module->getVar("dirname"));
/* activate the tag plugin */
$plugin_current = "flickr.php";
update_option('active_plugins', array($plugin_current));
include(ABSPATH . 'wp-content/plugins/'.$plugin_current);
do_action('activate_'.$plugin_current);
// Now drop in some default links
$wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".addslashes(__('Blogroll'))."')");
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/');");
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/');");
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss) VALUES ('http://xoopsforge.com/', 'XForge', 1, 'http://xoopsforge.com/modules/wordpress/wp-rss.php');");
// Default category
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')");
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?