search
HomeBackend DevelopmentPHP Tutorialucenter communication principle, ucenter_PHP tutorial

ucenter communication principle, ucenter_PHP tutorial

Jul 13, 2016 am 10:20 AM
discuzprincipledocumentuserLog incommunicationpass

ucenter communication principle, ucenter

1. The user logs in to discuz and verifies the posted data through the function uc_user_login in the logging.php file, that is, verifying the username and password.

2. If the verification is successful, the function uc_user_synlogin located in the client.php file under uc_client will be called. In this function, uc_api_post('user', 'synlogin', array('uid'=>$ uid)).

3. Then this function passes data to index.php of Ucenter. Index.php accepts the passed data and obtains the value of model as user and action as synlogin.

4. Then Ucenter’s index.php calls the onsynlogin method in the user.php class in the control directory, and uses javascript to notify the applications in the uc application list that enable synchronous login through the foreach loop to log in synchronously; That is, some data is passed to uc.php under the api in each application directory through get method.

5. uc.php receives the notification and processes the data obtained, and encrypts the data through the function _authcode in the function synlogin (located in uc.php) (default uses UC_KEY as the key), and uses the function _setcookie Set cookies.

6. Each application uses the corresponding key to decode the cookie set above and obtain the user ID and other data; use this value to determine whether the user has logged in through other applications, so that the user can log in automatically.

Logging.php in application ------>client.php in uc_client------>Ucenter------>api/ in other applications uc.php.

In fact, the principle of Ucenter to achieve synchronous login is cookie. After an application successfully logs in, it transfers data to Ucenter and lets Ucenter notify other applications to also set cookies, so that users can use the cookies that have been set when accessing other applications. Cookie enables automatic login.

General steps, first install ucenter and then copy the uc_client folder to your own project, and then configure several files

client.php is equivalent to the function library

uc.php is equivalent to the callback file

config.php is the configuration file


When you have two applications set up to synchronize login, when you log in to an application, then execute

include './config.inc.php';
include './uc_client/client.php';
$usernames=" kyee";
$passwords="123456";
list($uid, $username, $password, $email) = uc_user_login($usernames, $passwords );
if($uid > 0) {

setcookie("username",$username,time()+intval(24*3600));
echo uc_user_synlogin($uid);
echo 'Login successful';
} elseif($uid == -1) {
echo 'The user does not exist or has been deleted';
} elseif($uid == -2) {
echo 'wrong password';
} else {
echo 'undefined';
}


uc_user_synlogin() This function represents the synchronous login to all other functions that enable synchronous login. uc itself will loop through all the applications that enable synchronous login in the background and then output it on the page


JS code like this is sent to each application that enables synchronous login, and then the callback file uc.php of each application that enables synchronous login will be decrypted after receiving it. After decryption, you will actually You can write the code yourself. The code of this uc.php callback file does not have to be written in their format. You can also write your own code.


In fact, the principle of UC is very simple. After an application logs in, it then polls the callback file sent to the synchronously logged-in application in the background. After the callback file receives the user ID, it generates a cookie or session and then enters the login mode. .

Why does the UCenter user management center always display "communication failure" when adding daily group purchases and Note Dog Weibo? How to solve it? High score answer

Ucenter Communication Principle
wenku.baidu.com/...1.html

I am a second-year communication engineering major and teach unofficial answers. What is the purpose of learning communication principles? In what jobs would it work?

I am also a 2-book correspondent.
Studying communications in college is not only about choosing your own major, but also choosing your own career. Now that you have chosen it, you really have to study it with all your heart. Find a counterpart at work. If you are not interested now, you should cultivate your interest as soon as possible. Communication can be said to be a sunrise industry that will be lost forever, so as long as you learn it well, you don’t have to worry about not finding a good job!
There are many undergraduate courses, and each school is different. But there will definitely be some major basic courses. "Model Electricity", "Counting Points", "Signal System", "Principles of Communication". Especially signals, which are the theoretical basis of communication, must be learned well. In fact, to put it bluntly, it means learning mathematics well. No matter you want to take the postgraduate entrance examination or find a job in the future, you will definitely not suffer if you learn mathematics well. It is especially useful when taking postgraduate entrance examinations. Hey, let me express my feelings. There are many motivations for learning communications. First of all, if you work in the communications industry for more than 3 years, the salary is very high. What may seem profound to outsiders may appear to be very simple, which will give you a sense of accomplishment. The direct motivation is that you can go to large website forums such as Communication, or read introductory books such as "Dahua Communication".
Hope this information is useful to you.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/868763.htmlTechArticleucenter Communication Principle, ucenter 1. The user logs in to discuz, and uses the function uc_user_login in the logging.php file to post messages Verify the data, that is, verify the username and password...
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
PHP Performance Tuning for High Traffic WebsitesPHP Performance Tuning for High Traffic WebsitesMay 14, 2025 am 12:13 AM

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

Dependency Injection in PHP: Code Examples for BeginnersDependency Injection in PHP: Code Examples for BeginnersMay 14, 2025 am 12:08 AM

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

PHP Performance: is it possible to optimize the application?PHP Performance: is it possible to optimize the application?May 14, 2025 am 12:04 AM

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

PHP Performance Optimization: The Ultimate GuidePHP Performance Optimization: The Ultimate GuideMay 14, 2025 am 12:02 AM

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

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 Article

Hot 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.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software