echo $output;
     break;
 case 'hq':
     // es wird versucht, ein fehlendes HQ-Vorschaubild aus dem Original neu zu erzeugen:
     $result31 = mysql_query("SELECT FileName FROM {$table2} WHERE pic_id = '{$pic_id}'");
     if (mysql_error() !== "") {
         $error_code = 1;
     }
     $FileName = mysql_result($result31, isset($i31), 'FileName');
     $FILE = $pic_path . "/" . $FileName;
     @($file_handle = fopen($FILE, 'r'));
     if ($file_handle) {
         fclose($file_handle);
         $dest_path = $pic_hq_path;
         $max_len = 800;
         $FileNameHQ = resizeOriginalPicture($FILE, $dest_path, $max_len, $sr);
         $fileHQ = $pic_hq_path . "/" . $FileNameHQ;
         //echo $fileHQ;
         clearstatcache();
         @chmod($fileHQ, 0700);
         clearstatcache();
         @($fh = fopen($fileHQ, 'r'));
         if (!$fh) {
             $error_code = "No Original for " . $pic_id;
         } else {
             fclose($fh);
             $fh = fopen($p2b_path . 'pic2base/log/p2b.log', 'a');
             fwrite($fh, date('d.m.Y H:i:s') . ": > > > DB-Wartung > > > HQ-Vorschau zum Bild " . $pic_id . " wurde neu erzeugt. (Zugriff von " . $_SERVER['REMOTE_ADDR'] . ")\n");
             fclose($fh);
         }
     }
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();
}