Skip to content

Commit

Permalink
Us strpos() only
Browse files Browse the repository at this point in the history
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
  • Loading branch information
solracsf authored and AndyScherzinger committed Nov 13, 2023
1 parent 9813bb8 commit 6e7c5ad
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lib/private/Preview/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,20 +257,14 @@ public static function unguardWithSemaphore(false|\SysvSemaphore $semId): bool {
*/
public static function getHardwareConcurrency(): int {
static $width;

if (!isset($width)) {
if (function_exists('ini_get')) {
$openBasedir = ini_get('open_basedir');
if ($openBasedir == '') {
if (empty($openBasedir) || strpos($openBasedir, '/proc/cpuinfo') !== false) {
$width = is_readable('/proc/cpuinfo') ? substr_count(file_get_contents('/proc/cpuinfo'), 'processor') : 0;
} else {
$openBasedirPaths = explode(':', $openBasedir);
foreach ($openBasedirPaths as $path) {
if (strpos($path, '/proc') === 0 || $path === '/proc/cpuinfo') {
$width = is_readable('/proc/cpuinfo') ? substr_count(file_get_contents('/proc/cpuinfo'), 'processor') : 0;
} else {
$width = 0;
}
}
$width = 0;
}
} else {
$width = 0;
Expand Down

0 comments on commit 6e7c5ad

Please sign in to comment.