<?php require_once('../Connections/web3.php'); ?>
<?php
session_start();
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup, $Variabel) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers) && $_SESSION[place] == $Variabel) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups) && $_SESSION[place] == $Variabel) {
$isValid = true;
}
if (($strUsers == "") && true && $_SESSION[place] == $Variabel) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "login.php";
mysql_select_db($database_dk, $dinside_dk);
$query_rsSite = sprintf("SELECT sitenavn FROM web3_info WHERE id = 1");
$rsSite = mysql_query($query_rsSite, $dinside_dk) or die(mysql_error());
$row_rsSite = mysql_fetch_assoc($rsSite);
$totalRows_rsSite = mysql_num_rows($rsSite);
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'], $row_rsSite['sitenavn'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
$forward = $_GET['forward'];
if (!$forward){
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Upload produktbilled</title>
<link href="../elements.css" rel="stylesheet" type="text/css">
</head>
<body background="../pics/body_bg.jpg">
<table cellpadding="0" cellspacing="0" width="90%" align="center">
<tr>
<td height="15"></td>
</tr>
<tr>
<td class="box_headline" colspan="2">Administrationsområde for <?php echo $row_rsSite['sitenavn']; ?></td>
</tr>
<tr>
<td class="box_content" width="15%" style="vertical-align:top;">Upload produktbillede<br>
<br>
<a href="index.php" class="a1">Til admin-forside</a></td>
<td class="admin_content">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top">
Upload produktbillede<br><br>
</td>
</tr>
<tr style="font-size:11px;">
<td>
For at optimere din hjemmeside anbefales det, at du sørger for, at billedet har en bredde på 300 pixels, inden du uploader det. Størrelsen kan eksempelvis ændres ved at åbne billedet i paint og trykke 'ctrl + w'. Desuden må billedet maksimalt fylde 2MB.<br><br>
<p style="font-style:italic;"><strong>
<?php
}
$vareid = $_GET['vareid'];
$navnpre = $_FILES['filnavn']['name'];
$navn = preg_replace("/[^a-zA-Z0-9-_!&.,]/", " ", $navnpre);
if($navn && !preg_match("/.jpg$|.gif$|.JPG$|.JPEG$|.bmp$/i", $navn)){
exit("Filen skal være af type 'jpg', 'gif' eller 'bmp'.");
}
if (isset($_FILES['filnavn']) && $navn != '') {
if ($vareid != NULL) {
$query = "UPDATE web3_varer SET billede = '".$navn."' WHERE id = ".$vareid."";
}
$Result1 = mysql_query($query, $dinside_dk) or die(mysql_error());
$tempfile = $_FILES['filnavn']['tmp_name'];
$destination = "../pics/{$navn}";
copy($tempfile, $destination);
if($forward){
header("Location: admin_edit_products.php?vareid=".$vareid);
exit;
}
}
?>