This post has contributed a total of 500 points, no contribution to answer 100 points.

Source: Internet
Author: User
System: discuz3.2 version

I need some SQL, query discuz data sheets, get posts, members and other information, and so on. In addition to queries, these operations are written and updated.

Of course not a simple database connection, need and discuz his own rules on.

To give a real example:
Discuz program I installed in the BBS folder, then I write a menberinfo.php outside the folder through this PHP login box, I can log in, get their own membership information, and then into the Forum BBS, inside the login also.


Can only add 100 points, can solve the contribution of the big people to send points.


There's a clearance sale, everybody's coming.


Reply to discussion (solution)

http://bbs.csdn.net/topics/390896551#post-398264470
menberinfo.php

Require_once './bbs/source/class/class_core.php ';//root directory C::app ()->init ();/* Base Operation Db::insert (), Db::update (), DB:: Query (), DB::d elete () */

http://bbs.csdn.net/topics/390896551#post-398264470
menberinfo.php

Require_once './bbs/source/class/class_core.php ';//root directory C::app ()->init ();/* Base Operation Db::insert (), Db::update (), DB:: Query (), DB::d elete () */

Two main questions, one is the following usage, and the other is how to store the results in a session or a global variable.

 
  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" Login Successful ";} Else{echo "Login Failed";}? >
Why not like this?

But if you write it in the usual way, it's right:

 
  Init (); $name =$_post[' name ']; $PW =md5 (MD5 ($_post[' pw ")); $connect =mysql_pconnect (" localhost "," root "," 1234 "); 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 Query Statement $ROW=MYSQL_FETCH_ASSOC ($res), if ($row [' uid ']) {global  $_g;$_g= $row [' uid ']; echo "Login Successful";} Else{echo "Login Failed";}? >


Of course only the statement is correct, here weak weak Ask a sentence, discuz is how to encrypt?

$user = ' admin ';//Email or nickname $pwd=md5 (123456), if (strlen ($user) > 6 && strlen ($user) <= && preg_match (" /^ ([a-za-z0-9\-_.+]+) @ ([a-za-z0-9\-]+[.] [a-za-z0-9\-.] +) $/", $user)) {//e-mail 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 ']) {//Login successful//authenticated password is password field in Pre_ucenter_members table, It is MD5 by the user password after adding the Salt field (randomly generated at registration) and then MD5 generated}else{//failure}//You can also introduce ucenter to log in//call before you need Loaducenter () before you can use uc_user_login// Reference http://faq.comsenz.com/library/UCenter/interface/interface_user.htm

$user = ' admin ';//Email or nickname $pwd=md5 (123456), if (strlen ($user) > 6 && strlen ($user) <= && preg_match (" /^ ([a-za-z0-9\-_.+]+) @ ([a-za-z0-9\-]+[.] [a-za-z0-9\-.] +) $/", $user)) {//e-mail 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 ']) {//Login successful//authenticated password is password field in Pre_ucenter_members table, It is MD5 by the user password after adding the Salt field (randomly generated at registration) and then MD5 generated}else{//failure}//You can also introduce ucenter to log in//call before you need Loaducenter () before you can use uc_user_login// Reference http://faq.comsenz.com/library/UCenter/interface/interface_user.htm

Last question, how to assign a value to a global variable after login, update the session.

Read the reference document, the level is limited, can not understand.

$uid =1;//User Uid$cookietime = 31536000;if (($member = Getuserbyuid ($uid, 1)) {//This setting, this site is the login status, in fact, the following setloginstatus () Inside also performed this operation, can not, directly execute Setloginstatusdsetcookie (' auth ', Authcode ("$member [Password]\t$member[uid]", ' ENCODE '), $ Cookietime);} Require_once libfile (' function/member ');//After setting, you can use $_g[' uid '],$_g[' username '] ... Access to user information, session and statistics are also performed within the Setloginstatus ($member, $cookietime);//If there are other Web applications, to perform the following synchronous login if ($_g[' setting '] [' Allowsynlogin ']) {loaducenter ();//Outputs the $ucsynlogin to the Web page, performs a synchronous login $ucsynlogin = Uc_user_synlogin ($uid);} Update user state, Timestamp,discuz time constant C::t (' Common_member_status ')->update ($uid, Array (' lastip ' = = ', ' lastvisit ' = >timestamp, ' lastactivity ' = TIMESTAMP));

Can be implemented with Ucenter, provided that an application needs to be added to the Ucenter






The official has a demo, about landing, logout, access to user information, send and receive short messages.
See:
Http://faq.comsenz.com/library/UCenter/example/example_index.htm
Demo Download:
Http://faq.comsenz.com/library/UCenter/example/examples.zip

After download, unzip, put in any access to the site directory, the uc_client in your forum to copy to, the root path of the demo.
Then configure the config.inc.php in the demo, as you would in Ucenter.

Run the following effect:










Can be implemented with Ucenter, provided that an application needs to be added to the Ucenter






The official has a demo, about landing, logout, access to user information, send and receive short messages.
See:
Http://faq.comsenz.com/library/UCenter/example/example_index.htm
Demo Download:
Http://faq.comsenz.com/library/UCenter/example/examples.zip

After download, unzip, put in any access to the site directory, the uc_client in your forum to copy to, the root path of the demo.
Then configure the config.inc.php in the demo, as you would in Ucenter.

Run the following effect:







http://bbs.csdn.net/topics/390952723, please come here to pick up the points

$uid =1;//User Uid$cookietime = 31536000;if (($member = Getuserbyuid ($uid, 1)) {//This setting, this site is the login status, in fact, the following setloginstatus () Inside also performed this operation, can not, directly execute Setloginstatusdsetcookie (' auth ', Authcode ("$member [Password]\t$member[uid]", ' ENCODE '), $ Cookietime);} Require_once libfile (' function/member ');//After setting, you can use $_g[' uid '],$_g[' username '] ... Access to user information, session and statistics are also performed within the Setloginstatus ($member, $cookietime);//If there are other Web applications, to perform the following synchronous login if ($_g[' setting '] [' Allowsynlogin ']) {loaducenter ();//Outputs the $ucsynlogin to the Web page, performs a synchronous login $ucsynlogin = Uc_user_synlogin ($uid);} Update user state, 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 go to these two points, thank you for this post mission completed, early end.

This post has ended the mission, although there is a problem, but the theme is not, another to open a good.

Please two great gods to reply to the address to collect points, thanks!

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