function phpAds_ImageSize($type, $name)
{
    $aConf = $GLOBALS['_MAX']['CONF'];
    // Strip existing path
    $name = basename($name);
    if ($type == 'web') {
        if ($aConf['store']['mode'] == 'ftp') {
            // FTP mode
            $server = array();
            $server['host'] = $aConf['store']['ftpHost'];
            $server['path'] = $aConf['store']['ftpPath'];
            if ($server['path'] != "" && substr($server['path'], 0, 1) == "/") {
                $server['path'] = substr($server['path'], 1);
            }
            $server['user'] = $aConf['store']['ftpUsername'];
            $server['pass'] = $aConf['store']['ftpPassword'];
            $server['passiv'] = !empty($aConf['store']['ftpPassive']);
            $result = phpAds_FTPSize($server, $name);
        } else {
            // Local mode
            $result = @filesize($aConf['store']['webDir'] . "/" . $name);
        }
    }
    if ($type == 'sql') {
        if ($doImages = OA_Dal::staticGetDO('images', 'filename', $name)) {
            $result = strlen($doImages->contents);
        }
    }
    if (isset($result) && $result != '') {
        return $result;
    } else {
        return false;
    }
}
function phpAds_ImageSize($storagetype, $name)
{
    global $phpAds_config;
    // Strip existing path
    $name = basename($name);
    if ($storagetype == 'web') {
        if ($phpAds_config['type_web_mode'] == 0) {
            // Local mode
            $result = @filesize($phpAds_config['type_web_dir'] . "/" . $name);
        } else {
            // FTP mode
            $server = parse_url($phpAds_config['type_web_ftp']);
            // Decode URL parts
            $server['user'] = urldecode($server['user']);
            $server['pass'] = urldecode($server['pass']);
            $server['path'] = urldecode($server['path']);
            if ($server['path'] != "" && substr($server['path'], 0, 1) == "/") {
                $server['path'] = substr($server['path'], 1);
            }
            if ($server['scheme'] == 'ftp') {
                $result = phpAds_FTPSize($server, $name);
            }
        }
    }
    if ($storagetype == 'sql') {
        $res = phpAds_dbQuery("\n\t\t\tSELECT\n\t\t\t\tcontents\n\t\t\tFROM\n\t\t\t\t" . $phpAds_config['tbl_images'] . "\n\t\t\tWHERE\n\t\t\t\tfilename = '" . $name . "'\n\t\t");
        if ($row = phpAds_dbFetchArray($res)) {
            $result = strlen($row['contents']);
        }
    }
    if (isset($result) && $result != '') {
        return $result;
    } else {
        return false;
    }
}