Example #1
0
/**
 * Function is responsible for checking to see if the file is safe to
 * save to the system.
 *
 * @param string $file : location of the file on the server
 * @param string|array $types : (optional)accepted file types
 */
function file_is_safe($fileArray, $ftype = null)
{
    //reasosn to fail
    if (!is_array($fileArray)) {
        return false;
    }
    if ($fileArray['error'] > 0) {
        return false;
    }
    //checking the file size
    if ($fileArray['size'] < 1) {
        return false;
    }
    //checking the file type
    extract(check_filetype($fileArray['name']));
    if (!$ext || !$type) {
        return false;
    }
    if (!is_null($ftype) && strpos($type, $ftype) === false) {
        return false;
    }
    //additional checks if this is an image
    if ($ftype == 'image' && !getimagesize($fileArray['tmp_name'])) {
        return false;
    }
    //this is safe
    return true;
}
Example #2
0
    if (!check_filetype($_FILES['file1']['type'], $type_file_check)) {
        $errortext .= " дњ≈м " . $_FILES['file1']['name'] . " дЅиг™идњ≈маЌ° “√<br>";
        $iserror = 1;
    } else {
    }
    if ($_FILES['file1']['size'] > 512000) {
        $errortext .= "  дњ≈м " . $_FILES['file1']['name'] . "  ¢є“іа°‘є°”Ћєі<br>";
        $iserror = 1;
    } else {
    }
}
//дњ≈маЌ° “√2
if (!$_FILES['file2']['name']) {
    $file2 = false;
} else {
    if (!check_filetype($_FILES['file2']['type'], $type_file_check)) {
        $errortext .= " дњ≈м " . $_FILES['file2']['name'] . "дЅиг™идњ≈маЌ° “√<br>";
        $iserror = 1;
    }
    if ($_FILES['file2']['size'] > 512000) {
        $errortext .= "  дњ≈м " . $_FILES['file2']['name'] . "¢є“іа°‘є°”Ћєі<br>";
        $iserror = 1;
    }
}
if ($iserror == 1) {
    echo $errortext;
    echo '<a href="javascript:back();">°≈—Їдїб°йд¢</a>';
} else {
    //save elearning
    $timeval = time();
    $addip = $_SERVER["REMOTE_ADDR"];
Example #3
0
/**
 * Retrieve path of author template in current or parent template.
 *
 * @since 1.0.0
 * @return string
 */
function get_real_template()
{
    //initializing
    $path = $_SERVER['REQUEST_URI'];
    if (file_exists(ABSPATH . $path)) {
        //if there is a file
        header('HTTP/1.1 200 OK');
        $parts = check_filetype($path);
        if ($parts['ext'] == 'css') {
            header('Content-type: text/css');
        }
        ob_start();
        require ABSPATH . $path;
        $contents = ob_get_clean();
        die(compress($contents));
    }
    return get_query_template('errors', array('errors-404', 'errors'));
}