Einzelnen Beitrag anzeigen
  #5 (permalink)  
Alt 11.02.2013, 19:49
Walter IT-Services Walter IT-Services ist offline
Michael Walter
XHTMLforum-Mitglied
 
Registriert seit: 16.02.2010
Ort: Berlin
Beiträge: 237
Walter IT-Services befindet sich auf einem aufstrebenden Ast
Standard

Och, bitte streng dich auch selbst ein wenig an.

Hier ist definitv debugging gefordert.
Bei deinem unformatierten Quellcode sieht man sehr schlecht durch.
Außerdem wird auf jede Menge Variablen zugegriffen, wo die Zuweisung der Werte in deinem Quellcode fehlt. Meine Glaskugel ist momentan leider defekt

Nutze das hier um alle Fehlermeldungen auch wirklich auszugeben:
PHP-Code:
error_reporting(-E_NOTICE);
ini_set("display_errors",1); 
Ruf die beiden Funktionen mit var_dump() auf, um zu sehen, welche Wert sie zurückgeben oder prüfe den Wert zumindest und lass eine Fehlermeldung ausgeben.

Du hast vor dem move_upload_file() copy() mit den gleichen Werten ausgeführt. Lass das. Die erste Funktion ist die richtige und reicht völlig aus.

Tipp: Wenn du Variablen zuweist, dann musst sie nicht mit Anführungszeichen umschließen

Außerdem wäre noch ein var_dump($_FILES); nicht schlecht. Da kann man überprüfen, ob der Upload wirklich geklappt hat.

Ich habe das Gefühl, dass du noch nicht so viel Erfahrung hast.
Daher leiste ich mal Pionierarbeit und zeige dir, wie du deinen Fehler debuggen kannst.

Hier dein überarbeiteter Quellcode:
PHP-Code:
<?php
error_reporting
(-E_NOTICE);
ini_set("display_errors",1);
?>
<html>
<head>
<title>Administration artmedic aktuell 2.0</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.titel {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: #FFFFFF;
    text-decoration: none;
}
.titeldunkel {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: #333366;
    text-decoration: none;
}
.text {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: normal;
    color: #333366;
    text-decoration: none;
}
.inputtext {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
    color: #660066;
    text-decoration: none;
    background-color: #FFFFFF;
    border: 1px solid #666699;
}
-->
</style>
</head>

<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<?php 
if(!is_file("artmedic_aktuell_inc.php"))
{
echo 
"<br><br><center><p class=\"titeldunkel\">Es existiert noch keine Einstellungsdatei für artmedic aktuell!<br>
Führen Sie zunächst Setup durch.<br>
Klicken Sie <a href=\"artmedic_aktuell_setup.php\">hier</a>, um Setup durchzuführen.</p>"
;
exit;} 
?>
<p>&nbsp;</p>
<table width="100%" height="100%" border="0" align="center" cellpadding="4" cellspacing="0">
  <tr bgcolor="#666699">
    <td height="20" colspan="2" class="titel">Administration artmedic aktuell
      2.0</td>
  </tr>
  <tr>
    <td width="15%" valign="top" bgcolor="#6666CC"><p>&nbsp;</p>
      <p><a href="aktuell.php" target="_blank" class="titel">Anzeige
            einspaltig</a></p>      <p><a href="aktuell2.php" target="_blank" class="titel">Anzeige zweispaltig</a></p>
    </td>
    <td width="85%" align="center" valign="top" bgcolor="#FFFFFF" class="inputtext">
  
<?PHP
############################################################################# 
# artmedic aktuell 2.0
# Copyright (c) 2003 Ellen Baitinger, http://www.artmedic.de (kontakt@artmedic.de) # 
#  
# This program is free software;
# This program is distributed in the hope that it will be useful, # 
# but WITHOUT ANY WARRANTY; without even the implied warranty of # 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
#Dieses Script kann kostenlos auf privaten und kommerziellen Seiten eingesetzt und angepasst werden, 
#solange Sie den Link auf artmedic webdesign und die Hinweise auf das Copyright und die Autorenschaft intakt lassen.
#Die Nutzung des Programms erfolgt auf eigene Gefahr. <br>
#Das Programm darf nicht weiterverkauft oder in anderer Weise zu Geld gemacht werden.
#############################################################################               
require("artmedic_aktuell_inc.php");
if(isset(
$_POST['password'])){$password $_POST['password'];}
if(isset(
$_GET['password'])){$password $_GET['password'];}
$input $_POST['input'];
if(!isset(
$password) and !isset($input))
    {
    
?>      <p>&nbsp; </p>
      <table width="500" border="0" cellspacing="2" cellpadding="4">
        <tr bgcolor="#666699">
          <td class="titel">Passwort eingeben</td>
        </tr>
        <tr>
          <td bgcolor="#9999CC">
            <form name="form2" method="post" action="artmedic_aktuell_admin.php">
              <input name="password" type="password" class="inputtext" id="password">
              <input type="submit" name="Submit3" value="einloggen">
            </form>
          </td>
        </tr>
      </table>
      <?PHP
     
}
if(isset(
$password) and $password!=$passwort and !isset($input))
    {
    
?>      <table width="500" border="0" cellspacing="2" cellpadding="4">
        <tr bgcolor="#666699">
          <td colspan="2" class="titel">Passwort eingeben</td>
        </tr>
        <tr>
          <td width="100" nowrap bgcolor="#666699" class="titel">Falsches Passwort</td>
          <td width="392" bgcolor="#CCCCFF">
            <form name="form2" method="post" action="artmedic_aktuell_admin.php">
              <input name="password" type="password" class="inputtext" id="password">
              <input type="submit" name="Submit3" value="einloggen">
            </form>
          </td>
        </tr>
      </table>
      <?PHP
     
}     
     if(
$password==$passwort and !isset($input))
     {
     
?> <table width="100%" border="0" align="center" cellpadding="4" cellspacing="0">
        <tr bgcolor="#666699">
          <td height="20" colspan="2" class="titel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="artmedic_aktuell_admin.php?password=<?PHP echo $password?>" class="inputtext">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Neue
              Meldung eingeben &nbsp;&nbsp;</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="artmedic_aktuell_delete.php?password=<?PHP echo $password?>" class="inputtext">&nbsp;&nbsp;&nbsp;&nbsp;Aktuelle &nbsp;Meldungen
              l&ouml;schen&nbsp;&nbsp;&nbsp;&nbsp;</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="artmedic_aktuell_deletearchiv.php?password=<?PHP echo $password?>" class="inputtext">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Archiv-Meldungen
              l&ouml;schen&nbsp;&nbsp;&nbsp;&nbsp;</a></td>
        </tr>
      </table>      
      <br>      <table width="500" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><form action="artmedic_aktuell_admin.php" method="post" enctype="multipart/form-data" name="form1">
              <table width="100%" border="0" cellspacing="2" cellpadding="2">
                <tr bgcolor="#666699">
                  <td colspan="3" class="titel">Neue Meldung</td>
                </tr>
                <tr bgcolor="#6666CC">
                  <td colspan="3" class="titel">Startzeit eingeben (wenn die Anzeige ab sofort
                    erfolgen soll, hier nichts eingeben)</td>
                </tr>
                <tr>
                  <td width="13%" valign="top" bgcolor="#CCCCFF" class="titeldunkel">Datum</td>
                  <td width="31%" nowrap bgcolor="#CCCCFF">
                    <input name="tagstart" type="text" class="inputtext" id="tag3" onKeyup="if (this.value.length == 2) document.all['form1'].monatstart.focus()" size="2" maxlength="2">
                    .
                    <input name="monatstart" type="text" class="inputtext" id="monat3" onKeyup="if (this.value.length == 2) document.all['form1'].jahrstart.focus()" size="2" maxlength="2">
                    .
                    <input name="jahrstart" type="text" class="inputtext" id="jahr2" onKeyup="if (this.value.length == 2) document.all['form1'].stundestart.focus()" size="2" maxlength="2">
                  </td>
                  <td width="56%" bgcolor="#ECECFF" class="text">z.B. 19.08.02                    </td>
                </tr>
                <tr>
                  <td valign="top" bgcolor="#CCCCFF" class="titeldunkel">Uhrzeit</td>
                  <td bgcolor="#CCCCFF">
                    <input name="stundestart" type="text" class="inputtext" id="stunde3" onKeyup="if (this.value.length == 2) document.all['form1'].minutestart.focus()" size="2" maxlength="2">
                    :
                    <input name="minutestart" type="text" class="inputtext" id="minute3" onKeyup="if (this.value.length == 2) document.all['form1'].tagende.focus()" size="2" maxlength="2">
                  </td>
                  <td bgcolor="#ECECFF" class="text">z.B. 20:15 (wenn Sie keine Uhrzeit eingeben,
                    dann ist sie 00.00 Uhr)</td>
                </tr>
                <tr bgcolor="#6666CC">
                  <td colspan="3" valign="top" class="titel">Endzeit eingeben (wenn Sie hier
                    nichts eingeben, erfolgt die Anzeige unbegrenzt lange)</td>
                </tr>
                <tr>
                  <td valign="top" bgcolor="#CCCCFF" class="titeldunkel">Datum</td>
                  <td bgcolor="#CCCCFF">
                    <input name="tagende" type="text" class="inputtext" id="tag22" onKeyup="if (this.value.length == 2) document.all['form1'].monatende.focus()" size="2" maxlength="2">
                    .
                    <input name="monatende" type="text" class="inputtext" id="monat22" onKeyup="if (this.value.length == 2) document.all['form1'].jahrende.focus()" size="2" maxlength="2">
                    .
                    <input name="jahrende" type="text" class="inputtext" id="jahr22" onKeyup="if (this.value.length == 2) document.all['form1'].stundeende.focus()" size="2" maxlength="2">
                  </td>
                  <td bgcolor="#ECECFF" class="text">z.B. 19.08.02</td>
                </tr>
                <tr>
                  <td valign="top" bgcolor="#CCCCFF" class="titeldunkel">Uhrzeit</td>
                  <td bgcolor="#CCCCFF">
                    <input name="stundeende" type="text" class="inputtext" id="stunde22" onKeyup="if (this.value.length == 2) document.all['form1'].minuteende.focus()" size="2" maxlength="2">
                    :
                    <input name="minuteende" type="text" class="inputtext" id="minute22" onKeyup="if (this.value.length == 2) document.all['form1'].titel.focus()" size="2" maxlength="2">
                  </td>
                  <td bgcolor="#ECECFF" class="text"> z.B. 20:15 (wenn Sie keine Uhrzeit eingeben,
                    dann ist sie 00.00 Uhr)</td>
                </tr>
                <tr bgcolor="#6666CC">
                  <td colspan="3" valign="top" class="titel">Eingabe der Informationen</td>
                </tr>
                <tr>
                  <td valign="top" bgcolor="#CCCCFF" class="titeldunkel">Titel</td>
                  <td colspan="2" bgcolor="#ECECFF">
                    <input name="titel" type="text" class="inputtext" id="titel2" size="50">
                  </td>
                </tr>
                <tr>
                  <td valign="top" bgcolor="#CCCCFF" class="titeldunkel">Infotext</td>
                  <td colspan="2" bgcolor="#ECECFF">
                    <textarea name="infotext" cols="50" rows="8" class="inputtext" id="textarea"></textarea>
                  </td>
                </tr>
                <tr>
                  <td valign="top" bgcolor="#CCCCFF" class="titeldunkel">Bild<br>
                    <span class="text">optional</span></td>
                  <td colspan="2" bgcolor="#ECECFF" class="text"><input name="grafik" type="file" class="inputtext" size="40">
                    <br>
                  nur JPEG - Bildformat</td>
                </tr>
                <tr>
                  <td valign="top" bgcolor="#CCCCFF" class="titeldunkel">URL<br>
                    <span class="text">optional</span></td>
                  <td colspan="2" bgcolor="#ECECFF" class="text">
                    <input name="url" type="text" class="inputtext" id="url" size="50">
                    <br>
                    hier k&ouml;nnen Sie einen Link (&gt;&gt;&gt; mehr info)
                    einf&uuml;gen<br>
                    Wenn Sie nicht intern, sonder auf eine fremde Seite verlinken,
                    f&uuml;gen Sie bitte die korrekteURL beginnend mit <span class="titeldunkel">http://</span>www..........
                    ein.</td>
                </tr>
                <tr>
                  <td align="right" valign="top" bgcolor="#CCCCFF" class="titeldunkel"><input name="archivieren" type="checkbox" id="archivieren" value="1"></td>
                  <td colspan="2" bgcolor="#ECECFF" class="text">Meldung soll
                    beim L&ouml;schen ins Newsarchiv verschoben werden</td>
                </tr>
                <tr bgcolor="#6666CC">
                  <td>&nbsp;</td>
                  <td colspan="2">
                    <input name="Submit" type="submit" class="inputtext" value="Meldung eintragen">
                    <input name="Submit2" type="reset" class="inputtext" value="Zur&uuml;cksetzen">
                    <input name="input" type="hidden" id="input" value="1">
                    <input name="password" type="hidden" id="input2" value="<?PHP echo $password?>">
                  </td>
                </tr>
              </table>
            </form>
          </td>
        </tr>
      </table>
      <p>
        <?PHP
      
}
if(
$input==and $password==$passwort){
?>
<table width="100%" border="0" align="center" cellpadding="4" cellspacing="0">
        <tr bgcolor="#666699">
          <td height="20" colspan="2" class="titel">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="artmedic_aktuell_admin.php?password=<?PHP echo $password?>" class="inputtext">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Neue
              Meldung &nbsp;&nbsp;</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="artmedic_aktuell_delete.php?password=<?PHP echo $password?>" class="inputtext">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Meldungen
              l&ouml;schen&nbsp;&nbsp;&nbsp;&nbsp;</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="artmedic_aktuell_deletearchiv.php?password=<?PHP echo $password?>" class="inputtext">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Archiv-Meldungen
              l&ouml;schen&nbsp;&nbsp;&nbsp;&nbsp;</a>&nbsp;&nbsp;&nbsp;</td>
        </tr>
      </table><br>    
      <table width="500" border="0" cellspacing="0" cellpadding="2">
        <tr>
          <td bgcolor="#666699" class="titel">Meldung wurde eingetragen</td>
        </tr>
        <tr>
          <td bgcolor="#FFFFFF">
            <?PHP 
            
if($grafik_name!="")
            {
                if(
$grafik_type != "image/jpeg")
                {
                    die (
"Fehler: \"".$grafik_name."\" ist keine gültige JPEG-Datei<br><br><a href=\"javascript:history.go(-1);\">&laquo;&laquo; Zurück </A>");
                }
            }
            
//Startzeitpunkt festlegen
            
$jahrstart $_POST['jahrstart'];
            
$monatstart $_POST['monatstart'];
            
$tagstart $_POST['tagstart'];
            
$stundestart $_POST['stundestart'];
            
$minutestart $_POST['minutestart'];
            if(empty(
$stundestart)) {$stundestart "0";}
            if(empty(
$minutestart)) {$minutestart "0";}

            if(!empty(
$jahrstart))
            {
                
$check checkdate($monatstart,$tagstart,$jahrstart);
                if(
$check != 1)
                    die(
"Der ".$tagstart.$monatstart.$jahrstart." ist kein korrektes Datum.<br><br><a href=\"javascript:history.go(-1);\">&laquo;&laquo; Zurück </A>");
                
$timestampstart mktime($stundestart,$minutestart,0,$monatstart,$tagstart,$jahrstart); 
            }
            else
                
$timestampstart time();
            
//stunde,minute,sekunde,M-d-Y
            
$datum1 strftime("%a, %d.%m.%Y %H:%M"$timestampstart);
            
$datum1 ereg_replace("Thu""Donnerstag"$datum1);
            
$datum1 ereg_replace("Fri""Freitag"$datum1);
            
$datum1 ereg_replace("Sat""Samstag"$datum1);
            
$datum1 ereg_replace("Sun""Sonntag"$datum1);
            
$datum1 ereg_replace("Mon""Montag"$datum1);
            
$datum1 ereg_replace("Tue""Dienstag"$datum1);
            
$datum1 ereg_replace("Wed""Mittwoch"$datum1);
            echo 
"Startdatum: $datum1<br>";
            
//Klammerende ifjahrstart


            //Ablaufzeitpunkt festlegen
            
$jahrende $_POST['jahrende'];
            
$monatende $_POST['monatende'];
            
$tagende $_POST['tagende'];
            
$stundeende $_POST['stundeende'];
            
$minuteende $_POST['minuteende'];
            if(!empty(
$jahrende))
            {
                
$check checkdate($monatende,$tagende,$jahrende);
                if(
$check != 1)die("Der $tagende.$monatende.$jahrende ist kein korrektes Datum.<br><br><a href=\"javascript:history.go(-1);\">&laquo;&laquo; Zurück </A>");
                if(empty(
$stundeende)) {$stundeende "0";}
                if(empty(
$minuteende)) {$minuteende "0";}
                
$timestampende mktime($stundeende,$minuteende,0,$monatende,$tagende,$jahrende); 
                
//stunde,minute,sekunde,M-d-Y
                
$datum2 strftime("%a, %d.%m.%Y %H:%M"$timestampende);
                
$datum2 ereg_replace("Thu""Donnerstag"$datum2);
                
$datum2 ereg_replace("Fri""Freitag"$datum2);
                
$datum2 ereg_replace("Sat""Samstag"$datum2);
                
$datum2 ereg_replace("Sun""Sonntag"$datum2);
                
$datum2 ereg_replace("Mon""Montag"$datum2);
                
$datum2 ereg_replace("Tue""Dienstag"$datum2);
                
$datum2 ereg_replace("Wed""Mittwoch"$datum2);
                echo 
"Endzeitpunkt: ".$datum2."<br>";
            }
            else
            {
                
$timestampende "";
                
$datum2 "";
                echo 
"zeitlich unbegrenzte Anzeige, Meldung muss bei Bedarf manuell gelöscht werden.";
            }
            
            
//Daten aufbereiten
            
$infotext $_POST['infotext'];
            
$titel $_POST['titel'];
            
$url $_POST['url'];
            
$infotext ereg_replace("\n""<br>"$infotext);
            
$infotext ereg_replace("\r"""$infotext);
            
$infotext nl2br($infotext);
            
$infotext stripslashes($infotext);
            
$infotext preg_replace("/((http(s?):\/\/)|(www\.))([\w\_\-\/\.\?\=\&]+)/i""<a href=\"http$3://$4$5\" target=\"_blank\">$2$4$5</a>"$infotext);
            
$infotext preg_replace("/([\w\_\-\.]+)(@)([\w\_\-\.]+)/i""<a href=\"mailto:$0\">$0</a>"$infotext);
            
            
$titel stripslashes($titel);
            
//URL festlegen
            
if($url!="")
                
$url "<a href=\"".$url."\"> >>> mehr info</a>";
            else
                
$url "";
            
//Bild festlegen
            
$id time();
            
$bilderpfad $grafik_name;
            
//copy($grafik, $bilderpfad);
            
            
if(move_uploaded_file($grafik$bilderpfad))
            {
                if(
$dest_width!="")
                {
                    
//Thumbnail erzeugen
                    
$scr$bilderpfad
                    
$dest "$id".".jpg";
                    
$imageInfo getimagesize($scr); 
                    
$src_width $imageInfo[0]; 
                    
$src_height $imageInfo[1]; 
                    
$dest_height "$dest_width"*"$src_height"/"$src_width";
                    
                    
$src_img imagecreatefromjpeg($scr);
                    
$dst_img imagecreatetruecolor($dest_width,$dest_height);
                    
                    
imagecopyresampled($dst_img$src_img0000$dest_width$dest_height$src_width$src_height);
                    
imagejpeg($dst_img$dest70);
                    
imagedestroy($src_img);
                    
imagedestroy($dst_img);
                    echo 
'unlink('.$bilderpfad.')';
                    
var_dump(unlink($bilderpfad));
                    
$bilderpfad $dest;
                }
                echo 
'chmod('.$bilderpfad.',0644):';
                
var_dump(chmod($bilderpfad,0644));
                echo 
"<br>Bild $grafik_name ($grafik_size Bytes) wurde hochgeladen<br>";
                
$bildurl "$scripturl"."$bilderpfad";
                
$bildhtml "<td><img src=\"$bildurl\"></td>";
            }
            else 
            {
                echo 
'<br>Datei konnte nicht verschoben werden: move_upload_file("'.$grafik.'","'.$bilderpfad.'")</br>';
                echo 
"<br>Info: Es wurde kein Bild hochgeladen.<br>";
                
$bildhtml "";
            }

            
$archivieren $_POST[archivieren];
            
//Daten speichern
            
$fp fopen("$news""a+");
            if(
$fp){
            
flock($fp,2);
            
fputs ($fp"$timestampstart&&$timestampende&&$datum1&&$titel&&$infotext&&$url&&$bilderpfad&&$bildhtml&&$archivieren&&\n");
            
flock($fp,3);
            
fclose ($fp);}
            
//Rückmeldung ausgeben
            
$newstemplatefopen ("$template","r");
            
$newshtml fread($newstemplatefilesize($template));
            
$newshtml =  ereg_replace("%titel%","$titel",$newshtml);
            
$newshtml =  ereg_replace("%datum%","$datum1",$newshtml);
            
$newshtml =  ereg_replace("%infotext%","$infotext",$newshtml);
            
$newshtml =  ereg_replace("%url%","$url",$newshtml);
            
$newshtml ereg_replace("%bild%""$bildhtml"$newshtml);
            
fclose ($newstemplate);
            echo 
"$newshtml";
?>
          </td>
        </tr>
      </table>
      <?PHP
//Klammerende ifinput
}
?>
    </td>
  </tr>
</table>
<p>&nbsp;</p>
<?
var_dump
($_FILES);
?>
</body>
</html>
EDIT
Hast du auch auf dem Server in dem Verzechnis geschaut, ob das Bild da ist?
Vielleicht liegt hier nur ein Rechteproblem vor, was dich das Bild nicht anzeigen lässt.
Ich hab das schon oft bei Kunden auf dem Server gehabt, dass ich per PHP generierte/verschobene Bilder mit neuen Rechten ausstatten musste
__________________
Walter IT-Services
Michael Walter

http://www.walter-it.de
http://blog.walter-it.de

Geändert von Walter IT-Services (11.02.2013 um 19:52 Uhr)
Mit Zitat antworten