conectare = mysql_connect("localhost", "simelco", "12sim") or die(mysql_error()); mysql_select_db("simelco", $this->conectare) or die(mysql_error()); } function confirma_user_pass($user, $pass) { $q = "SELECT pass FROM admin WHERE user='$user'"; $rezultat = mysql_query($q, $this->conectare) or die (mysql_error()); if(!$rezultat || (mysql_num_rows($rezultat) < 1)) return 1; $tablou_pass_gasita = mysql_fetch_array($rezultat); if($pass == $tablou_pass_gasita['pass']) return 0; else return 2; } function adauga_anunt($subimobil, $subtranzactie, $subanuntul, $subpretul, $subzona, $subpoza1, $subpoza2, $subpoza3, $subpoza4, $subpoza5, $subpoza6) { $q = "INSERT INTO anunturi SET imobil='$subimobil',tranzactie='$subtranzactie',anunt='$subanuntul',pret='$subpretul',zona='$subzona',poza1='$subpoza1',poza2='$subpoza2',poza3='$subpoza3',poza4='$subpoza4',poza5='$subpoza5',poza6='$subpoza6',data=CURDATE()"; $rezultat = mysql_query($q, $this->conectare) or die(mysql_error()); return $rezultat; } function sterge_anunt_admin($subID_anunt_sters) { $ID = $_POST['ID_anunt_sters']; $q = "SELECT ID FROM anunturi WHERE ID='$ID'"; $rezultat = mysql_query($q, $this->conectare); if(!$rezultat || (mysql_num_rows($rezultat) < 1)) return 2; $tablou_ID_gasit = mysql_fetch_array($rezultat); if($ID == $tablou_ID_gasit['ID']) { $q = "SELECT poza1,poza2,poza3,poza4,poza5,poza6 FROM anunturi WHERE ID='$ID'"; $rezultat = mysql_query($q, $this->conectare); $tablou_poza_gasit = mysql_fetch_array($rezultat); for($i=1; $i<=6; $i++) { $poza = $tablou_poza_gasit['poza' . $i]; if($poza != 0) { $file = "foto/" . $ID . "_" . $i . ".jpg"; if (file_exists($file)) { unlink('foto/' . $ID . '_' . $i . '.jpg'); } } } $q1 = "DELETE FROM anunturi WHERE ID='$ID'"; $rezultat1 = mysql_query($q1, $this->conectare); if(!$rezultat1) return 1; } else return 0; } function cauta_anunt_admin($sub_ID_anunt_cautat) { $ID = $_POST['ID_anunt_cautat']; $q = "SELECT * FROM anunturi WHERE ID='$ID'"; $rezultat = mysql_query($q, $this->conectare); if(!$rezultat || (mysql_num_rows($rezultat) < 1)) return 1; else { $tablou_anunt_cautat = mysql_fetch_array($rezultat); $_SESSION['ID_anunt_cautat'] = $tablou_anunt_cautat['ID']; $_SESSION['imobil_anunt_cautat'] = $tablou_anunt_cautat['imobil']; $_SESSION['tranzactie_anunt_cautat'] = $tablou_anunt_cautat['tranzactie']; $_SESSION['pret_anunt_cautat'] = $tablou_anunt_cautat['pret']; $_SESSION['zona_anunt_cautat'] = $tablou_anunt_cautat['zona']; $_SESSION['anunt_anunt_cautat'] = $tablou_anunt_cautat['anunt']; return 0; } } function modifica_anunt_admin($sub_modifica_anunt_imobil, $sub_modifica_anunt_tranzactie, $sub_modifica_anunt_anuntul, $sub_modifica_anunt_pretul, $sub_modifica_anunt_zona) { $ID = $_SESSION['ID_anunt_cautat']; $q = "UPDATE anunturi SET imobil='$sub_modifica_anunt_imobil',tranzactie='$sub_modifica_anunt_tranzactie',anunt='$sub_modifica_anunt_anuntul',pret='$sub_modifica_anunt_pretul',zona='$sub_modifica_anunt_zona' WHERE ID='$ID'"; $rezultat = mysql_query($q, $this->conectare) or die(mysql_error()); return $rezultat; } function add_user($sub_ad_user, $sub_ad_pass) { $q1 = "SELECT user FROM admin WHERE user='$sub_ad_user'"; $rezultat1 = mysql_query($q1, $this->conectare) or die (mysql_error()); if(!$rezultat1 || (mysql_num_rows($rezultat1) < 1)) { $q = "INSERT INTO admin SET user='$sub_ad_user',pass='$sub_ad_pass'"; $rezultat = mysql_query($q, $this->conectare) or die (mysql_error()); return 0; } else { $tablou_user_gasit = mysql_fetch_array($rezultat1); if($sub_ad_user == $tablou_user_gasit['user']) return 1; } } function sterge_user($sub_user_de_sters) { $q1 = "SELECT user FROM admin WHERE user='$sub_user_de_sters'"; $rezultat1 = mysql_query($q1, $this->conectare) or die (mysql_error()); if(!$rezultat1 || (mysql_num_rows($rezultat1) < 1)) { $tablou_user_de_sters_gasit = mysql_fetch_array($rezultat1); if($sub_user_de_sters != $tablou_user_de_sters_gasit['user']) return 1; } else { $q = "DELETE FROM admin WHERE user='$sub_user_de_sters'"; $rezultat = mysql_query($q, $this->conectare) or die (mysql_error()); return 0; } } function schimba_pass($sub_schimba_pass_nou) { $user = $_SESSION['user']; $q = "UPDATE admin SET pass='$sub_schimba_pass_nou' WHERE user='$user'"; return mysql_query($q, $this->conectare) or die(mysql_error()); } function total_anunturi() { $q = "SELECT * FROM anunturi"; $rezultat = mysql_query($q, $this->conectare); $this->numar_anunturi = mysql_num_rows($rezultat); return $this->numar_anunturi; } function vanzari() { $q = "SELECT * FROM anunturi WHERE tranzactie=1"; $rezultat = mysql_query($q, $this->conectare); $this->vanzari = mysql_num_rows($rezultat); return $this->vanzari; } function vanzari_garsoniere() { $q = "SELECT * FROM anunturi WHERE tranzactie=1 AND imobil=1"; $rezultat = mysql_query($q, $this->conectare); $this->vanzari_garsoniere = mysql_num_rows($rezultat); return $this->vanzari_garsoniere; } function vanzari_1camera() { $q = "SELECT * FROM anunturi WHERE tranzactie=1 AND imobil=2"; $rezultat = mysql_query($q, $this->conectare); $this->vanzari_1camera = mysql_num_rows($rezultat); return $this->vanzari_1camera; } function vanzari_2camere() { $q = "SELECT * FROM anunturi WHERE tranzactie=1 AND imobil=3"; $rezultat = mysql_query($q, $this->conectare); $this->vanzari_2camere = mysql_num_rows($rezultat); return $this->vanzari_2camere; } function vanzari_3camere() { $q = "SELECT * FROM anunturi WHERE tranzactie=1 AND imobil=4"; $rezultat = mysql_query($q, $this->conectare); $this->vanzari_3camere = mysql_num_rows($rezultat); return $this->vanzari_3camere; } function vanzari_4camere() { $q = "SELECT * FROM anunturi WHERE tranzactie=1 AND imobil=5"; $rezultat = mysql_query($q, $this->conectare); $this->vanzari_4camere = mysql_num_rows($rezultat); return $this->vanzari_4camere; } function vanzari_case() { $q = "SELECT * FROM anunturi WHERE tranzactie=1 AND imobil=6"; $rezultat = mysql_query($q, $this->conectare); $this->vanzari_case = mysql_num_rows($rezultat); return $this->vanzari_case; } function vanzari_vile() { $q = "SELECT * FROM anunturi WHERE tranzactie=1 AND imobil=7"; $rezultat = mysql_query($q, $this->conectare); $this->vanzari_vile = mysql_num_rows($rezultat); return $this->vanzari_vile; } function vanzari_teren_intravilan() { $q = "SELECT * FROM anunturi WHERE tranzactie=1 AND imobil=8"; $rezultat = mysql_query($q, $this->conectare); $this->vanzari_teren_intravilan = mysql_num_rows($rezultat); return $this->vanzari_teren_intravilan; } function vanzari_teren_extravilan() { $q = "SELECT * FROM anunturi WHERE tranzactie=1 AND imobil=9"; $rezultat = mysql_query($q, $this->conectare); $this->vanzari_teren_extravilan = mysql_num_rows($rezultat); return $this->vanzari_teren_extravilan; } function vanzari_spatii_comerciale() { $q = "SELECT * FROM anunturi WHERE tranzactie=1 AND imobil=10"; $rezultat = mysql_query($q, $this->conectare); $this->vanzari_spatii_comerciale = mysql_num_rows($rezultat); return $this->vanzari_spatii_comerciale; } function vanzari_birouri() { $q = "SELECT * FROM anunturi WHERE tranzactie=1 AND imobil=11"; $rezultat = mysql_query($q, $this->conectare); $this->vanzari_birouri = mysql_num_rows($rezultat); return $this->vanzari_birouri; } function vanzari_spatii_industriale() { $q = "SELECT * FROM anunturi WHERE tranzactie=1 AND imobil=12"; $rezultat = mysql_query($q, $this->conectare); $this->vanzari_spatii_industriale = mysql_num_rows($rezultat); return $this->vanzari_spatii_industriale; } //*************************************************************************************** function inchirieri() { $q = "SELECT * FROM anunturi WHERE tranzactie=2"; $rezultat = mysql_query($q, $this->conectare); $this->inchirieri = mysql_num_rows($rezultat); return $this->inchirieri; } function inchirieri_garsoniere() { $q = "SELECT * FROM anunturi WHERE tranzactie=2 AND imobil=1"; $rezultat = mysql_query($q, $this->conectare); $this->inchirieri_garsoniere = mysql_num_rows($rezultat); return $this->inchirieri_garsoniere; } function inchirieri_1camera() { $q = "SELECT * FROM anunturi WHERE tranzactie=2 AND imobil=2"; $rezultat = mysql_query($q, $this->conectare); $this->inchirieri_1camera = mysql_num_rows($rezultat); return $this->inchirieri_1camera; } function inchirieri_2camere() { $q = "SELECT * FROM anunturi WHERE tranzactie=2 AND imobil=3"; $rezultat = mysql_query($q, $this->conectare); $this->inchirieri_2camere = mysql_num_rows($rezultat); return $this->inchirieri_2camere; } function inchirieri_3camere() { $q = "SELECT * FROM anunturi WHERE tranzactie=2 AND imobil=4"; $rezultat = mysql_query($q, $this->conectare); $this->inchirieri_3camere = mysql_num_rows($rezultat); return $this->inchirieri_3camere; } function inchirieri_4camere() { $q = "SELECT * FROM anunturi WHERE tranzactie=2 AND imobil=5"; $rezultat = mysql_query($q, $this->conectare); $this->inchirieri_4camere = mysql_num_rows($rezultat); return $this->inchirieri_4camere; } function inchirieri_case() { $q = "SELECT * FROM anunturi WHERE tranzactie=2 AND imobil=6"; $rezultat = mysql_query($q, $this->conectare); $this->inchirieri_case = mysql_num_rows($rezultat); return $this->inchirieri_case; } function inchirieri_vile() { $q = "SELECT * FROM anunturi WHERE tranzactie=2 AND imobil=7"; $rezultat = mysql_query($q, $this->conectare); $this->inchirieri_vile = mysql_num_rows($rezultat); return $this->inchirieri_vile; } function inchirieri_teren_intravilan() { $q = "SELECT * FROM anunturi WHERE tranzactie=2 AND imobil=8"; $rezultat = mysql_query($q, $this->conectare); $this->inchirieri_teren_intravilan = mysql_num_rows($rezultat); return $this->inchirieri_teren_intravilan; } function inchirieri_teren_extravilan() { $q = "SELECT * FROM anunturi WHERE tranzactie=2 AND imobil=9"; $rezultat = mysql_query($q, $this->conectare); $this->inchirieri_teren_extravilan = mysql_num_rows($rezultat); return $this->inchirieri_teren_extravilan; } function inchirieri_spatii_comerciale() { $q = "SELECT * FROM anunturi WHERE tranzactie=2 AND imobil=10"; $rezultat = mysql_query($q, $this->conectare); $this->inchirieri_spatii_comerciale = mysql_num_rows($rezultat); return $this->inchirieri_spatii_comerciale; } function inchirieri_birouri() { $q = "SELECT * FROM anunturi WHERE tranzactie=2 AND imobil=11"; $rezultat = mysql_query($q, $this->conectare); $this->inchirieri_birouri = mysql_num_rows($rezultat); return $this->inchirieri_birouri; } function inchirieri_spatii_industriale() { $q = "SELECT * FROM anunturi WHERE tranzactie=2 AND imobil=12"; $rezultat = mysql_query($q, $this->conectare); $this->inchirieri_spatii_industriale = mysql_num_rows($rezultat); return $this->inchirieri_spatii_industriale; } function inchirieri_regim_hotelier() { $q = "SELECT * FROM anunturi WHERE tranzactie=2 AND imobil=13"; $rezultat = mysql_query($q, $this->conectare); $this->inchirieri_regim_hotelier = mysql_num_rows($rezultat); return $this->inchirieri_regim_hotelier; } function useri() { $q = "SELECT * FROM admin"; $rezultat = mysql_query($q, $this->conectare); $this->useri = mysql_num_rows($rezultat); return $this->useri; } }; $database = new MySQLDB; ?>