$picture = $timestamp . $ext;
             $convertstr = " -scale {$pic_res} -quality {$pic_quality} {$bazar_dir}/{$pic_path}/temp{$ext} {$bazar_dir}/{$pic_path}/{$picture}";
             exec($convertpath . $convertstr);
             $_picture = "_" . $timestamp . $ext;
             $_convertstr = " -scale {$pic_lowres} -quality {$pic_quality} {$bazar_dir}/{$pic_path}/temp{$ext} {$bazar_dir}/{$pic_path}/{$_picture}";
             exec($convertpath . $_convertstr);
             suppr("{$bazar_dir}/{$pic_path}/temp{$ext}");
             if ($pic_database) {
                 if (!move_uploaded_file_todb("{$bazar_dir}/{$pic_path}/{$picture}", $picture, $type)) {
                     died("Could NOT copy the file!");
                 }
                 suppr("{$bazar_dir}/{$pic_path}/{$picture}");
                 if (!move_uploaded_file_todb("{$bazar_dir}/{$pic_path}/{$_picture}", $_picture, $type)) {
                     died("Could NOT copy the file!");
                 }
                 suppr("{$bazar_dir}/{$pic_path}/{$_picture}");
             }
         }
     }
 }
 if ($picture_del) {
     $picture = "";
     $_picture = "";
 }
 // Database Update
 $query = mysql_query("update " . $prefix . "userdata\n\t\t\t\t\t\t    set sex = '{$_POST['sex']}',\n\t\t\t\t                    newsletter = '{$_POST['newsletter']}',\n\t\t\t\t\t\t    firstname = '{$_POST['firstname']}',\n\t\t\t\t\t\t    lastname = '{$_POST['lastname']}',\n\t\t\t\t\t\t    address = '{$_POST['address']}',\n\t\t\t\t\t\t    zip = '{$_POST['zip']}',\n\t\t\t\t\t\t    city = '{$_POST['city']}',\n\t\t\t\t\t\t    state = '{$_POST['state']}',\n\t\t\t\t\t\t    country = '{$_POST['country']}',\n\t\t\t\t\t\t    phone = '{$_POST['phone']}',\n\t\t\t\t\t\t    cellphone = '{$_POST['cellphone']}',\n\t\t\t\t\t\t    icq = '{$_POST['icq']}',\n\t\t\t\t\t\t    homepage = '{$_POST['homepage']}',\n\t\t\t\t\t\t    hobbys = '{$_POST['hobbys']}',\n                                                    picture= '{$picture}',\n                                                    _picture= '{$_picture}',\n\t\t\t\t\t\t    field1 = '{$_POST['field1']}',\n\t\t\t\t\t\t    field2 = '{$_POST['field2']}',\n\t\t\t\t\t\t    field3 = '{$_POST['field3']}',\n\t\t\t\t\t\t    field4 = '{$_POST['field4']}',\n\t\t\t\t\t\t    field5 = '{$_POST['field5']}',\n\t\t\t\t\t\t    field6 = '{$_POST['field6']}',\n\t\t\t\t\t\t    field7 = '{$_POST['field7']}',\n\t\t\t\t\t\t    field8 = '{$_POST['field8']}',\n\t\t\t\t\t\t    field9 = '{$_POST['field9']}',\n\t\t\t\t\t\t    field10 = '{$_POST['field10']}',\n\t\t\t\t\t\t    timezone = '{$_POST['timezone']}',\n\t\t\t\t\t\t    dateformat = '{$_POST['dateformat']}'\n\t\t\t    where id = '{$_SESSION['suserid']}'") or died(mysql_error());
 $_SESSION[susertimezone] = $_POST[timezone];
 $_SESSION[suserdateformat] = $_POST[dateformat];
 logging("X", "{$_SESSION['suserid']}", "{$_SESSION['susername']}", "AUTH: updated data", "");
 if (!$query) {
     $m_update = $error[20];
         mysql_query("delete from " . $prefix . "pictures where picture_name = '{$db['picture3']}'") or died("Database Query Error");
     }
     if (!$pic_database && $db[_picture3] && is_file("{$bazar_dir}/{$pic_path}/{$db['_picture3']}")) {
         suppr("{$bazar_dir}/{$pic_path}/{$db['_picture3']}");
     } elseif ($db[_picture3]) {
         mysql_query("delete from " . $prefix . "pictures where picture_name = '{$db['_picture3']}'") or died("Database Query Error");
     }
     // Delete Attachments if any ...
     if ($db[attachment1] && is_file("{$bazar_dir}/{$att_path}/{$db['attachment1']}")) {
         suppr("{$bazar_dir}/{$att_path}/{$db['attachment1']}");
     }
     if ($db[attachment2] && is_file("{$bazar_dir}/{$att_path}/{$db['attachment2']}")) {
         suppr("{$bazar_dir}/{$att_path}/{$db['attachment2']}");
     }
     if ($db[attachment3] && is_file("{$bazar_dir}/{$att_path}/{$db['attachment3']}")) {
         suppr("{$bazar_dir}/{$att_path}/{$db['attachment3']}");
     }
     // Delete Entry from favorits-DB
     mysql_query("delete from " . $prefix . "favorits where adid = '{$adid}'") or died("Database Query Error");
     // Delete Entry from ads-DB
     mysql_query("delete from " . $prefix . "ads where id = '{$adid}'") or died("Database Query Error");
     echo "<div class=\"mainheader\">{$admydel_head}</div>\n";
     echo "<br>\n";
     echo "<div class=\"smsubmit\">{$admydel_done}<br><br>\n";
     if ($_SESSION[susermod]) {
         echo "<form action=javascript:window.opener.location.href='classified.php?" . sidstr() . "status=7';window.close(); METHOD=POST><input type=submit value={$close}></form>\n";
     } else {
         echo "<form action=javascript:window.opener.location.reload();window.close(); METHOD=POST><input type=submit value={$close}></form>\n";
     }
     echo "</div>\n";
 } else {
                    echo "         File {$val} deleted.\n";
                }
            }
        }
    }
    echo "         Attachment cleanup finished\n";
}
// remove old webmails & attachments
if ($webmail_enable && $webmail_storedays) {
    $deletestamp = $timestamp - $webmail_storedays * 3600 * 24;
    $result = mysql_query("SELECT * FROM " . $prefix . "webmail WHERE timestamp<'{$deletestamp}'") or die(mysql_error());
    while ($db = mysql_fetch_array($result)) {
        if ($db[attachment1] && is_file("{$bazar_dir}/{$webmail_path}/{$db['attachment1']}")) {
            suppr("{$bazar_dir}/{$webmail_path}/{$db['attachment1']}");
        }
        if ($db[attachment2] && is_file("{$bazar_dir}/{$webmail_path}/{$db['attachment2']}")) {
            suppr("{$bazar_dir}/{$webmail_path}/{$db['attachment2']}");
        }
        if ($db[attachment3] && is_file("{$bazar_dir}/{$webmail_path}/{$db['attachment3']}")) {
            suppr("{$bazar_dir}/{$webmail_path}/{$db['attachment3']}");
        }
        mysql_query("DELETE FROM " . $prefix . "webmail WHERE id='{$db['id']}'") or die(mysql_error());
    }
    echo "         WebMail prune old mails & attachments finished\n";
}
// remove old logevents
if ($logging_enable && $logging_days) {
    $deletestamp = $timestamp - $logging_days * 3600 * 24;
    mysql_query("DELETE FROM " . $prefix . "logging WHERE timestamp<'{$deletestamp}'") or die(mysql_error());
    echo "         Logging prune old events finished\n";
}
                         if (is_file("{$tmp_dir}/tmp_picture{$ext}")) {
                             $picture_size = filesize("{$tmp_dir}/tmp_picture{$ext}");
                             $picture_bin = addslashes(fread(fopen("{$tmp_dir}/tmp_picture{$ext}", "r"), $picture_size));
                             $picinfo = GetImageSize("{$tmp_dir}/tmp_picture{$ext}");
                             mysql_query("INSERT INTO pictures VALUES ('{$db['picture']}','{$type}','{$picinfo['1']}','{$picinfo['0']}','{$picture_size}','{$picture_bin}')") or die("DB Update Error {$db['picture']} " . mysql_error());
                             suppr("{$tmp_dir}/tmp_picture{$ext}");
                             echo "Picture {$db['picture']} stored in Database. (Type: {$ext}, Size: {$picture_size})<br>";
                         }
                         $_convertstr = " -geometry {$pic_lowres} -quality {$pic_quality} {$bazar_dir}/{$image_dir}/userpics/{$db['picture']} {$tmp_dir}/tmp_picture{$ext}";
                         exec($convertpath . $_convertstr);
                         if (is_file("{$tmp_dir}/tmp_picture{$ext}")) {
                             $picture_size = filesize("{$tmp_dir}/tmp_picture{$ext}");
                             $picture_bin = addslashes(fread(fopen("{$tmp_dir}/tmp_picture{$ext}", "r"), $picture_size));
                             $picinfo = GetImageSize("{$tmp_dir}/tmp_picture{$ext}");
                             mysql_query("INSERT INTO pictures VALUES ('_{$db['picture']}','{$type}','{$picinfo['1']}','{$picinfo['0']}','{$picture_size}','{$picture_bin}')") or die("DB Update Error {$db['picture']} " . mysql_error());
                             suppr("{$tmp_dir}/tmp_picture{$ext}");
                             echo "Picture _{$db['picture']} stored in Database. (Type: {$ext}, Size: {$picture_size})<br>";
                         }
                     }
                 } else {
                     echo "WARNING: Picture {$db['picture']} wrong Filetype, nothing done.<br>";
                 }
             } else {
                 echo "ERROR: Picture {$db['picture']} couldn't open.<br>";
             }
         }
     }
     echo "<br><b>Logix Classifieds Convert Pictures, Ready ...</b>";
 } else {
     echo "<b><u>INFOS: </b></u><br>";
     $result = mysql_query("SELECT * FROM " . $prefix . "config WHERE type='version' AND name='db'");
            suppr("{$bazar_dir}/{$pic_path}/{$db['picture2']}");
        } elseif ($db[picture2]) {
            mysql_query("delete from " . $prefix . "pictures where picture_name = '{$db['picture2']}'") or died(mysql_error());
        }
        if (!$pic_database && $db[_picture2] && is_file("{$bazar_dir}/{$pic_path}/{$db['_picture2']}")) {
            suppr("{$bazar_dir}/{$pic_path}/{$db['_picture2']}");
        } elseif ($db[_picture2]) {
            mysql_query("delete from " . $prefix . "pictures where picture_name = '{$db['_picture2']}'") or died(mysql_error());
        }
        if (!$pic_database && $db[picture3] && is_file("{$bazar_dir}/{$pic_path}/{$db['picture3']}")) {
            suppr("{$bazar_dir}/{$pic_path}/{$db['picture3']}");
        } elseif ($db[picture3]) {
            mysql_query("delete from " . $prefix . "pictures where picture_name = '{$db['picture3']}'") or died(mysql_error());
        }
        if (!$pic_database && $db[_picture3] && is_file("{$bazar_dir}/{$pic_path}/{$db['_picture3']}")) {
            suppr("{$bazar_dir}/{$pic_path}/{$db['_picture3']}");
        } elseif ($db[_picture3]) {
            mysql_query("delete from " . $prefix . "pictures where picture_name = '{$db['_picture3']}'") or died(mysql_error());
        }
        // Delete Entry from favorits-DB
        mysql_query("delete from " . $prefix . "favorits where adid = '{$db['id']}'") or died(mysql_error());
        // Delete Entry from ads-DB
        mysql_query("delete from " . $prefix . "ads where id = '{$db['id']}'") or died(mysql_error());
    }
} else {
    // or only overwrite the password :-) better
    mysql_query("update " . $prefix . "ads set deleted='1' where userid = '{$_SESSION['suserid']}'") or died(mysql_error());
    mysql_query("update " . $prefix . "userdata set password='******',language='xd' where id = '{$_SESSION['suserid']}'") or died(mysql_error());
}
logging("X", "{$_SESSION['suserid']}", "{$_SESSION['susername']}", "AUTH: deleted", "");
logout();
             if (!$pic_database && $db[$fieldname] && is_file("{$bazar_dir}/{$pic_path}/{$db[$fieldname]}")) {
                 suppr("{$bazar_dir}/{$pic_path}/{$db[$fieldname]}");
             } elseif ($db[$fieldname]) {
                 mysql_query("delete from " . $prefix . "pictures where picture_name = '{$db[$fieldname]}'") or died("Database Query Error");
             }
             if (!$pic_database && $db[$_fieldname] && is_file("{$bazar_dir}/{$pic_path}/{$db[$_fieldname]}")) {
                 suppr("{$bazar_dir}/{$pic_path}/{$db[$_fieldname]}");
             } elseif ($db[$_fieldname]) {
                 mysql_query("delete from " . $prefix . "pictures where picture_name = '{$db[$_fieldname]}'") or died("Database Query Error");
             }
         }
         // Delete Attachments if any ...
         for ($i = 1; $i <= 5; $i++) {
             $fieldname = "attachment" . $i;
             if ($db[$fieldname] && is_file("{$bazar_dir}/{$att_path}/{$db[$fieldname]}")) {
                 suppr("{$bazar_dir}/{$att_path}/{$db[$fieldname]}");
             }
         }
         // Delete Entry from favorits-DB
         mysql_query("delete from " . $prefix . "favorits where adid = '{$db['id']}'") or died("Database Query Error");
         // Delete Entry from ads-DB
         mysql_query("delete from " . $prefix . "ads where id = '{$db['id']}'") or died("Database Query Error - ads");
     }
 }
 if ($editadid && !$_SESSION[susermod]) {
     if ($adeditapproval) {
         $locvar = "choice=my&status=13&textmessage=" . rawurlencode($text_msg[1]);
     } else {
         #             $locvar="choice=my&status=13&textmessage=".rawurlencode($text_msg[0]);
         $locvar = "choice=my&status=13";
     }