本文整理匯總了PHP中wordfence::getWPFileContent方法的典型用法代碼示例。如果您正苦於以下問題:PHP wordfence::getWPFileContent方法的具體用法?PHP wordfence::getWPFileContent怎麽用?PHP wordfence::getWPFileContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wordfence
的用法示例。
在下文中一共展示了wordfence::getWPFileContent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: restore_file
function restore_file()
{
$issueID = $_POST['issueID'];
$wfIssues = new wfIssues();
$issue = $wfIssues->getIssueByID($issueID);
if (!$issue) {
return array('cerrorMsg' => 'We could not find that issue in our database.');
}
$dat = $issue['data'];
$result = wordfence::getWPFileContent($dat['file'], $dat['cType'], isset($dat['cName']) ? $dat['cName'] : '', isset($dat['cVersion']) ? $dat['cVersion'] : '');
$file = $dat['file'];
if (isset($result['cerrorMsg']) && $result['cerrorMsg']) {
return $result;
} else {
if (!$result['fileContent']) {
return array('cerrorMsg' => 'We could not get the original file to do a repair.');
}
}
if (preg_match('/\\.\\./', $file)) {
return array('cerrorMsg' => 'An invalid file was specified for repair.');
}
$localFile = ABSPATH . '/' . preg_replace('/^[\\.\\/]+/', '', $file);
$fh = fopen($localFile, 'w');
if (!$fh) {
$err = error_get_last();
if (preg_match('/Permission denied/i', $err['message'])) {
$errMsg = "You don't have permission to repair that file. You need to either fix the file manually using FTP or change the file permissions and ownership so that your web server has write access to repair the file.";
} else {
$errMsg = 'We could not write to that file. The error was: ' . $err['message'];
}
return array('cerrorMsg' => $errMsg);
}
flock($fh, LOCK_EX);
$bytes = fwrite($fh, $result['fileContent']);
flock($fh, LOCK_UN);
fclose($fh);
if ($bytes < 1) {
return array('cerrorMsg' => "We could not write to that file. ({$bytes} bytes written) You may not have permission to modify files on your WordPress server.");
}
$wfIssues->updateIssue($issueID, 'delete');
return array('ok' => 1, 'file' => $localFile);
}