prv_tablename." WHERE `".$this->prv_id_field."`='".$id."';"; if (mysql_num_rows(mysql_query($getQuery))) { $result = @mysql_query($getQuery) or die(mysql_error()); $fields = @mysql_fetch_assoc($result) or die(mysql_error()); $classfields = array_keys($fields); for($i=0; $i$classfields[$i] = strip_tags($fields[$classfields[$i]],"

    • "); $this->$classfields[$i] = $fields[$classfields[$i]]; } } else Header ("Location: /"); } public function updateDB($id) { if (strlen($this->title)>3) $this->tid = totextid($this->title); else $this->tid = totextid((date("Y-m-d", strtotime($this->added)))."-".$this->intro); //$this->assign_type(); $classfields = array_keys(get_class_vars(get_class($this))); for($i=0; $i$classfields[$i])) { $str_fields.="`".$classfields[$i]."`="; $str_fields.="'".$this->$classfields[$i]."',"; } } $str_fields[strlen($str_fields)-1]=' '; $editQuery = "UPDATE ".$this->prv_tablename." SET ".$str_fields." WHERE ".$this->prv_id_field."='".$id."';"; @mysql_query($editQuery) or die(mysql_error()); $this->prv_id_announcement=$id; } public function deleteFromDB($id) { $deleteQuery = "DELETE FROM ".$this->prv_tablename." WHERE ".$this->prv_id_field." = ".$id.";"; @mysql_query($deleteQuery) or die("Błąd bazy danych"); } public function fromPOST() { $classfields = array_keys(get_class_vars(get_class($this))); for($i=0; $i$classfields[$i] = strip_tags($_POST[$classfields[$i]],"

        • "); $this->$classfields[$i] = $_POST[$classfields[$i]]; } } public function selected($field,$value) { if($this->$field==$value) return "selected='selected'"; else return ''; } public function checked($field,$value) { if($this->$field==$value) return "checked='checked'"; else return ''; } public function toDB() { date_default_timezone_set("Europe/Warsaw"); $classfields = array_keys(get_class_vars(get_class($this))); if (strlen($this->title)>3) $this->tid = totextid($this->title); else $this->tid = totextid((date("Y-m-d", strtotime($this->added)))."-".$this->intro); if (!$this->added) $this->added = date("Y-m-d H:i:s", time()); for($i=0; $i$classfields[$i])) { $str_fields.="`".$classfields[$i]."`,"; $str_values.="'".$this->$classfields[$i]."',"; } } $str_fields[strlen($str_fields)-1]=' '; $str_values[strlen($str_values)-1]=' '; $addQuery = "INSERT INTO ".$this->prv_tablename."(".$str_fields.") VALUES(".$str_values.");"; @mysql_query($addQuery) or die(mysql_error()); $this->prv_id_announcement=mysql_insert_id(); } } function image_resize2($zrodlo, $przeznaczenie, $new_x, $new_y) { $_error=array(); if ( !file_exists( $zrodlo) ) { $_error[] = "Brak pliku źródłowego."; } $_arr = getimagesize($zrodlo); if (!$_arr ){ $_error[] = "podany plik nie jest grafik±"; } if (count($_error) ) { return $_error; } $width = $_arr[0]; $height = $_arr[1]; $stosunek_x = $width /$new_x; $stosunek_y = $height/$new_y ; $stosunek = ( ($stosunek_x > $stosunek_y) ? $stosunek_x : $stosunek_y ); if($width < $new_x&&$height<$new_y) { $new_x = $width; $new_y = $height; } else { $new_x = ceil( $width / $stosunek ); $new_y = ceil( $height / $stosunek ); } $_typ_pliku = $_arr[2]; switch ($_typ_pliku){ case 1 : $_src_img=imagecreatefromGif($zrodlo); break; case 2: $_src_img=imagecreatefromJpeg($zrodlo); break; case 3: $_src_img=imagecreatefromPNG($zrodlo); break; default: $_error[] = "Nieprawidłowy format pliku"; return $_error; } $_dst_img=imagecreatetruecolor($new_x,$new_y); ImageCopyResampled ($_dst_img,$_src_img,0,0,0,0,$new_x,$new_y,ImageSX($_src_img),ImageSY($_src_img)); ImageJpeg($_dst_img,$przeznaczenie.'.jpg'); }//func //wyrugowywanie function totextid ($text) { $do_zamiany = array("ą", "Ą", "ś", "Ś", "ć", "Ć", "ę", "Ę", "ń", "Ń", "Ó", "ó", "Ł", "ł", "Ż", "ż", "Ź", "ź", "__"); $zmienione = array("a", "A", "s", "S", "c", "C", "e", "E", "n", "N", "O", "o", "L", "l", "Z", "z", "Z", "z", "_"); $text = str_replace($do_zamiany, $zmienione, $text); $len=strlen($text); for ($i=0;$i<$len;$i++) { $cc = ord(substr($text,$i)); if (!(($cc>=48 && $cc<=57) || ($cc>=65 && $cc<=90) || ($cc>=97 && $cc<=122))) $text[$i]="-"; } $text = strtolower ($text); return $text; } //------------------------------------------------------------------- function checkbox2db ($field) { global $_POST; if(!$_POST[$field]) $_POST[$field]=0; } ?>prv_tablename="pb_sites"; $this->prv_id_field="id"; } public function deletePhotos($id) { @mysql_query("DELETE FROM pb_photos WHERE sites_id='".$id."';"); } } ?>