Файл: public_html/inc/produkte.php
Строк: 82
<?php
class produkte extends db
{
public function home()
{
$this->pro = $this->query('SELECT id, titel, preis, erstellung, kategorie, preisart, unterkategorie, postleitzahl, stadt, bild FROM produkte ORDER by id DESC LIMIT 12');
while($this->po = $this->fetch_assoc($this->pro)){
$data[] = array(
"id" => $this->po["id"],
"titel" => substr($this->po["titel"],0,23) . '...',
"preis" => $this->po["preis"],
"erstellung" => $this->po["erstellung"],
"kategorie" => $this->po["kategorie"],
"preisart" => $this->po["preisart"],
"unterkategorie" => $this->po["unterkategorie"],
"postleitzahl" => $this->po["stadt"],
"bild" => $this->po["bild"],
"zufall" => mt_rand(1,2)
);
}
return $data;
}
public function topanzeigen()
{
$this->pro1 = $this->query('SELECT id, titel, preis, erstellung, kategorie, preisart, unterkategorie, postleitzahl, stadt, bild FROM produkte WHERE topanzeige = "1" AND statuscode = "1" ORDER by rand() LIMIT 12');
while($this->po2 = $this->fetch_assoc($this->pro1)){
$data1[] = array(
"id" => $this->po2["id"],
"titel" => $this->po2["titel"],
"preis" => $this->po2["preis"],
"erstellung" => $this->po2["erstellung"],
"kategorie" => $this->po2["kategorie"],
"preisart" => $this->po2["preisart"],
"unterkategorie" => $this->po2["unterkategorie"],
"postleitzahl" => $this->po2["stadt"],
"bild" => $this->po2["bild"],
"zufall" => mt_rand(1,2)
);
}
return $data1;
}
public function cat1()
{
//suche
if($_GET['id'] == 0){
$where = 'kategorie != "'.$id.'"';
}else{
if($_GET['id2'] == ''){ $id = $_GET['id']; $datar = 'kategorie'; }else{ $id = $_GET['id2']; $datar = 'unterkategorie'; }
$where = ''.$datar.' = "'.$id.'"';
}
if($_GET['sucheWo'] != ''){
if($_GET['umkreis'] != 0){
$sucheplz = htmlspecialchars($_GET['sucheWo']);
if(is_numeric($sucheplz)){
$_bon = 'geo_plz';
}else{
$_bon = 'geo_ort';
}
$umkreis = intval($_GET['umkreis']);
// Erdradius
$radius = 3959;
//->Suche->latundLon
$_dbSQL = mysql_query("SELECT geo_lg AS lon, geo_plz, geo_bg AS lat FROM geo WHERE ".htmlspecialchars($_bon)." = '".$sucheplz."' ");
$_dbRad = mysql_fetch_object($_dbSQL);
@mysql_free_result($_dbSQL);
$lon = $_dbRad->lon / 180 * M_PI;
$lat = $_dbRad->lat / 180 * M_PI;
//
$query_boot = "SELECT geo_plz AS plz, (
".$radius." * SQRT(2*(1-cos(RADIANS(geo_bg)) *
cos(".$lat.") * (sin(RADIANS(geo_lg)) *
sin(".$lon.") + cos(RADIANS(geo_lg)) *
cos(".$lon.")) - sin(RADIANS(geo_bg)) * sin(".$lat.")))) AS Distance
FROM geo WHERE
".$radius." * SQRT(2*(1-cos(RADIANS(geo_bg)) *
cos(".$lat.") * (sin(RADIANS(geo_lg)) *
sin(".$lon.") + cos(RADIANS(geo_lg)) *
cos(".$lon.")) - sin(RADIANS(geo_bg)) * sin(".$lat."))) <= ".$umkreis."
ORDER BY Distance
";
$_row = mysql_query($query_boot);
while( $_bing = mysql_fetch_assoc($_row) ){
$dataPackageString[] = $_bing['plz'];
}
$dataPush = join(',', $dataPackageString);
$dataPusher = str_replace(',', '|', $dataPush);
$myplz = $_dbRad->geo_plz;
$where1 = "and postleitzahl REGEXP '$dataPusher|$myplz'";
}
else
{
$where1 = 'and ( stadt LIKE "%'.$_GET['sucheWo'].'%" OR postleitzahl = "'.$_GET['sucheWo'].'")';
}
}
if($_GET['suche'] != 'z. B. Titel oder Anzeigennummer'){ if($_GET['suche'] != ''){ $where2 = 'and titel LIKE "%'.$_GET['suche'].'%"'; } }
if(empty($_GET['page']) or $_GET['page'] == 1){ $limit = '20'; }else{
$limit = $_GET['page']*20-20;
$limit = $limit . ', 20';
}
if(!empty($_GET['room'])){
$room = 'AND i_zimmer >= "'.intval($_GET['room']).'"';
}else{
$room = '';
}
if(!empty($_GET['flache'])){
$flach = 'AND i_flache >= "'.intval($_GET['flache']).'"';
}else{
$flach = '';
}
if(!empty($_GET['price'])){
$endprice = 'AND preis <= "'.intval($_GET['price']).'"';
}else{
$endprice = '';
}
if(!empty($_GET['pricestart'])){
$startprice = 'AND preis >= "'.intval($_GET['pricestart']).'"';
}else{
$startprice = '';
}
if(!empty($_GET['zulassung'])){
$zulassung = 'AND a_zulassung <= "'.intval($_GET['zulassung']).'"';
}else{
$zulassung = '';
}
if(!empty($_GET['kilometer'])){
$kilometer = 'AND a_kilometer >= "'.$_GET['kilometer'].'"';
}else{
$kilometer = '';
}
if(!empty($_GET['kraftstoff'])){
$kraftstoff = 'AND a_kraftstoff LIKE "%'.$_GET['kraftstoff'].'%"';
}else{
$kraftstoff = '';
}
if(!empty($_GET['id3'])){
$idset3 = 'AND unterkategorie2 = "'.intval($_GET['id3']).'"';
}else{
$idset3 = '';
}
$this->pro = $this->query('
SELECT Sub.*
FROM ( SELECT * FROM
produkte
WHERE '.$where.' '.$where1.' '.$where2.' AND statuscode = "1"
'.$room.' '.$flach.' '.$startprice.' '.$endprice.'
'.$zulassung.' '.$kilometer.' '.$kraftstoff.' '.$idset3.'
ORDER by postleitzahl, erstellung DESC
) AS Sub
ORDER BY Sub.ad_highlight_time DESC
LIMIT ' . $limit . '
');
while($this->po = $this->fetch_assoc($this->pro)){
$data[] = $this->po;
}
return $data;
}
}
?>