\n"; $imageDestination = "kalender/img/calendar/" . $_FILES[img1][name]; move_uploaded_file($_FILES[img1][tmp_name], $imageDestination); } else $newfiles = $newfiles . $filenames[0] . ";"; if($_FILES[img2][name] != "") { $newfiles = $_FILES[img2][name] . ";"; echo "new file uploaded! newfiles is now $newfiles
\n"; $imageDestination = "kalender/img/calendar/" . $_FILES[img2][name]; move_uploaded_file($_FILES[img2][tmp_name], $imageDestination); } else $newfiles = $newfiles . $filenames[1] . ";"; if($_FILES[img3][name] != "") { $newfiles = $_FILES[img3][name] . ";"; echo "new file uploaded! newfiles is now $newfiles
\n"; $imageDestination = "kalender/img/calendar/" . $_FILES[img3][name]; move_uploaded_file($_FILES[img3][tmp_name], $imageDestination); } else $newfiles = $newfiles . $filenames[2] . ";"; // Check if a new banner got uploaded, if so, replace the current file with the new one by overwriting it, keeping the old filename if($_FILES[banner][name] != "") { $newbanner = $_FILES[banner][name]; $imageDestination = "kalender/img/banners/" . $newbanner; move_uploaded_file($_FILES[banner][tmp_name], $imageDestination); } else $newbanner = $line[banner]; // Build a new date $date = $_POST[year] . "-" . str_pad($_POST[month], 2, "0", STR_PAD_LEFT) . "-" . str_pad($_POST[date], 2, "0", STR_PAD_LEFT); // Build a new link list $newlinks = ""; if($_POST[lnk1] != "") $newlinks = $newlinks . $_POST[lnk1] . ";"; else $newlinks = $newlinks . $oldlinks[0] . ";"; if($_POST[lnk2] != "") $newlinks = $newlinks . $_POST[lnk2] . ";"; else $newlinks = $newlinks . $oldlinks[1] . ";"; $_POST[textbody] = filtratetext($_POST[textbody]); $_POST[subject] = filtratetext($_POST[subject]); $_POST[ingress] = filtratetext($_POST[ingress]); $query = "update calendar set date = '$date', rubrik = '$_POST[subject]', ingress = '$_POST[ingress]', kropp = '$_POST[textbody]', links = '$newlinks', images = '$newfiles', banner = '$newbanner' where id = '$_POST[update]'"; echo "query is: $query
\n"; mysql_query($query); } else // the event is a new one, store it in the database storeNewCalendarEvent(); } elseif($_GET[action] == "remcal" && $_GET[id] != "") { remcal($_GET[id]); $_GET[action] = "editkalender"; } elseif($_GET[action] == "banneradmin") { if(isset($_POST[updateprio])) { // Uppdatera prioriteringarna $query = "select id from calendar where banner != ''"; $result = mysql_query($query); while($line = mysql_fetch_array($result)) { $varname = "newpriofor" . $line[id]; mysql_query("update calendar set bannerprio = '$_POST[$varname]' where id = '$line[id]'"); } echo "Sparade ändringarna
\n"; } showBannerControls(); } elseif($_GET[action] == "editcal") { showCalendarInput(true); } // This is where the controls were printed before echo "Vad vill du göra?
\n"; echo "Lägg till kalenderhändelse
\n"; echo "Ta bort eller ändra en kalenderhändelse
\n"; echo "Hantera hur ofta/vilka banners som visas
\n"; echo "Skapa ett nyhetsbrev
\n"; echo "Ändra förstasidans nyheter
\n"; echo "

\n"; if($_GET[action] == "nykalender") { showCalendarInput(); } elseif($_GET[action] == "editkalender") { showCalendarEdit(); } elseif($_GET[action] == "editnews") { // check for any changes in the POST data insert these into the database if($_POST[id] != "") { // check if an image was uploaded, if so, update this value as well and move the picture accordingly. if($_FILES[newsimage][name] != "") { $imageDestination = "img/news/" . $_FILES[newsimage][name]; move_uploaded_file($_FILES[newsimage][tmp_name], $imageDestination); $query = "update news set text='$_POST[newstext]', img='$imageDestination' where id='$_POST[id]'"; } else $query = "update news set text='$_POST[newstext]' where id='$_POST[id]'"; mysql_query($query); } // Dra ut all data ur nyhetstabellen $query = "select * from news"; $result = mysql_query($query); /* echo "Hur många nyheter vill du ha?
\n"; echo "
\n"; echo "\n
\n"; echo "
\n"; */ // for each line of news, create a table to edit it, fill it with data from the database and show it. while($line = mysql_fetch_array($result)) { echo "
\n\n\n\n"; echo "\n\n"; echo "\n\n\n\n
\n
\n"; } } } function showBannerControls() { $query = "select id, date, rubrik, bannerprio from calendar where banner != '' and date > now()"; $result = mysql_query($query); echo "
\n"; echo "\n\n\n\n"; echo "\n\n\n\n\n"; while($line = mysql_fetch_array($result)) { echo "\n\n\n\n\n"; } echo "\n\n\n"; echo "
"; echo "These are the upcomming calendar events that have banners uploaded:
Datum:Rubrik:Prioritet:
$line[date]$line[rubrik]
\n"; } function remcal($id) { $query = "delete from calendar where id='$id' limit 1"; mysql_query($query); } function showlogin() { PHP?>
Den här sidan kräver att du verifierar dig med användarnamn och lösenord:
Användare:
Lösenord:
Dölj kalenderhändelser som redan varit
\n"; $query = "select * from calendar order by date asc"; } else { $_SESSION[showOld] = "no"; echo "Visa kalenderhändelser som redan varit
\n"; $query = 'select * from calendar where date > now() order by date asc'; } $result = mysql_query($query); echo "\n\n\n\n\n\n\n"; while($line = mysql_fetch_array($result)) { echo "\n\n\n\n\n\n"; } echo "
Datum:Namn:ändra:Ta bort
$line[date]$line[rubrik]ändrata bort
\n"; } function showCalendarInput($editmode = false) { echo "
"; if($editmode) { echo ""; $query = "select * from calendar where id='$_GET[id]'"; $result = mysql_query($query); $line = mysql_fetch_array($result); $editdate = explode("-", $line[date]); $edityear = $editdate[0]; $editmonth = $editdate[1]; $editday = $editdate[2]; $editlinks = explode(';', $line[links]); $editlink0 = $editlinks[0]; $editlink1 = $editlinks[1]; $editimages = explode(';', $line[images]); $editimage0 = $editimages[0]; $editimage1 = $editimages[1]; $editimage2 = $editimages[2]; } PHP?>
År:
Månad:
Datum:
Rubrik: >
Bildbankstext:
Text:
Länk 1: >
Länk 2: >
Bild 1: >
Bild 2: >
Bild 3: >
Banner: >
\n"; $images = ""; if($_FILES[img1][name] != "") { $imageDestination = "kalender/img/calendar/" . $_FILES[img1][name]; move_uploaded_file($_FILES[img1][tmp_name], $imageDestination); $images = $images . $_FILES[img1][name] . ";"; } else $images = $images . ";"; if($_FILES[img2][name] != "") { $imageDestination = "kalender/img/calendar/" . $_FILES[img2][name]; move_uploaded_file($_FILES[img2][tmp_name], $imageDestination); $images = $images . $_FILES[img2][name] . ";"; } else $images = $images . ";"; if($_FILES[img3][name] != "") { $imageDestination = "kalender/img/calendar/" . $_FILES[img3][name]; move_uploaded_file($_FILES[img3][tmp_name], $imageDestination); $images = $images . $_FILES[img3][name] . ";"; } else $images = $images . ";"; if($_FILES[banner][name] != "") { $imageDestination = "kalender/img/banners/" . $_FILES[banner][name]; move_uploaded_file($_FILES[banner][tmp_name], $imageDestination); $banner = $_FILES[banner][name]; } $_POST[ingress] = filtratetext($_POST[ingress]); $_POST[rubrik] = filtratetext($_POST[rubrik]); $_POST[textbody] = filtratetext($_POST[textbody]); $links = $_POST[lnk1] . ";" . $_POST[lnk2]; $date = $_POST[year] . "-" . str_pad($_POST[month], 2, "0", STR_PAD_LEFT) . "-" . str_pad($_POST[date], 2, "0", STR_PAD_LEFT); $query = "insert into calendar values('','$date','$_POST[subject]','$_POST[ingress]','$_POST[textbody]','$links','$images','$banner', 0)"; mysql_query($query); } PHP?>