Advertisement
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: |
<?php
include 'library/config.php';
include 'library/opendb.php';
require_once 'library/functions.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Afegir un nou Article</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" media="screen" href="../esportJudoManresa.css"/>
</head>
<body>
<div id="manresaesport7"><br/>
<h2 class="red">Zona d'administració del web esport7</h2><br/><br/>
<div id="manresa">
<?php
if(isset($_POST['submit']))
{ $title = $_POST['title'];
$detalls = $_POST['detalls'];
$content = $_POST['content'];
$categoriaID = $_POST['categoriaID'];
$peuFoto = $_POST['peuFoto'];
//make sure this directory is writable!
$path_thumbs = "/var/www/vhost/solucionsdigitals.com/home/html/webs/esport7/admine7/images/news/";
//the new width of the resized image, in pixels.
$img_thumb_width = 200; //
$extlimit = "yes"; //Limit allowed extensions? (no for all extensions allowed)
//List of allowed extensions if extlimit = yes
$limitedext = array(".gif",".jpg",".png",".jpeg",".bmp");
//the image -> variables
$file_type = $_FILES['vImage']['type'];
$file_name = $_FILES['vImage']['name'];
$file_size = $_FILES['vImage']['size'];
$file_tmp = $_FILES['vImage']['tmp_name'];
//check if you have selected a file.
if(!is_uploaded_file($file_tmp)){
echo "Cal escollir una imatge.";
exit(); //exit the script and don't process the rest of it!
}
//check the file's extension
$ext = strrchr($file_name,'.');
$ext = strtolower($ext);
// the file extension is not allowed!
if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
echo "No s'accepten aquestes imatge. Només jpg o gif. <br>--<a href=\"$_SERVER[PHP_SELF]\">back</a>";
exit();
}
//so, whats the file's extension?
$getExt = explode ('.', $file_name);
$file_ext = $getExt[count($getExt)-1];
//create a random file name
$rand_name = md5(time());
$rand_name= rand(0,999999999);
//the new width variable
$ThumbWidth = $img_thumb_width;
/////////////////////////////////
// CREATE THE THUMBNAIL //
////////////////////////////////
//keep image type
if($file_size){
if($file_type == "image/pjpeg" || $file_type == "image/jpeg"){
$new_img = imagecreatefromjpeg($file_tmp);
}elseif($file_type == "image/x-png" || $file_type == "image/png"){
$new_img = imagecreatefrompng($file_tmp);
}elseif($file_type == "image/gif"){
$new_img = imagecreatefromgif($file_tmp);
}
//list the width and height and keep the height ratio.
list($width, $height) = getimagesize($file_tmp);
//calculate the image ratio
$imgratio=$width/$height;
if ($imgratio>1){
$newwidth = $ThumbWidth;
$newheight = $ThumbWidth/$imgratio;
}else{
$newheight = $ThumbWidth;
$newwidth = $ThumbWidth*$imgratio;
}
//function for resize image.
if (function_exists(imagecreatetruecolor)){
$resized_img = imagecreatetruecolor($newwidth,$newheight);
}else{
die("No s'ha pogut penjar. Massa gran");
}
//the resizing is going on here!
imagecopyresized($resized_img, $new_img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
//finally, save the image
ImageJpeg ($resized_img,"$path_thumbs/$rand_name.$file_ext");
ImageDestroy ($resized_img);
ImageDestroy ($new_img);
echo "Ja hi ha la imatge al servidor.";
exit();
$newfilename = $rand_name.$file_ext;
//success message, redirect to main page.
$msg = urlencode("$title was uploaded! <a href=\"Resize.php\">Upload More?</a>");
header("Location: Resize.php?msg=$msg");
exit();
}else{
//if there is a message, display it
if(isset($_GET['msg']))
{
//but decode it first!
echo "<p>".urldecode($_GET['msg'])."</p>";
}
if(!get_magic_quotes_gpc())
{
$title = addslashes($title);
$detalls = addslashes($detalls);
$content = addslashes($content);
$categoriaID = addslashes($categoriaID);
$peuFoto = addslashes($peuFoto);
}
$query = "INSERT INTO news (title, detalls, content, categoriaID, image, peuFoto, date) VALUES ('$title', '$detalls', '$content', '$categoriaID', '$newfilename', '$peuFoto', NOW())";
mysql_query($query) or die('Error, ha fallat la consulta');
include 'library/closedb.php';
echo "<h4>Ja s'ha guardar l'article '$title'</h4>";
exit;
}
}
?>
<form action="cms-add.php" method="post" enctype="multipart/form-data">
<table width="700" border="0" cellpadding="2" cellspacing="1" class="box" align="center">
<tr>
<td width="100">Títol</td>
<td><input name="title" type="text" class="box" id="title"></td>
</tr>
<tr>
<td width="100">Breu presentació</td>
<td><textarea name="detalls" cols="50" rows="3" class="box" id="detalls"></textarea></td>
</tr>
<tr>
<td width="100">Continguts</td>
<td><textarea name="content" cols="50" rows="10" class="box" id="content"></textarea></td>
</tr>
<tr>
<td width="100">Seccio</td>
<td><textarea name="categoriaID" type="text" class="box" id="categoriaID"></textarea></td>
</tr>
<tr>
<td>Imatge</td>
<td><input type="file" name="vImage" /></td>
</tr>
<tr>
<td>Peu de foto</td>
<td><textarea name="peuFoto" cols="50" rows="3" class="box" id="peuFoto"></textarea></td>
</tr>
<tr>
<td colspan="2" align="right"><input name="submit" type="submit" class="box" id="save" value="- Guardar article -"><input name="btnCancel" type="button" id="btnCancel" value="- Cancel·la -" onClick="window.history.back();"></td>
</tr>
</table>
</form>
<p><a href="index.php" class="vermell">tornar a administració</a></p>
</div></div>
</body>
</html>
|
|
Loading Advertisement... |