This post has contributed a total of 500 points, and 100 points for no contribution. -Php Tutorial

Source: Internet
Author: User
This post has contributed a total of 500 points, and 100 points for no contribution. System: discuz3.2

I need some SQL statements to query the discuz data table and obtain information such as posts, members, and other information. In addition to queries, it also includes write and update operations.

Of course, it is not a simple database connection. it must be in line with discuz's own rules.

For example:
I installed the discuz program in the bbs folder. then I wrote a menberinfo program outside the folder. through the php logon box, php can log on to obtain information about its members and then go to the bbs Forum.


Only 100 points can be added, which can solve the problem of delivering scores to the major contributors one by one.


Clearance sales are coming soon


Reply to discussion (solution)

Http://bbs.csdn.net/topics/390896551#post-398264470
Menberinfo. php

Require_once '. /bbs/source/class/class_core.php '; // C: app ()-> init ();/* Basic operation DB: insert (), DB:: update (), DB: query (), DB: delete ()*/

Http://bbs.csdn.net/topics/390896551#post-398264470
Menberinfo. php

Require_once '. /bbs/source/class/class_core.php '; // C: app ()-> init ();/* Basic operation DB: insert (), DB:: update (), DB: query (), DB: delete ()*/

There are two main problems: one is the usage below, and the other is how to store the results for session or global variables.

 Init (); $ name = $ _ POST ['name']; $ pw = md5 (md5 ($ _ POST ['pw ']); $ count = DB :: result (DB: query ("select uid from md_common_member where username = $ name and password = $ pw"), 0); if ($ count) {global $ _ G; $ arr = array (); $ _ G = $ arr ['uid']; echo "logon successful";} else {echo "logon failed" ;}?>
Why not?

However, if you write data in the conventional method, it is correct:

 Init (); $ name = $ _ POST ['name']; $ pw = md5 (md5 ($ _ POST ['pw ']); $ connect = mysql_pconnect ("localhost", "root", "1234"); if (! Mysql_select_db ('XXX', $ connect) die ("database connection failed! "); $ SQL =" SELECT count (*) FROM md_common_member WHERE username = '$ username' and password =' $ pw '"; $ res = mysql_query ($ SQL ); // execute the query statement $ row = mysql_fetch_assoc ($ res); if ($ row ['uid']) {global $ _ G; $ _ G = $ row ['uid']; echo "logon successful" ;}else {echo "logon failed" ;}?>


Of course, the statement is correct. here, the weak question is: how is discuz encrypted?

$ User = 'Postmaster '; // email address or nickname $ pwd = md5 (123456); if (strlen ($ user)> 6 & strlen ($ user) <= 32 & preg_match ("/^ ([A-Za-z0-9 \-_. +] +) @ [A-Za-z0-9 \-] + [.] [A-Za-z0-9 \-.] +) $/", $ user) {// email login $ uc = DB: fetch_first ('select uid, email, username, password, salt FROM % t WHERE '. DB: field ("email", $ user), array ('ucenter _ members ');} else {// nickname login $ uc = DB :: fetch_first ('select uid, email, username, password, salt FROM % t WHERE '. DB: field ("username", $ user), array ('ucenter _ members ');} $ pwd = md5 ($ pwd. $ uc ['Salt']); if ($ pwd ===$ uc ['password']) {// logon succeeded // The password verified is the password field in the pre_ucenter_members table, which is added by the user password md5 with the salt field (randomly generated during registration) then md5 generated} else {// failed} // You can also introduce ucenter for login // before calling, you need loaducenter (); can use uc_user_login // reference http://faq.comsenz.com/library/UCenter/interface/interface_user.htm

$ User = 'Postmaster '; // email address or nickname $ pwd = md5 (123456); if (strlen ($ user)> 6 & strlen ($ user) <= 32 & preg_match ("/^ ([A-Za-z0-9 \-_. +] +) @ [A-Za-z0-9 \-] + [.] [A-Za-z0-9 \-.] +) $/", $ user) {// email login $ uc = DB: fetch_first ('select uid, email, username, password, salt FROM % t WHERE '. DB: field ("email", $ user), array ('ucenter _ members ');} else {// nickname login $ uc = DB :: fetch_first ('select uid, email, username, password, salt FROM % t WHERE '. DB: field ("username", $ user), array ('ucenter _ members ');} $ pwd = md5 ($ pwd. $ uc ['Salt']); if ($ pwd ===$ uc ['password']) {// logon succeeded // The password verified is the password field in the pre_ucenter_members table, which is added by the user password md5 with the salt field (randomly generated during registration) then md5 generated} else {// failed} // You can also introduce ucenter for login // before calling, you need loaducenter (); can use uc_user_login // reference http://faq.comsenz.com/library/UCenter/interface/interface_user.htm

The last question is how to assign values to global variables and update sessions after logon.

After reading the reference documents, the level is limited and cannot be understood.

$ Uid = 1; // User uid $ cookietime = 31536000; if ($ member = getuserbyuid ($ uid, 1) {// after this setting, this website is logged on. In fact, this operation is also performed in setloginstatus () below. you can skip this operation and directly execute setloginstatusdsetcookie ('auth ', authcode ("$ member [password] \ t $ member [uid]", 'encoding'), $ cookietime);} require_once libfile ('function/member '); // after setting, you can use $ _ G ['uid'], $ _ G ['username']... get user information. setloginstatus ($ member, $ cookietime) is also executed in session and statistics. // if there are other website applications, execute the following synchronous login if ($ _ G ['setting'] ['allowsynlogin']) {loaducenter (); // Output $ ucsynlogin to the webpage, execute synchronous login $ ucsynlogin = uc_user_synlogin ($ uid);} // update the user status, TIMESTAMP, discuz time constant C: t ('Common _ member_status ') -> update ($ uid, array ('lastip' => '', 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP ));

You can use ucenter to add an application to the Ucenter.






There is an official demo about login, logout, getting user information, and sending and receiving short messages.
See:
Http://faq.comsenz.com/library/UCenter/example/example_index.htm
Download demo:
Http://faq.comsenz.com/library/UCenter/example/examples.zip

Download and decompress the package. put it in any accessible website directory and copy the uc_client in your forum to the root path of the demo.
Configure config. inc. php in demo, just like that in ucenter.

The following running results:










You can use ucenter to add an application to the Ucenter.






There is an official demo about login, logout, getting user information, and sending and receiving short messages.
See:
Http://faq.comsenz.com/library/UCenter/example/example_index.htm
Download demo:
Http://faq.comsenz.com/library/UCenter/example/examples.zip

Download and decompress the package. put it in any accessible website directory and copy the uc_client in your forum to the root path of the demo.
Configure config. inc. php in demo, just like that in ucenter.

The following running results:







Pick up the http://bbs.csdn.net/topics/390952723 here

$ Uid = 1; // User uid $ cookietime = 31536000; if ($ member = getuserbyuid ($ uid, 1) {// after this setting, this website is logged on. In fact, this operation is also performed in setloginstatus () below. you can skip this operation and directly execute setloginstatusdsetcookie ('auth ', authcode ("$ member [password] \ t $ member [uid]", 'encoding'), $ cookietime);} require_once libfile ('function/member '); // after setting, you can use $ _ G ['uid'], $ _ G ['username']... get user information. setloginstatus ($ member, $ cookietime) is also executed in session and statistics. // if there are other website applications, execute the following synchronous login if ($ _ G ['setting'] ['allowsynlogin']) {loaducenter (); // Output $ ucsynlogin to the webpage, execute synchronous login $ ucsynlogin = uc_user_synlogin ($ uid);} // update the user status, TIMESTAMP, discuz time constant C: t ('Common _ member_status ') -> update ($ uid, array ('lastip' => '', 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP ));



Http://bbs.csdn.net/topics/390952720

Http://bbs.csdn.net/topics/390952721

Please post points for these two posts. thank you for completing this post's mission and coming to an end early.

This post has ended its mission. although there is still a problem, it is better to open another post with different themes.

Thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.