PHP Classes

File: libs/password_protect.php

Recommend this page to a friend!
  Classes of Olaf Lederer   Backup4WP   libs/password_protect.php   Download  
File: libs/password_protect.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Backup4WP
Backup and restore your WordPress website
Author: By
Last change:
Date: 11 months ago
Size: 984 bytes
 

Contents

Class file image Download
<?php
include_once 'func.php';

if ( isset(
$_SERVER['HTTP_X_REQUESTED_WITH'] ) && ( $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) ) {

   
$str2 = 'AuthGroupFile /dev/null
    AuthName "Protected Area"
    AuthType Basic
    AuthUserFile '
.MYBACKUPDIR.'.htpasswd
    require valid-user'
;

   
$savePathPassword = MYBACKUPDIR.'.htpasswd';
   
$savePath = MYBACKUPDIR.'.htaccess';
    if (
file_exists($savePath)) die('exists');

    if (!empty(
$_POST['loginname']) && !empty($_POST['password'])) {
       
$login = filter_var($_POST['loginname'], FILTER_SANITIZE_EMAIL);
       
$password = crypt($_POST['password'], base64_encode($_POST['password']));
       
$str = $login.':'.$password;
       
       
$handle = fopen($savePathPassword, 'w+');
        if (
fwrite($handle, $str) === FALSE) {
            echo
'error';
        } else {
           
fclose($handle);
           
           
$handle2 = fopen($savePath, 'w+');
            if (
fwrite($handle2, $str2) === FALSE) {
                echo
'error';
            } else {
                echo
'okay';
            }
           
fclose($handle2);
        }
    } else {
        echo
'error';
    }
}