function phpAds_ImageDelete($type, $name)
{
    $aConf = $GLOBALS['_MAX']['CONF'];
    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']);
            phpAds_FTPDelete($server, $name);
        } else {
            if (@file_exists($aConf['store']['webDir'] . "/" . $name)) {
                @unlink($aConf['store']['webDir'] . "/" . $name);
            }
        }
    }
    if ($type == 'sql') {
        $doImages = OA_Dal::staticGetDO('images', 'filename', $name);
        if ($doImages) {
            $doImages->delete();
        }
    }
}
function phpAds_ImageDelete($storagetype, $name)
{
    global $phpAds_config;
    if ($storagetype == 'web') {
        if ($phpAds_config['type_web_mode'] == 0) {
            if (@file_exists($phpAds_config['type_web_dir'] . "/" . $name)) {
                @unlink($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') {
                phpAds_FTPDelete($server, $name);
            }
        }
    }
    if ($storagetype == 'sql') {
        $res = phpAds_dbQuery("\n\t\t\tDELETE FROM \n\t\t\t\t" . $phpAds_config['tbl_images'] . "\n\t\t\tWHERE\n\t\t\t\tfilename = '" . $name . "'\n\t\t");
    }
}