HEX
Server: Apache
System: Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux
User: u90323915 (5560665)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /homepages/oneclick/moodle/2.6.0.1/3/scripts/custom.php
<?php

function delete_directory($dir)
{
	if (!preg_match("/\/$/", $dir)) {
		$dir .= '/';
	}
	if ($handle = @opendir($dir)) {
		while (strlen($file = readdir($handle))) {
			if ($file != '.' && $file != '..') {
				if(is_dir($dir.$file)) {
					if(!@rmdir($dir.$file)) {
						delete_directory($dir.$file.'/');
					}
				} else {
					@unlink($dir.$file);
				}
			}
		}
	}
	@closedir($handle);
	@rmdir($dir);
}

function getSystemDirectorySeparator() {

	$directory_separator = "/";

	$pwd = getcwd();
	if (preg_match("/:/", $pwd)) {
		$directory_separator = "\\";
	}
	return $directory_separator;
}

function launchUpgradeByCurl($rootURL)
{
	$myCurl = curl_init();
	curl_setopt($myCurl, CURLOPT_URL, $rootURL);
	curl_setopt($myCurl, CURLOPT_HEADER, 0);
	curl_setopt($myCurl, CURLOPT_RETURNTRANSFER, 1);

	$myData = curl_exec($myCurl);
	if(!curl_errno($myCurl)){
		$info = curl_getinfo($myCurl);
	} else {
		print "Curl error: ". curl_error($myCurl);
		exit(1);
	}
	
	curl_close($myCurl);
	
	$success='APS upgrade completed successfully';
	$pos = strpos($myData, $success);
		
	if ($pos === false) {
		print "Error: upgrade version by curl";
		print $myData;
		exit(1);
	} 	
}

function recursiveChmod($path, $filePerm=0644, $dirPerm=0755) {
	// Check if the path exists
	if (!file_exists($path)) {
		return(false);
	}

	// See whether this is a file
	if (is_file($path)) {
		// Chmod the file with our given filepermissions
		chmod($path, $filePerm);

		// If this is a directory...
	} elseif (is_dir($path)) {
		// Then get an array of the contents
		$foldersAndFiles = scandir($path);

		// Remove "." and ".." from the list
		$entries = array_slice($foldersAndFiles, 2);

		// Parse every result...
		foreach ($entries as $entry) {
			// And call this function again recursively, with the same permissions
			recursiveChmod($path."/".$entry, $filePerm, $dirPerm);
		}

		// When we are done with the contents of the directory, we chmod the directory itself
		chmod($path, $dirPerm);
	}

	// Everything seemed to work out well, return true
	return(true);
}

?>