예제 #1
0
파일: shared.php 프로젝트: shifter/ospap
$dir = opendir($preview_directory);
while ($f = readdir($dir)) {
    if (is_dir($f) == false) {
        $info = stat("{$preview_directory}/{$f}");
        $age_in_seconds = time() - $info['mtime'];
        $age_in_minutes = $age_in_seconds / 60;
        if ($age_in_minutes > $preview_timeout) {
            unlink("{$preview_directory}/{$f}");
        }
    }
}
if (is_dir($upload_directory) == false) {
    mkdir($upload_directory) or show_error_die("Unable to create upload directory '{$upload_directory}'");
}
if (is_dir($preview_directory) == false) {
    mkdir($preview_directory) or show_error_die("Unable to create preview directory '{$preview_directory}'");
}
$me = get_current_user_info(get_db_read());
# Makes sure the username is made up of letters and numbers, and is between 3 and 14 characters long
function validate_username($username)
{
    if (isset($username) == false) {
        return false;
    }
    if (ereg('^([a-zA-Z0-9])*$', $username) == false) {
        return false;
    }
    if (strlen($username) < 3 || strlen($username) > 14) {
        return false;
    }
    return true;
예제 #2
0
function resize_image($width, $height, $compression, $old_filename, $new_filename)
{
    $ret = 0;
    system("convert -quality {$compression} -resize " . $width . "x" . $height . " {$old_filename} {$new_filename}", $ret);
    if (is_file($old_filename) == false) {
        show_error_die('image failed to upload');
    } else {
        if ($ret == 127) {
            show_error_die('image conversion failed, please install imagemagick or edit the resize_image() function in configuration.php');
        } else {
            if ($ret != 0) {
                show_error_die('image conversion failed, picture was invalid or corrupt');
            }
        }
    }
}