$obj1->pic_id = $pic_id;
     $obj1->Userid = $uid;
     $obj1->filetype = $filetype;
     $output = json_encode($obj1);
     echo $output;
     break;
 case 'v':
     $result32 = mysql_query("SELECT FileNameHQ FROM {$table2} WHERE pic_id = '{$pic_id}'");
     if (mysql_error() !== "") {
         $error_code = 1;
     }
     $FileNameHQ = mysql_result($result32, isset($i32), 'FileNameHQ');
     $FILE = $pic_hq_path . "/" . $FileNameHQ;
     $dest_path = $pic_thumbs_path;
     $max_len = 160;
     $FileNameV = createPreviewPicture($FILE, $dest_path, $max_len, $sr);
     $fileV = $pic_thumbs_path . "/" . $FileNameV;
     clearstatcache();
     @chmod($fileV, 0700);
     clearstatcache();
     @($fh = fopen($fileV, 'r'));
     if (!$fh) {
         $error_code = 1;
     } else {
         fclose($fh);
         $fh = fopen($p2b_path . 'pic2base/log/p2b.log', 'a');
         fwrite($fh, date('d.m.Y H:i:s') . ": > > > DB-Wartung > > > Thumb-Vorschau zum Bild " . $pic_id . " wurde neu erzeugt. (Zugriff von " . $_SERVER['REMOTE_ADDR'] . ")\n");
         fclose($fh);
     }
     $obj1 = new stdClass();
     $obj1->errorCode = $error_code;
function savePicture($pic_id, $anzahl, $user_id, $Orientation, $sr)
{
    include $sr . '/bin/share/global_config.php';
    include $sr . '/bin/share/db_connect1.php';
    $md5 = buildMd5sumCommand($sr);
    // wenn eine lagerichtige Kopie angelegt wurde, wird diese weiter verwendet
    if ($Orientation == '3' or $Orientation == '6' or $Orientation == '8') {
        $FILE = $pic_rot_path . "/" . $pic_id . ".jpg";
    } else {
        $FILE = $pic_path . "/" . $pic_id . ".jpg";
    }
    //vom Original-JPG-Bild wird die Pruefsumme gebildet:
    $command = $md5 . " {$FILE}";
    $sum = explode(' ', shell_exec($command));
    //echo "Pr&uuml;fsumme: ".$sum[0]."<BR>";
    // 1) anlegen des hq-Bildes: (resamplen, speichern unter /vorschau/hq-preview)
    //HQ aus Original erzeugen
    $max_len = '800';
    $FileNameHQ = resizeOriginalPicture($FILE, $pic_hq_path, $max_len, $sr);
    $FILEHQ = $pic_hq_path . "/" . $FileNameHQ;
    //Thumb aus Performace-Gruenden aus HQ erzeugen
    // 2) Vorschaubild anlegen und im Ordner </vorschau/thumbs> speichern:
    $max_len = '160';
    $FileNameV = createPreviewPicture($FILEHQ, $pic_thumbs_path, $max_len, $sr);
    $result1 = mysql_query("UPDATE {$table2} SET FileNameHQ = '{$FileNameHQ}', FileNameV = '{$FileNameV}', md5sum = '{$sum['0']}' WHERE pic_id = '{$pic_id}'");
    //die Datei-Attribute werden fuer alle hochgeladenen bzw. erzeugten Bilddateien auf 0700 gesetzt:
    //HQ-Datei:
    $fileHQ = $pic_hq_path . "/" . $FileNameHQ;
    clearstatcache();
    chmod($fileHQ, 0700);
    clearstatcache();
    //Vorschaubild:
    $fileV = $pic_thumbs_path . "/" . $FileNameV;
    clearstatcache();
    chmod($fileV, 0700);
    clearstatcache();
    // damit wurden alle Vorschaubilder (ob mit oder ohne Ausrichtungsinformation) lagerichtig,
    // also aufrecht abgespeichert
}
function savePicture($pic_id, $anzahl, $user_id, $Orientation)
{
    include '../../share/global_config.php';
    include $sr . '/bin/share/db_connect1.php';
    if ($Orientation == '3' or $Orientation == '6' or $Orientation == '8') {
        $FILE = $pic_rot_path . "/" . $pic_id . ".jpg";
    } else {
        $FILE = $pic_path . "/" . $pic_id . ".jpg";
    }
    //vom Original-JPG-Bild wird die Pr�fsumme gebildet:
    $command = $md5sum_path . "/md5sum {$FILE}";
    $sum = explode(' ', shell_exec($command));
    //echo "Pr&uuml;fsumme: ".$sum[0]."<BR>";
    if ($anzahl == '1') {
        //echo "...bearbeite Bild ".$bild."<BR>";
        // 1) anlegen des hq-Bildes: (resamplen, ggf. drehen, speichern unter /vorschau/hq-preview)
        $max_len = '800';
        //HQ aus Original erzeugen
        $FileNameHQ = resizeOriginalPicture($FILE, $HQ_verzeichnis, $max_len);
        //echo "tempor�rer Datei-Name: ".$FileNameHQ." Ausrichtung: ".$Orientation."<BR>";
        $FILE = $pic_hq_preview . "/" . $FileNameHQ;
        //Thumb aus HQ erzeugen
        // 2) Vorschaubild anlegen und im Ordner </vorschau/thumbs> speichern:
        $max_len = '160';
        $FileNameV = createPreviewPicture($FILE, $vorschau_verzeichnis, $max_len);
        $result1 = mysql_query("UPDATE {$table2} SET FileNameHQ = '{$FileNameHQ}', FileNameV = '{$FileNameV}', md5sum = '{$sum['0']}' WHERE pic_id = '{$pic_id}'");
    } else {
    }
    //die Datei-Attribute werden f�r alle hochgeladenen bzw. erzeugten Bilddateien auf 0700 gesetzt:
    //HQ-Datei:
    $fileHQ = $HQ_verzeichnis . "/" . $FileNameHQ;
    clearstatcache();
    chmod($fileHQ, 0700);
    clearstatcache();
    //Vorschaubild:
    $fileV = $vorschau_verzeichnis . "/" . $FileNameV;
    clearstatcache();
    chmod($fileV, 0700);
    clearstatcache();
}