witam,
mam taki kod:
<?php
class miniaturka {
var $ustawienia;
Function miniaturka(){
$this->ustawienia['source']='';
$this->ustawienia['max_x']='';
$this->ustawienia['max_y']='';
$this->ustawienia['save_image']='';
$this->ustawienia['jpeg_quality']=85;
}
function ustawienia($nazwa,$wartosc,$pobiez=0){
if($pobiez){
return $this->ustawienia[$nazwa];
}else{
$this->ustawienia[$nazwa]=$wartosc;
}
}
function obrazek_typ($name) {
if($roz == '.jpg' || $roz == 'jpeg' || $roz == '.jpe') {
return "jpg";
}
elseif($roz == '.gif') {
return "gif";
}
elseif($roz == '.png') {
return "png";
}
}
function tworz() {
$source=$this->ustawienia['source'];
$max_x=$this->ustawienia['max_x'];
$max_y=$this->ustawienia['max_y'];
$save_image=$this->ustawienia['save_image'];
$jpeg_quality=$this->ustawienia['jpeg_quality'];
$roz=$this->obrazek_typ($source);
if ($roz == "jpg") {
$img_src = imagecreatefromjpeg($source);
}
else if ($roz == "gif") {
$img_src = imagecreatefromgif($source);
}
else if ($roz == "png") {
$img_src = imagecreatefrompng($source);
}
else {
return false;
}
$image_x = imagesx($img_src);
$image_y = imagesy($img_src);
if($image_x > $image_y) {
$ratio_x = ($image_x > $max_x) ? $max_x/$image_x : 1;
$ratio_y = $ratio_x;
$move = 'y';
}
else {
$ratio_y = ($image_y > $max_y) ? $max_y/$image_y : 1;
$ratio_x = $ratio_y;
$move = 'x';
}
$new_x = $image_x*$ratio_x;
$new_y = $image_y*$ratio_y;
$new_img = imagecreatetruecolor($new_x, $new_y);
imagecopyresampled($new_img, $img_src, 0, 0, 0, 0, $new_x, $new_y, $image_x, $image_y);
$roz2=$this->obrazek_typ($save_image);
if($roz2 == "jpg") {
imagejpeg($new_img, $save_image, $jpeg_quality);
}
else if ($roz2 == "gif") {
imagegif($new_img, $save_image);
}
else if ($roz2 == "png") {
imagepng($new_img, $save_image);
}
return array('x'=>$image_x,'y'=>$image_y,'roz'=>$roz,'roz2'=>$roz); //return true;
}
}
if ( empty($_POST['file']) ) { if($_COOKIE['dodajnowyfilm']){
echo '<p>Następny film możesz dodać dopiero po 5 min</p>';
}else{
echo '<form action="" method="post" enctype="multipart/form-data" style="padding-left:10px;"><table style="width: 100%"> <tr><td>Nazwa</td><td><input type="text" name="nazwa" value="' . $rekord['nazwa'] . '" /></td></tr>
<tr><td>Kategoria</td><td><select name="cat">';
{
if ( $rekord['cat'] == $cat['id'] ) echo '<option value="' . $cat['id'] . '" selected="selected">' . $cat['name'] . '</option>'; else echo '<option value="' . $cat['id'] . '">' . $cat['name'] . '</option>'; }
$si = $rekord['typ'] == 'img' ? 'selected="selected"' : '';
$sf = $rekord['typ'] == 'flash' ? 'selected="selected"' : '';
$sm = $rekord['typ'] == 'movie' ? 'selected="selected"' : '';
$s3 = $rekord['typ'] == 'mp3' ? 'selected="selected"' : ' ';
echo '</select></td></tr> <tr><td>Screen(jpg,png,gif)</td><td><input type="file" name="plik" value=" " /></td></tr>
<tr><td>Opis</td><td><textarea name="opis" rows="7" cols="40">' . $rekord['opis'] . '</textarea></td></tr>
<tr><td></td><td><input type="hidden" name="id" value="' . $rekord['id'] . '" /><input type="submit" name="dodaj_nowy_film" value="Zapisz" /></td></tr>
</table></form>';
echo '<span class="ltitle4"> <span style="color: red">*</span> Wpis zostanie dodany po akceptacj moderatora.</div>';
}
} elseif(!$_COOKIE['dodajnowyfilm']){
$miniaturka = new miniaturka();
$roz=$miniaturka->obrazek_typ($_FILES['plik']['name']);
if($roz=='jpg' or $roz=='gif' or $roz=='png'){
$tmp='/home/kreskowki/domains/kreskowki/public_html/miniaturki/'.$t.'__.'.$roz;
$screen='/home/kreskowki/domains/kreskowki/public_html/miniaturki/'.$t.'.'.$roz;
$miniaturka->ustawienia('source',$tmp);
$miniaturka->ustawienia('save_image',$screen);
$screen='http://adres.www/miniaturki/'.$t.'.'.$roz;
$miniaturka->ustawienia('max_x','190');
$miniaturka->ustawienia('max_y','97');
$miniaturka->tworz();
}else{
$screen='';
}
mysql_query("INSERT INTO `zglo` (`id`, `cat`, `nazwa`, `typ`, `screen`, `file`, `data`, `opis`, `width`, `he
ight`, `user_id`) VALUES ('', '" . intval($_POST['cat']) . "', '" . trim(htmlspecialchars(stripslashes($_POST['nazwa']))) . "', 'movie', '".$screen."', '" . stripslashes($_POST['file']) . "', '" . date("d.m.Y") . "', '" . trim(htmlspecialchars(stripslashes($_POST['opis']))) . "', '190', '97', '" . $_COOKIE['id_user'] . "');");
echo '<p style="text-align: center"><span class="ltitle4">Wpis został zgłoszony. Zostanie dodany po akceptacj przez moderatora<p style="text-align: center">';
}
?>
i gdy dodam plik pokazuje mi zawsze czysta strone z napisem 403 :/
zapytanie do bazy jest dobre, chmod'y poustawiane