Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wordpres.../admin/views
File: tool-file-editor.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WPSEO plugin file.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WPSEO\Admin
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
if ( ! defined( 'WPSEO_VERSION' ) ) {
[7] Fix | Delete
header( 'Status: 403 Forbidden' );
[8] Fix | Delete
header( 'HTTP/1.1 403 Forbidden' );
[9] Fix | Delete
exit();
[10] Fix | Delete
}
[11] Fix | Delete
[12] Fix | Delete
$yform = Yoast_Form::get_instance();
[13] Fix | Delete
$home_path = get_home_path();
[14] Fix | Delete
[15] Fix | Delete
if ( ! is_writable( $home_path ) && ! empty( $_SERVER['DOCUMENT_ROOT'] ) ) {
[16] Fix | Delete
$home_path = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR;
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
$robots_file = $home_path . 'robots.txt';
[20] Fix | Delete
$ht_access_file = $home_path . '.htaccess';
[21] Fix | Delete
[22] Fix | Delete
if ( isset( $_POST['create_robots'] ) ) {
[23] Fix | Delete
if ( ! current_user_can( 'edit_files' ) ) {
[24] Fix | Delete
$die_msg = sprintf(
[25] Fix | Delete
/* translators: %s expands to robots.txt. */
[26] Fix | Delete
__( 'You cannot create a %s file.', 'wordpress-seo' ),
[27] Fix | Delete
'robots.txt'
[28] Fix | Delete
);
[29] Fix | Delete
die( esc_html( $die_msg ) );
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
check_admin_referer( 'wpseo_create_robots' );
[33] Fix | Delete
[34] Fix | Delete
ob_start();
[35] Fix | Delete
error_reporting( 0 );
[36] Fix | Delete
do_robots();
[37] Fix | Delete
$robots_content = ob_get_clean();
[38] Fix | Delete
[39] Fix | Delete
$f = fopen( $robots_file, 'x' );
[40] Fix | Delete
fwrite( $f, $robots_content );
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
if ( isset( $_POST['submitrobots'] ) ) {
[44] Fix | Delete
if ( ! current_user_can( 'edit_files' ) ) {
[45] Fix | Delete
$die_msg = sprintf(
[46] Fix | Delete
/* translators: %s expands to robots.txt. */
[47] Fix | Delete
__( 'You cannot edit the %s file.', 'wordpress-seo' ),
[48] Fix | Delete
'robots.txt'
[49] Fix | Delete
);
[50] Fix | Delete
die( esc_html( $die_msg ) );
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
check_admin_referer( 'wpseo-robotstxt' );
[54] Fix | Delete
[55] Fix | Delete
if ( isset( $_POST['robotsnew'] ) && file_exists( $robots_file ) ) {
[56] Fix | Delete
$robotsnew = sanitize_textarea_field( wp_unslash( $_POST['robotsnew'] ) );
[57] Fix | Delete
if ( is_writable( $robots_file ) ) {
[58] Fix | Delete
$f = fopen( $robots_file, 'w+' );
[59] Fix | Delete
fwrite( $f, $robotsnew );
[60] Fix | Delete
fclose( $f );
[61] Fix | Delete
$msg = sprintf(
[62] Fix | Delete
/* translators: %s expands to robots.txt. */
[63] Fix | Delete
__( 'Updated %s', 'wordpress-seo' ),
[64] Fix | Delete
'robots.txt'
[65] Fix | Delete
);
[66] Fix | Delete
}
[67] Fix | Delete
}
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
if ( isset( $_POST['submithtaccess'] ) ) {
[71] Fix | Delete
if ( ! current_user_can( 'edit_files' ) ) {
[72] Fix | Delete
$die_msg = sprintf(
[73] Fix | Delete
/* translators: %s expands to ".htaccess". */
[74] Fix | Delete
__( 'You cannot edit the %s file.', 'wordpress-seo' ),
[75] Fix | Delete
'.htaccess'
[76] Fix | Delete
);
[77] Fix | Delete
die( esc_html( $die_msg ) );
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
check_admin_referer( 'wpseo-htaccess' );
[81] Fix | Delete
[82] Fix | Delete
if ( isset( $_POST['htaccessnew'] ) && file_exists( $ht_access_file ) ) {
[83] Fix | Delete
$ht_access_new = wp_unslash( $_POST['htaccessnew'] );
[84] Fix | Delete
if ( is_writable( $ht_access_file ) ) {
[85] Fix | Delete
$f = fopen( $ht_access_file, 'w+' );
[86] Fix | Delete
fwrite( $f, $ht_access_new );
[87] Fix | Delete
fclose( $f );
[88] Fix | Delete
}
[89] Fix | Delete
}
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
if ( is_multisite() ) {
[93] Fix | Delete
$action_url = network_admin_url( 'admin.php?page=wpseo_files' );
[94] Fix | Delete
$yform->admin_header( false, 'wpseo_ms' );
[95] Fix | Delete
}
[96] Fix | Delete
else {
[97] Fix | Delete
$action_url = admin_url( 'admin.php?page=wpseo_tools&tool=file-editor' );
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
if ( isset( $msg ) && ! empty( $msg ) ) {
[101] Fix | Delete
echo '<div id="message" class="notice notice-success"><p>', esc_html( $msg ), '</p></div>';
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
// N.B.: "robots.txt" is a fixed file name and should not be translatable.
[105] Fix | Delete
echo '<h2>robots.txt</h2>';
[106] Fix | Delete
[107] Fix | Delete
if ( ! file_exists( $robots_file ) ) {
[108] Fix | Delete
if ( is_writable( $home_path ) ) {
[109] Fix | Delete
echo '<form action="', esc_url( $action_url ), '" method="post" id="robotstxtcreateform">';
[110] Fix | Delete
wp_nonce_field( 'wpseo_create_robots', '_wpnonce', true, true );
[111] Fix | Delete
echo '<p>';
[112] Fix | Delete
printf(
[113] Fix | Delete
/* translators: %s expands to robots.txt. */
[114] Fix | Delete
esc_html__( 'You don\'t have a %s file, create one here:', 'wordpress-seo' ),
[115] Fix | Delete
'robots.txt'
[116] Fix | Delete
);
[117] Fix | Delete
echo '</p>';
[118] Fix | Delete
[119] Fix | Delete
printf(
[120] Fix | Delete
'<input type="submit" class="button" name="create_robots" value="%s">',
[121] Fix | Delete
sprintf(
[122] Fix | Delete
/* translators: %s expands to robots.txt. */
[123] Fix | Delete
esc_attr__( 'Create %s file', 'wordpress-seo' ),
[124] Fix | Delete
'robots.txt'
[125] Fix | Delete
)
[126] Fix | Delete
);
[127] Fix | Delete
echo '</form>';
[128] Fix | Delete
}
[129] Fix | Delete
else {
[130] Fix | Delete
echo '<p>';
[131] Fix | Delete
printf(
[132] Fix | Delete
/* translators: %s expands to robots.txt. */
[133] Fix | Delete
esc_html__( 'If you had a %s file and it was editable, you could edit it from here.', 'wordpress-seo' ),
[134] Fix | Delete
'robots.txt'
[135] Fix | Delete
);
[136] Fix | Delete
echo '</p>';
[137] Fix | Delete
}
[138] Fix | Delete
}
[139] Fix | Delete
else {
[140] Fix | Delete
$f = fopen( $robots_file, 'r' );
[141] Fix | Delete
[142] Fix | Delete
$content = '';
[143] Fix | Delete
if ( filesize( $robots_file ) > 0 ) {
[144] Fix | Delete
$content = fread( $f, filesize( $robots_file ) );
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
if ( ! is_writable( $robots_file ) ) {
[148] Fix | Delete
echo '<p><em>';
[149] Fix | Delete
printf(
[150] Fix | Delete
/* translators: %s expands to robots.txt. */
[151] Fix | Delete
esc_html__( 'If your %s were writable, you could edit it from here.', 'wordpress-seo' ),
[152] Fix | Delete
'robots.txt'
[153] Fix | Delete
);
[154] Fix | Delete
echo '</em></p>';
[155] Fix | Delete
echo '<textarea class="large-text code" disabled="disabled" rows="15" name="robotsnew">', esc_textarea( $content ), '</textarea><br/>';
[156] Fix | Delete
}
[157] Fix | Delete
else {
[158] Fix | Delete
echo '<form action="', esc_url( $action_url ), '" method="post" id="robotstxtform">';
[159] Fix | Delete
wp_nonce_field( 'wpseo-robotstxt', '_wpnonce', true, true );
[160] Fix | Delete
echo '<label for="robotsnew" class="yoast-inline-label">';
[161] Fix | Delete
printf(
[162] Fix | Delete
/* translators: %s expands to robots.txt. */
[163] Fix | Delete
esc_html__( 'Edit the content of your %s:', 'wordpress-seo' ),
[164] Fix | Delete
'robots.txt'
[165] Fix | Delete
);
[166] Fix | Delete
echo '</label>';
[167] Fix | Delete
echo '<textarea class="large-text code" rows="15" name="robotsnew" id="robotsnew">', esc_textarea( $content ), '</textarea><br/>';
[168] Fix | Delete
printf(
[169] Fix | Delete
'<div class="submit"><input class="button" type="submit" name="submitrobots" value="%s" /></div>',
[170] Fix | Delete
sprintf(
[171] Fix | Delete
/* translators: %s expands to robots.txt. */
[172] Fix | Delete
esc_attr__( 'Save changes to %s', 'wordpress-seo' ),
[173] Fix | Delete
'robots.txt'
[174] Fix | Delete
)
[175] Fix | Delete
);
[176] Fix | Delete
echo '</form>';
[177] Fix | Delete
}
[178] Fix | Delete
}
[179] Fix | Delete
if ( ! WPSEO_Utils::is_nginx() ) {
[180] Fix | Delete
[181] Fix | Delete
echo '<h2>';
[182] Fix | Delete
printf(
[183] Fix | Delete
/* translators: %s expands to ".htaccess". */
[184] Fix | Delete
esc_html__( '%s file', 'wordpress-seo' ),
[185] Fix | Delete
'.htaccess'
[186] Fix | Delete
);
[187] Fix | Delete
echo '</h2>';
[188] Fix | Delete
[189] Fix | Delete
if ( file_exists( $ht_access_file ) ) {
[190] Fix | Delete
$f = fopen( $ht_access_file, 'r' );
[191] Fix | Delete
[192] Fix | Delete
$contentht = '';
[193] Fix | Delete
if ( filesize( $ht_access_file ) > 0 ) {
[194] Fix | Delete
$contentht = fread( $f, filesize( $ht_access_file ) );
[195] Fix | Delete
}
[196] Fix | Delete
[197] Fix | Delete
if ( ! is_writable( $ht_access_file ) ) {
[198] Fix | Delete
echo '<p><em>';
[199] Fix | Delete
printf(
[200] Fix | Delete
/* translators: %s expands to ".htaccess". */
[201] Fix | Delete
esc_html__( 'If your %s were writable, you could edit it from here.', 'wordpress-seo' ),
[202] Fix | Delete
'.htaccess'
[203] Fix | Delete
);
[204] Fix | Delete
echo '</em></p>';
[205] Fix | Delete
echo '<textarea class="large-text code" disabled="disabled" rows="15" name="robotsnew">', esc_textarea( $contentht ), '</textarea><br/>';
[206] Fix | Delete
}
[207] Fix | Delete
else {
[208] Fix | Delete
echo '<form action="', esc_url( $action_url ), '" method="post" id="htaccessform">';
[209] Fix | Delete
wp_nonce_field( 'wpseo-htaccess', '_wpnonce', true, true );
[210] Fix | Delete
echo '<label for="htaccessnew" class="yoast-inline-label">';
[211] Fix | Delete
printf(
[212] Fix | Delete
/* translators: %s expands to ".htaccess". */
[213] Fix | Delete
esc_html__( 'Edit the content of your %s:', 'wordpress-seo' ),
[214] Fix | Delete
'.htaccess'
[215] Fix | Delete
);
[216] Fix | Delete
echo '</label>';
[217] Fix | Delete
echo '<textarea class="large-text code" rows="15" name="htaccessnew" id="htaccessnew">', esc_textarea( $contentht ), '</textarea><br/>';
[218] Fix | Delete
printf(
[219] Fix | Delete
'<div class="submit"><input class="button" type="submit" name="submithtaccess" value="%s" /></div>',
[220] Fix | Delete
sprintf(
[221] Fix | Delete
/* translators: %s expands to ".htaccess". */
[222] Fix | Delete
esc_attr__( 'Save changes to %s', 'wordpress-seo' ),
[223] Fix | Delete
'.htaccess'
[224] Fix | Delete
)
[225] Fix | Delete
);
[226] Fix | Delete
echo '</form>';
[227] Fix | Delete
}
[228] Fix | Delete
}
[229] Fix | Delete
else {
[230] Fix | Delete
echo '<p>';
[231] Fix | Delete
printf(
[232] Fix | Delete
/* translators: %s expands to ".htaccess". */
[233] Fix | Delete
esc_html__( 'If you had a %s file and it was editable, you could edit it from here.', 'wordpress-seo' ),
[234] Fix | Delete
'.htaccess'
[235] Fix | Delete
);
[236] Fix | Delete
echo '</p>';
[237] Fix | Delete
}
[238] Fix | Delete
}
[239] Fix | Delete
[240] Fix | Delete
if ( is_multisite() ) {
[241] Fix | Delete
$yform->admin_footer( false );
[242] Fix | Delete
}
[243] Fix | Delete
[244] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function