search
HomeBackend DevelopmentPHP TutorialPHP实现合并discuz用户_PHP

本文实例讲述了PHP合并discuz用户脚本的方法。分享给大家供大家参考。具体如下:

前几天遇到一个需要将两个discuz合并的项目,一个用户级别在12万左右,一个是1万8.不用说肯定是扔了1万8的,留下12万的。开始觉得不好处理,数据表都是关联,新注册一个用户,有8个表增加记录了,还没看有没有其他表有修改记录的可能性。当时觉得一时半会儿也理不清那些表,就搜索了一下,搜到了discuz tool.但是只能导10万以内的,于是就只能自己尝试了,后来考虑,我直接在关键表插入一条记录如何,其他表在用户操作的过程中没准就自动补齐的相关数据了,于是就试着导出原来的1万8用户,然后写了个PHP脚本直接将这1万8用户写入的uncenter的memeber表里。测试了一下还OK。遗憾的是用户积分啥的都没过去,只是保留了用户的用户名和密码。

关键步骤:

1.导出打算不要的那个系统的uncenter member数据库成sql文件。

2.运行脚本。

声明:本脚本只提供思路,请使用前提前备份好数据,如数据丢失与作者无关。(代码简单,勿喷)

set_time_limit(0); 
$link = mysql_connect('localhost', 'ngjc', 'ohFt6yhHYvt5') 
 or die('Could not connect: ' . mysql_error()); 
echo 'Connected successfully'; 
mysql_select_db('ngjc') or die('Could not select database'); 
require "sql.php";//此处换成导出的sql文件 
$arrayerr=array(); 
$oknum=0; 
$errnum=0; 
mysql_query("SET NAMES utf8"); 
foreach($sqlarr as $sql) 
{ 
 if(!mysql_query($sql)) 
 { 
  $arrayerr[]=$sql;$errnum++; 
 } 
 else 
 { 
  $oknum++; 
 } 
} 
echo "<pre class="brush:php;toolbar:false">OK:$oknum <br>errornum:$errnum <br> error:<br>"; 
print_r($arrayerr); 
mysql_close($link); 

我们再来看下使用UC整合的方法

这两天一直在2个discuz的ucenter和会员系统;经过我的不懈努力;终于整合完成;整合过后实现功能如下;

两个discuz系统共用同一个ucenter;    //实现方法:

两个discuz系统共用同一个会员系统;//解决方法在后面;

先整合ucenter;

先完整安装一个discuz系统;进入ucenter;添加应用:

点击安装:一直下一步到下面

如果点击出现您必须解决以上问题,安装才可以继续
请返回输入 UCenter 的IP地址:如果不出意外进入下一步

ucenter整合完毕;可以实现同时登陆;同时退出;只是第一次需要激活;

打开第二个分系统config/下的config_global.php;

$_config['db']['1']['tablepre'] = chuzi_';下添加$_config['db']['2']['tablepre'] = it_

第二个分系统打开source\class\db文件下的db_driver_mysql.php;

在第 34行 $this->tablepre = $config['1']['tablepre'];下面添加        $this->tableprechu = $config['2']['tablepre'];
第112行  return $this->tablepre.$tablename;修改成下面

if(preg_match("/^common_member(.*)/i",$tablename)|| preg_match("/^home(.*)/i",$tablename) || in_array($tablename, array('common_credit_rule_log')))
    {
      return $this->tableprechu .$tablename; //tableprechu与上面修改对应就行;
    }else{
    return $this->tablepre.$tablename;
    }

以上就是小编给大家总结的2种整合DZ论坛会员的方式,个人比较喜欢第二种,毕竟第一种还是有些缺陷的。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
The Continued Use of PHP: Reasons for Its EnduranceThe Continued Use of PHP: Reasons for Its EnduranceApr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python: Exploring Their Similarities and DifferencesPHP and Python: Exploring Their Similarities and DifferencesApr 19, 2025 am 12:21 AM

PHP and Python are both high-level programming languages ​​that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP and Python: Different Paradigms ExplainedPHP and Python: Different Paradigms ExplainedApr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP and Python: A Deep Dive into Their HistoryPHP and Python: A Deep Dive into Their HistoryApr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Choosing Between PHP and Python: A GuideChoosing Between PHP and Python: A GuideApr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP and Frameworks: Modernizing the LanguagePHP and Frameworks: Modernizing the LanguageApr 18, 2025 am 12:14 AM

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHP's Impact: Web Development and BeyondPHP's Impact: Web Development and BeyondApr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How does PHP type hinting work, including scalar types, return types, union types, and nullable types?How does PHP type hinting work, including scalar types, return types, union types, and nullable types?Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment