%PDF- %PDF-
Direktori : /home/nailstv/www/ |
Current File : /home/nailstv/www/tags.php |
<?php require_once 'config/config.php'; $p['title'] = 'Nails TV - Tags'; $p['desc'] = 'A műköröm .tv címkék segítséget nyújtanak a műkörmös szakemberek számára a keresett műköröm videó megtalálásában. Legyen az műköröm építés, vagy díszítés, zselé vagy porcelán köröm. Step by Step videók.'; $p['keywords'] = 'műköröm, körömdíszítés, köröm, építés, díszítés, videó, step by step, videók, porcelán, zselé'; $p['pagename'] = 'Tags'; $p['active'] = 'Cimkék' ; if(!empty($uri[2])) { $_GET['view'] = $uri[2]; } elseif(!empty($uri[1])) { $u = explode('.', $uri[1]); $_GET['id'] = end(explode('-', $u[0])); } $page = new Page(Registry::get('site'), false, $p); Registry::set('page', $page); $page->assign('content', content($uri)); $page->display('page.tpl.html'); //////////////////////////////////////////////////////////////////////////////// function content($uri) { $c = new Content(); Page::seoFromDb(1); if(!empty($_POST)){ $db = Registry::get('db'); if(!empty($_POST['cimkeSearch'])) { $k = htmlspecialchars(stripslashes($_POST['cimkeSearch'])); $k = urldecode(substr($k, 0, 100)); $_SESSION['cimkeSearch'] = $k; } elseif($_POST && empty($_POST['cimkeSearch'])) { $_SESSION['cimkeSearch'] = ''; } if(empty($_SESSION['cimkeSearch'])) return $c->fetch('cimkek.tpl.html'); Registry::get('page')->assign('title', $_SESSION['cimkeSearch']); Registry::get('page')->assign('keywords', $_SESSION['cimkeSearch']); $sql = "SELECT c.id, c.url, c.nev FROM cimkek c WHERE c.storno = 'f' AND c.aktiv = 't' AND c.nev LIKE '%" . $_SESSION['cimkeSearch'] . "%' ORDER BY c.nev, c.sorrend"; $cimkek = $db->GetArray($sql); foreach($cimkek as $key=>$val){ $cimkek[$key]['videoSzam'] = getVideoNum($val['id']); $cimkek[$key]['initial'] = strtoupper(substr($val['nev'], 0, 1)); } $c->assign('alpha', alpha()); $c->assign('cimkek', $cimkek); $c->assign('top_cimkek', top_cimkek()); } else { if(isset($_GET['id'])){ $db = Registry::get('db'); settype($_GET['id'], 'integer'); $bind = array($_GET['id']); $sql = "SELECT c.id, c.nev, c.szoveg, c.url, c.title, c.description, c.keywords FROM cimkek c WHERE c.id = ? AND c.storno = 'f' AND c.aktiv = 't'"; $row = $db->GetRow($sql, $bind); Registry::get('page')->assign('title', $row['title']); Registry::get('page')->assign('description', $row['description']); Registry::get('page')->assign('keywords', $row['keywords']); if(empty($row['id'])) { header("Location: " . Registry::get('wwwroot') . "/tags"); die; } else { $c->assign('cimke', $row); $c->assign('videok', videok($row['id'])); } } elseif(!empty($_GET['view'])) { // nézetek $db = Registry::get('db'); $bind = array($uri[1]); $sql = "SELECT id FROM cimkek WHERE url = ? AND aktiv = 't' AND storno = 'f'"; $row = $db->GetRow($sql, $bind); if(!empty($row['id'])){ $bind = array($row['id']); $sql = "SELECT c.id, c.nev, c.szoveg, c.url, c.title, c.description, c.keywords FROM cimkek c WHERE c.id = ? AND c.storno = 'f' AND c.aktiv = 't'"; $row = $db->GetRow($sql, $bind); Registry::get('page')->assign('title', $row['title']); Registry::get('page')->assign('description', $row['description']); Registry::get('page')->assign('keywords', $row['keywords']); if(empty($row['id'])) { header("Location: " . Registry::get('wwwroot') . "/tags"); die; } else { $c->assign('cimke', $row); switch($_GET['view']){ case 'uj': getVideosByDatum($row['id'], $c); break; case 'nezettseg': $tabla = 'vt_cimkek_nezettseg_full'; getVideosByNezettseg($row['id'], $c, $tabla); break; case 'nezettseghavi': $tabla = 'vt_cimkek_nezettseg_havi'; getVideosByNezettseg($row['id'], $c, $tabla); break; case 'nezettsegheti': $tabla = 'vt_cimkek_nezettseg_heti'; getVideosByNezettseg($row['id'], $c, $tabla); break; case 'nezettsegnapi': $tabla = 'vt_cimkek_nezettseg_napi'; getVideosByNezettseg($row['id'], $c, $tabla); break; case 'ertekeles': $tabla = 'vt_cimkek_szavazas_full'; getVideosByErtekeles($row['id'], $c, $tabla); break; case 'ertekeleshavi': $tabla = 'vt_cimkek_szavazas_havi'; getVideosByErtekeles($row['id'], $c, $tabla); break; case 'ertekelesheti': $tabla = 'vt_cimkek_szavazas_heti'; getVideosByErtekeles($row['id'], $c, $tabla); break; case 'ertekelesnapi': $tabla = 'vt_cimkek_szavazas_napi'; getVideosByErtekeles($row['id'], $c, $tabla); break; case 'szavazat': getVideosBySzavazatszam($row['id'], $c, 'full'); break; case 'szavazathavi': getVideosBySzavazatszam($row['id'], $c, 'month'); break; case 'szavazatheti': getVideosBySzavazatszam($row['id'], $c, 'week'); break; case 'szavazatnapi': getVideosBySzavazatszam($row['id'], $c, 'day'); break; case 'kedvenc': $tabla = 'vt_cimkek_kedvenc_full'; getVideosByKedvencszam($row['id'], $c, $tabla); break; case 'kedvenchavi': $tabla = 'vt_cimkek_kedvenc_havi'; getVideosByKedvencszam($row['id'], $c, $tabla); break; case 'kedvencheti': $tabla = 'vt_cimkek_kedvenc_heti'; getVideosByKedvencszam($row['id'], $c, $tabla); break; case 'kedvencnapi': $tabla = 'vt_cimkek_kedvenc_napi'; getVideosByKedvencszam($row['id'], $c, $tabla); break; default: die('????'); break; } } } else { //eldob header("Location: " . Registry::get('wwwroot') . "/channels"); die; } } else { $c->assign('cimkek', cimkek()); $c->assign('alpha', alpha()); $c->assign('top_cimkek', top_cimkek()); } } return $c->fetch('cimkek.tpl.html'); } function cimkek() { $db = Registry::get('db'); $sql = "SELECT c.id, c.url, c.nev FROM cimkek c WHERE c.storno = 'f' AND c.aktiv = 't' ORDER BY c.nev, c.sorrend"; $cimkek = $db->GetArray($sql); foreach($cimkek as $key=>$val){ $cimkek[$key]['videoSzam'] = getVideoNum($val['id']); //$cimkek[$key]['initial'] = strtoupper(mb_substr($val['nev'], 0, 1,'utf-8')); $cimkek[$key]['initial'] = mb_convert_case(mb_substr($val['nev'], 0, 1,'utf-8'), MB_CASE_UPPER, "UTF-8"); } return $cimkek; } function getVideoNum($cimke_id) { $db = Registry::get('db'); $bind = array($cimke_id); $sql = "SELECT COUNT(ctv.id) as videoszam FROM cimke_to_video ctv LEFT JOIN video v ON v.id = ctv.video_id WHERE v.storno = 'f' AND v.aktiv = 't' AND ctv.cimkek_id = ? GROUP BY ctv.cimkek_id"; $videokszama = $db->GetRow($sql, $bind); if(empty($videokszama['videoszam'])){ $videokszama['videoszam'] = 0; } return $videokszama['videoszam']; } function alpha() { $db = Registry::get('db'); $sql = "SELECT c.nev FROM cimkek c WHERE c.storno = 'f' AND c.aktiv = 't' ORDER BY c.nev, c.sorrend"; $cimkek = $db->GetArray($sql); $initials = array(); foreach($cimkek as $key=>$val){ $cimkek[$key]['initial'] = strtoupper(substr($val['nev'], 0, 1)); if(!in_array($cimkek[$key]['initial'], $initials)){ $initials[] = $cimkek[$key]['initial']; } } $alphabet = array('A', 'Á', 'B', 'C', 'Cs', 'D', 'Dz', 'Dzs', 'E', 'É', 'F', 'G', 'Gy', 'H', 'I', 'Í', 'J', 'K', 'L', 'Ly', 'M', 'N', 'Ny', 'O', 'Ó', 'Ö', 'Ő', 'P', 'Q', 'R', 'S', 'Sz', 'T', 'Ty', 'U', 'Ú', 'Ü', 'Ű', 'V', 'W', 'X', 'Y', 'Z', 'Zs'); $eredmeny = array_intersect($initials, $alphabet); return $eredmeny; } function top_cimkek() { $db = Registry::get('db'); $sql = "SELECT COUNT(ctv.id) as videoszam, c.nev, c.url, c.id FROM cimke_to_video ctv LEFT JOIN video v ON v.id = ctv.video_id LEFT JOIN cimkek c ON c.id = ctv.cimkek_id WHERE v.storno = 'f' AND v.aktiv = 't' GROUP BY ctv.cimkek_id ORDER BY videoszam DESC LIMIT 0,10"; $top = $db->GetArray($sql); return $top; } function videok($id) { $db = Registry::get('db'); $bind = array($id); $sql = "SELECT v.id, v.cim, v.datum, v.kep, v.html, v.hossz, /* COUNT(vn.id) as nezettseg, */ ka.url, vtvszf.szazalek as ertekeles, k.file, k.id as kep_id FROM cimke_to_video ctv LEFT JOIN video v ON v.id = ctv.video_id " . $db->joinDefPic('video', 'v') . " /* LEFT JOIN video_nezettseg vn ON vn.video_id = v.id */ LEFT JOIN kategoria ka ON ka.id = v.kategoria_id LEFT JOIN vt_video_szavazas_full vtvszf ON vtvszf.video_id = v.id WHERE v.storno = 'f' AND v.aktiv = 't' AND ctv.cimkek_id = ? AND ka.storno = 'f' GROUP BY v.id ORDER BY v.sorrend_cimkek"; $videok = $db->GetArray($sql, $bind); $videok = Video::getViews($videok); foreach($videok as $key=>$val){ $videok[$key]['url'] = $val['url'] . '/' . String::fancyurl($val['cim']) . '-' . $val['id']; $videok[$key]['hossz'] = substr($val['hossz'], 0, 5); $videok[$key]['ertekeles'] = intval($val['ertekeles']); $videok[$key]['datum'] = str_replace('-','.',$val['datum']); } return $videok; } function getVideosByDatum($cimkek_id, $c) { $db = Registry::get('db'); $bind = array($cimkek_id); $sql = "SELECT v.id, v.cim, v.datum, v.hossz, /* COUNT(vn.id) as nezettseg, */ ka.url, vtvszf.szazalek as ertekeles, k.file, k.id as kep_id FROM video v " . $db->joinDefPic('video', 'v') . " /* LEFT JOIN video_nezettseg vn ON vn.video_id = v.id */ LEFT JOIN kategoria ka ON ka.id = v.kategoria_id LEFT JOIN vt_video_szavazas_full vtvszf ON vtvszf.video_id = v.id LEFT JOIN cimke_to_video ctv ON ctv.video_id = v.id LEFT JOIN cimkek c ON c.id = ctv.cimkek_id WHERE v.storno = 'f' AND v.aktiv = 't' AND ka.storno = 'f' AND c.id = ? GROUP BY v.id ORDER BY v.datum DESC, v.sorrend"; $pager = new Pager; $limit = 20; $r = $db->PageExecute($sql, $limit, $pager->current, $bind); $pager->setup($r->LastPageNo(), $r->RecordCount(), $limit); $c->assign('n', $r->_maxRecordCount - ($limit * ($pager->current - 1))); $c->assign('pager', $pager->show('pager.tpl.html')); $videok = $r->GetArray(); $videok = Video::getViews($videok); foreach($videok as $key=>$val){ $videok[$key]['url'] = $val['url'] . '/' . String::fancyurl($val['cim']) . '-' . $val['id']; $videok[$key]['hossz'] = substr($val['hossz'], 0, 5); $videok[$key]['ertekeles'] = intval($val['ertekeles']); $videok[$key]['datum'] = str_replace('-','.',$val['datum']); } if(empty($videok)) { $videok = videok($cimkek_id); } $c->assign('videok', $videok); return; } function getVideosByNezettseg($cimkek_id, $c, $tabla) { $db = Registry::get('db'); $bind = array($cimkek_id); if(empty($tabla)){ $tabe = "vt_cimkek_nezettseg_full"; } /* $sql = "SELECT v.id, v.cim, v.datum, v.hossz, vtvnf.nezettseg as nezettseg, ka.url, vtvszf.szazalek as ertekeles, k.file, k.id as kep_id FROM ". $tabla ." vnf LEFT JOIN video v ON vnf.video_id = v.id " . $db->joinDefPic('video', 'v') . " LEFT JOIN kategoria ka ON ka.id = v.kategoria_id LEFT JOIN vt_video_szavazas_full vtvszf ON vtvszf.video_id = v.id LEFT JOIN vt_video_nezettseg_full vtvnf ON vtvnf.video_id = v.id LEFT JOIN cimkek c ON c.id = vnf.cimkek_id WHERE v.storno = 'f' AND v.aktiv = 't' AND ka.storno = 'f' AND c.id = ? GROUP BY v.id ORDER BY vnf.nezettseg DESC, v.sorrend_cimkek"; */ $sql = "SELECT v.id, v.cim, v.datum, v.hossz, v.osszes_nezettseg,/* COUNT(vn.id) as nezettseg, */ ka.url, vtvszf.szazalek as ertekeles, k.file, k.id as kep_id FROM video v " . $db->joinDefPic('video', 'v') . " /* LEFT JOIN video_nezettseg vn ON vn.video_id = v.id */ LEFT JOIN kategoria ka ON ka.id = v.kategoria_id LEFT JOIN vt_video_szavazas_full vtvszf ON vtvszf.video_id = v.id LEFT JOIN cimke_to_video ctv ON ctv.video_id = v.id LEFT JOIN cimkek c ON c.id = ctv.cimkek_id WHERE v.storno = 'f' AND v.aktiv = 't' AND ka.storno = 'f' AND c.id = ? GROUP BY v.id ORDER BY v.osszes_nezettseg DESC,v.sorrend_cimkek"; $pager = new Pager; $limit = 20; $r = $db->PageExecute($sql, $limit, $pager->current, $bind); $pager->setup($r->LastPageNo(), $r->RecordCount(), $limit); $c->assign('n', $r->_maxRecordCount - ($limit * ($pager->current - 1))); $c->assign('pager', $pager->show('pager.tpl.html')); $videok = $r->GetArray(); foreach($videok as $key=>$val){ $videok[$key]['url'] = $val['url'] . '/' . String::fancyurl($val['cim']) . '-' . $val['id']; $videok[$key]['hossz'] = substr($val['hossz'], 0, 5); $videok[$key]['ertekeles'] = intval($val['ertekeles']); $videok[$key]['datum'] = str_replace('-','.',$val['datum']); } if(empty($videok)) { $videok = videok($cimkek_id); } $c->assign('videok', $videok); return; } function getVideosByErtekeles($cimkek_id, $c, $tabla) { $db = Registry::get('db'); $bind = array($cimkek_id); if(empty($tabla)){ $tabe = "vt_cimkek_szavazas_full"; } $sql = "SELECT v.id, v.cim, v.datum, v.hossz, /* vtvnf.nezettseg as nezettseg, */ ka.url, vtvszf.szazalek as ertekeles, k.file, k.id as kep_id FROM ".$tabla." vnf LEFT JOIN video v ON vnf.video_id = v.id " . $db->joinDefPic('video', 'v') . " LEFT JOIN kategoria ka ON ka.id = v.kategoria_id LEFT JOIN vt_video_szavazas_full vtvszf ON vtvszf.video_id = v.id /* LEFT JOIN vt_video_nezettseg_full vtvnf ON vtvnf.video_id = v.id */ LEFT JOIN cimkek c ON c.id = vnf.cimkek_id WHERE v.storno = 'f' AND v.aktiv = 't' AND ka.storno = 'f' AND c.id = ? GROUP BY v.id ORDER BY vnf.szazalek DESC, ertekeles DESC, vnf.szavazatok DESC, v.sorrend_cimkek"; $pager = new Pager; $limit = 20; $r = $db->PageExecute($sql, $limit, $pager->current, $bind); $pager->setup($r->LastPageNo(), $r->RecordCount(), $limit); $c->assign('n', $r->_maxRecordCount - ($limit * ($pager->current - 1))); $c->assign('pager', $pager->show('pager.tpl.html')); $videok = $r->GetArray(); $videok = Video::getViews($videok); foreach($videok as $key=>$val){ $videok[$key]['url'] = $val['url'] . '/' . String::fancyurl($val['cim']) . '-' . $val['id']; $videok[$key]['hossz'] = substr($val['hossz'], 0, 5); $videok[$key]['ertekeles'] = intval($val['ertekeles']); $videok[$key]['datum'] = str_replace('-','.',$val['datum']); } if(empty($videok)) { $videok = videok($cimkek_id); } $c->assign('videok', $videok); return; } function getVideosBySzavazatszam($cimkek_id, $c, $ido) { $db = Registry::get('db'); $bind = array($cimkek_id); if(empty($tabla)){ $tabe = "vt_cimkek_szavazas_full"; } if($ido == 'full' || empty($ido)){ $where = ''; } else { $where = ' AND ((vsz.datum > (now() - interval 1 '.$ido.')) OR vsz.datum IS NULL)'; } $sql = "SELECT v.id, v.cim, v.datum, v.hossz, /* vtvnf.nezettseg as nezettseg, */ COUNT(vsz.id) as szavazatok, ka.url, vtvszf.szazalek as ertekeles, k.file, k.id as kep_id FROM video v " . $db->joinDefPic('video', 'v') . " LEFT JOIN video_szavazas vsz ON vsz.video_id = v.id LEFT JOIN video_nezettseg vn ON vn.video_id = v.id LEFT JOIN kategoria ka ON ka.id = v.kategoria_id LEFT JOIN vt_video_szavazas_full vtvszf ON vtvszf.video_id = v.id /* LEFT JOIN vt_video_nezettseg_full vtvnf ON vtvnf.video_id = v.id */ LEFT JOIN cimke_to_video ctv ON ctv.video_id = v.id LEFT JOIN cimkek c ON c.id = ctv.cimkek_id WHERE v.storno = 'f' AND v.aktiv = 't' AND szavazatok > 0 AND ka.storno = 'f' AND c.id = ? ".$where." GROUP BY v.id ORDER BY szavazatok DESC, ertekeles DESC, v.sorrend_cimkek"; $pager = new Pager; $limit = 20; $r = $db->PageExecute($sql, $limit, $pager->current, $bind); $pager->setup($r->LastPageNo(), $r->RecordCount(), $limit); $c->assign('n', $r->_maxRecordCount - ($limit * ($pager->current - 1))); $c->assign('pager', $pager->show('pager.tpl.html')); $videok = $r->GetArray(); $videok = Video::getViews($videok); foreach($videok as $key=>$val){ $videok[$key]['url'] = $val['url'] . '/' . String::fancyurl($val['cim']) . '-' . $val['id']; $videok[$key]['hossz'] = substr($val['hossz'], 0, 5); $videok[$key]['ertekeles'] = intval($val['ertekeles']); $videok[$key]['datum'] = str_replace('-','.',$val['datum']); } if(empty($videok)) { $videok = videok($cimkek_id); } $c->assign('videok', $videok); return; } function getVideosByKedvencszam($cimkek_id, $c, $tabla) { $db = Registry::get('db'); $bind = array($cimkek_id); if(empty($tabla)){ $tabe = "vt_cimkek_kedvenc_full"; } $sql = "SELECT v.id, v.cim, v.datum, v.hossz, /* vtvnf.nezettseg as nezettseg, */ ka.url, vtvszf.szazalek as ertekeles, k.file, k.id as kep_id FROM ".$tabla." vnf LEFT JOIN video v ON vnf.video_id = v.id " . $db->joinDefPic('video', 'v') . " LEFT JOIN kategoria ka ON ka.id = v.kategoria_id LEFT JOIN vt_video_szavazas_full vtvszf ON vtvszf.video_id = v.id /* LEFT JOIN vt_video_nezettseg_full vtvnf ON vtvnf.video_id = v.id */ LEFT JOIN cimkek c ON c.id = vnf.cimkek_id WHERE v.storno = 'f' AND v.aktiv = 't' AND ka.storno = 'f' AND c.id = ? GROUP BY v.id ORDER BY vnf.kedvenc DESC, ertekeles DESC, v.sorrend_cimkek"; $pager = new Pager; $limit = 20; $r = $db->PageExecute($sql, $limit, $pager->current, $bind); $pager->setup($r->LastPageNo(), $r->RecordCount(), $limit); $c->assign('n', $r->_maxRecordCount - ($limit * ($pager->current - 1))); $c->assign('pager', $pager->show('pager.tpl.html')); $videok = $r->GetArray(); $videok = Video::getViews($videok); foreach($videok as $key=>$val){ $videok[$key]['url'] = $val['url'] . '/' . String::fancyurl($val['cim']) . '-' . $val['id']; $videok[$key]['hossz'] = substr($val['hossz'], 0, 5); $videok[$key]['ertekeles'] = intval($val['ertekeles']); $videok[$key]['datum'] = str_replace('-','.',$val['datum']); } if(empty($videok)) { $videok = videok($cimkek_id); } $c->assign('videok', $videok); return; } ?>