mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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.
|
||||
// Returns true on write success, false on failure.
|
||||
function insert_with_markers($filename, $marker, $insertion) {
|
||||
if (!file_exists($filename) || is_writeable($filename)) {
|
||||
$markerdata = explode("\n", implode('', file($filename)));
|
||||
$f = fopen($filename, 'w');
|
||||
$foundit = false;
|
||||
if ($markerdata) {
|
||||
$state = true;
|
||||
$newline = '';
|
||||
foreach($markerdata as $markerline) {
|
||||
if (strstr($markerline, "# BEGIN {$marker}")) $state = false;
|
||||
if ($state) fwrite($f, "{$newline}{$markerline}");
|
||||
if (strstr($markerline, "# END {$marker}")) {
|
||||
fwrite($f, "{$newline}# BEGIN {$marker}");
|
||||
if(is_array($insertion)) foreach($insertion as $insertline) fwrite($f, "{$newline}{$insertline}");
|
||||
fwrite($f, "{$newline}# END {$marker}");
|
||||
$state = true;
|
||||
$foundit = true;
|
||||
}
|
||||
$newline = "\n";
|
||||
}
|
||||
}
|
||||
if (!$foundit) {
|
||||
fwrite($f, "# BEGIN {$marker}\n");
|
||||
foreach($insertion as $insertline) fwrite($f, "{$insertline}\n");
|
||||
fwrite($f, "# END {$marker}");
|
||||
}
|
||||
fclose($f);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if (!file_exists($filename) || is_writeable($filename)) {
|
||||
if (!file_exists($filename)) {
|
||||
$markerdata = '';
|
||||
} else {
|
||||
$markerdata = explode("\n", implode('', file($filename)));
|
||||
}
|
||||
|
||||
$f = fopen($filename, 'w');
|
||||
$foundit = false;
|
||||
if ($markerdata) {
|
||||
$state = true;
|
||||
$newline = '';
|
||||
foreach($markerdata as $markerline) {
|
||||
if (strstr($markerline, "# BEGIN {$marker}")) $state = false;
|
||||
if ($state) fwrite($f, "{$newline}{$markerline}");
|
||||
if (strstr($markerline, "# END {$marker}")) {
|
||||
fwrite($f, "{$newline}# BEGIN {$marker}");
|
||||
if(is_array($insertion)) foreach($insertion as $insertline) fwrite($f, "{$newline}{$insertline}");
|
||||
fwrite($f, "{$newline}# END {$marker}");
|
||||
$state = true;
|
||||
$foundit = true;
|
||||
}
|
||||
$newline = "\n";
|
||||
}
|
||||
}
|
||||
if (!$foundit) {
|
||||
fwrite($f, "# BEGIN {$marker}\n");
|
||||
foreach($insertion as $insertline) fwrite($f, "{$insertline}\n");
|
||||
fwrite($f, "# END {$marker}");
|
||||
}
|
||||
fclose($f);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// insert_with_markers: Owen Winkler
|
||||
// Returns an array of strings from a file (.htaccess) from between BEGIN
|
||||
// and END markers.
|
||||
function extract_from_markers($filename, $marker) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
$result = array();
|
||||
|
||||
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 () {
|
||||
|
Loading…
Reference in New Issue
Block a user