本文整理汇总了PHP中wfUtils::iniSet方法的典型用法代码示例。如果您正苦于以下问题:PHP wfUtils::iniSet方法的具体用法?PHP wfUtils::iniSet怎么用?PHP wfUtils::iniSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wfUtils
的用法示例。
在下文中一共展示了wfUtils::iniSet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wfFunc_testmem
private static function wfFunc_testmem()
{
header('Content-Type: text/plain');
@error_reporting(E_ALL);
wfUtils::iniSet('display_errors', 'On');
set_error_handler('wordfence::memtest_error_handler', E_ALL);
echo "Wordfence Memory benchmarking utility version " . WORDFENCE_VERSION . ".\n";
echo "This utility tests if your WordPress host respects the maximum memory configured\nin their php.ini file, or if they are using other methods to limit your access to memory.\n\n--Starting test--\n";
echo "Current maximum memory configured in php.ini: " . ini_get('memory_limit') . "\n";
echo "Current memory usage: " . sprintf('%.2f', memory_get_usage(true) / (1024 * 1024)) . "M\n";
echo "Setting max memory to 90M.\n";
wfUtils::iniSet('memory_limit', '90M');
echo "Starting memory benchmark. Seeing an error after this line is not unusual. Read the error carefully\nto determine how much memory your host allows. We have requested 90 megabytes.\n";
if (memory_get_usage(true) < 1) {
echo "Exiting test because memory_get_usage() returned a negative number\n";
}
if (memory_get_usage(true) > 1024 * 1024 * 1024) {
echo "Exiting because current memory usage is greater than a gigabyte.\n";
}
$arr = array();
//256 bytes
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111222222222222222222233333333333333334444444444444444444444444555555555555666666666666666666";
$finalUsage = '0';
while (true) {
if (memory_get_usage(true) > 80 * 1024 * 1024) {
$finalUsage = sprintf('%.2f', memory_get_usage(true) / 1024 / 1024);
echo "Completing test after benchmarking up to " . $finalUsage . " megabytes.\n";
break;
}
for ($i = 0; $i < 1024; $i++) {
//Roughly 1 megabyte if it's 256K and actual array size is 4x data size
$arr[] = $chars;
}
}
echo "--Test complete.--\n\nCongratulations, your web host allows you to use at least {$finalUsage} megabytes of memory for each PHP process hosting your WordPress site.\n";
exit;
}
示例2: wfScanMain
public static function wfScanMain()
{
self::$peakMemAtStart = memory_get_peak_usage();
$db = new wfDB();
if ($db->errorMsg) {
self::errorExit("Could not connect to database to start scan: " . $db->errorMsg);
}
if (!wordfence::wfSchemaExists()) {
self::errorExit("Looks like the Wordfence database tables have been deleted. You can fix this by de-activating and re-activating the Wordfence plugin from your Plugins menu.");
}
if (isset($_GET['test']) && $_GET['test'] == '1') {
echo "WFCRONTESTOK:" . wfConfig::get('cronTestID');
self::status(4, 'info', "Cron test received and message printed");
exit;
}
/* ----------Starting cronkey check -------- */
self::status(4, 'info', "Scan engine received request.");
self::status(4, 'info', "Checking cronkey");
if (!$_GET['cronKey']) {
self::status(4, 'error', "Wordfence scan script accessed directly, or WF did not receive a cronkey.");
echo "If you see this message it means Wordfence is working correctly. You should not access this URL directly. It is part of the Wordfence security plugin and is designed for internal use only.";
exit;
}
self::status(4, 'info', "Fetching stored cronkey for comparison.");
$currentCronKey = wfConfig::get('currentCronKey', false);
wfConfig::set('currentCronKey', '');
if (!$currentCronKey) {
wordfence::status(4, 'error', "Wordfence could not find a saved cron key to start the scan so assuming it started and exiting.");
exit;
}
self::status(4, 'info', "Exploding stored cronkey");
$savedKey = explode(',', $currentCronKey);
if (time() - $savedKey[0] > 86400) {
self::errorExit("The key used to start a scan expired. The value is: " . $savedKey[0] . " and split is: " . $currentCronKey . " and time is: " . time());
}
//keys only last 60 seconds and are used within milliseconds of creation
self::status(4, 'info', "Checking saved cronkey against cronkey param");
if ($savedKey[1] != $_GET['cronKey']) {
self::errorExit("Wordfence could not start a scan because the cron key does not match the saved key.");
}
/* --------- end cronkey check ---------- */
self::status(4, 'info', "Becoming admin for scan");
self::becomeAdmin();
self::status(4, 'info', "Done become admin");
$isFork = $_GET['isFork'] == '1' ? true : false;
if (!$isFork) {
self::status(4, 'info', "Checking if scan is already running");
if (!wfUtils::getScanLock()) {
self::errorExit("There is already a scan running.");
}
}
self::status(4, 'info', "Requesting max memory");
wfUtils::requestMaxMemory();
self::status(4, 'info', "Setting up error handling environment");
set_error_handler('wfScan::error_handler', E_ALL);
register_shutdown_function('wfScan::shutdown');
if (!self::$debugMode) {
ob_start('wfScan::obHandler');
}
@error_reporting(E_ALL);
wfUtils::iniSet('display_errors', 'On');
self::status(4, 'info', "Setting up scanRunning and starting scan");
$scan = false;
if ($isFork) {
$scan = wfConfig::get_ser('wfsd_engine', false, true);
if ($scan) {
self::status(4, 'info', "Got a true deserialized value back from 'wfsd_engine' with type: " . gettype($scan));
wfConfig::set('wfsd_engine', '', true);
} else {
self::status(2, 'error', "Scan can't continue - stored data not found after a fork. Got type: " . gettype($scan));
wfConfig::set('wfsd_engine', '', true);
exit;
}
} else {
wordfence::statusPrep();
//Re-initializes all status counters
$scan = new wfScanEngine();
}
try {
$scan->go();
} catch (Exception $e) {
wfUtils::clearScanLock();
self::status(2, 'error', "Scan terminated with error: " . $e->getMessage());
self::status(10, 'info', "SUM_KILLED:Previous scan terminated with an error. See below.");
exit;
}
wfUtils::clearScanLock();
self::logPeakMemory();
self::status(2, 'info', "Wordfence used " . sprintf('%.2f', (wfConfig::get('wfPeakMemory') - self::$peakMemAtStart) / 1024 / 1024) . "MB of memory for scan. Server peak memory usage was: " . sprintf('%.2f', wfConfig::get('wfPeakMemory') / 1024 / 1024) . "MB");
}