}
         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 {
         died("FATAL Error !!!");
     }
 } elseif ($adid) {
     // Ask for sure
     $result = mysql_query("SELECT * FROM " . $prefix . "ads WHERE id={$adid}");
     $db = mysql_fetch_array($result);
     if ($db[userid] == $_SESSION[suserid] || $_SESSION[susermod]) {
         echo "<div class=\"mainheader\">{$admydel_head}</div>\n";
         echo "<br>\n";
         echo "<form action=\"classified_my_del.php\" METHOD=\"POST\">\n";
            $db = mysql_fetch_array($query);
            if ($db) {
                $query2 = mysql_query("SELECT id,name FROM " . $prefix . "adcat WHERE id='{$db['catid']}'") or died("Ads - Record NOT Found");
                $dbc = mysql_fetch_array($query2);
                echo " <tr>\n";
                echo "   <td class=\"classcat1\">\n";
                if ($db[picture]) {
                    echo "<img src=\"{$db['picture']} \">\n";
                } else {
                    echo "&nbsp;";
                }
                echo "   </td>\n";
                echo "   <td class=\"classcat2\">\n";
                echo "   <a href=\"classified.php?catid={$db['catid']}&subcatid={$db['id']}\" onmouseover=\"window.status='{$db['description']}';\n                 return true;\" onmouseout=\"window.status=''; return true;\">{$dbc['name']}/{$db['name']}</a> ({$db['ads']})<br>\n";
                echo "   <div class=\"smallleft\">\n";
                echo "   <a href=\"notify.php?delid={$db['id']}\"\n          onClick='enterWindow=window.open(\"notify.php?" . sidstr() . "delid={$db['id']}\",\"Delete\",\"width=400,height=200,top=100,left=100\"); return false'\n          onmouseover=\"window.status='{$adnot_delete}'; return true;\"\n          onmouseout=\"window.status=''; return true;\">\n         <img src=\"{$image_dir}/icons/trash.gif\" border=\"0\" alt=\"{$adnot_delete}\" align=\"right\" vspace=\"2\"></a>\n";
                echo "   {$db['description']}\n";
                echo "   </div>";
                echo "   </td>\n";
            }
        }
        //End while
        echo "</table>\n";
    } else {
        echo $mess_noentry;
    }
} else {
    // NO Login
}
# End of Page reached
#################################################################################################
<?php

#################################################################################################
#
#  project              : Logix Classifieds
#  filename             : member_apic.inc.php
#  last modified by     :
#  e-mail               : support@phplogix.com
#  purpose              : IncludeModule show member picture
#
#################################################################################################
if (!strpos($_SERVER['PHP_SELF'], 'member_apic.php') === false) {
    die("YOU MAY NOT ACCESS THIS FILE DIRECTLY");
}
if (!$pic_database && $picture && is_file("{$pic_path}/{$picture}") && is_file("{$pic_path}/{$_picture}")) {
    echo "   <a href=\"pictureviewer.php?pic={$pic_path}/{$picture}\" onClick='enterWindow=window.open(\"pictureviewer.php?" . sidstr() . "pic={$pic_path}/{$picture}\",\"Picture\",\"width={$pic_width},height={$pic_height},top=100,left=100,scrollbars=yes\"); return false'>\n            <img src=\"{$pic_path}/{$_picture}\" border=\"0\" alt=\"{$ad_enlarge}\"></a>\n";
} elseif ($picture) {
    echo "   <a href=\"pictureviewer.php?id={$picture}\" onClick='enterWindow=window.open(\"pictureviewer.php?" . sidstr() . "id={$picture}\",\"Picture\",\"width={$pic_width},height={$pic_height},top=100,left=100,scrollbars=yes\"); return false'>\n                <img src=\"picturedisplay.php?id={$_picture}\" border=\"0\" alt=\"{$ad_enlarge}\"></a>\n";
}
             $checked[$i] = "checked";
         }
         if ($dbcat["icon{$i}"] && adfield($catid, "icon{$i}")) {
             echo "<input type=\"checkbox\" name=\"in[icon{$i}]\" {$checked[$i]}>\n";
         }
     }
     echo "</td></tr>\n";
 }
 // Text
 echo "<tr>\n";
 echo "<td class=\"classadd1\"><div class=\"maininputleft\">{$adadd_head} </div></td>\n";
 echo "<td class=\"classadd2\"><input type=text name=\"in[header]\" size=\"{$field_size}\" maxlength=\"50\" value=\"{$db['header']}\"> <em id=\"red\">**</em></td>\n";
 echo "</tr>\n";
 echo "<tr>\n";
 echo "<td class=\"classadd1\"><div class=\"maininputleft\">{$adadd_text} </div><br>\n";
 echo "<div class=\"mainpages\"><a href=\"smiliehelp.php\"\n      onClick='enterWindow=window.open(\"smiliehelp.php?" . sidstr() . "display=y\",\"Smilie\",\n      \"width=250,height=450,top=100,left=100,scrollbars=yes\"); return false'\n      onmouseover=\"window.status='{$smiliehelp}'; return true;\"\n      onmouseout=\"window.status=''; return true;\">{$smiliehelp}</a>&nbsp&nbsp\n";
 echo "</div></td>\n";
 $text = decode_msg($db[text]);
 echo "<td class=\"classadd2\"><textarea rows=\"8\" name=\"in[text]\" cols=\"{$text_field_size}\">{$text}</textarea> <em id=\"red\">**</em></td>\n";
 echo "</tr>\n";
 if ($convertpath && $pic_enable) {
     $result = mysql_query("select * FROM " . $prefix . "config WHERE type='cat' AND value='{$catid}' AND name LIKE 'picture%' ORDER BY name") or die(mysql_error());
     while ($dbp = mysql_fetch_array($result)) {
         $fieldname = $dbp[name];
         $_fieldname = "_" . $dbp[name];
         if ($dbp[value2] == "yes") {
             $pcount++;
             $fieldstr = $pcount == 1 ? "{$adadd_pic}" : "";
             if ($db[$fieldname]) {
                 echo "<tr>\n";
                 echo "<td class=\"classadd1\"><div class=\"maininputleft\"> {$fieldstr} </div></td>\n";
     $dbc = mysql_fetch_array($resultc);
     echo "   <td class=\"classcat1\">\n";
     if ($db['picture']) {
         echo "<img src=\"{$db['picture']} \">\n";
     } else {
         echo "&nbsp;";
     }
     echo "   </td>\n";
     echo "   <td class=\"classcat2\">\n";
     if ($db) {
         echo "   <a href=\"classified.php?catid={$catid}&subcatid={$db['id']}\" onmouseover=\"window.status='{$db['description']}';\n        return true;\" onmouseout=\"window.status=''; return true;\">{$db['name']}</a> ({$db['ads']})<br>\n";
     }
     echo "   <div class=\"smallleft\">\n";
     echo "   {$db['description']}<br>\n";
     if ($catnotify && $db[id] && $_SESSION[suserid]) {
         echo "   <a href=\"notify.php?addid={$db['id']}\"\n            onClick='enterWindow=window.open(\"notify.php?" . sidstr() . "addid={$db['id']}\",\"Notify\",\"width=400,height=200,top=200,left=200\"); return false'\n            onmouseover=\"window.status='{$notify_add}'; return true;\"\n            onmouseout=\"window.status=''; return true;\">\n        <img src=\"{$image_dir}/icons/mail.gif\" border=\"0\" alt=\"{$notify_add}\" align=\"right\" vspace=\"2\"></a>\n";
         if ($dbc[passphrase]) {
             echo "<img src=\"{$image_dir}/icons/key.gif\" alt=\"{$cat_pass}\" align=\"right\" vspace=\"2\"\n            onmouseover=\"window.status='{$cat_pass}'; return true;\"\n            onmouseout=\"window.status=''; return true;\">";
         }
         if ($show_newicon) {
             $query = mysql_query("SELECT id FROM " . $prefix . "ads WHERE subcatid='{$db['id']}' AND (TO_DAYS(addate)>TO_DAYS(now())-{$show_newicon})") or died(mysql_error());
             if (mysql_num_rows($query)) {
                 echo "<img src=\"{$image_dir}/icons/new.gif\" alt=\"{$cat_new}\" align=\"right\" vspace=\"2\"\n                onmouseover=\"window.status='{$cat_new}'; return true;\"\n            onmouseout=\"window.status=''; return true;\">";
             }
         }
     }
     echo "   </div>";
     echo "   </td>\n";
     echo " </tr>\n";
 }
 //End while
function ico_adrating($value, $align = "left")
{
    global $ad_rating, $image_dir;
    echo "   <a href=\"adrating.php?{$value}\" onClick='enterWindow=window.open(\"adrating.php?" . sidstr() . "{$value}\",\"Window\",\"width=180,height=180,top=200,left=200\"); return false'\n        onmouseover=\"window.status='{$ad_rating}'; return true;\"\n        onmouseout=\"window.status=''; return true;\">\n        <img src=\"{$image_dir}/icons/handup.gif\" border=\"0\" alt=\"{$ad_rating}\" align=\"{$align}\" vspace=\"2\"></a>\n";
}
    } else {
        ico_icq("{$dbu['icq']}", "left");
    }
}
ico_friend("catid={$catid}&subcatid={$subcatid}&adid={$adid}", "left");
if ($show_url && $dbu[homepage]) {
    if ($sales_option && !sales_checkaccess(3, $_SESSION[suserid], $catid)) {
        // check access for user and cat
        ico_url("", "left");
    } else {
        ico_url("{$dbu['homepage']}", "left");
    }
}
ico_print("", "left");
ico_favorits("adid={$adid}", "left");
if ($show_adrating && $_SESSION[suserid]) {
    ico_adrating("adid={$adid}", "left");
}
if ($show_members_details && $_SESSION[suserid]) {
    ico_info("choice=details&uid={$dbu['id']}&uname={$dbu['username']}", "left");
}
echo "   <div class=\"smallright\">{$ad_nr}{$adid}\n";
if ($_SESSION[susermod]) {
    echo "<a href=\"classified_my_del.php?adid={$db['id']}\" onClick='enterWindow=window.open(\"classified_my_del.php?" . sidstr() . "adid={$db['id']}\",\"Delete\",\"width=400,height=200,top=100,left=100\"); return false' onmouseover=\"window.status='MODERATOR {$admy_delete}'; return true;\" onmouseout=\"window.status=''; return true;\">\n             <img src=\"{$image_dir}/icons/trash.gif\" border=\"0\" alt=\"MODERATOR {$admy_delete}\" align=\"right\" vspace=\"2\"></a>\n";
    echo "<a href=\"classified.php?editadid={$db['id']}\" onmouseover=\"window.status='MODERATOR {$admy_edit}'; return true;\" onmouseout=\"window.status=''; return true;\">\n             <img src=\"{$image_dir}/icons/reply.gif\" border=\"0\" alt=\"MODERATOR {$admy_edit}\" align=\"right\" vspace=\"2\"></a>\n";
}
echo "   </div>\n";
echo "   </div>\n";
echo "   </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo " </table>\n";
include "spacer.inc.php";
if (!empty($errormessage)) {
    //TODO: Error handling needs to be streamlined, we need to create an error handler function or class.. and allow errors to pass through
    //TODO: whatever script they comne in, this is pure bullshit, passing errors in url ..
    #    $errormessage=rawurlencode($errormessage);
    echo "<script language=\"JavaScript\">\n    var winl = (screen.width - 300) / 2;\n    var wint = (screen.height - 150) / 2;\n    window.open(\"message.php?msgheader={$msghead_error}&msg={$errormessage}\",\"Error\",\"width=300,height=150,top=\"+wint+\",left=\"+winl+\",resizeable=no\");\n    </script>\n";
}
if (!empty($textmessage)) {
    #    $textmessage=rawurlencode($textmessage);
    //MOre bullshit passing stupid stuff like this in URL - Textmessages popups should not be sent in URL, but should comne via a function check
    echo "<script language=\"JavaScript\">\n    var winl = (screen.width - 300) / 2;\n    var wint = (screen.height - 150) / 2;\n    window.open(\"message.php?msgheader={$msghead_message}&msg={$textmessage}\",\"Message\",\"width=300,height=150,top=\"+wint+\",left=\"+winl+\",resizeable=no\");\n    </script>\n";
}
if (!empty($show_languages)) {
    $raw_url = rawurlencode(requesturi());
    echo "\n    <SCRIPT LANGUAGE=\"JavaScript\"><!--\n        function changelang(newlang) {\n            exit=false;\n            site = \"lang.php?" . sidstr() . "lng=\"+(newlang)+\"&url={$raw_url}\";\n            if (newlang!=0) {\n                top.location.href=site;\n            } else {\n                top.location.href=\"main.php\";\n            }\n        }\n     //--></SCRIPT>";
    $langstr = "<td align=\"right\"><div class=\"smallright\">\n";
    $langstr .= "<select name=\"lang\" onchange=\"changelang(this.options[this.selectedIndex].value)\">\n";
    for ($i = 0; $i < count($language); $i++) {
        if ($language[$i] == $language_user) {
            $selected = "SELECTED";
        } else {
            $selected = "";
        }
        $langstr .= "<option value=\"{$language[$i]}\" {$selected}>{$language[$i]}</option>\n";
    }
    $langstr .= "</select>\n";
    $langstr .= "</div></td>\n";
}
# Login Window
#################################################################################################
    echo "         <tr>\n";
    echo "          <td><div class=\"maininputleft\">{$memf_newsletter} : </div></td>\n";
    echo "          <td><input type=checkbox name=newsletter CHECKED></td>\n";
    echo "         </tr>\n";
}
$result = mysql_query("select * FROM " . $prefix . "config WHERE type='member' AND name<>'newsletter' AND name<>'sex' AND name<>'picture' ORDER BY value6,id") or die(mysql_error());
while ($db = mysql_fetch_array($result)) {
    $language = "memf_" . $db['name'];
    $preselect = $db['name'] == "homepage" ? "http://" : "";
    echo memberfield("1", "{$db['name']}", ${$language}, $preselect, 30);
}
echo "         <tr><td colspan=2><div class=\"smallcenter\">&nbsp;</div></td></tr>\n";
echo "         <tr><td align=right><em id=\"red\">*&nbsp;</em></td><td><em id=\"red\">{$memb_newpublic}</em></td></tr>";
echo "         <tr><td align=right><em id=\"red\">**&nbsp;</em></td><td><em id=\"red\">{$require}</em></td></tr>";
echo "         <tr><td colspan=2><div class=\"smallcenter\"><br>\n";
echo "                         <a href=\"termsofuse.php?" . sidstr() . "\" onClick='enterWindow=window.open(\"termsofuse.php\",\"Fenster\",\n                          \"width=750,height=550,top=50,left=50,scrollbars=yes\"); return false'>\n                          {$memb_newterms}</a>\n                          <input type=checkbox name=acceptterms CHECKED></div></td>\n";
echo "         </tr>\n";
echo "         <tr>\n";
echo "          <td>&nbsp;</td>\n";
echo "          <td><br><input type=submit value=\"{$memb_newsubmit}\" name=\"submit\"></td>\n";
echo "         </tr>\n";
echo "        </form>\n";
echo "        </table>\n";
echo "        </div>\n";
echo "        </td>\n";
echo "       </tr>\n";
echo "      </table>\n";
echo "    </td>\n";
echo "   </tr>\n";
echo " </table>\n";
#  The Foot-Section
        $prevtarget = $target - 1;
        $nexttarget = $target + 1;
        $prevadid = $tmp[$prevtarget];
        $nextadid = $tmp[$nexttarget];
        echo "<table align=\"center\"  cellspacing=\"0\" cellpadding=\"3\" width=\"100%\" border=\"0\">\n";
        echo "<tr><td><div class=\"maincatnav\">";
        echo "<a href=\"classified.php\" onmouseover=\"window.status='{$ad_home}'; return true;\"\n    onmouseout=\"window.status=''; return true;\">{$ad_home}</a> /\n      <a href=\"classified.php?catid={$catid}\" onmouseover=\"window.status='{$db['name']}'; return true;\"\n    onmouseout=\"window.status=''; return true;\">{$db['name']}</a> /\n      <a href=\"classified.php?catid={$catid}&subcatid={$subcatid}\" onmouseover=\"window.status='{$db2['name']}'; return true;\"\n    onmouseout=\"window.status=''; return true;\">{$db2['name']}</a><br>\n";
        echo "</div></td>";
        echo "<td><div class=\"mainpages\">";
        echo "[<a href=\"classified.php?catid={$catid}&subcatid={$subcatid}&adid={$nextadid}\" onmouseover=\"window.status='{$nav_prev}'; return true;\" onmouseout=\"window.status=''; return true;\"><</a>]\n";
        echo "[<a href=\"classified.php?catid={$catid}&subcatid={$subcatid}&adid={$prevadid}\" onmouseover=\"window.status='{$nav_next}'; return true;\" onmouseout=\"window.status=''; return true;\">></a>]\n";
        echo "</div></td></tr>";
        echo "</table>";
        $result = mysql_query("SELECT * FROM " . $prefix . "ads WHERE id={$adid} {$approval}") or died("Record NOT Found<br>" . mysql_error());
        $db = mysql_fetch_array($result) or died("Ad NOT Found");
        $result2 = mysql_query("SELECT * FROM " . $prefix . "userdata WHERE id={$db['userid']}") or died("Record NOT Found<br>" . mysql_error());
        $dbu = mysql_fetch_array($result2) or died("User NOT Found");
        $result3 = mysql_query("SELECT * FROM " . $prefix . "adcat WHERE id='{$db['catid']}' AND disabled<>'1'") or died("Record NOT Found<br>" . mysql_error());
        $dbc = mysql_fetch_array($result3) or died("Category NOT Found");
        // Stat Viewed Counter
        mysql_query("update " . $prefix . "ads set viewed=viewed+1 where id={$adid}") or died("Database Query Error");
        include "classified_ad.inc.php";
    } else {
        // NO or no valid passphrase
        echo "{$pass_text}";
        echo "<script language=javascript>\n    PASS=window.open(\"passphrase.php?" . sidstr() . "catid={$catid}&userid={$_SESSION['suserid']}\",\"Passphrase\",\"width=180,height=120,top=200,left=200\")\n    PASS.focus();\n    </script>\n";
    }
    // End Passphrase
}
# End of Page reached
#################################################################################################
         echo "[<a href=\"webmail.php?action={$action}&offset={$noffset}&poffset={$npoffset}\" onmouseover=\"window.status='{$nav_next}'; return true;\" onmouseout=\"window.status=''; return true;\">></a>]\n";
     }
 }
 echo "</div></td></tr>\n";
 echo "</table>\n";
 $sql .= " LIMIT {$offset}, {$perpage}";
 echo "<table align=\"center\"  cellspacing=\"1\" cellpadding=\"3\" width=\"100%\" border=\"0\">\n";
 $result = mysql_query($sql) or die(mysql_error());
 while ($db = mysql_fetch_array($result)) {
     echo " <tr>\n";
     echo "   <td class=\"classcat1\">\n";
     echo "   <div class=\"smallleft\">\n";
     if ($action != "trash" && $action != "sent") {
         echo "   <a href=\"webmail.php?action=del&id={$db['id']}\" onmouseover=\"window.status='{$webmail_del}'; return true;\"\n            onmouseout=\"window.status=''; return true;\">\n                <img src=\"{$image_dir}/icons/trash.gif\" border=\"0\" alt=\"{$webmail_del}\"></a>\n";
         if ($db[fromid]) {
             echo "<a href=\"sendmail.php?username={$db['fromname']}\" onClick='enterWindow=window.open(\"sendmail.php?" . sidstr() . "username={$db['fromname']}&newsubject=" . rawurlencode("Re:" . $db[subject]) . "&newtext=" . rawurlencode("\n\n> " . str_replace("\n", "\n> ", $db[text]) . "\n") . "\",\"EMail\",\"width=600,height=430,top=100,left=100\"); return false'\n                onmouseover=\"window.status='{$webmail_reply}'; return true;\"\n                onmouseout=\"window.status=''; return true;\">\n                <img src=\"{$image_dir}/icons/email.gif\" border=\"0\" alt=\"{$webmail_reply}\"></a>\n";
         }
     } elseif ($action == "sent") {
         echo "   <a href=\"webmail.php?action=sentdel&id={$db['id']}\" onmouseover=\"window.status='{$webmail_sdel}'; return true;\"\n            onmouseout=\"window.status=''; return true;\">\n                <img src=\"{$image_dir}/icons/trash.gif\" border=\"0\" alt=\"{$webmail_sdel}\"></a>\n";
     } elseif ($action == "trash") {
         echo "   <a href=\"webmail.php?action=trashdel&id={$db['id']}\" onmouseover=\"window.status='{$webmail_tdel}'; return true;\"\n            onmouseout=\"window.status=''; return true;\">\n                <img src=\"{$image_dir}/icons/trash.gif\" border=\"0\" alt=\"{$webmail_tdel}\"></a>\n";
         echo "   <a href=\"webmail.php?action=trashundel&id={$db['id']}\" onmouseover=\"window.status='{$webmail_tundel}'; return true;\"\n            onmouseout=\"window.status=''; return true;\">\n                <img src=\"{$image_dir}/icons/yinyan.gif\" border=\"0\" alt=\"{$webmail_tundel}\"></a>\n";
     }
     echo "   </div>\n";
     echo "   </td>\n";
     echo "   <td class=\"classcat4\">\n";
     echo "   <div class=\"mainleft\">\n";
     echo "<b>{$webmail_from}:</b> \n";
     if ($db[fromid]) {
         if ($action != "sent") {
             echo "<a href=\"members.php?choice=details&uid={$db['fromid']}&uname={$db['fromname']}\">{$db['fromname']}</a> ";