files.php
4.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* @package Admin
*/
if ( !defined('WPSEO_VERSION') ) {
header('HTTP/1.0 403 Forbidden');
die;
}
global $wpseo_admin_pages;
if ( isset( $_POST[ 'submitrobots' ] ) ) {
if ( !current_user_can( 'manage_options' ) ) die( __( 'You cannot edit the robots.txt file.', 'wordpress-seo' ) );
check_admin_referer( 'wpseo-robotstxt' );
if ( file_exists( get_home_path() . "robots.txt" ) ) {
$robots_file = get_home_path() . "robots.txt";
$robotsnew = stripslashes( $_POST[ 'robotsnew' ] );
if ( is_writable( $robots_file ) ) {
$f = fopen( $robots_file, 'w+' );
fwrite( $f, $robotsnew );
fclose( $f );
$msg = __( 'Updated Robots.txt', 'wordpress-seo' );
}
}
}
if ( isset( $_POST[ 'submithtaccess' ] ) ) {
if ( !current_user_can( 'manage_options' ) ) die( __( 'You cannot edit the .htaccess file.', 'wordpress-seo' ) );
check_admin_referer( 'wpseo-htaccess' );
if ( file_exists( get_home_path() . ".htaccess" ) ) {
$htaccess_file = get_home_path() . ".htaccess";
$htaccessnew = stripslashes( $_POST[ 'htaccessnew' ] );
if ( is_writeable( $htaccess_file ) ) {
$f = fopen( $htaccess_file, 'w+' );
fwrite( $f, $htaccessnew );
fclose( $f );
}
}
}
$wpseo_admin_pages->admin_header( false );
if ( isset( $msg ) && !empty( $msg ) ) {
echo '<div id="message" style="width:94%;" class="updated fade"><p>' . esc_html( $msg ) . '</p></div>';
}
if ( file_exists( get_home_path() . "robots.txt" ) ) {
$robots_file = get_home_path() . "robots.txt";
$f = fopen( $robots_file, 'r' );
if ( filesize( $robots_file ) > 0 )
$content = fread( $f, filesize( $robots_file ) );
else
$content = '';
$robotstxtcontent = esc_textarea( $content );
if ( !is_writable( $robots_file ) ) {
$content = "<p><em>" . __( "If your robots.txt were writable, you could edit it from here.", 'wordpress-seo' ) . "</em></p>";
$content .= '<textarea disabled="disabled" style="width: 90%;" rows="15" name="robotsnew">' . $robotstxtcontent . '</textarea><br/>';
} else {
$content = '<form action="" method="post" id="robotstxtform">';
$content .= wp_nonce_field( 'wpseo-robotstxt', '_wpnonce', true, false );
$content .= "<p>" . __( "Edit the content of your robots.txt:", 'wordpress-seo' ) . "</p>";
$content .= '<textarea style="width: 90%;" rows="15" name="robotsnew">' . $robotstxtcontent . '</textarea><br/>';
$content .= '<div class="submit"><input class="button" type="submit" name="submitrobots" value="' . __( "Save changes to Robots.txt", 'wordpress-seo' ) . '" /></div>';
$content .= '</form>';
}
} else {
$content = '<p>'.__('If you had a robots.txt file and it was editable, you could edit it from here.','wordpress-seo');
}
$wpseo_admin_pages->postbox( 'robotstxt', __( 'Robots.txt', 'wordpress-seo' ), $content );
if ( (isset($_SERVER['SERVER_SOFTWARE']) && stristr($_SERVER['SERVER_SOFTWARE'], 'nginx') === false) && file_exists( get_home_path() . ".htaccess" ) ) {
$htaccess_file = get_home_path() . "/.htaccess";
$f = fopen( $htaccess_file, 'r' );
$contentht = fread( $f, filesize( $htaccess_file ) );
$contentht = esc_textarea( $contentht );
if ( !is_writable( $htaccess_file ) ) {
$content = "<p><em>" . __( "If your .htaccess were writable, you could edit it from here.", 'wordpress-seo' ) . "</em></p>";
$content .= '<textarea disabled="disabled" style="width: 90%;" rows="15" name="robotsnew">' . $contentht . '</textarea><br/>';
} else {
$content = '<form action="" method="post" id="htaccessform">';
$content .= wp_nonce_field( 'wpseo-htaccess', '_wpnonce', true, false );
$content .= "<p>" . __( 'Edit the content of your .htaccess:', 'wordpress-seo' ) . "</p>";
$content .= '<textarea style="width: 90%;" rows="15" name="htaccessnew">' . $contentht . '</textarea><br/>';
$content .= '<div class="submit"><input class="button" type="submit" name="submithtaccess" value="' . __( 'Save changes to .htaccess', 'wordpress-seo' ) . '" /></div>';
$content .= '</form>';
}
$wpseo_admin_pages->postbox( 'htaccess', __( '.htaccess file', 'wordpress-seo' ), $content );
} else if ( (isset($_SERVER['SERVER_SOFTWARE']) && stristr($_SERVER['SERVER_SOFTWARE'], 'nginx') === false) && !file_exists( get_home_path() . ".htaccess" ) ) {
$content = '<p>'.__('If you had a .htaccess file and it was editable, you could edit it from here.','wordpress-seo');
$wpseo_admin_pages->postbox( 'htaccess', __( '.htaccess file', 'wordpress-seo' ), $content );
}
$wpseo_admin_pages->admin_footer( false );