<?php
echo '<h1 class="p_space">' . $lang['my_photos_galleries'] . '</h1>';
if($_SERVER['REQUEST_METHOD'] != 'POST') {
echo '<form action="" method="post" enctype="multipart/form-data">
<p><input type="text" name="title" class="textfields" required size="40" maxlength="70" required> ' . $lang['title'] . ' *</p>
<p><input type="text" name="description" class="textfields" required size="40" maxlength="70" required> ' . $lang['blank_description'] . ' *</p>
<input type="file" name="ifile" size="31" required>
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<br><br>
<input type="submit" name="upload" id="upload" value="' . $lang['upload_photos'] . '" class="buttons">
</form>';
echo '<p class="p_space"><span class="blue_span">Max. 1 MB - ' . $lang['only'] . 'JPEG/PNG - max. 1000 x 1000 px</span></p>';
echo '<img src="style/icons/arrow.png" border="0" alt="Info"> ' . $lang['pics_resized'] . '!';
echo '<div id="line"></div>';
echo '<img src="style/icons/arrow.png" border="0" alt="Info"> ' . $lang['pictures_save'] . '<br>
<div class="manage_zip"><a href="pack.php" onclick="return popup(this,800,500)"><img src="style/images/zip.png" vspace="5" border="0" alt="ZIP"></a></div>';
}else{
if(isset($_POST['upload'])) {
$id = (int)$_SESSION['id'];
if(!empty($_FILES['ifile']['tmp_name'])) {
include_once('framework/thumbnails/ThumbLib.inc.php');
if(!getimagesize($_FILES['ifile']['tmp_name'])) {
$errors[] = $lang['invalid_pic_format'];
}
$imgtype = array('1' => '.gif', '2' => '.jpg' , '3' => '.png');
list($width, $height, $type, $attr) = getimagesize($_FILES['ifile']['tmp_name']);
switch($type) {
case 1: $ext='.gif'; break;
case 2: $ext = '.jpg';break;
case 3: $ext='.png'; break;
}
if($ext == '.gif') {
$errors[] = $lang['only_format'];
}
if($width > 1000 || $height > 1000) {
$errors[] = $lang['max_mass_pics'];
}
if($_FILES['ifile']['size'] > 1000000 ) {
$errors[] = $lang['max_size_pics'];
}
if(!empty($errors)) {
echo '<p class="false">' . $lang['an_error_occurred'] . ' - <a href="javascript:history.back();" class="false_link">' . $lang['back'] . '</a></p>';
echo '<ul>';
foreach($errors as $key => $value) {
echo '<li>• ' . $value . '</li>';
}
echo '</ul>';
}else{
$uploaddir = 'uploads/photos/';
$secondname = rand(100,99);
include_once('framework/functions/encode.php');
if(!move_uploaded_file($_FILES['ifile']['tmp_name'], $uploadfile )) {
echo '<p class="false">' . $lang['picture_couldnot'] . '</p>';
}
$thumb = PhpThumbFactory::create($uploadfile);
$thumb->resize(230,154);
$thumb->save($uploadfile);
$sql = "INSERT INTO
photos(id2, title, tag, description, date)
VALUES ('" . $id . "',
'" . mysql_real_escape_string($_POST['title']) . "',
'" . mysql_real_escape_string($uploadfile) . "',
'" . mysql_real_escape_string($_POST['description']) . "',
NOW()
)";
$result = mysql_query($sql) OR die(mysql_error());
if(!$result) {
echo '<p class="false">' . $lang['picture_couldnot'] . '</p>';
}else{
echo '<p class="success">' . $lang['picture_success'] . '!</p>';
}
}
}
}else{
echo '<p class="false">' . $lang['choose_picture'] . ' - <a href="javascript:history.back();" class="false_link">' . $lang['back'] . '</a></p>';
}
}
?>