Do not attemp to load marker data from a non-existent htaccess. Bug 308.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1715 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7f5ef5c1d3
commit
217dd27ea9
|
@ -425,54 +425,64 @@ function check_admin_referer() {
|
||||||
// data. Creates file if none exists.
|
// data. Creates file if none exists.
|
||||||
// Returns true on write success, false on failure.
|
// Returns true on write success, false on failure.
|
||||||
function insert_with_markers($filename, $marker, $insertion) {
|
function insert_with_markers($filename, $marker, $insertion) {
|
||||||
if (!file_exists($filename) || is_writeable($filename)) {
|
if (!file_exists($filename) || is_writeable($filename)) {
|
||||||
$markerdata = explode("\n", implode('', file($filename)));
|
if (!file_exists($filename)) {
|
||||||
$f = fopen($filename, 'w');
|
$markerdata = '';
|
||||||
$foundit = false;
|
} else {
|
||||||
if ($markerdata) {
|
$markerdata = explode("\n", implode('', file($filename)));
|
||||||
$state = true;
|
}
|
||||||
$newline = '';
|
|
||||||
foreach($markerdata as $markerline) {
|
$f = fopen($filename, 'w');
|
||||||
if (strstr($markerline, "# BEGIN {$marker}")) $state = false;
|
$foundit = false;
|
||||||
if ($state) fwrite($f, "{$newline}{$markerline}");
|
if ($markerdata) {
|
||||||
if (strstr($markerline, "# END {$marker}")) {
|
$state = true;
|
||||||
fwrite($f, "{$newline}# BEGIN {$marker}");
|
$newline = '';
|
||||||
if(is_array($insertion)) foreach($insertion as $insertline) fwrite($f, "{$newline}{$insertline}");
|
foreach($markerdata as $markerline) {
|
||||||
fwrite($f, "{$newline}# END {$marker}");
|
if (strstr($markerline, "# BEGIN {$marker}")) $state = false;
|
||||||
$state = true;
|
if ($state) fwrite($f, "{$newline}{$markerline}");
|
||||||
$foundit = true;
|
if (strstr($markerline, "# END {$marker}")) {
|
||||||
}
|
fwrite($f, "{$newline}# BEGIN {$marker}");
|
||||||
$newline = "\n";
|
if(is_array($insertion)) foreach($insertion as $insertline) fwrite($f, "{$newline}{$insertline}");
|
||||||
}
|
fwrite($f, "{$newline}# END {$marker}");
|
||||||
}
|
$state = true;
|
||||||
if (!$foundit) {
|
$foundit = true;
|
||||||
fwrite($f, "# BEGIN {$marker}\n");
|
}
|
||||||
foreach($insertion as $insertline) fwrite($f, "{$insertline}\n");
|
$newline = "\n";
|
||||||
fwrite($f, "# END {$marker}");
|
}
|
||||||
}
|
}
|
||||||
fclose($f);
|
if (!$foundit) {
|
||||||
return true;
|
fwrite($f, "# BEGIN {$marker}\n");
|
||||||
} else {
|
foreach($insertion as $insertline) fwrite($f, "{$insertline}\n");
|
||||||
return false;
|
fwrite($f, "# END {$marker}");
|
||||||
}
|
}
|
||||||
|
fclose($f);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert_with_markers: Owen Winkler
|
// insert_with_markers: Owen Winkler
|
||||||
// Returns an array of strings from a file (.htaccess) from between BEGIN
|
// Returns an array of strings from a file (.htaccess) from between BEGIN
|
||||||
// and END markers.
|
// and END markers.
|
||||||
function extract_from_markers($filename, $marker) {
|
function extract_from_markers($filename, $marker) {
|
||||||
$result = array();
|
$result = array();
|
||||||
if($markerdata = explode("\n", implode('', file($filename))));
|
|
||||||
{
|
|
||||||
$state = false;
|
|
||||||
foreach($markerdata as $markerline) {
|
|
||||||
if(strstr($markerline, "# END {$marker}")) $state = false;
|
|
||||||
if($state) $result[] = $markerline;
|
|
||||||
if(strstr($markerline, "# BEGIN {$marker}")) $state = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
if (!file_exists($filename)) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($markerdata = explode("\n", implode('', file($filename))));
|
||||||
|
{
|
||||||
|
$state = false;
|
||||||
|
foreach($markerdata as $markerline) {
|
||||||
|
if(strstr($markerline, "# END {$marker}")) $state = false;
|
||||||
|
if($state) $result[] = $markerline;
|
||||||
|
if(strstr($markerline, "# BEGIN {$marker}")) $state = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function the_quicktags () {
|
function the_quicktags () {
|
||||||
|
|
Loading…
Reference in New Issue