$tytul"; } else if($img==6){ return "$tytul"; } else if($img==5){ return "albumik.php,alb_id,$id,rozmiar,".safe($anps).",".safe(substr($tytul,0,60)).",".safe($wyk); } else if($img==4){ return ""; }else if($img==3){ //bialy, np w nowosciach return "$tytul"; } else if($img==2){ //jak nie ma okladki return "$tytul"; } else if($img==1){ //jak jest okladka return ""; } else if($img==8){ return "albumik.php,alb_id,$id,".safe(substr($tytul,0,60)).",".safe($wyk); } else { //pogrubiony np w boxie promocje return "$tytul"; } } function gatunki_link($gatunki){ $i=0; $out = ""; foreach($gatunki as $ng) { $i++; $out .= "$ng[name_en]"; if($i != count($gatunki)) $out .= "/ "; } return $out; } function wykonawcy($wyk,$link=0){ $i=0; $out = ""; foreach($wyk as $w){ $i++; if($link=='1'){ $out .= "".$w['name'].""; } else if($link=='2'){ $out .= "$w[name]
"; } else if($link=='3'){ $out .= "".$w['name'].""; } else { $out .= $w['name']; } if($i != count($wyk) and $link!='2') $out .= "/ "; } return $out; } function koszyk_link($id_nosnika,$id_albumu,$ticket,$id=0){ global $db; $istnieje = $db->selectCell("select a.id_albumu from albumy a left join albumy_nosniki an on a.id_albumu=an.id_albumu where a.aktywny='T' and an.aktywny='T' and a.id_albumu='$id_albumu' and an.id_nosnika='$id_nosnika'"); if(!$istnieje){ return "wyprzedany"; } if($id==0){ return makelink("do koszyka"); } else if($id==1){ return makelink(""); } } function getmicrotime(){ list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } function wytwornia_link($wytwornia){ $out = ''; if($wytwornia['nazwa'] != '') { if($wytwornia['www_ofic'] != '') { $out = "".$wytwornia['nazwa'].""; } elseif($wytwornia['www'] != '') { $out = "".$wytwornia['nazwa'].""; } else { $out = "".$wytwornia['nazwa'].""; } $out .= ","; } return $out; } $starttime = getmicrotime(); function daj_ip() { $ip_proxy='brak';$ip_hosta='brak'; if (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])){ $ip_hosta = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else { $ip_hosta = $_SERVER["REMOTE_ADDR"]; } $ip = $ip_hosta; return $ip; } function get_perf($alb_id){ global $db; $wyks = $db->selectTable("select p.name from albumy_perf ap left join performers p on ap.id_perf=p.id where id_albumu='$alb_id'"); $w = array(); foreach($wyks as $wyk){ $w[] = $wyk['name'];} return implode(" & ",$w); } function get_access_code() { global $db; $kod = ""; while($kod == "") { for($i=0;$i<8;$i++) { $lc = mt_rand(0,1); if($lc == 0) $znak = chr(mt_rand(65,90)); if($lc == 1) $znak = mt_rand(0,9); $kod.=$znak; } $ile = $db->selectCell("select count(*) from transactions where access_code = '$kod'"); if($ile > 0) $kod = ""; } // wend return $kod; } function send_mail($fromname,$fromaddr,$toname,$toaddr,$subject,$tekst,$tplfile='') { include("func/smtp.php"); $boundary = md5(time()); $content = $tekst; $headers = array( "From: $fromname <$fromaddr>", "To: $toname <$toaddr>", "Subject: $subject", 'Date: '.date("r"), 'X-Mailser: Serpent Mailer', 'Sender-IP: '.$_SERVER["REMOTE_ADDR"], "MIME-Version: 1.0", // "Content-type: multipart/mixed; boundary=\"$boundary\"", // "Content-Transfer-Encoding: 7bit", // "--$boundary", "Content-Type: text/html; charset=iso-8859-2", "Content-Transfer-Encoding: 8bit", //$content // "--$boundary--" ); $params['host'] = 'localhost'; $params['port'] = 25; $params['helo'] = 'mail.serpent.pl'; $params['auth'] = TRUE; $params['user'] = 'sklep@serpent.pl'; $params['pass'] = 'heyhol'; $mail = new Smtp($params); $mail->headers = $headers; $mail->recipients = array($toaddr); $mail->from = 'sklep@serpent.pl'; //$mail->helo = $SET_shop_ip; $mail->body = $content; $mail->connect(); $mail->send(); if(count($mail->errors) > 1) trigger_error("Niepowodzenie przy wysy�aniu emaila: ".join(" ",$mail->errors),256); } function skroc($co,$doilu) { if(strlen($co) > $doilu) { $skrocone = trim(substr($co,0,$doilu))."..."; return $skrocone; } else { return $co; } } function cena_al($id) { global $db; // $trc = $db->selectCell("select cena from payment_methods where dft = 'Y'"); // $ilt = $db->selectCell("select count(*) from tracks where album_id = '$id'"); $cena_al = $db->selectCell("select sum(cena) from tracks where album_id = '$id'"); // $cena_al = $trc * $ilt; $cena_alb = $cena_al - (0.2 * $cena_al); return $cena_alb; } function odmien_plyte($lr) { if($lr == 1) { $prod = "album"; } elseif(($lr > 1) && ($lr < 5)) { $prod = "albumy"; } elseif(($lr > 4) && ($lr < 22)) { $prod = "album�w"; } else { $lr_dl = strlen($lr); $dzielnik = 10; $ulamek = $lr/$dzielnik; $t = explode(".",$ulamek); if(count($t) > 1) { $t2 = $t[1]; } if(($t2 > 1) && ($t2 < 5)) $prod = "albumy"; if($t2 > 4) $prod = "album�w"; } return $prod; } function odmien_utwor($lr) { if($lr == 1) { $prod = "utw�r"; } elseif(($lr > 1) && ($lr < 5)) { $prod = "utwory"; } elseif(($lr > 4) && ($lr < 22)) { $prod = "utwor�w"; } else { $lr_dl = strlen($lr); $dzielnik = 10; $ulamek = $lr/$dzielnik; $t = explode(".",$ulamek); $t2 = $t[1]; if(($t2 > 1) && ($t2 < 5)) $prod = "utwory"; if($t2 > 4) $prod = "utwor�w"; } return $prod; } function odmien_pozycje($lr) { if($lr == 1) { $prod = "pozycj�"; } elseif(($lr > 1) && ($lr < 5)) { $prod = "pozycje"; } elseif(($lr > 4) && ($lr < 22)) { $prod = "pozycji"; } else { $lr_dl = strlen($lr); $dzielnik = 10; $ulamek = $lr/$dzielnik; $t = explode(".",$ulamek); $t2 = $t[1]; if(($t2 > 1) && ($t2 < 5)) $prod = "pozycje"; if($t2 > 4) $prod = "pozycji"; } return $prod; } function wpiszdologu($metoda,$typ,$req = array()) { $f = fopen("a_log.txt","a"); fwrite($f,"\r\n --- ".date("Y-m-d H:i:s")." --- "); fwrite($f,"\r\n --- $metoda $typ $_SERVER[PHP_SELF] --- \r\n\r\n"); if(count($req) > 0) { foreach($req as $v) { fwrite($f,$v."\r\n"); } } fwrite($f,"\r\n --- END OF $metoda $typ --- \r\n"); fclose($f); } function wpiszdologudb($query) { $f = fopen("a_dblog.txt","a"); fwrite($f,"\r\n".date("Y-m-d H:i:s")."|$_SERVER[PHP_SELF]| $query "); fclose($f); } function katalog(){ $rev =strrev($_SERVER['SCRIPT_NAME']); $pos = strpos($rev,"/"); $part = substr($rev,$pos); return strrev($part); } function wykonaj_soap($url,$request) { $headers = array("Content-Type: text/xml"); $cnf = curl_init(); curl_setopt($cnf,CURLOPT_URL,$url); curl_setopt($cnf,CURLOPT_HTTPHEADER,$headers); curl_setopt($cnf,CURLOPT_POST,1); curl_setopt($cnf,CURLOPT_POSTFIELDS,$request); ob_start(); @curl_exec($cnf); if(curl_errno($cnf) != 0) { trigger_error("cURL: ".curl_error($cnf),256); } curl_close($cnf); $response = ob_get_contents(); ob_clean(); $resp_lines = explode("\r\n",$response); return $resp_lines; } function iso2utf($input) { $iso = array("'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'","'�'"); $utf = array("%C4%85","%C4%84","%C4%87","%C4%86","%C4%99","%C4%98","%C5%82","%C5%81","%C5%84","%C5%83","%C3%B3","%C3%93","%C5%9B","%C5%9A","%C5%BC","%C5%BB","%C5%BA","%C5%B9"); $output = preg_replace($iso,$utf,$input); return $output; } function verifyEmail($email) { $wholeexp = '/^(.+?)@(([a-z0-9\.-]+?)\.[a-z]{2,5})$/i'; $userexp = "/^[a-z0-9\~\!\#\$\%\&\(\)\-\_\+\=\[\]\;\:\'\"\,\.\/]+$/i"; if (preg_match($wholeexp, $email, $regs)) { $username = $regs[1]; $host = $regs[2]; //checkdnsrr($host, 'MX') if (1==1) { if (preg_match($userexp, $username)) { return true; } else { return false; } } else { return false; } } else { return false; } } function ustal_koszt_przes($items,$forma,$kwota,$przes = 2,$id_kraju = 2) { global $db,$order_id; $koszt = 0; if($id_kraju == 2) //koszty przesylek dla Polski { if(($kwota <= 100) and ($kwota > 0)) //koszt przesylek dla kwoty < 100zl { if($forma == 1) { $koszt = 13.9; //koszt przesylki za pobraniem } else { $koszt = 6.5; //koszt przesylki dla przelewu } if($przes == 1) { if($forma==1){ $koszt = $koszt + 4; //doplata za priorytet przy pobraniu } else { $koszt = $koszt + 1.4; //doplata za priorytet przy przelewie } } } elseif(($kwota > 100) and ($kwota <= 200)) //koszt przesylek dla kwoty >100 i <200 { if($forma == 1) { $koszt = 7.9; //koszt przesylki za pobraniem } else { $koszt = 3.9; //koszt przesylki dla przelewu } if($przes == 1){ if($forma==1){ $koszt = $koszt + 3; //doplata za priorytet przy pobraniu } else { $koszt = $koszt + 1.5; //doplata za priorytet przy przelewie } } } elseif($kwota > 200) //koszt przesylek dla kwoty > 200zl { if($forma == 1) { $koszt = 0; //koszt przesylki za pobraniem } else { $koszt = 0; //koszt przesylki dla przelewu } if($przes == 1){ if($forma==1){ $koszt = $koszt + 0; //doplata za priorytet przy pobraniu } else { $koszt = $koszt + 0; //doplata za priorytet przy przelewie } } } } else { if($kwota > 0) { $waga=0; $waga_opakowania=0; foreach($items as $el){ $w = $db->selectCell("select waga from albumy_nosniki where id_albumu = '".$el['id_albumu']."' and id_nosnika='".$el['id_nosnika']."'"); if (!$w) $w = $db->selectCell("select waga_domyslna from nosniki where id_nosnika='".$el['id_nosnika']."'"); $waga+=$w*$el['ilosc']; if ($el['id_nosnika']==14||$el['id_nosnika']==21||$el['id_nosnika']==24) $waga_opakowania=1; } if ($waga_opakowania) $waga_opakowania = $db->selectCell("select wartosc from config where nazwa = 'waga_opakowania_1'"); else $waga_opakowania = $db->selectCell("select wartosc from config where nazwa = 'waga_opakowania'"); $waga+=(int)$waga_opakowania/1000; $kraj = $db->selectRow("select * from countries where id_kraju = '$id_kraju'"); $ileplyt = count($items); $id_strefy = $kraj['id_strefy']; $koszt = $db->selectCell("select kwota from oplaty_poczt where id_strefy = '$id_strefy' and ilosc_plyt >= '$waga' order by ilosc_plyt asc limit 1"); } if($order_id=='SLPWJNTJK') $koszt = 23; if($order_id=='HTWOTVHQF') $koszt = 19; } return $koszt; } function daj_dostep($album_id,$nosnik_id,$ilosc_zam=0) { global $db; $album = $db->selectRow("select * from albumy where id_albumu = '$album_id'"); $an = $db->selectRow("select n.*, an.* from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$album_id' and an.id_nosnika = '$nosnik_id'"); if($an['stan'] > $ilosc_zam) { $dostepn = array('opis_en'=>'in stock','ilosc_dni'=>0); } else { if(($an['data_premiery'] != '0000-00-00') and ($an['data_premiery'] > date("Y-m-d"))) { $dostepn = array('opis_en'=>'available since'.$an['data_premiery']); } elseif(($album['data_premiery'] != '0000-00-00') and ($album['data_premiery'] > date("Y-m-d"))) { $dostepn = array('opis_en'=>'od'.$album['data_premiery']); } else { $id_dostepn = 0; if($an['id_dostepn'] != 0) { $id_dostepn = $an['id_dostepn']; } if(($id_dostepn == 0) and ($an['id_grupywyt']) != 0){ $grupywyt = $db->SelectRow("select id_dostepn,id_dystr from grupy_wytworni where id_grupy = '$an[id_grupywyt]'"); if($grupywyt['id_dostepn']!=0){ $id_dostepn = $grupywyt['id_dostepn']; } else { $id_dostepn = $db->selectCell("select id_dostepn from dystrybutorzy where id_dystryb = '$grupywyt[id_dystr]'"); } } if(($id_dostepn == 0) and ($an['id_wydawcy'] != 0)) { $wytwornia = $db->SelectRow("select id_dostepn,id_grupy from wytwornie where id_wytworni = '".$an['id_wydawcy']."'"); if($wytwornia['id_dostepn'] != 0) { $id_dostepn = $wytwornia['id_dostepn']; } else { $id_dostepn = $db->selectCell("select id_dostepn from grupy_wytworni where id_grupy = '".$wytwornia['id_grupy']."'"); } } if(($id_dostepn == 0) and ($album['grupa_wyt1'] != 0)) { $id_dostepn = $db->selectCell("select id_dostepn from grupy_wytworni where id_grupy = '".$album['grupa_wyt1']."'"); } if(($id_dostepn == 0) and ($album['grupa_wyt2'] != 0)) { $id_dostepn = $db->selectCell("select id_dostepn from grupy_wytworni where id_grupy = '".$album['grupa_wyt2']."'"); } if(($id_dostepn == 0) and ($album['id_wyt'] != 0)) { $wytwornia = $db->SelectRow("select id_dostepn,id_grupy from wytwornie where id_wytworni = '".$album['id_wyt']."'"); if($wytwornia['id_dostepn'] != 0) { $id_dostepn = $wytwornia['id_dostepn']; } else { $id_dostepn = $db->selectCell("select id_dostepn from grupy_wytworni where id_grupy = '".$wytwornia['id_grupy']."'"); } } if(($id_dostepn == 0) and ($an['id_dystryb'] != 0)) { $id_dostepn = $db->SelectCell("select id_dostepn from dystrybutorzy where id_dystryb = '".$an['id_dystryb']."'"); } if(($id_dostepn == 0) and ($album['id_dys_1'] != 0)) { $id_dostepn = $db->SelectCell("select id_dostepn from dystrybutorzy where id_dystryb = '".$album['id_dys_1']."'"); } if($id_dostepn == 0) { $dostepn = array('opis_en'=> "Brak danych.",'ilosc_dni'=>365); } else { $dostepn = $db->SelectRow("select * from dostepnosci where id_dostepn = '$id_dostepn'"); } } } return $dostepn; } // end function function daj_tid() { global $db; //while ($tid == "") { // for($i=0;$i<10;$i++) { // if ($i<2) $tid=$tid.Chr(mt_rand(66,90)); // if ($i>=2) $tid=$tid.mt_rand(0,9); // } // $is = $db->selectCell("select count(*) from koszyk_pozycje where trans_id = '$tid' and 1=1",true); // if($is > 0) { // $tid = ""; // } //} $byle = $db->selectCell("select order_id from transactions where order_id REGEXP '^[0-9]+$' and order_id<999999999 order by CAST( order_id AS UNSIGNED ) desc",true); $byle1 = $db->selectCell("select order_id from koszyk_zamowienia where order_id REGEXP '^[0-9]+$' and order_id<999999999 order by CAST( order_id AS UNSIGNED ) desc",true); if ($byle1>$byle) $byle=$byle1; $byle1 = $db->selectCell("select order_id from koszyk_pozycje where order_id REGEXP '^[0-9]+$' and order_id<999999999 order by CAST( order_id AS UNSIGNED ) desc",true); if ($byle1>$byle) $byle=$byle1; $tid=(int)$byle+1; return $tid; } function generateTicket() { global $db; $ticket = ""; while($ticket == "") { $ip = daj_ip(); $mtime = getmicrotime(); $tid = ""; for($i=0;$i<3;$i++) { $tid=$tid.Chr(mt_rand(66,90)); } $ticket = md5($ip.$mtime.$tid); // $is = $db->selectCell("select count(*) from koszyk_pozycje where ticket = '$ticket'"); if($is > 0) { $ticket = ""; } } return $ticket; } function multidimensionalArrayMap( $func, $arr ) { $newArr = array(); foreach( $arr as $key => $value ) { $newArr[ $key ] = ( is_array( $value ) ? multidimensionalArrayMap( $func, $value ) : $func( $value ) ); } return $newArr; } function createRandomPassword() { $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*1000000); $i = 0; $pass = '' ; while ($i <= 7) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $pass = $pass . $tmp; $i++; } return $pass; } function przelicz_cene($cena,$code){ $kurs = daj_komorke("select rate from currency where code='{$code}'"); return $cena*$kurs; } function cena_nosnik_wyswietl($cena){ $cena = str_replace(",",".",$cena); if(array_key_exists("currency",$_SESSION) && $_SESSION["currency"]=="USD"){ $cena_usd = przelicz_cene($cena,"USD"); $ret = number_format($cena_usd,2,",","")."$"; } else { $cena_eur = przelicz_cene($cena,"EUR"); $ret = number_format($cena_eur,2,",","")."€"; } return $ret; } /** * Funkcja $db->selectTable zwraca tablic� wielowymiarow�, gdzie ka�dy wiersz zawiera tablic� z * polami i ich warto�ciami dla danego rekordu. Gdy chcemy pobra� np. tylko tytu�y ze wszystkich * wierszy u�yjemy tej funkcji * * @author Marcin S�gol, prot.pl * @date 17.05.2012 * * @param array $tablica: tablica z wierszami rkord�w * @param string $pole: nazwa pola jakiego warto�ci chcemy pobra� * * @return array */ function pobierzWartosciPolaWszystkichWierszy($tablica, $pole) { $wartosci= array(); //tablica przechowuj�ca warto�ci dla wskazanego pola //sprawdz wszystkie wiersze i dodaj warto�� wybranego pola do tablicy $wartosci if(count($tablica) > 0) { foreach($tablica as $wiersz) { $wiersz[$pole] ? $wartosci[]= $wiersz[$pole] : ''; } } else { return array(); } return $wartosci; } $ticket = generateTicket(); ?>lang = &$oLang; $this->customer = &$customer; $this->items = array(); $this->tracks = array(); $this->suma = 0; $this->suma_sciezek = 0; $this->rabat = 0; $this->tabelka = array(); $this->tabelkasciezek = array(); $this->db = $db; if($_REQUEST['order_id']){ $this->orderid = $_REQUEST['order_id']; $this->items = $this->db->selectTable("select * from koszyk_pozycje where order_id = '".$this->orderid."' and potwierdzona = 'Y' order by dostepn_dni"); $this->forma=&$this->items[0]['forma']; $this->przesylka=&$this->items[0]['przesylka']; $this->id_kraju = $this->db->selectCell("select kraj from adresy where id_adresu = '".$this->items[0]['id_adresu']."' and usuniety!='T'"); if(!$this->id_kraju) { $this->id_kraju = $this->db->selectCell("select kraj from adresy where cust_id = '".$this->customer->cust_id."' and nazwa = 'Podstawowy' and usuniety!='T'"); } if(!$this->id_kraju) $this->id_kraju = 2; if($this->items[0]['id_sciezki'] != 0) $this->zakupplikow = true; $this->getTransakcja(); //print_r($transakcja); $transakcje_id="0"; foreach($this->items as $poz) if ($poz['id_transakcji']){ $transakcje_id.=", ".$poz['id_transakcji']; } $this->suma_zaplacona=0; if ($transakcje_id!="0") { $q = "select * from transactions where (id in (".$transakcje_id.") or order_id='".$this->orderid."') and paid='Y'"; $transakcje = $this->db->selectTable($q); foreach($transakcje as $tran){$this->suma_zaplacona+=$tran['cash_amount'];} } //$this->suma_teraz = $this->dajSumeTerazByOid($this->orderid); //$this->suma_skomplet = $this->dajSumeSkompletByOid($this->orderid); //$this->koszt_teraz = ustal_koszt_przes($this->items,$this->forma,$this->suma_teraz,$this->przesylka,$this->id_kraju); //$this->koszt_skomplet = ustal_koszt_przes($this->items,$this->forma,$this->suma_skomplet,$this->przesylka,$this->id_kraju); //$this->suma_ogolna_teraz = $this->suma_teraz + $this->koszt_teraz; //$this->suma_ogolna_skomplet = $this->suma_skomplet + $this->koszt_skomplet; //$this->suma_ogolna = $this->suma_ogolna_teraz + $this->suma_ogolna_skomplet; $this->suma_teraz = $this->dajSumeByOid($this->orderid); $this->koszt_teraz = ustal_koszt_przes($this->items,$this->forma,$this->suma_teraz,$this->przesylka,$this->id_kraju); $this->suma_ogolna_teraz = $this->suma_teraz + $this->koszt_teraz; $this->suma_ogolna = round($this->suma_ogolna_teraz-$this->suma_zaplacona,2); foreach($this->items as $k=>$p){ if($p['id_sciezki'] != 0) { $this->items[$k]['track'] = $this->db->selectRow("select * from tracks where id = '".$p['id_sciezki']."'"); } if($p['id_albumu'] != 0){ $this->items[$k]['album'] = $this->db->selectRow("select * from albumy where id_albumu = '".$p['id_albumu']."'"); } if($p['id_nosnika'] != 0){ $this->items[$k]['nosnik'] = $this->db->selectCell("select nazwa_en from nosniki where id_nosnika = '".$p['id_nosnika']."'"); $this->items[$k]['a_n'] = $this->db->selectRow("select * from albumy_nosniki where id_albumu = '$p[id_albumu]' and id_nosnika = '$p[id_nosnika]' and aktywny='T'"); } $this->items[$k]['dostepn_dni'] = daj_dostep($p['id_albumu'],$p['id_nosnika'],$p['ilosc']); if($p['wyslana'] != 'Y') { $this->all_sent = false; } if($p['spakowana'] != 'Y') { $this->all_spak = false; } //Uzupelnianie pola Wysylka w statusie zamowienia if($p['wysylka'] == 'teraz') { //$this->items[$k]['wysylka_str'].='Od razu'; //if($p['zaplacona'] != 'Y') { $this->t_now[] = $poz['id_pozycji']; if($p['wyslana'] != 'Y') { $this->all_sent = false; } if($p['spakowana'] != 'Y') { $this->all_spak = false; } $this->items[$k]['wysylka_str'].="[Zmie�]"; //} //if($p['zaplacona'] == 'Y') { $this->items[$k]['wysylka_str'].="
Paid"; } } else if($p['wysylka'] == 'skomplet') { $this->all_now = false; $this->items[$k]['wysylka_str'].="When complete whole order"; if(($p['wyslana'] != 'Y') and ((($p['dostepn_dni'] == 0) and strtotime($this->items[$k]['a_n']['data_premiery'])items[$k]['wysylka_str'].="
[Zmie�]"; } if($p['zaplacona'] == 'Y') { $this->items[$k]['wysylka_str'].="
Paid"; } if($p['wyslana'] == 'Y') { $this->items[$k]['wysylka_str'].="
Shipped"; } else { $this->all_sent = false; } if($p['spakowana'] != 'Y') { $this->all_spak = false; } } //Uzupelnianie pola Status w statusie zamowienia if($p['przygotowana'] == 'Y') { if ($p['zaplacona'] != 'Y') { $this->t_ready[] = $p['id_pozycji']; $this->some_ready = true; } if($p['wyslana'] == 'Y') { $this->items[$k]['status_str'].="Shipped"; } else { $this->all_sent = false; $this->items[$k]['status_str'].="Left";//"Left"; } if($p['zaplacona'] != 'Y') { $this->all_paid = false; } } else { $this->all_ready = false; if($p['dostepn_dni'] > 0 or strtotime($this->items[$k]['a_n']['data_premiery'])>time()) { $this->items[$k]['status_str'].="Wait for delivery"; } else { $this->items[$k]['status_str'].="Processing"; } if($p['zaplacona'] != 'Y') { $this->all_paid = false; } } } } $this->getInneGotowe(); } // end function function getInneGotowe(){ $q = "select * from koszyk_pozycje where id_klienta = '".$this->customer->cust_id."' and przygotowana = 'Y' and trans_id = '' and wyslana != 'Y' and zaplacona != 'Y' and order_id != '".$this->orderid."' and id_sciezki = 0"; $this->inne_gotowe = $this->db->selectTable($q); if($this->inne_gotowe)foreach($this->inne_gotowe as $k=>$poz) { if($poz['id_sciezki'] != 0) { $this->inne_gotowe[$k]['track'] = $this->db->selectRow("select * from tracks where id = '".$poz['id_sciezki']."'"); } if($poz['id_albumu'] != 0) { $this->inne_gotowe[$k]['album'] = $this->db->selectRow("select * from albumy where id_albumu = '".$poz['id_albumu']."'"); } if($poz['id_nosnika'] != 0) { $this->inne_gotowe[$k]['nosnik'] = $this->db->selectCell("select nazwa_en from nosniki where id_nosnika = '".$poz['id_nosnika']."'"); } } } function getTransakcja(){ $transakcje_id="0"; foreach($this->items as $poz) if ($poz['id_transakcji']){ $transakcje_id.=", ".$poz['id_transakcji']; } $this->transakcja = $this->db->selectRow("select * from transactions where order_id = '".$this->items[0]['trans_id']."' and order_id != '' order by paid desc"); if(!$this->transakcja) { $this->transakcja = $this->db->selectRow("select * from transactions where id in (".$transakcje_id.") order by paid desc"); } if(($this->transakcja['date'] < date("Y-m-d H:i:s",mktime(date("H"),date("i")-20,date("s"),date("m"),date("d"),date("Y")))) and ($this->transakcja['paid'] == 'N') and ($this->transakcja['returned'] == 'N')) { $this->db->run("update transactions set sent = 'N' where id = '".$this->transakcja['id']."'"); $this->transakcja = $this->db->selectRow("select * from transactions where id = '".$this->transakcja['id']."'"); if($this->zakupplikow) { $this->db->run("update koszyk_pozycje set wyslana = 'Y' where order_id = '$this->orderid'"); } else { //$db->run("update koszyk_pozycje set where order_id = '$order_id'"); } } } function iledlaopa($aid) { global $db,$customer,$requestticket; $opa = 0; $nosnikplik = $db->selectCell("select id_nosnika from nosniki where id_nosnika = '23'"); $id_organiz = $db->selectCell("select id_organiz from albumy_nosniki where id_albumu = '$aid' and id_nosnika = '$nosnikplik'"); if($id_organiz == 0) { $id_organiz = $db->selectCell("select id_organiz from albumy where id_albumu = '$aid'"); } if($id_organiz != 0) { return 'T'; } else return 'N'; } function addMedium($album_id,$nosnik_id,$rozmiar='') { global $customer,$requestticket; $dodano = false; $session_id = session_id(); if($this->db->selectRow("select * from albumy where id_albumu='$album_id' and aktywny='T'")){ if($this->db->selectRow("select * from albumy_nosniki where id_albumu='$album_id' and id_nosnika='$nosnik_id' and aktywny='T'")){ $pola_spec = $this->db->selectRow("select np.*, nps.nazwa_en as nazwa from nosniki_pola np left join nosniki_pola_spec nps on np.id_pola_spec = nps.id_pola_spec where np.id_albumu = '$album_id' and id_nosnika = '$nosnik_id' and nazwa='rozmiar' order by nazwa limit 1"); if($pola_spec and !$rozmiar){ if($_SERVER['HTTP_REFERER']){ header("Location: ".$_SERVER['HTTP_REFERER']);exit(); } else { header("Location: index.php");exit(); } } $ilosc_artykulu = $this->db->selectCell("select sum(ilosc) from koszyk_pozycje where id_klienta = '".$customer->cust_id."' and order_id = '".$this->orderid."' and session_id = '".$session_id."' and id_albumu = '$album_id' and id_nosnika = '$nosnik_id'"); $dostepn = $this->dajDostepnosc($album_id,$nosnik_id,(int)$ilosc_artykulu+1); $ilosc_dni = $dostepn['ilosc_dni']; $cena = $this->dajCene($album_id,$nosnik_id,$ilosc_artykulu+1); // dodanie nosnika do items if(count($this->items) > 0) { foreach($this->items as $k=>$poz) { if(($poz['id_albumu'] == $album_id) and ($poz['id_nosnika'] == $nosnik_id) and $poz['cena']==$cena and $ilosc_dni==$poz['dostepn_dni']) { $pozycja = $this->db->selectRow("select * from koszyk_pozycje where id_klienta = '".$customer->cust_id."' and session_id = '".$session_id."' and id_albumu = '$album_id' and id_nosnika = '$nosnik_id' and id_pozycji='$poz[id_pozycji]'"); $this->db->run("update koszyk_pozycje set ilosc = ilosc + 1,dostepn_dni='$ilosc_dni',cena='$cena', ticket = '$requestticket' where id_klienta = '".$customer->cust_id."' and session_id = '".$session_id."' and id_albumu = '$album_id' and id_nosnika = '$nosnik_id'"); $dodano = true; } } } if(!$dodano) { $opa = $this->iledlaopa($album_id); $q = "insert into koszyk_pozycje set id_klienta = '".$customer->cust_id."', session_id = '".$session_id."', rozmiar = '$rozmiar', id_albumu = '$album_id', id_nosnika = '$nosnik_id', cena = '$cena', data_wstawienia = '".date("Y-m-d")."', dostepn_dni = '".$dostepn['ilosc_dni']."', ilosc = '1', ticket = '$requestticket', zaiks='$opa', sklep='ENG'"; $this->db->insert($q); } return true; } else { return false; } } } // end function function addTrack($track_id) { global $db,$customer,$requestticket; $session_id = session_id(); $track = $db->selectRow("select * from tracks where id = '$track_id'"); $album_id = $track['album_id']; $nosnik_id = $db->selectCell("select id_nosnika from nosniki where id_nosnika = '23'"); if(!$this->db->selectRow("select * from albumy where id_albumu='$album_id' and aktywny='T'"))return false; if(!$this->db->selectRow("select * from albumy_nosniki where id_albumu='$album_id' and id_nosnika='$nosnik_id' and aktywny='T'"))return false; if($track['cena']>0)$cena=$track['cena']; else $cena = $this->dajCene($album_id,$nosnik_id); $cena_albumu = $this->dajCeneAlb($album_id,$nosnik_id); $jest = false; if(count($this->sciezki) > 0) { foreach($this->sciezki as $tt) { if($tt['id_sciezki'] == $track_id) $jest = true; } } if(!$jest) { $opa = $this->iledlaopa($album_id); $q = "insert into koszyk_pozycje set id_klienta = '".$customer->cust_id."', session_id = '".$session_id."', id_albumu = '$album_id', id_sciezki = '$track_id', cena = '$cena', cena_albumu = '$cena_albumu', data_wstawienia = '".date("Y-m-d")."', ilosc = '1', ticket = '$requestticket', zaiks='$opa', sklep='ENG'"; $db->insert($q); } return true; } // end function function addAllTracks($album_id, $nosnik= null) { global $db,$customer,$requestticket; if(!$this->db->selectRow("select * from albumy where id_albumu='$album_id' and aktywny='T'"))return false; $pliki = $db->selectTable("select id,mp3_full from tracks where album_id = '$album_id' and track_no<>0"); $ileplikow = count($pliki); $session_id = session_id(); //$nosnik_id = $db->selectCell("select id_nosnika from nosniki where nazwa_en = 'file'"); $nosnik_id = $db->selectCell("select id_nosnika from nosniki where id_nosnika = ".intval($nosnik)); if ($nosnik_id=='27') { $pliki = $db->selectTable("select id from tracks where album_id = '$album_id' and track_no=0"); $ileplikow = count($pliki); } if($nosnik_id) { if ($nosnik_id=='27') $cena= $this->dajCeneAlb($album_id,$nosnik_id); else $cena = $this->dajCene($album_id,$nosnik_id); $cena_albumu = $this->dajCeneAlb($album_id,$nosnik_id); foreach($pliki as $p){ $poprawna=false; if($p['mp3_full'] != '' and file_exists("../../pliki/".$p['mp3_full'])){ $jest = false; foreach($this->sciezki as $tt){ if($tt['id_sciezki'] == $p['id']) $jest = true; } if(!$jest){ $poprawna=true; } } else if ($nosnik_id=='27' && file_exists("../../pliki/".$album_id."_flac.zip")) { $poprawna=true; } // end foreach if($poprawna){ $opa = $this->iledlaopa($album_id); $q = "insert into koszyk_pozycje set id_klienta = '".$customer->cust_id."', session_id = '".$session_id."', id_albumu = '$album_id', id_sciezki = '".$p['id']."', cena = '$cena', cena_albumu = '$cena_albumu', id_nosnika='$nosnik_id', data_wstawienia = '".date("Y-m-d")."', ilosc = '1', ticket = '$requestticket', zaiks='$opa', sklep='ENG'"; $db->insert($q); } // endif } // end foreach return true; } else { return false; } } // end function function policzRabat() { global $db; if(count($this->sciezki) > 0) { foreach($this->sciezki as $ts) { $id_albumu = $ts['id_albumu']; $albumy[$id_albumu] = $albumy[$id_albumu] + $ts['ilosc']; if($ts['cena_albumu'] > 0) { $cena['cena_en'] = $ts['cena_albumu']; $cena['cena_tr_en'] = $ts['cena']; } else { $id_nosnika = $db->selectCell("select id_nosnika from nosniki where id_nosnika = '23'"); $id_ceny = $db->selectCell("select id_ceny from albumy_nosniki where id_albumu = '$id_albumu' and id_nosnika = '$id_nosnika'"); $cena = $db->selectRow("select * from ceny where id_ceny = '$id_ceny'"); } $ceny[$id_albumu] = $cena; } foreach($albumy as $aid=>$ilesc){ $pliki = $db->selectTable("select id,mp3_full from tracks where album_id = '$aid' and track_no<>0"); $ilewb=0; foreach($pliki as $p){ $poprawna=false; if($p['mp3_full'] != '' and file_exists("../../pliki/".$p['mp3_full'])){ $ilewb+=1; } } //$ilewb = $db->selectCell("select count(*) from tracks where album_id = '$aid'"); if($ilesc == $ilewb) { $cenacalalb = $ceny[$aid]['cena_en']; $cenaalbtr = $ceny[$aid]['cena_tr_en'] * $ilewb; $roznica = $cenaalbtr - $cenacalalb; if($roznica != 0) { $this->rabat = $this->rabat + $roznica; } } } } return true; } function modifyPoz($id_pozycji,$ilosc) { global $db,$customer; $session_id = session_id(); $pozycja = $db->selectRow("select * from koszyk_pozycje where id_pozycji = '$id_pozycji' and id_klienta = '".$customer->cust_id."' and session_id = '$session_id' and potwierdzona = 'N'"); $album_id=$pozycja['id_albumu']; $nosnik_id=$pozycja['id_nosnika']; $ilosc_do_dodania=$ilosc-$pozycja['ilosc']; print_r($ilosc_do_dodania); if($ilosc_do_dodania==0){ return true; } $ilosc_artykulu = $db->selectCell("select sum(ilosc) from koszyk_pozycje where id_klienta = '".$customer->cust_id."' and session_id = '".$session_id."' and id_albumu = '$album_id' and id_nosnika = '$nosnik_id'"); $dostepn = $this->dajDostepnosc($pozycja['id_albumu'],$pozycja['id_nosnika'],$ilosc_artykulu+$ilosc_do_dodania); $cena = $this->dajCene($pozycja['id_albumu'],$pozycja['id_nosnika'],$ilosc_artykulu+$ilosc_do_dodania); $ilosc_dni = $dostepn['ilosc_dni']; if (!$ilosc_dni) $ilosc_dni=0; if(($pozycja['cena']!=$cena or $ilosc_dni!=$pozycja['dostepn_dni']) and $ilosc_do_dodania>0){ //Staram sie znalezc pasujaca pozycje $pozycja_pasujaca = $db->selectRow("select * from koszyk_pozycje where id_klienta = '".$customer->cust_id."' and session_id = '".$session_id."' and id_albumu = '$album_id' and id_nosnika = '$nosnik_id' and cena = '$cena' and dostepn_dni = '$dostepn[ilosc_dni]' and potwierdzona = 'N'"); if($pozycja_pasujaca){ $pozycja=$pozycja_pasujaca; } } if(($pozycja['cena']!=$cena or $ilosc_dni!=$pozycja['dostepn_dni']) and $ilosc_do_dodania>0){ $nazwa_albumu = $this->db->selectCell("select tytul from albumy where id_albumu='".$pozycja['id_albumu']."'"); $this->message[] = "Limited availability of the album $nazwa_albumu in special price"; $requestticket=$pozycja['ticket']; $rozmiar=$pozycja['rozmiar']; $opa = $this->iledlaopa($album_id); $ilosc_dostepnych = $db->selectCell("select stan from albumy_nosniki where id_albumu = '$album_id' and id_nosnika = '$nosnik_id'"); if ($ilosc_dostepnych>$ilosc_artykulu+$ilosc_do_dodania) { $q = "update koszyk_pozycje set ilosc = '$ilosc_dostepnych' where id_pozycji = '$id_pozycji' and id_klienta = '".$customer->cust_id."' and session_id = '$session_id' and potwierdzona = 'N'"; $ilosc_do_dodania=$ilosc_artykulu+$ilosc_do_dodania-$ilosc_dostepnych; } $q = "insert into koszyk_pozycje set id_klienta = '".$customer->cust_id."', session_id = '".$session_id."', rozmiar = '$rozmiar', id_albumu = '$album_id', id_nosnika = '$nosnik_id', cena = '$cena', data_wstawienia = '".date("Y-m-d")."', dostepn_dni = '".$dostepn['ilosc_dni']."', ilosc = '$ilosc_do_dodania', ticket = '$requestticket', zaiks='$opa', sklep='ENG'"; $this->db->insert($q); } elseif ($ilosc_do_dodania<0){ $q = "update koszyk_pozycje set ilosc = ilosc+'$ilosc_do_dodania' where id_pozycji = '$id_pozycji' and id_klienta = '".$customer->cust_id."' and session_id = '$session_id' and potwierdzona = 'N'"; } else { if($ilosc_dni!=$pozycja['dostepn_dni']){ $nazwa_albumu = $db->selectCell("select tytul from albumy where id_albumu='".$pozycja['id_albumu']."'"); $this->message[] = "availability of the album $nazwa_albumu nas been changed"; } $q = "update koszyk_pozycje set ilosc =ilosc+ '$ilosc_do_dodania',cena='$cena',dostepn_dni='$ilosc_dni' where id_pozycji = '$id_pozycji' and id_klienta = '".$customer->cust_id."' and session_id = '$session_id' and potwierdzona = 'N'"; $db->run($q); } return true; } function removePoz($id_pozycji) { global $db,$customer; $session_id = session_id(); $q = "delete from koszyk_pozycje where id_pozycji = '$id_pozycji' and id_klienta = '".$customer->cust_id."' and session_id = '$session_id' and potwierdzona = 'N'"; $db->run($q); return true; } // end function function removeTracks() { global $db,$customer; $session_id = session_id(); $q = "delete from koszyk_pozycje where id_sciezki != 0 and id_klienta = '".$customer->cust_id."' and session_id = '$session_id' and potwierdzona = 'N'"; $db->run($q); return true; } function dajItems() { global $db,$customer; $session_id = session_id(); $q = "select * from koszyk_pozycje where id_klienta = '".$customer->cust_id."' and session_id = '$session_id' and potwierdzona = 'N' and id_sciezki = 0 order by id_pozycji"; $this->items = $db->selectTable($q); return true; } function dajSciezki() { global $db,$customer; $session_id = session_id(); $q = "select * from koszyk_pozycje where id_klienta = '".$customer->cust_id."' and session_id = '$session_id' and potwierdzona = 'N' and id_sciezki != 0"; $this->sciezki = $db->selectTable($q); return true; } function ustalWysylke($poz,$sposob) { global $db,$customer; $session_id = session_id(); $q = "update koszyk_pozycje set wysylka = '$sposob' where id_pozycji = '$poz' and id_klienta = '".$customer->cust_id."'"; $db->run($q); return true; } function ustalFakture($poz,$faktura){ global $db,$customer; $session_id = session_id(); if($faktura){ $q = "update koszyk_pozycje set faktura = 'T' where id_pozycji = '$poz' and id_klienta = '".$customer->cust_id."'"; $db->run($q); } return true; } function dajSumeTeraz() { global $db,$customer; $session_id = session_id(); $q = "select * from koszyk_pozycje where wysylka = 'teraz' and id_klienta = '".$customer->cust_id."' and session_id = '$session_id' and potwierdzona = 'N'"; $pozteraz = $db->selectTable($q); foreach($pozteraz as $poz) { $poz_nosnikpola = $db->selectRow("select * from albumy_nosniki where id_albumu = '".$poz['id_albumu']."' and id_nosnika = '".$poz['id_nosnika']."'"); $cena = $db->selectCell("select cena_en from ceny where id_ceny = '".$poz_nosnikpola['id_ceny']."'"); if(($poz_nosnikpola['id_promocji'] != 0) and ($poz_nosnikpola['id_ceny_promo'] != 0)){ $promocja = $db->selectCell("select do_wyczerp from promocje where id_promocji='".$poz_nosnikpola['id_promocji']."'"); if($promocja=='Y' and (!($poz_nosnikpola['stan']>0))){ mysql_query("update albumy_nosniki set id_promocji=0 where id_nosnika='".$poz['id_nosnika']."' and id_albumu = '".$poz['id_albumu']."'"); } else { $cena = $db->selectCell("select cena_en from ceny where id_ceny = '".$poz_nosnikpola['id_ceny_promo']."'"); } } if($poz['cena'] != 0) $cena = $poz['cena']; $wartosc = $poz['ilosc'] * $cena; $suma = $suma + $wartosc; } return $suma; } function dajSumeTerazI() { global $db,$customer; $session_id = session_id(); $q = "select * from koszyk_pozycje where id_klienta = '".$customer->cust_id."' and session_id = '$session_id' and potwierdzona = 'N' and id_nosnika<>23 and id_nosnika<>27"; $pozteraz = $db->selectTable($q); foreach($pozteraz as $poz) { $poz_nosnikpola = $db->selectRow("select * from albumy_nosniki where id_albumu = '".$poz['id_albumu']."' and id_nosnika = '".$poz['id_nosnika']."'"); $cena = $db->selectCell("select cena_pl from ceny where id_ceny = '".$poz_nosnikpola['id_ceny']."'"); if(($poz_nosnikpola['id_promocji'] != 0) and ($poz_nosnikpola['id_ceny_promo'] != 0)){ $promocja = $db->selectCell("select do_wyczerp from promocje where id_promocji='".$poz_nosnikpola['id_promocji']."'"); if($promocja=='Y' and (!($poz_nosnikpola['stan']>0))){ mysql_query("update albumy_nosniki set id_promocji=0 where id_nosnika='".$poz['id_nosnika']."' and id_albumu = '".$poz['id_albumu']."'"); } else { $cena = $db->selectCell("select cena_pl from ceny where id_ceny = '".$poz_nosnikpola['id_ceny_promo']."'"); } } if($poz['cena'] != 0) $cena = $poz['cena']; $wartosc = $poz['ilosc'] * $cena; $suma = $suma + $wartosc; } return $suma; } function dajSumeByOid($oid) { global $db,$customer; $session_id = session_id(); $q = "select * from koszyk_pozycje where order_id = '$oid'"; $pozteraz = $db->selectTable($q); foreach($pozteraz as $poz) { $cena = $this->dajCene($poz['id_albumu'],$poz['id_nosnika'],$poz['ilosc']); if($poz['cena'] != 0) $cena = $poz['cena']; $wartosc = $poz['ilosc'] * $cena; $suma = $suma + $wartosc; } return $suma; } function dajSumeTerazByOid($oid) { global $db,$customer; $session_id = session_id(); $q = "select * from koszyk_pozycje where wysylka = 'teraz' and order_id = '$oid'";// and zaplacona != 'Y'"; $pozteraz = $db->selectTable($q); foreach($pozteraz as $poz) { $cena = $this->dajCene($poz['id_albumu'],$poz['id_nosnika'],$poz['ilosc']); if($poz['cena'] != 0) $cena = $poz['cena']; $wartosc = $poz['ilosc'] * $cena; $suma = $suma + $wartosc; } return $suma; } function dajSumeSkomplet() { global $db,$customer; $session_id = session_id(); $q = "select * from koszyk_pozycje where wysylka = 'skomplet' and id_klienta = '".$customer->cust_id."' and session_id = '$session_id' and potwierdzona = 'N'"; $pozskompl = $db->selectTable($q); foreach($pozskompl as $poz) { $cena = $this->dajCene($poz['id_albumu'],$poz['id_nosnika'],$poz['ilosc']); if($poz['cena'] != 0) $cena = $poz['cena']; $wartosc = $poz['ilosc'] * $cena; $suma = $suma + $wartosc; } return $suma; } function dajSumeSkompletByOid($oid) { global $db,$customer; $session_id = session_id(); $q = "select * from koszyk_pozycje where wysylka = 'skomplet' and order_id = '$oid'";// and zaplacona != 'Y'"; $pozskompl = $db->selectTable($q); foreach($pozskompl as $poz) { $cena = $this->dajCene($poz['id_albumu'],$poz['id_nosnika'],$poz['ilosc']); if($poz['cena'] != 0) $cena = $poz['cena']; $wartosc = $poz['ilosc'] * $cena; $suma = $suma + $wartosc; } return $suma; } function zrobTabele() { if(count($this->items) > 0) { $suma = 0; $i=0; $items_ilosc=array(); foreach($this->items as $poz) { $items_ilosc[$poz['id_albumu']."_".$poz['id_nosnika']]+=$poz['ilosc']; $poz_album = $this->db->selectRow("select * from albumy where id_albumu = '".$poz['id_albumu']."'"); if($poz_album){ $poz_nosnik = $this->db->selectRow("select * from nosniki where id_nosnika = '".$poz['id_nosnika']."'"); } if($poz_nosnik){ $i++; $poz_wykonawcy = $this->db->selectTable("select p.name from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '".$poz['id_albumu']."' order by ap.id"); if(!$poz_wykonawcy){ $poz_wykonawcy[0] = array(); } $poz_nosnik_p = $this->db->selectTable("select wartosc_en from nosniki_pola where id_albumu='".$poz['id_albumu']."' and id_nosnika='".$poz['id_nosnika']."'"); if(!$poz_nosnik_p){ $poz_nosnik_p[0] = array(); } $cena = $this->dajCene($poz['id_albumu'],$poz['id_nosnika'],$items_ilosc[$poz['id_albumu']."_".$poz['id_nosnika']]); if($poz['cena']>0){ $cena = $poz['cena']; } $wartosc = $poz['ilosc'] * $cena; $suma = $suma + $wartosc; if($poz_nosnikpola['id_wydawcy'] != 0) { $wydawca = $this->db->selectRow("select * from wytwornie where id_wytworni = '".$poz_nosnikpola['id_wydawcy']."'"); } elseif($poz_album['id_wyt'] != 0) { $wydawca = $this->db->selectRow("select * from wytwornie where id_wytworni = '".$poz_album['id_wyt']."'"); } $waga = $this->db->selectCell("select waga from albumy_nosniki where id_albumu = '".$poz['id_albumu']."' and id_nosnika='".$poz['id_nosnika']."'"); if (!$waga) $waga = $this->db->selectCell("select waga_domyslna from nosniki where id_nosnika='".$poz['id_nosnika']."'"); $dostepn = $this->dajDostepnosc($poz['id_albumu'],$poz['id_nosnika'],$items_ilosc[$poz['id_albumu']."_".$poz['id_nosnika']]); $this->tabelka[] = array( "poz"=>$poz, "pozycja"=>$poz['id_pozycji'], "wykonawca"=>join("
",$poz_wykonawcy[0]), "id_albumu"=>$poz['album_id'], "tytul_albumu"=>$poz_album['tytul'], "nosnik"=>$poz_nosnik['nazwa_en'], "id_nosnika"=>$poz['nosnik_id'], "rozmiar"=>$poz['rozmiar'], "dostepnosc"=>$dostepn['opis_en'], "dostepn_dni"=>$dostepn['ilosc_dni'], "cena"=>number_format($cena,2,",",""), "ilosc"=>$poz['ilosc'], "wartosc"=>number_format($wartosc,2,",",""), "wysylka"=>$poz['wysylka'], "wydawca"=>$wydawca['nazwa'], "faktura"=>$poz['faktura'], "waga"=>$waga ); } } usort($this->tabelka, "cmp_tabelka2"); $this->suma = $suma; return true; } else { return false; } } function zrobTabeleSciezek($db) { if(count($this->sciezki) > 0) { $suma = 0; $i = 0; foreach($this->sciezki as $tt) { $i++; $poz_track = $db->selectRow("select * from tracks where id = '".$tt['id_sciezki']."'"); $poz_album = $db->selectRow("select * from albumy where id_albumu = '".$poz_track['album_id']."'"); $poz_wykonawcy = $db->selectTable("select p.name from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '".$poz_track['album_id']."' order by ap.id"); if(!$poz_wykonawcy){ $poz_wykonawcy[0] = array(); } $id_nosnika = $db->selectCell("select id_nosnika from nosniki where id_nosnika = '23'"); $id_ceny = $db->selectCell("select id_ceny from albumy_nosniki where id_albumu = '".$poz_track['album_id']."' and id_nosnika = '$id_nosnika'"); $cenat = $db->selectRow("select * from ceny where id_ceny = '$id_ceny'"); if($tt['cena'] != 0) { $cena = $tt['cena']; } else { $cena = $cenat['cena_tr_pl']; } $suma = $suma + $cena; $this->tabelkasciezek[] = array( 'id_albumu'=>$tt['id_albumu'], 'pozycja'=>$tt['id_pozycji'], 'tytul'=>$poz_track['title'], 'tytul_albumu'=>$poz_album['tytul'], "wykonawca"=>join("
",$poz_wykonawcy[0]), 'cena'=>number_format($cena,2,",","") ); } $this->suma_sciezek = $suma - $this->rabat; return true; } else { return false; } } // end function function dajDostepnosc($album_id,$nosnik_id,$ilosc_zam) { global $db; $album = $db->selectRow("select * from albumy where id_albumu = '$album_id'"); $an = $db->selectRow("select n.*, an.* from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$album_id' and an.id_nosnika = '$nosnik_id'"); if($an['stan'] >= $ilosc_zam) { $dostepn = array('opis_en'=>'in stock','ilosc_dni'=>0); } else { if(($an['data_premiery'] != '0000-00-00') and ($an['data_premiery'] > date("Y-m-d"))) { $dostepn = array('opis_en'=>'available since: '.$an['data_premiery']); } elseif(($album['data_premiery'] != '0000-00-00') and ($album['data_premiery'] > date("Y-m-d"))) { $dostepn = array('opis_en'=>'available since: '.$album['data_premiery']); } else { $id_dostepn = 0; if($an['id_dostepn'] != 0) { $id_dostepn = $an['id_dostepn']; } if(($id_dostepn == 0) and ($an['id_grupywyt']) != 0){ $grupywyt = $db->SelectRow("select id_dostepn,id_dystr from grupy_wytworni where id_grupy = '$an[id_grupywyt]'"); if($grupywyt['id_dostepn']!=0){ $id_dostepn = $grupywyt['id_dostepn']; } else { $id_dostepn = $db->selectCell("select id_dostepn from dystrybutorzy where id_dystryb = '$grupywyt[id_dystr]'"); } } if(($id_dostepn == 0) and ($an['id_wydawcy'] != 0)) { $wytwornia = $db->SelectRow("select id_dostepn,id_grupy from wytwornie where id_wytworni = '".$an['id_wydawcy']."'"); if($wytwornia['id_dostepn'] != 0) { $id_dostepn = $wytwornia['id_dostepn']; } else { $id_dostepn = $db->selectCell("select id_dostepn from grupy_wytworni where id_grupy = '".$wytwornia['id_grupy']."'"); } } if(($id_dostepn == 0) and ($album['grupa_wyt1'] != 0)) { $id_dostepn = $db->selectCell("select id_dostepn from grupy_wytworni where id_grupy = '".$album['grupa_wyt1']."'"); } if(($id_dostepn == 0) and ($album['grupa_wyt2'] != 0)) { $id_dostepn = $db->selectCell("select id_dostepn from grupy_wytworni where id_grupy = '".$album['grupa_wyt2']."'"); } if(($id_dostepn == 0) and ($album['id_wyt'] != 0)) { $wytwornia = $db->SelectRow("select id_dostepn,id_grupy from wytwornie where id_wytworni = '".$album['id_wyt']."'"); if($wytwornia['id_dostepn'] != 0) { $id_dostepn = $wytwornia['id_dostepn']; } else { $id_dostepn = $db->selectCell("select id_dostepn from grupy_wytworni where id_grupy = '".$wytwornia['id_grupy']."'"); } } if(($id_dostepn == 0) and ($an['id_dystryb'] != 0)) { $id_dostepn = $db->SelectCell("select id_dostepn from dystrybutorzy where id_dystryb = '".$an['id_dystryb']."'"); } if(($id_dostepn == 0) and ($album['id_dys_1'] != 0)) { $id_dostepn = $db->SelectCell("select id_dostepn from dystrybutorzy where id_dystryb = '".$album['id_dys_1']."'"); } if($id_dostepn == 0) { $dostepn = array('opis_en'=> "lack of data.",'ilosc_dni'=>365); } else { $dostepn = $db->SelectRow("select * from dostepnosci where id_dostepn = '$id_dostepn'"); } } } return $dostepn; } // end function function dajCene($album_id,$nosnik_id,$ilosc=1) { global $db; //$nosnikplik = $db->selectCell("select id_nosnika from nosniki where rodzaj_nosnika = 'cyfrowy'"); $nosnikiCyfrowe= pobierzWartosciPolaWszystkichWierszy($db->selectTable("select id_nosnika from nosniki where rodzaj_nosnika='cyfrowy'"), 'id_nosnika'); $an = $db->selectRow("select * from albumy_nosniki where id_albumu = '$album_id' and id_nosnika = '$nosnik_id'"); $cena = $db->selectCell("select cena_en from ceny where id_ceny = '".$an['id_ceny']."'"); if(($an['id_promocji'] != 0) and ($an['id_ceny_promo'] != 0)){ $promocja = $db->selectCell("select do_wyczerp from promocje where id_promocji='".$an['id_promocji']."'"); if($promocja=='Y' and (!($an['stan']>0))){ mysql_query("update albumy_nosniki set id_promocji=0 where id_nosnika='$nosnik_id' and id_albumu = '$album_id'"); } else if(($promocja=='Y' and $an['stan']>=$ilosc) or $promocja=='N'){ $cena = $db->selectCell("select cena_en from ceny where id_ceny = '".$an['id_ceny_promo']."'"); } } //if($nosnik_id == $nosnikplik) if(in_array($nosnik_id, $nosnikiCyfrowe)) { $cena = $db->selectCell("select cena_tr_en from ceny where id_ceny = '".$an['id_ceny']."'"); } return $cena; } // end fn function dajCeneAlb($album_id,$nosnik_id,$ilosc=1) { global $db; //$nosnikplik = $db->selectCell("select id_nosnika from nosniki where nazwa_en = 'file'"); $an = $db->selectRow("select * from albumy_nosniki where id_albumu = '$album_id' and id_nosnika = '$nosnik_id'"); $cena = $db->selectCell("select cena_en from ceny where id_ceny = '".$an['id_ceny']."'"); if(($an['id_promocji'] != 0) and ($an['id_ceny_promo'] != 0)){ $promocja = $db->selectCell("select do_wyczerp from promocje where id_promocji='".$an['id_promocji']."'"); if($promocja=='Y' and (!($an['stan']>0))){ mysql_query("update albumy_nosniki set id_promocji=0 where id_nosnika='$nosnik_id' and id_albumu = '$album_id'"); } else if(($promocja=='Y' and $an['stan']>=$ilosc) or $promocja=='N'){ $cena = $db->selectCell("select cena_en from ceny where id_ceny = '".$an['id_ceny_promo']."'"); } } $cena = $db->selectCell("select cena_en from ceny where id_ceny = '".$an['id_ceny']."'"); return $cena; } // end fn } // end class ?> db = $db; $this->customer = $customer; if(array_key_exists('gat_id',$_REQUEST) and $_REQUEST['gat_id']>0){ $ads_id = $this->db->selectRow("select genre_id,ads from genres where genre_id = '".$_REQUEST['gat_id']."'"); $_SESSION['gat_id'] = $ads_id['genre_id']; $_SESSION['ads_id'] = $ads_id['ads']; if(!$ads_id){ $_SESSION['ads_id'] =0; $_SESSION['gat_id']=0; } } else { //if(!(strpos($_SERVER['SCRIPT_FILENAME'],"gatunke.php")===false)){ if(array_key_exists('gat_id',$_REQUEST) and $_REQUEST['gat_id']=='-1'){ $_SESSION['gat_id']=0; $_SESSION['ads_id']=0; header("Location: index.php"); } //} } $this->alb_id = array_key_exists('alb_id',$_REQUEST)?$_REQUEST['alb_id']:0; if($this->alb_id>0){ $this->daj_album(); if($this->album_dane){ $this->opis_ajax(); $this->sample(); } } $this->gatunki_get(); } function album($id){ $album = $this->db->selectRow("select a.*,c.nazwa from albumy a left join czasopisma c on c.id_pisma=a.id_pisma where a.id_albumu = '$id'"); //$album['nosniki']=$this->db->selectTable("select n.nazwa, an.id_ceny,an.id_promocji,an.id_ceny_promo,an.id_promocji,an.stan,an.id_nosnika,an.nr_kat_dyst,an.nr_kat,an.region from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$id' and an.aktywny='T'"); $album['nosniki']=$this->db->selectTable("select n.*,an.* from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$id' and an.aktywny='T'"); $album['wykonawcy']=$this->db->selectTable("select p.id,p.name from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$id' order by ap.id"); $album['gatunki'] = $this->db->selectTable("select g.* from genres g left join albumy_gatunki ag on g.genre_id = ag.id_gatunku where ag.id_albumu = '$id'"); $album['wytwornia'] = $this->db->selectRow("select * from wytwornie where id_wytworni = '".$album['id_wyt']."'"); if($album['id_pisma'] != 0) { $album['pismo'] = $this->db->selectRow("select * from czasopisma where id_pisma = '".$album['id_pisma']."'"); } return $album; } function promocje($l=10,$offset=0){ if(!($offset>=0))$offset=0; if(!($l>0))$l=10; $limit = " limit $offset,$l"; if($_SESSION['gat_id']>0){ $extra = " and albumy_gatunki.id_gatunku='".$_SESSION['gat_id']."' and p.id_promocji>0"; } else { $promocja = $this->db->selectRow("select * from promocje where aktywna='Y' order by rand() limit 1"); $extra = " and p.id_promocji='$promocja[id_promocji]'"; } $pr_albums = $this->db->selectTable("select p.banner,p.nazwa,albumy_gatunki.id_gatunku,albumy.* from albumy inner join albumy_nosniki on albumy.id_albumu = albumy_nosniki.id_albumu inner join albumy_gatunki on albumy_nosniki.id_albumu=albumy_gatunki.id_albumu left join promocje p on albumy_nosniki.id_promocji = p.id_promocji where p.aktywna='Y' and albumy.aktywny='T' and albumy_nosniki.aktywny='T' and albumy.tytul not like '%^^^%' $extra order by rand() $limit"); foreach($pr_albums as $k=>$n) { $pr_albums[$k]['nosniki'] = $this->db->selectTable("select n.nazwa, an.id_ceny,an.id_promocji,an.id_ceny_promo,an.id_promocji,an.stan,an.id_nosnika from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$n[id_albumu]' and an.aktywny='T'"); $pr_albums[$k]['wykonawcy'] = $this->db->selectTable("select p.id,p.name from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$n[id_albumu]' order by ap.id"); } $this->promocje_albumy = $pr_albums; $this->promocja = isset($promocja)?$promocja:null; unset($pr_albums,$promocja); } function cena_nosnik($an){ /* * Array ( [okladka_mini] => okl_10020_m.jpg * [id_albumu] => 10020 * [id_pisma] => 0 * [tytul] => Rock Action * [id_nosnika] => 13 * [nazwa] => CD * [cena_pl] => 48.9 ) */ if(array_key_exists('id_albumu',$an) && $an['id_albumu']>0)$an['album_id'] = $an['id_albumu']; $cena = $this->db->selectCell("select cena_en from ceny where id_ceny = '".$an['id_ceny']."'"); if(($an['id_promocji'] != 0) and ($an['id_ceny_promo'] != 0)){ $pl_promocja = $this->db->selectCell("select do_wyczerp from promocje where id_promocji='".$an['id_promocji']."'"); if($pl_promocja=='Y' and (!($an['stan']>0))){ $this->db->run("update albumy_nosniki set id_promocji=0 where id_nosnika='".$an['id_nosnika']."' and id_albumu = '".$an['album_id']."'"); } else { $cena = $this->db->selectCell("select cena_en from ceny where id_ceny = '".$an['id_ceny_promo']."'"); } } return $cena; } function daj_dostep($an,$id_albumu){ $out = ''; if($an['rodzaj_nosnika'] != 'cyfrowy') { $dost = daj_dostep($id_albumu,$an['id_nosnika']); $opis_en = array_key_exists('opis_en',$dost)?$dost['opis_en']:""; $out = "format: "; $out .= $an['nazwa_en']."
".$opis_en; $out .= "
"; } else { $out = "format: ". $an['nazwa_en'].""; } return $out; } function nowosci_main(){ if($_SESSION['gat_id']>0)$extra=" and albumy_gatunki.id_gatunku='".$_SESSION['gat_id']."'"; $nowosci = $this->db->selectTable("select a.id_albumu from albumy a inner join albumy_gatunki on a.id_albumu=albumy_gatunki.id_albumu where a.nowosc = 'T' and a.polecamy = 'T' and a.aktywny != 'N' and a.tytul not like '%^^^%' $extra group by a.id_albumu order by a.data_edycji_sort desc limit 15"); foreach($nowosci as $k=>$v) { $alb_id = $v['id_albumu']; $nowosci[$k] = $this->album($alb_id); //$nowosci[$k]['wykonawcy'] = $this->db->selectTable("select p.* from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$alb_id' order by ap.id"); //$nowosci[$k]['gatunki'] = $this->db->selectTable("select g.* from genres g left join albumy_gatunki ag on g.genre_id = ag.id_gatunku where ag.id_albumu = '$alb_id'"); //$nowosci[$k]['wytwornia'] = $this->db->selectRow("select * from wytwornie where id_wytworni = '".$v['id_wyt']."'"); //$nowosci[$k]['nosniki'] = $this->db->selectTable("select n.*, an.* from nosniki n left join albumy_nosniki an // on n.id_nosnika = an.id_nosnika where an.id_albumu = '$alb_id' and an.aktywny='T'"); } $this->nowosci = $nowosci; unset($nowosci); } function polecamy_main(){ if($_SESSION['gat_id']>0)$extra=" and albumy_gatunki.id_gatunku='".$_SESSION['gat_id']."'"; $polecane = $this->db->selectTable("select * from albumy inner join albumy_gatunki on albumy.id_albumu=albumy_gatunki.id_albumu where polecamy = 'T' and nowosc != 'T' and aktywny != 'N' and tytul not like '%^^^%' $extra group by albumy.id_albumu order by data_edycji_sort desc limit 15"); foreach($polecane as $k=>$v) { $alb_id = $v['id_albumu']; $polecane[$k]['wykonawcy'] = $this->db->selectTable("select p.* from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$alb_id' order by ap.id"); $polecane[$k]['gatunki'] = $this->db->selectTable("select g.* from genres g left join albumy_gatunki ag on g.genre_id = ag.id_gatunku where ag.id_albumu = '$alb_id'"); $polecane[$k]['wytwornia'] = $this->db->selectRow("select * from wytwornie where id_wytworni = '".$v['id_wyt']."'"); $polecane[$k]['nosniki'] = $this->db->selectTable("select n.*, an.* from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$alb_id' and an.aktywny='T'"); } $this->polecamy = $polecane; unset($polecane); } function bestselery_box($box=0){ $ile_dni_wstecz = 30; $where2 = ""; if($box==0){ $limit = 100; $okres=$_REQUEST['okres']; $gatunek = $_REQUEST['gatunek']; $nosnik = $_REQUEST['nosnik']; if($gatunek>0){ $where1 = " and a.id_gatunku='$gatunek'";} if($nosnik==23){ $where2 = " and k.id_sciezki>0 "; } if($nosnik>0 and $nosnik!=23){ $where2 = " and k.id_nosnika='$nosnik'"; } } else { $limit = 10; if($_SESSION['gat_id']>0)$where1=" and a.id_gatunku='".$_SESSION['gat_id']."'"; } if(!isset($okres))$okres=null; if($okres==1){ //14dni $start = date("Y-m-d",mktime(0,0,0,date('m'),date('d')-14,date('Y'))); } else if($okres==2){ //miesiac $start = date("Y-m-d",mktime(0,0,0,date('m')-1,date('d'),date('Y'))); }else if($okres==3){ //3 miesiace $start = date("Y-m-d",mktime(0,0,0,date('m')-3,date('d'),date('Y'))); }else if($okres==4){ $start = date("Y-m-d",mktime(0,0,0,date('m'),date('d'),date('Y')-1)); } else { $start = date("Y-m-d",mktime(0,0,0,date('m'),date('d')-$ile_dni_wstecz,date('Y'))); } if($_SESSION['gat_id']>0)$extra=" and a.id_gatunku='".$_SESSION['gat_id']."'"; $sql = "select k.id_albumu, k.id_sciezki from koszyk_pozycje k left join albumy_gatunki a on k.id_albumu=a.id_albumu left join albumy al on al.id_albumu=a.id_albumu where al.tytul not like '%^^^%' and k.potwierdzona='Y' and k.id_albumu != 0 and k.data_wstawienia>='$start' $where2 $where1"; //echo $sql; $koszyk = $this->db->selectTable($sql); $liczniki = array(); foreach ($koszyk as $k){ if(!array_key_exists('id_sciezki',$k)){ $liczniki[$k['id_albumu']] = array(); $liczniki[$k['id_albumu']]['licznik'] = 0; $liczniki[$k['id_albumu']]['ile_sciezek'] = 0; } if(!($k['id_sciezki']>0)){ $liczniki[$k['id_albumu']]['licznik']+=1; } else { if($liczniki[$k['id_albumu']]['ile_sciezek']>0){ $liczniki[$k['id_albumu']]['licznik']+=1/$liczniki[$k['id_albumu']]['ile_sciezek']; } else { $liczniki[$k['id_albumu']]['ile_sciezek'] = $this->db->selectCell("select count(*) from tracks where album_id='$k[id_albumu]'"); $liczniki[$k['id_albumu']]['licznik']+=1/$liczniki[$k['id_albumu']]['ile_sciezek']; } } } foreach ($liczniki as $k=>$v)$liczniki[$k] = $v['licznik']; arsort($liczniki); $bestselery = array(); $count = 0; foreach($liczniki as $key=>$b) { $id_albumu = $key; $tmp = array(); $tmp['album'] = $this->db->selectRow("select * from albumy where id_albumu = '$id_albumu' and aktywny='T' and tytul not like '%^^^%'"); $tmp['nosniki'] = $this->db->selectTable("select n.*, an.* from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$id_albumu' and an.aktywny='T'"); if($tmp['album'] and $tmp['nosniki']){ $tmp['wykonawcy'] = $this->db->selectTable("select p.id,p.name from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$id_albumu' order by ap.id"); $tmp['gatunki'] = $this->db->selectTable("select g.* from genres g left join albumy_gatunki ag on g.genre_id = ag.id_gatunku where ag.id_albumu = '$id_albumu'"); $tmp['wytwornia'] = $this->db->selectRow("select * from wytwornie where id_wytworni = '".$tmp['album']['id_wyt']."'"); if($tmp['album']['id_pisma']){ $tmp['album']['pismo'] = $this->db->selectRow("select * from czasopisma where id_pisma = '".$tmp['album']['id_pisma']."'"); } $bestselery[] = $tmp; $count+=1; } if($count>=$limit)break; } $this->bestselery = $bestselery; unset($bestselery); } function gatunki_get(){ $this->gatunki = $this->db->selectTable("select * from genres order by name"); } function kupione_box(){ if($_SESSION['gat_id']>0)$extra=" and a.id_gatunku='".$_SESSION['gat_id']."'"; //$sql = "select distinct(k.id_albumu) from koszyk_pozycje k left join albumy_gatunki a on k.id_albumu=a.id_albumu and k.potwierdzona = 'Y' $extra group by k.id_albumu having k.id_albumu != 0 order by k.id_pozycji desc limit 3"; $sql = "select count(k.id_albumu) as ile, k.id_albumu,k.potwierdzona from koszyk_pozycje k left join albumy_gatunki a on k.id_albumu=a.id_albumu left join albumy al on al.id_albumu=a.id_albumu where al.tytul not like '%^^^%' $extra group by k.id_albumu having k.id_albumu != 0 and k.potwierdzona = 'Y' order by k.id_pozycji desc limit 3"; $kupione = $this->db->selectTable($sql); foreach($kupione as $k=>$a){ $id_albumu = $a['id_albumu']; $kupione[$k]['album'] = $this->db->selectRow("select * from albumy where id_albumu = '$id_albumu' and tytul not like '%^^^%'"); $kupione[$k]['wykonawcy'] = $this->db->selectTable("select p.name,p.id from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$id_albumu' order by ap.id"); } $this->kupione=$kupione; unset($kupione); } function recenzje_box(){ if($_SESSION['gat_id']>0)$extra=" and a.id_gatunku='".$_SESSION['gat_id']."'"; $recki = $this->db->selectTable("select * from recenzje r left join albumy_gatunki a on r.id_albumu=a.id_albumu left join albumy al on al.id_albumu=a.id_albumu where al.tytul not like '%^^^%' $extra group by a.id_albumu order by r.id_recenzji desc limit 4"); foreach($recki as $k=>$r){ $recki[$k]['nazwa'] = $this->db->selectCell("select tytul from albumy where id_albumu='$r[id_albumu]' and tytul not like '%^^^%'"); $recki[$k]['wykonawcy'] = $this->db->selectTable("select p.name,p.id from albumy_perf ap left join performers p on ap.id_perf=p.id where ap.id_albumu='$r[id_albumu]'"); $recki[$k]['autor'] = $this->db->selectRow("select imie,nazwisko from customers where cust_id='$r[id_klienta]'"); } $this->recenzje = $recki; unset($recki); } function sample(){ $alb_id = $this->alb_id; $sample = $_REQUEST['sample']; if($alb_id>0 and !empty($sample)){ if(($this->customer->cust_id)>0){ if(!$this->db->selectRow("select * from sample_powiadomienia where id_klienta='".$this->customer->cust_id."' and id_albumu='$alb_id'")){ $this->db->insert("insert into sample_powiadomienia set id_klienta='".$this->customer->cust_id."',id_albumu='$alb_id'"); } } else { header("Location: logowanie.php"); exit(); } } } function opis_ajax(){ $opis = $_REQUEST['opis'];//opis=1 to opis dlugi, opis=2 to opis krotki $alb_id = $this->alb_id; if($opis=='1'){ echo substr(nl2br($this->album_dane['opis_en']),$this->max_opis); exit(); } if($opis=='2'){ echo substr(nl2br($this->album_dane['opis_krotki']),$this->max_opis); exit(); } } function ocena_ajax(){ if($_REQUEST['ocena']>=0 and $_REQUEST['ocena']<=10 and $alb_id>=0 and isset($_REQUEST['ocena'])){ $ocena = explode(";",$this->album_dane['srednia']); $ocena[0] = $ocena[0]+$_REQUEST['ocena']; $ocena[1] = $ocena[1]+1; mysql_query("update albumy set srednia='".implode(";",$ocena)."' where id_albumu = '".$this->alb_id."'"); print round($ocena[0]/$ocena[1],2);exit(); } } function daj_album(){ $alb_id = $this->alb_id; $this->album_dane = $this->album($alb_id); $this->album_dane['recenzje'] = $this->db->selectTable("select * from recenzje where id_albumu = '$alb_id'"); $this->album_dane['tracks'] = $this->db->selectTable("select * from tracks where album_id = '$alb_id' order by track_order"); $_SESSION['gat_id'] = $this->album_dane['gatunki'][0]['genre_id']; $_SESSION['ads_id'] =$this->db->selectCell("select ads from genres where genre_id = '".$_SESSION['gat_id']."'"); $kraje = explode(";",$this->album_dane['kraje_zabr']); foreach($kraje as $k){ if($k>0 and $k==$this->customer->geoip)$this->pliki_zabronione=true; } $this->rozmiar = ''; if(isset($_REQUEST['rozmiar'])) $this->rozmiar = $_REQUEST['rozmiar']; $this->inne_kupili(); } function inne_kupili(){ $alb_id = $this->alb_id; $klienci = $this->db->selectTable("select distinct(id_klienta) from koszyk_pozycje where order_id!='' and id_nosnika!='0' and id_albumu='$alb_id'"); if(count($klienci)){ foreach($klienci as $k){$kl[] = $k['id_klienta'];} $klienci = implode(", ",$kl); $tmp = $this->db->selectTable("select distinct(id_albumu) from koszyk_pozycje where order_id!='' and id_nosnika!='0' and id_albumu!=0 and id_albumu!='$alb_id' and id_klienta in ($klienci) order by rand() limit 6"); $inne = array(); foreach($tmp as $key=>$val){ $alb_id = $val['id_albumu']; $inne[$key] = $this->db->selectRow("select * from albumy where id_albumu='$alb_id' and aktywny='T' and tytul not like '%^^^%'"); $inne[$key]['wykonawcy'] = $this->db->selectTable("select p.* from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$alb_id' order by ap.id"); $inne[$key]['gatunki'] = $this->db->selectTable("select g.* from genres g left join albumy_gatunki ag on g.genre_id = ag.id_gatunku where ag.id_albumu = '$alb_id'"); $inne[$key]['wytwornia'] = $this->db->selectRow("select * from wytwornie where id_wytworni = '".$inne[$key]['id_wyt']."'"); $inne[$key]['nosniki'] = $this->db->selectTable("select n.*, an.* from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$alb_id' and an.aktywny='T'"); } $this->inne = $inne; } } function meta_keywords($typ=0){ if($typ=='1'){ $out = 'album_dane['kompozytor']!='')$out.=",".$album['kompozytor']; if($this->album_dane['rezyser'] != '')$out.=",".$album['rezyser']; unset($wy); foreach($this->album_dane['gatunki'] as $w){$wy[]=$w['name'];} if(count($wy))$out.=",".implode(",",$wy); $out.=",".$this->album_dane['wytwornia']['nazwa']; $out.=",".$this->album_dane['tytul']; $out.=',mp3">album_dane['kompozytor']!='')$out.=",".$this->album_dane['kompozytor']; if($this->album_dane['rezyser'] != '')$out.=",".$this->album_dane['rezyser']; unset($wy); foreach($this->album_dane['gatunki'] as $w){$wy[]=$w['name'];} if(count($wy))$out.=",".implode(",",$wy); $out.=",".$this->album_dane['wytwornia']['nazwa']; $out.=",".$this->album_dane['tytul']; $out.=',mp3 available at www.serpent.pl">'; $this->metatag=$out; if(is_array($wr)){ $this->title = implode(",",$wr); if($this->album_dane['tytul'])$this->title.=" - "; } $this->title.=$this->album_dane['tytul']; }else{ $this->metatag=''; $this->title=''; } } function check_promotion($id_albumu,$id_nosnika){ $no = $this->db->selectRow("select * from albumy_nosniki where id_albumu='$id_albumu' and id_nosnika='$id_nosnika'"); if(($no['id_promocji'] != 0) and ($no['id_ceny_promo'] != 0)){ $pl_promocja = $this->db->selectCell("select do_wyczerp from promocje where id_promocji='".$no['id_promocji']."'"); if($pl_promocja=='Y' and (!($no['stan']>0))){ $this->db->run("update albumy_nosniki set id_promocji=0 where id_nosnika='".$no['id_nosnika']."' and id_albumu = '".$no['album_id']."'"); } } } } ?>albumy = $oAlbumy; $this->db = $db; $this->next=0; } function utwor_search($page){ $this->strona = $page; $limit = 20; $searchstring = $_REQUEST['searchstring']; if($_SESSION['searchstring'] and !$searchstring){ $searchstring = $_SESSION['searchstring']; } else { $_SESSION['searchstring']=$searchstring; } $offset=$limit*$page; $real_limit = $limit*3; $q = "select * from tracks left join albumy on tracks.album_id=albumy.id_albumu where albumy.aktywny='T' and tracks.title like '%$searchstring%' and tracks.title != '' and albumy.tytul not like '%^^^%' order by title limit $offset,$real_limit"; $tracks = $this->db->selectTable($q); $trackscount = count($tracks); $ile = ceil($trackscount/$limit); $this->from = $page-2;if($this->from<0)$this->from=0; $this->to = $page+$ile; $tracks = array_slice($tracks,0,$limit); foreach($tracks as $k=>$t) { $alb_id = $t['album_id']; $tracks[$k]['album'] = $this->db->selectRow("select * from albumy where id_albumu = '$alb_id'"); $tracks[$k]['wykonawcy'] = $this->db->selectTable("select p.* from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$alb_id' order by ap.id"); } if(!count($tracks)>0)$this->msg.="Sorry, there is no song title with: '$searchstring'"; $this->wyniki=$tracks; $this->typ="tracks"; } function wykonawca_search($page){ $searchstring = $_REQUEST['searchstring']; if($_SESSION['searchstring'] and !$searchstring){ $searchstring = $_SESSION['searchstring']; } else { $_SESSION['searchstring']=$searchstring; } $where = " and (p.keywords like '%".$searchstring."%' or p.keywords_txt like '%".$searchstring."%' or a.slowa_kluczowe_wyk like '%$searchstring%')"; $q = "select distinct(p.id) from performers p left join albumy_perf ap on ap.id_perf=p.id left join albumy a on ap.id_albumu=a.id_albumu where a.aktywny='T' and p.showd != 'N' and a.tytul not like '%^^^%' $where group by ap.id_albumu order by p.name"; $powiazani = $this->db->selectTable($q); $this->wyniki= $this->db->selectTable("select * from performers where name like '%$searchstring%' order by name"); $id = array(); foreach($powiazani as $k=>$p) { $id[]=$p['id']; //} //$performers[$k]['own_albums'] = $own_albums; } if(count($powiazani)>0){ $this->powiazani=$this->db->selectTable("select * from performers where id in (".implode(",",$id).")"); } if(!count($this->powiazani)>0 and !count($this->wyniki)>0){ $this->msg .= "Sorry, there is no artis name contains: '$searchstring'."; } $this->typ='performers'; } function wykonawca_czasopismo_search($page){ $this->strona = $page; $limit = 20; // wyszukiwanie w albumach $searchstring = $_REQUEST['searchstring']; if($_SESSION['searchstring'] and !$searchstring){ $searchstring = $_SESSION['searchstring']; } else { $_SESSION['searchstring']=$searchstring; } $offset=$limit*$page; $real_limit = $limit*3; $q = "select id_albumu from albumy a left join czasopisma p on p.id_pisma=a.id_pisma where (p.nazwa like '%$searchstring%' or p.slowa_kluczowe like '%$searchstring%') and a.aktywny='T' and a.tytul not like '%^^^%' order by data_edycji_sort desc limit $offset,$real_limit"; $albums = $this->db->selectTable($q); $albumcount = count($albums); $ilestron = ceil($albumcount/$limit); $this->from = $page-2;if($this->from<0)$this->from=0; $this->to = $page+$ilestron; $albums = array_slice($albums,0,$limit); foreach($albums as $k=>$n) { $alb_id = $n['id_albumu']; $albums[$k] = $this->albumy->album($alb_id); //$albums[$k]['nosniki'] = $this->db->selectTable("select n.*, an.* from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$alb_id' and an.aktywny='T'"); //$albums[$k]['wykonawcy'] = $this->db->selectTable("select p.* from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$alb_id' order by ap.id"); //$albums[$k]['gatunki'] = $this->db->selectTable("select g.* from genres g left join albumy_gatunki ag on g.genre_id = ag.id_gatunku where ag.id_albumu = '$alb_id'"); //$albums[$k]['wytwornia'] = $this->db->selectRow("select * from wytwornie where id_wytworni = '".$n['id_wyt']."'"); } if(!count($albums)>0)$this->msg.="Sorry, there is no magazine name contains: '$searchstring'"; $this->wyniki = $albums; $this->typ = 'albums'; unset($albums); } function album_search_all($page){ $this->strona = $page; $limit = 20; // wyszukiwanie w albumach $searchstring = $_REQUEST['searchstring']; $searchstring=str_replace ("[","",$searchstring); $searchstring=str_replace ("]","",$searchstring); $searchstring=str_replace ("<"," ",$searchstring); $searchstring=str_replace (">"," ",$searchstring); $searchstring=str_replace (":"," ",$searchstring); $keywords = explode(' ', $searchstring); if ($searchstring){ $wykonawca_check = 1; $_SESSION['wykonawca_check']=$wykonawca_check; $album_check = 1; $_SESSION['album_check']=$album_check; $utwor_check = 1; $_SESSION['utwor_check']=$utwor_check; $wytwornia_check=1; $_SESSION['wytwornia_check']=$wytwornia_check; $nosnik_check[1]=26; $nosnik_check[2]=13; $nosnik_check[3]=18; $nosnik_check[4]=20; $nosnik_check[5]=17; $nosnik_check[6]=19; $nosnik_check[7]=25; $nosnik_check[8]=22; $nosnik_check[9]=12; $nosnik_check[10]=24; $nosnik_check[11]=21; $nosnik_check[12]=27; $nosnik_check[13]=23; $nosnik_check[14]=14; $_SESSION['nosnik_check']=$nosnik_check; } $filtr_check = $_REQUEST['filtr_check']; if ($filtr_check){ $wykonawca_check = (int)$_REQUEST['wykonawca_check']; $_SESSION['wykonawca_check']=$wykonawca_check; $album_check = (int)$_REQUEST['album_check']; $_SESSION['album_check']=$album_check; $utwor_check = (int)$_REQUEST['utwor_check']; $_SESSION['utwor_check']=$utwor_check; $wytwornia_check = (int)$_REQUEST['wytwornia_check']; $_SESSION['wytwornia_check']=$wytwornia_check; $nosnik_check = $_REQUEST['nosnik_check']; $_SESSION['nosnik_check']=$nosnik_check; } else{ $wykonawca_check = $_SESSION['wykonawca_check']; $album_check = $_SESSION['album_check']; $utwor_check = $_SESSION['utwor_check']; $wytwornia_check = $_SESSION['wytwornia_check']; $nosnik_check = $_SESSION['nosnik_check']; } if (!$wykonawca_check && !$album_check && !$utwor_check && !$opis_check && !$wytwornia_check && !$nosnik_check[1] && !$nosnik_check[2] && !$nosnik_check[3] && !$nosnik_check[4] && !$nosnik_check[5] && !$nosnik_check[6] && !$nosnik_check[7] && !$nosnik_check[8] && !$nosnik_check[9] && !$nosnik_check[10] && !$nosnik_check[11] && !$nosnik_check[12] && !$nosnik_check[13] && !$nosnik_check[14]){ $wykonawca_check = 1; $album_check = 1; $utwor_check = 1; $wytwornia_check=1; $nosnik_check[1]=26; $nosnik_check[2]=13; $nosnik_check[3]=18; $nosnik_check[4]=20; $nosnik_check[5]=17; $nosnik_check[6]=19; $nosnik_check[7]=25; $nosnik_check[8]=22; $nosnik_check[9]=12; $nosnik_check[10]=24; $nosnik_check[11]=21; $nosnik_check[12]=27; $nosnik_check[13]=23; $nosnik_check[14]=14; } if($_SESSION['searchstring'] and !$searchstring){ $searchstring = $_SESSION['searchstring']; } else { $_SESSION['searchstring']=$searchstring; } $offset=$limit*$page; $real_limit = $limit*3; $keywords = explode(' ', $searchstring); $q = "select DISTINCT(a.id_albumu) from albumy a left join czasopisma p on p.id_pisma=a.id_pisma left join wytwornie w on w.id_wytworni=a.id_wyt left join albumy_perf ap on ap.id_albumu=a.id_albumu left join performers pe on pe.id=ap.id_perf left join tracks t on t.album_id=a.id_albumu left join albumy_nosniki n on n.id_albumu=a.id_albumu where"; for ($i=0;$i:]]' OR a.slowa_kluczowe REGEXP '[[:<:]]".$keywords[$i]."[[:>:]]' OR "; if ($wykonawca_check) $q.="a.slowa_kluczowe_wyk REGEXP '[[:<:]]".$keywords[$i]."[[:>:]]' OR a.kompozytor REGEXP '[[:<:]]".$keywords[$i]."[[:>:]]' OR "; if ($album_check) $q.="p.nazwa REGEXP '[[:<:]]".$keywords[$i]."[[:>:]]' OR p.slowa_kluczowe REGEXP '[[:<:]]".$keywords[$i]."[[:>:]]' OR "; if ($wytwornia_check) $q.="w.nazwa REGEXP '[[:<:]]".$keywords[$i]."[[:>:]]' OR "; if ($wykonawca_check) $q.="pe.name REGEXP '[[:<:]]".$keywords[$i]."[[:>:]]' OR pe.keywords REGEXP '[[:<:]]".$keywords[$i]."[[:>:]]' OR pe.keywords_txt REGEXP '[[:<:]]".$keywords[$i]."[[:>:]]' OR "; if ($utwor_check) $q.="t.title REGEXP '[[:<:]]".$keywords[$i]."[[:>:]]' OR t.wykonawca REGEXP '[[:<:]]".$keywords[$i]."[[:>:]]' OR "; if ($album_check) $q.="a.tytul like '%".$keywords[$i]."%' OR a.slowa_kluczowe like '%".$keywords[$i]."%' OR "; if ($wykonawca_check) $q.="a.slowa_kluczowe_wyk like '%".$keywords[$i]."%' OR a.kompozytor like '%".$keywords[$i]."%' OR "; if ($album_check) $q.="p.nazwa like '%".$keywords[$i]."%' OR p.slowa_kluczowe like '%".$keywords[$i]."%' OR "; if ($wytwornia_check) $q.="w.nazwa like '%".$keywords[$i]."%' OR "; if ($wykonawca_check) $q.="pe.name like '%".$keywords[$i]."%' OR pe.keywords like '%".$keywords[$i]."%' OR pe.keywords_txt like '%".$keywords[$i]."%' OR "; if ($utwor_check) $q.="t.title like '%".$keywords[$i]."%' OR t.wykonawca like '%".$keywords[$i]."%' OR "; $q.=" 1=2) AND "; } } if (!is_array($nosnik_check))$nosnik_check[0]=0; $nosniki = implode(",",array_map('intval',$nosnik_check)); $q.=" n.id_nosnika in (".$nosniki.") AND "; $q.=" a.aktywny='T' and a.tytul not like '%^^^%' order by a.data_edycji_sort desc limit 1000"; $albums = $this->db->selectTable($q); $albumcount = count($albums); $ilestron = ceil($albumcount/$limit); $this->from = $page-2;if($this->from<0)$this->from=0; $this->to = $page+$ilestron; foreach($albums as $k=>$n) { $alb_id = $n['id_albumu']; $albums[$k] = $this->albumy->album($alb_id); $albums[$k]['nosniki'] = $this->db->selectTable("select n.*, an.* from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$alb_id' and an.aktywny='T'"); foreach($albums[$k]['nosniki'] as $an) { if (!$nosniki_filtr[$an['id_nosnika']])$nosniki_filtr[$an['id_nosnika']]=1; else $nosniki_filtr[$an['id_nosnika']]++; } $albums[$k]['wykonawcy'] = $this->db->selectTable("select p.* from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$alb_id' order by ap.id"); foreach($albums[$k]['wykonawcy'] as $an) { $nosniki_filtr['wykonawcy'][$an['id']]=$an['name']; } } $_SESSION['nosniki_filtr']=$nosniki_filtr; $albums = array_slice($albums,$offset,$limit); if(!count($albums)>0)$this->msg.="Sorry, there is no album contains: '$searchstring'"; $this->wyniki = $albums; $this->typ = 'albums'; unset($albums); } function album_search($page){ $this->strona = $page; $limit = 20; // wyszukiwanie w albumach $searchstring = $_REQUEST['searchstring']; if($_SESSION['searchstring'] and !$searchstring){ $searchstring = $_SESSION['searchstring']; } else { $_SESSION['searchstring']=$searchstring; } $offset=$limit*$page; $real_limit = $limit*3; $q = "select id_albumu from albumy where (tytul like '%$searchstring%' or slowa_kluczowe like '%$searchstring%' or slowa_kluczowe_wyk like '%$searchstring%') and aktywny='T' and tytul not like '%^^^%' order by data_edycji_sort desc limit $offset,$real_limit"; $albums = $this->db->selectTable($q); $albumcount = count($albums); $ilestron = ceil($albumcount/$limit); $this->from = $page-2;if($this->from<0)$this->from=0; $this->to = $page+$ilestron; $albums = array_slice($albums,0,$limit); foreach($albums as $k=>$n) { $alb_id = $n['id_albumu']; $albums[$k] = $this->albumy->album($alb_id); //$albums[$k]['nosniki'] = $this->db->selectTable("select n.*, an.* from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$alb_id' and an.aktywny='T'"); //$albums[$k]['wykonawcy'] = $this->db->selectTable("select p.* from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$alb_id' order by ap.id"); //$albums[$k]['gatunki'] = $this->db->selectTable("select g.* from genres g left join albumy_gatunki ag on g.genre_id = ag.id_gatunku where ag.id_albumu = '$alb_id'"); //$albums[$k]['wytwornia'] = $this->db->selectRow("select * from wytwornie where id_wytworni = '".$n['id_wyt']."'"); } if(!count($albums)>0)$this->msg.="Sorry, there is no album name contains: '$searchstring'"; $this->wyniki = $albums; $this->typ = 'albums'; unset($albums); } function wytwornia_search($page){ $this->strona=$page; //$limit = 20; $searchstring = $_REQUEST['searchstring']; if($_SESSION['searchstring'] and !$searchstring){ $searchstring = $_SESSION['searchstring']; } else { $_SESSION['searchstring']=$searchstring; } $offset=$limit*$page; $real_limit = $limit*3; $q = "select * from wytwornie where nazwa like '%$searchstring%' order by nazwa"; $wytw = $this->db->selectTable($q); /*$wytwcount = count($wytw); $ilestron = ceil($wytwcount/$limit); $this->from = $page-2;if($this->from<0)$this->from=0; $this->to = $page+$ilestron; $wytw = array_slice($wytw,0,$limit); foreach($wytw as $k=>$w) { $albumy = $this->db->selectTable("select distinct(a.id_albumu),a.*,c.nazwa as nazwa_pisma from albumy a left join albumy_nosniki an on a.id_albumu=an.id_albumu left join czasopisma c on a.id_pisma=c.id_pisma where a.id_wyt = '".$w['id_wytworni']."' or an.id_wydawcy='$w[id_wytworni]' and a.aktywny='T' and an.aktywny='T' group by a.id_albumu"); foreach($albumy as $kl=>$al) { $alb_id = $al['id_albumu']; $albumy[$kl]['wykonawcy'] = $this->db->selectTable("select p.* from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$alb_id' order by ap.id"); } $wytw[$k]['albumy'] = $albumy; }*/ if(!count($wytw)>0)$this->msg.="Sorry, there is no label name contains: '$searchstring'"; $this->wyniki=$wytw; $this->typ="wytwornia"; } function advance_search($page){ $this->strona=$page; $limit = 20; $dane = serialize($_REQUEST); if($_SESSION['dane'] and !$_REQUEST['typ']){ $dane = $_SESSION['dane']; } else { $_SESSION['dane']=$dane; } $dane = unserialize($dane); $offset=$limit*$page; $real_limit = $limit*3; $pola = array('alb_rok','wyk_nazwa','alb_nazwa','utw_nazwa','wyt_nazwa','nastanie','id_nosnika','id_wytworni','wyk_id','gat_id'); foreach($pola as $p) { if(array_key_exists($p,$dane)) { $$p = $dane[$p]; } } $an_cls = array(); $msg = "Sorry, there are no results for: :
"; if($wyk_nazwa != '' or $wyk_id>0){ $msg .= "Wykonawca/kompozytor/autor/czasopismo: $wyk_nazwa
"; //" albumy.kompozytor like '%$wyk_nazwa%' "; // szukanie wykonawcy wg nazwy // -> i albumow tego wykonawcy // -> oraz tych ktore maja wykonawce w slowach kluczowych if($wyk_id>0){ $q = "select distinct(ap.id_albumu) from performers p left join albumy_perf ap on p.id=ap.id_perf where p.id='$wyk_id'"; } else { $q = "select distinct(ap.id_albumu) from performers p left join albumy_perf ap on p.id=ap.id_perf where p.name like '%$wyk_nazwa%' or p.keywords like '%$wyk_nazwa%' or p.keywords_txt like '%$wyk_nazwa%'"; } $perfs = $this->db->selectTable($q); if(!$wyk_id>0){ $q = "select distinct(id_albumu) from albumy where kompozytor like '%$wyk_nazwa%' and tytul not like '%^^^%'"; $perfs = array_merge($perfs,$this->db->selectTable($q)); } if($wyk_id>0){ $q = "select distinct(a.id_albumu) from czasopisma c left join albumy a on c.id_pisma=a.id_pisma where c.id_pisma='$wyk_id' and a.tytul not like '%^^^%'"; } else { $q = "select distinct(a.id_albumu) from czasopisma c left join albumy a on c.id_pisma=a.id_pisma where (c.nazwa like '%$wyk_nazwa%' or a.kompozytor like '%$wyk_nazwa%') and a.tytul not like '%^^^%'"; } $pisma = $this->db->selectTable($q); $alb_perfs = array(); if(count($pisma)) { foreach($pisma as $v) { if($v['id_albumu']>0)$alb_perfs[] = $v['id_albumu']; } } if(count($perfs)) { foreach($perfs as $v) { if($v['id_albumu']>0)$alb_perfs[] = $v['id_albumu']; } } if($wyk_id>0){ $q = "select name from performers where id='$wyk_id'"; } else { $q = "select name from performers where name like '%$wyk_nazwa%'"; } $wyk_tmp = $this->db->selectTable($q); $wyk=array(); if(count($wyk_tmp)) foreach($wyk_tmp as $v) { $wyk[] = "'".$v['name']."'"; } if(count($wyk)>0){ $wyk = implode(",",$wyk); $q = "select distinct(album_id) from tracks where wykonawca in ($wyk)"; $track_perfs = $this->db->selectTable($q); if(count($track_perfs)) foreach($track_perfs as $v) { if($v['album_id']>0)$alb_perfs[] = $v['album_id']; } } if($alb_perfs)$an_cls[] = " albumy.id_albumu in (".join(",",$alb_perfs).") "; else " albumy.id_albumu=0 "; unset($pisma,$perfs,$q); } if($alb_nazwa != '') { $msg .= "Nazwa albumu: $alb_nazwa
"; $an_cls[] = " albumy.tytul like '%$alb_nazwa%' "; } if($utw_nazwa!=''){ $msg .= "Nazwa utworu: $utw_nazwa
"; $q = "select distinct(album_id) from tracks where title like '%$utw_nazwa%' and title != ''"; $tracks=$this->db->selectTable($q); $alb_tr = array(); if($tracks)foreach ($tracks as $t)$alb_tr[] = $t['album_id']; if($alb_tr)$an_cls[] = " albumy.id_albumu in (".join(",",$alb_tr).") "; else " albumy.id_albumu=0 "; unset($tracks,$alb_tr,$q); } if($wyt_nazwa != '' or $id_wytworni>0) { if($wyt_nazwa!=''){ $msg .= "Wytw�rnia: $wyt_nazwa
"; $q = "select id_wytworni from wytwornie where nazwa like '%$wyt_nazwa%'"; $wts = $this->db->selectTable($q); foreach($wts as $w) { $ids[] = $w['id_wytworni']; } } if($id_wytworni>0)$ids[] = $id_wytworni; if(count($ids)){ $nosniki_a = $this->db->selectTable("select distinct(id_albumu) from albumy_nosniki where id_wydawcy in (".implode(",",$ids).")"); $nosniki = array(); foreach($nosniki_a as $n)$nosniki[] = $n['id_albumu']; if($nosniki){ $an_cls[] = " (albumy.id_wyt in(".implode(",",$ids).") or albumy.id_albumu in (".implode(",",$nosniki)."))"; } else { $an_cls[] = " albumy.id_wyt in(".implode(",",$ids).")"; } unset($nosniki_a,$nosniki); } } if($alb_rok != ''){ $msg.="Rok wydania: $alb_rok
"; $an_cls[] = " albumy.rok_wydania = '$alb_rok'"; } if($nastanie == 'T') { $msg.="Na stanie: tak
"; $q = "select id_albumu from albumy_nosniki where stan > 0 and aktywny='T'"; $anids = $this->db->selectTable($q); foreach($anids as $v) { $ans[] = $v['id_albumu']; } if(count($ans)) $an_cls[] = " albumy.id_albumu in(".implode(",",$ans).")"; else " albumy.id_albumu=0 "; } if($id_nosnika != 0) { if($id_nosnika == -1) { $nosnikplik = $this->db->selectCell("select id_nosnika from nosniki where id_nosnika = '23'"); $id_nosnika = $nosnikplik; } $msg.="format: '".$this->db->selectCell("select nazwa from nosniki where id_nosnika='$id_nosnika'")."'
"; $q = "select id_albumu from albumy_nosniki where id_nosnika = '$id_nosnika' and aktywny='T'"; $awn = $this->db->selectTable($q); foreach($awn as $v) { $awns[] = $v['id_albumu']; } if(count($awns)) $an_cls[] = " albumy.id_albumu in(".implode(",",$awns).")"; else " albumy.id_albumu=0 "; } if(count($gat_id)>0) { foreach($gat_id as $gid) { $q = "select ag.id_albumu,g.name from albumy_gatunki ag left join genres g on ag.id_gatunku=g.genre_id where ag.id_gatunku = '$gid'"; //echo $q; $w = $this->db->selectTable($q); $str.=$w[0]['name']." "; foreach($w as $v) { $ags[] = $v['id_albumu']; } } $msg.="Gatunki: ".$str; if(count($ags)) $an_cls[] = " albumy.id_albumu in(".implode(",",$ags).")"; else " albumy.id_albumu=0 "; unset($q,$ags,$w); } if(count($an_cls)) $ancls = join("and",$an_cls); if($ancls != '') { $q = "select id_albumu from albumy where $ancls and albumy.aktywny = 'T' and albumy.tytul not like '%^^^%' order by albumy.data_edycji_sort desc limit $offset,$real_limit";//order by albumy.tytul asc limit $offset,$real_limit"; //echo $q; $albums = $this->db->selectTable($q); } else { $albums = array(); } //$albums = $this->db->selectTable($q); $albcount = count($albums); $ilestron = ceil($albcount/$limit); $this->from = $page-2;if($this->from<0)$this->from=0; $this->to = $page+$ilestron; $albums = array_slice($albums,0,$limit); foreach($albums as $k=>$n) { $alb_id = $n['id_albumu']; $albums[$k] = $this->albumy->album($alb_id); } $this->wyniki = $albums; $this->typ='advance'; if(!count($albums)>0)$this->msg = $msg; } function pasek_search($page){ $this->strona = $page; $limit = 20; // wyszukiwanie w albumach $podtyp = $_REQUEST['podtyp']; if($_SESSION['podtyp'] and !$podtyp){ $podtyp = $_SESSION['podtyp']; } else { $_SESSION['podtyp']=$podtyp; } $offset=$limit*$page; $real_limit = $limit*3; if($podtyp=='1'){ //ostatnio dodane $q = "select id_albumu from albumy where aktywny='T' and tytul not like '%^^^%' order by id_albumu desc limit $offset,$real_limit"; } else if ($podtyp=='2') { //nowosci $q = "select id_albumu from albumy where nowosc='T' and aktywny='T' and tytul not like '%^^^%' order by data_edycji_sort desc limit $offset,$real_limit"; } elseif ($podtyp=='3'){ //polecamy $q = "select id_albumu from albumy where polecamy='T' and nowosc!='T' and aktywny='T' and tytul not like '%^^^%' order by data_edycji_sort desc limit $offset,$real_limit"; } else { $q = "select id_albumu from albumy where aktywny='T' and albumy.tytul not like '%^^^%' order by data_edycji_sort desc limit $offset,$real_limit"; } $albums = $this->db->selectTable($q); $albumcount = count($albums); $ilestron = ceil($albumcount/$limit); $this->from = $page-2;if($this->from<0)$this->from=0; $this->to = $page+$ilestron; $albums = array_slice($albums,0,$limit); foreach($albums as $k=>$n) { $alb_id = $n['id_albumu']; $albums[$k] = $this->albumy->album($alb_id); //$albums[$k]['nosniki'] = $this->db->selectTable("select n.*, an.* from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$alb_id' and an.aktywny='T'"); //$albums[$k]['wykonawcy'] = $this->db->selectTable("select p.* from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$alb_id' order by ap.id"); //$albums[$k]['gatunki'] = $this->db->selectTable("select g.* from genres g left join albumy_gatunki ag on g.genre_id = ag.id_gatunku where ag.id_albumu = '$alb_id'"); //$albums[$k]['wytwornia'] = $this->db->selectRow("select * from wytwornie where id_wytworni = '".$n['id_wyt']."'"); } $this->wyniki = $albums; $this->typ = 'albums'; unset($albums); } function promocje($page){ $this->strona = $page; $limit = 5; // wyszukiwanie w albumach $podtyp = $_REQUEST['podtyp']; if($_SESSION['podtyp'] and !$podtyp){ $podtyp = $_SESSION['podtyp']; } else { $_SESSION['podtyp']=$podtyp; } $offset=$limit*$page; $real_limit = $limit*3; $promocje = $this->db->selectTable("select id_promocji,banner,nazwa,opis,do_kiedy,do_wyczerp from promocje where aktywna='Y' order by data_sort desc limit $offset,$real_limit"); $promcount = count($promocje); $ilestron = ceil($promcount/$limit); $this->from = $page-2;if($this->from<0)$this->from=0; $this->to = $page+$ilestron; $promocje = array_slice($promocje,0,$limit); foreach($promocje as $id=>$promo){ if($_SESSION['typ']=='6'){ $promocje[$id]['nosniki'] = $this->db->selectTable(" select a.okladka_mini,a.id_albumu,a.id_pisma,a.tytul,an.id_nosnika,n.nazwa,c.cena_pl,p.nazwa as nazwa_pisma from albumy_nosniki an left join albumy a on an.id_albumu=a.id_albumu left join nosniki n on an.id_nosnika=n.id_nosnika left join ceny c on an.id_ceny_promo=c.id_ceny left join czasopisma p on p.id_pisma=a.id_pisma left join albumy_perf ap on ap.id_albumu = a.id_albumu left join performers pr on pr.id = ap.id_perf where a.id_albumu>0 and an.id_ceny_promo>0 and a.aktywny='T' and an.id_promocji = '".$promo['id_promocji']."' and an.aktywny='T' and a.tytul not like '%^^^%' order by pr.name asc, a.data_edycji_sort desc"); } else { $promocje[$id]['nosniki'] = $this->db->selectTable(" select a.okladka_mini,a.id_albumu,a.id_pisma,a.tytul,an.id_nosnika,n.nazwa,c.cena_pl,p.nazwa as nazwa_pisma from albumy_nosniki an left join albumy a on an.id_albumu=a.id_albumu left join nosniki n on an.id_nosnika=n.id_nosnika left join ceny c on an.id_ceny_promo=c.id_ceny left join czasopisma p on p.id_pisma=a.id_pisma left join albumy_perf ap on ap.id_albumu = a.id_albumu left join performers pr on pr.id = ap.id_perf where a.id_albumu>0 and an.id_ceny_promo>0 and a.aktywny='T' and an.id_promocji = '".$promo['id_promocji']."' and an.aktywny='T' and a.tytul not like '%^^^%' order by pr.name asc, a.data_edycji_sort desc limit 3"); } foreach($promocje[$id]['nosniki'] as $key=>$val){ $id_alb = $promocje[$id]['nosniki'][$key]['id_albumu']; $id_nos = $promocje[$id]['nosniki'][$key]['id_nosnika']; $promocje[$id]['nosniki'][$key]['wykonawcy'] = $this->db->selectTable("select p.id,p.name from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$id_alb' order by ap.id"); $promocje[$id]['nosniki'][$key]['gatunki'] = $this->db->selectTable("select g.* from genres g left join albumy_gatunki ag on g.genre_id = ag.id_gatunku where ag.id_albumu = '$id_alb'"); $promocje[$id]['nosniki'][$key]['nosnik'] = $this->db->selectRow("select n.nazwa, an.id_ceny,an.id_promocji,an.id_ceny_promo,an.id_promocji,an.stan,an.id_nosnika from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$id_alb' and an.id_nosnika='$id_nos' and an.aktywny='T'"); } } $this->wyniki = $promocje; } function promocja($page){ $this->strona = $page; $limit = 20; // wyszukiwanie w albumach $id = $_REQUEST['id']; if($_SESSION['id'] and !$id){ $id = $_SESSION['id']; } else { $_SESSION['id']=$id; } $offset=$limit*$page; $real_limit = $limit*3; $promocja = $this->db->selectRow("select id_promocji,banner,nazwa,opis,do_kiedy,do_wyczerp from promocje where id_promocji='$id' order by data_sort,id_promocji desc "); $promocja['nosniki'] = $this->db->selectTable( "SELECT DISTINCT a.okladka_mini,a.id_albumu,a.id_pisma,a.tytul,an.id_nosnika,n.nazwa,c.cena_pl,p.nazwa as nazwa_pisma from albumy_nosniki an left join albumy a on an.id_albumu=a.id_albumu left join nosniki n on an.id_nosnika=n.id_nosnika left join ceny c on an.id_ceny_promo=c.id_ceny left join czasopisma p on p.id_pisma=a.id_pisma left join albumy_perf ap on (a.id_albumu = ap.id_albumu and ap.id_perf>0) left join performers pe on pe.id = ap.id_perf where a.id_albumu>0 and an.id_ceny_promo>0 and a.aktywny='T' and an.id_promocji = '".$promocja['id_promocji']."' and an.aktywny='T' and a.tytul not like '%^^^%'order by pe.name, a.tytul, a.data_edycji_sort desc limit $offset,$real_limit"); $promcount = count($promocja['nosniki']); $ilestron = ceil($promcount/$limit); $this->from = $page-2;if($this->from<0)$this->from=0; $this->to = $page+$ilestron; $promocja['nosniki'] = array_slice($promocja['nosniki'],0,$limit); foreach($promocja['nosniki'] as $key=>$val){ $id_alb = $promocja['nosniki'][$key]['id_albumu']; $id_nos = $promocja['nosniki'][$key]['id_nosnika']; $promocja['nosniki'][$key]['wykonawcy'] = $this->db->selectTable("select p.id,p.name from performers p left join albumy_perf ap on p.id = ap.id_perf where ap.id_albumu = '$id_alb' order by ap.id"); $promocja['nosniki'][$key]['gatunki'] = $this->db->selectTable("select g.* from genres g left join albumy_gatunki ag on g.genre_id = ag.id_gatunku where ag.id_albumu = '$id_alb'"); $promocja['nosniki'][$key]['nosnik'] = $this->db->selectRow("select n.nazwa, an.id_ceny,an.id_promocji,an.id_ceny_promo,an.id_promocji,an.stan,an.id_nosnika from nosniki n left join albumy_nosniki an on n.id_nosnika = an.id_nosnika where an.id_albumu = '$id_alb' and an.id_nosnika='$id_nos' and an.aktywny='T'"); } $this->wyniki=$promocja; } function wykonawca_site($page=0){ //$this->strona=$page; //$limit = 20; $dane = serialize($_REQUEST); if($_SESSION['dane'] and !$_REQUEST['typ']){ $dane = $_SESSION['dane']; } else { $_SESSION['dane']=$dane; } $dane = unserialize($dane); //$offset=$limit*$page; //$real_limit = $limit*3; $pola = array('wyk_id'); foreach($pola as $p) { if(array_key_exists($p,$dane)) { $$p = $dane[$p]; } } $an_cls = array(); $msg = "Unfortunately there are no results fit to:
"; if($wyk_id>0){ $wykonawca= $this->db->selectRow("select * from performers where id='$wyk_id'"); $wykonawca['name'] = mysql_real_escape_string($wykonawca['name']); $msg .= "Wykonawca/kompozytor/autor/czasopismo: $wykonawca[name]
"; //" albumy.kompozytor like '%$wyk_nazwa%' "; // szukanie wykonawcy wg nazwy // -> i albumow tego wykonawcy // -> oraz tych ktore maja wykonawce w slowach kluczowych $alb_perfs = array(); $q = "select distinct(ap.id_albumu) from performers p left join albumy_perf ap on p.id=ap.id_perf where p.id='$wyk_id'"; $perfs = $this->db->selectTable($q); if(count($perfs))foreach($perfs as $v) { if($v['id_albumu']>0)$alb_perfs[] = $v['id_albumu']; } $this->slowa_klucz=$this->db->selectTable("select id_albumu from albumy where slowa_kluczowe_wyk like '%$wykonawca[name]%' and tytul not like '%^^^%'"); if(strlen($wykonawca['keywords'])>0){ $wyk_slowa=explode(",",$wykonawca['keywords']); foreach ($wyk_slowa as $k=>$v)$wyk_slowa[$k]=mysql_real_escape_string($v); $wyk_slowa="'".implode("','",$wyk_slowa)."'"; $this->wyk_powiazani=$this->db->selectTable("select * from performers where name in ($wyk_slowa) or keywords like '%$wykonawca[name]%'"); } else { $this->wyk_powiazani=$this->db->selectTable("select * from performers where keywords like '%$wykonawca[name]%'"); } foreach($this->slowa_klucz as $k=>$n){ $alb_id = $n['id_albumu']; $this->slowa_klucz[$k] = $this->albumy->album($alb_id); } /* if($wyk_id>0){ $q = "select distinct(a.id_albumu) from czasopisma c left join albumy a on c.id_pisma=a.id_pisma where c.id_pisma='$wyk_id'"; $pisma = $this->db->selectTable($q); if(count($pisma))foreach($pisma as $v) { if($v['id_albumu']>0)$alb_perfs[] = $v['id_albumu']; } } */ $skladanki_perf=array(); if($wyk_id>0){ $q = "select name from performers where id='$wyk_id'"; $wyk_tmp = $this->db->selectTable($q); $wyk=array(); if(count($wyk_tmp)) foreach($wyk_tmp as $v) { $wyk[] = "'".mysql_real_escape_string($v['name'])."'"; } if(count($wyk)>0){ $wyk = implode(",",$wyk); $q = "select distinct(album_id) from tracks where wykonawca in ($wyk)"; $track_perfs = $this->db->selectTable($q); if(count($track_perfs)) foreach($track_perfs as $v) { if($v['album_id']>0)$skladanki_perf[] = $v['album_id']; } } } unset($pisma,$perfs,$q); } if(count($alb_perfs)>0){ $ancls=join(",",$alb_perfs); $q = "select id_albumu from albumy where albumy.id_albumu in ($ancls) and albumy.aktywny != 'N' and albumy.tytul not like '%^^^%' order by albumy.data_edycji_sort desc";//order by albumy.tytul asc limit $offset,$real_limit"; $albums = $this->db->selectTable($q); } else { $albums = array(); } foreach($albums as $k=>$n) { $alb_id = $n['id_albumu']; $albums[$k] = $this->albumy->album($alb_id); } $this->wyniki = $albums; $this->typ='advance'; //skladaniki if(count($skladanki_perf)>0){ $skla=join(",",$skladanki_perf); $q = "select id_albumu from albumy where albumy.id_albumu in ($skla) and albumy.aktywny != 'N' and albumy.tytul not like '%^^^%' order by albumy.data_edycji_sort desc";//order by albumy.tytul asc limit $offset,$real_limit"; //echo $q; $skladanki= $this->db->selectTable($q); } else { $skladanki = array(); } foreach($skladanki as $k=>$n) { $alb_id = $n['id_albumu']; $skladanki[$k] = $this->albumy->album($alb_id); } $this->skladanki = $skladanki; if(!count($albums)>0 and !count($skladanki)>0 and !count($this->slowa_klucz)>0 and !count($this->wyk_powiazani)>0){ $this->msg = $msg; } } } ?>