Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $continue = '';
- $sessiontekst = md5(date("d-m-Y"));
- $sessionname = "Secure";
- if(!isset($_SESSION[$sessionname]) or $_SESSION[$sessionname] != $sessiontekst)
- {
- $continue = 'Please log in to access this page';
- }
- if($continue == '') {
- include("config.inc.php");
- include("list.inc.php");
- if($_POST['submit'] == "Submit") {
- // List of our known photo types
- $known_photo_types = array(
- 'image/pjpeg' => 'jpg',
- 'image/jpeg' => 'jpg',
- 'image/gif' => 'gif',
- 'image/bmp' => 'bmp',
- 'image/x-png' => 'png'
- );
- // GD Function List
- $gd_function_suffix = array(
- 'image/pjpeg' => 'JPEG',
- 'image/jpeg' => 'JPEG',
- 'image/gif' => 'GIF',
- 'image/bmp' => 'WBMP',
- 'image/x-png' => 'PNG'
- );
- // Fetch the cover
- $cover = $_FILES['cover'];
- if($cover['size'] > 0)
- {
- if(!array_key_exists($cover['type'], $known_photo_types))
- {
- $result_final .= "File is not a photo<br />";
- }
- else
- {
- mysql_query( "INSERT INTO albums(`title`, `type`, `size`, `artist`, `year`, `persing`, `quality`, `colour`, `code`, `label`, `amount`, `comments`, `cover`) VALUES('".$_POST['title']."', '".$_POST['type']."', '".$_POST['size']."', '".$_POST['artist']."', '".$_POST['year']."', '".$_POST['persing']."', '".$_POST['quality']."', '".$_POST['colour']."', '".$_POST['code']."', '".$_POST['label']."', '".$_POST['comments']."', '0')" );
- $new_id = mysql_insert_id();
- $filetype = $cover['type'];
- $extention = $known_photo_types[$filetype];
- $filename = $new_id.".".$extention;
- mysql_query( "UPDATE albums SET cover='".addslashes($filename)."' WHERE id='".addslashes($new_id)."'" );
- // Store the orignal file
- copy($photos_uploaded['tmp_name'], $images_dir."/".$filename);
- // Let's get the Thumbnail size
- $size = getimagesize( $images_dir."/".$filename );
- if($size[0] > $size[1])
- {
- $thumbnail_width = 150;
- $thumbnail_height = (int)(150 * $size[1] / $size[0]);
- }
- else
- {
- $thumbnail_width = (int)(150 * $size[0] / $size[1]);
- $thumbnail_height = 150;
- }
- // Build Thumbnail with GD 1.x.x, you can use the other described methods too
- $function_suffix = $gd_function_suffix[$filetype];
- $function_to_read = "ImageCreateFrom".$function_suffix;
- $function_to_write = "Image".$function_suffix;
- // Read the source file
- $source_handle = $function_to_read ( $images_dir."/".$filename );
- if($source_handle)
- {
- // Let's create an blank image for the thumbnail
- $destination_handle = imagecreatetruecolor($thumbnail_width, $thumbnail_height);
- // Now we resize it
- imagecopyresampled( $destination_handle, $source_handle, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $size[0], $size[1] );
- }
- // Let's save the thumbnail
- $function_to_write( $destination_handle, $images_dir."/tb_".$filename );
- //
- echo "Album is added.";
- }
- }
- }
- else {
- ?>
- <form id="addalbum" method="post">
- <select name="artist">
- <option disabled="true" selected="true">Artist</option>
- <?php echo $artist; ?></select><br>
- <input type="text" name="title" placeholder="Title"><br>
- <select name="type">
- <option disabled="true" selected="true">Type</option>
- <?php echo $type; ?></select><br>
- <select name="size">
- <option disabled="true" selected="true">Size</option>
- <?php echo $size; ?></select><br>
- <select name="year">
- <option disabled="true" selected="true">Year</option>
- <?php echo $year; ?></select><br>
- <input type="text" name="pressing" placeholder="Pressing"><br>
- <select name="quality">
- <option disabled="true" selected="true">Quality</option>
- <?php echo $quality; ?></select><br>
- <select name="colour">
- <option disabled="true" selected="true">Colour</option>
- <?php echo $colour; ?></select><br>
- <input type="text" name="code" placeholder="Code"><br>
- <select name="label">
- <option disabled="true" selected="true">Label</option>
- <?php echo $label; ?></select><br>
- <select name="amount">
- <option disabled="true" selected="true">Amount</option>
- <?php echo $amount; ?></select><br>
- <textarea name="comments" placeholder="Comments">
- </textarea><br>
- <input type="file" name="cover"><br>
- <input type="submit" name="submit" value="Submit">
- </form>
- <?php
- }
- }
- else {
- echo $continue;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment