Esempio n. 1
0
    }
}
// Validate input
$i = 0;
$breakpoints = array();
foreach ($input as $key => $value) {
    if (is_numeric($value)) {
        $value = '' . $value . 'em';
    }
    // Basic input type validation
    if (!is_string($key) or !is_string($value)) {
        throw new Exception('Invalid name or value given for breakpoint number ' . $i, 400);
    } else {
        $key = unsuffix(unsuffix(unprefix(unprefix(trim_whitespace($key), '.'), '-'), '.'), '-');
        if (is_string($value)) {
            $value = unsuffix(unsuffix(unprefix(unprefix(trim_whitespace($value), '.'), '-'), '.'), '-');
        }
        // Empty after formatting
        if (empty($key) or empty($value)) {
            throw new Exception('Please provide proper name and value for breakpoint number ' . $i, 400);
        } else {
            $breakpoints[$key] = $value;
        }
    }
    $i++;
}
unset($i);
// Output
if (!count($breakpoints)) {
    header('HTTP/1.1 400 Bad Request');
    echo '
Esempio n. 2
0
/**
* Move directory
*
* @param $path
*	...
*
* @param $newLocation
*	...
*
* @return
*	...
*/
function move_dir($path, $newLocation)
{
    $path = suffix($path, '/');
    // Make sure we can work with the directory
    if (is_dir($path) and is_writable($path)) {
        $newLocation = suffix($newLocation, '/');
        // Create the new directory if it doesn't exist yet
        if (!is_dir($newLocation)) {
            if (!mkdir($newLocation, 0777, true)) {
                return false;
            }
        }
        // Move files individually
        foreach (rglob_files($path) as $filepath) {
            move_file($filepath, pathinfo($newLocation . unprefix($filepath, $path), PATHINFO_DIRNAME));
        }
        // Remove previous, now empty directories
        remove_dir($path);
        return true;
    }
    return false;
}