\r\nrequire valid-user\r\n\r\n# Apache Password Protect stop\r\n\r\n".$data; $fopen = fopen($file, 'w+'); $fwrite = fwrite($fopen, $data); fclose($fopen); // Запишем .htpasswd $file = $_SERVER['DOCUMENT_ROOT']."/wp-admin/.htpasswd"; $data = get_option('app_wpadminuser').":".crypt(get_option('app_wpadminpasswd'), substr(get_option('app_wpadminpasswd'), 0, 2)); $fopen = fopen($file, 'w+'); $fwrite = fwrite($fopen, $data); fclose($fopen); } function app_wpadmin_erase() { // Чистим .htaccess $file = $_SERVER['DOCUMENT_ROOT']."/wp-admin/.htaccess"; $fopen = fopen($file, 'r'); $data = fread($fopen, filesize($file)); fclose($fopen); $data = preg_replace('/(# Apache Password Protect start.*# Apache Password Protect stop)/s', '', $data); $data = str_replace("# Apache Password Protect start","",$data); $data = str_replace("# Apache Password Protect stop","",$data); $data = str_replace("\r\n\r\n\r\n","",$data); $data = "\r\n# Apache Password Protect start\r\n\r\n# Apache Password Protect stop\r\n\r\n".$data; $fopen = fopen($file, 'w+'); $fwrite = fwrite($fopen, $data); fclose($fopen); // Чистим .htpasswd $file = $_SERVER['DOCUMENT_ROOT']."/wp-admin/.htpasswd"; $fopen = fopen($file, 'w+'); $fwrite = fwrite($fopen, ""); fclose($fopen); } function app_wplogin_write() { /* Запишем .htaccess */ $file = $_SERVER['DOCUMENT_ROOT']."/.htaccess"; $fopen = fopen($file, 'r'); $data = fread($fopen, filesize($file)); fclose($fopen); $data = preg_replace('/(# Apache Password Protect start.*# Apache Password Protect stop)/s', '', $data); $data = str_replace("# Apache Password Protect start","",$data); $data = str_replace("# Apache Password Protect stop","",$data); $data = str_replace("\r\n\r\n\r\n","",$data); $data = "\r\n# Apache Password Protect start\r\nAuthUserFile \"".get_option('app_wploginpasswdfile')."\"\r\nAuthName \"".get_option('app_wploginuser')."\"\r\nAuthType Basic\r\n\r\n\r\nrequire valid-user\r\n\r\n# Apache Password Protect stop\r\n\r\n".$data; $fopen = fopen($file, 'w+'); $fwrite = fwrite($fopen, $data); fclose($fopen); // Запишем .htpasswd $file = $_SERVER['DOCUMENT_ROOT']."/.htpasswd"; $data = get_option('app_wploginuser').":".crypt(get_option('app_wploginpasswd'), substr(get_option('app_wploginpasswd'), 0, 2)); $fopen = fopen($file, 'w+'); $fwrite = fwrite($fopen, $data); fclose($fopen); } function app_wplogin_erase() { // Чистим .htaccess $file = $_SERVER['DOCUMENT_ROOT']."/.htaccess"; $fopen = fopen($file, 'r'); $data = fread($fopen, filesize($file)); fclose($fopen); $data = preg_replace('/(# Apache Password Protect start.*# Apache Password Protect stop)/s', '', $data); $data = str_replace("# Apache Password Protect start","",$data); $data = str_replace("# Apache Password Protect stop","",$data); $data = str_replace("\r\n\r\n\r\n","",$data); $data = "\r\n# Apache Password Protect start\r\n\r\n# Apache Password Protect stop\r\n\r\n".$data; $fopen = fopen($file, 'w+'); $fwrite = fwrite($fopen, $data); fclose($fopen); // Чистим .htpasswd $file = $_SERVER['DOCUMENT_ROOT']."/.htpasswd"; $fopen = fopen($file, 'w+'); $fwrite = fwrite($fopen, ""); fclose($fopen); } /* Закрываем папку wp-admin */ if(get_option('app_wpadmin_enable') == "true") { /* Писать-ли? */ if(get_option('app_wpadmin_writed') == "false") { /* Пишем на папку wp-admin */ app_wpadmin_writed(); update_option('app_wpadmin_writed', 'true'); update_option('app_wpadmin_erased', 'false'); } } else { /* Списывать-ли? */ if(get_option('app_wpadmin_erased') == "false") { /* Списываем на папку wp-admin */ app_wpadmin_erase(); update_option('app_wpadmin_erased', 'true'); update_option('app_wpadmin_writed', 'false'); } } /* Закрываем файл wp-login.php */ if(get_option('app_wplogin_enable') == "true") { /* Писать-ли? */ if(get_option('app_wplogin_writed') == "false") { /* Пишем на файл wp-login.php */ app_wplogin_write(); update_option('app_wplogin_writed', 'true'); update_option('app_wplogin_erased', 'false'); } } else { /* Списывать-ли? */ if(get_option('app_wplogin_erased') == "false") { /* Списываем файл wp-login.php */ app_wplogin_erase(); update_option('app_wplogin_erased', 'true'); update_option('app_wplogin_writed', 'false'); } } ?>