Submit WordPress Program Password Programmatically

How can I allow a user to access a secure WordPress page with a URL that will send a password in the form below?

I want the user to be able to go to the password protected WordPress page without having to enter a password, so when they go to the page, the password is sent by the POST URL when the page loads.

This is not intended to be safe in any way; I need to hardcode the password in the URL and PHP. It is just for simplicity for the user.

Edit 4/19/10: According to the answers below, you can set cookies directly so that users cannot enter a password. Allowing the search for bots is best done by detecting the user agent and redirecting, since the bots will not process cookies.

This is the form (which is the main WordPress code):

<form action="http://mydomain.com/wp-pass.php" method="post">

Password: <input name="post_password" type="password" size="20" />

<input type="submit" name="Submit" value="Submit" /></form>

This is wp-pass.php (which is the main WordPress code):

<?php
require( dirname(__FILE__) . '/wp-load.php');

if ( get_magic_quotes_gpc() )
    $_POST['post_password'] = stripslashes($_POST['post_password']);

setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 864000, COOKIEPATH);

wp_safe_redirect(wp_get_referer());
?>
+3
source share
6 answers

Instead of adding in the previous answer, I will try to explain the problem a bit further.

How Wordpress WordWORD works, it is:

  • The original page has a form that is sent to wp-pass.php.
  • wp-pass.php , cookie .
  • cookie , .

, cookie. , :

  • Wordpress , $_GET.
  • cURL cookie , .

, , ; , . ?

+3

$_POST $_REQUEST wp-pass.php.

POST, GET URL. REQUEST POST, GET-, .

, , WordPress.

, GET, POST. . . , , .

<form action="http://mydomain.com/wp-pass.php" method="post">
<input name="post_password" type="hidden" value="totally insecure password here" />
<input type="submit" name="Submit" value="Click here to enter your account" />
</form>
+1

WP, cURL POST :

$ch = curl_init("http://mydomain.com/wp-pass.php");
curl_setopt($ch, CURLOPT_POSTFIELDS,  "post_password=mypassword&Submit=Submit");  
curl_setopt($ch, CURLOPT_HEADER, 0);  
curl_setopt($ch, CURLOPT_POST, 1);  
curl_exec($ch);  
curl_close($ch);
+1

:

, , search , , -googlebot , . php googlebot, ( ), -googlebot http- , ajax , ?

. Cloaking.

- (SEO), , .

, , , , . .

, , , .

+1

, javascript, - ?

mydomain.com/wp-pass.php?post_password=mypassword&Submit=Submit

js:

function gup( name ){  
 name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
 var regexS = "[\\?&]"+name+"=([^&#]*)";  var regex = new RegExp( regexS );  
 var results = regex.exec( window.location.href );  
 if( results == null )    
  return "";  
 else    
  return results[1];
}

function setPassword()
{

 var password = gup('post_password');
 var passField = document.getElementByName('post_password');
 var buttonSubmit = document.getElementByName('Submit');

 if(password != "")
 {
  passField.value = password;
  buttonSubmit.Click();
 }

}

body, OnLoad="setPassword();"

, ...

0

, , .

, . , , . , ?

, POST, :

(, , , : HTTP URL-; POST , GET - . URL-, , <a> , GET.)

, $_POST $_REQUEST . , POST. :

<form action="your url" method="POST">
    <input type="hidden" value="my_password" name="password"/>
    <input type="submit" value="Submit" name="submit">
</form>

style = "border: 0; background: transparent;" .. , , . , , , POST.

PS. Using Wireshark to check POST variables is a big waste of time. Install the Firebug FF extension and use the net panel. This will greatly speed up work on these things.

-1
source

Source: https://habr.com/ru/post/1740700/


All Articles