There are many methods to use php to call the discuz logon box. The most common method is to use the iframe method directly, and the php page directly, the following is a summary of some common methods.
Method 1Directly use iframe to call a page with the discuz logon Function
| The Code is as follows: |
Copy code |
<Iframe src = "/login.html" style = "width: 100%; height: 32px" scrolling = "no" frameborder = "0"> </iframe> |
Login.html code
| The Code is as follows: |
Copy code |
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <Html xmlns = "http://www.w3.org/1999/xhtml"> <Head> <Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/> <Title> c-gd.com-Logon </title> <Style type = "text/css"> <! -- *{ Margin: 0; Padding: 0; } Body { Font: normal 12px Arial, Helvetica, Sans-Serif, ""; Line-height: 160%; Text-align: left; Color: # 3a3a3a; Margin: 0; Padding: 0; } Img { Border: 0; } Ul, li { Padding: 0; Margin: 0; List-style: none; } A { Text-decoration: none; Color: # 3a3a3a; } A: hover { Color: # C00; } . Banner { Margin-bottom: 1px; Height: 59px; } . Denglu { Height: 31px; Border-bottom: 1px solid # FFF; Background: # e7e3e4; Color: # 7b797a; } . Denglu { Color: # 7b797a; Text-decoration: none; } . Denglu a: hover { Color: # C00; Text-decoration: underline; } . Denglu. box01 { Margin-left: 30px; Float: left; Width: 224px; Line-height: 30px; Height: 31px; } . Denglu. box02 { Width: 433px; Float: left; Color: #000; Text-align: right; } . Denglu. box02 input { Border: 1px # c5c3c3 solid; Height: 20px; Width: 88px; Background: # FFF; Line-height: 20px; Margin-top: 5px; } . Denglu. box02. button { Background: url (/static/image/common/imparts 1.gif) no-repeat; Width: 50px; Height: 21px; Border: 0; Color: # 4b4b4b; Margin: 0 5px; Font-size: 12px; Line-height: 20px; } . Denglu. box03 { Float: right; Line-height: 30px; Height: 31px; Margin-right: 15px; } . Denglu. box03. font1 { Margin-left: 20px; } . Denglu. box03. font2 { Margin-left: 10px; Background: url (/static/image/common/icon03.jpg) left center no-repeat; Padding-left: 8px; Margin-left: 40px; } --> </Style> <Script type = "text/javascript"> Function checkform (){ If (document. getElementById ('username'). value = ''){ Alert ('enter your username '); Return false; } If (document. getElementById ('Password'). value = ''){ Alert ('Enter the password '); Return false; } Return true; } Function showDate () { Var d = new Date (); Document. write ("<div class = 'date _ div '>" + d. getYear () + "year" + (d. getMonth () + 1) + "month" + d. getDate () + "day "); Switch (d. getDay ()) { Case 0: Document. write ("Sunday "); Break; Case 1: Document. write ("Monday "); Break; Case 2: Document. write ("Tuesday "); Break; Case 3: Document. write ("Wednesday "); Break; Case 4: Document. write ("Thursday "); Break; Case 5: Document. write ("Friday "); Break; Case 6: Document. write ("Saturday "); Break; } Document. write ("</div> "); } </Script> </Head> <Body> <Div id = "header"> <! -- Logon --> <Div class = "denglu"> <Div class = "box01"> <Script language = "JavaScript" type = "text/JavaScript"> ShowDate (); </Script> </div> <Form method = "post" action = "/bbs/member. php? Mod = logging & action = login & loginsubmit = yes & infloat = yes "onsubmit =" return checkform (); "> <Div class = "box02"> Username: <input type = "text" name = "username" id = "username"/> Password: <input type = "password" name = "password" id = "password"/> <Input type = "hidden" name = "quickforward" value = "yes"/> <Input type = "hidden" name = "handlekey" value = "ls"/> <Input type = "hidden" name = "iflogin" value = "plus. php? Mod = iframelogin "/> <Span> <Input name = "input" type = "submit" class = "button" value = "login" style = "cursor: pointer"/> </Span> <Span> <Input name = "input" type = "button" class = "button" value = "register" style = "cursor: pointer" onclick = "window. open ('/bbs/member. php? Mod = register ') "/> </Span> </Div> </Form>
<Div class = "box03"> <Span class = "font2"> <a onclick = "this. style. behavior = 'url (# default # homepage) '; this. setHomePage ('HTTP: // www. bKjia. c0m'); "href =" javascript:; "> set as homepage </a> </span> <Span class = "font1"> <a href = "/" target = "_ parent"> Chinese </a> | <a href = "#" target = "_ parent "> English </a> </span>
</Div>
</Div> </Div> </Body> </Html> |
Method 2: Use php to call
Add the discuz logon box to the custom PHP page. PHP calls the discuz login box.
| The Code is as follows: |
Copy code |
<? Php Error_reporting (0 ); Require 'source/class/class_core.php '; $ Discuz = & discuz_core: instance (); $ Discuz-> init (); If (empty ($ _ G ['uid']) { ?> <Form target = "_ blank" action = "member. php? Mod = logging & action = login & loginsubmit = yes & infloat = yes "method =" post "name =" form2 "onSubmit =" return check () "> <Span> User Name: <input name = "username" type = "text" id = "textfield2" size = "13" tabindex = "1" value = "Enter the username" onFocus = "this. value = '';" onBlur = "if (this. value = '') {this. value = 'enter user name';} "> Password: <input name = "password" type = "password" id = "password" size = "12"> <Input type = "submit" name = "button2" id = "button2" value = "login" onClick = "setTimeout ('window. location. reload () ', 2000) "> <A href = "member. php? Mod = register "target =" _ blank "> register </a> <A href = "member. php? Mod = logging & action = login & viewlostpw "target =" _ blank "> retrieve password </a> <Input type = "hidden" name = "referer" value = "/"/> </span> </Form> <? Php} else {?> <Div> Dear <a href = "home. php? Mod = space & uid = <? Php echo $ _ G ['uid'];?> & Do = profile "target =" _ blank "> <? Echo $ _ G ['username'];?> </A> welcome! & Nbsp | & nbsp <a href = "home. php? Mod = space & do = thread & view = me "target =" _ blank "> my post </a> & nbsp | & nbsp <a href =" home. php "target =" _ blank "> personal center </a> & nbsp | & nbsp <a href =" member. php? Mod = logging & action = logout & formhash = <? Echo FORMHASH;?> "Target =" _ blank "onClick =" setTimeout ('window. location. reload () ', 2000) "> log out </a> </Div> <? Php }?> |
Method 3:The discuz login box is called by ajax. At first, you can see the called interface in firebug:
| The Code is as follows: |
Copy code |
| /Member. php? Mod = logging & action = login & infloat = yes & handlekey = login & inajax = 1 & ajaxtarget = fwin_content_login |
The returned content is an xml file, where the root node is located. It determines whether the user has logged on to the forum based on local cookies. if the user has not logged on to the Forum
The content is a form login form. If you log in, it is a piece of post-login information. Then save the css in the ajax request to the current
Location. Can be called in the login box. In the login box, there is a hidden input name = 'reffer'. The value here is a link. However, if
In the Forum program. For example, changing the connection to h/home. php? Mod = spacecp & ac = blog.
Automatically jump to the blog posting page. Supports one-click posting.
The Code is as follows:
| The Code is as follows: |
Copy code |
<? Php $ Login = file_get_contents ("/member. php? Mod = logging & action = login & infloat = yes & handlekey = login & inajax = 1 & ajaxtarget = fwin_content_login "); Require_once ('sofeexmlparser. php'); // search xml in xml parsing blog $ Xml = new SofeeXmlParser (); $ Xml-> parseString ($ login ); $ Tree = $ xml-> getTree (); $ Login = str_replace ("member. php", "h/member. php", $ tree ["root"] ["value"]); $ Login = str_replace ("h/./", "h/home. php? Mod = spacecp & ac = blog ", $ login); // jump to the posting page $ Login = preg_replace ('/ Var_dump ($ login ); Exit (); $ Login = iconv ('utf-8', 'gbk', $ login );
Echo $ login; ?> |